< prev index next >

src/hotspot/share/oops/arrayKlass.cpp

Print this page
*** 24,10 ***
--- 24,11 ---
  
  #include "cds/cdsConfig.hpp"
  #include "cds/metaspaceShared.hpp"
  #include "classfile/javaClasses.hpp"
  #include "classfile/moduleEntry.hpp"
+ #include "classfile/symbolTable.hpp"
  #include "classfile/vmClasses.hpp"
  #include "classfile/vmSymbols.hpp"
  #include "gc/shared/collectedHeap.inline.hpp"
  #include "jvmtifiles/jvmti.h"
  #include "memory/metaspaceClosure.hpp"

*** 35,10 ***
--- 36,11 ---
  #include "memory/universe.hpp"
  #include "oops/arrayKlass.inline.hpp"
  #include "oops/arrayOop.hpp"
  #include "oops/instanceKlass.hpp"
  #include "oops/klass.inline.hpp"
+ #include "oops/objArrayKlass.hpp"
  #include "oops/objArrayOop.hpp"
  #include "oops/oop.inline.hpp"
  #include "runtime/handles.inline.hpp"
  
  void* ArrayKlass::operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw() {

*** 90,12 ***
    // super klass of an array, (j.l.Object) should not have
    // any overpass methods present.
    return super()->uncached_lookup_method(name, signature, OverpassLookupMode::skip, private_mode);
  }
  
! ArrayKlass::ArrayKlass(Symbol* name, KlassKind kind) :
!   Klass(kind),
    _dimension(1),
    _higher_dimension(nullptr),
    _lower_dimension(nullptr) {
    // Arrays don't add any new methods, so their vtable is the same size as
    // the vtable of klass Object.
--- 92,12 ---
    // super klass of an array, (j.l.Object) should not have
    // any overpass methods present.
    return super()->uncached_lookup_method(name, signature, OverpassLookupMode::skip, private_mode);
  }
  
! ArrayKlass::ArrayKlass(Symbol* name, KlassKind kind, markWord prototype_header) :
! Klass(kind, prototype_header),
    _dimension(1),
    _higher_dimension(nullptr),
    _lower_dimension(nullptr) {
    // Arrays don't add any new methods, so their vtable is the same size as
    // the vtable of klass Object.

*** 106,10 ***
--- 108,29 ---
    set_is_cloneable(); // All arrays are considered to be cloneable (See JLS 20.1.5)
    JFR_ONLY(INIT_ID(this);)
    log_array_class_load(this);
  }
  
+ Symbol* ArrayKlass::create_element_klass_array_name(Klass* element_klass, TRAPS) {
+   ResourceMark rm(THREAD);
+   Symbol* name = nullptr;
+   char *name_str = element_klass->name()->as_C_string();
+   int len = element_klass->name()->utf8_length();
+   char *new_str = NEW_RESOURCE_ARRAY(char, len + 4);
+   int idx = 0;
+   new_str[idx++] = JVM_SIGNATURE_ARRAY;
+   if (element_klass->is_instance_klass()) { // it could be an array or simple type
+     new_str[idx++] = JVM_SIGNATURE_CLASS;
+   }
+   memcpy(&new_str[idx], name_str, len * sizeof(char));
+   idx += len;
+   if (element_klass->is_instance_klass()) {
+     new_str[idx++] = JVM_SIGNATURE_ENDCLASS;
+   }
+   new_str[idx++] = '\0';
+   return SymbolTable::new_symbol(new_str);
+ }
  
  // Initialization of vtables and mirror object is done separately from base_create_array_klass,
  // since a GC can happen. At this point all instance variables of the ArrayKlass must be setup.
  void ArrayKlass::complete_create_array_klass(ArrayKlass* k, Klass* super_klass, ModuleEntry* module_entry, TRAPS) {
    k->initialize_supers(super_klass, nullptr, CHECK);

*** 137,11 ***
      RecursiveLocker rl(MultiArray_lock, THREAD);
  
      if (higher_dimension() == nullptr) {
        // Create multi-dim klass object and link them together
        ObjArrayKlass* ak =
!           ObjArrayKlass::allocate_objArray_klass(class_loader_data(), dim + 1, this, CHECK_NULL);
        // use 'release' to pair with lock-free load
        release_set_higher_dimension(ak);
        assert(ak->lower_dimension() == this, "lower dimension mismatch");
      }
    }
--- 158,11 ---
      RecursiveLocker rl(MultiArray_lock, THREAD);
  
      if (higher_dimension() == nullptr) {
        // Create multi-dim klass object and link them together
        ObjArrayKlass* ak =
!       ObjArrayKlass::allocate_objArray_klass(class_loader_data(), dim + 1, this, false, CHECK_NULL);
        // use 'release' to pair with lock-free load
        release_set_higher_dimension(ak);
        assert(ak->lower_dimension() == this, "lower dimension mismatch");
      }
    }

*** 195,10 ***
--- 216,14 ---
                                                                  /* do_zero */ true, CHECK_NULL);
    // initialization to null not necessary, area already cleared
    return o;
  }
  
+ oop ArrayKlass::component_mirror() const {
+   return java_lang_Class::component_mirror(java_mirror());
+ }
+ 
  // JVMTI support
  
  jint ArrayKlass::jvmti_class_status() const {
    return JVMTI_CLASS_STATUS_ARRAY;
  }
< prev index next >