Skip to content
Permalink
Browse files
8252689: Classes are loaded from jrt:/java.base even when CDS is used
Reviewed-by: iklam, ccheung
  • Loading branch information
yminqi committed Sep 14, 2020
1 parent c5e63b6 commit f978f6fe8ab57ab815f61dc0571df955db2663d5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
@@ -655,6 +655,22 @@ static RunTimeSharedDictionary _unregistered_dictionary;
static RunTimeSharedDictionary _dynamic_builtin_dictionary;
static RunTimeSharedDictionary _dynamic_unregistered_dictionary;


Handle SystemDictionaryShared::create_jar_manifest(const char* manifest_chars, size_t size, TRAPS) {
typeArrayOop buf = oopFactory::new_byteArray((int)size, CHECK_NH);
typeArrayHandle bufhandle(THREAD, buf);
ArrayAccess<>::arraycopy_from_native(reinterpret_cast<const jbyte*>(manifest_chars),
buf, typeArrayOopDesc::element_offset<jbyte>(0), size);
Handle bais = JavaCalls::construct_new_instance(SystemDictionary::ByteArrayInputStream_klass(),
vmSymbols::byte_array_void_signature(),
bufhandle, CHECK_NH);
// manifest = new Manifest(ByteArrayInputStream)
Handle manifest = JavaCalls::construct_new_instance(SystemDictionary::Jar_Manifest_klass(),
vmSymbols::input_stream_void_signature(),
bais, CHECK_NH);
return manifest;
}

oop SystemDictionaryShared::shared_protection_domain(int index) {
return ((objArrayOop)_shared_protection_domains.resolve())->obj_at(index);
}
@@ -671,30 +687,17 @@ Handle SystemDictionaryShared::get_shared_jar_manifest(int shared_path_index, TR
Handle manifest ;
if (shared_jar_manifest(shared_path_index) == NULL) {
SharedClassPathEntry* ent = FileMapInfo::shared_path(shared_path_index);
long size = ent->manifest_size();
if (size <= 0) {
size_t size = (size_t)ent->manifest_size();
if (size == 0) {
return Handle();
}

// ByteArrayInputStream bais = new ByteArrayInputStream(buf);
const char* src = ent->manifest();
assert(src != NULL, "No Manifest data");
typeArrayOop buf = oopFactory::new_byteArray(size, CHECK_NH);
typeArrayHandle bufhandle(THREAD, buf);
ArrayAccess<>::arraycopy_from_native(reinterpret_cast<const jbyte*>(src),
buf, typeArrayOopDesc::element_offset<jbyte>(0), size);

Handle bais = JavaCalls::construct_new_instance(SystemDictionary::ByteArrayInputStream_klass(),
vmSymbols::byte_array_void_signature(),
bufhandle, CHECK_NH);

// manifest = new Manifest(bais)
manifest = JavaCalls::construct_new_instance(SystemDictionary::Jar_Manifest_klass(),
vmSymbols::input_stream_void_signature(),
bais, CHECK_NH);
manifest = create_jar_manifest(src, size, THREAD);
atomic_set_shared_jar_manifest(shared_path_index, manifest());
}

manifest = Handle(THREAD, shared_jar_manifest(shared_path_index));
assert(manifest.not_null(), "sanity");
return manifest;
@@ -320,6 +320,7 @@ class SystemDictionaryShared: public SystemDictionary {
static void print_table_statistics(outputStream* st) NOT_CDS_RETURN;
static bool empty_dumptime_table() NOT_CDS_RETURN_(true);
static void start_dumping() NOT_CDS_RETURN;
static Handle create_jar_manifest(const char* man, size_t size, TRAPS) NOT_CDS_RETURN_(NULL);

DEBUG_ONLY(static bool no_class_loading_should_happen() {return _no_class_loading_should_happen;})

@@ -1089,6 +1089,8 @@ void MetaspaceShared::preload_and_dump(TRAPS) {

HeapShared::init_for_dumping(THREAD);

// exercise the manifest processing code to ensure classes used by CDS are always archived
SystemDictionaryShared::create_jar_manifest("Manifest-Version: 1.0\n", strlen("Manifest-Version: 1.0\n"), THREAD);
// Rewrite and link classes
log_info(cds)("Rewriting and linking classes ...");

1 comment on commit f978f6f

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented on f978f6f Sep 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.