--- old/src/hotspot/share/classfile/classLoader.hpp 2019-03-13 08:49:07.823253459 -0700 +++ new/src/hotspot/share/classfile/classLoader.hpp 2019-03-13 08:49:07.523249772 -0700 @@ -26,6 +26,7 @@ #define SHARE_CLASSFILE_CLASSLOADER_HPP #include "jimage.hpp" +#include "runtime/arguments.hpp" #include "runtime/handles.hpp" #include "runtime/perfData.hpp" #include "utilities/exceptions.hpp" @@ -34,7 +35,12 @@ // The VM class loader. #include -// Name of boot "modules" image +// Name of boot "modules" image. This macro may be used with caution. +// +// For most of use cases, ClassLoader::modules_image_identity(), which gives the +// canonical path 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. #define MODULES_IMAGE_NAME "modules" // Class path entry (directory or zip file) @@ -217,6 +223,9 @@ // Last entry in linked list of appended ClassPathEntry instances static ClassPathEntry* _last_append_entry; + // The modules image identity obtained from the canonical path. + static const char* _modules_image_identity; + // Info used by CDS CDS_ONLY(static SharedPathsMiscInfo * _shared_paths_misc_info;) @@ -439,7 +448,14 @@ // distinguish from a class_name with no package name, as both cases have a NULL return value static const char* package_from_name(const char* const class_name, bool* bad_class_name = NULL); - static bool is_modules_image(const char* name) { return string_ends_with(name, MODULES_IMAGE_NAME); } + static const char* modules_image_identity() { return _modules_image_identity; } + static bool is_modules_image(const char* name) { + if (Arguments::has_jimage()) { + assert(modules_image_identity() != NULL, "must be set"); + return strcmp(name, modules_image_identity()) == 0; + } + return false; + } // Debugging static void verify() PRODUCT_RETURN;