< prev index next >

src/hotspot/share/classfile/javaClasses.cpp

Print this page
*** 51,12 ***
  #include "memory/oopFactory.hpp"
  #include "memory/resourceArea.hpp"
  #include "memory/universe.hpp"
  #include "oops/fieldInfo.hpp"
  #include "oops/fieldStreams.inline.hpp"
  #include "oops/instanceKlass.inline.hpp"
! #include "oops/instanceMirrorKlass.hpp"
  #include "oops/klass.hpp"
  #include "oops/klass.inline.hpp"
  #include "oops/method.inline.hpp"
  #include "oops/objArrayKlass.hpp"
  #include "oops/objArrayOop.inline.hpp"
--- 51,14 ---
  #include "memory/oopFactory.hpp"
  #include "memory/resourceArea.hpp"
  #include "memory/universe.hpp"
  #include "oops/fieldInfo.hpp"
  #include "oops/fieldStreams.inline.hpp"
+ #include "oops/flatArrayKlass.hpp"
+ #include "oops/inlineKlass.inline.hpp"
  #include "oops/instanceKlass.inline.hpp"
! #include "oops/instanceMirrorKlass.inline.hpp"
  #include "oops/klass.hpp"
  #include "oops/klass.inline.hpp"
  #include "oops/method.inline.hpp"
  #include "oops/objArrayKlass.hpp"
  #include "oops/objArrayOop.inline.hpp"

*** 786,10 ***
--- 788,11 ---
  int java_lang_Class::_static_oop_field_count_offset;
  int java_lang_Class::_class_loader_offset;
  int java_lang_Class::_module_offset;
  int java_lang_Class::_protection_domain_offset;
  int java_lang_Class::_component_mirror_offset;
+ 
  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;

