< prev index next >

src/hotspot/share/classfile/javaClasses.hpp

Print this page

 235   friend class VMStructs;
 236   friend class JVMCIVMStructs;
 237   friend class HeapShared;
 238 
 239  private:
 240 
 241   // The fake offsets are added by the class loader when java.lang.Class is loaded
 242 
 243   static int _klass_offset;
 244   static int _array_klass_offset;
 245 
 246   static int _oop_size_offset;
 247   static int _static_oop_field_count_offset;
 248 
 249   static int _protection_domain_offset;
 250   static int _init_lock_offset;
 251   static int _signers_offset;
 252   static int _class_loader_offset;
 253   static int _module_offset;
 254   static int _component_mirror_offset;

 255   static int _name_offset;
 256   static int _source_file_offset;
 257   static int _classData_offset;
 258   static int _classRedefinedCount_offset;
 259   static int _reflectionData_offset;
 260   static int _modifiers_offset;
 261   static int _is_primitive_offset;

 262   static int _raw_access_flags_offset;
 263 
 264   static bool _offsets_computed;
 265 
 266   static GrowableArray<Klass*>* _fixup_mirror_list;
 267   static GrowableArray<Klass*>* _fixup_module_field_list;
 268 
 269   static void set_init_lock(oop java_class, oop init_lock);
 270   static void set_protection_domain(oop java_class, oop protection_domain);
 271   static void set_class_loader(oop java_class, oop class_loader);
 272   static void set_component_mirror(oop java_class, oop comp_mirror);
 273   static void initialize_mirror_fields(InstanceKlass* ik, Handle mirror, Handle protection_domain,
 274                                        Handle classData, TRAPS);
 275   static void set_mirror_module_field(JavaThread* current, Klass* K, Handle mirror, Handle module);

 276 
 277   static void set_modifiers(oop java_class, u2 value);
 278   static void set_raw_access_flags(oop java_class, u2 value);
 279   static void set_is_primitive(oop java_class);
 280   static void release_set_array_klass(oop java_class, Klass* klass);
 281 
 282  public:
 283   static void allocate_fixup_lists();
 284   static void compute_offsets();
 285 
 286   // Instance creation
 287   static void allocate_mirror(Klass* k, bool is_scratch, Handle protection_domain, Handle classData,
 288                               Handle& mirror, Handle& comp_mirror, TRAPS); // returns mirror and comp_mirror
 289   static void create_mirror(Klass* k, Handle class_loader, Handle module,
 290                             Handle protection_domain, Handle classData, TRAPS);
 291   static void fixup_mirror(Klass* k, TRAPS);
 292   static oop  create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS);
 293 
 294   // Archiving
 295   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;

 303   // Conversion -- java_class must not be null. The return value is null only if java_class is a primitive type.
 304   static Klass* as_Klass(oop java_class);
 305   static InstanceKlass* as_InstanceKlass(oop java_class);
 306 
 307   static void set_klass(oop java_class, Klass* klass);
 308   static BasicType as_BasicType(oop java_class, Klass** reference_klass = nullptr);
 309   static Symbol* as_signature(oop java_class, bool intern_if_not_found);
 310   static void print_signature(oop java_class, outputStream *st);
 311   static const char* as_external_name(oop java_class);
 312   // Testing
 313   static bool is_instance(oop obj);
 314 
 315   static bool is_primitive(oop java_class);
 316   static BasicType primitive_type(oop java_class);
 317   static oop primitive_mirror(BasicType t);
 318   static Klass* array_klass_acquire(oop java_class);
 319 
 320   // compiler support for class operations
 321   static int klass_offset()                { CHECK_INIT(_klass_offset); }
 322   static int array_klass_offset()          { CHECK_INIT(_array_klass_offset); }

 323   // Support for classRedefinedCount field
 324   static int classRedefinedCount(oop the_class_mirror);
 325   static void set_classRedefinedCount(oop the_class_mirror, int value);
 326 
 327   // Support for embedded per-class oops
 328   static oop  protection_domain(oop java_class);
 329   static oop  init_lock(oop java_class);
 330   static void clear_init_lock(oop java_class) {
 331     set_init_lock(java_class, nullptr);
 332   }
 333   static oop  component_mirror(oop java_class);
 334   static int component_mirror_offset() { return _component_mirror_offset; }
 335   static objArrayOop signers(oop java_class);
 336   static oop  class_data(oop java_class);
 337   static void set_class_data(oop java_class, oop classData);
 338   static int reflection_data_offset() { return _reflectionData_offset; }
 339 
 340   static oop class_loader(oop java_class);
 341   static void set_module(oop java_class, oop module);
 342   static oop module(oop java_class);

 644     trace_hidden_offset  = 6,
 645     trace_size           = 7,
 646     trace_chunk_size     = 32
 647   };
 648 
 649   static int _backtrace_offset;
 650   static int _detailMessage_offset;
 651   static int _stackTrace_offset;
 652   static int _depth_offset;
 653   static int _cause_offset;
 654   static int _static_unassigned_stacktrace_offset;
 655 
 656   // StackTrace (programmatic access, new since 1.4)
 657   static void clear_stacktrace(oop throwable);
 658   // Stacktrace (post JDK 1.7.0 to allow immutability protocol to be followed)
 659   static void set_stacktrace(oop throwable, oop st_element_array);
 660   static oop unassigned_stacktrace();
 661 
 662  public:
 663   // Backtrace
 664   static oop backtrace(oop throwable);
 665   static void set_backtrace(oop throwable, oop value);
 666   static int depth(oop throwable);
 667   static void set_depth(oop throwable, int value);
 668   // Message
 669   static int get_detailMessage_offset() { CHECK_INIT(_detailMessage_offset); }
 670   static oop message(oop throwable);
 671   static const char* message_as_utf8(oop throwable);
 672   static void set_message(oop throwable, oop value);
 673 
 674   static oop cause(oop throwable);
 675 
 676   static void print_stack_element(outputStream *st, Method* method, int bci);
 677 
 678   static void compute_offsets();
 679   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 680 
 681   // Allocate space for backtrace (created but stack trace not filled in)
 682   static void allocate_backtrace(Handle throwable, TRAPS);
 683   // Fill in current stack trace for throwable with preallocated backtrace (no GC)
 684   static void fill_in_stack_trace_of_preallocated_backtrace(Handle throwable);
 685   // Fill in current stack trace, can cause GC
 686   static void fill_in_stack_trace(Handle throwable, const methodHandle& method, TRAPS);
 687   static void fill_in_stack_trace(Handle throwable, const methodHandle& method = methodHandle());
 688 
 689   // Programmatic access to stack trace
 690   static void get_stack_trace_elements(int depth, Handle backtrace, objArrayHandle stack_trace, TRAPS);
 691 
 692   // For recreating class initialization error exceptions.
 693   static Handle create_initialization_error(JavaThread* current, Handle throwable);
 694 
 695   // Printing
 696   static void print(oop throwable, outputStream* st);
 697   static void print_stack_trace(Handle throwable, outputStream* st);
 698   static void java_printStackTrace(Handle throwable, TRAPS);
 699   // Debugging
 700   friend class JavaClasses;
 701   // Gets the method and bci of the top frame (TOS). Returns false if this failed.
 702   static bool get_top_method_and_bci(oop throwable, Method** method, int* bci);
 703 };
 704 
 705 
 706 // Interface to java.lang.reflect.AccessibleObject objects
 707 
 708 class java_lang_reflect_AccessibleObject: AllStatic {
 709  private:
 710   // Note that to reduce dependencies on the JDK we compute these

 814   static void set_signature(oop constructor, oop value);
 815   static void set_annotations(oop constructor, oop value);
 816   static void set_parameter_annotations(oop method, oop value);
 817 
 818   // Debugging
 819   friend class JavaClasses;
 820 };
 821 
 822 
 823 // Interface to java.lang.reflect.Field objects
 824 
 825 class java_lang_reflect_Field : public java_lang_reflect_AccessibleObject {
 826  private:
 827   // Note that to reduce dependencies on the JDK we compute these
 828   // offsets at run-time.
 829   static int _clazz_offset;
 830   static int _name_offset;
 831   static int _type_offset;
 832   static int _slot_offset;
 833   static int _modifiers_offset;
 834   static int _trusted_final_offset;
 835   static int _signature_offset;
 836   static int _annotations_offset;
 837 
 838   static void compute_offsets();
 839 
 840  public:
 841   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 842 
 843   // Allocation
 844   static Handle create(TRAPS);
 845 
 846   // Accessors
 847   static oop clazz(oop reflect);
 848   static void set_clazz(oop reflect, oop value);
 849 
 850   static oop name(oop field);
 851   static void set_name(oop field, oop value);
 852 
 853   static oop type(oop field);
 854   static void set_type(oop field, oop value);
 855 
 856   static int slot(oop reflect);
 857   static void set_slot(oop reflect, int value);
 858 
 859   static int modifiers(oop field);
 860   static void set_modifiers(oop field, int value);
 861 
 862   static void set_trusted_final(oop field);
 863 
 864   static void set_signature(oop constructor, oop value);
 865   static void set_annotations(oop constructor, oop value);
 866 
 867   // Debugging
 868   friend class JavaClasses;
 869 };
 870 
 871 class java_lang_reflect_Parameter {
 872  private:
 873   // Note that to reduce dependencies on the JDK we compute these
 874   // offsets at run-time.
 875   static int _name_offset;
 876   static int _modifiers_offset;
 877   static int _index_offset;
 878   static int _executable_offset;
 879 
 880   static void compute_offsets();
 881 
 882  public:

 964 
 965   // Debugging
 966   friend class JavaClasses;
 967 };
 968 
 969 
 970 // Interface to java.lang primitive type boxing objects:
 971 //  - java.lang.Boolean
 972 //  - java.lang.Character
 973 //  - java.lang.Float
 974 //  - java.lang.Double
 975 //  - java.lang.Byte
 976 //  - java.lang.Short
 977 //  - java.lang.Integer
 978 //  - java.lang.Long
 979 
 980 // This could be separated out into 8 individual classes.
 981 
 982 class java_lang_boxing_object: AllStatic {
 983  private:
 984   static int _value_offset;
 985   static int _long_value_offset;
 986 
 987   static void compute_offsets();
 988   static oop initialize_and_allocate(BasicType type, TRAPS);
 989  public:
 990   // Allocation. Returns a boxed value, or null for invalid type.
 991   static oop create(BasicType type, jvalue* value, TRAPS);
 992   // Accessors. Returns the basic type being boxed, or T_ILLEGAL for invalid oop.
 993   static BasicType get_value(oop box, jvalue* value);
 994   static BasicType set_value(oop box, jvalue* value);
 995   static BasicType basic_type(oop box);
 996   static bool is_instance(oop box)                 { return basic_type(box) != T_ILLEGAL; }
 997   static bool is_instance(oop box, BasicType type) { return basic_type(box) == type; }
 998   static void print(oop box, outputStream* st)     { jvalue value;  print(get_value(box, &value), &value, st); }
 999   static void print(BasicType type, jvalue* value, outputStream* st);
1000 
1001   static int value_offset(BasicType type) {
1002     return is_double_word_type(type) ? _long_value_offset : _value_offset;


1003   }
1004 
1005   static void serialize_offsets(SerializeClosure* f);
1006 
1007   // Debugging
1008   friend class JavaClasses;
1009 };
1010 
1011 
1012 
1013 // Interface to java.lang.ref.Reference objects
1014 
1015 class java_lang_ref_Reference: AllStatic {
1016   static int _referent_offset;
1017   static int _queue_offset;
1018   static int _next_offset;
1019   static int _discovered_offset;
1020 
1021   static bool _offsets_initialized;
1022 

1182 };
1183 
1184 class jdk_internal_foreign_abi_ABIDescriptor: AllStatic {
1185   friend class JavaClasses;
1186 
1187  private:
1188   static int _inputStorage_offset;
1189   static int _outputStorage_offset;
1190   static int _volatileStorage_offset;
1191   static int _stackAlignment_offset;
1192   static int _shadowSpace_offset;
1193   static int _scratch1_offset;
1194   static int _scratch2_offset;
1195 
1196   static void compute_offsets();
1197 
1198  public:
1199   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1200 
1201   // Accessors
1202   static objArrayOop inputStorage(oop entry);
1203   static objArrayOop outputStorage(oop entry);
1204   static objArrayOop volatileStorage(oop entry);
1205   static jint        stackAlignment(oop entry);
1206   static jint        shadowSpace(oop entry);
1207   static oop         scratch1(oop entry);
1208   static oop         scratch2(oop entry);
1209 };
1210 
1211 class jdk_internal_foreign_abi_VMStorage: AllStatic {
1212   friend class JavaClasses;
1213 
1214  private:
1215   static int _type_offset;
1216   static int _indexOrOffset_offset;
1217   static int _segmentMaskOrSize_offset;
1218   static int _debugName_offset;
1219 
1220   static void compute_offsets();
1221 
1222  public:
1223   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1224 

1232   static bool is_subclass(Klass* klass) {
1233     return vmClasses::VMStorage_klass() != nullptr &&
1234       klass->is_subclass_of(vmClasses::VMStorage_klass());
1235   }
1236   static bool is_instance(oop obj);
1237 };
1238 
1239 class jdk_internal_foreign_abi_CallConv: AllStatic {
1240   friend class JavaClasses;
1241 
1242  private:
1243   static int _argRegs_offset;
1244   static int _retRegs_offset;
1245 
1246   static void compute_offsets();
1247 
1248  public:
1249   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1250 
1251   // Accessors
1252   static objArrayOop argRegs(oop entry);
1253   static objArrayOop retRegs(oop entry);
1254 
1255   // Testers
1256   static bool is_subclass(Klass* klass) {
1257     return vmClasses::CallConv_klass() != nullptr &&
1258       klass->is_subclass_of(vmClasses::CallConv_klass());
1259   }
1260   static bool is_instance(oop obj);
1261 };
1262 
1263 // Interface to java.lang.invoke.MemberName objects
1264 // (These are a private interface for Java code to query the class hierarchy.)
1265 
1266 #define RESOLVEDMETHOD_INJECTED_FIELDS(macro)                                   \
1267   macro(java_lang_invoke_ResolvedMethodName, vmtarget, intptr_signature, false)
1268 
1269 class java_lang_invoke_ResolvedMethodName : AllStatic {
1270   friend class JavaClasses;
1271 
1272   static int _vmtarget_offset;
1273   static int _vmholder_offset;

1330   static void       set_flags(oop mname, int flags);
1331 
1332   // Link through ResolvedMethodName field to get Method*
1333   static Method*        vmtarget(oop mname);
1334   static void       set_method(oop mname, oop method);
1335 
1336   static intptr_t       vmindex(oop mname);
1337   static void       set_vmindex(oop mname, intptr_t index);
1338 
1339   // Testers
1340   static bool is_subclass(Klass* klass) {
1341     return klass->is_subclass_of(vmClasses::MemberName_klass());
1342   }
1343   static bool is_instance(oop obj);
1344 
1345   static bool is_method(oop obj);
1346 
1347   // Relevant integer codes (keep these in synch. with MethodHandleNatives.Constants):
1348   enum {
1349     MN_IS_METHOD             = 0x00010000, // method (not constructor)
1350     MN_IS_CONSTRUCTOR        = 0x00020000, // constructor
1351     MN_IS_FIELD              = 0x00040000, // field
1352     MN_IS_TYPE               = 0x00080000, // nested type
1353     MN_CALLER_SENSITIVE      = 0x00100000, // @CallerSensitive annotation detected
1354     MN_TRUSTED_FINAL         = 0x00200000, // trusted final field
1355     MN_HIDDEN_MEMBER         = 0x00400000, // @Hidden annotation detected

1356     MN_REFERENCE_KIND_SHIFT  = 24, // refKind
1357     MN_REFERENCE_KIND_MASK   = 0x0F000000 >> MN_REFERENCE_KIND_SHIFT,


1358     MN_NESTMATE_CLASS        = 0x00000001,
1359     MN_HIDDEN_CLASS          = 0x00000002,
1360     MN_STRONG_LOADER_LINK    = 0x00000004,
1361     MN_ACCESS_VM_ANNOTATIONS = 0x00000008,
1362     // Lookup modes
1363     MN_MODULE_MODE           = 0x00000010,
1364     MN_UNCONDITIONAL_MODE    = 0x00000020,
1365     MN_TRUSTED_MODE          = -1
1366   };
1367 
1368   // Accessors for code generation:
1369   static int clazz_offset()   { CHECK_INIT(_clazz_offset); }
1370   static int type_offset()    { CHECK_INIT(_type_offset); }
1371   static int flags_offset()   { CHECK_INIT(_flags_offset); }
1372   static int method_offset()  { CHECK_INIT(_method_offset); }
1373   static int vmindex_offset() { CHECK_INIT(_vmindex_offset); }
1374 };
1375 
1376 
1377 // Interface to java.lang.invoke.MethodType objects
1378 
1379 class java_lang_invoke_MethodType: AllStatic {
1380   friend class JavaClasses;
1381 
1382  private:
1383   static int _rtype_offset;
1384   static int _ptypes_offset;
1385 
1386   static void compute_offsets();
1387 
1388  public:
1389   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1390   // Accessors
1391   static oop            rtype(oop mt);
1392   static objArrayOop    ptypes(oop mt);
1393 
1394   static oop            ptype(oop mt, int index);
1395   static int            ptype_count(oop mt);
1396 
1397   static int            ptype_slot_count(oop mt);  // extra counts for long/double
1398   static int            rtype_slot_count(oop mt);  // extra counts for long/double
1399 
1400   static Symbol*        as_signature(oop mt, bool intern_if_not_found);
1401   static void           print_signature(oop mt, outputStream* st);
1402 
1403   static bool is_instance(oop obj);
1404 
1405   static bool equals(oop mt1, oop mt2);
1406 
1407   // Accessors for code generation:
1408   static int rtype_offset()  { CHECK_INIT(_rtype_offset); }
1409   static int ptypes_offset() { CHECK_INIT(_ptypes_offset); }
1410 };
1411 
1412 

