src/share/vm/runtime/java.hpp

Thu, 04 Dec 2008 17:29:56 -0800

author
poonam
date
Thu, 04 Dec 2008 17:29:56 -0800
changeset 900
dc16daa0329d
parent 677
d95b224e9f17
child 1907
c18cbe5936b8
permissions
-rw-r--r--

6739363: Xcheck jni doesn't check native function arguments
Summary: Fix adds support for verifying arguments with -Xcheck:jni.
Reviewed-by: coleenp

     1 /*
     2  * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
    21  * have any questions.
    22  *
    23  */
    25 // Register function to be called by before_exit
    26 extern "C" { void register_on_exit_function(void (*func)(void)) ;}
    28 // Execute code before all handles are released and thread is killed; prologue to vm_exit
    29 extern void before_exit(JavaThread * thread);
    31 // Forced VM exit (i.e, internal error or JVM_Exit)
    32 extern void vm_exit(int code);
    34 // Wrapper for ::exit()
    35 extern void vm_direct_exit(int code);
    37 // Shutdown the VM but do not exit the process
    38 extern void vm_shutdown();
    39 // Shutdown the VM and abort the process
    40 extern void vm_abort(bool dump_core=true);
    42 // Trigger any necessary notification of the VM being shutdown
    43 extern void notify_vm_shutdown();
    45 // VM exit if error occurs during initialization of VM
    46 extern void vm_exit_during_initialization(Handle exception);
    47 extern void vm_exit_during_initialization(symbolHandle exception_name, const char* message);
    48 extern void vm_exit_during_initialization(const char* error, const char* message = NULL);
    49 extern void vm_shutdown_during_initialization(const char* error, const char* message = NULL);
    51 /**
    52  * Discovering the JDK_Version during initialization is tricky when the
    53  * running JDK is less than JDK6.  For JDK6 and greater, a "GetVersion"
    54  * function exists in libjava.so and we simply call it during the
    55  * 'initialize()' call to find the version.  For JDKs with version < 6, no
    56  * such call exists and we have to probe the JDK in order to determine
    57  * the exact version.  This probing cannot happen during late in
    58  * the VM initialization process so there's a period of time during
    59  * initialization when we don't know anything about the JDK version other than
    60  * that it less than version 6.  This is the "partially initialized" time,
    61  * when we can answer only certain version queries (such as, is the JDK
    62  * version greater than 5?  Answer: no).  Once the JDK probing occurs, we
    63  * know the version and are considered fully initialized.
    64  */
    65 class JDK_Version VALUE_OBJ_CLASS_SPEC {
    66   friend class VMStructs;
    67   friend class Universe;
    68   friend void JDK_Version_init();
    69  private:
    71   static JDK_Version _current;
    73   // In this class, we promote the minor version of release to be the
    74   // major version for releases >= 5 in anticipation of the JDK doing the
    75   // same thing.  For example, we represent "1.5.0" as major version 5 (we
    76   // drop the leading 1 and use 5 as the 'major').
    78   uint8_t _major;
    79   uint8_t _minor;
    80   uint8_t _micro;
    81   uint8_t _update;
    82   uint8_t _special;
    83   uint8_t _build;
    85   // If partially initialized, the above fields are invalid and we know
    86   // that we're less than major version 6.
    87   bool _partially_initialized;
    89   bool _thread_park_blocker;
    91   bool is_valid() const {
    92     return (_major != 0 || _partially_initialized);
    93   }
    95   // initializes or partially initializes the _current static field
    96   static void initialize();
    98   // Completes initialization for a pre-JDK6 version.
    99   static void fully_initialize(uint8_t major, uint8_t minor = 0,
   100                                uint8_t micro = 0, uint8_t update = 0);
   102  public:
   104   // Returns true if the the current version has only been partially initialized
   105   static bool is_partially_initialized() {
   106     return _current._partially_initialized;
   107   }
   109   JDK_Version() : _major(0), _minor(0), _micro(0), _update(0),
   110                   _special(0), _build(0), _partially_initialized(false),
   111                   _thread_park_blocker(false) {}
   113   JDK_Version(uint8_t major, uint8_t minor = 0, uint8_t micro = 0,
   114               uint8_t update = 0, uint8_t special = 0, uint8_t build = 0,
   115               bool thread_park_blocker = false) :
   116       _major(major), _minor(minor), _micro(micro), _update(update),
   117       _special(special), _build(build), _partially_initialized(false),
   118       _thread_park_blocker(thread_park_blocker) {}
   120   // Returns the current running JDK version
   121   static JDK_Version current() { return _current; }
   123   // Factory methods for convenience
   124   static JDK_Version jdk(uint8_t m) {
   125     return JDK_Version(m);
   126   }
   128   static JDK_Version jdk_update(uint8_t major, uint8_t update_number) {
   129     return JDK_Version(major, 0, 0, update_number);
   130   }
   132   uint8_t major_version() const          { return _major; }
   133   uint8_t minor_version() const          { return _minor; }
   134   uint8_t micro_version() const          { return _micro; }
   135   uint8_t update_version() const         { return _update; }
   136   uint8_t special_update_version() const { return _special; }
   137   uint8_t build_number() const           { return _build; }
   139   bool supports_thread_park_blocker() const {
   140     return _thread_park_blocker;
   141   }
   143   // Performs a full ordering comparison using all fields (update, build, etc.)
   144   int compare(const JDK_Version& other) const;
   146   /**
   147    * Performs comparison using only the major version, returning negative
   148    * if the major version of 'this' is less than the parameter, 0 if it is
   149    * equal, and a positive value if it is greater.
   150    */
   151   int compare_major(int version) const {
   152     if (_partially_initialized) {
   153       if (version >= 6) {
   154         return -1;
   155       } else {
   156         assert(false, "Can't make this comparison during init time");
   157         return -1; // conservative
   158       }
   159     } else {
   160       return major_version() - version;
   161     }
   162   }
   164   void to_string(char* buffer, size_t buflen) const;
   166   // Convenience methods for queries on the current major/minor version
   167   static bool is_jdk12x_version() {
   168     return current().compare_major(2) == 0;
   169   }
   171   static bool is_jdk13x_version() {
   172     return current().compare_major(3) == 0;
   173   }
   175   static bool is_jdk14x_version() {
   176     return current().compare_major(4) == 0;
   177   }
   179   static bool is_jdk15x_version() {
   180     return current().compare_major(5) == 0;
   181   }
   183   static bool is_jdk16x_version() {
   184     return current().compare_major(6) == 0;
   185   }
   187   static bool is_jdk17x_version() {
   188     return current().compare_major(7) == 0;
   189   }
   191   static bool is_gte_jdk13x_version() {
   192     return current().compare_major(3) >= 0;
   193   }
   195   static bool is_gte_jdk14x_version() {
   196     return current().compare_major(4) >= 0;
   197   }
   199   static bool is_gte_jdk15x_version() {
   200     return current().compare_major(5) >= 0;
   201   }
   203   static bool is_gte_jdk16x_version() {
   204     return current().compare_major(6) >= 0;
   205   }
   207   static bool is_gte_jdk17x_version() {
   208     return current().compare_major(7) >= 0;
   209   }
   210 };

mercurial