< prev index next >

src/hotspot/share/classfile/javaClasses.cpp

Print this page
@@ -51,12 +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.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"

@@ -1040,25 +1042,34 @@
  
    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()) {
+     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 (is_scratch) {
          comp_mirror = Handle(THREAD, HeapShared::scratch_java_mirror(element_klass));
        } else {
-         comp_mirror = Handle(THREAD, element_klass->java_mirror());
+         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:

@@ -1116,10 +1127,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");

@@ -1138,13 +1150,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()) {
+   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

@@ -1353,11 +1365,13 @@
    }
    if (name == nullptr) {
      st->print("<null>");
      return;
    }
-   if (is_instance)  st->print("L");
+   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) {

@@ -1412,10 +1426,14 @@
  }
  
  
  void java_lang_Class::release_set_array_klass(oop java_class, Klass* klass) {
    assert(klass->is_klass() && klass->is_array_klass(), "should be array klass");
+   if (klass->is_flatArray_klass() || (klass->is_objArray_klass() && ObjArrayKlass::cast(klass)->is_null_free_array_klass())) {
+     // TODO 8336006 Ignore flat / null-free arrays
+     return;
+   }
    java_class->release_metadata_field_put(_array_klass_offset, klass);
  }
  
  
  BasicType java_lang_Class::primitive_type(oop java_class) {

@@ -2691,11 +2709,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() &&
+       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;

@@ -3050,12 +3068,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_initializer()) {
-     flags |= java_lang_invoke_MemberName::MN_IS_CONSTRUCTOR;
+   if (m->is_object_constructor()) {
+     flags |= java_lang_invoke_MemberName::MN_IS_OBJECT_CONSTRUCTOR;
    } else {
      // Note: Static initializers can be here. Record them as plain methods.
      flags |= java_lang_invoke_MemberName::MN_IS_METHOD;
    }
    if (m->caller_sensitive()) {

@@ -3442,21 +3460,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::_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(_trusted_final_offset,    k, vmSymbols::trusted_final_name(),    bool_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();

@@ -3517,12 +3535,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_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);
  }

@@ -3825,15 +3843,15 @@
  
  int java_lang_boxing_object::_value_offset;
  int java_lang_boxing_object::_long_value_offset;
  
  #define BOXING_FIELDS_DO(macro) \
-   macro(_value_offset,      integerKlass, "value", int_signature, false); \
+   macro(_value_offset,      byteKlass, "value", byte_signature, false); \
    macro(_long_value_offset, longKlass, "value", long_signature, false);
  
  void java_lang_boxing_object::compute_offsets() {
-   InstanceKlass* integerKlass = vmClasses::Integer_klass();
+   InstanceKlass* byteKlass = vmClasses::Byte_klass();
    InstanceKlass* longKlass = vmClasses::Long_klass();
    BOXING_FIELDS_DO(FIELD_COMPUTE_OFFSET);
  }
  
  #if INCLUDE_CDS

@@ -4360,11 +4378,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;
+   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);

@@ -5484,15 +5502,23 @@
  
    // Boxed primitive objects (java_lang_boxing_object)
  
    CHECK_OFFSET("java/lang/Boolean",   java_lang_boxing_object, value, "Z");
    CHECK_OFFSET("java/lang/Character", java_lang_boxing_object, value, "C");
-   CHECK_OFFSET("java/lang/Float",     java_lang_boxing_object, value, "F");
+   if (Arguments::enable_preview() && NullableFieldFlattening && (InlineFieldMaxFlatSize >= 64 || InlineFieldMaxFlatSize < 0)) {
+     CHECK_LONG_OFFSET("java/lang/Float",     java_lang_boxing_object, value, "F");
+   } else {
+     CHECK_OFFSET("java/lang/Float",     java_lang_boxing_object, value, "F");
+   }
    CHECK_LONG_OFFSET("java/lang/Double", java_lang_boxing_object, value, "D");
    CHECK_OFFSET("java/lang/Byte",      java_lang_boxing_object, value, "B");
    CHECK_OFFSET("java/lang/Short",     java_lang_boxing_object, value, "S");
-   CHECK_OFFSET("java/lang/Integer",   java_lang_boxing_object, value, "I");
+   if (Arguments::enable_preview() && NullableFieldFlattening && (InlineFieldMaxFlatSize >= 64 || InlineFieldMaxFlatSize < 0)) {
+     CHECK_LONG_OFFSET("java/lang/Integer",   java_lang_boxing_object, value, "I");
+   } else {
+     CHECK_OFFSET("java/lang/Integer",   java_lang_boxing_object, value, "I");
+   }
    CHECK_LONG_OFFSET("java/lang/Long", java_lang_boxing_object, value, "J");
  
    if (!valid) vm_exit_during_initialization("Field offset verification failed");
  }
  
< prev index next >