1797 
1798 class java_lang_Boolean : AllStatic {
1799  private:
1800   static int _static_TRUE_offset;
1801   static int _static_FALSE_offset;
1802  public:
1803   static Symbol* symbol();
1804   static void compute_offsets(InstanceKlass* k);
1805   static oop  get_TRUE(InstanceKlass *k);
1806   static oop  get_FALSE(InstanceKlass *k);
1807   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1808   static jboolean value(oop obj);
1809 };
1810 
1811 class java_lang_Integer_IntegerCache : AllStatic {
1812  private:
1813   static int _static_cache_offset;
1814  public:
1815   static Symbol* symbol();
1816   static void compute_offsets(InstanceKlass* k);
1817   static objArrayOop  cache(InstanceKlass *k);
1818   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1819 };
1820 
1821 class java_lang_Long_LongCache : AllStatic {
1822  private:
1823   static int _static_cache_offset;
1824  public:
1825   static Symbol* symbol();
1826   static void compute_offsets(InstanceKlass* k);
1827   static objArrayOop  cache(InstanceKlass *k);
1828   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1829 };
1830 
1831 class java_lang_Character_CharacterCache : AllStatic {
1832  private:
1833   static int _static_cache_offset;
1834  public:
1835   static Symbol* symbol();
1836   static void compute_offsets(InstanceKlass* k);
1837   static objArrayOop  cache(InstanceKlass *k);
1838   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1839 };
1840 
1841 class java_lang_Short_ShortCache : AllStatic {
1842  private:
1843   static int _static_cache_offset;
1844  public:
1845   static Symbol* symbol();
1846   static void compute_offsets(InstanceKlass* k);
1847   static objArrayOop  cache(InstanceKlass *k);
1848   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1849 };
1850 
1851 class java_lang_Byte_ByteCache : AllStatic {
1852  private:
1853   static int _static_cache_offset;
1854  public:
1855   static Symbol* symbol();
1856   static void compute_offsets(InstanceKlass* k);
1857   static objArrayOop  cache(InstanceKlass *k);
1858   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1859 };
1860 
1861 
1862 // Interface to java.lang.InternalError objects
1863 
1864 #define INTERNALERROR_INJECTED_FIELDS(macro)                      \
1865   macro(java_lang_InternalError, during_unsafe_access, bool_signature, false)
1866 
1867 class java_lang_InternalError : AllStatic {
1868  private:
1869   static int _during_unsafe_access_offset;
1870  public:
1871   static jboolean during_unsafe_access(oop internal_error);
1872   static void set_during_unsafe_access(oop internal_error);
1873   static void compute_offsets();
1874   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1875 };
1876 
1877 // Use to declare fields that need to be injected into Java classes
1878 // for the JVM to use.  The name_index and signature_index are
1879 // declared in vmSymbols.  The may_be_java flag is used to declare
1880 // fields that might already exist in Java but should be injected if
1881 // they don't.  Otherwise the field is unconditionally injected and

 235   friend class VMStructs;
 236   friend class JVMCIVMStructs;
 237   friend class HeapShared;
 238 
 239  private:
 240 
 241   // The fake offsets are added by the class loader when java.lang.Class is loaded
 242 
 243   static int _klass_offset;
 244   static int _array_klass_offset;
 245 
 246   static int _oop_size_offset;
 247   static int _static_oop_field_count_offset;
 248 
 249   static int _protection_domain_offset;
 250   static int _init_lock_offset;
 251   static int _signers_offset;
 252   static int _class_loader_offset;
 253   static int _module_offset;
 254   static int _component_mirror_offset;
 255 
 256   static int _name_offset;
 257   static int _source_file_offset;
 258   static int _classData_offset;
 259   static int _classRedefinedCount_offset;
 260   static int _reflectionData_offset;
 261   static int _modifiers_offset;
 262   static int _is_primitive_offset;
 263   static int _is_identity_offset;
 264   static int _raw_access_flags_offset;
 265 
 266   static bool _offsets_computed;
 267 
 268   static GrowableArray<Klass*>* _fixup_mirror_list;
 269   static GrowableArray<Klass*>* _fixup_module_field_list;
 270 
 271   static void set_init_lock(oop java_class, oop init_lock);
 272   static void set_protection_domain(oop java_class, oop protection_domain);
 273   static void set_class_loader(oop java_class, oop class_loader);
 274   static void set_component_mirror(oop java_class, oop comp_mirror);
 275   static void initialize_mirror_fields(InstanceKlass* ik, Handle mirror, Handle protection_domain,
 276                                        Handle classData, TRAPS);
 277   static void set_mirror_module_field(JavaThread* current, Klass* K, Handle mirror, Handle module);
 278   static void set_is_identity(oop java_class, bool value);
 279 
 280   static void set_modifiers(oop java_class, u2 value);
 281   static void set_raw_access_flags(oop java_class, u2 value);
 282   static void set_is_primitive(oop java_class);
 283   static void release_set_array_klass(oop java_class, Klass* klass);
 284 
 285  public:
 286   static void allocate_fixup_lists();
 287   static void compute_offsets();
 288 
 289   // Instance creation
 290   static void allocate_mirror(Klass* k, bool is_scratch, Handle protection_domain, Handle classData,
 291                               Handle& mirror, Handle& comp_mirror, TRAPS); // returns mirror and comp_mirror
 292   static void create_mirror(Klass* k, Handle class_loader, Handle module,
 293                             Handle protection_domain, Handle classData, TRAPS);
 294   static void fixup_mirror(Klass* k, TRAPS);
 295   static oop  create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS);
 296 
 297   // Archiving
 298   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;

 306   // Conversion -- java_class must not be null. The return value is null only if java_class is a primitive type.
 307   static Klass* as_Klass(oop java_class);
 308   static InstanceKlass* as_InstanceKlass(oop java_class);
 309 
 310   static void set_klass(oop java_class, Klass* klass);
 311   static BasicType as_BasicType(oop java_class, Klass** reference_klass = nullptr);
 312   static Symbol* as_signature(oop java_class, bool intern_if_not_found);
 313   static void print_signature(oop java_class, outputStream *st);
 314   static const char* as_external_name(oop java_class);
 315   // Testing
 316   static bool is_instance(oop obj);
 317 
 318   static bool is_primitive(oop java_class);
 319   static BasicType primitive_type(oop java_class);
 320   static oop primitive_mirror(BasicType t);
 321   static Klass* array_klass_acquire(oop java_class);
 322 
 323   // compiler support for class operations
 324   static int klass_offset()                { CHECK_INIT(_klass_offset); }
 325   static int array_klass_offset()          { CHECK_INIT(_array_klass_offset); }
 326 
 327   // Support for classRedefinedCount field
 328   static int classRedefinedCount(oop the_class_mirror);
 329   static void set_classRedefinedCount(oop the_class_mirror, int value);
 330 
 331   // Support for embedded per-class oops
 332   static oop  protection_domain(oop java_class);
 333   static oop  init_lock(oop java_class);
 334   static void clear_init_lock(oop java_class) {
 335     set_init_lock(java_class, nullptr);
 336   }
 337   static oop  component_mirror(oop java_class);
 338   static int component_mirror_offset() { return _component_mirror_offset; }
 339   static objArrayOop signers(oop java_class);
 340   static oop  class_data(oop java_class);
 341   static void set_class_data(oop java_class, oop classData);
 342   static int reflection_data_offset() { return _reflectionData_offset; }
 343 
 344   static oop class_loader(oop java_class);
 345   static void set_module(oop java_class, oop module);
 346   static oop module(oop java_class);

 648     trace_hidden_offset  = 6,
 649     trace_size           = 7,
 650     trace_chunk_size     = 32
 651   };
 652 
 653   static int _backtrace_offset;
 654   static int _detailMessage_offset;
 655   static int _stackTrace_offset;
 656   static int _depth_offset;
 657   static int _cause_offset;
 658   static int _static_unassigned_stacktrace_offset;
 659 
 660   // StackTrace (programmatic access, new since 1.4)
 661   static void clear_stacktrace(oop throwable);
 662   // Stacktrace (post JDK 1.7.0 to allow immutability protocol to be followed)
 663   static void set_stacktrace(oop throwable, oop st_element_array);
 664   static oop unassigned_stacktrace();
 665 
 666  public:
 667   // Backtrace
 668   static refArrayOop backtrace(oop throwable);
 669   static void set_backtrace(oop throwable, refArrayOop value);
 670   static int depth(oop throwable);
 671   static void set_depth(oop throwable, int value);
 672   // Message
 673   static int get_detailMessage_offset() { CHECK_INIT(_detailMessage_offset); }
 674   static oop message(oop throwable);
 675   static const char* message_as_utf8(oop throwable);
 676   static void set_message(oop throwable, oop value);
 677 
 678   static oop cause(oop throwable);
 679 
 680   static void print_stack_element(outputStream *st, Method* method, int bci);
 681 
 682   static void compute_offsets();
 683   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 684 
 685   // Allocate space for backtrace (created but stack trace not filled in)
 686   static void allocate_backtrace(Handle throwable, TRAPS);
 687   // Fill in current stack trace for throwable with preallocated backtrace (no GC)
 688   static void fill_in_stack_trace_of_preallocated_backtrace(Handle throwable);
 689   // Fill in current stack trace, can cause GC
 690   static void fill_in_stack_trace(Handle throwable, const methodHandle& method, TRAPS);
 691   static void fill_in_stack_trace(Handle throwable, const methodHandle& method = methodHandle());
 692 
 693   // Programmatic access to stack trace
 694   static void get_stack_trace_elements(int depth, Handle backtrace, refArrayHandle stack_trace, TRAPS);
 695 
 696   // For recreating class initialization error exceptions.
 697   static Handle create_initialization_error(JavaThread* current, Handle throwable);
 698 
 699   // Printing
 700   static void print(oop throwable, outputStream* st);
 701   static void print_stack_trace(Handle throwable, outputStream* st);
 702   static void java_printStackTrace(Handle throwable, TRAPS);
 703   // Debugging
 704   friend class JavaClasses;
 705   // Gets the method and bci of the top frame (TOS). Returns false if this failed.
 706   static bool get_top_method_and_bci(oop throwable, Method** method, int* bci);
 707 };
 708 
 709 
 710 // Interface to java.lang.reflect.AccessibleObject objects
 711 
 712 class java_lang_reflect_AccessibleObject: AllStatic {
 713  private:
 714   // Note that to reduce dependencies on the JDK we compute these

 818   static void set_signature(oop constructor, oop value);
 819   static void set_annotations(oop constructor, oop value);
 820   static void set_parameter_annotations(oop method, oop value);
 821 
 822   // Debugging
 823   friend class JavaClasses;
 824 };
 825 
 826 
 827 // Interface to java.lang.reflect.Field objects
 828 
 829 class java_lang_reflect_Field : public java_lang_reflect_AccessibleObject {
 830  private:
 831   // Note that to reduce dependencies on the JDK we compute these
 832   // offsets at run-time.
 833   static int _clazz_offset;
 834   static int _name_offset;
 835   static int _type_offset;
 836   static int _slot_offset;
 837   static int _modifiers_offset;
 838   static int _flags_offset;
 839   static int _signature_offset;
 840   static int _annotations_offset;
 841 
 842   static void compute_offsets();
 843 
 844  public:
 845   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 846 
 847   // Allocation
 848   static Handle create(TRAPS);
 849 
 850   // Accessors
 851   static oop clazz(oop reflect);
 852   static void set_clazz(oop reflect, oop value);
 853 
 854   static oop name(oop field);
 855   static void set_name(oop field, oop value);
 856 
 857   static oop type(oop field);
 858   static void set_type(oop field, oop value);
 859 
 860   static int slot(oop reflect);
 861   static void set_slot(oop reflect, int value);
 862 
 863   static int modifiers(oop field);
 864   static void set_modifiers(oop field, int value);
 865 
 866   static void set_flags(oop field, int value);
 867 
 868   static void set_signature(oop constructor, oop value);
 869   static void set_annotations(oop constructor, oop value);
 870 
 871   // Debugging
 872   friend class JavaClasses;
 873 };
 874 
 875 class java_lang_reflect_Parameter {
 876  private:
 877   // Note that to reduce dependencies on the JDK we compute these
 878   // offsets at run-time.
 879   static int _name_offset;
 880   static int _modifiers_offset;
 881   static int _index_offset;
 882   static int _executable_offset;
 883 
 884   static void compute_offsets();
 885 
 886  public:

 968 
 969   // Debugging
 970   friend class JavaClasses;
 971 };
 972 
 973 
 974 // Interface to java.lang primitive type boxing objects:
 975 //  - java.lang.Boolean
 976 //  - java.lang.Character
 977 //  - java.lang.Float
 978 //  - java.lang.Double
 979 //  - java.lang.Byte
 980 //  - java.lang.Short
 981 //  - java.lang.Integer
 982 //  - java.lang.Long
 983 
 984 // This could be separated out into 8 individual classes.
 985 
 986 class java_lang_boxing_object: AllStatic {
 987  private:
 988   static int* _offsets;

 989 
 990   static void compute_offsets();
 991   static oop initialize_and_allocate(BasicType type, TRAPS);
 992  public:
 993   // Allocation. Returns a boxed value, or null for invalid type.
 994   static oop create(BasicType type, jvalue* value, TRAPS);
 995   // Accessors. Returns the basic type being boxed, or T_ILLEGAL for invalid oop.
 996   static BasicType get_value(oop box, jvalue* value);
 997   static BasicType set_value(oop box, jvalue* value);
 998   static BasicType basic_type(oop box);
 999   static bool is_instance(oop box)                 { return basic_type(box) != T_ILLEGAL; }
1000   static bool is_instance(oop box, BasicType type) { return basic_type(box) == type; }
1001   static void print(oop box, outputStream* st)     { jvalue value;  print(get_value(box, &value), &value, st); }
1002   static void print(BasicType type, jvalue* value, outputStream* st);
1003 
1004   static int value_offset(BasicType type) {
1005     assert(type >= T_BOOLEAN && type <= T_LONG, "BasicType out of range");
1006     assert(_offsets != nullptr, "Uninitialized offsets");
1007     return _offsets[type - T_BOOLEAN];
1008   }
1009 
1010   static void serialize_offsets(SerializeClosure* f);
1011 
1012   // Debugging
1013   friend class JavaClasses;
1014 };
1015 
1016 
1017 
1018 // Interface to java.lang.ref.Reference objects
1019 
1020 class java_lang_ref_Reference: AllStatic {
1021   static int _referent_offset;
1022   static int _queue_offset;
1023   static int _next_offset;
1024   static int _discovered_offset;
1025 
1026   static bool _offsets_initialized;
1027 

1187 };
1188 
1189 class jdk_internal_foreign_abi_ABIDescriptor: AllStatic {
1190   friend class JavaClasses;
1191 
1192  private:
1193   static int _inputStorage_offset;
1194   static int _outputStorage_offset;
1195   static int _volatileStorage_offset;
1196   static int _stackAlignment_offset;
1197   static int _shadowSpace_offset;
1198   static int _scratch1_offset;
1199   static int _scratch2_offset;
1200 
1201   static void compute_offsets();
1202 
1203  public:
1204   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1205 
1206   // Accessors
1207   static refArrayOop inputStorage(oop entry);
1208   static refArrayOop outputStorage(oop entry);
1209   static refArrayOop volatileStorage(oop entry);
1210   static jint        stackAlignment(oop entry);
1211   static jint        shadowSpace(oop entry);
1212   static oop         scratch1(oop entry);
1213   static oop         scratch2(oop entry);
1214 };
1215 
1216 class jdk_internal_foreign_abi_VMStorage: AllStatic {
1217   friend class JavaClasses;
1218 
1219  private:
1220   static int _type_offset;
1221   static int _indexOrOffset_offset;
1222   static int _segmentMaskOrSize_offset;
1223   static int _debugName_offset;
1224 
1225   static void compute_offsets();
1226 
1227  public:
1228   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1229 

1237   static bool is_subclass(Klass* klass) {
1238     return vmClasses::VMStorage_klass() != nullptr &&
1239       klass->is_subclass_of(vmClasses::VMStorage_klass());
1240   }
1241   static bool is_instance(oop obj);
1242 };
1243 
1244 class jdk_internal_foreign_abi_CallConv: AllStatic {
1245   friend class JavaClasses;
1246 
1247  private:
1248   static int _argRegs_offset;
1249   static int _retRegs_offset;
1250 
1251   static void compute_offsets();
1252 
1253  public:
1254   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1255 
1256   // Accessors
1257   static refArrayOop argRegs(oop entry);
1258   static refArrayOop retRegs(oop entry);
1259 
1260   // Testers
1261   static bool is_subclass(Klass* klass) {
1262     return vmClasses::CallConv_klass() != nullptr &&
1263       klass->is_subclass_of(vmClasses::CallConv_klass());
1264   }
1265   static bool is_instance(oop obj);
1266 };
1267 
1268 // Interface to java.lang.invoke.MemberName objects
1269 // (These are a private interface for Java code to query the class hierarchy.)
1270 
1271 #define RESOLVEDMETHOD_INJECTED_FIELDS(macro)                                   \
1272   macro(java_lang_invoke_ResolvedMethodName, vmtarget, intptr_signature, false)
1273 
1274 class java_lang_invoke_ResolvedMethodName : AllStatic {
1275   friend class JavaClasses;
1276 
1277   static int _vmtarget_offset;
1278   static int _vmholder_offset;

1335   static void       set_flags(oop mname, int flags);
1336 
1337   // Link through ResolvedMethodName field to get Method*
1338   static Method*        vmtarget(oop mname);
1339   static void       set_method(oop mname, oop method);
1340 
1341   static intptr_t       vmindex(oop mname);
1342   static void       set_vmindex(oop mname, intptr_t index);
1343 
1344   // Testers
1345   static bool is_subclass(Klass* klass) {
1346     return klass->is_subclass_of(vmClasses::MemberName_klass());
1347   }
1348   static bool is_instance(oop obj);
1349 
1350   static bool is_method(oop obj);
1351 
1352   // Relevant integer codes (keep these in synch. with MethodHandleNatives.Constants):
1353   enum {
1354     MN_IS_METHOD             = 0x00010000, // method (not constructor)
1355     MN_IS_OBJECT_CONSTRUCTOR = 0x00020000, // constructor
1356     MN_IS_FIELD              = 0x00040000, // field
1357     MN_IS_TYPE               = 0x00080000, // nested type
1358     MN_CALLER_SENSITIVE      = 0x00100000, // @CallerSensitive annotation detected
1359     MN_TRUSTED_FINAL         = 0x00200000, // trusted final field
1360     MN_HIDDEN_MEMBER         = 0x00400000, // @Hidden annotation detected
1361     MN_NULL_RESTRICTED_FIELD = 0x00800000, // null-restricted field
1362     MN_REFERENCE_KIND_SHIFT  = 24, // refKind
1363     MN_REFERENCE_KIND_MASK   = 0x0F000000 >> MN_REFERENCE_KIND_SHIFT, // 4 bits
1364     MN_LAYOUT_SHIFT          = 28, // field layout
1365     MN_LAYOUT_MASK           = 0x70000000 >> MN_LAYOUT_SHIFT, // 3 bits
1366     MN_NESTMATE_CLASS        = 0x00000001,
1367     MN_HIDDEN_CLASS          = 0x00000002,
1368     MN_STRONG_LOADER_LINK    = 0x00000004,
1369     MN_ACCESS_VM_ANNOTATIONS = 0x00000008,
1370     // Lookup modes
1371     MN_MODULE_MODE           = 0x00000010,
1372     MN_UNCONDITIONAL_MODE    = 0x00000020,
1373     MN_TRUSTED_MODE          = -1
1374   };
1375 
1376   // Accessors for code generation:
1377   static int clazz_offset()   { CHECK_INIT(_clazz_offset); }
1378   static int type_offset()    { CHECK_INIT(_type_offset); }
1379   static int flags_offset()   { CHECK_INIT(_flags_offset); }
1380   static int method_offset()  { CHECK_INIT(_method_offset); }
1381   static int vmindex_offset() { CHECK_INIT(_vmindex_offset); }
1382 };
1383 
1384 
1385 // Interface to java.lang.invoke.MethodType objects
1386 
1387 class java_lang_invoke_MethodType: AllStatic {
1388   friend class JavaClasses;
1389 
1390  private:
1391   static int _rtype_offset;
1392   static int _ptypes_offset;
1393 
1394   static void compute_offsets();
1395 
1396  public:
1397   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1398   // Accessors
1399   static oop            rtype(oop mt);
1400   static refArrayOop    ptypes(oop mt);
1401 
1402   static oop            ptype(oop mt, int index);
1403   static int            ptype_count(oop mt);
1404 
1405   static int            ptype_slot_count(oop mt);  // extra counts for long/double
1406   static int            rtype_slot_count(oop mt);  // extra counts for long/double
1407 
1408   static Symbol*        as_signature(oop mt, bool intern_if_not_found);
1409   static void           print_signature(oop mt, outputStream* st);
1410 
1411   static bool is_instance(oop obj);
1412 
1413   static bool equals(oop mt1, oop mt2);
1414 
1415   // Accessors for code generation:
1416   static int rtype_offset()  { CHECK_INIT(_rtype_offset); }
1417   static int ptypes_offset() { CHECK_INIT(_ptypes_offset); }
1418 };
1419 
1420 

