src/share/vm/classfile/javaClasses.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 7086585 Sdiff src/share/vm/classfile

src/share/vm/classfile/javaClasses.hpp

Print this page




 139   static Handle externalize_classname(Handle java_string, TRAPS) { return char_converter(java_string, '/', '.', THREAD); }
 140   static Handle internalize_classname(Handle java_string, TRAPS) { return char_converter(java_string, '.', '/', THREAD); }
 141 
 142   // Conversion
 143   static Symbol* as_symbol(Handle java_string, TRAPS);
 144   static Symbol* as_symbol_or_null(oop java_string);
 145 
 146   // Testers
 147   static bool is_instance(oop obj) {
 148     return obj != NULL && obj->klass() == SystemDictionary::String_klass();
 149   }
 150 
 151   // Debugging
 152   static void print(Handle java_string, outputStream* st);
 153   friend class JavaClasses;
 154 };
 155 
 156 
 157 // Interface to java.lang.Class objects
 158 







 159 class java_lang_Class : AllStatic {
 160    friend class VMStructs;

 161  private:
 162   // The fake offsets are added by the class loader when java.lang.Class is loaded
 163 
 164   enum {
 165     hc_number_of_fake_oop_fields   = 3,
 166     hc_number_of_fake_int_fields   = 2
 167   };
 168 
 169   static int klass_offset;
 170   static int resolved_constructor_offset;
 171   static int array_klass_offset;
 172   static int number_of_fake_oop_fields;
 173 
 174   static int oop_size_offset;
 175   static int static_oop_field_count_offset;
 176 
 177   static void compute_offsets();
 178   static bool offsets_computed;
 179   static int classRedefinedCount_offset;
 180   static int parallelCapable_offset;
 181 
 182  public:


 183   // Instance creation
 184   static oop  create_mirror(KlassHandle k, TRAPS);
 185   static void fixup_mirror(KlassHandle k, TRAPS);
 186   static oop  create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS);
 187   // Conversion
 188   static klassOop as_klassOop(oop java_class);
 189   static BasicType as_BasicType(oop java_class, klassOop* reference_klass = NULL);
 190   static BasicType as_BasicType(oop java_class, KlassHandle* reference_klass) {
 191     klassOop refk_oop = NULL;
 192     BasicType result = as_BasicType(java_class, &refk_oop);
 193     (*reference_klass) = KlassHandle(refk_oop);
 194     return result;
 195   }
 196   static Symbol* as_signature(oop java_class, bool intern_if_not_found, TRAPS);
 197   static void print_signature(oop java_class, outputStream *st);
 198   // Testing
 199   static bool is_instance(oop obj) {
 200     return obj != NULL && obj->klass() == SystemDictionary::Class_klass();
 201   }
 202   static bool is_primitive(oop java_class);
 203   static BasicType primitive_type(oop java_class);
 204   static oop primitive_mirror(BasicType t);
 205   // JVM_NewInstance support
 206   static methodOop resolved_constructor(oop java_class);
 207   static void set_resolved_constructor(oop java_class, methodOop constructor);
 208   // JVM_NewArray support
 209   static klassOop array_klass(oop java_class);
 210   static void set_array_klass(oop java_class, klassOop klass);
 211   // compiler support for class operations
 212   static int klass_offset_in_bytes() { return klass_offset; }
 213   static int resolved_constructor_offset_in_bytes() { return resolved_constructor_offset; }
 214   static int array_klass_offset_in_bytes() { return array_klass_offset; }
 215   // Support for classRedefinedCount field
 216   static int classRedefinedCount(oop the_class_mirror);
 217   static void set_classRedefinedCount(oop the_class_mirror, int value);
 218   // Support for parallelCapable field
 219   static bool parallelCapable(oop the_class_mirror);
 220 
 221   static int oop_size(oop java_class);
 222   static void set_oop_size(oop java_class, int size);
 223   static int static_oop_field_count(oop java_class);
 224   static void set_static_oop_field_count(oop java_class, int size);
 225 
 226   // Debugging
 227   friend class JavaClasses;
 228   friend class instanceKlass;   // verification code accesses offsets
 229   friend class ClassFileParser; // access to number_of_fake_fields
 230 };
 231 
 232 // Interface to java.lang.Thread objects
 233 
 234 class java_lang_Thread : AllStatic {
 235  private:
 236   // Note that for this class the layout changed between JDK1.2 and JDK1.3,
 237   // so we compute the offsets at startup rather than hard-wiring them.
 238   static int _name_offset;
 239   static int _group_offset;


 817    hc_timestamp_offset  = hc_discovered_offset + 1
 818   };
 819   enum {
 820    hc_static_clock_offset = 0
 821   };
 822 
 823   static int timestamp_offset;
 824   static int static_clock_offset;
 825 
 826   // Accessors
 827   static jlong timestamp(oop ref);
 828 
 829   // Accessors for statics
 830   static jlong clock();
 831   static void set_clock(jlong value);
 832 };
 833 
 834 
 835 // Interface to java.lang.invoke.MethodHandle objects
 836 




 837 class MethodHandleEntry;
 838 
 839 class java_lang_invoke_MethodHandle: AllStatic {
 840   friend class JavaClasses;
 841 
 842  private:
 843   static int _vmentry_offset;           // assembly code trampoline for MH
 844   static int _vmtarget_offset;          // class-specific target reference
 845   static int _type_offset;              // the MethodType of this MH
 846   static int _vmslots_offset;           // OPTIONAL hoisted type.form.vmslots
 847 
 848   static void compute_offsets();
 849 
 850  public:
 851   // Accessors
 852   static oop            type(oop mh);
 853   static void       set_type(oop mh, oop mtype);
 854 
 855   static oop            vmtarget(oop mh);
 856   static void       set_vmtarget(oop mh, oop target);
 857 
 858   static MethodHandleEntry* vmentry(oop mh);
 859   static void       set_vmentry(oop mh, MethodHandleEntry* data);
 860 
 861   static int            vmslots(oop mh);
 862   static void      init_vmslots(oop mh);
 863   static int    compute_vmslots(oop mh);
 864 
 865   // Testers
 866   static bool is_subclass(klassOop klass) {
 867     return Klass::cast(klass)->is_subclass_of(SystemDictionary::MethodHandle_klass());
 868   }
 869   static bool is_instance(oop obj) {
 870     return obj != NULL && is_subclass(obj->klass());
 871   }
 872 
 873   // Accessors for code generation:
 874   static int type_offset_in_bytes()             { return _type_offset; }
 875   static int vmtarget_offset_in_bytes()         { return _vmtarget_offset; }
 876   static int vmentry_offset_in_bytes()          { return _vmentry_offset; }
 877   static int vmslots_offset_in_bytes()          { return _vmslots_offset; }
 878 };
 879 



 880 class java_lang_invoke_DirectMethodHandle: public java_lang_invoke_MethodHandle {
 881   friend class JavaClasses;
 882 
 883  private:
 884   //         _vmtarget_offset;          // method   or class      or interface
 885   static int _vmindex_offset;           // negative or vtable idx or itable idx
 886   static void compute_offsets();
 887 
 888  public:
 889   // Accessors
 890   static int            vmindex(oop mh);
 891   static void       set_vmindex(oop mh, int index);
 892 
 893   // Testers
 894   static bool is_subclass(klassOop klass) {
 895     return Klass::cast(klass)->is_subclass_of(SystemDictionary::DirectMethodHandle_klass());
 896   }
 897   static bool is_instance(oop obj) {
 898     return obj != NULL && is_subclass(obj->klass());
 899   }
 900 
 901   // Accessors for code generation:
 902   static int vmindex_offset_in_bytes()          { return _vmindex_offset; }
 903 };
 904 


 995   static void       set_vmcount(oop mh, int count);
 996 
 997   // Testers
 998   static bool is_subclass(klassOop klass) {
 999     return SystemDictionary::CountingMethodHandle_klass() != NULL &&
1000       Klass::cast(klass)->is_subclass_of(SystemDictionary::CountingMethodHandle_klass());
1001   }
1002   static bool is_instance(oop obj) {
1003     return obj != NULL && is_subclass(obj->klass());
1004   }
1005 
1006   // Accessors for code generation:
1007   static int vmcount_offset_in_bytes()          { return _vmcount_offset; }
1008 };
1009 
1010 
1011 
1012 // Interface to java.lang.invoke.MemberName objects
1013 // (These are a private interface for Java code to query the class hierarchy.)
1014 



