hotspot/src/share/vm/classfile/javaClasses.cpp
changeset 13738 d67be49a5beb
parent 13728 882756847a04
child 13952 e3cf184080bc
equal deleted inserted replaced
13737:aa8c9eb6d900 13738:d67be49a5beb
   498   }
   498   }
   499 }
   499 }
   500 
   500 
   501 
   501 
   502 void java_lang_Class::fixup_mirror(KlassHandle k, TRAPS) {
   502 void java_lang_Class::fixup_mirror(KlassHandle k, TRAPS) {
   503   assert(instanceMirrorKlass::offset_of_static_fields() != 0, "must have been computed already");
   503   assert(InstanceMirrorKlass::offset_of_static_fields() != 0, "must have been computed already");
   504 
   504 
   505   // If the offset was read from the shared archive, it was fixed up already
   505   // If the offset was read from the shared archive, it was fixed up already
   506   if (!k->is_shared()) {
   506   if (!k->is_shared()) {
   507   if (k->oop_is_instance()) {
   507   if (k->oop_is_instance()) {
   508     // During bootstrap, java.lang.Class wasn't loaded so static field
   508     // During bootstrap, java.lang.Class wasn't loaded so static field
   509     // offsets were computed without the size added it.  Go back and
   509     // offsets were computed without the size added it.  Go back and
   510     // update all the static field offsets to included the size.
   510     // update all the static field offsets to included the size.
   511       for (JavaFieldStream fs(InstanceKlass::cast(k())); !fs.done(); fs.next()) {
   511       for (JavaFieldStream fs(InstanceKlass::cast(k())); !fs.done(); fs.next()) {
   512       if (fs.access_flags().is_static()) {
   512       if (fs.access_flags().is_static()) {
   513         int real_offset = fs.offset() + instanceMirrorKlass::offset_of_static_fields();
   513         int real_offset = fs.offset() + InstanceMirrorKlass::offset_of_static_fields();
   514         fs.set_offset(real_offset);
   514         fs.set_offset(real_offset);
   515       }
   515       }
   516     }
   516     }
   517   }
   517   }
   518   }
   518   }
   529   k->set_modifier_flags(computed_modifiers);
   529   k->set_modifier_flags(computed_modifiers);
   530   // Class_klass has to be loaded because it is used to allocate
   530   // Class_klass has to be loaded because it is used to allocate
   531   // the mirror.
   531   // the mirror.
   532   if (SystemDictionary::Class_klass_loaded()) {
   532   if (SystemDictionary::Class_klass_loaded()) {
   533     // Allocate mirror (java.lang.Class instance)
   533     // Allocate mirror (java.lang.Class instance)
   534     Handle mirror = instanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance(k, CHECK_0);
   534     Handle mirror = InstanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance(k, CHECK_0);
   535 
   535 
   536     instanceMirrorKlass* mk = instanceMirrorKlass::cast(mirror->klass());
   536     InstanceMirrorKlass* mk = InstanceMirrorKlass::cast(mirror->klass());
   537     java_lang_Class::set_static_oop_field_count(mirror(), mk->compute_static_oop_field_count(mirror()));
   537     java_lang_Class::set_static_oop_field_count(mirror(), mk->compute_static_oop_field_count(mirror()));
   538 
   538 
   539     // It might also have a component mirror.  This mirror must already exist.
   539     // It might also have a component mirror.  This mirror must already exist.
   540     if (k->oop_is_array()) {
   540     if (k->oop_is_array()) {
   541       Handle comp_mirror;
   541       Handle comp_mirror;
   590 }
   590 }
   591 
   591 
   592 oop java_lang_Class::create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS) {
   592 oop java_lang_Class::create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS) {
   593   // This should be improved by adding a field at the Java level or by
   593   // This should be improved by adding a field at the Java level or by
   594   // introducing a new VM klass (see comment in ClassFileParser)
   594   // introducing a new VM klass (see comment in ClassFileParser)
   595   oop java_class = instanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance(NULL, CHECK_0);
   595   oop java_class = InstanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance(NULL, CHECK_0);
   596   if (type != T_VOID) {
   596   if (type != T_VOID) {
   597     Klass* aklass = Universe::typeArrayKlassObj(type);
   597     Klass* aklass = Universe::typeArrayKlassObj(type);
   598     assert(aklass != NULL, "correct bootstrap");
   598     assert(aklass != NULL, "correct bootstrap");
   599     set_array_klass(java_class, aklass);
   599     set_array_klass(java_class, aklass);
   600   }
   600   }
   601 #ifdef ASSERT
   601 #ifdef ASSERT
   602   instanceMirrorKlass* mk = instanceMirrorKlass::cast(SystemDictionary::Class_klass());
   602   InstanceMirrorKlass* mk = InstanceMirrorKlass::cast(SystemDictionary::Class_klass());
   603   assert(java_lang_Class::static_oop_field_count(java_class) == 0, "should have been zeroed by allocation");
   603   assert(java_lang_Class::static_oop_field_count(java_class) == 0, "should have been zeroed by allocation");
   604 #endif
   604 #endif
   605   return java_class;
   605   return java_class;
   606 }
   606 }
   607 
   607 
  2833 }
  2833 }
  2834 
  2834 
  2835 
  2835 
  2836 // Support for java_lang_System
  2836 // Support for java_lang_System
  2837 int java_lang_System::in_offset_in_bytes() {
  2837 int java_lang_System::in_offset_in_bytes() {
  2838   return (instanceMirrorKlass::offset_of_static_fields() + static_in_offset);
  2838   return (InstanceMirrorKlass::offset_of_static_fields() + static_in_offset);
  2839 }
  2839 }
  2840 
  2840 
  2841 
  2841 
  2842 int java_lang_System::out_offset_in_bytes() {
  2842 int java_lang_System::out_offset_in_bytes() {
  2843   return (instanceMirrorKlass::offset_of_static_fields() + static_out_offset);
  2843   return (InstanceMirrorKlass::offset_of_static_fields() + static_out_offset);
  2844 }
  2844 }
  2845 
  2845 
  2846 
  2846 
  2847 int java_lang_System::err_offset_in_bytes() {
  2847 int java_lang_System::err_offset_in_bytes() {
  2848   return (instanceMirrorKlass::offset_of_static_fields() + static_err_offset);
  2848   return (InstanceMirrorKlass::offset_of_static_fields() + static_err_offset);
  2849 }
  2849 }
  2850 
  2850 
  2851 
  2851 
  2852 
  2852 
  2853 int java_lang_Class::_klass_offset;
  2853 int java_lang_Class::_klass_offset;
  3122   }
  3122   }
  3123   if (!fd.is_static()) {
  3123   if (!fd.is_static()) {
  3124     tty->print_cr("Static field %s.%s appears to be nonstatic", klass_name, field_name);
  3124     tty->print_cr("Static field %s.%s appears to be nonstatic", klass_name, field_name);
  3125     return false;
  3125     return false;
  3126   }
  3126   }
  3127   if (fd.offset() == hardcoded_offset + instanceMirrorKlass::offset_of_static_fields()) {
  3127   if (fd.offset() == hardcoded_offset + InstanceMirrorKlass::offset_of_static_fields()) {
  3128     return true;
  3128     return true;
  3129   } else {
  3129   } else {
  3130     tty->print_cr("Offset of static field %s.%s is hardcoded as %d but should really be %d.", klass_name, field_name, hardcoded_offset, fd.offset() - instanceMirrorKlass::offset_of_static_fields());
  3130     tty->print_cr("Offset of static field %s.%s is hardcoded as %d but should really be %d.", klass_name, field_name, hardcoded_offset, fd.offset() - InstanceMirrorKlass::offset_of_static_fields());
  3131     return false;
  3131     return false;
  3132   }
  3132   }
  3133 }
  3133 }
  3134 
  3134 
  3135 
  3135