src/share/vm/classfile/javaClasses.hpp

Mon, 25 Jun 2012 21:33:35 -0400

author
coleenp
date
Mon, 25 Jun 2012 21:33:35 -0400
changeset 3875
246d977b51f2
parent 3869
58ad5f22317e
child 3969
1d7922586cf6
permissions
-rw-r--r--

7178670: runtime/7158800/BadUtf8.java fails in SymbolTable::rehash_table
Summary: Cannot delete _buckets and HashtableEntries in shared space (CDS)
Reviewed-by: acorn, kvn, dlong, dcubed, kamg

     1 /*
     2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 #ifndef SHARE_VM_CLASSFILE_JAVACLASSES_HPP
    26 #define SHARE_VM_CLASSFILE_JAVACLASSES_HPP
    28 #include "classfile/systemDictionary.hpp"
    29 #include "jvmtifiles/jvmti.h"
    30 #include "oops/oop.hpp"
    31 #include "runtime/os.hpp"
    32 #include "utilities/utf8.hpp"
    34 // Interface for manipulating the basic Java classes.
    35 //
    36 // All dependencies on layout of actual Java classes should be kept here.
    37 // If the layout of any of the classes above changes the offsets must be adjusted.
    38 //
    39 // For most classes we hardwire the offsets for performance reasons. In certain
    40 // cases (e.g. java.security.AccessControlContext) we compute the offsets at
    41 // startup since the layout here differs between JDK1.2 and JDK1.3.
    42 //
    43 // Note that fields (static and non-static) are arranged with oops before non-oops
    44 // on a per class basis. The offsets below have to reflect this ordering.
    45 //
    46 // When editing the layouts please update the check_offset verification code
    47 // correspondingly. The names in the enums must be identical to the actual field
    48 // names in order for the verification code to work.
    51 // Interface to java.lang.String objects
    53 class java_lang_String : AllStatic {
    54  private:
    55   static int value_offset;
    56   static int offset_offset;
    57   static int count_offset;
    58   static int hash_offset;
    60   static bool initialized;
    62   static Handle basic_create(int length, bool tenured, TRAPS);
    63   static Handle basic_create_from_unicode(jchar* unicode, int length, bool tenured, TRAPS);
    65   static void set_value( oop string, typeArrayOop buffer) {
    66     assert(initialized, "Must be initialized");
    67     string->obj_field_put(value_offset,  (oop)buffer);
    68   }
    69   static void set_offset(oop string, int offset) {
    70     assert(initialized, "Must be initialized");
    71     if (offset_offset > 0) {
    72       string->int_field_put(offset_offset, offset);
    73     }
    74   }
    75   static void set_count( oop string, int count) {
    76     assert(initialized, "Must be initialized");
    77     if (count_offset > 0) {
    78       string->int_field_put(count_offset,  count);
    79     }
    80   }
    82  public:
    83   static void compute_offsets();
    85   // Instance creation
    86   static Handle create_from_unicode(jchar* unicode, int len, TRAPS);
    87   static Handle create_tenured_from_unicode(jchar* unicode, int len, TRAPS);
    88   static oop    create_oop_from_unicode(jchar* unicode, int len, TRAPS);
    89   static Handle create_from_str(const char* utf8_str, TRAPS);
    90   static oop    create_oop_from_str(const char* utf8_str, TRAPS);
    91   static Handle create_from_symbol(Symbol* symbol, TRAPS);
    92   static Handle create_from_platform_dependent_str(const char* str, TRAPS);
    93   static Handle char_converter(Handle java_string, jchar from_char, jchar to_char, TRAPS);
    95   static bool has_offset_field()  {
    96     assert(initialized, "Must be initialized");
    97     return (offset_offset > 0);
    98   }
   100   static bool has_count_field()  {
   101     assert(initialized, "Must be initialized");
   102     return (count_offset > 0);
   103   }
   105   static bool has_hash_field()  {
   106     assert(initialized, "Must be initialized");
   107     return (hash_offset > 0);
   108   }
   110   static int value_offset_in_bytes()  {
   111     assert(initialized && (value_offset > 0), "Must be initialized");
   112     return value_offset;
   113   }
   114   static int count_offset_in_bytes()  {
   115     assert(initialized && (count_offset > 0), "Must be initialized");
   116     return count_offset;
   117   }
   118   static int offset_offset_in_bytes() {
   119     assert(initialized && (offset_offset > 0), "Must be initialized");
   120     return offset_offset;
   121   }
   122   static int hash_offset_in_bytes()   {
   123     assert(initialized && (hash_offset > 0), "Must be initialized");
   124     return hash_offset;
   125   }
   127   // Accessors
   128   static typeArrayOop value(oop java_string) {
   129     assert(initialized && (value_offset > 0), "Must be initialized");
   130     assert(is_instance(java_string), "must be java_string");
   131     return (typeArrayOop) java_string->obj_field(value_offset);
   132   }
   133   static int offset(oop java_string) {
   134     assert(initialized, "Must be initialized");
   135     assert(is_instance(java_string), "must be java_string");
   136     if (offset_offset > 0) {
   137       return java_string->int_field(offset_offset);
   138     } else {
   139       return 0;
   140     }
   141   }
   142   static int length(oop java_string) {
   143     assert(initialized, "Must be initialized");
   144     assert(is_instance(java_string), "must be java_string");
   145     if (count_offset > 0) {
   146       return java_string->int_field(count_offset);
   147     } else {
   148       return ((typeArrayOop)java_string->obj_field(value_offset))->length();
   149     }
   150   }
   151   static int utf8_length(oop java_string);
   153   // String converters
   154   static char*  as_utf8_string(oop java_string);
   155   static char*  as_utf8_string(oop java_string, char* buf, int buflen);
   156   static char*  as_utf8_string(oop java_string, int start, int len);
   157   static char*  as_platform_dependent_str(Handle java_string, TRAPS);
   158   static jchar* as_unicode_string(oop java_string, int& length);
   160   // Compute the hash value for a java.lang.String object which would
   161   // contain the characters passed in.
   162   //
   163   // As the hash value used by the String object itself, in
   164   // String.hashCode().  This value is normally calculated in Java code
   165   // in the String.hashCode method(), but is precomputed for String
   166   // objects in the shared archive file.
   167   // hash P(31) from Kernighan & Ritchie
   168   //
   169   // For this reason, THIS ALGORITHM MUST MATCH String.toHash().
   170   template <typename T> static unsigned int to_hash(T* s, int len) {
   171     unsigned int h = 0;
   172     while (len-- > 0) {
   173       h = 31*h + (unsigned int) *s;
   174       s++;
   175     }
   176     return h;
   177   }
   178   static unsigned int to_hash(oop java_string);
   180   // This is the string hash code used by the StringTable, which may be
   181   // the same as String.toHash or an alternate hash code.
   182   static unsigned int hash_string(oop java_string);
   184   static bool equals(oop java_string, jchar* chars, int len);
   186   // Conversion between '.' and '/' formats
   187   static Handle externalize_classname(Handle java_string, TRAPS) { return char_converter(java_string, '/', '.', THREAD); }
   188   static Handle internalize_classname(Handle java_string, TRAPS) { return char_converter(java_string, '.', '/', THREAD); }
   190   // Conversion
   191   static Symbol* as_symbol(Handle java_string, TRAPS);
   192   static Symbol* as_symbol_or_null(oop java_string);
   194   // Testers
   195   static bool is_instance(oop obj) {
   196     return obj != NULL && obj->klass() == SystemDictionary::String_klass();
   197   }
   199   // Debugging
   200   static void print(Handle java_string, outputStream* st);
   201   friend class JavaClasses;
   202 };
   205 // Interface to java.lang.Class objects
   207 #define CLASS_INJECTED_FIELDS(macro)                                       \
   208   macro(java_lang_Class, klass,                  object_signature,  false) \
   209   macro(java_lang_Class, resolved_constructor,   object_signature,  false) \
   210   macro(java_lang_Class, array_klass,            object_signature,  false) \
   211   macro(java_lang_Class, oop_size,               int_signature,     false) \
   212   macro(java_lang_Class, static_oop_field_count, int_signature,     false)
   214 class java_lang_Class : AllStatic {
   215   friend class VMStructs;
   217  private:
   218   // The fake offsets are added by the class loader when java.lang.Class is loaded
   220   static int _klass_offset;
   221   static int _resolved_constructor_offset;
   222   static int _array_klass_offset;
   224   static int _oop_size_offset;
   225   static int _static_oop_field_count_offset;
   227   static bool offsets_computed;
   228   static int classRedefinedCount_offset;
   230  public:
   231   static void compute_offsets();
   233   // Instance creation
   234   static oop  create_mirror(KlassHandle k, TRAPS);
   235   static void fixup_mirror(KlassHandle k, TRAPS);
   236   static oop  create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS);
   237   // Conversion
   238   static klassOop as_klassOop(oop java_class);
   239   static void set_klass(oop java_class, klassOop klass);
   240   static BasicType as_BasicType(oop java_class, klassOop* reference_klass = NULL);
   241   static BasicType as_BasicType(oop java_class, KlassHandle* reference_klass) {
   242     klassOop refk_oop = NULL;
   243     BasicType result = as_BasicType(java_class, &refk_oop);
   244     (*reference_klass) = KlassHandle(refk_oop);
   245     return result;
   246   }
   247   static Symbol* as_signature(oop java_class, bool intern_if_not_found, TRAPS);
   248   static void print_signature(oop java_class, outputStream *st);
   249   // Testing
   250   static bool is_instance(oop obj) {
   251     return obj != NULL && obj->klass() == SystemDictionary::Class_klass();
   252   }
   253   static bool is_primitive(oop java_class);
   254   static BasicType primitive_type(oop java_class);
   255   static oop primitive_mirror(BasicType t);
   256   // JVM_NewInstance support
   257   static methodOop resolved_constructor(oop java_class);
   258   static void set_resolved_constructor(oop java_class, methodOop constructor);
   259   // JVM_NewArray support
   260   static klassOop array_klass(oop java_class);
   261   static void set_array_klass(oop java_class, klassOop klass);
   262   // compiler support for class operations
   263   static int klass_offset_in_bytes()                { return _klass_offset; }
   264   static int resolved_constructor_offset_in_bytes() { return _resolved_constructor_offset; }
   265   static int array_klass_offset_in_bytes()          { return _array_klass_offset; }
   266   // Support for classRedefinedCount field
   267   static int classRedefinedCount(oop the_class_mirror);
   268   static void set_classRedefinedCount(oop the_class_mirror, int value);
   270   static int oop_size(oop java_class);
   271   static void set_oop_size(oop java_class, int size);
   272   static int static_oop_field_count(oop java_class);
   273   static void set_static_oop_field_count(oop java_class, int size);
   275   // Debugging
   276   friend class JavaClasses;
   277   friend class instanceKlass;   // verification code accesses offsets
   278   friend class ClassFileParser; // access to number_of_fake_fields
   279 };
   281 // Interface to java.lang.Thread objects
   283 class java_lang_Thread : AllStatic {
   284  private:
   285   // Note that for this class the layout changed between JDK1.2 and JDK1.3,
   286   // so we compute the offsets at startup rather than hard-wiring them.
   287   static int _name_offset;
   288   static int _group_offset;
   289   static int _contextClassLoader_offset;
   290   static int _inheritedAccessControlContext_offset;
   291   static int _priority_offset;
   292   static int _eetop_offset;
   293   static int _daemon_offset;
   294   static int _stillborn_offset;
   295   static int _stackSize_offset;
   296   static int _tid_offset;
   297   static int _thread_status_offset;
   298   static int _park_blocker_offset;
   299   static int _park_event_offset ;
   301   static void compute_offsets();
   303  public:
   304   // Instance creation
   305   static oop create();
   306   // Returns the JavaThread associated with the thread obj
   307   static JavaThread* thread(oop java_thread);
   308   // Set JavaThread for instance
   309   static void set_thread(oop java_thread, JavaThread* thread);
   310   // Name
   311   static typeArrayOop name(oop java_thread);
   312   static void set_name(oop java_thread, typeArrayOop name);
   313   // Priority
   314   static ThreadPriority priority(oop java_thread);
   315   static void set_priority(oop java_thread, ThreadPriority priority);
   316   // Thread group
   317   static oop  threadGroup(oop java_thread);
   318   // Stillborn
   319   static bool is_stillborn(oop java_thread);
   320   static void set_stillborn(oop java_thread);
   321   // Alive (NOTE: this is not really a field, but provides the correct
   322   // definition without doing a Java call)
   323   static bool is_alive(oop java_thread);
   324   // Daemon
   325   static bool is_daemon(oop java_thread);
   326   static void set_daemon(oop java_thread);
   327   // Context ClassLoader
   328   static oop context_class_loader(oop java_thread);
   329   // Control context
   330   static oop inherited_access_control_context(oop java_thread);
   331   // Stack size hint
   332   static jlong stackSize(oop java_thread);
   333   // Thread ID
   334   static jlong thread_id(oop java_thread);
   336   // Blocker object responsible for thread parking
   337   static oop park_blocker(oop java_thread);
   339   // Pointer to type-stable park handler, encoded as jlong.
   340   // Should be set when apparently null
   341   // For details, see unsafe.cpp Unsafe_Unpark
   342   static jlong park_event(oop java_thread);
   343   static bool set_park_event(oop java_thread, jlong ptr);
   345   // Java Thread Status for JVMTI and M&M use.
   346   // This thread status info is saved in threadStatus field of
   347   // java.lang.Thread java class.
   348   enum ThreadStatus {
   349     NEW                      = 0,
   350     RUNNABLE                 = JVMTI_THREAD_STATE_ALIVE +          // runnable / running
   351                                JVMTI_THREAD_STATE_RUNNABLE,
   352     SLEEPING                 = JVMTI_THREAD_STATE_ALIVE +          // Thread.sleep()
   353                                JVMTI_THREAD_STATE_WAITING +
   354                                JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT +
   355                                JVMTI_THREAD_STATE_SLEEPING,
   356     IN_OBJECT_WAIT           = JVMTI_THREAD_STATE_ALIVE +          // Object.wait()
   357                                JVMTI_THREAD_STATE_WAITING +
   358                                JVMTI_THREAD_STATE_WAITING_INDEFINITELY +
   359                                JVMTI_THREAD_STATE_IN_OBJECT_WAIT,
   360     IN_OBJECT_WAIT_TIMED     = JVMTI_THREAD_STATE_ALIVE +          // Object.wait(long)
   361                                JVMTI_THREAD_STATE_WAITING +
   362                                JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT +
   363                                JVMTI_THREAD_STATE_IN_OBJECT_WAIT,
   364     PARKED                   = JVMTI_THREAD_STATE_ALIVE +          // LockSupport.park()
   365                                JVMTI_THREAD_STATE_WAITING +
   366                                JVMTI_THREAD_STATE_WAITING_INDEFINITELY +
   367                                JVMTI_THREAD_STATE_PARKED,
   368     PARKED_TIMED             = JVMTI_THREAD_STATE_ALIVE +          // LockSupport.park(long)
   369                                JVMTI_THREAD_STATE_WAITING +
   370                                JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT +
   371                                JVMTI_THREAD_STATE_PARKED,
   372     BLOCKED_ON_MONITOR_ENTER = JVMTI_THREAD_STATE_ALIVE +          // (re-)entering a synchronization block
   373                                JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER,
   374     TERMINATED               = JVMTI_THREAD_STATE_TERMINATED
   375   };
   376   // Write thread status info to threadStatus field of java.lang.Thread.
   377   static void set_thread_status(oop java_thread_oop, ThreadStatus status);
   378   // Read thread status info from threadStatus field of java.lang.Thread.
   379   static ThreadStatus get_thread_status(oop java_thread_oop);
   381   static const char*  thread_status_name(oop java_thread_oop);
   383   // Debugging
   384   friend class JavaClasses;
   385 };
   387 // Interface to java.lang.ThreadGroup objects
   389 class java_lang_ThreadGroup : AllStatic {
   390  private:
   391   static int _parent_offset;
   392   static int _name_offset;
   393   static int _threads_offset;
   394   static int _groups_offset;
   395   static int _maxPriority_offset;
   396   static int _destroyed_offset;
   397   static int _daemon_offset;
   398   static int _vmAllowSuspension_offset;
   399   static int _nthreads_offset;
   400   static int _ngroups_offset;
   402   static void compute_offsets();
   404  public:
   405   // parent ThreadGroup
   406   static oop  parent(oop java_thread_group);
   407   // name
   408   static typeArrayOop name(oop java_thread_group);
   409   // ("name as oop" accessor is not necessary)
   410   // Number of threads in group
   411   static int nthreads(oop java_thread_group);
   412   // threads
   413   static objArrayOop threads(oop java_thread_group);
   414   // Number of threads in group
   415   static int ngroups(oop java_thread_group);
   416   // groups
   417   static objArrayOop groups(oop java_thread_group);
   418   // maxPriority in group
   419   static ThreadPriority maxPriority(oop java_thread_group);
   420   // Destroyed
   421   static bool is_destroyed(oop java_thread_group);
   422   // Daemon
   423   static bool is_daemon(oop java_thread_group);
   424   // vmAllowSuspension
   425   static bool is_vmAllowSuspension(oop java_thread_group);
   426   // Debugging
   427   friend class JavaClasses;
   428 };
   432 // Interface to java.lang.Throwable objects
   434 class java_lang_Throwable: AllStatic {
   435   friend class BacktraceBuilder;
   437  private:
   438   // Offsets
   439   enum {
   440     hc_backtrace_offset     =  0,
   441     hc_detailMessage_offset =  1,
   442     hc_cause_offset         =  2,  // New since 1.4
   443     hc_stackTrace_offset    =  3   // New since 1.4
   444   };
   445   enum {
   446       hc_static_unassigned_stacktrace_offset = 0  // New since 1.7
   447   };
   448   // Trace constants
   449   enum {
   450     trace_methods_offset = 0,
   451     trace_bcis_offset    = 1,
   452     trace_next_offset    = 2,
   453     trace_size           = 3,
   454     trace_chunk_size     = 32
   455   };
   457   static int backtrace_offset;
   458   static int detailMessage_offset;
   459   static int cause_offset;
   460   static int stackTrace_offset;
   461   static int static_unassigned_stacktrace_offset;
   463   // Printing
   464   static char* print_stack_element_to_buffer(methodOop method, int bci);
   465   static void print_to_stream(Handle stream, const char* str);
   466   // StackTrace (programmatic access, new since 1.4)
   467   static void clear_stacktrace(oop throwable);
   468   // No stack trace available
   469   static const char* no_stack_trace_message();
   470   // Stacktrace (post JDK 1.7.0 to allow immutability protocol to be followed)
   471   static void set_stacktrace(oop throwable, oop st_element_array);
   472   static oop unassigned_stacktrace();
   474  public:
   475   // Backtrace
   476   static oop backtrace(oop throwable);
   477   static void set_backtrace(oop throwable, oop value);
   478   // Needed by JVMTI to filter out this internal field.
   479   static int get_backtrace_offset() { return backtrace_offset;}
   480   static int get_detailMessage_offset() { return detailMessage_offset;}
   481   // Message
   482   static oop message(oop throwable);
   483   static oop message(Handle throwable);
   484   static void set_message(oop throwable, oop value);
   485   // Print stack trace stored in exception by call-back to Java
   486   // Note: this is no longer used in Merlin, but we still suppport
   487   // it for compatibility.
   488   static void print_stack_trace(oop throwable, oop print_stream);
   489   static void print_stack_element(Handle stream, methodOop method, int bci);
   490   static void print_stack_element(outputStream *st, methodOop method, int bci);
   491   static void print_stack_usage(Handle stream);
   493   // Allocate space for backtrace (created but stack trace not filled in)
   494   static void allocate_backtrace(Handle throwable, TRAPS);
   495   // Fill in current stack trace for throwable with preallocated backtrace (no GC)
   496   static void fill_in_stack_trace_of_preallocated_backtrace(Handle throwable);
   497   // Fill in current stack trace, can cause GC
   498   static void fill_in_stack_trace(Handle throwable, methodHandle method, TRAPS);
   499   static void fill_in_stack_trace(Handle throwable, methodHandle method = methodHandle());
   500   // Programmatic access to stack trace
   501   static oop  get_stack_trace_element(oop throwable, int index, TRAPS);
   502   static int  get_stack_trace_depth(oop throwable, TRAPS);
   503   // Printing
   504   static void print(oop throwable, outputStream* st);
   505   static void print(Handle throwable, outputStream* st);
   506   static void print_stack_trace(oop throwable, outputStream* st);
   507   // Debugging
   508   friend class JavaClasses;
   509 };
   512 // Interface to java.lang.reflect.AccessibleObject objects
   514 class java_lang_reflect_AccessibleObject: AllStatic {
   515  private:
   516   // Note that to reduce dependencies on the JDK we compute these
   517   // offsets at run-time.
   518   static int override_offset;
   520   static void compute_offsets();
   522  public:
   523   // Accessors
   524   static jboolean override(oop reflect);
   525   static void set_override(oop reflect, jboolean value);
   527   // Debugging
   528   friend class JavaClasses;
   529 };
   532 // Interface to java.lang.reflect.Method objects
   534 class java_lang_reflect_Method : public java_lang_reflect_AccessibleObject {
   535  private:
   536   // Note that to reduce dependencies on the JDK we compute these
   537   // offsets at run-time.
   538   static int clazz_offset;
   539   static int name_offset;
   540   static int returnType_offset;
   541   static int parameterTypes_offset;
   542   static int exceptionTypes_offset;
   543   static int slot_offset;
   544   static int modifiers_offset;
   545   static int signature_offset;
   546   static int annotations_offset;
   547   static int parameter_annotations_offset;
   548   static int annotation_default_offset;
   550   static void compute_offsets();
   552  public:
   553   // Allocation
   554   static Handle create(TRAPS);
   556   // Accessors
   557   static oop clazz(oop reflect);
   558   static void set_clazz(oop reflect, oop value);
   560   static oop name(oop method);
   561   static void set_name(oop method, oop value);
   563   static oop return_type(oop method);
   564   static void set_return_type(oop method, oop value);
   566   static oop parameter_types(oop method);
   567   static void set_parameter_types(oop method, oop value);
   569   static oop exception_types(oop method);
   570   static void set_exception_types(oop method, oop value);
   572   static int slot(oop reflect);
   573   static void set_slot(oop reflect, int value);
   575   static int modifiers(oop method);
   576   static void set_modifiers(oop method, int value);
   578   static bool has_signature_field();
   579   static oop signature(oop method);
   580   static void set_signature(oop method, oop value);
   582   static bool has_annotations_field();
   583   static oop annotations(oop method);
   584   static void set_annotations(oop method, oop value);
   586   static bool has_parameter_annotations_field();
   587   static oop parameter_annotations(oop method);
   588   static void set_parameter_annotations(oop method, oop value);
   590   static bool has_annotation_default_field();
   591   static oop annotation_default(oop method);
   592   static void set_annotation_default(oop method, oop value);
   594   // Debugging
   595   friend class JavaClasses;
   596 };
   599 // Interface to java.lang.reflect.Constructor objects
   601 class java_lang_reflect_Constructor : public java_lang_reflect_AccessibleObject {
   602  private:
   603   // Note that to reduce dependencies on the JDK we compute these
   604   // offsets at run-time.
   605   static int clazz_offset;
   606   static int parameterTypes_offset;
   607   static int exceptionTypes_offset;
   608   static int slot_offset;
   609   static int modifiers_offset;
   610   static int signature_offset;
   611   static int annotations_offset;
   612   static int parameter_annotations_offset;
   614   static void compute_offsets();
   616  public:
   617   // Allocation
   618   static Handle create(TRAPS);
   620   // Accessors
   621   static oop clazz(oop reflect);
   622   static void set_clazz(oop reflect, oop value);
   624   static oop parameter_types(oop constructor);
   625   static void set_parameter_types(oop constructor, oop value);
   627   static oop exception_types(oop constructor);
   628   static void set_exception_types(oop constructor, oop value);
   630   static int slot(oop reflect);
   631   static void set_slot(oop reflect, int value);
   633   static int modifiers(oop constructor);
   634   static void set_modifiers(oop constructor, int value);
   636   static bool has_signature_field();
   637   static oop signature(oop constructor);
   638   static void set_signature(oop constructor, oop value);
   640   static bool has_annotations_field();
   641   static oop annotations(oop constructor);
   642   static void set_annotations(oop constructor, oop value);
   644   static bool has_parameter_annotations_field();
   645   static oop parameter_annotations(oop method);
   646   static void set_parameter_annotations(oop method, oop value);
   648   // Debugging
   649   friend class JavaClasses;
   650 };
   653 // Interface to java.lang.reflect.Field objects
   655 class java_lang_reflect_Field : public java_lang_reflect_AccessibleObject {
   656  private:
   657   // Note that to reduce dependencies on the JDK we compute these
   658   // offsets at run-time.
   659   static int clazz_offset;
   660   static int name_offset;
   661   static int type_offset;
   662   static int slot_offset;
   663   static int modifiers_offset;
   664   static int signature_offset;
   665   static int annotations_offset;
   667   static void compute_offsets();
   669  public:
   670   // Allocation
   671   static Handle create(TRAPS);
   673   // Accessors
   674   static oop clazz(oop reflect);
   675   static void set_clazz(oop reflect, oop value);
   677   static oop name(oop field);
   678   static void set_name(oop field, oop value);
   680   static oop type(oop field);
   681   static void set_type(oop field, oop value);
   683   static int slot(oop reflect);
   684   static void set_slot(oop reflect, int value);
   686   static int modifiers(oop field);
   687   static void set_modifiers(oop field, int value);
   689   static bool has_signature_field();
   690   static oop signature(oop constructor);
   691   static void set_signature(oop constructor, oop value);
   693   static bool has_annotations_field();
   694   static oop annotations(oop constructor);
   695   static void set_annotations(oop constructor, oop value);
   697   static bool has_parameter_annotations_field();
   698   static oop parameter_annotations(oop method);
   699   static void set_parameter_annotations(oop method, oop value);
   701   static bool has_annotation_default_field();
   702   static oop annotation_default(oop method);
   703   static void set_annotation_default(oop method, oop value);
   705   // Debugging
   706   friend class JavaClasses;
   707 };
   709 // Interface to sun.reflect.ConstantPool objects
   710 class sun_reflect_ConstantPool {
   711  private:
   712   // Note that to reduce dependencies on the JDK we compute these
   713   // offsets at run-time.
   714   static int _cp_oop_offset;
   716   static void compute_offsets();
   718  public:
   719   // Allocation
   720   static Handle create(TRAPS);
   722   // Accessors
   723   static oop cp_oop(oop reflect);
   724   static void set_cp_oop(oop reflect, oop value);
   725   static int cp_oop_offset() {
   726     return _cp_oop_offset;
   727   }
   729   // Debugging
   730   friend class JavaClasses;
   731 };
   733 // Interface to sun.reflect.UnsafeStaticFieldAccessorImpl objects
   734 class sun_reflect_UnsafeStaticFieldAccessorImpl {
   735  private:
   736   static int _base_offset;
   737   static void compute_offsets();
   739  public:
   740   static int base_offset() {
   741     return _base_offset;
   742   }
   744   // Debugging
   745   friend class JavaClasses;
   746 };
   748 // Interface to java.lang primitive type boxing objects:
   749 //  - java.lang.Boolean
   750 //  - java.lang.Character
   751 //  - java.lang.Float
   752 //  - java.lang.Double
   753 //  - java.lang.Byte
   754 //  - java.lang.Short
   755 //  - java.lang.Integer
   756 //  - java.lang.Long
   758 // This could be separated out into 8 individual classes.
   760 class java_lang_boxing_object: AllStatic {
   761  private:
   762   enum {
   763    hc_value_offset = 0
   764   };
   765   static int value_offset;
   766   static int long_value_offset;
   768   static oop initialize_and_allocate(BasicType type, TRAPS);
   769  public:
   770   // Allocation. Returns a boxed value, or NULL for invalid type.
   771   static oop create(BasicType type, jvalue* value, TRAPS);
   772   // Accessors. Returns the basic type being boxed, or T_ILLEGAL for invalid oop.
   773   static BasicType get_value(oop box, jvalue* value);
   774   static BasicType set_value(oop box, jvalue* value);
   775   static BasicType basic_type(oop box);
   776   static bool is_instance(oop box)                 { return basic_type(box) != T_ILLEGAL; }
   777   static bool is_instance(oop box, BasicType type) { return basic_type(box) == type; }
   778   static void print(oop box, outputStream* st)     { jvalue value;  print(get_value(box, &value), &value, st); }
   779   static void print(BasicType type, jvalue* value, outputStream* st);
   781   static int value_offset_in_bytes(BasicType type) {
   782     return ( type == T_LONG || type == T_DOUBLE ) ? long_value_offset :
   783                                                     value_offset;
   784   }
   786   // Debugging
   787   friend class JavaClasses;
   788 };
   792 // Interface to java.lang.ref.Reference objects
   794 class java_lang_ref_Reference: AllStatic {
   795  public:
   796   enum {
   797    hc_referent_offset   = 0,
   798    hc_queue_offset      = 1,
   799    hc_next_offset       = 2,
   800    hc_discovered_offset = 3  // Is not last, see SoftRefs.
   801   };
   802   enum {
   803    hc_static_lock_offset    = 0,
   804    hc_static_pending_offset = 1
   805   };
   807   static int referent_offset;
   808   static int queue_offset;
   809   static int next_offset;
   810   static int discovered_offset;
   811   static int static_lock_offset;
   812   static int static_pending_offset;
   813   static int number_of_fake_oop_fields;
   815   // Accessors
   816   static oop referent(oop ref) {
   817     return ref->obj_field(referent_offset);
   818   }
   819   static void set_referent(oop ref, oop value) {
   820     ref->obj_field_put(referent_offset, value);
   821   }
   822   static void set_referent_raw(oop ref, oop value) {
   823     ref->obj_field_put_raw(referent_offset, value);
   824   }
   825   static HeapWord* referent_addr(oop ref) {
   826     return ref->obj_field_addr<HeapWord>(referent_offset);
   827   }
   828   static oop next(oop ref) {
   829     return ref->obj_field(next_offset);
   830   }
   831   static void set_next(oop ref, oop value) {
   832     ref->obj_field_put(next_offset, value);
   833   }
   834   static void set_next_raw(oop ref, oop value) {
   835     ref->obj_field_put_raw(next_offset, value);
   836   }
   837   static HeapWord* next_addr(oop ref) {
   838     return ref->obj_field_addr<HeapWord>(next_offset);
   839   }
   840   static oop discovered(oop ref) {
   841     return ref->obj_field(discovered_offset);
   842   }
   843   static void set_discovered(oop ref, oop value) {
   844     ref->obj_field_put(discovered_offset, value);
   845   }
   846   static void set_discovered_raw(oop ref, oop value) {
   847     ref->obj_field_put_raw(discovered_offset, value);
   848   }
   849   static HeapWord* discovered_addr(oop ref) {
   850     return ref->obj_field_addr<HeapWord>(discovered_offset);
   851   }
   852   // Accessors for statics
   853   static oop  pending_list_lock();
   854   static oop  pending_list();
   856   static HeapWord*  pending_list_addr();
   857 };
   860 // Interface to java.lang.ref.SoftReference objects
   862 class java_lang_ref_SoftReference: public java_lang_ref_Reference {
   863  public:
   864   enum {
   865    // The timestamp is a long field and may need to be adjusted for alignment.
   866    hc_timestamp_offset  = hc_discovered_offset + 1
   867   };
   868   enum {
   869    hc_static_clock_offset = 0
   870   };
   872   static int timestamp_offset;
   873   static int static_clock_offset;
   875   // Accessors
   876   static jlong timestamp(oop ref);
   878   // Accessors for statics
   879   static jlong clock();
   880   static void set_clock(jlong value);
   881 };
   884 // Interface to java.lang.invoke.MethodHandle objects
   886 #define METHODHANDLE_INJECTED_FIELDS(macro)                               \
   887   macro(java_lang_invoke_MethodHandle, vmentry,  intptr_signature, false) \
   888   macro(java_lang_invoke_MethodHandle, vmtarget, object_signature, true)
   890 class MethodHandleEntry;
   892 class java_lang_invoke_MethodHandle: AllStatic {
   893   friend class JavaClasses;
   895  private:
   896   static int _vmentry_offset;            // assembly code trampoline for MH
   897   static int _vmtarget_offset;           // class-specific target reference
   898   static int _type_offset;              // the MethodType of this MH
   900   static void compute_offsets();
   902  public:
   903   // Accessors
   904   static oop            type(oop mh);
   905   static void       set_type(oop mh, oop mtype);
   907   static oop            vmtarget(oop mh);
   908   static void       set_vmtarget(oop mh, oop target);
   910   static MethodHandleEntry* vmentry(oop mh);
   911   static void       set_vmentry(oop mh, MethodHandleEntry* data);
   913   static int            vmslots(oop mh);
   915   // Testers
   916   static bool is_subclass(klassOop klass) {
   917     return Klass::cast(klass)->is_subclass_of(SystemDictionary::MethodHandle_klass());
   918   }
   919   static bool is_instance(oop obj) {
   920     return obj != NULL && is_subclass(obj->klass());
   921   }
   923   // Accessors for code generation:
   924   static int type_offset_in_bytes()             { return _type_offset; }
   925   static int vmtarget_offset_in_bytes()         { return _vmtarget_offset; }
   926   static int vmentry_offset_in_bytes()          { return _vmentry_offset; }
   927 };
   929 #define DIRECTMETHODHANDLE_INJECTED_FIELDS(macro)                          \
   930   macro(java_lang_invoke_DirectMethodHandle, vmindex, int_signature, true)
   932 class java_lang_invoke_DirectMethodHandle: public java_lang_invoke_MethodHandle {
   933   friend class JavaClasses;
   935  private:
   936   static int _vmindex_offset;           // negative or vtable idx or itable idx
   937   static void compute_offsets();
   939  public:
   940   // Accessors
   941   static int            vmindex(oop mh);
   942   static void       set_vmindex(oop mh, int index);
   944   // Testers
   945   static bool is_subclass(klassOop klass) {
   946     return Klass::cast(klass)->is_subclass_of(SystemDictionary::DirectMethodHandle_klass());
   947   }
   948   static bool is_instance(oop obj) {
   949     return obj != NULL && is_subclass(obj->klass());
   950   }
   952   // Accessors for code generation:
   953   static int vmindex_offset_in_bytes()          { return _vmindex_offset; }
   954 };
   956 class java_lang_invoke_BoundMethodHandle: public java_lang_invoke_MethodHandle {
   957   friend class JavaClasses;
   959  private:
   960   static int _argument_offset;          // argument value bound into this MH
   961   static int _vmargslot_offset;         // relevant argument slot (<= vmslots)
   962   static void compute_offsets();
   964 public:
   965   static oop            argument(oop mh);
   966   static void       set_argument(oop mh, oop ref);
   968   static jint           vmargslot(oop mh);
   969   static void       set_vmargslot(oop mh, jint slot);
   971   // Testers
   972   static bool is_subclass(klassOop klass) {
   973     return Klass::cast(klass)->is_subclass_of(SystemDictionary::BoundMethodHandle_klass());
   974   }
   975   static bool is_instance(oop obj) {
   976     return obj != NULL && is_subclass(obj->klass());
   977   }
   979   static int argument_offset_in_bytes()         { return _argument_offset; }
   980   static int vmargslot_offset_in_bytes()        { return _vmargslot_offset; }
   981 };
   983 class java_lang_invoke_AdapterMethodHandle: public java_lang_invoke_BoundMethodHandle {
   984   friend class JavaClasses;
   986  private:
   987   static int _conversion_offset;        // type of conversion to apply
   988   static void compute_offsets();
   990  public:
   991   static int            conversion(oop mh);
   992   static void       set_conversion(oop mh, int conv);
   994   // Testers
   995   static bool is_subclass(klassOop klass) {
   996     return Klass::cast(klass)->is_subclass_of(SystemDictionary::AdapterMethodHandle_klass());
   997   }
   998   static bool is_instance(oop obj) {
   999     return obj != NULL && is_subclass(obj->klass());
  1002   // Relevant integer codes (keep these in synch. with MethodHandleNatives.Constants):
  1003   enum {
  1004     OP_RETYPE_ONLY   = 0x0, // no argument changes; straight retype
  1005     OP_RETYPE_RAW    = 0x1, // straight retype, trusted (void->int, Object->T)
  1006     OP_CHECK_CAST    = 0x2, // ref-to-ref conversion; requires a Class argument
  1007     OP_PRIM_TO_PRIM  = 0x3, // converts from one primitive to another
  1008     OP_REF_TO_PRIM   = 0x4, // unboxes a wrapper to produce a primitive
  1009     OP_PRIM_TO_REF   = 0x5, // boxes a primitive into a wrapper
  1010     OP_SWAP_ARGS     = 0x6, // swap arguments (vminfo is 2nd arg)
  1011     OP_ROT_ARGS      = 0x7, // rotate arguments (vminfo is displaced arg)
  1012     OP_DUP_ARGS      = 0x8, // duplicates one or more arguments (at TOS)
  1013     OP_DROP_ARGS     = 0x9, // remove one or more argument slots
  1014     OP_COLLECT_ARGS  = 0xA, // combine arguments using an auxiliary function
  1015     OP_SPREAD_ARGS   = 0xB, // expand in place a varargs array (of known size)
  1016     OP_FOLD_ARGS     = 0xC, // combine but do not remove arguments; prepend result
  1017     //OP_UNUSED_13   = 0xD, // unused code, perhaps for reified argument lists
  1018     CONV_OP_LIMIT    = 0xE, // limit of CONV_OP enumeration
  1020     CONV_OP_MASK     = 0xF00, // this nybble contains the conversion op field
  1021     CONV_TYPE_MASK   = 0x0F,  // fits T_ADDRESS and below
  1022     CONV_VMINFO_MASK = 0x0FF, // LSB is reserved for JVM use
  1023     CONV_VMINFO_SHIFT     =  0, // position of bits in CONV_VMINFO_MASK
  1024     CONV_OP_SHIFT         =  8, // position of bits in CONV_OP_MASK
  1025     CONV_DEST_TYPE_SHIFT  = 12, // byte 2 has the adapter BasicType (if needed)
  1026     CONV_SRC_TYPE_SHIFT   = 16, // byte 2 has the source BasicType (if needed)
  1027     CONV_STACK_MOVE_SHIFT = 20, // high 12 bits give signed SP change
  1028     CONV_STACK_MOVE_MASK  = (1 << (32 - CONV_STACK_MOVE_SHIFT)) - 1
  1029   };
  1031   static int conversion_offset_in_bytes()       { return _conversion_offset; }
  1032 };
  1035 // A simple class that maintains an invocation count
  1036 class java_lang_invoke_CountingMethodHandle: public java_lang_invoke_MethodHandle {
  1037   friend class JavaClasses;
  1039  private:
  1040   static int _vmcount_offset;
  1041   static void compute_offsets();
  1043  public:
  1044   // Accessors
  1045   static int            vmcount(oop mh);
  1046   static void       set_vmcount(oop mh, int count);
  1048   // Testers
  1049   static bool is_subclass(klassOop klass) {
  1050     return SystemDictionary::CountingMethodHandle_klass() != NULL &&
  1051       Klass::cast(klass)->is_subclass_of(SystemDictionary::CountingMethodHandle_klass());
  1053   static bool is_instance(oop obj) {
  1054     return obj != NULL && is_subclass(obj->klass());
  1057   // Accessors for code generation:
  1058   static int vmcount_offset_in_bytes()          { return _vmcount_offset; }
  1059 };
  1063 // Interface to java.lang.invoke.MemberName objects
  1064 // (These are a private interface for Java code to query the class hierarchy.)
  1066 #define MEMBERNAME_INJECTED_FIELDS(macro)                              \
  1067   macro(java_lang_invoke_MemberName, vmtarget, object_signature, true)
  1069 class java_lang_invoke_MemberName: AllStatic {
  1070   friend class JavaClasses;
  1072  private:
  1073   // From java.lang.invoke.MemberName:
  1074   //    private Class<?>   clazz;       // class in which the method is defined
  1075   //    private String     name;        // may be null if not yet materialized
  1076   //    private Object     type;        // may be null if not yet materialized
  1077   //    private int        flags;       // modifier bits; see reflect.Modifier
  1078   //    private Object     vmtarget;    // VM-specific target value
  1079   //    private int        vmindex;     // method index within class or interface
  1080   static int _clazz_offset;
  1081   static int _name_offset;
  1082   static int _type_offset;
  1083   static int _flags_offset;
  1084   static int _vmtarget_offset;
  1085   static int _vmindex_offset;
  1087   static void compute_offsets();
  1089  public:
  1090   // Accessors
  1091   static oop            clazz(oop mname);
  1092   static void       set_clazz(oop mname, oop clazz);
  1094   static oop            type(oop mname);
  1095   static void       set_type(oop mname, oop type);
  1097   static oop            name(oop mname);
  1098   static void       set_name(oop mname, oop name);
  1100   static int            flags(oop mname);
  1101   static void       set_flags(oop mname, int flags);
  1103   static int            modifiers(oop mname) { return (u2) flags(mname); }
  1104   static void       set_modifiers(oop mname, int mods)
  1105                                 { set_flags(mname, (flags(mname) &~ (u2)-1) | (u2)mods); }
  1107   static oop            vmtarget(oop mname);
  1108   static void       set_vmtarget(oop mname, oop target);
  1110   static int            vmindex(oop mname);
  1111   static void       set_vmindex(oop mname, int index);
  1113   // Testers
  1114   static bool is_subclass(klassOop klass) {
  1115     return Klass::cast(klass)->is_subclass_of(SystemDictionary::MemberName_klass());
  1117   static bool is_instance(oop obj) {
  1118     return obj != NULL && is_subclass(obj->klass());
  1121   // Relevant integer codes (keep these in synch. with MethodHandleNatives.Constants):
  1122   enum {
  1123     MN_IS_METHOD           = 0x00010000, // method (not constructor)
  1124     MN_IS_CONSTRUCTOR      = 0x00020000, // constructor
  1125     MN_IS_FIELD            = 0x00040000, // field
  1126     MN_IS_TYPE             = 0x00080000, // nested type
  1127     MN_SEARCH_SUPERCLASSES = 0x00100000, // for MHN.getMembers
  1128     MN_SEARCH_INTERFACES   = 0x00200000, // for MHN.getMembers
  1129     VM_INDEX_UNINITIALIZED = -99
  1130   };
  1132   // Accessors for code generation:
  1133   static int clazz_offset_in_bytes()            { return _clazz_offset; }
  1134   static int type_offset_in_bytes()             { return _type_offset; }
  1135   static int name_offset_in_bytes()             { return _name_offset; }
  1136   static int flags_offset_in_bytes()            { return _flags_offset; }
  1137   static int vmtarget_offset_in_bytes()         { return _vmtarget_offset; }
  1138   static int vmindex_offset_in_bytes()          { return _vmindex_offset; }
  1139 };
  1142 // Interface to java.lang.invoke.MethodType objects
  1144 class java_lang_invoke_MethodType: AllStatic {
  1145   friend class JavaClasses;
  1147  private:
  1148   static int _rtype_offset;
  1149   static int _ptypes_offset;
  1150   static int _form_offset;
  1152   static void compute_offsets();
  1154  public:
  1155   // Accessors
  1156   static oop            rtype(oop mt);
  1157   static objArrayOop    ptypes(oop mt);
  1158   static oop            form(oop mt);
  1160   static oop            ptype(oop mt, int index);
  1161   static int            ptype_count(oop mt);
  1163   static Symbol*        as_signature(oop mt, bool intern_if_not_found, TRAPS);
  1164   static void           print_signature(oop mt, outputStream* st);
  1166   static bool is_instance(oop obj) {
  1167     return obj != NULL && obj->klass() == SystemDictionary::MethodType_klass();
  1170   static bool equals(oop mt1, oop mt2);
  1172   // Accessors for code generation:
  1173   static int rtype_offset_in_bytes()            { return _rtype_offset; }
  1174   static int ptypes_offset_in_bytes()           { return _ptypes_offset; }
  1175   static int form_offset_in_bytes()             { return _form_offset; }
  1176 };
  1178 #define METHODTYPEFORM_INJECTED_FIELDS(macro)                              \
  1179   macro(java_lang_invoke_MethodTypeForm, vmslots,  int_signature,    true) \
  1180   macro(java_lang_invoke_MethodTypeForm, vmlayout, object_signature, true)
  1182 class java_lang_invoke_MethodTypeForm: AllStatic {
  1183   friend class JavaClasses;
  1185  private:
  1186   static int _vmslots_offset;           // number of argument slots needed
  1187   static int _vmlayout_offset;          // object describing internal calling sequence
  1188   static int _erasedType_offset;        // erasedType = canonical MethodType
  1189   static int _genericInvoker_offset;    // genericInvoker = adapter for invokeGeneric
  1191   static void compute_offsets();
  1193  public:
  1194   // Accessors
  1195   static int            vmslots(oop mtform);
  1196   static void       set_vmslots(oop mtform, int vmslots);
  1198   static oop            erasedType(oop mtform);
  1199   static oop            genericInvoker(oop mtform);
  1201   static oop            vmlayout(oop mtform);
  1202   static oop       init_vmlayout(oop mtform, oop cookie);
  1204   // Accessors for code generation:
  1205   static int vmslots_offset_in_bytes()          { return _vmslots_offset; }
  1206   static int vmlayout_offset_in_bytes()         { return _vmlayout_offset; }
  1207   static int erasedType_offset_in_bytes()       { return _erasedType_offset; }
  1208   static int genericInvoker_offset_in_bytes()   { return _genericInvoker_offset; }
  1209 };
  1212 // Interface to java.lang.invoke.CallSite objects
  1214 class java_lang_invoke_CallSite: AllStatic {
  1215   friend class JavaClasses;
  1217 private:
  1218   static int _target_offset;
  1220   static void compute_offsets();
  1222 public:
  1223   // Accessors
  1224   static oop              target(         oop site)             { return site->obj_field(             _target_offset);         }
  1225   static void         set_target(         oop site, oop target) {        site->obj_field_put(         _target_offset, target); }
  1227   static volatile oop     target_volatile(oop site)             { return site->obj_field_volatile(    _target_offset);         }
  1228   static void         set_target_volatile(oop site, oop target) {        site->obj_field_put_volatile(_target_offset, target); }
  1230   // Testers
  1231   static bool is_subclass(klassOop klass) {
  1232     return Klass::cast(klass)->is_subclass_of(SystemDictionary::CallSite_klass());
  1234   static bool is_instance(oop obj) {
  1235     return obj != NULL && is_subclass(obj->klass());
  1238   // Accessors for code generation:
  1239   static int target_offset_in_bytes()           { return _target_offset; }
  1240 };
  1243 // Interface to java.security.AccessControlContext objects
  1245 class java_security_AccessControlContext: AllStatic {
  1246  private:
  1247   // Note that for this class the layout changed between JDK1.2 and JDK1.3,
  1248   // so we compute the offsets at startup rather than hard-wiring them.
  1249   static int _context_offset;
  1250   static int _privilegedContext_offset;
  1251   static int _isPrivileged_offset;
  1253   static void compute_offsets();
  1254  public:
  1255   static oop create(objArrayHandle context, bool isPrivileged, Handle privileged_context, TRAPS);
  1257   // Debugging/initialization
  1258   friend class JavaClasses;
  1259 };
  1262 // Interface to java.lang.ClassLoader objects
  1264 class java_lang_ClassLoader : AllStatic {
  1265  private:
  1266   enum {
  1267    hc_parent_offset = 0
  1268   };
  1270   static bool offsets_computed;
  1271   static int parent_offset;
  1272   static int parallelCapable_offset;
  1274   static void compute_offsets();
  1276  public:
  1277   static oop parent(oop loader);
  1279   // Support for parallelCapable field
  1280   static bool parallelCapable(oop the_class_mirror);
  1282   static bool is_trusted_loader(oop loader);
  1284   // Fix for 4474172
  1285   static oop  non_reflection_class_loader(oop loader);
  1287   // Debugging
  1288   friend class JavaClasses;
  1289 };
  1292 // Interface to java.lang.System objects
  1294 class java_lang_System : AllStatic {
  1295  private:
  1296   enum {
  1297    hc_static_in_offset  = 0,
  1298    hc_static_out_offset = 1,
  1299    hc_static_err_offset = 2
  1300   };
  1302   static int  static_in_offset;
  1303   static int static_out_offset;
  1304   static int static_err_offset;
  1306  public:
  1307   static int  in_offset_in_bytes();
  1308   static int out_offset_in_bytes();
  1309   static int err_offset_in_bytes();
  1311   // Debugging
  1312   friend class JavaClasses;
  1313 };
  1316 // Interface to java.lang.StackTraceElement objects
  1318 class java_lang_StackTraceElement: AllStatic {
  1319  private:
  1320   enum {
  1321     hc_declaringClass_offset  = 0,
  1322     hc_methodName_offset = 1,
  1323     hc_fileName_offset   = 2,
  1324     hc_lineNumber_offset = 3
  1325   };
  1327   static int declaringClass_offset;
  1328   static int methodName_offset;
  1329   static int fileName_offset;
  1330   static int lineNumber_offset;
  1332  public:
  1333   // Setters
  1334   static void set_declaringClass(oop element, oop value);
  1335   static void set_methodName(oop element, oop value);
  1336   static void set_fileName(oop element, oop value);
  1337   static void set_lineNumber(oop element, int value);
  1339   // Create an instance of StackTraceElement
  1340   static oop create(methodHandle m, int bci, TRAPS);
  1342   // Debugging
  1343   friend class JavaClasses;
  1344 };
  1347 // Interface to java.lang.AssertionStatusDirectives objects
  1349 class java_lang_AssertionStatusDirectives: AllStatic {
  1350  private:
  1351   enum {
  1352     hc_classes_offset,
  1353     hc_classEnabled_offset,
  1354     hc_packages_offset,
  1355     hc_packageEnabled_offset,
  1356     hc_deflt_offset
  1357   };
  1359   static int classes_offset;
  1360   static int classEnabled_offset;
  1361   static int packages_offset;
  1362   static int packageEnabled_offset;
  1363   static int deflt_offset;
  1365  public:
  1366   // Setters
  1367   static void set_classes(oop obj, oop val);
  1368   static void set_classEnabled(oop obj, oop val);
  1369   static void set_packages(oop obj, oop val);
  1370   static void set_packageEnabled(oop obj, oop val);
  1371   static void set_deflt(oop obj, bool val);
  1372   // Debugging
  1373   friend class JavaClasses;
  1374 };
  1377 class java_nio_Buffer: AllStatic {
  1378  private:
  1379   static int _limit_offset;
  1381  public:
  1382   static int  limit_offset();
  1383   static void compute_offsets();
  1384 };
  1386 class java_util_concurrent_locks_AbstractOwnableSynchronizer : AllStatic {
  1387  private:
  1388   static int  _owner_offset;
  1389  public:
  1390   static void initialize(TRAPS);
  1391   static oop  get_owner_threadObj(oop obj);
  1392 };
  1394 // Use to declare fields that need to be injected into Java classes
  1395 // for the JVM to use.  The name_index and signature_index are
  1396 // declared in vmSymbols.  The may_be_java flag is used to declare
  1397 // fields that might already exist in Java but should be injected if
  1398 // they don't.  Otherwise the field is unconditionally injected and
  1399 // the JVM uses the injected one.  This is to ensure that name
  1400 // collisions don't occur.  In general may_be_java should be false
  1401 // unless there's a good reason.
  1403 class InjectedField {
  1404  public:
  1405   const SystemDictionary::WKID klass_id;
  1406   const vmSymbols::SID name_index;
  1407   const vmSymbols::SID signature_index;
  1408   const bool           may_be_java;
  1411   klassOop klass() const    { return SystemDictionary::well_known_klass(klass_id); }
  1412   Symbol* name() const      { return lookup_symbol(name_index); }
  1413   Symbol* signature() const { return lookup_symbol(signature_index); }
  1415   int compute_offset();
  1417   // Find the Symbol for this index
  1418   static Symbol* lookup_symbol(int symbol_index) {
  1419     return vmSymbols::symbol_at((vmSymbols::SID)symbol_index);
  1421 };
  1423 #define DECLARE_INJECTED_FIELD_ENUM(klass, name, signature, may_be_java) \
  1424   klass##_##name##_enum,
  1426 #define ALL_INJECTED_FIELDS(macro)          \
  1427   CLASS_INJECTED_FIELDS(macro)              \
  1428   METHODHANDLE_INJECTED_FIELDS(macro)       \
  1429   DIRECTMETHODHANDLE_INJECTED_FIELDS(macro) \
  1430   MEMBERNAME_INJECTED_FIELDS(macro)         \
  1431   METHODTYPEFORM_INJECTED_FIELDS(macro)
  1433 // Interface to hard-coded offset checking
  1435 class JavaClasses : AllStatic {
  1436  private:
  1438   static InjectedField _injected_fields[];
  1440   static bool check_offset(const char *klass_name, int offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0;
  1441   static bool check_static_offset(const char *klass_name, int hardcoded_offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0;
  1442   static bool check_constant(const char *klass_name, int constant, const char *field_name, const char* field_sig) PRODUCT_RETURN0;
  1444  public:
  1445   enum InjectedFieldID {
  1446     ALL_INJECTED_FIELDS(DECLARE_INJECTED_FIELD_ENUM)
  1447     MAX_enum
  1448   };
  1450   static int compute_injected_offset(InjectedFieldID id);
  1452   static void compute_hard_coded_offsets();
  1453   static void compute_offsets();
  1454   static void check_offsets() PRODUCT_RETURN;
  1456   static InjectedField* get_injected(Symbol* class_name, int* field_count);
  1457 };
  1459 #undef DECLARE_INJECTED_FIELD_ENUM
  1461 #endif // SHARE_VM_CLASSFILE_JAVACLASSES_HPP

mercurial