1015 class java_lang_invoke_MemberName: AllStatic {
1016   friend class JavaClasses;
1017 
1018  private:
1019   // From java.lang.invoke.MemberName:
1020   //    private Class<?>   clazz;       // class in which the method is defined
1021   //    private String     name;        // may be null if not yet materialized
1022   //    private Object     type;        // may be null if not yet materialized
1023   //    private int        flags;       // modifier bits; see reflect.Modifier
1024   //    private Object     vmtarget;    // VM-specific target value
1025   //    private int        vmindex;     // method index within class or interface
1026   static int _clazz_offset;
1027   static int _name_offset;
1028   static int _type_offset;
1029   static int _flags_offset;
1030   static int _vmtarget_offset;
1031   static int _vmindex_offset;
1032 
1033   static void compute_offsets();
1034 


1104   static oop            form(oop mt);
1105 
1106   static oop            ptype(oop mt, int index);
1107   static int            ptype_count(oop mt);
1108 
1109   static Symbol*        as_signature(oop mt, bool intern_if_not_found, TRAPS);
1110   static void           print_signature(oop mt, outputStream* st);
1111 
1112   static bool is_instance(oop obj) {
1113     return obj != NULL && obj->klass() == SystemDictionary::MethodType_klass();
1114   }
1115 
1116   static bool equals(oop mt1, oop mt2);
1117 
1118   // Accessors for code generation:
1119   static int rtype_offset_in_bytes()            { return _rtype_offset; }
1120   static int ptypes_offset_in_bytes()           { return _ptypes_offset; }
1121   static int form_offset_in_bytes()             { return _form_offset; }
1122 };
1123 




