< prev index next >

src/hotspot/share/classfile/javaClasses.cpp

Print this page
*** 840,10 ***
--- 840,11 ---
  int java_lang_Class::_signers_offset;
  int java_lang_Class::_name_offset;
  int java_lang_Class::_source_file_offset;
  int java_lang_Class::_classData_offset;
  int java_lang_Class::_classRedefinedCount_offset;
+ int java_lang_Class::_reflectionData_offset;
  
  bool java_lang_Class::_offsets_computed = false;
  GrowableArray<Klass*>* java_lang_Class::_fixup_mirror_list = nullptr;
  GrowableArray<Klass*>* java_lang_Class::_fixup_module_field_list = nullptr;
  

*** 1117,11 ***
        // Set after k->java_mirror() is published, because compiled code running
        // concurrently doesn't expect a k to have a null java_mirror.
        release_set_array_klass(comp_mirror(), k);
      }
      if (CDSConfig::is_dumping_heap()) {
!       create_scratch_mirror(k, CHECK);
      }
    } else {
      assert(fixup_mirror_list() != nullptr, "fixup_mirror_list not initialized");
      fixup_mirror_list()->push(k);
    }
--- 1118,15 ---
        // Set after k->java_mirror() is published, because compiled code running
        // concurrently doesn't expect a k to have a null java_mirror.
        release_set_array_klass(comp_mirror(), k);
      }
      if (CDSConfig::is_dumping_heap()) {
!       if (CDSConfig::is_dumping_protection_domains()) {
+         create_scratch_mirror(k, protection_domain, CHECK);
+       } else {
+         create_scratch_mirror(k, Handle() /* null protection_domain*/, CHECK);
+       }
      }
    } else {
      assert(fixup_mirror_list() != nullptr, "fixup_mirror_list not initialized");
      fixup_mirror_list()->push(k);
    }

*** 1137,19 ***
  // produces the same result as /*runtime*/create_mirror().
  //
  // Note: we archive the "scratch mirror" instead of k->java_mirror(), because the
  // latter may contain dumptime-specific information that cannot be archived
  // (e.g., ClassLoaderData*, or static fields that are modified by Java code execution).
