8261479: CDS runtime code should check exceptions

Reviewed-by: minqi, dholmes, iklam
This commit is contained in:
Calvin Cheung 2021-03-23 19:05:50 +00:00
parent 087c8bfb5f
commit 1c9817b0bc
13 changed files with 66 additions and 68 deletions

View File

@ -464,7 +464,7 @@ InstanceKlass* ClassListParser::load_class_from_source(Symbol* class_name, TRAPS
_interfaces->length(), k->local_interfaces()->length()); _interfaces->length(), k->local_interfaces()->length());
} }
bool added = SystemDictionaryShared::add_unregistered_class(k, CHECK_NULL); bool added = SystemDictionaryShared::add_unregistered_class(THREAD, k);
if (!added) { if (!added) {
// We allow only a single unregistered class for each unique name. // We allow only a single unregistered class for each unique name.
error("Duplicated class %s", _class_name); error("Duplicated class %s", _class_name);

View File

@ -237,11 +237,11 @@ const char* ClassPathEntry::copy_path(const char* path) {
return copy; return copy;
} }
ClassFileStream* ClassPathDirEntry::open_stream(const char* name, TRAPS) { ClassFileStream* ClassPathDirEntry::open_stream(Thread* current, const char* name) {
// construct full path name // construct full path name
assert((_dir != NULL) && (name != NULL), "sanity"); assert((_dir != NULL) && (name != NULL), "sanity");
size_t path_len = strlen(_dir) + strlen(name) + strlen(os::file_separator()) + 1; size_t path_len = strlen(_dir) + strlen(name) + strlen(os::file_separator()) + 1;
char* path = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, path_len); char* path = NEW_RESOURCE_ARRAY_IN_THREAD(current, char, path_len);
int len = jio_snprintf(path, path_len, "%s%s%s", _dir, os::file_separator(), name); int len = jio_snprintf(path, path_len, "%s%s%s", _dir, os::file_separator(), name);
assert(len == (int)(path_len - 1), "sanity"); assert(len == (int)(path_len - 1), "sanity");
// check if file exists // check if file exists
@ -285,10 +285,9 @@ ClassPathZipEntry::~ClassPathZipEntry() {
FREE_C_HEAP_ARRAY(char, _zip_name); FREE_C_HEAP_ARRAY(char, _zip_name);
} }
u1* ClassPathZipEntry::open_entry(const char* name, jint* filesize, bool nul_terminate, TRAPS) { u1* ClassPathZipEntry::open_entry(Thread* current, const char* name, jint* filesize, bool nul_terminate) {
// enable call to C land // enable call to C land
JavaThread* thread = THREAD->as_Java_thread(); ThreadToNativeFromVM ttn(current->as_Java_thread());
ThreadToNativeFromVM ttn(thread);
// check whether zip archive contains name // check whether zip archive contains name
jint name_len; jint name_len;
jzentry* entry = (*FindEntry)(_zip, name, filesize, &name_len); jzentry* entry = (*FindEntry)(_zip, name, filesize, &name_len);
@ -314,9 +313,9 @@ u1* ClassPathZipEntry::open_entry(const char* name, jint* filesize, bool nul_ter
return buffer; return buffer;
} }
ClassFileStream* ClassPathZipEntry::open_stream(const char* name, TRAPS) { ClassFileStream* ClassPathZipEntry::open_stream(Thread* current, const char* name) {
jint filesize; jint filesize;
u1* buffer = open_entry(name, &filesize, false, CHECK_NULL); u1* buffer = open_entry(current, name, &filesize, false);
if (buffer == NULL) { if (buffer == NULL) {
return NULL; return NULL;
} }
@ -374,8 +373,8 @@ ClassPathImageEntry::~ClassPathImageEntry() {
} }
} }
ClassFileStream* ClassPathImageEntry::open_stream(const char* name, TRAPS) { ClassFileStream* ClassPathImageEntry::open_stream(Thread* current, const char* name) {
return open_stream_for_loader(name, ClassLoaderData::the_null_class_loader_data(), THREAD); return open_stream_for_loader(current, name, ClassLoaderData::the_null_class_loader_data());
} }
// For a class in a named module, look it up in the jimage file using this syntax: // For a class in a named module, look it up in the jimage file using this syntax:
@ -385,7 +384,7 @@ ClassFileStream* ClassPathImageEntry::open_stream(const char* name, TRAPS) {
// 1. There are no unnamed modules in the jimage file. // 1. There are no unnamed modules in the jimage file.
// 2. A package is in at most one module in the jimage file. // 2. A package is in at most one module in the jimage file.
// //
ClassFileStream* ClassPathImageEntry::open_stream_for_loader(const char* name, ClassLoaderData* loader_data, TRAPS) { ClassFileStream* ClassPathImageEntry::open_stream_for_loader(Thread* current, const char* name, ClassLoaderData* loader_data) {
jlong size; jlong size;
JImageLocationRef location = (*JImageFindResource)(_jimage, "", get_jimage_version_string(), name, &size); JImageLocationRef location = (*JImageFindResource)(_jimage, "", get_jimage_version_string(), name, &size);
@ -399,7 +398,7 @@ ClassFileStream* ClassPathImageEntry::open_stream_for_loader(const char* name, C
} else { } else {
PackageEntry* package_entry = ClassLoader::get_package_entry(pkg_name, loader_data); PackageEntry* package_entry = ClassLoader::get_package_entry(pkg_name, loader_data);
if (package_entry != NULL) { if (package_entry != NULL) {
ResourceMark rm(THREAD); ResourceMark rm(current);
// Get the module name // Get the module name
ModuleEntry* module = package_entry->module(); ModuleEntry* module = package_entry->module();
assert(module != NULL, "Boot classLoader package missing module"); assert(module != NULL, "Boot classLoader package missing module");
@ -1156,7 +1155,7 @@ ClassFileStream* ClassLoader::search_module_entries(const GrowableArray<ModuleCl
// Try to load the class from the module's ClassPathEntry list. // Try to load the class from the module's ClassPathEntry list.
while (e != NULL) { while (e != NULL) {
stream = e->open_stream(file_name, CHECK_NULL); stream = e->open_stream(THREAD, file_name);
// No context.check is required since CDS is not supported // No context.check is required since CDS is not supported
// for an exploded modules build or if --patch-module is specified. // for an exploded modules build or if --patch-module is specified.
if (NULL != stream) { if (NULL != stream) {
@ -1227,7 +1226,7 @@ InstanceKlass* ClassLoader::load_class(Symbol* name, bool search_append_only, TR
if (!search_append_only && (NULL == stream)) { if (!search_append_only && (NULL == stream)) {
if (has_jrt_entry()) { if (has_jrt_entry()) {
e = _jrt_entry; e = _jrt_entry;
stream = _jrt_entry->open_stream(file_name, CHECK_NULL); stream = _jrt_entry->open_stream(THREAD, file_name);
} else { } else {
// Exploded build - attempt to locate class in its defining module's location. // Exploded build - attempt to locate class in its defining module's location.
assert(_exploded_entries != NULL, "No exploded build entries present"); assert(_exploded_entries != NULL, "No exploded build entries present");
@ -1245,7 +1244,7 @@ InstanceKlass* ClassLoader::load_class(Symbol* name, bool search_append_only, TR
e = first_append_entry(); e = first_append_entry();
while (e != NULL) { while (e != NULL) {
stream = e->open_stream(file_name, CHECK_NULL); stream = e->open_stream(THREAD, file_name);
if (NULL != stream) { if (NULL != stream) {
break; break;
} }
@ -1295,7 +1294,7 @@ char* ClassLoader::skip_uri_protocol(char* source) {
// Record the shared classpath index and loader type for classes loaded // Record the shared classpath index and loader type for classes loaded
// by the builtin loaders at dump time. // by the builtin loaders at dump time.
void ClassLoader::record_result(InstanceKlass* ik, const ClassFileStream* stream, TRAPS) { void ClassLoader::record_result(Thread* current, InstanceKlass* ik, const ClassFileStream* stream) {
Arguments::assert_is_dumping_archive(); Arguments::assert_is_dumping_archive();
assert(stream != NULL, "sanity"); assert(stream != NULL, "sanity");
@ -1317,7 +1316,7 @@ void ClassLoader::record_result(InstanceKlass* ik, const ClassFileStream* stream
assert(has_jrt_entry(), "CDS dumping does not support exploded JDK build"); assert(has_jrt_entry(), "CDS dumping does not support exploded JDK build");
ResourceMark rm(THREAD); ResourceMark rm(current);
int classpath_index = -1; int classpath_index = -1;
PackageEntry* pkg_entry = ik->package(); PackageEntry* pkg_entry = ik->package();
@ -1401,7 +1400,7 @@ void ClassLoader::record_result(InstanceKlass* ik, const ClassFileStream* stream
ik->name()->utf8_length()); ik->name()->utf8_length());
assert(file_name != NULL, "invariant"); assert(file_name != NULL, "invariant");
ClassLoaderExt::record_result(classpath_index, ik, CHECK); ClassLoaderExt::record_result(classpath_index, ik);
} }
#endif // INCLUDE_CDS #endif // INCLUDE_CDS

View File

@ -65,10 +65,10 @@ public:
ClassPathEntry() : _next(NULL) {} ClassPathEntry() : _next(NULL) {}
// Attempt to locate file_name through this class path entry. // Attempt to locate file_name through this class path entry.
// Returns a class file parsing stream if successfull. // Returns a class file parsing stream if successfull.
virtual ClassFileStream* open_stream(const char* name, TRAPS) = 0; virtual ClassFileStream* open_stream(Thread* current, const char* name) = 0;
// Open the stream for a specific class loader // Open the stream for a specific class loader
virtual ClassFileStream* open_stream_for_loader(const char* name, ClassLoaderData* loader_data, TRAPS) { virtual ClassFileStream* open_stream_for_loader(Thread* current, const char* name, ClassLoaderData* loader_data) {
return open_stream(name, THREAD); return open_stream(current, name);
} }
}; };
@ -81,7 +81,7 @@ class ClassPathDirEntry: public ClassPathEntry {
_dir = copy_path(dir); _dir = copy_path(dir);
} }
virtual ~ClassPathDirEntry() {} virtual ~ClassPathDirEntry() {}
ClassFileStream* open_stream(const char* name, TRAPS); ClassFileStream* open_stream(Thread* current, const char* name);
}; };
// Type definitions for zip file and zip file entry // Type definitions for zip file and zip file entry
@ -108,8 +108,8 @@ class ClassPathZipEntry: public ClassPathEntry {
const char* name() const { return _zip_name; } const char* name() const { return _zip_name; }
ClassPathZipEntry(jzfile* zip, const char* zip_name, bool is_boot_append, bool from_class_path_attr); ClassPathZipEntry(jzfile* zip, const char* zip_name, bool is_boot_append, bool from_class_path_attr);
virtual ~ClassPathZipEntry(); virtual ~ClassPathZipEntry();
u1* open_entry(const char* name, jint* filesize, bool nul_terminate, TRAPS); u1* open_entry(Thread* current, const char* name, jint* filesize, bool nul_terminate);
ClassFileStream* open_stream(const char* name, TRAPS); ClassFileStream* open_stream(Thread* current, const char* name);
void contents_do(void f(const char* name, void* context), void* context); void contents_do(void f(const char* name, void* context), void* context);
}; };
@ -128,8 +128,8 @@ public:
void close_jimage(); void close_jimage();
ClassPathImageEntry(JImageFile* jimage, const char* name); ClassPathImageEntry(JImageFile* jimage, const char* name);
virtual ~ClassPathImageEntry(); virtual ~ClassPathImageEntry();
ClassFileStream* open_stream(const char* name, TRAPS); ClassFileStream* open_stream(Thread* current, const char* name);
ClassFileStream* open_stream_for_loader(const char* name, ClassLoaderData* loader_data, TRAPS); ClassFileStream* open_stream_for_loader(Thread* current, const char* name, ClassLoaderData* loader_data);
}; };
// ModuleClassPathList contains a linked list of ClassPathEntry's // ModuleClassPathList contains a linked list of ClassPathEntry's
@ -365,7 +365,7 @@ class ClassLoader: AllStatic {
static int num_module_path_entries(); static int num_module_path_entries();
static void exit_with_path_failure(const char* error, const char* message); static void exit_with_path_failure(const char* error, const char* message);
static char* skip_uri_protocol(char* source); static char* skip_uri_protocol(char* source);
static void record_result(InstanceKlass* ik, const ClassFileStream* stream, TRAPS); static void record_result(Thread* current, InstanceKlass* ik, const ClassFileStream* stream);
#endif #endif
static char* lookup_vm_options(); static char* lookup_vm_options();

View File

@ -103,13 +103,13 @@ void ClassLoaderExt::setup_module_paths(TRAPS) {
process_module_table(met, CHECK); process_module_table(met, CHECK);
} }
char* ClassLoaderExt::read_manifest(ClassPathEntry* entry, jint *manifest_size, bool clean_text, TRAPS) { char* ClassLoaderExt::read_manifest(Thread* current, ClassPathEntry* entry, jint *manifest_size, bool clean_text) {
const char* name = "META-INF/MANIFEST.MF"; const char* name = "META-INF/MANIFEST.MF";
char* manifest; char* manifest;
jint size; jint size;
assert(entry->is_jar_file(), "must be"); assert(entry->is_jar_file(), "must be");
manifest = (char*) ((ClassPathZipEntry*)entry )->open_entry(name, &size, true, CHECK_NULL); manifest = (char*) ((ClassPathZipEntry*)entry )->open_entry(current, name, &size, true);
if (manifest == NULL) { // No Manifest if (manifest == NULL) { // No Manifest
*manifest_size = 0; *manifest_size = 0;
@ -167,7 +167,7 @@ void ClassLoaderExt::process_jar_manifest(ClassPathEntry* entry,
bool check_for_duplicates, TRAPS) { bool check_for_duplicates, TRAPS) {
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
jint manifest_size; jint manifest_size;
char* manifest = read_manifest(entry, &manifest_size, CHECK); char* manifest = read_manifest(THREAD, entry, &manifest_size);
if (manifest == NULL) { if (manifest == NULL) {
return; return;
@ -230,9 +230,7 @@ void ClassLoaderExt::setup_search_paths(TRAPS) {
ClassLoaderExt::setup_app_search_path(CHECK); ClassLoaderExt::setup_app_search_path(CHECK);
} }
void ClassLoaderExt::record_result(const s2 classpath_index, void ClassLoaderExt::record_result(const s2 classpath_index, InstanceKlass* result) {
InstanceKlass* result,
TRAPS) {
Arguments::assert_is_dumping_archive(); Arguments::assert_is_dumping_archive();
// We need to remember where the class comes from during dumping. // We need to remember where the class comes from during dumping.
@ -275,7 +273,7 @@ InstanceKlass* ClassLoaderExt::load_class(Symbol* name, const char* path, TRAPS)
PerfClassTraceTime vmtimer(perf_sys_class_lookup_time(), PerfClassTraceTime vmtimer(perf_sys_class_lookup_time(),
THREAD->as_Java_thread()->get_thread_stat()->perf_timers_addr(), THREAD->as_Java_thread()->get_thread_stat()->perf_timers_addr(),
PerfClassTraceTime::CLASS_LOAD); PerfClassTraceTime::CLASS_LOAD);
stream = e->open_stream(file_name, CHECK_NULL); stream = e->open_stream(THREAD, file_name);
} }
if (stream == NULL) { if (stream == NULL) {

View File

@ -57,7 +57,7 @@ private:
static bool _has_app_classes; static bool _has_app_classes;
static bool _has_platform_classes; static bool _has_platform_classes;
static char* read_manifest(ClassPathEntry* entry, jint *manifest_size, bool clean_text, TRAPS); static char* read_manifest(Thread* current, ClassPathEntry* entry, jint *manifest_size, bool clean_text);
static ClassPathEntry* find_classpath_entry_from_cache(Thread* current, const char* path); static ClassPathEntry* find_classpath_entry_from_cache(Thread* current, const char* path);
public: public:
@ -69,16 +69,16 @@ public:
static void setup_search_paths(TRAPS); static void setup_search_paths(TRAPS);
static void setup_module_paths(TRAPS); static void setup_module_paths(TRAPS);
static char* read_manifest(ClassPathEntry* entry, jint *manifest_size, TRAPS) { static char* read_manifest(Thread* current, ClassPathEntry* entry, jint *manifest_size) {
// Remove all the new-line continuations (which wrap long lines at 72 characters, see // Remove all the new-line continuations (which wrap long lines at 72 characters, see
// http://docs.oracle.com/javase/6/docs/technotes/guides/jar/jar.html#JAR%20Manifest), so // http://docs.oracle.com/javase/6/docs/technotes/guides/jar/jar.html#JAR%20Manifest), so
// that the manifest is easier to parse. // that the manifest is easier to parse.
return read_manifest(entry, manifest_size, true, THREAD); return read_manifest(current, entry, manifest_size, true);
} }
static char* read_raw_manifest(ClassPathEntry* entry, jint *manifest_size, TRAPS) { static char* read_raw_manifest(Thread* current, ClassPathEntry* entry, jint *manifest_size) {
// Do not remove new-line continuations, so we can easily pass it as an argument to // Do not remove new-line continuations, so we can easily pass it as an argument to
// java.util.jar.Manifest.getManifest() at run-time. // java.util.jar.Manifest.getManifest() at run-time.
return read_manifest(entry, manifest_size, false, THREAD); return read_manifest(current, entry, manifest_size, false);
} }
static jshort app_class_paths_start_index() { return _app_class_paths_start_index; } static jshort app_class_paths_start_index() { return _app_class_paths_start_index; }
@ -107,8 +107,7 @@ public:
return _has_app_classes || _has_platform_classes; return _has_app_classes || _has_platform_classes;
} }
static void record_result(const s2 classpath_index, static void record_result(const s2 classpath_index, InstanceKlass* result);
InstanceKlass* result, TRAPS);
static InstanceKlass* load_class(Symbol* h_name, const char* path, TRAPS); static InstanceKlass* load_class(Symbol* h_name, const char* path, TRAPS);
static void set_has_app_classes() { static void set_has_app_classes() {
_has_app_classes = true; _has_app_classes = true;

View File

@ -216,7 +216,7 @@ InstanceKlass* KlassFactory::create_from_stream(ClassFileStream* stream,
#if INCLUDE_CDS #if INCLUDE_CDS
if (Arguments::is_dumping_archive()) { if (Arguments::is_dumping_archive()) {
ClassLoader::record_result(result, stream, THREAD); ClassLoader::record_result(THREAD, result, stream);
} }
#endif // INCLUDE_CDS #endif // INCLUDE_CDS

View File

@ -736,7 +736,7 @@ Handle SystemDictionaryShared::get_shared_jar_manifest(int shared_path_index, TR
// ByteArrayInputStream bais = new ByteArrayInputStream(buf); // ByteArrayInputStream bais = new ByteArrayInputStream(buf);
const char* src = ent->manifest(); const char* src = ent->manifest();
assert(src != NULL, "No Manifest data"); assert(src != NULL, "No Manifest data");
manifest = create_jar_manifest(src, size, THREAD); manifest = create_jar_manifest(src, size, CHECK_NH);
atomic_set_shared_jar_manifest(shared_path_index, manifest()); atomic_set_shared_jar_manifest(shared_path_index, manifest());
} }
manifest = Handle(THREAD, shared_jar_manifest(shared_path_index)); manifest = Handle(THREAD, shared_jar_manifest(shared_path_index));
@ -896,7 +896,7 @@ Handle SystemDictionaryShared::init_security_info(Handle class_loader, InstanceK
// Modules::define_module(). // Modules::define_module().
assert(pkg_entry != NULL, "archived class in module image cannot be from unnamed package"); assert(pkg_entry != NULL, "archived class in module image cannot be from unnamed package");
ModuleEntry* mod_entry = pkg_entry->module(); ModuleEntry* mod_entry = pkg_entry->module();
pd = get_shared_protection_domain(class_loader, mod_entry, THREAD); pd = get_shared_protection_domain(class_loader, mod_entry, CHECK_(pd));
} else { } else {
// For shared app/platform classes originated from JAR files on the class path: // For shared app/platform classes originated from JAR files on the class path:
// Each of the 3 SystemDictionaryShared::_shared_xxx arrays has the same length // Each of the 3 SystemDictionaryShared::_shared_xxx arrays has the same length
@ -1180,7 +1180,7 @@ class LoadedUnregisteredClassesTable : public ResourceHashtable<
static LoadedUnregisteredClassesTable* _loaded_unregistered_classes = NULL; static LoadedUnregisteredClassesTable* _loaded_unregistered_classes = NULL;
bool SystemDictionaryShared::add_unregistered_class(InstanceKlass* k, TRAPS) { bool SystemDictionaryShared::add_unregistered_class(Thread* current, InstanceKlass* k) {
// We don't allow duplicated unregistered classes of the same name. // We don't allow duplicated unregistered classes of the same name.
assert(DumpSharedSpaces, "only when dumping"); assert(DumpSharedSpaces, "only when dumping");
Symbol* name = k->name(); Symbol* name = k->name();
@ -1190,7 +1190,7 @@ bool SystemDictionaryShared::add_unregistered_class(InstanceKlass* k, TRAPS) {
bool created = false; bool created = false;
_loaded_unregistered_classes->put_if_absent(name, true, &created); _loaded_unregistered_classes->put_if_absent(name, true, &created);
if (created) { if (created) {
MutexLocker mu_r(THREAD, Compile_lock); // add_to_hierarchy asserts this. MutexLocker mu_r(current, Compile_lock); // add_to_hierarchy asserts this.
SystemDictionary::add_to_hierarchy(k); SystemDictionary::add_to_hierarchy(k);
} }
return created; return created;
@ -1602,7 +1602,8 @@ void SystemDictionaryShared::add_lambda_proxy_class(InstanceKlass* caller_ik,
lambda_ik->assign_class_loader_type(); lambda_ik->assign_class_loader_type();
lambda_ik->set_shared_classpath_index(caller_ik->shared_classpath_index()); lambda_ik->set_shared_classpath_index(caller_ik->shared_classpath_index());
InstanceKlass* nest_host = caller_ik->nest_host(THREAD); InstanceKlass* nest_host = caller_ik->nest_host(CHECK);
assert(nest_host != NULL, "unexpected NULL nest_host");
DumpTimeSharedClassInfo* info = _dumptime_table->get(lambda_ik); DumpTimeSharedClassInfo* info = _dumptime_table->get(lambda_ik);
if (info != NULL && !lambda_ik->is_non_strong_hidden() && is_builtin(lambda_ik) && is_builtin(caller_ik) if (info != NULL && !lambda_ik->is_non_strong_hidden() && is_builtin(lambda_ik) && is_builtin(caller_ik)

View File

@ -246,7 +246,7 @@ public:
// Check if sharing is supported for the class loader. // Check if sharing is supported for the class loader.
static bool is_sharing_possible(ClassLoaderData* loader_data); static bool is_sharing_possible(ClassLoaderData* loader_data);
static bool add_unregistered_class(InstanceKlass* k, TRAPS); static bool add_unregistered_class(Thread* current, InstanceKlass* k);
static InstanceKlass* lookup_super_for_unregistered_class(Symbol* class_name, static InstanceKlass* lookup_super_for_unregistered_class(Symbol* class_name,
Symbol* super_name, bool is_superclass); Symbol* super_name, bool is_superclass);

View File

@ -1770,7 +1770,7 @@ void LinkResolver::resolve_invokedynamic(CallInfo& result, const constantPoolHan
// to CPCE state, including f1. // to CPCE state, including f1.
// Log dynamic info to CDS classlist. // Log dynamic info to CDS classlist.
ArchiveUtils::log_to_classlist(&bootstrap_specifier, THREAD); ArchiveUtils::log_to_classlist(&bootstrap_specifier, CHECK);
} }
void LinkResolver::resolve_dynamic_call(CallInfo& result, void LinkResolver::resolve_dynamic_call(CallInfo& result,

View File

@ -339,7 +339,7 @@ void ArchiveUtils::log_to_classlist(BootstrapInfo* bootstrap_specifier, TRAPS) {
ClassListWriter w; ClassListWriter w;
w.stream()->print("%s %s", LAMBDA_PROXY_TAG, pool->pool_holder()->name()->as_C_string()); w.stream()->print("%s %s", LAMBDA_PROXY_TAG, pool->pool_holder()->name()->as_C_string());
CDSIndyInfo cii; CDSIndyInfo cii;
ClassListParser::populate_cds_indy_info(pool, pool_index, &cii, THREAD); ClassListParser::populate_cds_indy_info(pool, pool_index, &cii, CHECK);
GrowableArray<const char*>* indy_items = cii.items(); GrowableArray<const char*>* indy_items = cii.items();
for (int i = 0; i < indy_items->length(); i++) { for (int i = 0; i < indy_items->length(); i++) {
w.stream()->print(" %s", indy_items->at(i)); w.stream()->print(" %s", indy_items->at(i));

View File

@ -657,7 +657,7 @@ void FileMapInfo::update_jar_manifest(ClassPathEntry *cpe, SharedClassPathEntry*
jint manifest_size; jint manifest_size;
assert(cpe->is_jar_file() && ent->is_jar(), "the shared class path entry is not a JAR file"); assert(cpe->is_jar_file() && ent->is_jar(), "the shared class path entry is not a JAR file");
char* manifest = ClassLoaderExt::read_manifest(cpe, &manifest_size, CHECK); char* manifest = ClassLoaderExt::read_manifest(THREAD, cpe, &manifest_size);
if (manifest != NULL) { if (manifest != NULL) {
ManifestStream* stream = new ManifestStream((u1*)manifest, ManifestStream* stream = new ManifestStream((u1*)manifest,
manifest_size); manifest_size);
@ -665,7 +665,7 @@ void FileMapInfo::update_jar_manifest(ClassPathEntry *cpe, SharedClassPathEntry*
ent->set_is_signed(); ent->set_is_signed();
} else { } else {
// Copy the manifest into the shared archive // Copy the manifest into the shared archive
manifest = ClassLoaderExt::read_raw_manifest(cpe, &manifest_size, CHECK); manifest = ClassLoaderExt::read_raw_manifest(THREAD, cpe, &manifest_size);
Array<u1>* buf = MetadataFactory::new_array<u1>(loader_data, Array<u1>* buf = MetadataFactory::new_array<u1>(loader_data,
manifest_size, manifest_size,
CHECK); CHECK);
@ -2370,9 +2370,8 @@ ClassFileStream* FileMapInfo::open_stream_for_jvmti(InstanceKlass* ik, Handle cl
const char* const file_name = ClassLoader::file_name_for_class_name(class_name, const char* const file_name = ClassLoader::file_name_for_class_name(class_name,
name->utf8_length()); name->utf8_length());
ClassLoaderData* loader_data = ClassLoaderData::class_loader_data(class_loader()); ClassLoaderData* loader_data = ClassLoaderData::class_loader_data(class_loader());
ClassFileStream* cfs = cpe->open_stream_for_loader(file_name, loader_data, THREAD); ClassFileStream* cfs = cpe->open_stream_for_loader(THREAD, file_name, loader_data);
assert(!HAS_PENDING_EXCEPTION && assert(cfs != NULL, "must be able to read the classfile data of shared classes for built-in loaders.");
cfs != NULL, "must be able to read the classfile data of shared classes for built-in loaders.");
log_debug(cds, jvmti)("classfile data for %s [%d: %s] = %d bytes", class_name, path_index, log_debug(cds, jvmti)("classfile data for %s [%d: %s] = %d bytes", class_name, path_index,
cfs->source(), cfs->length()); cfs->source(), cfs->length());
return cfs; return cfs;

View File

@ -700,14 +700,15 @@ void HeapShared::resolve_classes_for_subgraphs(ArchivableStaticFieldInfo fields[
} }
void HeapShared::resolve_classes_for_subgraph_of(Klass* k, Thread* THREAD) { void HeapShared::resolve_classes_for_subgraph_of(Klass* k, Thread* THREAD) {
const ArchivedKlassSubGraphInfoRecord* record = ExceptionMark em(THREAD);
const ArchivedKlassSubGraphInfoRecord* record =
resolve_or_init_classes_for_subgraph_of(k, /*do_init=*/false, THREAD); resolve_or_init_classes_for_subgraph_of(k, /*do_init=*/false, THREAD);
if (HAS_PENDING_EXCEPTION) { if (HAS_PENDING_EXCEPTION) {
CLEAR_PENDING_EXCEPTION; CLEAR_PENDING_EXCEPTION;
} }
if (record == NULL) { if (record == NULL) {
clear_archived_roots_of(k); clear_archived_roots_of(k);
} }
} }
void HeapShared::initialize_from_archived_subgraph(Klass* k, Thread* THREAD) { void HeapShared::initialize_from_archived_subgraph(Klass* k, Thread* THREAD) {
@ -715,6 +716,7 @@ void HeapShared::initialize_from_archived_subgraph(Klass* k, Thread* THREAD) {
return; // nothing to do return; // nothing to do
} }
ExceptionMark em(THREAD);
const ArchivedKlassSubGraphInfoRecord* record = const ArchivedKlassSubGraphInfoRecord* record =
resolve_or_init_classes_for_subgraph_of(k, /*do_init=*/true, THREAD); resolve_or_init_classes_for_subgraph_of(k, /*do_init=*/true, THREAD);
@ -746,7 +748,7 @@ HeapShared::resolve_or_init_classes_for_subgraph_of(Klass* k, bool do_init, TRAP
if (record != NULL) { if (record != NULL) {
if (record->is_full_module_graph() && !MetaspaceShared::use_full_module_graph()) { if (record->is_full_module_graph() && !MetaspaceShared::use_full_module_graph()) {
if (log_is_enabled(Info, cds, heap)) { if (log_is_enabled(Info, cds, heap)) {
ResourceMark rm; ResourceMark rm(THREAD);
log_info(cds, heap)("subgraph %s cannot be used because full module graph is disabled", log_info(cds, heap)("subgraph %s cannot be used because full module graph is disabled",
k->external_name()); k->external_name());
} }
@ -755,7 +757,7 @@ HeapShared::resolve_or_init_classes_for_subgraph_of(Klass* k, bool do_init, TRAP
if (record->has_non_early_klasses() && JvmtiExport::should_post_class_file_load_hook()) { if (record->has_non_early_klasses() && JvmtiExport::should_post_class_file_load_hook()) {
if (log_is_enabled(Info, cds, heap)) { if (log_is_enabled(Info, cds, heap)) {
ResourceMark rm; ResourceMark rm(THREAD);
log_info(cds, heap)("subgraph %s cannot be used because JVMTI ClassFileLoadHook is enabled", log_info(cds, heap)("subgraph %s cannot be used because JVMTI ClassFileLoadHook is enabled",
k->external_name()); k->external_name());
} }

View File

@ -218,7 +218,7 @@ void MetaspaceShared::post_initialize(TRAPS) {
if (UseSharedSpaces) { if (UseSharedSpaces) {
int size = FileMapInfo::get_number_of_shared_paths(); int size = FileMapInfo::get_number_of_shared_paths();
if (size > 0) { if (size > 0) {
SystemDictionaryShared::allocate_shared_data_arrays(size, THREAD); SystemDictionaryShared::allocate_shared_data_arrays(size, CHECK);
if (!DynamicDumpSharedSpaces) { if (!DynamicDumpSharedSpaces) {
FileMapInfo* info; FileMapInfo* info;
if (FileMapInfo::dynamic_info() == NULL) { if (FileMapInfo::dynamic_info() == NULL) {
@ -558,7 +558,7 @@ bool MetaspaceShared::link_class_for_cds(InstanceKlass* ik, TRAPS) {
// The following function is used to resolve all Strings in the statically // The following function is used to resolve all Strings in the statically
// dumped classes to archive all the Strings. The archive heap is not supported // dumped classes to archive all the Strings. The archive heap is not supported
// for the dynamic archive. // for the dynamic archive.
ik->constants()->resolve_class_constants(CHECK_0); // may throw OOM when interning strings. ik->constants()->resolve_class_constants(CHECK_(false)); // may throw OOM when interning strings.
} }
return res; return res;
} }
@ -709,9 +709,9 @@ void MetaspaceShared::preload_and_dump_impl(TRAPS) {
log_info(cds)("Rewriting and linking classes: done"); log_info(cds)("Rewriting and linking classes: done");
#if INCLUDE_CDS_JAVA_HEAP #if INCLUDE_CDS_JAVA_HEAP
if (use_full_module_graph()) { if (use_full_module_graph()) {
HeapShared::reset_archived_object_states(CHECK); HeapShared::reset_archived_object_states(CHECK);
} }
#endif #endif
VM_PopulateDumpSharedSpace op; VM_PopulateDumpSharedSpace op;