@@ -870,6 +870,7 @@ int java_lang_Class::_classRedefinedCount_offset;
870870int java_lang_Class::_reflectionData_offset;
871871int java_lang_Class::_modifiers_offset;
872872int java_lang_Class::_is_primitive_offset;
873+ int java_lang_Class::_raw_access_flags_offset;
873874
874875bool java_lang_Class::_offsets_computed = false ;
875876GrowableArray<Klass*>* java_lang_Class::_fixup_mirror_list = nullptr ;
@@ -1073,6 +1074,10 @@ void java_lang_Class::allocate_mirror(Klass* k, bool is_scratch, Handle protecti
10731074 // Set the modifiers flag.
10741075 u2 computed_modifiers = k->compute_modifier_flags ();
10751076 set_modifiers (mirror (), computed_modifiers);
1077+ // Set the raw access_flags, this is used by reflection instead of modifier flags.
1078+ // The Java code for array classes gets the access flags from the element type.
1079+ assert (!k->is_array_klass () || k->access_flags ().as_unsigned_short () == 0 , " access flags are not set for arrays" );
1080+ set_raw_access_flags (mirror (), k->access_flags ().as_unsigned_short ());
10761081
10771082 InstanceMirrorKlass* mk = InstanceMirrorKlass::cast (mirror->klass ());
10781083 assert (oop_size (mirror ()) == mk->instance_size (k), " should have been set" );
@@ -1378,6 +1383,8 @@ oop java_lang_Class::create_basic_type_mirror(const char* basic_type_name, Basic
13781383 assert (static_oop_field_count (java_class) == 0 , " should have been zeroed by allocation" );
13791384#endif
13801385 set_modifiers (java_class, JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC);
1386+ set_raw_access_flags (java_class, JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC);
1387+
13811388 set_is_primitive (java_class);
13821389 return java_class;
13831390}
@@ -1519,6 +1526,7 @@ oop java_lang_Class::primitive_mirror(BasicType t) {
15191526 macro (_reflectionData_offset, k, " reflectionData" , java_lang_ref_SoftReference_signature, false ); \
15201527 macro (_signers_offset, k, " signers" , object_array_signature, false ); \
15211528 macro (_modifiers_offset, k, vmSymbols::modifiers_name(), char_signature, false); \
1529+ macro (_raw_access_flags_offset, k, " classFileAccessFlags" , char_signature, false ); \
15221530 macro (_protection_domain_offset, k, " protectionDomain" , java_security_ProtectionDomain_signature, false ); \
15231531 macro (_is_primitive_offset, k, " primitive" , bool_signature, false );
15241532
@@ -1564,6 +1572,16 @@ void java_lang_Class::set_modifiers(oop the_class_mirror, u2 value) {
15641572 the_class_mirror->char_field_put (_modifiers_offset, value);
15651573}
15661574
1575+ int java_lang_Class::raw_access_flags (oop the_class_mirror) {
1576+ assert (_raw_access_flags_offset != 0 , " offsets should have been initialized" );
1577+ return the_class_mirror->char_field (_raw_access_flags_offset);
1578+ }
1579+
1580+ void java_lang_Class::set_raw_access_flags (oop the_class_mirror, u2 value) {
1581+ assert (_raw_access_flags_offset != 0 , " offsets should have been initialized" );
1582+ the_class_mirror->char_field_put (_raw_access_flags_offset, value);
1583+ }
1584+
15671585
15681586// Note: JDK1.1 and before had a privateInfo_offset field which was used for the
15691587// platform thread structure, and a eetop offset which was used for thread
0 commit comments