< prev index next >

src/hotspot/share/classfile/classLoader.cpp

Print this page

        

@@ -137,10 +137,11 @@
 GrowableArray<ModuleClassPathList*>* ClassLoader::_patch_mod_entries = NULL;
 GrowableArray<ModuleClassPathList*>* ClassLoader::_exploded_entries = NULL;
 ClassPathEntry* ClassLoader::_jrt_entry = NULL;
 ClassPathEntry* ClassLoader::_first_append_entry = NULL;
 ClassPathEntry* ClassLoader::_last_append_entry  = NULL;
+const char*     ClassLoader::_modules_image_name = MODULES_IMAGE_NAME;
 #if INCLUDE_CDS
 ClassPathEntry* ClassLoader::_app_classpath_entries = NULL;
 ClassPathEntry* ClassLoader::_last_app_classpath_entry = NULL;
 ClassPathEntry* ClassLoader::_module_path_entries = NULL;
 ClassPathEntry* ClassLoader::_last_module_path_entry = NULL;

@@ -696,10 +697,42 @@
     }
   }
   return false;
 }
 
+const char* ClassLoader::skip_directories(const char* path) {
+  assert(path != NULL, "sanity");
+
+  const char *p1 = path, *p2 = NULL;
+  const char* fileSep = os::file_separator();
+  int len = (int)strlen(fileSep);
+  if (len == 1) {
+    p2 = strrchr(path, fileSep[0]);
+    if (p2 != NULL) {
+      p1 = p2 + 1;
+    }
+  } else {
+    while ((p2 = strstr(p1, fileSep)) != NULL) {
+      p1 = p2 + len;
+    }
+  }
+  return p1;
+}
+
+// Obtain the canonical name of the MODULES_IMAGE_NAME and save it in
+// _modules_image_name.
+//
+// For most of use cases, ClassLoader::modules_image_name(), which returns the
+// canonical name should be used. When dealing with the system boot path string
+// that's set up by os::set_boot_path(), then the canonical name cannot be
+// used and MODULES_IMAGE_NAME should be used directly.
+void ClassLoader::init_modules_image_name(const char* modules_path) {
+  const char* p = skip_directories(modules_path);
+  guarantee(strlen(p) > 0, "must be a valid name");
+  _modules_image_name = os::strdup(p);
+}
+
 // Set up the _jrt_entry if present and boot append path
 void ClassLoader::setup_boot_search_path(const char *class_path) {
   int len = (int)strlen(class_path);
   int end = 0;
   bool set_base_piece = true;

@@ -734,10 +767,12 @@
         // Directory found
         ClassPathEntry* new_entry = create_class_path_entry(path, &st, false, false, CHECK);
 
         // Check for a jimage
         if (Arguments::has_jimage()) {
+          init_modules_image_name(new_entry->name());
+
           assert(_jrt_entry == NULL, "should not setup bootstrap class search path twice");
           assert(new_entry != NULL && new_entry->is_modules_image(), "No java runtime image present");
           _jrt_entry = new_entry;
           assert(_jrt_entry->jimage() != NULL, "No java runtime image");
         }

@@ -844,11 +879,11 @@
         } else {
           return NULL;
         }
       }
     }
-    log_info(class, path)("opened: %s", path);
+    log_info(class, path)("opened: %s (real path: %s)", path, canonical_path);
     log_info(class, load)("opened: %s", path);
   } else {
     // Directory
     new_entry = new ClassPathDirEntry(path);
     log_info(class, load)("path: %s", path);
< prev index next >