hotspot/src/share/vm/classfile/javaClasses.cpp
changeset 25326 85b2f2e63e3e
parent 25057 f38210f84f8c
child 25465 17a6bddcfa5d
equal deleted inserted replaced
25325:e3af4e02b0d5 25326:85b2f2e63e3e
   556           fs.set_offset(real_offset);
   556           fs.set_offset(real_offset);
   557         }
   557         }
   558       }
   558       }
   559     }
   559     }
   560   }
   560   }
   561   create_mirror(k, Handle(NULL), CHECK);
   561   create_mirror(k, Handle(NULL), Handle(NULL), CHECK);
   562 }
   562 }
   563 
   563 
   564 void java_lang_Class::initialize_mirror_fields(KlassHandle k,
   564 void java_lang_Class::initialize_mirror_fields(KlassHandle k,
   565                                                Handle mirror,
   565                                                Handle mirror,
   566                                                Handle protection_domain,
   566                                                Handle protection_domain,
   576 
   576 
   577   // Initialize static fields
   577   // Initialize static fields
   578   InstanceKlass::cast(k())->do_local_static_fields(&initialize_static_field, mirror, CHECK);
   578   InstanceKlass::cast(k())->do_local_static_fields(&initialize_static_field, mirror, CHECK);
   579 }
   579 }
   580 
   580 
   581 void java_lang_Class::create_mirror(KlassHandle k, Handle protection_domain, TRAPS) {
   581 void java_lang_Class::create_mirror(KlassHandle k, Handle class_loader,
       
   582                                     Handle protection_domain, TRAPS) {
   582   assert(k->java_mirror() == NULL, "should only assign mirror once");
   583   assert(k->java_mirror() == NULL, "should only assign mirror once");
   583   // Use this moment of initialization to cache modifier_flags also,
   584   // Use this moment of initialization to cache modifier_flags also,
   584   // to support Class.getModifiers().  Instance classes recalculate
   585   // to support Class.getModifiers().  Instance classes recalculate
   585   // the cached flags after the class file is parsed, but before the
   586   // the cached flags after the class file is parsed, but before the
   586   // class is put into the system dictionary.
   587   // class is put into the system dictionary.
   631         java_lang_Class::set_klass(mirror(), NULL);
   632         java_lang_Class::set_klass(mirror(), NULL);
   632         return;
   633         return;
   633       }
   634       }
   634     }
   635     }
   635 
   636 
       
   637     // set the classLoader field in the java_lang_Class instance
       
   638     set_class_loader(mirror(), class_loader());
       
   639 
   636     // Setup indirection from klass->mirror last
   640     // Setup indirection from klass->mirror last
   637     // after any exceptions can happen during allocations.
   641     // after any exceptions can happen during allocations.
   638     if (!k.is_null()) {
   642     if (!k.is_null()) {
   639       k->set_java_mirror(mirror());
   643       k->set_java_mirror(mirror());
   640     }
   644     }
   691 void java_lang_Class::set_signers(oop java_class, objArrayOop signers) {
   695 void java_lang_Class::set_signers(oop java_class, objArrayOop signers) {
   692   assert(_signers_offset != 0, "must be set");
   696   assert(_signers_offset != 0, "must be set");
   693   java_class->obj_field_put(_signers_offset, (oop)signers);
   697   java_class->obj_field_put(_signers_offset, (oop)signers);
   694 }
   698 }
   695 
   699 
       
   700 
       
   701 void java_lang_Class::set_class_loader(oop java_class, oop loader) {
       
   702   // jdk7 runs Queens in bootstrapping and jdk8-9 has no coordinated pushes yet.
       
   703   if (_class_loader_offset != 0) {
       
   704     java_class->obj_field_put(_class_loader_offset, loader);
       
   705   }
       
   706 }
       
   707 
       
   708 oop java_lang_Class::class_loader(oop java_class) {
       
   709   assert(_class_loader_offset != 0, "must be set");
       
   710   return java_class->obj_field(_class_loader_offset);
       
   711 }
   696 
   712 
   697 oop java_lang_Class::create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS) {
   713 oop java_lang_Class::create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS) {
   698   // This should be improved by adding a field at the Java level or by
   714   // This should be improved by adding a field at the Java level or by
   699   // introducing a new VM klass (see comment in ClassFileParser)
   715   // introducing a new VM klass (see comment in ClassFileParser)
   700   oop java_class = InstanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance(NULL, CHECK_0);
   716   oop java_class = InstanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance(NULL, CHECK_0);
   850   Klass* klass_oop = SystemDictionary::Class_klass();
   866   Klass* klass_oop = SystemDictionary::Class_klass();
   851   // The classRedefinedCount field is only present starting in 1.5,
   867   // The classRedefinedCount field is only present starting in 1.5,
   852   // so don't go fatal.
   868   // so don't go fatal.
   853   compute_optional_offset(classRedefinedCount_offset,
   869   compute_optional_offset(classRedefinedCount_offset,
   854                           klass_oop, vmSymbols::classRedefinedCount_name(), vmSymbols::int_signature());
   870                           klass_oop, vmSymbols::classRedefinedCount_name(), vmSymbols::int_signature());
       
   871 
       
   872   // Needs to be optional because the old build runs Queens during bootstrapping
       
   873   // and jdk8-9 doesn't have coordinated pushes yet.
       
   874   compute_optional_offset(_class_loader_offset,
       
   875                  klass_oop, vmSymbols::classLoader_name(),
       
   876                  vmSymbols::classloader_signature());
   855 
   877 
   856   CLASS_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
   878   CLASS_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
   857 }
   879 }
   858 
   880 
   859 int java_lang_Class::classRedefinedCount(oop the_class_mirror) {
   881 int java_lang_Class::classRedefinedCount(oop the_class_mirror) {
  3071 
  3093 
  3072 int java_lang_Class::_klass_offset;
  3094 int java_lang_Class::_klass_offset;
  3073 int java_lang_Class::_array_klass_offset;
  3095 int java_lang_Class::_array_klass_offset;
  3074 int java_lang_Class::_oop_size_offset;
  3096 int java_lang_Class::_oop_size_offset;
  3075 int java_lang_Class::_static_oop_field_count_offset;
  3097 int java_lang_Class::_static_oop_field_count_offset;
       
  3098 int java_lang_Class::_class_loader_offset;
  3076 int java_lang_Class::_protection_domain_offset;
  3099 int java_lang_Class::_protection_domain_offset;
  3077 int java_lang_Class::_init_lock_offset;
  3100 int java_lang_Class::_init_lock_offset;
  3078 int java_lang_Class::_signers_offset;
  3101 int java_lang_Class::_signers_offset;
  3079 GrowableArray<Klass*>* java_lang_Class::_fixup_mirror_list = NULL;
  3102 GrowableArray<Klass*>* java_lang_Class::_fixup_mirror_list = NULL;
  3080 int java_lang_Throwable::backtrace_offset;
  3103 int java_lang_Throwable::backtrace_offset;