@@ -868,6 +868,7 @@ int java_lang_Class::_classData_offset;
868868int java_lang_Class::_classRedefinedCount_offset;
869869int java_lang_Class::_reflectionData_offset;
870870int java_lang_Class::_modifiers_offset;
871+ int java_lang_Class::_is_primitive_offset;
871872
872873bool java_lang_Class::_offsets_computed = false ;
873874GrowableArray<Klass*>* java_lang_Class::_fixup_mirror_list = nullptr ;
@@ -1062,7 +1063,7 @@ void java_lang_Class::allocate_mirror(Klass* k, bool is_scratch, Handle protecti
10621063 set_klass (mirror (), k);
10631064
10641065 // Set the modifiers flag.
1065- int computed_modifiers = k->compute_modifier_flags ();
1066+ u2 computed_modifiers = k->compute_modifier_flags ();
10661067 set_modifiers (mirror (), computed_modifiers);
10671068
10681069 InstanceMirrorKlass* mk = InstanceMirrorKlass::cast (mirror->klass ());
@@ -1272,8 +1273,11 @@ void java_lang_Class::set_protection_domain(oop java_class, oop pd) {
12721273
12731274void java_lang_Class::set_component_mirror (oop java_class, oop comp_mirror) {
12741275 assert (_component_mirror_offset != 0 , " must be set" );
1275- java_class->obj_field_put (_component_mirror_offset, comp_mirror);
1276- }
1276+ assert (java_lang_Class::as_Klass (java_class) != nullptr &&
1277+ java_lang_Class::as_Klass (java_class)->is_array_klass (), " must be" );
1278+ java_class->obj_field_put (_component_mirror_offset, comp_mirror);
1279+ }
1280+
12771281oop java_lang_Class::component_mirror (oop java_class) {
12781282 assert (_component_mirror_offset != 0 , " must be set" );
12791283 return java_class->obj_field (_component_mirror_offset);
@@ -1347,9 +1351,14 @@ void java_lang_Class::set_source_file(oop java_class, oop source_file) {
13471351 java_class->obj_field_put (_source_file_offset, source_file);
13481352}
13491353
1354+ void java_lang_Class::set_is_primitive (oop java_class) {
1355+ assert (_is_primitive_offset != 0 , " must be set" );
1356+ java_class->bool_field_put (_is_primitive_offset, true );
1357+ }
1358+
1359+
13501360oop java_lang_Class::create_basic_type_mirror (const char * basic_type_name, BasicType type, TRAPS) {
1351- // This should be improved by adding a field at the Java level or by
1352- // introducing a new VM klass (see comment in ClassFileParser)
1361+ // Mirrors for basic types have a null klass field, which makes them special.
13531362 oop java_class = InstanceMirrorKlass::cast (vmClasses::Class_klass ())->allocate_instance (nullptr , CHECK_NULL);
13541363 if (type != T_VOID) {
13551364 Klass* aklass = Universe::typeArrayKlass (type);
@@ -1361,6 +1370,7 @@ oop java_lang_Class::create_basic_type_mirror(const char* basic_type_name, Basic
13611370 assert (static_oop_field_count (java_class) == 0 , " should have been zeroed by allocation" );
13621371#endif
13631372 set_modifiers (java_class, JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC);
1373+ set_is_primitive (java_class);
13641374 return java_class;
13651375}
13661376
@@ -1500,8 +1510,9 @@ oop java_lang_Class::primitive_mirror(BasicType t) {
15001510 macro (_classData_offset, k, " classData" , object_signature, false ); \
15011511 macro (_reflectionData_offset, k, " reflectionData" , java_lang_ref_SoftReference_signature, false ); \
15021512 macro (_signers_offset, k, " signers" , object_array_signature, false ); \
1503- macro (_modifiers_offset, k, vmSymbols::modifiers_name(), int_signature, false); \
1504- macro (_protection_domain_offset, k, " protectionDomain" , java_security_ProtectionDomain_signature, false );
1513+ macro (_modifiers_offset, k, vmSymbols::modifiers_name(), char_signature, false); \
1514+ macro (_protection_domain_offset, k, " protectionDomain" , java_security_ProtectionDomain_signature, false ); \
1515+ macro (_is_primitive_offset, k, " primitive" , bool_signature, false );
15051516
15061517void java_lang_Class::compute_offsets () {
15071518 if (_offsets_computed) {
@@ -1537,12 +1548,12 @@ void java_lang_Class::set_classRedefinedCount(oop the_class_mirror, int value) {
15371548
15381549int java_lang_Class::modifiers (oop the_class_mirror) {
15391550 assert (_modifiers_offset != 0 , " offsets should have been initialized" );
1540- return the_class_mirror->int_field (_modifiers_offset);
1551+ return the_class_mirror->char_field (_modifiers_offset);
15411552}
15421553
1543- void java_lang_Class::set_modifiers (oop the_class_mirror, int value) {
1554+ void java_lang_Class::set_modifiers (oop the_class_mirror, u2 value) {
15441555 assert (_modifiers_offset != 0 , " offsets should have been initialized" );
1545- the_class_mirror->int_field_put (_modifiers_offset, value);
1556+ the_class_mirror->char_field_put (_modifiers_offset, value);
15461557}
15471558
15481559
0 commit comments