1805 
1806 class java_lang_Boolean : AllStatic {
1807  private:
1808   static int _static_TRUE_offset;
1809   static int _static_FALSE_offset;
1810  public:
1811   static Symbol* symbol();
1812   static void compute_offsets(InstanceKlass* k);
1813   static oop  get_TRUE(InstanceKlass *k);
1814   static oop  get_FALSE(InstanceKlass *k);
1815   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1816   static jboolean value(oop obj);
1817 };
1818 
1819 class java_lang_Integer_IntegerCache : AllStatic {
1820  private:
1821   static int _static_cache_offset;
1822  public:
1823   static Symbol* symbol();
1824   static void compute_offsets(InstanceKlass* k);
1825   static refArrayOop  cache(InstanceKlass *k);
1826   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1827 };
1828 
1829 class java_lang_Long_LongCache : AllStatic {
1830  private:
1831   static int _static_cache_offset;
1832  public:
1833   static Symbol* symbol();
1834   static void compute_offsets(InstanceKlass* k);
1835   static refArrayOop  cache(InstanceKlass *k);
1836   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1837 };
1838 
1839 class java_lang_Character_CharacterCache : AllStatic {
1840  private:
1841   static int _static_cache_offset;
1842  public:
1843   static Symbol* symbol();
1844   static void compute_offsets(InstanceKlass* k);
1845   static refArrayOop  cache(InstanceKlass *k);
1846   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1847 };
1848 
1849 class java_lang_Short_ShortCache : AllStatic {
1850  private:
1851   static int _static_cache_offset;
1852  public:
1853   static Symbol* symbol();
1854   static void compute_offsets(InstanceKlass* k);
1855   static refArrayOop  cache(InstanceKlass *k);
1856   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1857 };
1858 
1859 class java_lang_Byte_ByteCache : AllStatic {
1860  private:
1861   static int _static_cache_offset;
1862  public:
1863   static Symbol* symbol();
1864   static void compute_offsets(InstanceKlass* k);
1865   static refArrayOop  cache(InstanceKlass *k);
1866   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1867 };
1868 

1869 // Interface to java.lang.InternalError objects
1870 
1871 #define INTERNALERROR_INJECTED_FIELDS(macro)                      \
1872   macro(java_lang_InternalError, during_unsafe_access, bool_signature, false)
1873 
1874 class java_lang_InternalError : AllStatic {
1875  private:
1876   static int _during_unsafe_access_offset;
1877  public:
1878   static jboolean during_unsafe_access(oop internal_error);
1879   static void set_during_unsafe_access(oop internal_error);
1880   static void compute_offsets();
1881   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
1882 };
1883 
1884 // Use to declare fields that need to be injected into Java classes
1885 // for the JVM to use.  The name_index and signature_index are
1886 // declared in vmSymbols.  The may_be_java flag is used to declare
1887 // fields that might already exist in Java but should be injected if
1888 // they don't.  Otherwise the field is unconditionally injected and
< prev index next >