1124 class java_lang_invoke_MethodTypeForm: AllStatic {
1125   friend class JavaClasses;
1126 
1127  private:
1128   static int _vmslots_offset;           // number of argument slots needed
1129   static int _vmlayout_offset;          // object describing internal calling sequence
1130   static int _erasedType_offset;        // erasedType = canonical MethodType
1131   static int _genericInvoker_offset;    // genericInvoker = adapter for invokeGeneric
1132 
1133   static void compute_offsets();
1134 
1135  public:
1136   // Accessors
1137   static int            vmslots(oop mtform);


1138   static oop            erasedType(oop mtform);
1139   static oop            genericInvoker(oop mtform);
1140 
1141   static oop            vmlayout(oop mtform);
1142   static oop       init_vmlayout(oop mtform, oop cookie);
1143 
1144   // Accessors for code generation:
1145   static int vmslots_offset_in_bytes()          { return _vmslots_offset; }
1146   static int vmlayout_offset_in_bytes()         { return _vmlayout_offset; }
1147   static int erasedType_offset_in_bytes()       { return _erasedType_offset; }
1148   static int genericInvoker_offset_in_bytes()   { return _genericInvoker_offset; }
1149 };
1150 
1151 
1152 // Interface to java.lang.invoke.CallSite objects
1153 
1154 class java_lang_invoke_CallSite: AllStatic {
1155   friend class JavaClasses;
1156 
1157 private:
1158   static int _target_offset;
1159   static int _caller_method_offset;
1160   static int _caller_bci_offset;
1161 
1162   static void compute_offsets();
1163 
1164 public:
1165   // Accessors
1166   static oop              target(         oop site)             { return site->obj_field(             _target_offset);         }
1167   static void         set_target(         oop site, oop target) {        site->obj_field_put(         _target_offset, target); }
1168 
1169   static volatile oop     target_volatile(oop site)             { return site->obj_field_volatile(    _target_offset);         }
1170   static void         set_target_volatile(oop site, oop target) {        site->obj_field_put_volatile(_target_offset, target); }
1171 
1172   static oop              caller_method(oop site);
1173   static void         set_caller_method(oop site, oop ref);
1174 
1175   static jint             caller_bci(oop site);
1176   static void         set_caller_bci(oop site, jint bci);
1177 
1178   // Testers
1179   static bool is_subclass(klassOop klass) {
1180     return Klass::cast(klass)->is_subclass_of(SystemDictionary::CallSite_klass());
1181   }
1182   static bool is_instance(oop obj) {
1183     return obj != NULL && is_subclass(obj->klass());
1184   }
1185 
1186   // Accessors for code generation:
1187   static int target_offset_in_bytes()           { return _target_offset; }
1188   static int caller_method_offset_in_bytes()    { return _caller_method_offset; }
1189   static int caller_bci_offset_in_bytes()       { return _caller_bci_offset; }
1190 };
1191 
1192 
1193 // Interface to java.security.AccessControlContext objects
1194 
1195 class java_security_AccessControlContext: AllStatic {
1196  private:
1197   // Note that for this class the layout changed between JDK1.2 and JDK1.3,
1198   // so we compute the offsets at startup rather than hard-wiring them.
1199   static int _context_offset;
1200   static int _privilegedContext_offset;
1201   static int _isPrivileged_offset;
1202 
1203   static void compute_offsets();
1204  public:
1205   static oop create(objArrayHandle context, bool isPrivileged, Handle privileged_context, TRAPS);
1206 
1207   // Debugging/initialization
1208   friend class JavaClasses;
1209 };
1210 
1211 
1212 // Interface to java.lang.ClassLoader objects
1213 
1214 class java_lang_ClassLoader : AllStatic {
1215  private:
1216   enum {
1217    hc_parent_offset = 0
1218   };
1219 

1220   static int parent_offset;

1221 


1222  public:
1223   static oop parent(oop loader);
1224 



1225   static bool is_trusted_loader(oop loader);
1226 
1227   // Fix for 4474172
1228   static oop  non_reflection_class_loader(oop loader);
1229 
1230   // Debugging
1231   friend class JavaClasses;
1232 };
1233 
1234 
1235 // Interface to java.lang.System objects
1236 
1237 class java_lang_System : AllStatic {
1238  private:
1239   enum {
1240    hc_static_in_offset  = 0,
1241    hc_static_out_offset = 1,
1242    hc_static_err_offset = 2
1243   };
1244 


1326   static void compute_offsets();
1327 };
1328 
1329 class sun_misc_AtomicLongCSImpl: AllStatic {
1330  private:
1331   static int _value_offset;
1332 
1333  public:
1334   static int  value_offset();
1335   static void compute_offsets();
1336 };
1337 
1338 class java_util_concurrent_locks_AbstractOwnableSynchronizer : AllStatic {
1339  private:
1340   static int  _owner_offset;
1341  public:
1342   static void initialize(TRAPS);
1343   static oop  get_owner_threadObj(oop obj);
1344 };
1345 







