! void java_lang_Class::create_scratch_mirror(Klass* k, TRAPS) {
    if (k->class_loader() != nullptr &&
        k->class_loader() != SystemDictionary::java_platform_loader() &&
        k->class_loader() != SystemDictionary::java_system_loader()) {
      // We only archive the mirrors of classes loaded by the built-in loaders
      return;
    }
  
!   Handle protection_domain, classData; // set to null. Will be reinitialized at runtime
    Handle mirror;
    Handle comp_mirror;
    allocate_mirror(k, /*is_scratch=*/true, protection_domain, classData, mirror, comp_mirror, CHECK);
  
    if (comp_mirror() != nullptr) {
--- 1142,19 ---
  // produces the same result as /*runtime*/create_mirror().
  //
  // Note: we archive the "scratch mirror" instead of k->java_mirror(), because the
  // latter may contain dumptime-specific information that cannot be archived
  // (e.g., ClassLoaderData*, or static fields that are modified by Java code execution).
! void java_lang_Class::create_scratch_mirror(Klass* k, Handle protection_domain, TRAPS) {
    if (k->class_loader() != nullptr &&
        k->class_loader() != SystemDictionary::java_platform_loader() &&
        k->class_loader() != SystemDictionary::java_system_loader()) {
      // We only archive the mirrors of classes loaded by the built-in loaders
      return;
    }
  
!   Handle classData; // set to null. Will be reinitialized at runtime
    Handle mirror;
    Handle comp_mirror;
    allocate_mirror(k, /*is_scratch=*/true, protection_domain, classData, mirror, comp_mirror, CHECK);
  
    if (comp_mirror() != nullptr) {

*** 1276,10 ***
--- 1281,24 ---
  void java_lang_Class::set_class_data(oop java_class, oop class_data) {
    assert(_classData_offset != 0, "must be set");
    java_class->obj_field_put(_classData_offset, class_data);
  }
  
+ oop java_lang_Class::reflection_data(oop java_class) {
+   assert(_reflectionData_offset != 0, "must be set");
+   return java_class->obj_field(_reflectionData_offset);
+ }
+ 
+ bool java_lang_Class::has_reflection_data(oop java_class) {
+   return (java_lang_Class::reflection_data(java_class) != nullptr);
+ }
+ 
+ void java_lang_Class::set_reflection_data(oop java_class, oop reflection_data) {
+   assert(_reflectionData_offset != 0, "must be set");
+   java_class->obj_field_put(_reflectionData_offset, reflection_data);
+ }
+ 
  void java_lang_Class::set_class_loader(oop java_class, oop loader) {
    assert(_class_loader_offset != 0, "offsets should have been initialized");
    java_class->obj_field_put(_class_loader_offset, loader);
  }
  

*** 1466,10 ***
--- 1485,11 ---
    macro(_class_loader_offset,        k, "classLoader",         classloader_signature,  false); \
    macro(_component_mirror_offset,    k, "componentType",       class_signature,        false); \
    macro(_module_offset,              k, "module",              module_signature,       false); \
    macro(_name_offset,                k, "name",                string_signature,       false); \
    macro(_classData_offset,           k, "classData",           object_signature,       false); \
+   macro(_reflectionData_offset,      k, "reflectionData",      class_ReflectionData_signature, false); \
    macro(_signers_offset,             k, "signers",             object_array_signature, false);
  
  void java_lang_Class::compute_offsets() {
    if (_offsets_computed) {
      return;

*** 2169,10 ***
--- 2189,14 ---
  
  void java_lang_Throwable::clear_stacktrace(oop throwable) {
    set_stacktrace(throwable, nullptr);
  }
  
+ oop java_lang_Throwable::create_exception_instance(Symbol* class_name, TRAPS) {
+   Klass* k = SystemDictionary::resolve_or_fail(class_name, true, CHECK_NULL);
+   return InstanceKlass::cast(k)->allocate_instance(CHECK_NULL);
+ }
  
  void java_lang_Throwable::print(oop throwable, outputStream* st) {
    ResourceMark rm;
    Klass* k = throwable->klass();
    assert(k != nullptr, "just checking");

*** 5420,24 ***
  
  #if INCLUDE_CDS_JAVA_HEAP
  bool JavaClasses::is_supported_for_archiving(oop obj) {
    Klass* klass = obj->klass();
  
!   if (klass == vmClasses::ClassLoader_klass() ||  // ClassLoader::loader_data is malloc'ed.
!       // The next 3 classes are used to implement java.lang.invoke, and are not used directly in
!       // regular Java code. The implementation of java.lang.invoke uses generated hidden classes
!       // (e.g., as referenced by ResolvedMethodName::vmholder) that are not yet supported by CDS.
!       // So for now we cannot not support these classes for archiving.
!       //
!       // These objects typically are not referenced by static fields, but rather by resolved
!       // constant pool entries, so excluding them shouldn't affect the archiving of static fields.
!       klass == vmClasses::ResolvedMethodName_klass() ||
!       klass == vmClasses::MemberName_klass() ||
!       klass == vmClasses::Context_klass() ||
!       // It's problematic to archive Reference objects. One of the reasons is that
-       // Reference::discovered may pull in unwanted objects (see JDK-8284336)
-       klass->is_subclass_of(vmClasses::Reference_klass())) {
      return false;
    }
  
    return true;
  }
--- 5444,22 ---
  
  #if INCLUDE_CDS_JAVA_HEAP
  bool JavaClasses::is_supported_for_archiving(oop obj) {
    Klass* klass = obj->klass();
  
!   if (!CDSConfig::is_dumping_invokedynamic()) {
!     // These are supported by CDS only when CDSConfig::is_dumping_invokedynamic() is enabled.
!     if (klass == vmClasses::ResolvedMethodName_klass() ||
!         klass == vmClasses::MemberName_klass() ||
!         klass == vmClasses::Context_klass()) {
!       return false;
!     }
!   }
! 
!   if (klass->is_subclass_of(vmClasses::Reference_klass())) {
!     // It's problematic to archive Reference objects. One of the reasons is that
!     // Reference::discovered may pull in unwanted objects (see JDK-8284336)
      return false;
    }
  
    return true;
  }
< prev index next >