src/share/vm/classfile/classLoader.cpp
Index
Unified diffs
Context diffs
Sdiffs
Wdiffs
Patch
New
Old
Previous File
Next File
*** old/src/share/vm/classfile/classLoader.cpp Thu Sep 8 18:13:51 2016
--- new/src/share/vm/classfile/classLoader.cpp Thu Sep 8 18:13:51 2016
*** 317,326 ****
--- 317,336 ----
(*ZipClose)(_zip);
}
FREE_C_HEAP_ARRAY(char, _zip_name);
}
+ bool ClassPathZipEntry::stream_exists(const char* name) {
+ // enable call to C land
+ JavaThread* thread = JavaThread::current();
+ ThreadToNativeFromVM ttn(thread);
+ // check whether zip archive contains name
+ jint name_len, filesize;
+ jzentry* entry = (*FindEntry)(_zip, name, &filesize, &name_len);
+ return (entry != NULL) ? true : false;
+ }
+
u1* ClassPathZipEntry::open_entry(const char* name, jint* filesize, bool nul_terminate, TRAPS) {
// enable call to C land
JavaThread* thread = JavaThread::current();
ThreadToNativeFromVM ttn(thread);
// check whether zip archive contains name
*** 691,702 ****
--- 701,710 ----
void ClassLoader::setup_patch_mod_entries() {
Thread* THREAD = Thread::current();
GrowableArray<ModulePatchPath*>* patch_mod_args = Arguments::get_patch_mod_prefix();
int num_of_entries = patch_mod_args->length();
assert(!DumpSharedSpaces, "DumpSharedSpaces not supported with --patch-module");
assert(!UseSharedSpaces, "UseSharedSpaces not supported with --patch-module");
// Set up the boot loader's _patch_mod_entries list
_patch_mod_entries = new (ResourceObj::C_HEAP, mtModule) GrowableArray<ModuleClassPathList*>(num_of_entries, true);
for (int i = 0; i < num_of_entries; i++) {
*** 1393,1402 ****
--- 1401,1467 ----
}
return NULL;
}
+ #if INCLUDE_CDS
+ // The following function is only used during CDS dump time.
+ // It checks if a class can be found in the jar entries of the _patch_mod_entries.
+ // It does not support non-jar entries.
+ bool ClassLoader::is_in_patch_module(const char* const file_name) {
+ assert(DumpSharedSpaces, "dump time only");
+ if (_patch_mod_entries == NULL) {
+ return false;
+ }
+
+ bool found;
+ int num_of_entries = _patch_mod_entries->length();
+ char* class_module_name = NULL;
+ ResourceMark rm;
+ const char *pkg_name = package_from_name(file_name);
+ // Using the jimage to obtain the class' module name.
+ // The ModuleEntryTable cannot be used at this point during dump time
+ // because the module system hasn't been initialized yet.
+ if (pkg_name != NULL) {
+ JImageFile *jimage = _jrt_entry->jimage();
+ class_module_name = (char*)(*JImagePackageToModule)(jimage, pkg_name);
+ }
+
+ if (class_module_name == NULL) {
+ return false;
+ }
+
+ // Loop through all the patch module entries looking for module
+ for (int i = 0; i < num_of_entries; i++) {
+ ModuleClassPathList* module_cpl = _patch_mod_entries->at(i);
+ Symbol* module_cpl_name = module_cpl->module_name();
+
+ if (strcmp(module_cpl_name->as_C_string(), class_module_name) == 0) {
+ // Class' module has been located, attempt to locate
+ // the class from the module's ClassPathEntry list.
+ ClassPathEntry* e = module_cpl->module_first_entry();
+ while (e != NULL) {
+ if (e->is_jar_file()) {
+ found = e->stream_exists(file_name);
+ if (found) {
+ return true;
+ } else {
+ e = e->next();
+ }
+ } else {
+ if (DumpSharedSpaces) {
+ vm_exit_during_initialization("Only jar file in --patch-module is supported for CDS dumping ", e->name());
+ }
+ }
+ }
+ }
+ }
+
+ return false;
+ }
+ #endif // INCLUDE_CDS
+
instanceKlassHandle ClassLoader::load_class(Symbol* name, bool search_append_only, TRAPS) {
assert(name != NULL, "invariant");
assert(THREAD->is_Java_thread(), "must be a JavaThread");
ResourceMark rm(THREAD);
*** 1418,1429 ****
--- 1483,1494 ----
s2 classpath_index = 0;
ClassPathEntry* e = NULL;
// If DumpSharedSpaces is true boot loader visibility boundaries are set to:
// - [jimage] + [_first_append_entry to _last_append_entry] (all path entries).
// No --patch-module entries or exploded module builds are included since CDS
! // is not supported if --patch-module or exploded module builds are used.
+ // If a class is found in the --patch-module entries, the class will not be included in the
! // CDS archive. Also, CDS is not supported if exploeded module builds are used.
//
// If search_append_only is true, boot loader visibility boundaries are
// set to be _first_append_entry to the end. This includes:
// [-Xbootclasspath/a]; [jvmti appended entries]
//
*** 1434,1453 ****
--- 1499,1530 ----
//
// DumpSharedSpaces and search_append_only are mutually exclusive and cannot
// be true at the same time.
assert(!(DumpSharedSpaces && search_append_only), "DumpSharedSpaces and search_append_only are both true");
+ bool found_patch_mod_entry = false;
// Load Attempt #1: --patch-module
// Determine the class' defining module. If it appears in the _patch_mod_entries,
// attempt to load the class from those locations specific to the module.
// Specifications to --patch-module can contain a partial number of classes
// that are part of the overall module definition. So if a particular class is not
// found within its module specification, the search should continue to Load Attempt #2.
// Note: The --patch-module entries are never searched if the boot loader's
// visibility boundary is limited to only searching the append entries.
- if (_patch_mod_entries != NULL && !search_append_only && !DumpSharedSpaces) {
+ if (!DumpSharedSpaces) {
stream = search_module_entries(_patch_mod_entries, class_name, file_name, CHECK_NULL);
+ } else {
+ #if INCLUDE_CDS
+ found_patch_mod_entry = is_in_patch_module(file_name);
+ #endif
+ }
+ }
+
+ if (DumpSharedSpaces && found_patch_mod_entry) {
+ tty->print_cr("Preload Warning: Skip archiving class %s found in --patch-module entry", class_name);
+ return NULL;
}
// Load Attempt #2: [jimage | exploded build]
if (!search_append_only && (NULL == stream)) {
if (has_jrt_entry()) {
src/share/vm/classfile/classLoader.cpp
Index
Unified diffs
Context diffs
Sdiffs
Wdiffs
Patch
New
Old
Previous File
Next File