1346 // Interface to hard-coded offset checking
1347 
1348 class JavaClasses : AllStatic {
1349  private:



1350   static bool check_offset(const char *klass_name, int offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0;
1351   static bool check_static_offset(const char *klass_name, int hardcoded_offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0;
1352   static bool check_constant(const char *klass_name, int constant, const char *field_name, const char* field_sig) PRODUCT_RETURN0;

1353  public:







1354   static void compute_hard_coded_offsets();
1355   static void compute_offsets();
1356   static void check_offsets() PRODUCT_RETURN;


1357 };
1358 


1359 #endif // SHARE_VM_CLASSFILE_JAVACLASSES_HPP


 139   static Handle externalize_classname(Handle java_string, TRAPS) { return char_converter(java_string, '/', '.', THREAD); }
 140   static Handle internalize_classname(Handle java_string, TRAPS) { return char_converter(java_string, '.', '/', THREAD); }
 141 
 142   // Conversion
 143   static Symbol* as_symbol(Handle java_string, TRAPS);
 144   static Symbol* as_symbol_or_null(oop java_string);
 145 
 146   // Testers
 147   static bool is_instance(oop obj) {
 148     return obj != NULL && obj->klass() == SystemDictionary::String_klass();
 149   }
 150 
 151   // Debugging
 152   static void print(Handle java_string, outputStream* st);
 153   friend class JavaClasses;
 154 };
 155 
 156 
 157 // Interface to java.lang.Class objects
 158 
 159 #define CLASS_INJECTED_FIELDS(macro)                                       \
 160   macro(java_lang_Class, klass,                  object_signature,  false) \
 161   macro(java_lang_Class, resolved_constructor,   object_signature,  false) \
 162   macro(java_lang_Class, array_klass,            object_signature,  false) \
 163   macro(java_lang_Class, oop_size,               int_signature,     false) \
 164   macro(java_lang_Class, static_oop_field_count, int_signature,     false)
 165 
 166 class java_lang_Class : AllStatic {
 167   friend class VMStructs;
 168 
 169  private:
 170   // The fake offsets are added by the class loader when java.lang.Class is loaded
 171 
 172   static int _klass_offset;
 173   static int _resolved_constructor_offset;
 174   static int _array_klass_offset;

 175 
 176   static int _oop_size_offset;
 177   static int _static_oop_field_count_offset;


 178 




 179   static bool offsets_computed;
 180   static int classRedefinedCount_offset;

 181 
 182  public:
 183   static void compute_offsets();
 184 
 185   // Instance creation
 186   static oop  create_mirror(KlassHandle k, TRAPS);
 187   static void fixup_mirror(KlassHandle k, TRAPS);
 188   static oop  create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS);
 189   // Conversion
 190   static klassOop as_klassOop(oop java_class);
 191   static BasicType as_BasicType(oop java_class, klassOop* reference_klass = NULL);
 192   static BasicType as_BasicType(oop java_class, KlassHandle* reference_klass) {
 193     klassOop refk_oop = NULL;
 194     BasicType result = as_BasicType(java_class, &refk_oop);
 195     (*reference_klass) = KlassHandle(refk_oop);
 196     return result;
 197   }
 198   static Symbol* as_signature(oop java_class, bool intern_if_not_found, TRAPS);
 199   static void print_signature(oop java_class, outputStream *st);
 200   // Testing
 201   static bool is_instance(oop obj) {
 202     return obj != NULL && obj->klass() == SystemDictionary::Class_klass();
 203   }
 204   static bool is_primitive(oop java_class);
 205   static BasicType primitive_type(oop java_class);
 206   static oop primitive_mirror(BasicType t);
 207   // JVM_NewInstance support
 208   static methodOop resolved_constructor(oop java_class);
 209   static void set_resolved_constructor(oop java_class, methodOop constructor);
 210   // JVM_NewArray support
 211   static klassOop array_klass(oop java_class);
 212   static void set_array_klass(oop java_class, klassOop klass);
 213   // compiler support for class operations
 214   static int klass_offset_in_bytes()                { return _klass_offset; }
 215   static int resolved_constructor_offset_in_bytes() { return _resolved_constructor_offset; }
 216   static int array_klass_offset_in_bytes()          { return _array_klass_offset; }
 217   // Support for classRedefinedCount field
 218   static int classRedefinedCount(oop the_class_mirror);
 219   static void set_classRedefinedCount(oop the_class_mirror, int value);


 220 
 221   static int oop_size(oop java_class);
 222   static void set_oop_size(oop java_class, int size);
 223   static int static_oop_field_count(oop java_class);
 224   static void set_static_oop_field_count(oop java_class, int size);
 225 
 226   // Debugging
 227   friend class JavaClasses;
 228   friend class instanceKlass;   // verification code accesses offsets
 229   friend class ClassFileParser; // access to number_of_fake_fields
 230 };
 231 
 232 // Interface to java.lang.Thread objects
 233 
 234 class java_lang_Thread : AllStatic {
 235  private:
 236   // Note that for this class the layout changed between JDK1.2 and JDK1.3,
 237   // so we compute the offsets at startup rather than hard-wiring them.
 238   static int _name_offset;
 239   static int _group_offset;


 817    hc_timestamp_offset  = hc_discovered_offset + 1
 818   };
 819   enum {
 820    hc_static_clock_offset = 0
 821   };
 822 
 823   static int timestamp_offset;
 824   static int static_clock_offset;
 825 
 826   // Accessors
 827   static jlong timestamp(oop ref);
 828 
 829   // Accessors for statics
 830   static jlong clock();
 831   static void set_clock(jlong value);
 832 };
 833 
 834 
 835 // Interface to java.lang.invoke.MethodHandle objects
 836 
 837 #define METHODHANDLE_INJECTED_FIELDS(macro)                               \
 838   macro(java_lang_invoke_MethodHandle, vmentry,  intptr_signature, false) \
 839   macro(java_lang_invoke_MethodHandle, vmtarget, object_signature, true)
 840 
 841 class MethodHandleEntry;
 842 
 843 class java_lang_invoke_MethodHandle: AllStatic {
 844   friend class JavaClasses;
 845 
 846  private:
 847   static int _vmentry_offset;            // assembly code trampoline for MH
 848   static int _vmtarget_offset;           // class-specific target reference
 849   static int _type_offset;              // the MethodType of this MH

 850 
 851   static void compute_offsets();
 852 
 853  public:
 854   // Accessors
 855   static oop            type(oop mh);
 856   static void       set_type(oop mh, oop mtype);
 857 
 858   static oop            vmtarget(oop mh);
 859   static void       set_vmtarget(oop mh, oop target);
 860 
 861   static MethodHandleEntry* vmentry(oop mh);
 862   static void       set_vmentry(oop mh, MethodHandleEntry* data);
 863 
 864   static int            vmslots(oop mh);


 865 
 866   // Testers
 867   static bool is_subclass(klassOop klass) {
 868     return Klass::cast(klass)->is_subclass_of(SystemDictionary::MethodHandle_klass());
 869   }
 870   static bool is_instance(oop obj) {
 871     return obj != NULL && is_subclass(obj->klass());
 872   }
 873 
 874   // Accessors for code generation:
 875   static int type_offset_in_bytes()             { return _type_offset; }
 876   static int vmtarget_offset_in_bytes()         { return _vmtarget_offset; }
 877   static int vmentry_offset_in_bytes()          { return _vmentry_offset; }

 878 };
 879 
 880 #define DIRECTMETHODHANDLE_INJECTED_FIELDS(macro)                          \
 881   macro(java_lang_invoke_DirectMethodHandle, vmindex, int_signature, true)
 882 
 883 class java_lang_invoke_DirectMethodHandle: public java_lang_invoke_MethodHandle {
 884   friend class JavaClasses;
 885 
 886  private:

 887   static int _vmindex_offset;           // negative or vtable idx or itable idx
 888   static void compute_offsets();
 889 
 890  public:
 891   // Accessors
 892   static int            vmindex(oop mh);
 893   static void       set_vmindex(oop mh, int index);
 894 
 895   // Testers
 896   static bool is_subclass(klassOop klass) {
 897     return Klass::cast(klass)->is_subclass_of(SystemDictionary::DirectMethodHandle_klass());
 898   }
 899   static bool is_instance(oop obj) {
 900     return obj != NULL && is_subclass(obj->klass());
 901   }
 902 
 903   // Accessors for code generation:
 904   static int vmindex_offset_in_bytes()          { return _vmindex_offset; }
 905 };
 906 


 997   static void       set_vmcount(oop mh, int count);
 998 
 999   // Testers
