< prev index next >

src/hotspot/share/classfile/javaClasses.cpp

Print this page
@@ -1143,11 +1143,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()) {
-       create_scratch_mirror(k, CHECK);
+       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);
    }

@@ -1163,19 +1167,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) {
+ 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 protection_domain, classData; // set to null. Will be reinitialized at runtime
+   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) {

@@ -1302,10 +1306,19 @@
  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);
  }
  

@@ -1497,11 +1510,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",      java_lang_ref_SoftReference_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;

@@ -2274,10 +2287,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");
< prev index next >