mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8260341: CDS dump VM init code does not check exceptions
Reviewed-by: coleenp, hseigel
This commit is contained in:
parent
447db62762
commit
adca84cc29
12 changed files with 93 additions and 85 deletions
|
@ -287,7 +287,7 @@ ClassPathZipEntry::~ClassPathZipEntry() {
|
||||||
|
|
||||||
u1* ClassPathZipEntry::open_entry(const char* name, jint* filesize, bool nul_terminate, TRAPS) {
|
u1* ClassPathZipEntry::open_entry(const char* name, jint* filesize, bool nul_terminate, TRAPS) {
|
||||||
// enable call to C land
|
// enable call to C land
|
||||||
JavaThread* thread = JavaThread::current();
|
JavaThread* thread = THREAD->as_Java_thread();
|
||||||
ThreadToNativeFromVM ttn(thread);
|
ThreadToNativeFromVM ttn(thread);
|
||||||
// check whether zip archive contains name
|
// check whether zip archive contains name
|
||||||
jint name_len;
|
jint name_len;
|
||||||
|
@ -501,7 +501,7 @@ void ClassLoader::trace_class_path(const char* msg, const char* name) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClassLoader::setup_bootstrap_search_path() {
|
void ClassLoader::setup_bootstrap_search_path(TRAPS) {
|
||||||
const char* sys_class_path = Arguments::get_sysclasspath();
|
const char* sys_class_path = Arguments::get_sysclasspath();
|
||||||
assert(sys_class_path != NULL, "System boot class path must not be NULL");
|
assert(sys_class_path != NULL, "System boot class path must not be NULL");
|
||||||
if (PrintSharedArchiveAndExit) {
|
if (PrintSharedArchiveAndExit) {
|
||||||
|
@ -510,11 +510,11 @@ void ClassLoader::setup_bootstrap_search_path() {
|
||||||
} else {
|
} else {
|
||||||
trace_class_path("bootstrap loader class path=", sys_class_path);
|
trace_class_path("bootstrap loader class path=", sys_class_path);
|
||||||
}
|
}
|
||||||
setup_boot_search_path(sys_class_path);
|
setup_bootstrap_search_path_impl(sys_class_path, CHECK);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if INCLUDE_CDS
|
#if INCLUDE_CDS
|
||||||
void ClassLoader::setup_app_search_path(const char *class_path) {
|
void ClassLoader::setup_app_search_path(const char *class_path, TRAPS) {
|
||||||
Arguments::assert_is_dumping_archive();
|
Arguments::assert_is_dumping_archive();
|
||||||
|
|
||||||
ResourceMark rm;
|
ResourceMark rm;
|
||||||
|
@ -522,7 +522,7 @@ void ClassLoader::setup_app_search_path(const char *class_path) {
|
||||||
|
|
||||||
while (cp_stream.has_next()) {
|
while (cp_stream.has_next()) {
|
||||||
const char* path = cp_stream.get_next();
|
const char* path = cp_stream.get_next();
|
||||||
update_class_path_entry_list(path, false, false, false);
|
update_class_path_entry_list(path, false, false, false, CHECK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -542,7 +542,7 @@ void ClassLoader::add_to_module_path_entries(const char* path,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a module path to the _module_path_entries list.
|
// Add a module path to the _module_path_entries list.
|
||||||
void ClassLoader::update_module_path_entry_list(const char *path, TRAPS) {
|
void ClassLoader::setup_module_search_path(const char* path, TRAPS) {
|
||||||
Arguments::assert_is_dumping_archive();
|
Arguments::assert_is_dumping_archive();
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (os::stat(path, &st) != 0) {
|
if (os::stat(path, &st) != 0) {
|
||||||
|
@ -562,10 +562,6 @@ void ClassLoader::update_module_path_entry_list(const char *path, TRAPS) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClassLoader::setup_module_search_path(const char* path, TRAPS) {
|
|
||||||
update_module_path_entry_list(path, THREAD);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // INCLUDE_CDS
|
#endif // INCLUDE_CDS
|
||||||
|
|
||||||
void ClassLoader::close_jrt_image() {
|
void ClassLoader::close_jrt_image() {
|
||||||
|
@ -632,8 +628,7 @@ bool ClassLoader::is_in_patch_mod_entries(Symbol* module_name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up the _jrt_entry if present and boot append path
|
// Set up the _jrt_entry if present and boot append path
|
||||||
void ClassLoader::setup_boot_search_path(const char *class_path) {
|
void ClassLoader::setup_bootstrap_search_path_impl(const char *class_path, TRAPS) {
|
||||||
EXCEPTION_MARK;
|
|
||||||
ResourceMark rm(THREAD);
|
ResourceMark rm(THREAD);
|
||||||
ClasspathStream cp_stream(class_path);
|
ClasspathStream cp_stream(class_path);
|
||||||
bool set_base_piece = true;
|
bool set_base_piece = true;
|
||||||
|
@ -675,7 +670,7 @@ void ClassLoader::setup_boot_search_path(const char *class_path) {
|
||||||
} else {
|
} else {
|
||||||
// Every entry on the system boot class path after the initial base piece,
|
// Every entry on the system boot class path after the initial base piece,
|
||||||
// which is set by os::set_boot_path(), is considered an appended entry.
|
// which is set by os::set_boot_path(), is considered an appended entry.
|
||||||
update_class_path_entry_list(path, false, true, false);
|
update_class_path_entry_list(path, false, true, false, CHECK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -722,7 +717,7 @@ ClassPathEntry* ClassLoader::create_class_path_entry(const char *path, const str
|
||||||
bool is_boot_append,
|
bool is_boot_append,
|
||||||
bool from_class_path_attr,
|
bool from_class_path_attr,
|
||||||
TRAPS) {
|
TRAPS) {
|
||||||
JavaThread* thread = JavaThread::current();
|
JavaThread* thread = THREAD->as_Java_thread();
|
||||||
ClassPathEntry* new_entry = NULL;
|
ClassPathEntry* new_entry = NULL;
|
||||||
if ((st->st_mode & S_IFMT) == S_IFREG) {
|
if ((st->st_mode & S_IFMT) == S_IFREG) {
|
||||||
ResourceMark rm(thread);
|
ResourceMark rm(thread);
|
||||||
|
@ -847,7 +842,8 @@ void ClassLoader::add_to_boot_append_entries(ClassPathEntry *new_entry) {
|
||||||
// jdk/internal/loader/ClassLoaders$AppClassLoader instance.
|
// jdk/internal/loader/ClassLoaders$AppClassLoader instance.
|
||||||
void ClassLoader::add_to_app_classpath_entries(const char* path,
|
void ClassLoader::add_to_app_classpath_entries(const char* path,
|
||||||
ClassPathEntry* entry,
|
ClassPathEntry* entry,
|
||||||
bool check_for_duplicates) {
|
bool check_for_duplicates,
|
||||||
|
TRAPS) {
|
||||||
#if INCLUDE_CDS
|
#if INCLUDE_CDS
|
||||||
assert(entry != NULL, "ClassPathEntry should not be NULL");
|
assert(entry != NULL, "ClassPathEntry should not be NULL");
|
||||||
ClassPathEntry* e = _app_classpath_entries;
|
ClassPathEntry* e = _app_classpath_entries;
|
||||||
|
@ -871,7 +867,7 @@ void ClassLoader::add_to_app_classpath_entries(const char* path,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry->is_jar_file()) {
|
if (entry->is_jar_file()) {
|
||||||
ClassLoaderExt::process_jar_manifest(entry, check_for_duplicates);
|
ClassLoaderExt::process_jar_manifest(entry, check_for_duplicates, CHECK);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -881,13 +877,12 @@ bool ClassLoader::update_class_path_entry_list(const char *path,
|
||||||
bool check_for_duplicates,
|
bool check_for_duplicates,
|
||||||
bool is_boot_append,
|
bool is_boot_append,
|
||||||
bool from_class_path_attr,
|
bool from_class_path_attr,
|
||||||
bool throw_exception) {
|
TRAPS) {
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (os::stat(path, &st) == 0) {
|
if (os::stat(path, &st) == 0) {
|
||||||
// File or directory found
|
// File or directory found
|
||||||
ClassPathEntry* new_entry = NULL;
|
ClassPathEntry* new_entry = NULL;
|
||||||
Thread* THREAD = Thread::current();
|
new_entry = create_class_path_entry(path, &st, /*throw_exception=*/true, is_boot_append, from_class_path_attr, CHECK_false);
|
||||||
new_entry = create_class_path_entry(path, &st, throw_exception, is_boot_append, from_class_path_attr, CHECK_(false));
|
|
||||||
if (new_entry == NULL) {
|
if (new_entry == NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -897,7 +892,7 @@ bool ClassLoader::update_class_path_entry_list(const char *path,
|
||||||
if (is_boot_append) {
|
if (is_boot_append) {
|
||||||
add_to_boot_append_entries(new_entry);
|
add_to_boot_append_entries(new_entry);
|
||||||
} else {
|
} else {
|
||||||
add_to_app_classpath_entries(path, new_entry, check_for_duplicates);
|
add_to_app_classpath_entries(path, new_entry, check_for_duplicates, CHECK_false);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1286,7 +1281,7 @@ InstanceKlass* ClassLoader::load_class(Symbol* name, bool search_append_only, TR
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
result->set_classpath_index(classpath_index, THREAD);
|
result->set_classpath_index(classpath_index);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1421,7 +1416,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, THREAD);
|
ClassLoaderExt::record_result(classpath_index, ik, CHECK);
|
||||||
}
|
}
|
||||||
#endif // INCLUDE_CDS
|
#endif // INCLUDE_CDS
|
||||||
|
|
||||||
|
@ -1430,9 +1425,7 @@ void ClassLoader::record_result(InstanceKlass* ik, const ClassFileStream* stream
|
||||||
// this list has been created, it must not change order (see class PackageInfo)
|
// this list has been created, it must not change order (see class PackageInfo)
|
||||||
// it can be appended to and is by jvmti.
|
// it can be appended to and is by jvmti.
|
||||||
|
|
||||||
void ClassLoader::initialize() {
|
void ClassLoader::initialize(TRAPS) {
|
||||||
EXCEPTION_MARK;
|
|
||||||
|
|
||||||
if (UsePerfData) {
|
if (UsePerfData) {
|
||||||
// jvmstat performance counters
|
// jvmstat performance counters
|
||||||
NEWPERFTICKCOUNTER(_perf_accumulated_time, SUN_CLS, "time");
|
NEWPERFTICKCOUNTER(_perf_accumulated_time, SUN_CLS, "time");
|
||||||
|
@ -1464,7 +1457,7 @@ void ClassLoader::initialize() {
|
||||||
// lookup java library entry points
|
// lookup java library entry points
|
||||||
load_java_library();
|
load_java_library();
|
||||||
// jimage library entry points are loaded below, in lookup_vm_options
|
// jimage library entry points are loaded below, in lookup_vm_options
|
||||||
setup_bootstrap_search_path();
|
setup_bootstrap_search_path(CHECK);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* lookup_vm_resource(JImageFile *jimage, const char *jimage_version, const char *path) {
|
char* lookup_vm_resource(JImageFile *jimage, const char *jimage_version, const char *path) {
|
||||||
|
@ -1501,16 +1494,16 @@ char* ClassLoader::lookup_vm_options() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if INCLUDE_CDS
|
#if INCLUDE_CDS
|
||||||
void ClassLoader::initialize_shared_path() {
|
void ClassLoader::initialize_shared_path(TRAPS) {
|
||||||
if (Arguments::is_dumping_archive()) {
|
if (Arguments::is_dumping_archive()) {
|
||||||
ClassLoaderExt::setup_search_paths();
|
ClassLoaderExt::setup_search_paths(CHECK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClassLoader::initialize_module_path(TRAPS) {
|
void ClassLoader::initialize_module_path(TRAPS) {
|
||||||
if (Arguments::is_dumping_archive()) {
|
if (Arguments::is_dumping_archive()) {
|
||||||
ClassLoaderExt::setup_module_paths(THREAD);
|
ClassLoaderExt::setup_module_paths(CHECK);
|
||||||
FileMapInfo::allocate_shared_path_table();
|
FileMapInfo::allocate_shared_path_table(CHECK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1566,7 +1559,11 @@ int ClassLoader::compute_Object_vtable() {
|
||||||
|
|
||||||
|
|
||||||
void classLoader_init1() {
|
void classLoader_init1() {
|
||||||
ClassLoader::initialize();
|
EXCEPTION_MARK;
|
||||||
|
ClassLoader::initialize(THREAD);
|
||||||
|
if (HAS_PENDING_EXCEPTION) {
|
||||||
|
vm_exit_during_initialization("ClassLoader::initialize() failed unexpectedly");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Complete the ClassPathEntry setup for the boot loader
|
// Complete the ClassPathEntry setup for the boot loader
|
||||||
|
|
|
@ -222,11 +222,12 @@ class ClassLoader: AllStatic {
|
||||||
CDS_ONLY(static ClassPathEntry* _last_app_classpath_entry;)
|
CDS_ONLY(static ClassPathEntry* _last_app_classpath_entry;)
|
||||||
CDS_ONLY(static ClassPathEntry* _module_path_entries;)
|
CDS_ONLY(static ClassPathEntry* _module_path_entries;)
|
||||||
CDS_ONLY(static ClassPathEntry* _last_module_path_entry;)
|
CDS_ONLY(static ClassPathEntry* _last_module_path_entry;)
|
||||||
CDS_ONLY(static void setup_app_search_path(const char* class_path);)
|
CDS_ONLY(static void setup_app_search_path(const char* class_path, TRAPS);)
|
||||||
CDS_ONLY(static void setup_module_search_path(const char* path, TRAPS);)
|
CDS_ONLY(static void setup_module_search_path(const char* path, TRAPS);)
|
||||||
static void add_to_app_classpath_entries(const char* path,
|
static void add_to_app_classpath_entries(const char* path,
|
||||||
ClassPathEntry* entry,
|
ClassPathEntry* entry,
|
||||||
bool check_for_duplicates);
|
bool check_for_duplicates,
|
||||||
|
TRAPS);
|
||||||
CDS_ONLY(static void add_to_module_path_entries(const char* path,
|
CDS_ONLY(static void add_to_module_path_entries(const char* path,
|
||||||
ClassPathEntry* entry);)
|
ClassPathEntry* entry);)
|
||||||
public:
|
public:
|
||||||
|
@ -240,8 +241,8 @@ class ClassLoader: AllStatic {
|
||||||
// - setup the boot loader's system class path
|
// - setup the boot loader's system class path
|
||||||
// - setup the boot loader's patch mod entries, if present
|
// - setup the boot loader's patch mod entries, if present
|
||||||
// - create the ModuleEntry for java.base
|
// - create the ModuleEntry for java.base
|
||||||
static void setup_bootstrap_search_path();
|
static void setup_bootstrap_search_path(TRAPS);
|
||||||
static void setup_boot_search_path(const char *class_path);
|
static void setup_bootstrap_search_path_impl(const char *class_path, TRAPS);
|
||||||
static void setup_patch_mod_entries();
|
static void setup_patch_mod_entries();
|
||||||
static void create_javabase();
|
static void create_javabase();
|
||||||
|
|
||||||
|
@ -272,8 +273,7 @@ class ClassLoader: AllStatic {
|
||||||
bool check_for_duplicates,
|
bool check_for_duplicates,
|
||||||
bool is_boot_append,
|
bool is_boot_append,
|
||||||
bool from_class_path_attr,
|
bool from_class_path_attr,
|
||||||
bool throw_exception=true);
|
TRAPS);
|
||||||
CDS_ONLY(static void update_module_path_entry_list(const char *path, TRAPS);)
|
|
||||||
static void print_bootclasspath();
|
static void print_bootclasspath();
|
||||||
|
|
||||||
// Timing
|
// Timing
|
||||||
|
@ -335,9 +335,9 @@ class ClassLoader: AllStatic {
|
||||||
static objArrayOop get_system_packages(TRAPS);
|
static objArrayOop get_system_packages(TRAPS);
|
||||||
|
|
||||||
// Initialization
|
// Initialization
|
||||||
static void initialize();
|
static void initialize(TRAPS);
|
||||||
static void classLoader_init2(TRAPS);
|
static void classLoader_init2(TRAPS);
|
||||||
CDS_ONLY(static void initialize_shared_path();)
|
CDS_ONLY(static void initialize_shared_path(TRAPS);)
|
||||||
CDS_ONLY(static void initialize_module_path(TRAPS);)
|
CDS_ONLY(static void initialize_module_path(TRAPS);)
|
||||||
|
|
||||||
static int compute_Object_vtable();
|
static int compute_Object_vtable();
|
||||||
|
|
|
@ -65,7 +65,7 @@ void ClassLoaderExt::append_boot_classpath(ClassPathEntry* new_entry) {
|
||||||
ClassLoader::add_to_boot_append_entries(new_entry);
|
ClassLoader::add_to_boot_append_entries(new_entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClassLoaderExt::setup_app_search_path() {
|
void ClassLoaderExt::setup_app_search_path(TRAPS) {
|
||||||
Arguments::assert_is_dumping_archive();
|
Arguments::assert_is_dumping_archive();
|
||||||
_app_class_paths_start_index = ClassLoader::num_boot_classpath_entries();
|
_app_class_paths_start_index = ClassLoader::num_boot_classpath_entries();
|
||||||
char* app_class_path = os::strdup(Arguments::get_appclasspath());
|
char* app_class_path = os::strdup(Arguments::get_appclasspath());
|
||||||
|
@ -77,7 +77,7 @@ void ClassLoaderExt::setup_app_search_path() {
|
||||||
trace_class_path("app loader class path (skipped)=", app_class_path);
|
trace_class_path("app loader class path (skipped)=", app_class_path);
|
||||||
} else {
|
} else {
|
||||||
trace_class_path("app loader class path=", app_class_path);
|
trace_class_path("app loader class path=", app_class_path);
|
||||||
ClassLoader::setup_app_search_path(app_class_path);
|
ClassLoader::setup_app_search_path(app_class_path, CHECK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ void ClassLoaderExt::process_module_table(ModuleEntryTable* met, TRAPS) {
|
||||||
char* path = m->location()->as_C_string();
|
char* path = m->location()->as_C_string();
|
||||||
if (strncmp(path, "file:", 5) == 0) {
|
if (strncmp(path, "file:", 5) == 0) {
|
||||||
path = ClassLoader::skip_uri_protocol(path);
|
path = ClassLoader::skip_uri_protocol(path);
|
||||||
ClassLoader::setup_module_search_path(path, THREAD);
|
ClassLoader::setup_module_search_path(path, CHECK);
|
||||||
}
|
}
|
||||||
m = m->next();
|
m = m->next();
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ void ClassLoaderExt::setup_module_paths(TRAPS) {
|
||||||
ClassLoader::num_app_classpath_entries();
|
ClassLoader::num_app_classpath_entries();
|
||||||
Handle system_class_loader (THREAD, SystemDictionary::java_system_loader());
|
Handle system_class_loader (THREAD, SystemDictionary::java_system_loader());
|
||||||
ModuleEntryTable* met = Modules::get_module_entry_table(system_class_loader);
|
ModuleEntryTable* met = Modules::get_module_entry_table(system_class_loader);
|
||||||
process_module_table(met, THREAD);
|
process_module_table(met, CHECK);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* ClassLoaderExt::read_manifest(ClassPathEntry* entry, jint *manifest_size, bool clean_text, TRAPS) {
|
char* ClassLoaderExt::read_manifest(ClassPathEntry* entry, jint *manifest_size, bool clean_text, TRAPS) {
|
||||||
|
@ -164,8 +164,7 @@ char* ClassLoaderExt::get_class_path_attr(const char* jar_path, char* manifest,
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClassLoaderExt::process_jar_manifest(ClassPathEntry* entry,
|
void ClassLoaderExt::process_jar_manifest(ClassPathEntry* entry,
|
||||||
bool check_for_duplicates) {
|
bool check_for_duplicates, TRAPS) {
|
||||||
Thread* THREAD = Thread::current();
|
|
||||||
ResourceMark rm(THREAD);
|
ResourceMark rm(THREAD);
|
||||||
jint manifest_size;
|
jint manifest_size;
|
||||||
char* manifest = read_manifest(entry, &manifest_size, CHECK);
|
char* manifest = read_manifest(entry, &manifest_size, CHECK);
|
||||||
|
@ -213,7 +212,8 @@ void ClassLoaderExt::process_jar_manifest(ClassPathEntry* entry,
|
||||||
char* libname = NEW_RESOURCE_ARRAY(char, libname_len + 1);
|
char* libname = NEW_RESOURCE_ARRAY(char, libname_len + 1);
|
||||||
int n = os::snprintf(libname, libname_len + 1, "%.*s%s", dir_len, dir_name, file_start);
|
int n = os::snprintf(libname, libname_len + 1, "%.*s%s", dir_len, dir_name, file_start);
|
||||||
assert((size_t)n == libname_len, "Unexpected number of characters in string");
|
assert((size_t)n == libname_len, "Unexpected number of characters in string");
|
||||||
if (ClassLoader::update_class_path_entry_list(libname, true, false, true /* from_class_path_attr */)) {
|
bool status = ClassLoader::update_class_path_entry_list(libname, true, false, true /* from_class_path_attr */, CHECK);
|
||||||
|
if (status) {
|
||||||
trace_class_path("library = ", libname);
|
trace_class_path("library = ", libname);
|
||||||
} else {
|
} else {
|
||||||
trace_class_path("library (non-existent) = ", libname);
|
trace_class_path("library (non-existent) = ", libname);
|
||||||
|
@ -226,8 +226,8 @@ void ClassLoaderExt::process_jar_manifest(ClassPathEntry* entry,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClassLoaderExt::setup_search_paths() {
|
void ClassLoaderExt::setup_search_paths(TRAPS) {
|
||||||
ClassLoaderExt::setup_app_search_path();
|
ClassLoaderExt::setup_app_search_path(CHECK);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClassLoaderExt::record_result(const s2 classpath_index,
|
void ClassLoaderExt::record_result(const s2 classpath_index,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -45,7 +45,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
static char* get_class_path_attr(const char* jar_path, char* manifest, jint manifest_size);
|
static char* get_class_path_attr(const char* jar_path, char* manifest, jint manifest_size);
|
||||||
static void setup_app_search_path(); // Only when -Xshare:dump
|
static void setup_app_search_path(TRAPS); // Only when -Xshare:dump
|
||||||
static void process_module_table(ModuleEntryTable* met, TRAPS);
|
static void process_module_table(ModuleEntryTable* met, TRAPS);
|
||||||
// index of first app JAR in shared classpath entry table
|
// index of first app JAR in shared classpath entry table
|
||||||
static jshort _app_class_paths_start_index;
|
static jshort _app_class_paths_start_index;
|
||||||
|
@ -61,12 +61,12 @@ private:
|
||||||
static ClassPathEntry* find_classpath_entry_from_cache(const char* path, TRAPS);
|
static ClassPathEntry* find_classpath_entry_from_cache(const char* path, TRAPS);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void process_jar_manifest(ClassPathEntry* entry, bool check_for_duplicates);
|
static void process_jar_manifest(ClassPathEntry* entry, bool check_for_duplicates, TRAPS);
|
||||||
|
|
||||||
// Called by JVMTI code to add boot classpath
|
// Called by JVMTI code to add boot classpath
|
||||||
static void append_boot_classpath(ClassPathEntry* new_entry);
|
static void append_boot_classpath(ClassPathEntry* new_entry);
|
||||||
|
|
||||||
static void setup_search_paths();
|
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(ClassPathEntry* entry, jint *manifest_size, TRAPS) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -98,7 +98,7 @@ InstanceKlass* KlassFactory::check_shared_class_file_load_hook(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (class_loader.is_null()) {
|
if (class_loader.is_null()) {
|
||||||
new_ik->set_classpath_index(path_index, THREAD);
|
new_ik->set_classpath_index(path_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new_ik;
|
return new_ik;
|
||||||
|
|
|
@ -1360,7 +1360,7 @@ void SystemDictionary::load_shared_class_misc(InstanceKlass* ik, ClassLoaderData
|
||||||
// package was loaded.
|
// package was loaded.
|
||||||
if (loader_data->is_the_null_class_loader_data()) {
|
if (loader_data->is_the_null_class_loader_data()) {
|
||||||
int path_index = ik->shared_classpath_index();
|
int path_index = ik->shared_classpath_index();
|
||||||
ik->set_classpath_index(path_index, THREAD);
|
ik->set_classpath_index(path_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
// notify a class loaded from shared object
|
// notify a class loaded from shared object
|
||||||
|
|
|
@ -304,7 +304,7 @@ void FileMapHeader::print(outputStream* st) {
|
||||||
|
|
||||||
void SharedClassPathEntry::init_as_non_existent(const char* path, TRAPS) {
|
void SharedClassPathEntry::init_as_non_existent(const char* path, TRAPS) {
|
||||||
_type = non_existent_entry;
|
_type = non_existent_entry;
|
||||||
set_name(path, THREAD);
|
set_name(path, CHECK);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SharedClassPathEntry::init(bool is_modules_image,
|
void SharedClassPathEntry::init(bool is_modules_image,
|
||||||
|
@ -343,12 +343,12 @@ void SharedClassPathEntry::init(bool is_modules_image,
|
||||||
// No need to save the name of the module file, as it will be computed at run time
|
// No need to save the name of the module file, as it will be computed at run time
|
||||||
// to allow relocation of the JDK directory.
|
// to allow relocation of the JDK directory.
|
||||||
const char* name = is_modules_image ? "" : cpe->name();
|
const char* name = is_modules_image ? "" : cpe->name();
|
||||||
set_name(name, THREAD);
|
set_name(name, CHECK);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SharedClassPathEntry::set_name(const char* name, TRAPS) {
|
void SharedClassPathEntry::set_name(const char* name, TRAPS) {
|
||||||
size_t len = strlen(name) + 1;
|
size_t len = strlen(name) + 1;
|
||||||
_name = MetadataFactory::new_array<char>(ClassLoaderData::the_null_class_loader_data(), (int)len, THREAD);
|
_name = MetadataFactory::new_array<char>(ClassLoaderData::the_null_class_loader_data(), (int)len, CHECK);
|
||||||
strcpy(_name->data(), name);
|
strcpy(_name->data(), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,12 +358,12 @@ void SharedClassPathEntry::copy_from(SharedClassPathEntry* ent, ClassLoaderData*
|
||||||
_timestamp = ent->_timestamp;
|
_timestamp = ent->_timestamp;
|
||||||
_filesize = ent->_filesize;
|
_filesize = ent->_filesize;
|
||||||
_from_class_path_attr = ent->_from_class_path_attr;
|
_from_class_path_attr = ent->_from_class_path_attr;
|
||||||
set_name(ent->name(), THREAD);
|
set_name(ent->name(), CHECK);
|
||||||
|
|
||||||
if (ent->is_jar() && !ent->is_signed() && ent->manifest() != NULL) {
|
if (ent->is_jar() && !ent->is_signed() && ent->manifest() != NULL) {
|
||||||
Array<u1>* buf = MetadataFactory::new_array<u1>(loader_data,
|
Array<u1>* buf = MetadataFactory::new_array<u1>(loader_data,
|
||||||
ent->manifest_size(),
|
ent->manifest_size(),
|
||||||
THREAD);
|
CHECK);
|
||||||
char* p = (char*)(buf->data());
|
char* p = (char*)(buf->data());
|
||||||
memcpy(p, ent->manifest(), ent->manifest_size());
|
memcpy(p, ent->manifest(), ent->manifest_size());
|
||||||
set_manifest(buf);
|
set_manifest(buf);
|
||||||
|
@ -449,7 +449,7 @@ void SharedPathTable::metaspace_pointers_do(MetaspaceClosure* it) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SharedPathTable::dumptime_init(ClassLoaderData* loader_data, Thread* THREAD) {
|
void SharedPathTable::dumptime_init(ClassLoaderData* loader_data, TRAPS) {
|
||||||
size_t entry_size = sizeof(SharedClassPathEntry);
|
size_t entry_size = sizeof(SharedClassPathEntry);
|
||||||
int num_entries = 0;
|
int num_entries = 0;
|
||||||
num_entries += ClassLoader::num_boot_classpath_entries();
|
num_entries += ClassLoader::num_boot_classpath_entries();
|
||||||
|
@ -458,7 +458,7 @@ void SharedPathTable::dumptime_init(ClassLoaderData* loader_data, Thread* THREAD
|
||||||
num_entries += FileMapInfo::num_non_existent_class_paths();
|
num_entries += FileMapInfo::num_non_existent_class_paths();
|
||||||
size_t bytes = entry_size * num_entries;
|
size_t bytes = entry_size * num_entries;
|
||||||
|
|
||||||
_table = MetadataFactory::new_array<u8>(loader_data, (int)bytes, THREAD);
|
_table = MetadataFactory::new_array<u8>(loader_data, (int)bytes, CHECK);
|
||||||
_size = num_entries;
|
_size = num_entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -466,44 +466,43 @@ void SharedPathTable::dumptime_init(ClassLoaderData* loader_data, Thread* THREAD
|
||||||
// It is needed because some Java code continues to execute after dynamic dump has finished.
|
// It is needed because some Java code continues to execute after dynamic dump has finished.
|
||||||
// However, during dynamic dump, we have modified FileMapInfo::_shared_path_table so
|
// However, during dynamic dump, we have modified FileMapInfo::_shared_path_table so
|
||||||
// FileMapInfo::shared_path(i) returns incorrect information in ClassLoader::record_result().
|
// FileMapInfo::shared_path(i) returns incorrect information in ClassLoader::record_result().
|
||||||
void FileMapInfo::copy_shared_path_table(ClassLoaderData* loader_data, Thread* THREAD) {
|
void FileMapInfo::copy_shared_path_table(ClassLoaderData* loader_data, TRAPS) {
|
||||||
size_t entry_size = sizeof(SharedClassPathEntry);
|
size_t entry_size = sizeof(SharedClassPathEntry);
|
||||||
size_t bytes = entry_size * _shared_path_table.size();
|
size_t bytes = entry_size * _shared_path_table.size();
|
||||||
|
|
||||||
_saved_shared_path_table = SharedPathTable(MetadataFactory::new_array<u8>(loader_data, (int)bytes, THREAD),
|
Array<u8>* array = MetadataFactory::new_array<u8>(loader_data, (int)bytes, CHECK);
|
||||||
_shared_path_table.size());
|
_saved_shared_path_table = SharedPathTable(array, _shared_path_table.size());
|
||||||
|
|
||||||
for (int i = 0; i < _shared_path_table.size(); i++) {
|
for (int i = 0; i < _shared_path_table.size(); i++) {
|
||||||
_saved_shared_path_table.path_at(i)->copy_from(shared_path(i), loader_data, THREAD);
|
_saved_shared_path_table.path_at(i)->copy_from(shared_path(i), loader_data, CHECK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileMapInfo::allocate_shared_path_table() {
|
void FileMapInfo::allocate_shared_path_table(TRAPS) {
|
||||||
Arguments::assert_is_dumping_archive();
|
Arguments::assert_is_dumping_archive();
|
||||||
|
|
||||||
EXCEPTION_MARK; // The following calls should never throw, but would exit VM on error.
|
|
||||||
ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
|
ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
|
||||||
ClassPathEntry* jrt = ClassLoader::get_jrt_entry();
|
ClassPathEntry* jrt = ClassLoader::get_jrt_entry();
|
||||||
|
|
||||||
assert(jrt != NULL,
|
assert(jrt != NULL,
|
||||||
"No modular java runtime image present when allocating the CDS classpath entry table");
|
"No modular java runtime image present when allocating the CDS classpath entry table");
|
||||||
|
|
||||||
_shared_path_table.dumptime_init(loader_data, THREAD);
|
_shared_path_table.dumptime_init(loader_data, CHECK);
|
||||||
|
|
||||||
// 1. boot class path
|
// 1. boot class path
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i = add_shared_classpaths(i, "boot", jrt, THREAD);
|
i = add_shared_classpaths(i, "boot", jrt, CHECK);
|
||||||
i = add_shared_classpaths(i, "app", ClassLoader::app_classpath_entries(), THREAD);
|
i = add_shared_classpaths(i, "app", ClassLoader::app_classpath_entries(), CHECK);
|
||||||
i = add_shared_classpaths(i, "module", ClassLoader::module_path_entries(), THREAD);
|
i = add_shared_classpaths(i, "module", ClassLoader::module_path_entries(), CHECK);
|
||||||
|
|
||||||
for (int x = 0; x < num_non_existent_class_paths(); x++, i++) {
|
for (int x = 0; x < num_non_existent_class_paths(); x++, i++) {
|
||||||
const char* path = _non_existent_class_paths->at(x);
|
const char* path = _non_existent_class_paths->at(x);
|
||||||
shared_path(i)->init_as_non_existent(path, THREAD);
|
shared_path(i)->init_as_non_existent(path, CHECK);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(i == _shared_path_table.size(), "number of shared path entry mismatch");
|
assert(i == _shared_path_table.size(), "number of shared path entry mismatch");
|
||||||
|
|
||||||
copy_shared_path_table(loader_data, THREAD);
|
copy_shared_path_table(loader_data, CHECK);
|
||||||
}
|
}
|
||||||
|
|
||||||
int FileMapInfo::add_shared_classpaths(int i, const char* which, ClassPathEntry *cpe, TRAPS) {
|
int FileMapInfo::add_shared_classpaths(int i, const char* which, ClassPathEntry *cpe, TRAPS) {
|
||||||
|
@ -513,9 +512,9 @@ int FileMapInfo::add_shared_classpaths(int i, const char* which, ClassPathEntry
|
||||||
const char* type = (is_jrt ? "jrt" : (cpe->is_jar_file() ? "jar" : "dir"));
|
const char* type = (is_jrt ? "jrt" : (cpe->is_jar_file() ? "jar" : "dir"));
|
||||||
log_info(class, path)("add %s shared path (%s) %s", which, type, cpe->name());
|
log_info(class, path)("add %s shared path (%s) %s", which, type, cpe->name());
|
||||||
SharedClassPathEntry* ent = shared_path(i);
|
SharedClassPathEntry* ent = shared_path(i);
|
||||||
ent->init(is_jrt, is_module_path, cpe, THREAD);
|
ent->init(is_jrt, is_module_path, cpe, CHECK_0);
|
||||||
if (cpe->is_jar_file()) {
|
if (cpe->is_jar_file()) {
|
||||||
update_jar_manifest(cpe, ent, THREAD);
|
update_jar_manifest(cpe, ent, CHECK_0);
|
||||||
}
|
}
|
||||||
if (is_jrt) {
|
if (is_jrt) {
|
||||||
cpe = ClassLoader::get_next_boot_classpath_entry(cpe);
|
cpe = ClassLoader::get_next_boot_classpath_entry(cpe);
|
||||||
|
@ -670,7 +669,7 @@ void FileMapInfo::update_jar_manifest(ClassPathEntry *cpe, SharedClassPathEntry*
|
||||||
manifest = ClassLoaderExt::read_raw_manifest(cpe, &manifest_size, CHECK);
|
manifest = ClassLoaderExt::read_raw_manifest(cpe, &manifest_size, CHECK);
|
||||||
Array<u1>* buf = MetadataFactory::new_array<u1>(loader_data,
|
Array<u1>* buf = MetadataFactory::new_array<u1>(loader_data,
|
||||||
manifest_size,
|
manifest_size,
|
||||||
THREAD);
|
CHECK);
|
||||||
char* p = (char*)(buf->data());
|
char* p = (char*)(buf->data());
|
||||||
memcpy(p, manifest, manifest_size);
|
memcpy(p, manifest, manifest_size);
|
||||||
ent->set_manifest(buf);
|
ent->set_manifest(buf);
|
||||||
|
@ -2364,7 +2363,8 @@ ClassFileStream* FileMapInfo::open_stream_for_jvmti(InstanceKlass* ik, Handle cl
|
||||||
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(file_name, loader_data, THREAD);
|
||||||
assert(cfs != NULL, "must be able to read the classfile data of shared classes for built-in loaders.");
|
assert(!HAS_PENDING_EXCEPTION &&
|
||||||
|
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;
|
||||||
|
|
|
@ -117,7 +117,7 @@ public:
|
||||||
SharedPathTable() : _table(NULL), _size(0) {}
|
SharedPathTable() : _table(NULL), _size(0) {}
|
||||||
SharedPathTable(Array<u8>* table, int size) : _table(table), _size(size) {}
|
SharedPathTable(Array<u8>* table, int size) : _table(table), _size(size) {}
|
||||||
|
|
||||||
void dumptime_init(ClassLoaderData* loader_data, Thread* THREAD);
|
void dumptime_init(ClassLoaderData* loader_data, TRAPS);
|
||||||
void metaspace_pointers_do(MetaspaceClosure* it);
|
void metaspace_pointers_do(MetaspaceClosure* it);
|
||||||
|
|
||||||
int size() {
|
int size() {
|
||||||
|
@ -498,8 +498,8 @@ public:
|
||||||
// Stop CDS sharing and unmap CDS regions.
|
// Stop CDS sharing and unmap CDS regions.
|
||||||
static void stop_sharing_and_unmap(const char* msg);
|
static void stop_sharing_and_unmap(const char* msg);
|
||||||
|
|
||||||
static void allocate_shared_path_table();
|
static void allocate_shared_path_table(TRAPS);
|
||||||
static void copy_shared_path_table(ClassLoaderData* loader_data, Thread* THREAD);
|
static void copy_shared_path_table(ClassLoaderData* loader_data, TRAPS);
|
||||||
static int add_shared_classpaths(int i, const char* which, ClassPathEntry *cpe, TRAPS);
|
static int add_shared_classpaths(int i, const char* which, ClassPathEntry *cpe, TRAPS);
|
||||||
static void check_nonempty_dir_in_shared_path_table();
|
static void check_nonempty_dir_in_shared_path_table();
|
||||||
bool validate_shared_path_table();
|
bool validate_shared_path_table();
|
||||||
|
|
|
@ -816,8 +816,15 @@ void MetaspaceShared::link_and_cleanup_shared_classes(TRAPS) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetaspaceShared::prepare_for_dumping() {
|
void MetaspaceShared::prepare_for_dumping() {
|
||||||
|
Arguments::assert_is_dumping_archive();
|
||||||
Arguments::check_unsupported_dumping_properties();
|
Arguments::check_unsupported_dumping_properties();
|
||||||
ClassLoader::initialize_shared_path();
|
|
||||||
|
EXCEPTION_MARK;
|
||||||
|
ClassLoader::initialize_shared_path(THREAD);
|
||||||
|
if (HAS_PENDING_EXCEPTION) {
|
||||||
|
java_lang_Throwable::print(PENDING_EXCEPTION, tty);
|
||||||
|
vm_exit_during_initialization("ClassLoader::initialize_shared_path() failed unexpectedly");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Preload classes from a list, populate the shared spaces and dump to a
|
// Preload classes from a list, populate the shared spaces and dump to a
|
||||||
|
|
|
@ -2934,7 +2934,7 @@ void InstanceKlass::set_package(ClassLoaderData* loader_data, PackageEntry* pkg_
|
||||||
// in an unnamed module. It is also used to indicate (for all packages whose
|
// in an unnamed module. It is also used to indicate (for all packages whose
|
||||||
// classes are loaded by the boot loader) that at least one of the package's
|
// classes are loaded by the boot loader) that at least one of the package's
|
||||||
// classes has been loaded.
|
// classes has been loaded.
|
||||||
void InstanceKlass::set_classpath_index(s2 path_index, TRAPS) {
|
void InstanceKlass::set_classpath_index(s2 path_index) {
|
||||||
if (_package_entry != NULL) {
|
if (_package_entry != NULL) {
|
||||||
DEBUG_ONLY(PackageEntryTable* pkg_entry_tbl = ClassLoaderData::the_null_class_loader_data()->packages();)
|
DEBUG_ONLY(PackageEntryTable* pkg_entry_tbl = ClassLoaderData::the_null_class_loader_data()->packages();)
|
||||||
assert(pkg_entry_tbl->lookup_only(_package_entry->name()) == _package_entry, "Should be same");
|
assert(pkg_entry_tbl->lookup_only(_package_entry->name()) == _package_entry, "Should be same");
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -524,7 +524,7 @@ public:
|
||||||
// packages returned by get_system_packages().
|
// packages returned by get_system_packages().
|
||||||
// For packages whose classes are loaded from the boot loader class path, the
|
// For packages whose classes are loaded from the boot loader class path, the
|
||||||
// classpath_index indicates which entry on the boot loader class path.
|
// classpath_index indicates which entry on the boot loader class path.
|
||||||
void set_classpath_index(s2 path_index, TRAPS);
|
void set_classpath_index(s2 path_index);
|
||||||
bool is_same_class_package(const Klass* class2) const;
|
bool is_same_class_package(const Klass* class2) const;
|
||||||
bool is_same_class_package(oop other_class_loader, const Symbol* other_class_name) const;
|
bool is_same_class_package(oop other_class_loader, const Symbol* other_class_name) const;
|
||||||
|
|
||||||
|
|
|
@ -3361,6 +3361,10 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
|
||||||
#if INCLUDE_CDS
|
#if INCLUDE_CDS
|
||||||
// capture the module path info from the ModuleEntryTable
|
// capture the module path info from the ModuleEntryTable
|
||||||
ClassLoader::initialize_module_path(THREAD);
|
ClassLoader::initialize_module_path(THREAD);
|
||||||
|
if (HAS_PENDING_EXCEPTION) {
|
||||||
|
java_lang_Throwable::print(PENDING_EXCEPTION, tty);
|
||||||
|
vm_exit_during_initialization("ClassLoader::initialize_module_path() failed unexpectedly");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if INCLUDE_JVMCI
|
#if INCLUDE_JVMCI
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue