8187118: Remove appending -cp path to the boot class path at AppCDS dump time

8187119: Consolidate record_shared_class_loader_type() and record_result()

Remove -cp path from the boot append list at dump time and other AppCDS cleanups.

Reviewed-by: lfoltan, iklam
This commit is contained in:
Jiangli Zhou 2017-11-19 23:30:41 -05:00
parent 768e1121de
commit 7409630577
6 changed files with 240 additions and 153 deletions

View file

@ -237,14 +237,6 @@ class ClassLoader: AllStatic {
// Last entry in linked list of appended ClassPathEntry instances
static ClassPathEntry* _last_append_entry;
// Note: _num_entries includes the java runtime image and all
// the entries on the _first_append_entry linked list.
static int _num_entries;
// number of entries in the boot class path including the
// java runtime image
static int _num_boot_entries;
// Array of module names associated with the boot class loader
CDS_ONLY(static GrowableArray<char*>* _boot_modules_array;)
@ -254,12 +246,22 @@ class ClassLoader: AllStatic {
// Info used by CDS
CDS_ONLY(static SharedPathsMiscInfo * _shared_paths_misc_info;)
CDS_ONLY(static ClassPathEntry* _app_classpath_entries;)
CDS_ONLY(static ClassPathEntry* _last_app_classpath_entry;)
CDS_ONLY(static void setup_app_search_path(const char *class_path);)
static void add_to_app_classpath_entries(const char* path,
ClassPathEntry* entry,
bool check_for_duplicates);
public:
CDS_ONLY(static ClassPathEntry* app_classpath_entries() {return _app_classpath_entries;})
protected:
// Initialization:
// - setup the boot loader's system class path
// - setup the boot loader's patch mod entries, if present
// - create the ModuleEntry for java.base
static void setup_bootstrap_search_path();
static void setup_search_path(const char *class_path, bool setting_bootstrap);
static void setup_boot_search_path(const char *class_path);
static void setup_patch_mod_entries();
static void create_javabase();
@ -395,7 +397,6 @@ class ClassLoader: AllStatic {
static ClassPathEntry* classpath_entry(int n) {
assert(n >= 0, "sanity");
assert(!has_jrt_entry() || n < _num_entries, "sanity");
if (n == 0) {
assert(has_jrt_entry(), "No class path entry at 0 for exploded module builds");
return ClassLoader::_jrt_entry;
@ -414,15 +415,46 @@ class ClassLoader: AllStatic {
}
}
static int number_of_classpath_entries() {
return _num_entries;
}
static bool is_in_patch_mod_entries(Symbol* module_name);
#if INCLUDE_CDS
// Sharing dump and restore
// Helper function used by CDS code to get the number of boot classpath
// entries during shared classpath setup time.
static int num_boot_classpath_entries() {
assert(DumpSharedSpaces, "Should only be called at CDS dump time");
assert(has_jrt_entry(), "must have a java runtime image");
int num_entries = 1; // count the runtime image
ClassPathEntry* e = ClassLoader::_first_append_entry;
while (e != NULL) {
num_entries ++;
e = e->next();
}
return num_entries;
}
static ClassPathEntry* get_next_boot_classpath_entry(ClassPathEntry* e) {
if (e == ClassLoader::_jrt_entry) {
return ClassLoader::_first_append_entry;
} else {
return e->next();
}
}
// Helper function used by CDS code to get the number of app classpath
// entries during shared classpath setup time.
static int num_app_classpath_entries() {
assert(DumpSharedSpaces, "Should only be called at CDS dump time");
int num_entries = 0;
ClassPathEntry* e= ClassLoader::_app_classpath_entries;
while (e != NULL) {
num_entries ++;
e = e->next();
}
return num_entries;
}
static void check_shared_classpath(const char *path);
static void finalize_shared_paths_misc_info();
static int get_shared_paths_misc_info_size();
@ -430,7 +462,7 @@ class ClassLoader: AllStatic {
static bool check_shared_paths_misc_info(void* info, int size);
static void exit_with_path_failure(const char* error, const char* message);
static void record_shared_class_loader_type(InstanceKlass* ik, const ClassFileStream* stream);
static void record_result(InstanceKlass* ik, const ClassFileStream* stream);
#endif
static JImageLocationRef jimage_find_resource(JImageFile* jf, const char* module_name,
const char* file_name, jlong &size);
@ -446,20 +478,15 @@ class ClassLoader: AllStatic {
static jlong class_link_count();
static jlong class_link_time_ms();
static void set_first_append_entry(ClassPathEntry* entry);
// indicates if class path already contains a entry (exact match by name)
static bool contains_append_entry(const char* name);
// adds a class path list
static void add_to_list(ClassPathEntry* new_entry);
// adds a class path to the boot append entries
static void add_to_boot_append_entries(ClassPathEntry* new_entry);
// creates a class path zip entry (returns NULL if JAR file cannot be opened)
static ClassPathZipEntry* create_class_path_zip_entry(const char *apath, bool is_boot_append);
// add a path to class path list
static void add_to_list(const char* apath);
static bool string_ends_with(const char* str, const char* str_to_find);
// obtain package name from a fully qualified class name