*** 985,25 ***
  
    set_static_oop_field_count(mirror(), mk->compute_static_oop_field_count(mirror()));
  
    // It might also have a component mirror.  This mirror must already exist.
    if (k->is_array_klass()) {
!     if (k->is_typeArray_klass()) {
        BasicType type = TypeArrayKlass::cast(k)->element_type();
        if (is_scratch) {
          comp_mirror = Handle(THREAD, HeapShared::scratch_java_mirror(type));
        } else {
          comp_mirror = Handle(THREAD, Universe::java_mirror(type));
        }
      } else {
        assert(k->is_objArray_klass(), "Must be");
        Klass* element_klass = ObjArrayKlass::cast(k)->element_klass();
        assert(element_klass != nullptr, "Must have an element klass");
        if (is_scratch) {
          comp_mirror = Handle(THREAD, HeapShared::scratch_java_mirror(element_klass));
        } else {
!         comp_mirror = Handle(THREAD, element_klass->java_mirror());
        }
      }
      assert(comp_mirror() != nullptr, "must have a mirror");
  
      // Two-way link between the array klass and its component mirror:
--- 988,38 ---
  
    set_static_oop_field_count(mirror(), mk->compute_static_oop_field_count(mirror()));
  
    // It might also have a component mirror.  This mirror must already exist.
    if (k->is_array_klass()) {
!     if (k->is_flatArray_klass()) {
+       Klass* element_klass = (Klass*) FlatArrayKlass::cast(k)->element_klass();
+       assert(element_klass->is_inline_klass(), "Must be inline type component");
+       if (is_scratch) {
+         comp_mirror = Handle(THREAD, HeapShared::scratch_java_mirror(element_klass));
+       } else {
+         comp_mirror = Handle(THREAD, element_klass->java_mirror());
+       }
+     } else if (k->is_typeArray_klass()) {
        BasicType type = TypeArrayKlass::cast(k)->element_type();
        if (is_scratch) {
          comp_mirror = Handle(THREAD, HeapShared::scratch_java_mirror(type));
        } else {
          comp_mirror = Handle(THREAD, Universe::java_mirror(type));
        }
      } else {
        assert(k->is_objArray_klass(), "Must be");
        Klass* element_klass = ObjArrayKlass::cast(k)->element_klass();
        assert(element_klass != nullptr, "Must have an element klass");
+       oop comp_oop = element_klass->java_mirror();
+       if (element_klass->is_inline_klass()) {
+         InlineKlass* ik = InlineKlass::cast(element_klass);
+         comp_oop = ik->java_mirror();
+       }
        if (is_scratch) {
          comp_mirror = Handle(THREAD, HeapShared::scratch_java_mirror(element_klass));
        } else {
!         comp_mirror = Handle(THREAD, comp_oop);
        }
      }
      assert(comp_mirror() != nullptr, "must have a mirror");
  
      // Two-way link between the array klass and its component mirror:

*** 1061,10 ***
--- 1077,11 ---
      if (comp_mirror() != nullptr) {
        // 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");

*** 1083,13 ***
  //
  // 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
--- 1100,18 ---
  //
  // 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) {
!   // Inline classes encapsulate two mirror objects, a value mirror (primitive value mirror)
!   // and a reference mirror (primitive class mirror), skip over scratch mirror allocation
!   // for inline classes, they will not be part of shared archive and will be created while
+   // restoring unshared fileds. Refer Klass::restore_unshareable_info() for more details.
+   if (k->is_inline_klass() ||
+       (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

*** 1289,11 ***
    }
    if (name == nullptr) {
      st->print("<null>");
      return;
    }
!   if (is_instance)  st->print("L");
    st->write((char*) name->base(), (int) name->utf8_length());
    if (is_instance)  st->print(";");
  }
  
  Symbol* java_lang_Class::as_signature(oop java_class, bool intern_if_not_found) {
--- 1311,13 ---
    }
    if (name == nullptr) {
      st->print("<null>");
      return;
    }
!   if (is_instance)  {
+     st->print("L");
+   }
    st->write((char*) name->base(), (int) name->utf8_length());
    if (is_instance)  st->print(";");
  }
  
  Symbol* java_lang_Class::as_signature(oop java_class, bool intern_if_not_found) {

*** 2622,11 ***
      if (!skip_throwableInit_check) {
        assert(skip_fillInStackTrace_check, "logic error in backtrace filtering");
  
        // skip <init> methods of the exception class and superclasses
        // This is similar to classic VM.
!       if (method->name() == vmSymbols::object_initializer_name() &&
            throwable->is_a(method->method_holder())) {
          continue;
        } else {
          // there are none or we've seen them all - either way stop checking
          skip_throwableInit_check = true;
--- 2646,11 ---
      if (!skip_throwableInit_check) {
        assert(skip_fillInStackTrace_check, "logic error in backtrace filtering");
  
        // skip <init> methods of the exception class and superclasses
        // This is similar to classic VM.
!       if (method->is_object_constructor() &&
            throwable->is_a(method->method_holder())) {
          continue;
        } else {
          // there are none or we've seen them all - either way stop checking
          skip_throwableInit_check = true;

*** 2981,12 ***
  }
  #endif
  
  static int get_flags(const methodHandle& m) {
    int flags = (jushort)( m->access_flags().as_short() & JVM_RECOGNIZED_METHOD_MODIFIERS );
!   if (m->is_initializer()) {
!     flags |= java_lang_invoke_MemberName::MN_IS_CONSTRUCTOR;
    } else {
      flags |= java_lang_invoke_MemberName::MN_IS_METHOD;
    }
    if (m->caller_sensitive()) {
      flags |= java_lang_invoke_MemberName::MN_CALLER_SENSITIVE;
--- 3005,12 ---
  }
  #endif
  
  static int get_flags(const methodHandle& m) {
    int flags = (jushort)( m->access_flags().as_short() & JVM_RECOGNIZED_METHOD_MODIFIERS );
!   if (m->is_object_constructor()) {
!     flags |= java_lang_invoke_MemberName::MN_IS_OBJECT_CONSTRUCTOR;
    } else {
      flags |= java_lang_invoke_MemberName::MN_IS_METHOD;
    }
    if (m->caller_sensitive()) {
      flags |= java_lang_invoke_MemberName::MN_CALLER_SENSITIVE;

*** 3372,21 ***
  int java_lang_reflect_Field::_clazz_offset;
  int java_lang_reflect_Field::_name_offset;
  int java_lang_reflect_Field::_type_offset;
  int java_lang_reflect_Field::_slot_offset;
  int java_lang_reflect_Field::_modifiers_offset;
! int java_lang_reflect_Field::_trusted_final_offset;
  int java_lang_reflect_Field::_signature_offset;
  int java_lang_reflect_Field::_annotations_offset;
  
  #define FIELD_FIELDS_DO(macro) \
    macro(_clazz_offset,     k, vmSymbols::clazz_name(),     class_signature,  false); \
    macro(_name_offset,      k, vmSymbols::name_name(),      string_signature, false); \
    macro(_type_offset,      k, vmSymbols::type_name(),      class_signature,  false); \
    macro(_slot_offset,      k, vmSymbols::slot_name(),      int_signature,    false); \
    macro(_modifiers_offset, k, vmSymbols::modifiers_name(), int_signature,    false); \
!   macro(_trusted_final_offset,    k, vmSymbols::trusted_final_name(),    bool_signature,       false); \
    macro(_signature_offset,        k, vmSymbols::signature_name(),        string_signature,     false); \
    macro(_annotations_offset,      k, vmSymbols::annotations_name(),      byte_array_signature, false);
  
  void java_lang_reflect_Field::compute_offsets() {
    InstanceKlass* k = vmClasses::reflect_Field_klass();
--- 3396,21 ---
  int java_lang_reflect_Field::_clazz_offset;
  int java_lang_reflect_Field::_name_offset;
  int java_lang_reflect_Field::_type_offset;
  int java_lang_reflect_Field::_slot_offset;
  int java_lang_reflect_Field::_modifiers_offset;
! int java_lang_reflect_Field::_flags_offset;
  int java_lang_reflect_Field::_signature_offset;
  int java_lang_reflect_Field::_annotations_offset;
  
  #define FIELD_FIELDS_DO(macro) \
    macro(_clazz_offset,     k, vmSymbols::clazz_name(),     class_signature,  false); \
    macro(_name_offset,      k, vmSymbols::name_name(),      string_signature, false); \
    macro(_type_offset,      k, vmSymbols::type_name(),      class_signature,  false); \
    macro(_slot_offset,      k, vmSymbols::slot_name(),      int_signature,    false); \
    macro(_modifiers_offset, k, vmSymbols::modifiers_name(), int_signature,    false); \
!   macro(_flags_offset,     k, vmSymbols::flags_name(),     int_signature,    false); \
    macro(_signature_offset,        k, vmSymbols::signature_name(),        string_signature,     false); \
    macro(_annotations_offset,      k, vmSymbols::annotations_name(),      byte_array_signature, false);
  
  void java_lang_reflect_Field::compute_offsets() {
    InstanceKlass* k = vmClasses::reflect_Field_klass();

*** 3447,12 ***
  
  void java_lang_reflect_Field::set_modifiers(oop field, int value) {
    field->int_field_put(_modifiers_offset, value);
  }
  
! void java_lang_reflect_Field::set_trusted_final(oop field) {
!   field->bool_field_put(_trusted_final_offset, true);
  }
  
  void java_lang_reflect_Field::set_signature(oop field, oop value) {
    field->obj_field_put(_signature_offset, value);
  }
--- 3471,12 ---
  
  void java_lang_reflect_Field::set_modifiers(oop field, int value) {
    field->int_field_put(_modifiers_offset, value);
  }
  
! void java_lang_reflect_Field::set_flags(oop field, int value) {
!   field->int_field_put(_flags_offset, value);
  }
  
  void java_lang_reflect_Field::set_signature(oop field, oop value) {
    field->obj_field_put(_signature_offset, value);
  }

*** 4290,11 ***
    return method == nullptr ? nullptr : java_lang_invoke_ResolvedMethodName::vmtarget(method);
  }
  
  bool java_lang_invoke_MemberName::is_method(oop mname) {
    assert(is_instance(mname), "must be MemberName");
!   return (flags(mname) & (MN_IS_METHOD | MN_IS_CONSTRUCTOR)) > 0;
  }
  
  void java_lang_invoke_MemberName::set_method(oop mname, oop resolved_method) {
    assert(is_instance(mname), "wrong type");
    mname->obj_field_put(_method_offset, resolved_method);
--- 4314,11 ---
    return method == nullptr ? nullptr : java_lang_invoke_ResolvedMethodName::vmtarget(method);
  }
  
  bool java_lang_invoke_MemberName::is_method(oop mname) {
    assert(is_instance(mname), "must be MemberName");
!   return (flags(mname) & (MN_IS_METHOD | MN_IS_OBJECT_CONSTRUCTOR)) > 0;
  }
  
  void java_lang_invoke_MemberName::set_method(oop mname, oop resolved_method) {
    assert(is_instance(mname), "wrong type");
    mname->obj_field_put(_method_offset, resolved_method);
< prev index next >