1000   static bool is_subclass(klassOop klass) {
1001     return SystemDictionary::CountingMethodHandle_klass() != NULL &&
1002       Klass::cast(klass)->is_subclass_of(SystemDictionary::CountingMethodHandle_klass());
1003   }
1004   static bool is_instance(oop obj) {
1005     return obj != NULL && is_subclass(obj->klass());
1006   }
1007 
1008   // Accessors for code generation:
1009   static int vmcount_offset_in_bytes()          { return _vmcount_offset; }
1010 };
1011 
1012 
1013 
1014 // Interface to java.lang.invoke.MemberName objects
1015 // (These are a private interface for Java code to query the class hierarchy.)
1016 
1017 #define MEMBERNAME_INJECTED_FIELDS(macro)                              \
1018   macro(java_lang_invoke_MemberName, vmtarget, object_signature, true)
1019 
1020 class java_lang_invoke_MemberName: AllStatic {
1021   friend class JavaClasses;
1022 
1023  private:
1024   // From java.lang.invoke.MemberName:
1025   //    private Class<?>   clazz;       // class in which the method is defined
1026   //    private String     name;        // may be null if not yet materialized
1027   //    private Object     type;        // may be null if not yet materialized
1028   //    private int        flags;       // modifier bits; see reflect.Modifier
1029   //    private Object     vmtarget;    // VM-specific target value
1030   //    private int        vmindex;     // method index within class or interface
1031   static int _clazz_offset;
1032   static int _name_offset;
1033   static int _type_offset;
1034   static int _flags_offset;
1035   static int _vmtarget_offset;
1036   static int _vmindex_offset;
1037 
1038   static void compute_offsets();
1039 


1109   static oop            form(oop mt);
1110 
1111   static oop            ptype(oop mt, int index);
1112   static int            ptype_count(oop mt);
1113 
1114   static Symbol*        as_signature(oop mt, bool intern_if_not_found, TRAPS);
1115   static void           print_signature(oop mt, outputStream* st);
1116 
1117   static bool is_instance(oop obj) {
1118     return obj != NULL && obj->klass() == SystemDictionary::MethodType_klass();
1119   }
1120 
1121   static bool equals(oop mt1, oop mt2);
1122 
1123   // Accessors for code generation:
1124   static int rtype_offset_in_bytes()            { return _rtype_offset; }
1125   static int ptypes_offset_in_bytes()           { return _ptypes_offset; }
1126   static int form_offset_in_bytes()             { return _form_offset; }
1127 };
1128 
1129 #define METHODTYPEFORM_INJECTED_FIELDS(macro)                              \
1130   macro(java_lang_invoke_MethodTypeForm, vmslots,  int_signature,    true) \
1131   macro(java_lang_invoke_MethodTypeForm, vmlayout, object_signature, true)
1132 
1133 class java_lang_invoke_MethodTypeForm: AllStatic {
1134   friend class JavaClasses;
1135 
1136  private:
1137   static int _vmslots_offset;           // number of argument slots needed
1138   static int _vmlayout_offset;          // object describing internal calling sequence
1139   static int _erasedType_offset;        // erasedType = canonical MethodType
1140   static int _genericInvoker_offset;    // genericInvoker = adapter for invokeGeneric
1141 
1142   static void compute_offsets();
1143 
1144  public:
1145   // Accessors
1146   static int            vmslots(oop mtform);
1147   static void       set_vmslots(oop mtform, int vmslots);
1148 
1149   static oop            erasedType(oop mtform);
1150   static oop            genericInvoker(oop mtform);
1151 
1152   static oop            vmlayout(oop mtform);
1153   static oop       init_vmlayout(oop mtform, oop cookie);
1154 
1155   // Accessors for code generation:
1156   static int vmslots_offset_in_bytes()          { return _vmslots_offset; }
1157   static int vmlayout_offset_in_bytes()         { return _vmlayout_offset; }
1158   static int erasedType_offset_in_bytes()       { return _erasedType_offset; }
1159   static int genericInvoker_offset_in_bytes()   { return _genericInvoker_offset; }
1160 };
1161 
1162 
1163 // Interface to java.lang.invoke.CallSite objects
1164 
1165 class java_lang_invoke_CallSite: AllStatic {
1166   friend class JavaClasses;
1167 
1168 private:
1169   static int _target_offset;


1170 
1171   static void compute_offsets();
1172 
1173 public:
1174   // Accessors
1175   static oop              target(         oop site)             { return site->obj_field(             _target_offset);         }
1176   static void         set_target(         oop site, oop target) {        site->obj_field_put(         _target_offset, target); }
1177 
1178   static volatile oop     target_volatile(oop site)             { return site->obj_field_volatile(    _target_offset);         }
1179   static void         set_target_volatile(oop site, oop target) {        site->obj_field_put_volatile(_target_offset, target); }
1180 






1181   // Testers
1182   static bool is_subclass(klassOop klass) {
1183     return Klass::cast(klass)->is_subclass_of(SystemDictionary::CallSite_klass());
1184   }
1185   static bool is_instance(oop obj) {
1186     return obj != NULL && is_subclass(obj->klass());
1187   }
1188 
1189   // Accessors for code generation:
1190   static int target_offset_in_bytes()           { return _target_offset; }


1191 };
1192 
1193 
1194 // Interface to java.security.AccessControlContext objects
1195 
1196 class java_security_AccessControlContext: AllStatic {
1197  private:
1198   // Note that for this class the layout changed between JDK1.2 and JDK1.3,
1199   // so we compute the offsets at startup rather than hard-wiring them.
1200   static int _context_offset;
1201   static int _privilegedContext_offset;
1202   static int _isPrivileged_offset;
1203 
1204   static void compute_offsets();
1205  public:
1206   static oop create(objArrayHandle context, bool isPrivileged, Handle privileged_context, TRAPS);
1207 
1208   // Debugging/initialization
1209   friend class JavaClasses;
1210 };
1211 
1212 
1213 // Interface to java.lang.ClassLoader objects
1214 
1215 class java_lang_ClassLoader : AllStatic {
1216  private:
1217   enum {
1218    hc_parent_offset = 0
1219   };
1220 
1221   static bool offsets_computed;
1222   static int parent_offset;
1223   static int parallelCapable_offset;
1224 
1225   static void compute_offsets();
1226 
1227  public:
1228   static oop parent(oop loader);
1229 
1230   // Support for parallelCapable field
1231   static bool parallelCapable(oop the_class_mirror);
1232 
1233   static bool is_trusted_loader(oop loader);
1234 
1235   // Fix for 4474172
1236   static oop  non_reflection_class_loader(oop loader);
1237 
1238   // Debugging
1239   friend class JavaClasses;
1240 };
1241 
1242 
1243 // Interface to java.lang.System objects
1244 
1245 class java_lang_System : AllStatic {
1246  private:
1247   enum {
1248    hc_static_in_offset  = 0,
1249    hc_static_out_offset = 1,
1250    hc_static_err_offset = 2
1251   };
1252 


1334   static void compute_offsets();
1335 };
1336 
1337 class sun_misc_AtomicLongCSImpl: AllStatic {
1338  private:
1339   static int _value_offset;
1340 
1341  public:
1342   static int  value_offset();
1343   static void compute_offsets();
1344 };
1345 
1346 class java_util_concurrent_locks_AbstractOwnableSynchronizer : AllStatic {
1347  private:
1348   static int  _owner_offset;
1349  public:
1350   static void initialize(TRAPS);
1351   static oop  get_owner_threadObj(oop obj);
1352 };
1353 
1354 // Use to declare fields that need to be injected into Java classes
1355 // for the JVM to use.  The name_index and signature_index are
1356 // declared in vmSymbols.  The may_be_java flag is used to declare
1357 // fields that might already exist in Java but should be injected if
1358 // they don't.  Otherwise the field is unconditionally injected and
1359 // the JVM uses the injected one.  This is to ensure that name
1360 // collisions don't occur.  In general may_be_java should be false
1361 // unless there's a good reason.
1362 
1363 class InjectedField {
1364  public:
1365   const SystemDictionary::WKID klass_id;
1366   const vmSymbols::SID name_index;
1367   const vmSymbols::SID signature_index;
1368   const bool           may_be_java;
1369                               
1370 
1371   klassOop klass() const    { return SystemDictionary::well_known_klass(klass_id); }
1372   Symbol* name() const      { return lookup_symbol(name_index); }
1373   Symbol* signature() const { return lookup_symbol(signature_index); }
1374 
1375   int compute_offset();
1376 
1377   // Find the Symbol for this index
1378   static Symbol* lookup_symbol(int symbol_index) {
1379     return vmSymbols::symbol_at((vmSymbols::SID)symbol_index);
1380   }
1381 };
1382 
1383 #define DECLARE_INJECTED_FIELD_ENUM(klass, name, signature, may_be_java) \
1384   klass##_##name##_enum,
1385 
1386 #define ALL_INJECTED_FIELDS(macro)          \
1387   CLASS_INJECTED_FIELDS(macro)              \
1388   METHODHANDLE_INJECTED_FIELDS(macro)       \
1389   DIRECTMETHODHANDLE_INJECTED_FIELDS(macro) \
1390   MEMBERNAME_INJECTED_FIELDS(macro)         \
1391   METHODTYPEFORM_INJECTED_FIELDS(macro)
1392 
1393 // Interface to hard-coded offset checking
1394 
1395 class JavaClasses : AllStatic {
1396  private:
1397 
1398   static InjectedField _injected_fields[];
1399 
1400   static bool check_offset(const char *klass_name, int offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0;
1401   static bool check_static_offset(const char *klass_name, int hardcoded_offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0;
1402   static bool check_constant(const char *klass_name, int constant, const char *field_name, const char* field_sig) PRODUCT_RETURN0;
1403 
1404  public:
1405   enum InjectedFieldID {
1406     ALL_INJECTED_FIELDS(DECLARE_INJECTED_FIELD_ENUM)
1407     MAX_enum
1408   };
1409 
1410   static int compute_injected_offset(InjectedFieldID id);
1411 
1412   static void compute_hard_coded_offsets();
1413   static void compute_offsets();
1414   static void check_offsets() PRODUCT_RETURN;
1415 
1416   static InjectedField* get_injected(Symbol* class_name, int* field_count);
1417 };
1418 
1419 #undef DECLARE_INJECTED_FIELD_ENUM
1420 
1421 #endif // SHARE_VM_CLASSFILE_JAVACLASSES_HPP
src/share/vm/classfile/javaClasses.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File