diff --git a/make/CompileJavaModules.gmk b/make/CompileJavaModules.gmk index 3ec32971ed8..2667524df88 100644 --- a/make/CompileJavaModules.gmk +++ b/make/CompileJavaModules.gmk @@ -99,13 +99,16 @@ endif ################################################################################ # Setup the main compilation + +COMPILATION_OUTPUTDIR := $(if $($(MODULE)_BIN), $($(MODULE)_BIN), $(JDK_OUTPUTDIR)/modules) + $(eval $(call SetupJavaCompilation, $(MODULE), \ SMALL_JAVA := false, \ MODULE := $(MODULE), \ SRC := $(wildcard $(MODULE_SRC_DIRS)), \ INCLUDES := $(JDK_USER_DEFINED_FILTER), \ FAIL_NO_SRC := $(FAIL_NO_SRC), \ - BIN := $(if $($(MODULE)_BIN), $($(MODULE)_BIN), $(JDK_OUTPUTDIR)/modules), \ + BIN := $(COMPILATION_OUTPUTDIR), \ HEADERS := $(SUPPORT_OUTPUTDIR)/headers, \ CREATE_API_DIGEST := true, \ CLEAN := $(CLEAN), \ @@ -137,6 +140,15 @@ ifneq ($(COMPILER), bootjdk) MODULE_VALUECLASS_SRC_DIRS := $(call FindModuleValueClassSrcDirs, $(MODULE)) MODULE_VALUECLASS_SOURCEPATH := $(call GetModuleValueClassSrcPath) + # Temporarily compile valueclasses into a separate directory with the form: + # // + # and then copy the class files into: + # //META-INF/preview/ + # We cannot compile directly into the desired directory because it's the + # compiler which creates the original '//...' hierarchy. + VALUECLASS_OUTPUTDIR := $(SUPPORT_OUTPUTDIR)/$(VALUECLASSES_STR) + PREVIEW_OUTPUTDIR := $(COMPILATION_OUTPUTDIR)/$(MODULE)/META-INF/preview + ifneq ($(MODULE_VALUECLASS_SRC_DIRS),) $(eval $(call SetupJavaCompilation, $(MODULE)-$(VALUECLASSES_STR), \ SMALL_JAVA := false, \ @@ -144,7 +156,7 @@ ifneq ($(COMPILER), bootjdk) SRC := $(wildcard $(MODULE_VALUECLASS_SRC_DIRS)), \ INCLUDES := $(JDK_USER_DEFINED_FILTER), \ FAIL_NO_SRC := $(FAIL_NO_SRC), \ - BIN := $(SUPPORT_OUTPUTDIR)/$(VALUECLASSES_STR)/, \ + BIN := $(VALUECLASS_OUTPUTDIR)/, \ JAR := $(JDK_OUTPUTDIR)/lib/$(VALUECLASSES_STR)/$(MODULE)-$(VALUECLASSES_STR).jar, \ HEADERS := $(SUPPORT_OUTPUTDIR)/headers, \ DISABLED_WARNINGS := $(DISABLED_WARNINGS_java) preview, \ @@ -162,6 +174,14 @@ ifneq ($(COMPILER), bootjdk) TARGETS += $($(MODULE)-$(VALUECLASSES_STR)) + # Restructure the class file hierarchy from //... to /META-INF/preview//... + $(PREVIEW_OUTPUTDIR)/_copy_valueclasses.marker: $($(MODULE)-$(VALUECLASSES_STR)) + $(call MakeTargetDir) + $(CP) -R $(VALUECLASS_OUTPUTDIR)/$(MODULE)/. $(@D)/ + $(TOUCH) $@ + + TARGETS += $(PREVIEW_OUTPUTDIR)/_copy_valueclasses.marker + $(eval $(call SetupCopyFiles, $(MODULE)-copy-valueclass-jar, \ FILES := $(JDK_OUTPUTDIR)/lib/$(VALUECLASSES_STR)/$(MODULE)-$(VALUECLASSES_STR).jar, \ DEST := $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE)/$(VALUECLASSES_STR), \ diff --git a/src/hotspot/share/classfile/classLoader.cpp b/src/hotspot/share/classfile/classLoader.cpp index b38450358cd..2872b492631 100644 --- a/src/hotspot/share/classfile/classLoader.cpp +++ b/src/hotspot/share/classfile/classLoader.cpp @@ -96,9 +96,18 @@ static JImageClose_t JImageClose = nullptr; static JImageFindResource_t JImageFindResource = nullptr; static JImageGetResource_t JImageGetResource = nullptr; -// JimageFile pointer, or null if exploded JDK build. +// JImageFile pointer, or null if exploded JDK build. static JImageFile* JImage_file = nullptr; +// JImageMode status to control preview behaviour. JImage_file is unusable +// for normal lookup until (JImage_mode != JIMAGE_MODE_UNINITIALIZED). +enum JImageMode { + JIMAGE_MODE_UNINITIALIZED = 0, + JIMAGE_MODE_DEFAULT = 1, + JIMAGE_MODE_ENABLE_PREVIEW = 2 +}; +static JImageMode JImage_mode = JIMAGE_MODE_UNINITIALIZED; + // Globals PerfCounter* ClassLoader::_perf_accumulated_time = nullptr; @@ -153,7 +162,7 @@ void ClassLoader::print_counters(outputStream *st) { GrowableArray* ClassLoader::_patch_mod_entries = nullptr; GrowableArray* ClassLoader::_exploded_entries = nullptr; -ClassPathEntry* ClassLoader::_jrt_entry = nullptr; +ClassPathImageEntry* ClassLoader::_jrt_entry = nullptr; ClassPathEntry* volatile ClassLoader::_first_append_entry_list = nullptr; ClassPathEntry* volatile ClassLoader::_last_append_entry = nullptr; @@ -170,15 +179,6 @@ static bool string_starts_with(const char* str, const char* str_to_find) { } #endif -static const char* get_jimage_version_string() { - static char version_string[10] = ""; - if (version_string[0] == '\0') { - jio_snprintf(version_string, sizeof(version_string), "%d.%d", - VM_Version::vm_major_version(), VM_Version::vm_minor_version()); - } - return (const char*)version_string; -} - bool ClassLoader::string_ends_with(const char* str, const char* str_to_find) { size_t str_len = strlen(str); size_t str_to_find_len = strlen(str_to_find); @@ -233,6 +233,73 @@ Symbol* ClassLoader::package_from_class_name(const Symbol* name, bool* bad_class return SymbolTable::new_symbol(name, pointer_delta_as_int(start, base), pointer_delta_as_int(end, base)); } +// -------------------------------- +// The following jimage_xxx static functions encapsulate all JImage_file and JImage_mode access. +// This is done to make it easy to reason about the JImage file state (exists vs initialized etc.). + +// Opens the named JImage file and sets the JImage file reference. +// Returns true if opening the JImage file was successful (see also jimage_exists()). +static bool jimage_open(const char* modules_path) { + // Currently 'error' is not set to anything useful, so ignore it here. + jint error; + JImage_file = (*JImageOpen)(modules_path, &error); + return JImage_file != nullptr; +} + +// Closes and clears the JImage file reference (this will only be called during shutdown). +static void jimage_close() { + if (JImage_file != nullptr) { + (*JImageClose)(JImage_file); + JImage_file = nullptr; + } +} + +// Returns whether a JImage file was opened (but NOT whether it was initialized yet). +static bool jimage_exists() { + return JImage_file != nullptr; +} + +// Returns the JImage file reference (which may or may not be initialized). +static JImageFile* jimage_non_null() { + assert(jimage_exists(), "should have been opened by ClassLoader::lookup_vm_options " + "and remained throughout normal JVM lifetime"); + return JImage_file; +} + +// Called once to set the access mode for resource (i.e. preview or non-preview) before +// general resource lookup can occur. +static void jimage_init(bool enable_preview) { + assert(JImage_mode == JIMAGE_MODE_UNINITIALIZED, "jimage_init must not be called twice"); + JImage_mode = enable_preview ? JIMAGE_MODE_ENABLE_PREVIEW : JIMAGE_MODE_DEFAULT; +} + +// Returns true if jimage_init() has been called. Once the JImage file is initialized, +// jimage_is_preview_enabled() can be called to correctly determine the access mode. +static bool jimage_is_initialized() { + return jimage_exists() && JImage_mode != JIMAGE_MODE_UNINITIALIZED; +} + +// Returns the access mode for an initialized JImage file (reflects --enable-preview). +static bool jimage_is_preview_enabled() { + assert(jimage_is_initialized(), "jimage is not initialized"); + return JImage_mode == JIMAGE_MODE_ENABLE_PREVIEW; +} + +// Looks up the location of a named JImage resource. This "raw" lookup function allows +// the preview mode to be manually specified, so must not be accessible outside this +// class. ClassPathImageEntry manages all calls for resources after startup is complete. +static JImageLocationRef jimage_find_resource(const char* module_name, + const char* file_name, + bool is_preview, + jlong *size) { + return ((*JImageFindResource)(jimage_non_null(), + module_name, + file_name, + is_preview, + size)); +} +// -------------------------------- + // Given a fully qualified package name, find its defining package in the class loader's // package entry table. PackageEntry* ClassLoader::get_package_entry(Symbol* pkg_name, ClassLoaderData* loader_data) { @@ -371,28 +438,15 @@ ClassFileStream* ClassPathZipEntry::open_stream(JavaThread* current, const char* DEBUG_ONLY(ClassPathImageEntry* ClassPathImageEntry::_singleton = nullptr;) -JImageFile* ClassPathImageEntry::jimage() const { - return JImage_file; -} - -JImageFile* ClassPathImageEntry::jimage_non_null() const { - assert(ClassLoader::has_jrt_entry(), "must be"); - assert(jimage() != nullptr, "should have been opened by ClassLoader::lookup_vm_options " - "and remained throughout normal JVM lifetime"); - return jimage(); -} - void ClassPathImageEntry::close_jimage() { - if (jimage() != nullptr) { - (*JImageClose)(jimage()); - JImage_file = nullptr; - } + jimage_close(); } -ClassPathImageEntry::ClassPathImageEntry(JImageFile* jimage, const char* name) : +ClassPathImageEntry::ClassPathImageEntry(const char* name) : ClassPathEntry() { - guarantee(jimage != nullptr, "jimage file is null"); + guarantee(jimage_is_initialized(), "jimage is not initialized"); guarantee(name != nullptr, "jimage file name is null"); + assert(_singleton == nullptr, "VM supports only one jimage"); DEBUG_ONLY(_singleton = this); size_t len = strlen(name) + 1; @@ -411,8 +465,10 @@ ClassFileStream* ClassPathImageEntry::open_stream(JavaThread* current, const cha // 2. A package is in at most one module in the jimage file. // ClassFileStream* ClassPathImageEntry::open_stream_for_loader(JavaThread* current, const char* name, ClassLoaderData* loader_data) { + bool is_preview = jimage_is_preview_enabled(); + jlong size; - JImageLocationRef location = (*JImageFindResource)(jimage_non_null(), "", get_jimage_version_string(), name, &size); + JImageLocationRef location = jimage_find_resource("", name, is_preview, &size); if (location == 0) { TempNewSymbol class_name = SymbolTable::new_symbol(name); @@ -420,7 +476,7 @@ ClassFileStream* ClassPathImageEntry::open_stream_for_loader(JavaThread* current if (pkg_name != nullptr) { if (!Universe::is_module_initialized()) { - location = (*JImageFindResource)(jimage_non_null(), JAVA_BASE_NAME, get_jimage_version_string(), name, &size); + location = jimage_find_resource(JAVA_BASE_NAME, name, is_preview, &size); } else { PackageEntry* package_entry = ClassLoader::get_package_entry(pkg_name, loader_data); if (package_entry != nullptr) { @@ -431,7 +487,7 @@ ClassFileStream* ClassPathImageEntry::open_stream_for_loader(JavaThread* current assert(module->is_named(), "Boot classLoader package is in unnamed module"); const char* module_name = module->name()->as_C_string(); if (module_name != nullptr) { - location = (*JImageFindResource)(jimage_non_null(), module_name, get_jimage_version_string(), name, &size); + location = jimage_find_resource(module_name, name, is_preview, &size); } } } @@ -444,7 +500,7 @@ ClassFileStream* ClassPathImageEntry::open_stream_for_loader(JavaThread* current char* data = NEW_RESOURCE_ARRAY(char, size); (*JImageGetResource)(jimage_non_null(), location, data, size); // Resource allocated - assert(this == (ClassPathImageEntry*)ClassLoader::get_jrt_entry(), "must be"); + assert(this == ClassLoader::get_jrt_entry(), "must be"); return new ClassFileStream((u1*)data, checked_cast(size), _name, @@ -454,16 +510,9 @@ ClassFileStream* ClassPathImageEntry::open_stream_for_loader(JavaThread* current return nullptr; } -JImageLocationRef ClassLoader::jimage_find_resource(JImageFile* jf, - const char* module_name, - const char* file_name, - jlong &size) { - return ((*JImageFindResource)(jf, module_name, get_jimage_version_string(), file_name, &size)); -} - bool ClassPathImageEntry::is_modules_image() const { assert(this == _singleton, "VM supports a single jimage"); - assert(this == (ClassPathImageEntry*)ClassLoader::get_jrt_entry(), "must be used for jrt entry"); + assert(this == ClassLoader::get_jrt_entry(), "must be used for jrt entry"); return true; } @@ -618,14 +667,15 @@ void ClassLoader::setup_bootstrap_search_path_impl(JavaThread* current, const ch struct stat st; if (os::stat(path, &st) == 0) { // Directory found - if (JImage_file != nullptr) { + if (jimage_exists()) { assert(Arguments::has_jimage(), "sanity check"); const char* canonical_path = get_canonical_path(path, current); assert(canonical_path != nullptr, "canonical_path issue"); - _jrt_entry = new ClassPathImageEntry(JImage_file, canonical_path); + // Hand over lifecycle control of the JImage file to the _jrt_entry singleton + // (see ClassPathImageEntry::close_jimage). The image must be initialized by now. + _jrt_entry = new ClassPathImageEntry(canonical_path); assert(_jrt_entry != nullptr && _jrt_entry->is_modules_image(), "No java runtime image present"); - assert(_jrt_entry->jimage() != nullptr, "No java runtime image"); } // else it's an exploded build. } else { // If path does not exist, exit @@ -1439,20 +1489,8 @@ void ClassLoader::initialize(TRAPS) { setup_bootstrap_search_path(THREAD); } -static char* lookup_vm_resource(JImageFile *jimage, const char *jimage_version, const char *path) { - jlong size; - JImageLocationRef location = (*JImageFindResource)(jimage, "java.base", jimage_version, path, &size); - if (location == 0) - return nullptr; - char *val = NEW_C_HEAP_ARRAY(char, size+1, mtClass); - (*JImageGetResource)(jimage, location, val, size); - val[size] = '\0'; - return val; -} - // Lookup VM options embedded in the modules jimage file char* ClassLoader::lookup_vm_options() { - jint error; char modules_path[JVM_MAXPATHLEN]; const char* fileSep = os::file_separator(); @@ -1460,28 +1498,42 @@ char* ClassLoader::lookup_vm_options() { load_jimage_library(); jio_snprintf(modules_path, JVM_MAXPATHLEN, "%s%slib%smodules", Arguments::get_java_home(), fileSep, fileSep); - JImage_file =(*JImageOpen)(modules_path, &error); - if (JImage_file == nullptr) { - return nullptr; + if (jimage_open(modules_path)) { + // Special case where we lookup the options string *before* calling jimage_init(). + // Since VM arguments have not been parsed, and the ClassPathImageEntry singleton + // has not been created yet, we access the JImage file directly in non-preview mode. + jlong size; + JImageLocationRef location = + jimage_find_resource(JAVA_BASE_NAME, "jdk/internal/vm/options", /* is_preview */ false, &size); + if (location != 0) { + char *options = NEW_C_HEAP_ARRAY(char, size+1, mtClass); + (*JImageGetResource)(jimage_non_null(), location, options, size); + options[size] = '\0'; + return options; + } } + return nullptr; +} - const char *jimage_version = get_jimage_version_string(); - char *options = lookup_vm_resource(JImage_file, jimage_version, "jdk/internal/vm/options"); - return options; +// Finishes initializing the JImageFile (if present) by setting the access mode. +void ClassLoader::init_jimage(bool enable_preview) { + if (jimage_exists()) { + jimage_init(enable_preview); + } } bool ClassLoader::is_module_observable(const char* module_name) { assert(JImageOpen != nullptr, "jimage library should have been opened"); - if (JImage_file == nullptr) { + if (!jimage_exists()) { struct stat st; const char *path = get_exploded_module_path(module_name, true); bool res = os::stat(path, &st) == 0; FREE_C_HEAP_ARRAY(char, path); return res; } + // We don't expect preview mode (i.e. --enable-preview) to affect module visibility. jlong size; - const char *jimage_version = get_jimage_version_string(); - return (*JImageFindResource)(JImage_file, module_name, jimage_version, "module-info.class", &size) != 0; + return jimage_find_resource(module_name, "module-info.class", /* is_preview */ false, &size) != 0; } jlong ClassLoader::classloader_time_ms() { diff --git a/src/hotspot/share/classfile/classLoader.hpp b/src/hotspot/share/classfile/classLoader.hpp index a946f1f4e25..574dd3ccd07 100644 --- a/src/hotspot/share/classfile/classLoader.hpp +++ b/src/hotspot/share/classfile/classLoader.hpp @@ -99,7 +99,8 @@ class ClassPathZipEntry: public ClassPathEntry { }; -// For java image files +// A singleton path entry which takes ownership of the initialized JImageFile +// reference. Not used for exploded builds. class ClassPathImageEntry: public ClassPathEntry { private: const char* _name; @@ -107,11 +108,12 @@ class ClassPathImageEntry: public ClassPathEntry { public: bool is_modules_image() const; const char* name() const { return _name == nullptr ? "" : _name; } - JImageFile* jimage() const; - JImageFile* jimage_non_null() const; + // Called to close the JImage during os::abort (normally not called). void close_jimage(); - ClassPathImageEntry(JImageFile* jimage, const char* name); + // Takes effective ownership of the static JImageFile pointer. + ClassPathImageEntry(const char* name); virtual ~ClassPathImageEntry() { ShouldNotReachHere(); } + ClassFileStream* open_stream(JavaThread* current, const char* name); ClassFileStream* open_stream_for_loader(JavaThread* current, const char* name, ClassLoaderData* loader_data); }; @@ -200,10 +202,10 @@ class ClassLoader: AllStatic { static GrowableArray* _patch_mod_entries; // 2. the base piece - // Contains the ClassPathEntry of the modular java runtime image. + // Contains the ClassPathImageEntry of the modular java runtime image. // If no java runtime image is present, this indicates a // build with exploded modules is being used instead. - static ClassPathEntry* _jrt_entry; + static ClassPathImageEntry* _jrt_entry; static GrowableArray* _exploded_entries; enum { EXPLODED_ENTRY_SIZE = 80 }; // Initial number of exploded modules @@ -350,15 +352,20 @@ class ClassLoader: AllStatic { static void append_boot_classpath(ClassPathEntry* new_entry); #endif + // Retrieves additional VM options prior to flags processing. Options held + // in the JImage file are retrieved without fully initializing it. (this is + // the only JImage lookup which can succeed before init_jimage() is called). static char* lookup_vm_options(); + // Called once, after all flags are processed, to finish initializing the + // JImage file. Until this is called, jimage_find_resource(), and any other + // JImage resource lookups or access will fail. + static void init_jimage(bool enable_preview); + // Determines if the named module is present in the // modules jimage file or in the exploded modules directory. static bool is_module_observable(const char* module_name); - static JImageLocationRef jimage_find_resource(JImageFile* jf, const char* module_name, - const char* file_name, jlong &size); - static void trace_class_path(const char* msg, const char* name = nullptr); // VM monitoring and management support diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp index d311e172bcc..adb561ef41b 100644 --- a/src/hotspot/share/runtime/arguments.cpp +++ b/src/hotspot/share/runtime/arguments.cpp @@ -2079,6 +2079,18 @@ int Arguments::process_patch_mod_option(const char* patch_mod_tail) { return JNI_OK; } +// Temporary system property to disable preview patching and enable the new preview mode +// feature for testing/development. Once the preview mode feature is finished, the value +// will be always 'true' and this code, and all related dead-code can be removed. +#define DISABLE_PREVIEW_PATCHING_DEFAULT false + +bool Arguments::disable_preview_patching() { + const char* prop = get_property("DISABLE_PREVIEW_PATCHING"); + return (prop != nullptr) + ? strncmp(prop, "true", strlen("true")) == 0 + : DISABLE_PREVIEW_PATCHING_DEFAULT; +} + // VALUECLASS_STR must match string used in the build #define VALUECLASS_STR "valueclasses" #define VALUECLASS_JAR "-" VALUECLASS_STR ".jar" @@ -2086,11 +2098,17 @@ int Arguments::process_patch_mod_option(const char* patch_mod_tail) { // Finalize --patch-module args and --enable-preview related to value class module patches. // Create all numbered properties passing module patches. int Arguments::finalize_patch_module() { - // If --enable-preview and EnableValhalla is true, each module may have value classes that - // are to be patched into the module. + // If --enable-preview and EnableValhalla is true, modules may have preview mode resources. + bool enable_valhalla_preview = enable_preview() && EnableValhalla; + // Whether to use module patching, or the new preview mode feature for preview resources. + bool disable_patching = disable_preview_patching(); + + // This must be called, even with 'false', to enable resource lookup from JImage. + ClassLoader::init_jimage(disable_patching && enable_valhalla_preview); + // For each -valueclasses.jar in /lib/valueclasses/ // appends the equivalent of --patch-module =/lib/valueclasses/-valueclasses.jar - if (enable_preview() && EnableValhalla) { + if (!disable_patching && enable_valhalla_preview) { char * valueclasses_dir = AllocateHeap(JVM_MAXPATHLEN, mtArguments); const char * fileSep = os::file_separator(); @@ -2123,7 +2141,7 @@ int Arguments::finalize_patch_module() { } // Create numbered properties for each module that has been patched either - // by --patch-module or --enable-preview + // by --patch-module (or --enable-preview if disable_patching is false). // Format is "jdk.module.patch.==" if (_patch_mod_prefix != nullptr) { char * prop_value = AllocateHeap(JVM_MAXPATHLEN + JVM_MAXPATHLEN + 1, mtArguments); diff --git a/src/hotspot/share/runtime/arguments.hpp b/src/hotspot/share/runtime/arguments.hpp index bc2de98a638..f5a1a102fcf 100644 --- a/src/hotspot/share/runtime/arguments.hpp +++ b/src/hotspot/share/runtime/arguments.hpp @@ -486,6 +486,8 @@ class Arguments : AllStatic { // Set up the underlying pieces of the boot class path static void add_patch_mod_prefix(const char *module_name, const char *path, bool allow_append, bool allow_cds); static int finalize_patch_module(); + static bool disable_preview_patching(); + static void set_boot_class_path(const char *value, bool has_jimage) { // During start up, set by os::set_boot_path() assert(get_boot_class_path() == nullptr, "Boot class path previously set"); diff --git a/src/java.base/share/classes/jdk/internal/jimage/ImageHeader.java b/src/java.base/share/classes/jdk/internal/jimage/ImageHeader.java index f63665119e2..49c914465ed 100644 --- a/src/java.base/share/classes/jdk/internal/jimage/ImageHeader.java +++ b/src/java.base/share/classes/jdk/internal/jimage/ImageHeader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,6 +30,23 @@ import java.util.Objects; /** + * Defines the header and version information for jimage files. + * + *

Version number changes must be synced in a single change across all code + * which reads/writes jimage files, and code which tries to open a jimage file + * with an unexpected version should fail. + * + *

Known jimage file code which needs updating on version change: + *

    + *
  • src/java.base/share/native/libjimage/imageFile.hpp + *
+ * + *

Version history: + *

    + *
  • {@code 1.0}: Original version. + *
  • {@code 1.1}: Change package entry flags to support preview mode. + *
+ * * @implNote This class needs to maintain JDK 8 source compatibility. * * It is used internally in the JDK to implement jimage/jrtfs access, @@ -39,7 +56,7 @@ public final class ImageHeader { public static final int MAGIC = 0xCAFEDADA; public static final int MAJOR_VERSION = 1; - public static final int MINOR_VERSION = 0; + public static final int MINOR_VERSION = 1; private static final int HEADER_SLOTS = 7; private final int magic; diff --git a/src/java.base/share/classes/jdk/internal/jimage/ImageLocation.java b/src/java.base/share/classes/jdk/internal/jimage/ImageLocation.java index f31c7291927..42f532c6ae2 100644 --- a/src/java.base/share/classes/jdk/internal/jimage/ImageLocation.java +++ b/src/java.base/share/classes/jdk/internal/jimage/ImageLocation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,7 @@ import java.nio.ByteBuffer; import java.util.Objects; +import java.util.function.Predicate; /** * @implNote This class needs to maintain JDK 8 source compatibility. @@ -44,7 +45,82 @@ public class ImageLocation { public static final int ATTRIBUTE_OFFSET = 5; public static final int ATTRIBUTE_COMPRESSED = 6; public static final int ATTRIBUTE_UNCOMPRESSED = 7; - public static final int ATTRIBUTE_COUNT = 8; + public static final int ATTRIBUTE_PREVIEW_FLAGS = 8; + public static final int ATTRIBUTE_COUNT = 9; + + // Flag masks for the ATTRIBUTE_PREVIEW_FLAGS attribute. Defined so + // that zero is the overwhelmingly common case for normal resources. + + /** + * Set on a "normal" (non-preview) location if a preview version + * of it exists in the same module (can apply to both resources + * and directories in the {@code /modules/xxx/...} namespace). + */ + public static final int FLAGS_HAS_PREVIEW_VERSION = 0x1; + /** + * Set on all preview locations in the {@code /modules/xxx/...} namespace. + */ + public static final int FLAGS_IS_PREVIEW_VERSION = 0x2; + /** + * Set on a preview location if no normal (non-preview) version + * of it exists in the same module (can apply to both resources + * and directories in the {@code /modules/xxx/...} namespace). + */ + public static final int FLAGS_IS_PREVIEW_ONLY = 0x4; + /** + * This flag identifies the unique {@code "/packages"} location, and + * is used to determine the {@link LocationType} without additional + * string comparison. + */ + public static final int FLAGS_IS_PACKAGE_ROOT = 0x8; + + // Also used in ImageReader. + static final String MODULES_PREFIX = "/modules"; + static final String PACKAGES_PREFIX = "/packages"; + static final String PREVIEW_INFIX = "/META-INF/preview"; + + /** + * Helper function to calculate preview flags (ATTRIBUTE_PREVIEW_FLAGS). + * + *

Since preview flags are calculated separately for resource nodes and + * directory nodes (in two quite different places) it's useful to have a + * common helper. + * + * @param name the jimage name of the resource or directory. + * @param hasEntry a predicate for jimage names returning whether an entry + * is present. + * @return flags for the ATTRIBUTE_PREVIEW_FLAGS attribute. + */ + public static int getFlags(String name, Predicate hasEntry) { + if (name.startsWith(PACKAGES_PREFIX + "/")) { + throw new IllegalArgumentException("Package sub-directory flags handled separately: " + name); + } + String start = name.startsWith(MODULES_PREFIX + "/") ? MODULES_PREFIX + "/" : "/"; + int idx = name.indexOf('/', start.length()); + if (idx == -1) { + // Special case for "/packages" root, but otherwise, no flags. + return name.equals(PACKAGES_PREFIX) ? FLAGS_IS_PACKAGE_ROOT : 0; + } + String prefix = name.substring(0, idx); + String suffix = name.substring(idx); + if (suffix.startsWith(PREVIEW_INFIX + "/")) { + // Preview resources/directories. + String nonPreviewName = prefix + suffix.substring(PREVIEW_INFIX.length()); + return FLAGS_IS_PREVIEW_VERSION + | (hasEntry.test(nonPreviewName) ? 0 : FLAGS_IS_PREVIEW_ONLY); + } else if (!suffix.startsWith("/META-INF/")) { + // Non-preview resources/directories. + String previewName = prefix + PREVIEW_INFIX + suffix; + return hasEntry.test(previewName) ? FLAGS_HAS_PREVIEW_VERSION : 0; + } else { + // Edge case for things META-INF/module-info.class etc. + return 0; + } + } + + public enum LocationType { + RESOURCE, MODULES_ROOT, MODULES_DIR, PACKAGES_ROOT, PACKAGES_DIR; + } protected final long[] attributes; @@ -285,6 +361,10 @@ public int getExtensionOffset() { return (int)getAttribute(ATTRIBUTE_EXTENSION); } + public int getFlags() { + return (int) getAttribute(ATTRIBUTE_PREVIEW_FLAGS); + } + public String getFullName() { return getFullName(false); } @@ -294,7 +374,7 @@ public String getFullName(boolean modulesPrefix) { if (getModuleOffset() != 0) { if (modulesPrefix) { - builder.append("/modules"); + builder.append(MODULES_PREFIX); } builder.append('/'); @@ -317,36 +397,6 @@ public String getFullName(boolean modulesPrefix) { return builder.toString(); } - String buildName(boolean includeModule, boolean includeParent, - boolean includeName) { - StringBuilder builder = new StringBuilder(); - - if (includeModule && getModuleOffset() != 0) { - builder.append("/modules/"); - builder.append(getModule()); - } - - if (includeParent && getParentOffset() != 0) { - builder.append('/'); - builder.append(getParent()); - } - - if (includeName) { - if (includeModule || includeParent) { - builder.append('/'); - } - - builder.append(getBase()); - - if (getExtensionOffset() != 0) { - builder.append('.'); - builder.append(getExtension()); - } - } - - return builder.toString(); - } - public long getContentOffset() { return getAttribute(ATTRIBUTE_OFFSET); } @@ -359,6 +409,42 @@ public long getUncompressedSize() { return getAttribute(ATTRIBUTE_UNCOMPRESSED); } + // Fast (zero allocation) type determination for locations. + public LocationType getType() { + switch (getModuleOffset()) { + case ImageStrings.MODULES_STRING_OFFSET: + // Locations in /modules/... namespace are directory entries. + return LocationType.MODULES_DIR; + case ImageStrings.PACKAGES_STRING_OFFSET: + // Locations in /packages/... namespace are always 2-level + // "/packages/xxx" directories. + return LocationType.PACKAGES_DIR; + case ImageStrings.EMPTY_STRING_OFFSET: + // Only 2 choices, either the "/modules" or "/packages" root. + assert isRootDir() : "Invalid root directory: " + getFullName(); + return (getFlags() & FLAGS_IS_PACKAGE_ROOT) != 0 + ? LocationType.PACKAGES_ROOT + : LocationType.MODULES_ROOT; + default: + // Anything else is // and references a resource. + return LocationType.RESOURCE; + } + } + + private boolean isRootDir() { + if (getModuleOffset() == 0 && getParentOffset() == 0) { + String name = getFullName(); + return name.equals(MODULES_PREFIX) || name.equals(PACKAGES_PREFIX); + } + return false; + } + + @Override + public String toString() { + // Cannot use String.format() (too early in startup for locale code). + return "ImageLocation[name='" + getFullName() + "', type=" + getType() + ", flags=" + getFlags() + "]"; + } + static ImageLocation readFrom(BasicImageReader reader, int offset) { Objects.requireNonNull(reader); long[] attributes = reader.getAttributes(offset); diff --git a/src/java.base/share/classes/jdk/internal/jimage/ImageReader.java b/src/java.base/share/classes/jdk/internal/jimage/ImageReader.java index e062e1629ff..00811da2f05 100644 --- a/src/java.base/share/classes/jdk/internal/jimage/ImageReader.java +++ b/src/java.base/share/classes/jdk/internal/jimage/ImageReader.java @@ -24,6 +24,8 @@ */ package jdk.internal.jimage; +import jdk.internal.jimage.ImageLocation.LocationType; + import java.io.IOException; import java.nio.ByteBuffer; import java.nio.ByteOrder; @@ -34,16 +36,28 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; +import java.util.TreeMap; import java.util.function.Function; import java.util.function.Supplier; import java.util.stream.Stream; +import static jdk.internal.jimage.ImageLocation.FLAGS_HAS_PREVIEW_VERSION; +import static jdk.internal.jimage.ImageLocation.FLAGS_IS_PREVIEW_ONLY; +import static jdk.internal.jimage.ImageLocation.LocationType.MODULES_DIR; +import static jdk.internal.jimage.ImageLocation.LocationType.MODULES_ROOT; +import static jdk.internal.jimage.ImageLocation.LocationType.PACKAGES_DIR; +import static jdk.internal.jimage.ImageLocation.LocationType.RESOURCE; +import static jdk.internal.jimage.ImageLocation.MODULES_PREFIX; +import static jdk.internal.jimage.ImageLocation.PACKAGES_PREFIX; +import static jdk.internal.jimage.ImageLocation.PREVIEW_INFIX; + /** * A view over the entries of a jimage file with a unified namespace suitable * for file system use. The jimage entries (resources, module and package @@ -86,22 +100,26 @@ private ImageReader(SharedImageReader reader) { } /** - * Opens an image reader for a jimage file at the specified path, using the - * given byte order. + * Opens an image reader for a jimage file at the specified path. + * + * @param imagePath file system path of the jimage file. + * @param mode whether to return preview resources. */ - public static ImageReader open(Path imagePath, ByteOrder byteOrder) throws IOException { - Objects.requireNonNull(imagePath); - Objects.requireNonNull(byteOrder); - - return SharedImageReader.open(imagePath, byteOrder); + public static ImageReader open(Path imagePath, PreviewMode mode) throws IOException { + return open(imagePath, ByteOrder.nativeOrder(), mode); } /** - * Opens an image reader for a jimage file at the specified path, using the - * platform native byte order. + * Opens an image reader for a jimage file at the specified path. + * + * @param imagePath file system path of the jimage file. + * @param byteOrder the byte-order to be used when reading the jimage file. + * @param mode controls whether preview resources are visible. */ - public static ImageReader open(Path imagePath) throws IOException { - return open(imagePath, ByteOrder.nativeOrder()); + public static ImageReader open(Path imagePath, ByteOrder byteOrder, PreviewMode mode) throws IOException { + Objects.requireNonNull(imagePath); + Objects.requireNonNull(byteOrder); + return SharedImageReader.open(imagePath, byteOrder, mode.resolve()); } @Override @@ -214,14 +232,38 @@ public ByteBuffer getResourceBuffer(Node node) { } private static final class SharedImageReader extends BasicImageReader { - private static final Map OPEN_FILES = new HashMap<>(); - private static final String MODULES_ROOT = "/modules"; - private static final String PACKAGES_ROOT = "/packages"; // There are >30,000 nodes in a complete jimage tree, and even relatively // common tasks (e.g. starting up javac) load somewhere in the region of // 1000 classes. Thus, an initial capacity of 2000 is a reasonable guess. private static final int INITIAL_NODE_CACHE_CAPACITY = 2000; + static final class ReaderKey { + private final Path imagePath; + private final boolean previewMode; + + public ReaderKey(Path imagePath, boolean previewMode) { + this.imagePath = imagePath; + this.previewMode = previewMode; + } + + @Override + public boolean equals(Object obj) { + // No pattern variables here (Java 8 compatible source). + if (obj instanceof ReaderKey) { + ReaderKey other = (ReaderKey) obj; + return this.imagePath.equals(other.imagePath) && this.previewMode == other.previewMode; + } + return false; + } + + @Override + public int hashCode() { + return imagePath.hashCode() ^ Boolean.hashCode(previewMode); + } + } + + private static final Map OPEN_FILES = new HashMap<>(); + // List of openers for this shared image. private final Set openers = new HashSet<>(); @@ -232,55 +274,145 @@ private static final class SharedImageReader extends BasicImageReader { // Cache of all user visible nodes, guarded by synchronizing 'this' instance. private final Map nodes; - // Used to classify ImageLocation instances without string comparison. - private final int modulesStringOffset; - private final int packagesStringOffset; - private SharedImageReader(Path imagePath, ByteOrder byteOrder) throws IOException { + // Preview mode support. + private final boolean previewMode; + // A relativized mapping from non-preview name to directories containing + // preview-only nodes. This is used to add preview-only content to + // directories as they are completed. + private final HashMap previewDirectoriesToMerge; + + private SharedImageReader(Path imagePath, ByteOrder byteOrder, boolean previewMode) throws IOException { super(imagePath, byteOrder); this.imageFileAttributes = Files.readAttributes(imagePath, BasicFileAttributes.class); this.nodes = new HashMap<>(INITIAL_NODE_CACHE_CAPACITY); - // Pick stable jimage names from which to extract string offsets (we cannot - // use "/modules" or "/packages", since those have a module offset of zero). - this.modulesStringOffset = getModuleOffset("/modules/java.base"); - this.packagesStringOffset = getModuleOffset("/packages/java.lang"); + this.previewMode = previewMode; // Node creation is very lazy, so we can just make the top-level directories // now without the risk of triggering the building of lots of other nodes. - Directory packages = newDirectory(PACKAGES_ROOT); - nodes.put(packages.getName(), packages); - Directory modules = newDirectory(MODULES_ROOT); - nodes.put(modules.getName(), modules); + Directory packages = ensureCached(newDirectory(PACKAGES_PREFIX)); + Directory modules = ensureCached(newDirectory(MODULES_PREFIX)); Directory root = newDirectory("/"); root.setChildren(Arrays.asList(packages, modules)); - nodes.put(root.getName(), root); + ensureCached(root); + + // By scanning the /packages directory information early we can determine + // which module/package pairs have preview resources, and build the (small) + // set of preview nodes early. This also ensures that preview-only entries + // in the /packages directory are not present in non-preview mode. + this.previewDirectoriesToMerge = previewMode ? new HashMap<>() : null; + packages.setChildren(processPackagesDirectory(previewMode)); } /** - * Returns the offset of the string denoting the leading "module" segment in - * the given path (e.g. {@code /}). We can't just pass in the - * {@code /} string here because that has a module offset of zero. + * Process {@code "/packages/xxx"} entries to build the child nodes for the + * root {@code "/packages"} node. Preview-only entries will be skipped if + * {@code previewMode == false}. + * + *

If {@code previewMode == true}, this method also populates the {@link + * #previewDirectoriesToMerge} map with any preview-only nodes, to be merged + * into directories as they are completed. It also caches preview resources + * and preview-only directories for direct lookup. */ - private int getModuleOffset(String path) { - ImageLocation location = findLocation(path); - assert location != null : "Cannot find expected jimage location: " + path; - int offset = location.getModuleOffset(); - assert offset != 0 : "Invalid module offset for jimage location: " + path; - return offset; + private ArrayList processPackagesDirectory(boolean previewMode) { + ImageLocation pkgRoot = findLocation(PACKAGES_PREFIX); + assert pkgRoot != null : "Invalid jimage file"; + IntBuffer offsets = getOffsetBuffer(pkgRoot); + ArrayList pkgDirs = new ArrayList<>(offsets.capacity()); + // Package path to module map, sorted in reverse order so that + // longer child paths get processed first. + Map> previewPackagesToModules = + new TreeMap<>(Comparator.reverseOrder()); + for (int i = 0; i < offsets.capacity(); i++) { + ImageLocation pkgDir = getLocation(offsets.get(i)); + int flags = pkgDir.getFlags(); + // A package subdirectory is "preview only" if all the modules + // it references have that package marked as preview only. + // Skipping these entries avoids empty package subdirectories. + if (previewMode || (flags & FLAGS_IS_PREVIEW_ONLY) == 0) { + pkgDirs.add(ensureCached(newDirectory(pkgDir.getFullName()))); + } + if (!previewMode || (flags & FLAGS_HAS_PREVIEW_VERSION) == 0) { + continue; + } + // Only do this in preview mode for the small set of packages with + // preview versions (the number of preview entries should be small). + List moduleNames = new ArrayList<>(); + ModuleReference.readNameOffsets(getOffsetBuffer(pkgDir), /*normal*/ false, /*preview*/ true) + .forEachRemaining(n -> moduleNames.add(getString(n))); + previewPackagesToModules.put(pkgDir.getBase().replace('.', '/'), moduleNames); + } + // Reverse sorted map means child directories are processed first. + previewPackagesToModules.forEach((pkgPath, modules) -> + modules.forEach(modName -> processPreviewDir(MODULES_PREFIX + "/" + modName, pkgPath))); + // We might have skipped some preview-only package entries. + pkgDirs.trimToSize(); + return pkgDirs; + } + + void processPreviewDir(String namePrefix, String pkgPath) { + String previewDirName = namePrefix + PREVIEW_INFIX + "/" + pkgPath; + ImageLocation previewLoc = findLocation(previewDirName); + assert previewLoc != null : "Missing preview directory location: " + previewDirName; + String nonPreviewDirName = namePrefix + "/" + pkgPath; + List previewOnlyChildren = createChildNodes(previewLoc, 0, childLoc -> { + String baseName = getBaseName(childLoc); + String nonPreviewChildName = nonPreviewDirName + "/" + baseName; + boolean isPreviewOnly = (childLoc.getFlags() & FLAGS_IS_PREVIEW_ONLY) != 0; + LocationType type = childLoc.getType(); + if (type == RESOURCE) { + // Preview resources are cached to override non-preview versions. + Node childNode = ensureCached(newResource(nonPreviewChildName, childLoc)); + return isPreviewOnly ? childNode : null; + } else { + // Child directories are not cached here (they are either cached + // already or have been added to previewDirectoriesToMerge). + assert type == MODULES_DIR : "Invalid location type: " + childLoc; + Node childNode = nodes.get(nonPreviewChildName); + assert isPreviewOnly == (childNode != null) : + "Inconsistent child node: " + nonPreviewChildName; + return childNode; + } + }); + Directory previewDir = newDirectory(nonPreviewDirName); + previewDir.setChildren(previewOnlyChildren); + if ((previewLoc.getFlags() & FLAGS_IS_PREVIEW_ONLY) != 0) { + // If we are preview-only, our children are also preview-only, so + // this directory is a complete hierarchy and should be cached. + assert !previewOnlyChildren.isEmpty() : "Invalid empty preview-only directory: " + nonPreviewDirName; + ensureCached(previewDir); + } else if (!previewOnlyChildren.isEmpty()) { + // A partial directory containing extra preview-only nodes + // to be merged when the non-preview directory is completed. + previewDirectoriesToMerge.put(nonPreviewDirName, previewDir); + } } - private static ImageReader open(Path imagePath, ByteOrder byteOrder) throws IOException { + // Adds a node to the cache, ensuring that no matching entry already existed. + private T ensureCached(T node) { + Node existingNode = nodes.put(node.getName(), node); + assert existingNode == null : "Unexpected node already cached for: " + node; + return node; + } + + // As above but ignores null. + private T ensureCachedIfNonNull(T node) { + return node != null ? ensureCached(node) : null; + } + + private static ImageReader open(Path imagePath, ByteOrder byteOrder, boolean previewMode) throws IOException { Objects.requireNonNull(imagePath); Objects.requireNonNull(byteOrder); synchronized (OPEN_FILES) { - SharedImageReader reader = OPEN_FILES.get(imagePath); + ReaderKey key = new ReaderKey(imagePath, previewMode); + SharedImageReader reader = OPEN_FILES.get(key); if (reader == null) { // Will fail with an IOException if wrong byteOrder. - reader = new SharedImageReader(imagePath, byteOrder); - OPEN_FILES.put(imagePath, reader); + reader = new SharedImageReader(imagePath, byteOrder, previewMode); + OPEN_FILES.put(key, reader); } else if (reader.getByteOrder() != byteOrder) { throw new IOException("\"" + reader.getName() + "\" is not an image file"); } @@ -304,7 +436,7 @@ public void close(ImageReader image) throws IOException { close(); nodes.clear(); - if (!OPEN_FILES.remove(this.getImagePath(), this)) { + if (!OPEN_FILES.remove(new ReaderKey(getImagePath(), previewMode), this)) { throw new IOException("image file not found in open list"); } } @@ -322,20 +454,14 @@ public void close(ImageReader image) throws IOException { * "/modules" or "/packages". */ synchronized Node findNode(String name) { + // Root directories "/", "/modules" and "/packages", as well + // as all "/packages/xxx" subdirectories are already cached. Node node = nodes.get(name); if (node == null) { - // We cannot get the root paths ("/modules" or "/packages") here - // because those nodes are already in the nodes cache. - if (name.startsWith(MODULES_ROOT + "/")) { - // This may perform two lookups, one for a directory (in - // "/modules/...") and one for a non-prefixed resource - // (with "/modules" removed). - node = buildModulesNode(name); - } else if (name.startsWith(PACKAGES_ROOT + "/")) { - node = buildPackagesNode(name); - } - if (node != null) { - nodes.put(node.getName(), node); + if (name.startsWith(MODULES_PREFIX + "/")) { + node = buildAndCacheModulesNode(name); + } else if (name.startsWith(PACKAGES_PREFIX + "/")) { + node = buildAndCacheLinkNode(name); } } else if (!node.isCompleted()) { // Only directories can be incomplete. @@ -359,13 +485,13 @@ Node findResourceNode(String moduleName, String resourcePath) { if (moduleName.indexOf('/') >= 0) { throw new IllegalArgumentException("invalid module name: " + moduleName); } - String nodeName = MODULES_ROOT + "/" + moduleName + "/" + resourcePath; + String nodeName = MODULES_PREFIX + "/" + moduleName + "/" + resourcePath; // Synchronize as tightly as possible to reduce locking contention. synchronized (this) { Node node = nodes.get(nodeName); if (node == null) { ImageLocation loc = findLocation(moduleName, resourcePath); - if (loc != null && isResource(loc)) { + if (loc != null && loc.getType() == RESOURCE) { node = newResource(nodeName, loc); nodes.put(node.getName(), node); } @@ -381,18 +507,29 @@ Node findResourceNode(String moduleName, String resourcePath) { * *

This method is expected to be called frequently for resources * which do not exist in the given module (e.g. as part of classpath - * search). As such, it skips checking the nodes cache and only checks - * for an entry in the jimage file, as this is faster if the resource - * is not present. This also means it doesn't need synchronization. + * search). As such, it skips checking the nodes cache if possible, and + * only checks for an entry in the jimage file, as this is faster if the + * resource is not present. This also means it doesn't need + * synchronization most of the time. */ boolean containsResource(String moduleName, String resourcePath) { if (moduleName.indexOf('/') >= 0) { throw new IllegalArgumentException("invalid module name: " + moduleName); } - // If the given module name is 'modules', then 'isResource()' - // returns false to prevent false positives. + // In preview mode, preview-only resources are eagerly added to the + // cache, so we must check that first. + if (previewMode) { + String nodeName = MODULES_PREFIX + "/" + moduleName + "/" + resourcePath; + // Synchronize as tightly as possible to reduce locking contention. + synchronized (this) { + Node node = nodes.get(nodeName); + if (node != null) { + return node.isResource(); + } + } + } ImageLocation loc = findLocation(moduleName, resourcePath); - return loc != null && isResource(loc); + return loc != null && loc.getType() == RESOURCE; } /** @@ -401,55 +538,81 @@ boolean containsResource(String moduleName, String resourcePath) { *

Called by {@link #findNode(String)} if a {@code /modules/...} node * is not present in the cache. */ - private Node buildModulesNode(String name) { - assert name.startsWith(MODULES_ROOT + "/") : "Invalid module node name: " + name; + private Node buildAndCacheModulesNode(String name) { + assert name.startsWith(MODULES_PREFIX + "/") : "Invalid module node name: " + name; + if (isPreviewName(name)) { + return null; + } // Returns null for non-directory resources, since the jimage name does not // start with "/modules" (e.g. "/java.base/java/lang/Object.class"). ImageLocation loc = findLocation(name); if (loc != null) { assert name.equals(loc.getFullName()) : "Mismatched location for directory: " + name; - assert isModulesSubdirectory(loc) : "Invalid modules directory: " + name; - return completeModuleDirectory(newDirectory(name), loc); + assert loc.getType() == MODULES_DIR : "Invalid modules directory: " + name; + return ensureCached(completeModuleDirectory(newDirectory(name), loc)); } // Now try the non-prefixed resource name, but be careful to avoid false // positives for names like "/modules/modules/xxx" which could return a // location of a directory entry. - loc = findLocation(name.substring(MODULES_ROOT.length())); - return loc != null && isResource(loc) ? newResource(name, loc) : null; + loc = findLocation(name.substring(MODULES_PREFIX.length())); + return ensureCachedIfNonNull( + loc != null && loc.getType() == RESOURCE ? newResource(name, loc) : null); } /** - * Builds a node in the "/packages/..." namespace. + * Returns whether a directory name in the "/modules/" directory could be referencing + * the "META-INF" directory". + */ + private boolean isMetaInf(Directory dir) { + String name = dir.getName(); + int pathStart = name.indexOf('/', MODULES_PREFIX.length() + 1); + return name.length() == pathStart + "/META-INF".length() + && name.endsWith("/META-INF"); + } + + /** + * Returns whether a node name in the "/modules/" directory could be referencing + * a preview resource or directory under "META-INF/preview". + */ + private boolean isPreviewName(String name) { + int pathStart = name.indexOf('/', MODULES_PREFIX.length() + 1); + int previewEnd = pathStart + PREVIEW_INFIX.length(); + return pathStart > 0 + && name.regionMatches(pathStart, PREVIEW_INFIX, 0, PREVIEW_INFIX.length()) + && (name.length() == previewEnd || name.charAt(previewEnd) == '/'); + } + + private String getBaseName(ImageLocation loc) { + // Matches logic in ImageLocation#getFullName() regarding extensions. + String trailingParts = loc.getBase() + + ((loc.getExtensionOffset() != 0) ? "." + loc.getExtension() : ""); + return trailingParts.substring(trailingParts.lastIndexOf('/') + 1); + } + + /** + * Builds a link node of the form "/packages/xxx/yyy". * - *

Called by {@link #findNode(String)} if a {@code /packages/...} node - * is not present in the cache. + *

Called by {@link #findNode(String)} if a {@code /packages/...} + * node is not present in the cache (the name is not trusted). */ - private Node buildPackagesNode(String name) { - // There are only locations for the root "/packages" or "/packages/xxx" - // directories, but not the symbolic links below them (the links can be - // entirely derived from the name information in the parent directory). - // However, unlike resources this means that we do not have a constant - // time lookup for link nodes when creating them. - int packageStart = PACKAGES_ROOT.length() + 1; + private Node buildAndCacheLinkNode(String name) { + // There are only locations for "/packages" or "/packages/xxx" + // directories, but not the symbolic links below them (links are + // derived from the name information in the parent directory). + int packageStart = PACKAGES_PREFIX.length() + 1; int packageEnd = name.indexOf('/', packageStart); - if (packageEnd == -1) { - ImageLocation loc = findLocation(name); - return loc != null ? completePackageDirectory(newDirectory(name), loc) : null; - } else { - // We cannot assume that the parent directory exists for a link node, since - // the given name is untrusted and could reference a non-existent link. - // However, if the parent directory is present, we can conclude that the - // given name was not a valid link (or else it would already be cached). + // We already built the 2-level "/packages/xxx" directories, + // so if this is a 2-level name, it cannot reference a node. + if (packageEnd >= 0) { String dirName = name.substring(0, packageEnd); - if (!nodes.containsKey(dirName)) { - ImageLocation loc = findLocation(dirName); - // If the parent location doesn't exist, the link node cannot exist. - if (loc != null) { - nodes.put(dirName, completePackageDirectory(newDirectory(dirName), loc)); - // When the parent is created its child nodes are created and cached, - // but this can still return null if given name wasn't a valid link. - return nodes.get(name); + // If no parent exists here, the name cannot be valid. + Directory parent = (Directory) nodes.get(dirName); + if (parent != null) { + if (!parent.isCompleted()) { + // This caches all child links of the parent directory. + completePackageSubdirectory(parent, findLocation(dirName)); } + return nodes.get(name); } } return null; @@ -461,127 +624,118 @@ private void completeDirectory(Directory dir) { // Since the node exists, we can assert that its name starts with // either "/modules" or "/packages", making differentiation easy. // It also means that the name is valid, so it must yield a location. - assert name.startsWith(MODULES_ROOT) || name.startsWith(PACKAGES_ROOT); + assert name.startsWith(MODULES_PREFIX) || name.startsWith(PACKAGES_PREFIX); ImageLocation loc = findLocation(name); assert loc != null && name.equals(loc.getFullName()) : "Invalid location for name: " + name; - // We cannot use 'isXxxSubdirectory()' methods here since we could - // be given a top-level directory (for which that test doesn't work). - // The string MUST start "/modules" or "/packages" here. - if (name.charAt(1) == 'm') { + LocationType type = loc.getType(); + if (type == MODULES_DIR || type == MODULES_ROOT) { completeModuleDirectory(dir, loc); } else { - completePackageDirectory(dir, loc); + assert type == PACKAGES_DIR : "Invalid location type: " + loc; + completePackageSubdirectory(dir, loc); } assert dir.isCompleted() : "Directory must be complete by now: " + dir; } - /** - * Completes a modules directory by setting the list of child nodes. - * - *

The given directory can be the top level {@code /modules} directory, - * so it is NOT safe to use {@code isModulesSubdirectory(loc)} here. - */ + /** Completes a modules directory by setting the list of child nodes. */ private Directory completeModuleDirectory(Directory dir, ImageLocation loc) { assert dir.getName().equals(loc.getFullName()) : "Mismatched location for directory: " + dir; - List children = createChildNodes(loc, childLoc -> { - if (isModulesSubdirectory(childLoc)) { - return nodes.computeIfAbsent(childLoc.getFullName(), this::newDirectory); + List previewOnlyNodes = getPreviewNodesToMerge(dir); + // We hide preview names from direct lookup, but must also prevent + // the preview directory from appearing in any META-INF directories. + boolean parentIsMetaInfDir = isMetaInf(dir); + List children = createChildNodes(loc, previewOnlyNodes.size(), childLoc -> { + LocationType type = childLoc.getType(); + if (type == MODULES_DIR) { + String name = childLoc.getFullName(); + return parentIsMetaInfDir && name.endsWith("/preview") + ? null + : nodes.computeIfAbsent(name, this::newDirectory); } else { + assert type == RESOURCE : "Invalid location type: " + loc; // Add "/modules" prefix to image location paths to get node names. String resourceName = childLoc.getFullName(true); return nodes.computeIfAbsent(resourceName, n -> newResource(n, childLoc)); } }); + children.addAll(previewOnlyNodes); dir.setChildren(children); return dir; } - /** - * Completes a package directory by setting the list of child nodes. - * - *

The given directory can be the top level {@code /packages} directory, - * so it is NOT safe to use {@code isPackagesSubdirectory(loc)} here. - */ - private Directory completePackageDirectory(Directory dir, ImageLocation loc) { + /** Completes a package directory by setting the list of child nodes. */ + private void completePackageSubdirectory(Directory dir, ImageLocation loc) { assert dir.getName().equals(loc.getFullName()) : "Mismatched location for directory: " + dir; - // The only directories in the "/packages" namespace are "/packages" or - // "/packages/". However, unlike "/modules" directories, the - // location offsets mean different things. - List children; - if (dir.getName().equals(PACKAGES_ROOT)) { - // Top-level directory just contains a list of subdirectories. - children = createChildNodes(loc, c -> nodes.computeIfAbsent(c.getFullName(), this::newDirectory)); - } else { - // A package directory's content is array of offset PAIRS in the - // Strings table, but we only need the 2nd value of each pair. - IntBuffer intBuffer = getOffsetBuffer(loc); - int offsetCount = intBuffer.capacity(); - assert (offsetCount & 0x1) == 0 : "Offset count must be even: " + offsetCount; - children = new ArrayList<>(offsetCount / 2); - // Iterate the 2nd offset in each pair (odd indices). - for (int i = 1; i < offsetCount; i += 2) { - String moduleName = getString(intBuffer.get(i)); - children.add(nodes.computeIfAbsent( - dir.getName() + "/" + moduleName, - n -> newLinkNode(n, MODULES_ROOT + "/" + moduleName))); + assert !dir.isCompleted() : "Directory already completed: " + dir; + assert loc.getType() == PACKAGES_DIR : "Invalid location type: " + loc.getType(); + + // In non-preview mode we might skip a very small number of preview-only + // entries, but it's not worth "right-sizing" the array for that. + IntBuffer offsets = getOffsetBuffer(loc); + List children = new ArrayList<>(offsets.capacity() / 2); + ModuleReference.readNameOffsets(offsets, /*normal*/ true, previewMode) + .forEachRemaining(n -> { + String modName = getString(n); + Node link = newLinkNode(dir.getName() + "/" + modName, MODULES_PREFIX + "/" + modName); + children.add(ensureCached(link)); + }); + // If the parent directory exists, there must be at least one child node. + assert !children.isEmpty() : "Invalid empty package directory: " + dir; + dir.setChildren(children); + } + + /** Returns the list of child preview nodes to be merged into the given directory. */ + List getPreviewNodesToMerge(Directory dir) { + if (previewDirectoriesToMerge != null) { + Directory mergeDir = previewDirectoriesToMerge.get(dir.getName()); + if (mergeDir != null) { + return mergeDir.children; } } - // This only happens once and "completes" the directory. - dir.setChildren(children); - return dir; + return Collections.emptyList(); } /** - * Creates the list of child nodes for a {@code Directory} based on a given + * Creates the list of child nodes for a modules {@code Directory} from + * its parent location. + * + *

The {@code getChildFn} may return existing cached nodes rather + * than creating them, and if newly created nodes are to be cached, + * it is the job of {@code getChildFn}, or the caller of this method, + * to do that. * - *

Note: This cannot be used for package subdirectories as they have - * child offsets stored differently to other directories. + * @param loc a location relating to a "/modules" directory. + * @param extraNodesCount a known number of preview-only child nodes + * which will be merged onto the end of the returned list later. + * @param getChildFn a function to return a node for each child location + * (or null to skip putting anything in the list). + * @return the list of the non-null child nodes, returned by + * {@code getChildFn}, in the order of the locations entries. */ - private List createChildNodes(ImageLocation loc, Function newChildFn) { + private List createChildNodes(ImageLocation loc, int extraNodesCount, Function getChildFn) { + LocationType type = loc.getType(); + assert type == MODULES_DIR || type == MODULES_ROOT : "Invalid location type: " + loc; IntBuffer offsets = getOffsetBuffer(loc); int childCount = offsets.capacity(); - List children = new ArrayList<>(childCount); + List children = new ArrayList<>(childCount + extraNodesCount); for (int i = 0; i < childCount; i++) { - children.add(newChildFn.apply(getLocation(offsets.get(i)))); + Node childNode = getChildFn.apply(getLocation(offsets.get(i))); + if (childNode != null) { + children.add(childNode); + } } return children; } /** Helper to extract the integer offset buffer from a directory location. */ private IntBuffer getOffsetBuffer(ImageLocation dir) { - assert !isResource(dir) : "Not a directory: " + dir.getFullName(); + assert dir.getType() != RESOURCE : "Not a directory: " + dir.getFullName(); byte[] offsets = getResource(dir); ByteBuffer buffer = ByteBuffer.wrap(offsets); buffer.order(getByteOrder()); return buffer.asIntBuffer(); } - /** - * Efficiently determines if an image location is a resource. - * - *

A resource must have a valid module associated with it, so its - * module offset must be non-zero, and not equal to the offsets for - * "/modules/..." or "/packages/..." entries. - */ - private boolean isResource(ImageLocation loc) { - int moduleOffset = loc.getModuleOffset(); - return moduleOffset != 0 - && moduleOffset != modulesStringOffset - && moduleOffset != packagesStringOffset; - } - - /** - * Determines if an image location is a directory in the {@code /modules} - * namespace (if so, the location name is the node name). - * - *

In jimage, every {@code ImageLocation} under {@code /modules/} is a - * directory and has the same value for {@code getModule()}, and {@code - * getModuleOffset()}. - */ - private boolean isModulesSubdirectory(ImageLocation loc) { - return loc.getModuleOffset() == modulesStringOffset; - } - /** * Creates an "incomplete" directory node with no child nodes set. * Directories need to be "completed" before they are returned by @@ -597,7 +751,6 @@ private Directory newDirectory(String name) { * In image files, resource locations are NOT prefixed by {@code /modules}. */ private Resource newResource(String name, ImageLocation loc) { - assert name.equals(loc.getFullName(true)) : "Mismatched location for resource: " + name; return new Resource(name, loc, imageFileAttributes); } @@ -829,11 +982,12 @@ public Stream getChildNames() { throw new IllegalStateException("Cannot get child nodes of an incomplete directory: " + getName()); } - private void setChildren(List children) { + private void setChildren(List children) { assert this.children == null : this + ": Cannot set child nodes twice!"; this.children = Collections.unmodifiableList(children); } } + /** * Resource node (e.g. a ".class" entry, or any other data resource). * diff --git a/src/java.base/share/classes/jdk/internal/jimage/ImageStrings.java b/src/java.base/share/classes/jdk/internal/jimage/ImageStrings.java index eea62e444de..d9a6755d0cc 100644 --- a/src/java.base/share/classes/jdk/internal/jimage/ImageStrings.java +++ b/src/java.base/share/classes/jdk/internal/jimage/ImageStrings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,19 @@ * to the jimage file provided by the shipped JDK by tools running on JDK 8. */ public interface ImageStrings { + // String offset constants are useful for efficient classification + // of location entries without string comparison. These may change + // between jimage versions (they are checked during initialization). + + /** Fixed offset for the empty string in the strings table. */ + int EMPTY_STRING_OFFSET = 0; + /** Fixed offset for the string "class" in the strings table. */ + int CLASS_STRING_OFFSET = 1; + /** Fixed offset for the string "modules" in the strings table. */ + int MODULES_STRING_OFFSET = 7; + /** Fixed offset for the string "packages" in the strings table. */ + int PACKAGES_STRING_OFFSET = 15; + String get(int offset); int add(final String string); diff --git a/src/java.base/share/classes/jdk/internal/jimage/ModuleReference.java b/src/java.base/share/classes/jdk/internal/jimage/ModuleReference.java new file mode 100644 index 00000000000..6a28fd10c87 --- /dev/null +++ b/src/java.base/share/classes/jdk/internal/jimage/ModuleReference.java @@ -0,0 +1,265 @@ +/* + * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.internal.jimage; + +import java.nio.IntBuffer; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.Iterator; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.function.Function; +import java.util.function.IntFunction; +import java.util.function.IntPredicate; +import java.util.function.Predicate; +import java.util.function.Supplier; +import java.util.stream.Stream; + +/** + * Represents the module entries stored in the buffer of {@code "/packages/xxx"} + * image locations (package subdirectories). These entries use flags which are + * similar to, but distinct from, the {@link ImageLocation} flags, so + * encapsulating them here helps avoid confusion. + * + * @implNote This class needs to maintain JDK 8 source compatibility. + * + * It is used internally in the JDK to implement jimage/jrtfs access, + * but also compiled and delivered as part of the jrtfs.jar to support access + * to the jimage file provided by the shipped JDK by tools running on JDK 8. + */ +public final class ModuleReference implements Comparable { + // The following flags are designed to be additive (hence "has-resources" + // rather than "is-empty", even though "isEmpty()" is whats in the API). + // API methods like "isEmpty()" and "hasPreviewVersion()" are designed to + // match the semantics of ImageLocation flags to avoid having business + // logic need to reason about two different flag regimes. + + /** If set, the associated module has resources (in normal or preview mode). */ + private static final int FLAGS_HAS_CONTENT = 0x1; + /** If set, this package exists in non-preview mode. */ + private static final int FLAGS_HAS_NORMAL_VERSION = 0x2; + /** If set, this package exists in preview mode. */ + private static final int FLAGS_HAS_PREVIEW_VERSION = 0x4; + + /** + * References are ordered with preview versions first which permits early + * exit when processing preview entries (it's reversed because the default + * order for a boolean is {@code false < true}). + */ + private static final Comparator PREVIEW_FIRST = + Comparator.comparing(ModuleReference::hasPreviewVersion).reversed() + .thenComparing(ModuleReference::name); + + /** Creates a reference for an empty package (one without content in). */ + public static ModuleReference forEmptyPackage(String moduleName, boolean isPreview) { + return new ModuleReference(moduleName, previewFlag(isPreview)); + } + + /** Creates a reference for a preview only module. */ + public static ModuleReference forResource(String moduleName, boolean isPreview) { + return new ModuleReference(moduleName, FLAGS_HAS_CONTENT | previewFlag(isPreview)); + } + + private static int previewFlag(boolean isPreview) { + return isPreview ? FLAGS_HAS_PREVIEW_VERSION : FLAGS_HAS_NORMAL_VERSION; + } + + /** Merges two references for the same module (combining their flags). */ + public ModuleReference merge(ModuleReference other) { + if (!name.equals(other.name)) { + throw new IllegalArgumentException("Cannot merge " + other + " with " + this); + } + // Because flags are additive, we can just OR them here. + return new ModuleReference(name, flags | other.flags); + } + + private final String name; + private final int flags; + + private ModuleReference(String moduleName, int flags) { + this.name = Objects.requireNonNull(moduleName); + this.flags = flags; + } + + /** Returns the module name of this reference. */ + public String name() { + return name; + } + + /** + * Returns whether the package associated with this reference contains + * resources in this reference's module. + * + *

An invariant of the module system is that while a package may exist + * under many modules, it is only non-empty in one. + */ + public boolean hasContent() { + return ((flags & FLAGS_HAS_CONTENT) != 0); + } + + /** + * Returns whether the package associated with this reference has a preview + * version (empty or otherwise) in this reference's module. + */ + public boolean hasPreviewVersion() { + return (flags & FLAGS_HAS_PREVIEW_VERSION) != 0; + } + + /** Returns whether this reference exists only in preview mode. */ + public boolean isPreviewOnly() { + return !hasNormalVersion(flags); + } + + private static boolean hasNormalVersion(int flags) { + return (flags & FLAGS_HAS_NORMAL_VERSION) != 0; + } + + @Override + public int compareTo(ModuleReference rhs) { + return PREVIEW_FIRST.compare(this, rhs); + } + + @Override + public String toString() { + return "ModuleReference{ module=" + name + ", flags=" + flags + " }"; + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof ModuleReference)) { + return false; + } + ModuleReference other = (ModuleReference) obj; + return name.equals(other.name) && flags == other.flags; + } + + @Override + public int hashCode() { + return Objects.hash(name, flags); + } + + /** + * Reads the content buffer of a package subdirectory to return a sequence + * of module name offsets in the jimage. + * + * @param buffer the content buffer of an {@link ImageLocation} with type + * {@link ImageLocation.LocationType#PACKAGES_DIR PACKAGES_DIR}. + * @param includeNormal whether to include name offsets for modules present + * in normal (non-preview) mode. + * @param includePreview whether to include name offsets for modules present + * in preview mode. + * @return an iterator of module name offsets. + */ + public static Iterator readNameOffsets( + IntBuffer buffer, boolean includeNormal, boolean includePreview) { + int bufferSize = buffer.capacity(); + if (bufferSize == 0 || (bufferSize & 0x1) != 0) { + throw new IllegalArgumentException("Invalid buffer size"); + } + int testFlags = (includeNormal ? FLAGS_HAS_NORMAL_VERSION : 0) + + (includePreview ? FLAGS_HAS_PREVIEW_VERSION : 0); + if (testFlags == 0) { + throw new IllegalArgumentException("Invalid flags"); + } + + return new Iterator() { + private int idx = nextIdx(0); + + int nextIdx(int idx) { + for (; idx < bufferSize; idx += 2) { + // If any of the test flags are set, include this entry. + if ((buffer.get(idx) & testFlags) != 0) { + return idx; + } else if (!includeNormal) { + // Preview entries are first in the offset buffer, so we + // can exit early (by returning the end index) if we are + // only iterating preview entries, and have run out. + break; + } + } + return bufferSize; + } + + @Override + public boolean hasNext() { + return idx < bufferSize; + } + + @Override + public Integer next() { + if (idx < bufferSize) { + int nameOffset = buffer.get(idx + 1); + idx = nextIdx(idx + 2); + return nameOffset; + } + throw new NoSuchElementException(); + } + }; + } + + /** + * Writes a list of module references to a given buffer. The given references + * list is checked carefully to ensure the written buffer will be valid. + * + *

Entries are written in order, taking two integer slots per entry as + * {@code [, ]}. + * + * @param refs the references to write, correctly ordered. + * @param buffer destination buffer. + * @param nameEncoder encoder for module names. + * @throws IllegalArgumentException in the references are invalid in any way. + */ + public static void write( + List refs, IntBuffer buffer, Function nameEncoder) { + if (refs.isEmpty()) { + throw new IllegalArgumentException("References list must be non-empty"); + } + int expectedCapacity = 2 * refs.size(); + if (buffer.capacity() != expectedCapacity) { + throw new IllegalArgumentException( + "Invalid buffer capacity: expected " + expectedCapacity + ", got " + buffer.capacity()); + } + // This catches exact duplicates in the list. + refs.stream().reduce((lhs, rhs) -> { + if (lhs.compareTo(rhs) >= 0) { + throw new IllegalArgumentException("References must be strictly ordered: " + refs); + } + return rhs; + }); + // Distinct references can have the same name (but we don't allow this). + if (refs.stream().map(ModuleReference::name).distinct().count() != refs.size()) { + throw new IllegalArgumentException("Reference names must be unique: " + refs); + } + if (refs.stream().filter(ModuleReference::hasContent).count() > 1) { + throw new IllegalArgumentException("At most one reference can have content: " + refs); + } + for (ModuleReference modRef : refs) { + buffer.put(modRef.flags); + buffer.put(nameEncoder.apply(modRef.name)); + } + } +} diff --git a/src/java.base/share/classes/jdk/internal/jimage/PreviewMode.java b/src/java.base/share/classes/jdk/internal/jimage/PreviewMode.java new file mode 100644 index 00000000000..e6e54de0f2a --- /dev/null +++ b/src/java.base/share/classes/jdk/internal/jimage/PreviewMode.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.internal.jimage; + +import java.lang.reflect.InvocationTargetException; + +/** + * Specifies the preview mode used to open a jimage file via {@link ImageReader}. + * + * @implNote This class needs to maintain JDK 8 source compatibility. + * + * It is used internally in the JDK to implement jimage/jrtfs access, + * but also compiled and delivered as part of the jrtfs.jar to support access + * to the jimage file provided by the shipped JDK by tools running on JDK 8. + * */ +public enum PreviewMode { + /** + * Preview mode is disabled. No preview classes or resources will be available + * in this mode. + */ + DISABLED() { + @Override + boolean resolve() { + return false; + } + }, + /** + * Preview mode is enabled. If preview classes or resources exist in the jimage file, + * they will be made available. + */ + ENABLED() { + @Override + boolean resolve() { + return true; + } + }, + /** + * The preview mode of the current run-time, typically determined by the + * {@code --enable-preview} flag. + */ + FOR_RUNTIME() { + @Override + boolean resolve() { + // We want to call jdk.internal.misc.PreviewFeatures.isEnabled(), but + // is not available in older JREs, so we must look to it reflectively. + Class clazz; + try { + clazz = Class.forName("jdk.internal.misc.PreviewFeatures"); + } catch (ClassNotFoundException e) { + // It is valid and expected that the class might not exist (JDK-8). + return false; + } + try { + return (Boolean) clazz.getDeclaredMethod("isEnabled").invoke(null); + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + // But if the class exists, the method must exist and be callable. + throw new ExceptionInInitializerError(e); + } + } + }; + + /** + * Resolves whether preview mode should be enabled for an {@link ImageReader}. + */ + abstract boolean resolve(); +} diff --git a/src/java.base/share/classes/jdk/internal/jimage/SystemImageReader.java b/src/java.base/share/classes/jdk/internal/jimage/SystemImageReader.java new file mode 100644 index 00000000000..38bf786e533 --- /dev/null +++ b/src/java.base/share/classes/jdk/internal/jimage/SystemImageReader.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.internal.jimage; + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; + +/** + * Static holder class for singleton {@link ImageReader} instance. + * + * @implNote This class needs to maintain JDK 8 source compatibility. + * + * It is used internally in the JDK to implement jimage/jrtfs access, + * but also compiled and delivered as part of the jrtfs.jar to support access + * to the jimage file provided by the shipped JDK by tools running on JDK 8. + */ +public class SystemImageReader { + private static final ImageReader SYSTEM_IMAGE_READER; + + static { + String javaHome = System.getProperty("java.home"); + FileSystem fs; + if (SystemImageReader.class.getClassLoader() == null) { + try { + fs = (FileSystem) Class.forName("sun.nio.fs.DefaultFileSystemProvider") + .getMethod("theFileSystem") + .invoke(null); + } catch (Exception e) { + throw new ExceptionInInitializerError(e); + } + } else { + fs = FileSystems.getDefault(); + } + try { + SYSTEM_IMAGE_READER = ImageReader.open(fs.getPath(javaHome, "lib", "modules"), PreviewMode.FOR_RUNTIME); + } catch (IOException e) { + throw new ExceptionInInitializerError(e); + } + } + + /** + * Returns the singleton {@code ImageReader} to read the image file in this + * run-time image. The returned instance must not be closed. + * + * @throws UncheckedIOException if an I/O error occurs + */ + public static ImageReader get() { + return SYSTEM_IMAGE_READER; + } + + private SystemImageReader() {} +} diff --git a/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java b/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java index c405801506f..4d739d1e200 100644 --- a/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java +++ b/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java @@ -58,11 +58,11 @@ import java.util.Collections; import java.util.HashSet; import java.util.Iterator; -import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.regex.Pattern; import jdk.internal.jimage.ImageReader.Node; +import jdk.internal.jimage.PreviewMode; /** * jrt file system implementation built on System jimage files. @@ -81,13 +81,34 @@ class JrtFileSystem extends FileSystem { private volatile boolean isClosable; private SystemImage image; - JrtFileSystem(JrtFileSystemProvider provider, Map env) - throws IOException - { + /** + * Special constructor for the singleton system jrt file system. This creates + * a non-closable instance, and should only be called once by {@link + * JrtFileSystemProvider}. + * + * @param provider the provider opening the file system. + */ + JrtFileSystem(JrtFileSystemProvider provider) + throws IOException { + this.provider = provider; + this.image = SystemImage.open(PreviewMode.FOR_RUNTIME); // open image file + this.isOpen = true; + // Only the system singleton jrt file system is "unclosable". + this.isClosable = false; + } + + /** + * Creates a new, non-system, instance of the jrt file system. + * + * @param provider the provider opening the file system. + * @param mode controls whether preview resources are visible. + */ + JrtFileSystem(JrtFileSystemProvider provider, PreviewMode mode) + throws IOException { this.provider = provider; - this.image = SystemImage.open(); // open image file + this.image = SystemImage.open(mode); // open image file this.isOpen = true; - this.isClosable = env != null; + this.isClosable = true; } // FileSystem method implementations diff --git a/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystemProvider.java b/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystemProvider.java index 9ee620f4137..5721aa7411e 100644 --- a/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystemProvider.java +++ b/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystemProvider.java @@ -24,6 +24,8 @@ */ package jdk.internal.jrtfs; +import jdk.internal.jimage.PreviewMode; + import java.io.*; import java.net.MalformedURLException; import java.net.URL; @@ -44,7 +46,7 @@ /** * File system provider for jrt file systems. Conditionally creates jrt fs on - * .jimage file or exploded modules directory of underlying JDK. + * a jimage file, or exploded modules directory of underlying JDK. * * @implNote This class needs to maintain JDK 8 source compatibility. * @@ -107,8 +109,22 @@ public FileSystem newFileSystem(URI uri, Map env) if (env.containsKey("java.home")) { return newFileSystem((String)env.get("java.home"), uri, env); } else { - return new JrtFileSystem(this, env); + return new JrtFileSystem(this, parsePreviewMode(env.get("previewMode"))); + } + } + + // Currently this does not support specifying "for runtime", because it is + // expected that callers creating non-standard image readers will not be + // using them to read resources for the current runtime (they would just + // use "jrt:" URLs if they were doing that). + private static PreviewMode parsePreviewMode(Object envValue) { + if (envValue instanceof Boolean && (Boolean) envValue) { + return PreviewMode.ENABLED; + } else if (envValue instanceof String && Boolean.parseBoolean((String) envValue)) { + return PreviewMode.ENABLED; } + // Default (unspecified/null or bad parameter) is to not use preview mode. + return PreviewMode.DISABLED; } private static final String JRT_FS_JAR = "jrt-fs.jar"; @@ -208,7 +224,8 @@ private FileSystem getTheFileSystem() { fs = this.theFileSystem; if (fs == null) { try { - this.theFileSystem = fs = new JrtFileSystem(this, null); + // Special constructor call for singleton instance. + this.theFileSystem = fs = new JrtFileSystem(this); } catch (IOException ioe) { throw new InternalError(ioe); } @@ -226,7 +243,7 @@ public FileSystem getFileSystem(URI uri) { } // Checks that the given file is a JrtPath - static final JrtPath toJrtPath(Path path) { + static JrtPath toJrtPath(Path path) { Objects.requireNonNull(path, "path"); if (!(path instanceof JrtPath)) { throw new ProviderMismatchException(); @@ -257,7 +274,7 @@ public void createDirectory(Path path, FileAttribute... attrs) } @Override - public final void delete(Path path) throws IOException { + public void delete(Path path) throws IOException { toJrtPath(path).delete(); } diff --git a/src/java.base/share/classes/jdk/internal/jrtfs/SystemImage.java b/src/java.base/share/classes/jdk/internal/jrtfs/SystemImage.java index b38e953a5f9..caa915f926f 100644 --- a/src/java.base/share/classes/jdk/internal/jrtfs/SystemImage.java +++ b/src/java.base/share/classes/jdk/internal/jrtfs/SystemImage.java @@ -39,6 +39,7 @@ import jdk.internal.jimage.ImageReader; import jdk.internal.jimage.ImageReader.Node; +import jdk.internal.jimage.PreviewMode; /** * @implNote This class needs to maintain JDK 8 source compatibility. @@ -54,10 +55,10 @@ abstract class SystemImage { abstract byte[] getResource(Node node) throws IOException; abstract void close() throws IOException; - static SystemImage open() throws IOException { + static SystemImage open(PreviewMode mode) throws IOException { if (modulesImageExists) { // open a .jimage and build directory structure - final ImageReader image = ImageReader.open(moduleImageFile); + final ImageReader image = ImageReader.open(moduleImageFile, mode); return new SystemImage() { @Override Node findNode(String path) throws IOException { @@ -73,6 +74,9 @@ void close() throws IOException { } }; } + + // TODO: Maybe throw if enablePreview attempted for exploded image? + if (Files.notExists(explodedModulesDir)) throw new FileSystemNotFoundException(explodedModulesDir.toString()); return new ExplodedImage(explodedModulesDir); diff --git a/src/java.base/share/classes/jdk/internal/module/SystemModuleFinders.java b/src/java.base/share/classes/jdk/internal/module/SystemModuleFinders.java index 370c151af84..e7184b599f2 100644 --- a/src/java.base/share/classes/jdk/internal/module/SystemModuleFinders.java +++ b/src/java.base/share/classes/jdk/internal/module/SystemModuleFinders.java @@ -54,7 +54,7 @@ import java.util.stream.StreamSupport; import jdk.internal.jimage.ImageReader; -import jdk.internal.jimage.ImageReaderFactory; +import jdk.internal.jimage.SystemImageReader; import jdk.internal.access.JavaNetUriAccess; import jdk.internal.access.SharedSecrets; import jdk.internal.util.StaticProperty; @@ -392,7 +392,7 @@ public byte[] generate(String algorithm) { * Holder class for the ImageReader. */ private static class SystemImage { - static final ImageReader READER = ImageReaderFactory.getImageReader(); + static final ImageReader READER = SystemImageReader.get(); static ImageReader reader() { return READER; } diff --git a/src/java.base/share/classes/sun/net/www/protocol/jrt/JavaRuntimeURLConnection.java b/src/java.base/share/classes/sun/net/www/protocol/jrt/JavaRuntimeURLConnection.java index 71080950b80..b2133144d2f 100644 --- a/src/java.base/share/classes/sun/net/www/protocol/jrt/JavaRuntimeURLConnection.java +++ b/src/java.base/share/classes/sun/net/www/protocol/jrt/JavaRuntimeURLConnection.java @@ -34,7 +34,7 @@ import jdk.internal.jimage.ImageReader; import jdk.internal.jimage.ImageReader.Node; -import jdk.internal.jimage.ImageReaderFactory; +import jdk.internal.jimage.SystemImageReader; import sun.net.www.ParseUtil; import sun.net.www.URLConnection; @@ -48,7 +48,7 @@ public class JavaRuntimeURLConnection extends URLConnection { // ImageReader to access resources in jimage. - private static final ImageReader READER = ImageReaderFactory.getImageReader(); + private static final ImageReader READER = SystemImageReader.get(); // The module and resource name in the URL (i.e. "jrt:/[$MODULE[/$PATH]]"). // @@ -109,9 +109,11 @@ public InputStream getInputStream() throws IOException { @Override public long getContentLengthLong() { + // Note: UncheckedIOException is thrown by the Node subclass in + // ExplodedImage (this not obvious, so worth calling out). try { return connectResourceNode().size(); - } catch (IOException ioe) { + } catch (IOException | UncheckedIOException ioe) { return -1L; } } @@ -124,6 +126,10 @@ public int getContentLength() { // Perform percent decoding of the resource name/path from the URL. private static String percentDecode(String path) throws MalformedURLException { + if (path.indexOf('%') == -1) { + // Nothing to decode (overwhelmingly common case). + return path; + } // Any additional special case decoding logic should go here. try { return ParseUtil.decode(path); diff --git a/src/java.base/share/native/libjimage/imageFile.cpp b/src/java.base/share/native/libjimage/imageFile.cpp index d97a8f95a60..31ac4ebc8d4 100644 --- a/src/java.base/share/native/libjimage/imageFile.cpp +++ b/src/java.base/share/native/libjimage/imageFile.cpp @@ -404,7 +404,7 @@ u4 ImageFileReader::find_location_index(const char* path, u8 *size) const { // Make sure result is not a false positive. if (verify_location(location, path)) { *size = (jlong)location.get_attribute(ImageLocation::ATTRIBUTE_UNCOMPRESSED); - return offset; + return offset; } } return 0; // not found @@ -435,7 +435,7 @@ bool ImageFileReader::verify_location(ImageLocation& location, const char* path) } // Get base name string. const char* base = location.get_attribute(ImageLocation::ATTRIBUTE_BASE, strings); - // Compare with basne name. + // Compare with base name. if (!(next = ImageStrings::starts_with(next, base))) return false; // Get extension string. const char* extension = location.get_attribute(ImageLocation::ATTRIBUTE_EXTENSION, strings); diff --git a/src/java.base/share/native/libjimage/imageFile.hpp b/src/java.base/share/native/libjimage/imageFile.hpp index 5fb4ea3baaa..ea0afa98380 100644 --- a/src/java.base/share/native/libjimage/imageFile.hpp +++ b/src/java.base/share/native/libjimage/imageFile.hpp @@ -237,13 +237,27 @@ class ImageLocation { ATTRIBUTE_MODULE, // String table offset of module name ATTRIBUTE_PARENT, // String table offset of resource path parent ATTRIBUTE_BASE, // String table offset of resource path base - ATTRIBUTE_EXTENSION, // String table offset of resource path extension + ATTRIBUTE_EXTENSION, // String table offset of resource path extension ATTRIBUTE_OFFSET, // Container byte offset of resource - ATTRIBUTE_COMPRESSED, // In image byte size of the compressed resource - ATTRIBUTE_UNCOMPRESSED, // In memory byte size of the uncompressed resource + ATTRIBUTE_COMPRESSED, // In-image byte size of the compressed resource + ATTRIBUTE_UNCOMPRESSED, // In-memory byte size of the uncompressed resource + ATTRIBUTE_PREVIEW_FLAGS, // Flags relating to preview mode resources. ATTRIBUTE_COUNT // Number of attribute kinds }; + // Flag masks for the ATTRIBUTE_PREVIEW_FLAGS attribute. Defined so + // that zero is the overwhelmingly common case for normal resources. + enum { + // Set on a "normal" (non-preview) location if a preview version of + // it exists in the same module. + FLAGS_HAS_PREVIEW_VERSION = 0x1, + // Set on all preview locations in "/modules/xxx/META-INF/preview/..." + FLAGS_IS_PREVIEW_VERSION = 0x2, + // Set on a preview location if no normal (non-preview) version of + // it exists in the same module. + FLAGS_IS_PREVIEW_ONLY = 0x4 + }; + private: // Values of inflated attributes. u8 _attributes[ATTRIBUTE_COUNT]; @@ -300,6 +314,11 @@ class ImageLocation { inline const char* get_attribute(u4 kind, const ImageStrings& strings) const { return strings.get((u4)get_attribute(kind)); } + + // Retrieve flags from the ATTRIBUTE_PREVIEW_FLAGS attribute. + inline u4 get_preview_flags() const { + return (u4) get_attribute(ATTRIBUTE_PREVIEW_FLAGS); + } }; // Image file header, starting at offset 0. @@ -394,6 +413,7 @@ class ImageFileReaderTable { // leads the ImageFileReader to be actually closed and discarded. class ImageFileReader { friend class ImageFileReaderTable; +friend class PackageFlags; private: // Manage a number of image files such that an image can be shared across // multiple uses (ex. loader.) @@ -433,7 +453,7 @@ friend class ImageFileReaderTable; // Image file major version number. MAJOR_VERSION = 1, // Image file minor version number. - MINOR_VERSION = 0 + MINOR_VERSION = 1 }; // Locate an image if file already open. diff --git a/src/java.base/share/native/libjimage/jimage.cpp b/src/java.base/share/native/libjimage/jimage.cpp index 10e85eb2520..b20e9b027b4 100644 --- a/src/java.base/share/native/libjimage/jimage.cpp +++ b/src/java.base/share/native/libjimage/jimage.cpp @@ -91,45 +91,97 @@ JIMAGE_Close(JImageFile* image) { * name, a version string and the name of a class/resource, return location * information describing the resource and its size. If no resource is found, the * function returns JIMAGE_NOT_FOUND and the value of size is undefined. - * The version number should be "9.0" and is not used in locating the resource. * The resulting location does/should not have to be released. * All strings are utf-8, zero byte terminated. * * Ex. * jlong size; * JImageLocationRef location = (*JImageFindResource)(image, - * "java.base", "9.0", "java/lang/String.class", &size); + * "java.base", "java/lang/String.class", is_preview_mode, &size); */ extern "C" JNIEXPORT JImageLocationRef JIMAGE_FindResource(JImageFile* image, - const char* module_name, const char* version, const char* name, + const char* module_name, const char* name, bool is_preview_mode, jlong* size) { + static const char str_modules[] = "modules"; + static const char str_packages[] = "packages"; + static const char preview_infix[] = "/META-INF/preview"; + + size_t module_name_len = strlen(module_name); + size_t name_len = strlen(name); + size_t preview_infix_len = strlen(preview_infix); + + // TBD: assert(module_name_len > 0 && "module name must be non-empty"); + assert(name_len > 0 && "name must non-empty"); + + // Do not attempt to lookup anything of the form /modules/... or /packages/... + if (strncmp(module_name, str_modules, sizeof(str_modules)) == 0 + || strncmp(module_name, str_packages, sizeof(str_packages)) == 0) { + return 0L; + } + // If the preview mode version of the path string is too long for the buffer, + // return not found (even when not in preview mode). + if (1 + module_name_len + preview_infix_len + 1 + name_len + 1 > IMAGE_MAX_PATH) { + return 0L; + } + // Concatenate to get full path - char fullpath[IMAGE_MAX_PATH]; - size_t moduleNameLen = strlen(module_name); - size_t nameLen = strlen(name); - size_t index; + char name_buffer[IMAGE_MAX_PATH]; + char* path; + { // Write the buffer with room to prepend the preview mode infix + // at the start (saves copying the trailing name part twice). + size_t index = preview_infix_len; + name_buffer[index++] = '/'; + memcpy(&name_buffer[index], module_name, module_name_len); + index += module_name_len; + name_buffer[index++] = '/'; + memcpy(&name_buffer[index], name, name_len); + index += name_len; + name_buffer[index++] = '\0'; + // Path begins at the leading '/' (not the start of the buffer). + path = &name_buffer[preview_infix_len]; + } - // TBD: assert(moduleNameLen > 0 && "module name must be non-empty"); - assert(nameLen > 0 && "name must non-empty"); + // find_location_index() returns the data "offset", not an index. + const ImageFileReader* image_file = (ImageFileReader*) image; + u4 locOffset = image_file->find_location_index(path, (u8*) size); + if (locOffset == 0) { + return 0L; + } + ImageLocation loc; + loc.set_data(image_file->get_location_offset_data(locOffset)); - // If the concatenated string is too long for the buffer, return not found - if (1 + moduleNameLen + 1 + nameLen + 1 > IMAGE_MAX_PATH) { + u4 flags = loc.get_preview_flags(); + // No preview flags means "a normal resource, without a preview version". + // This is the overwhelmingly common case, with or without preview mode. + if (flags == 0) { + return locOffset; + } + // Regardless of preview mode, don't return resources requested directly + // via their preview path. + if ((flags & ImageLocation::FLAGS_IS_PREVIEW_VERSION) != 0) { return 0L; } + // Even if there is a preview version, we might not want to return it. + if (!is_preview_mode || (flags & ImageLocation::FLAGS_HAS_PREVIEW_VERSION) == 0) { + return locOffset; + } + + { // Rewrite the front of the name buffer to make it a preview path. + size_t index = 0; + name_buffer[index++] = '/'; + memcpy(&name_buffer[index], module_name, module_name_len); + index += module_name_len; + memcpy(&name_buffer[index], preview_infix, preview_infix_len); + index += preview_infix_len; + // Check we copied up to the expected '/' separator. + assert(name_buffer[index] == '/' && "bad string concatenation"); + // The preview path now begins at the start of the buffer. + path = &name_buffer[0]; + } - index = 0; - fullpath[index++] = '/'; - memcpy(&fullpath[index], module_name, moduleNameLen); - index += moduleNameLen; - fullpath[index++] = '/'; - memcpy(&fullpath[index], name, nameLen); - index += nameLen; - fullpath[index++] = '\0'; - - JImageLocationRef loc = - (JImageLocationRef) ((ImageFileReader*) image)->find_location_index(fullpath, (u8*) size); - return loc; + // Lookup the preview version (which *should* exist). + return image_file->find_location_index(path, (u8*) size); } /* diff --git a/src/java.base/share/native/libjimage/jimage.hpp b/src/java.base/share/native/libjimage/jimage.hpp index a514e737b49..960d8e8ee21 100644 --- a/src/java.base/share/native/libjimage/jimage.hpp +++ b/src/java.base/share/native/libjimage/jimage.hpp @@ -98,21 +98,20 @@ typedef void (*JImageClose_t)(JImageFile* jimage); * name, a version string and the name of a class/resource, return location * information describing the resource and its size. If no resource is found, the * function returns JIMAGE_NOT_FOUND and the value of size is undefined. - * The version number should be "9.0" and is not used in locating the resource. * The resulting location does/should not have to be released. * All strings are utf-8, zero byte terminated. * * Ex. * jlong size; * JImageLocationRef location = (*JImageFindResource)(image, - * "java.base", "9.0", "java/lang/String.class", &size); + * "java.base", "java/lang/String.class", is_preview_mode, &size); */ extern "C" JNIEXPORT JImageLocationRef JIMAGE_FindResource(JImageFile* jimage, - const char* module_name, const char* version, const char* name, + const char* module_name, const char* name, bool is_preview_mode, jlong* size); typedef JImageLocationRef(*JImageFindResource_t)(JImageFile* jimage, - const char* module_name, const char* version, const char* name, + const char* module_name, const char* name, bool is_preview_mode, jlong* size); diff --git a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/BasicImageWriter.java b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/BasicImageWriter.java index ca576227692..ee00ea24d14 100644 --- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/BasicImageWriter.java +++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/BasicImageWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -76,10 +76,10 @@ public String getString(int offset) { } public void addLocation(String fullname, long contentOffset, - long compressedSize, long uncompressedSize) { + long compressedSize, long uncompressedSize, int previewFlags) { ImageLocationWriter location = ImageLocationWriter.newLocation(fullname, strings, - contentOffset, compressedSize, uncompressedSize); + contentOffset, compressedSize, uncompressedSize, previewFlags); input.add(location); length++; } diff --git a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java index 9e05fe31aa9..c8345d13358 100644 --- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java +++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,6 +49,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import jdk.internal.jimage.ImageLocation; import jdk.tools.jlink.internal.Archive.Entry; import jdk.tools.jlink.internal.Archive.Entry.EntryType; import jdk.tools.jlink.internal.JRTArchive.ResourceFileEntry; @@ -227,31 +228,8 @@ private static ResourcePool generateJImage(ResourcePoolManager allContent, DataOutputStream out, boolean generateRuntimeImage ) throws IOException { - ResourcePool resultResources; - try { - resultResources = pluginSupport.visitResources(allContent); - if (generateRuntimeImage) { - // Keep track of non-modules resources for linking from a run-time image - resultResources = addNonClassResourcesTrackFiles(resultResources, - writer); - // Generate the diff between the input resources from packaged - // modules in 'allContent' to the plugin- or otherwise - // generated-content in 'resultResources' - resultResources = addResourceDiffFiles(allContent.resourcePool(), - resultResources, - writer); - } - } catch (PluginException pe) { - if (JlinkTask.DEBUG) { - pe.printStackTrace(); - } - throw pe; - } catch (Exception ex) { - if (JlinkTask.DEBUG) { - ex.printStackTrace(); - } - throw new IOException(ex); - } + ResourcePool resultResources = + getResourcePool(allContent, writer, pluginSupport, generateRuntimeImage); Set duplicates = new HashSet<>(); long[] offset = new long[1]; @@ -282,8 +260,10 @@ private static ResourcePool generateJImage(ResourcePoolManager allContent, offset[0] += onFileSize; return; } + int locFlags = ImageLocation.getFlags( + res.path(), p -> resultResources.findEntry(p).isPresent()); duplicates.add(path); - writer.addLocation(path, offset[0], compressedSize, uncompressedSize); + writer.addLocation(path, offset[0], compressedSize, uncompressedSize, locFlags); paths.add(path); offset[0] += onFileSize; } @@ -307,6 +287,40 @@ private static ResourcePool generateJImage(ResourcePoolManager allContent, return resultResources; } + private static ResourcePool getResourcePool( + ResourcePoolManager allContent, + BasicImageWriter writer, + ImagePluginStack pluginSupport, + boolean generateRuntimeImage) + throws IOException { + ResourcePool resultResources; + try { + resultResources = pluginSupport.visitResources(allContent); + if (generateRuntimeImage) { + // Keep track of non-modules resources for linking from a run-time image + resultResources = addNonClassResourcesTrackFiles(resultResources, + writer); + // Generate the diff between the input resources from packaged + // modules in 'allContent' to the plugin- or otherwise + // generated-content in 'resultResources' + resultResources = addResourceDiffFiles(allContent.resourcePool(), + resultResources, + writer); + } + } catch (PluginException pe) { + if (JlinkTask.DEBUG) { + pe.printStackTrace(); + } + throw pe; + } catch (Exception ex) { + if (JlinkTask.DEBUG) { + ex.printStackTrace(); + } + throw new IOException(ex); + } + return resultResources; + } + /** * Support for creating a runtime suitable for linking from the run-time * image. diff --git a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageLocationWriter.java b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageLocationWriter.java index f2c7f102027..624e608ac21 100644 --- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageLocationWriter.java +++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageLocationWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,8 +54,8 @@ private ImageLocationWriter addAttribute(int kind, String value) { } static ImageLocationWriter newLocation(String fullName, - ImageStringsWriter strings, - long contentOffset, long compressedSize, long uncompressedSize) { + ImageStringsWriter strings, + long contentOffset, long compressedSize, long uncompressedSize, int previewFlags) { String moduleName = ""; String parentName = ""; String baseName; @@ -90,13 +90,14 @@ static ImageLocationWriter newLocation(String fullName, } return new ImageLocationWriter(strings) - .addAttribute(ATTRIBUTE_MODULE, moduleName) - .addAttribute(ATTRIBUTE_PARENT, parentName) - .addAttribute(ATTRIBUTE_BASE, baseName) - .addAttribute(ATTRIBUTE_EXTENSION, extensionName) - .addAttribute(ATTRIBUTE_OFFSET, contentOffset) - .addAttribute(ATTRIBUTE_COMPRESSED, compressedSize) - .addAttribute(ATTRIBUTE_UNCOMPRESSED, uncompressedSize); + .addAttribute(ATTRIBUTE_MODULE, moduleName) + .addAttribute(ATTRIBUTE_PARENT, parentName) + .addAttribute(ATTRIBUTE_BASE, baseName) + .addAttribute(ATTRIBUTE_EXTENSION, extensionName) + .addAttribute(ATTRIBUTE_OFFSET, contentOffset) + .addAttribute(ATTRIBUTE_COMPRESSED, compressedSize) + .addAttribute(ATTRIBUTE_UNCOMPRESSED, uncompressedSize) + .addAttribute(ATTRIBUTE_PREVIEW_FLAGS, previewFlags); } @Override diff --git a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageResourcesTree.java b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageResourcesTree.java index 8a4288f0cfd..48dbf2010bd 100644 --- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageResourcesTree.java +++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageResourcesTree.java @@ -24,33 +24,40 @@ */ package jdk.tools.jlink.internal; +import jdk.internal.jimage.ImageLocation; +import jdk.internal.jimage.ModuleReference; + import java.io.DataOutputStream; import java.io.IOException; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Collections; +import java.util.Comparator; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.TreeMap; -import java.util.TreeSet; +import java.util.stream.Collectors; + +import static java.util.stream.Collectors.joining; /** * A class to build a sorted tree of Resource paths as a tree of ImageLocation. - * */ // XXX Public only due to the JImageTask / JImageTask code duplication public final class ImageResourcesTree { public static boolean isTreeInfoResource(String path) { - return path.startsWith("/packages") || path.startsWith("/modules"); + return path.startsWith("/packages/") || path.startsWith("/modules/"); } /** * Path item tree node. */ - private static class Node { + // Visible for testing only. + static class Node { private final String name; private final Map children = new TreeMap<>(); @@ -66,6 +73,14 @@ private Node(String name, Node parent) { } } + private void setLocation(ImageLocationWriter loc) { + // This *can* be called more than once, but only with the same instance. + if (this.loc != null && loc != this.loc) { + throw new IllegalStateException("Cannot add different locations: " + name); + } + this.loc = Objects.requireNonNull(loc); + } + public String getPath() { if (parent == null) { return "/"; @@ -95,215 +110,240 @@ private static String buildPath(Node item) { } } - private static final class ResourceNode extends Node { + // Visible for testing only. + static final class ResourceNode extends Node { public ResourceNode(String name, Node parent) { super(name, parent); } } - private static class PackageNode extends Node { - /** - * A reference to a package. Empty packages can be located inside one or - * more modules. A package with classes exist in only one module. - */ - static final class PackageReference { - - private final String name; - private final boolean isEmpty; - - PackageReference(String name, boolean isEmpty) { - this.name = Objects.requireNonNull(name); - this.isEmpty = isEmpty; - } + /** + * A 2nd level package directory, {@code "/packages/"}. + * + *

While package paths can exist within many modules, for each package + * there is at most one module in which that package has resources. + * + *

For example, the package path {@code java/util} exists in both the + * {@code java.base} and {@code java.logging} modules. This means both + * {@code "/packages/java.util/java.base"} and + * {@code "/packages/java.util/java.logging"} will exist, but only + * {@code "java.base"} entry will be marked as non-empty. + * + *

For preview mode however, a package that's empty in non-preview mode + * can be non-empty in preview mode. Furthermore, packages which only exist + * in preview mode (empty or not) need to be ignored in non-preview mode. + * + *

To account for this, the following flags are used for each module + * reference in a package node: + *

    + *
  • {@code HAS_NORMAL_CONTENT}: Packages with resources in normal + * mode. At most one entry will have this flag set. + *
  • {@code HAS_PREVIEW_CONTENT}: Packages with resources in preview + * mode. At most one entry will have this flag set. + *
  • {@code IS_PREVIEW_ONLY}: This is set for packages, empty + * or not, which exist only in preview mode. + *
+ * + *

While there are 8 combinations of these 3 flags, some will never + * occur (e.g. {@code HAS_NORMAL_CONTENT + IS_PREVIEW_ONLY}). + * + *

Package node entries are sorted by name, with the exception that (if + * it exists) the unique entry marked as having content will be listed first. + * + *

When processing entries in normal (non preview) mode, entries marked + * with {@code IS_PREVIEW_ONLY} must be ignored. If, after filtering, there + * are no entries left, then the entire package must be ignored. + * + *

After this, in either mode, the content flag(s) of the first entry + * determine if that module contains resources for the package. + */ + // Visible for testing only. + static final class PackageNode extends Node { + private final List moduleReferences; + private final int packageFlags; - @Override - public String toString() { - return name + "[empty:" + isEmpty + "]"; - } + PackageNode(String name, List moduleReferences, Node parent) { + super(name, parent); + this.moduleReferences = Collections.unmodifiableList(moduleReferences); + this.packageFlags = validate(); } - private final Map references = new TreeMap<>(); - - PackageNode(String name, Node parent) { - super(name, parent); + List getModuleReferences() { + return moduleReferences; } - private void addReference(String name, boolean isEmpty) { - PackageReference ref = references.get(name); - if (ref == null || ref.isEmpty) { - references.put(name, new PackageReference(name, isEmpty)); + private int validate() { + if (moduleReferences.isEmpty()) { + throw new IllegalStateException("Package must be associated with modules: " + getName()); } + if (moduleReferences.stream().filter(ModuleReference::hasContent).count() > 1) { + throw new IllegalStateException("Multiple modules contain non-empty package: " + getName()); + } + // Calculate the package's ImageLocation flags. + boolean hasPreviewVersion = + moduleReferences.stream().anyMatch(ModuleReference::hasPreviewVersion); + boolean isPreviewOnly = + moduleReferences.stream().allMatch(ModuleReference::isPreviewOnly); + return (hasPreviewVersion ? ImageLocation.FLAGS_HAS_PREVIEW_VERSION : 0) + | (isPreviewOnly ? ImageLocation.FLAGS_IS_PREVIEW_ONLY : 0); } + } - private void validate() { - boolean exists = false; - for (PackageReference ref : references.values()) { - if (!ref.isEmpty) { - if (exists) { - throw new RuntimeException("Multiple modules to contain package " - + getName()); - } else { - exists = true; - } - } - } + // Not serialized, and never stored in any field of any class that is. + @SuppressWarnings("serial") + private static final class InvalidTreeException extends Exception { + public InvalidTreeException(Node badNode) { + super("Resources tree, invalid data structure, skipping: " + badNode.getPath()); } + // Exception only used for program flow, not debugging. + @Override + public Throwable fillInStackTrace() {return this;} } /** * Tree of nodes. */ - private static final class Tree { + // Visible for testing only. + static final class Tree { + private static final String PREVIEW_PREFIX = "META-INF/preview/"; private final Map directAccess = new HashMap<>(); private final List paths; private final Node root; - private Node modules; - private Node packages; + private Node packagesRoot; - private Tree(List paths) { - this.paths = paths; + // Visible for testing only. + Tree(List paths) { + this.paths = paths.stream().sorted(Comparator.reverseOrder()).toList(); + // Root node is not added to the directAccess map. root = new Node("", null); buildTree(); } private void buildTree() { - modules = new Node("modules", root); - directAccess.put(modules.getPath(), modules); - - Map> moduleToPackage = new TreeMap<>(); - Map> packageToModule = new TreeMap<>(); - - for (String p : paths) { - if (!p.startsWith("/")) { - continue; - } - String[] split = p.split("/"); - // minimum length is 3 items: // - if (split.length < 3) { - System.err.println("Resources tree, invalid data structure, " - + "skipping " + p); - continue; - } - Node current = modules; - String module = null; - for (int i = 0; i < split.length; i++) { - // When a non terminal node is marked as being a resource, something is wrong. + Node modulesRoot = new Node("modules", root); + directAccess.put(modulesRoot.getPath(), modulesRoot); + packagesRoot = new Node("packages", root); + directAccess.put(packagesRoot.getPath(), packagesRoot); + + // Map of dot-separated package names to module references (those + // in which the package appear). References are merged after to + // ensure each module name appears only once, but temporarily a + // module may have several entries per package (e.g. with-content, + // without-content, normal, preview-only etc..). + Map> packageToModules = new TreeMap<>(); + for (String fullPath : paths) { + try { + processPath(fullPath, modulesRoot, packageToModules); + } catch (InvalidTreeException err) { // It has been observed some badly created jar file to contain - // invalid directory entry marled as not directory (see 8131762) - if (current instanceof ResourceNode) { - System.err.println("Resources tree, invalid data structure, " - + "skipping " + p); - continue; - } - String s = split[i]; - if (!s.isEmpty()) { - // First item, this is the module, simply add a new node to the - // tree. - if (module == null) { - module = s; - } - Node n = current.children.get(s); - if (n == null) { - if (i == split.length - 1) { // Leaf - n = new ResourceNode(s, current); - String pkg = toPackageName(n.parent); - //System.err.println("Adding a resource node. pkg " + pkg + ", name " + s); - if (pkg != null && !pkg.startsWith("META-INF")) { - Set pkgs = moduleToPackage.get(module); - if (pkgs == null) { - pkgs = new TreeSet<>(); - moduleToPackage.put(module, pkgs); - } - pkgs.add(pkg); - } - } else { // put only sub trees, no leaf - n = new Node(s, current); - directAccess.put(n.getPath(), n); - String pkg = toPackageName(n); - if (pkg != null && !pkg.startsWith("META-INF")) { - Set mods = packageToModule.get(pkg); - if (mods == null) { - mods = new TreeSet<>(); - packageToModule.put(pkg, mods); - } - mods.add(module); - } - } - } - current = n; - } - } - } - packages = new Node("packages", root); - directAccess.put(packages.getPath(), packages); - // The subset of package nodes that have some content. - // These packages exist only in a single module. - for (Map.Entry> entry : moduleToPackage.entrySet()) { - for (String pkg : entry.getValue()) { - PackageNode pkgNode = new PackageNode(pkg, packages); - pkgNode.addReference(entry.getKey(), false); - directAccess.put(pkgNode.getPath(), pkgNode); + // invalid directory entry marked as not directory (see 8131762). + System.err.println(err.getMessage()); } } - // All packages - for (Map.Entry> entry : packageToModule.entrySet()) { - // Do we already have a package node? - PackageNode pkgNode = (PackageNode) packages.getChildren(entry.getKey()); - if (pkgNode == null) { - pkgNode = new PackageNode(entry.getKey(), packages); - } - for (String module : entry.getValue()) { - pkgNode.addReference(module, true); - } + // We've collected information for all "packages", including the root + // (empty) package and anything under "META-INF". However, these should + // not have entries in the "/packages" directory. + packageToModules.keySet().removeIf(p -> p.isEmpty() || p.equals("META-INF") || p.startsWith("META-INF.")); + packageToModules.forEach((pkgName, modRefs) -> { + // Merge multiple refs for the same module. + List pkgModules = modRefs.stream() + .collect(Collectors.groupingBy(ModuleReference::name)) + .values().stream() + .map(refs -> refs.stream().reduce(ModuleReference::merge).orElseThrow()) + .sorted() + .toList(); + PackageNode pkgNode = new PackageNode(pkgName, pkgModules, packagesRoot); directAccess.put(pkgNode.getPath(), pkgNode); + }); + } + + private void processPath( + String fullPath, + Node modulesRoot, + Map> packageToModules) + throws InvalidTreeException { + // Paths are untrusted, so be careful about checking expected format. + if (!fullPath.startsWith("/") || fullPath.endsWith("/") || fullPath.contains("//")) { + return; + } + int modEnd = fullPath.indexOf('/', 1); + // Ensure non-empty module name with non-empty suffix. + if (modEnd <= 1) { + return; } - // Validate that the packages are well formed. - for (Node n : packages.children.values()) { - ((PackageNode)n).validate(); + String modName = fullPath.substring(1, modEnd); + String pkgPath = fullPath.substring(modEnd + 1); + + Node parentNode = getDirectoryNode(modName, modulesRoot); + boolean isPreviewPath = false; + if (pkgPath.startsWith(PREVIEW_PREFIX)) { + // For preview paths, process nodes relative to the preview directory. + pkgPath = pkgPath.substring(PREVIEW_PREFIX.length()); + Node metaInf = getDirectoryNode("META-INF", parentNode); + parentNode = getDirectoryNode("preview", metaInf); + isPreviewPath = true; } + int pathEnd = pkgPath.lastIndexOf('/'); + // From invariants tested above, this must now be well-formed. + String fullPkgName = (pathEnd == -1) ? "" : pkgPath.substring(0, pathEnd).replace('/', '.'); + String resourceName = pkgPath.substring(pathEnd + 1); + // Intermediate packages are marked "empty" (no resources). This might + // later be merged with a non-empty reference for the same package. + ModuleReference emptyRef = ModuleReference.forEmptyPackage(modName, isPreviewPath); + + // Work down through empty packages to final resource. + for (int i = pkgEndIndex(fullPkgName, 0); i != -1; i = pkgEndIndex(fullPkgName, i)) { + // Due to invariants already checked, pkgName is non-empty. + String pkgName = fullPkgName.substring(0, i); + packageToModules.computeIfAbsent(pkgName, p -> new HashSet<>()).add(emptyRef); + String childNodeName = pkgName.substring(pkgName.lastIndexOf('.') + 1); + parentNode = getDirectoryNode(childNodeName, parentNode); + } + // Reached non-empty (leaf) package (could still be a duplicate). + Node resourceNode = parentNode.getChildren(resourceName); + if (resourceNode == null) { + ModuleReference resourceRef = ModuleReference.forResource(modName, isPreviewPath); + packageToModules.computeIfAbsent(fullPkgName, p -> new HashSet<>()).add(resourceRef); + // Init adds new node to parent (don't add resources to directAccess). + new ResourceNode(resourceName, parentNode); + } else if (!(resourceNode instanceof ResourceNode)) { + throw new InvalidTreeException(resourceNode); + } } - public String toResourceName(Node node) { - if (!node.children.isEmpty()) { - throw new RuntimeException("Node is not a resource"); + private Node getDirectoryNode(String name, Node parent) throws InvalidTreeException { + Node child = parent.getChildren(name); + if (child == null) { + // Adds child to parent during init. + child = new Node(name, parent); + directAccess.put(child.getPath(), child); + } else if (child instanceof ResourceNode) { + throw new InvalidTreeException(child); } - return removeRadical(node); + return child; } - public String getModule(Node node) { - if (node.parent == null || node.getName().equals("modules") - || node.getName().startsWith("packages")) { - return null; - } - String path = removeRadical(node); - // "/xxx/..."; - path = path.substring(1); - int i = path.indexOf("/"); - if (i == -1) { - return path; - } else { - return path.substring(0, i); + // Helper to iterate package names up to, and including, the complete name. + private int pkgEndIndex(String s, int i) { + if (i >= 0 && i < s.length()) { + i = s.indexOf('.', i + 1); + return i != -1 ? i : s.length(); } + return -1; } - public String toPackageName(Node node) { - if (node.parent == null) { - return null; - } - String path = removeRadical(node.getPath(), "/modules/"); - String module = getModule(node); - if (path.equals(module)) { - return null; + private String toResourceName(Node node) { + if (!node.children.isEmpty()) { + throw new RuntimeException("Node is not a resource"); } - String pkg = removeRadical(path, module + "/"); - return pkg.replace('/', '.'); + return removeRadical(node); } - public String removeRadical(Node node) { + private String removeRadical(Node node) { return removeRadical(node.getPath(), "/modules"); } @@ -339,9 +379,10 @@ private static final class LocationsAdder { private int addLocations(Node current) { if (current instanceof PackageNode) { + // "/packages/" entries have 8-byte entries (flags+offset). PackageNode pkgNode = (PackageNode) current; - int size = pkgNode.references.size() * 8; - writer.addLocation(current.getPath(), offset, 0, size); + int size = pkgNode.getModuleReferences().size() * 8; + writer.addLocation(current.getPath(), offset, 0, size, pkgNode.packageFlags); offset += size; } else { int[] ret = new int[current.children.size()]; @@ -351,8 +392,11 @@ private int addLocations(Node current) { i += 1; } if (current != tree.getRoot() && !(current instanceof ResourceNode)) { + int locFlags = ImageLocation.getFlags( + current.getPath(), tree.directAccess::containsKey); + // Normal directory entries have 4-byte entries (offset only). int size = ret.length * 4; - writer.addLocation(current.getPath(), offset, 0, size); + writer.addLocation(current.getPath(), offset, 0, size, locFlags); offset += size; } } @@ -369,7 +413,7 @@ private List computeContent() { for (Map.Entry entry : outLocations.entrySet()) { Node item = tree.getMap().get(entry.getKey()); if (item != null) { - item.loc = entry.getValue(); + item.setLocation(entry.getValue()); } } computeContent(tree.getRoot(), outLocations); @@ -378,18 +422,15 @@ private List computeContent() { private int computeContent(Node current, Map outLocations) { if (current instanceof PackageNode) { - // /packages/ + // "/packages/" entries have 8-byte entries (flags+offset). PackageNode pkgNode = (PackageNode) current; - int size = pkgNode.references.size() * 8; - ByteBuffer buff = ByteBuffer.allocate(size); - buff.order(writer.getByteOrder()); - for (PackageNode.PackageReference mod : pkgNode.references.values()) { - buff.putInt(mod.isEmpty ? 1 : 0); - buff.putInt(writer.addString(mod.name)); - } - byte[] arr = buff.array(); - content.add(arr); - current.loc = outLocations.get(current.getPath()); + + List refs = pkgNode.getModuleReferences(); + ByteBuffer byteBuffer = ByteBuffer.allocate(8 * refs.size()); + byteBuffer.order(writer.getByteOrder()); + ModuleReference.write(refs, byteBuffer.asIntBuffer(), writer::addString); + content.add(byteBuffer.array()); + current.setLocation(outLocations.get(current.getPath())); } else { int[] ret = new int[current.children.size()]; int i = 0; @@ -410,10 +451,10 @@ private int computeContent(Node current, Map outLoc if (current instanceof ResourceNode) { // A resource location, remove "/modules" String s = tree.toResourceName(current); - current.loc = outLocations.get(s); + current.setLocation(outLocations.get(s)); } else { // empty "/packages" or empty "/modules" paths - current.loc = outLocations.get(current.getPath()); + current.setLocation(outLocations.get(current.getPath())); } } if (current.loc == null && current != tree.getRoot()) { diff --git a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageStringsWriter.java b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageStringsWriter.java index 7ba9b7db72e..4dcbd955913 100644 --- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageStringsWriter.java +++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageStringsWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,6 @@ class ImageStringsWriter implements ImageStrings { private static final int NOT_FOUND = -1; - static final int EMPTY_OFFSET = 0; private final HashMap stringToOffsetMap; private final ImageStream stream; @@ -42,16 +41,17 @@ class ImageStringsWriter implements ImageStrings { this.stringToOffsetMap = new HashMap<>(); this.stream = new ImageStream(); - // Reserve 0 offset for empty string. - int offset = addString(""); - if (offset != 0) { - throw new InternalError("Empty string not offset zero"); - } + // Frequently used/special strings for which the offset is useful. + reserveString("", ImageStrings.EMPTY_STRING_OFFSET); + reserveString("class", ImageStrings.CLASS_STRING_OFFSET); + reserveString("modules", ImageStrings.MODULES_STRING_OFFSET); + reserveString("packages", ImageStrings.PACKAGES_STRING_OFFSET); + } - // Reserve 1 offset for frequently used ".class". - offset = addString("class"); - if (offset != 1) { - throw new InternalError("'class' string not offset one"); + private void reserveString(String value, int expectedOffset) { + int offset = addString(value); + if (offset != expectedOffset) { + throw new InternalError("Reserved string \"" + value + "\" not at expected offset " + expectedOffset + "[was " + offset + "]"); } } diff --git a/test/jdk/jdk/internal/jimage/ImageReaderTest.java b/test/jdk/jdk/internal/jimage/ImageReaderTest.java index de52ed1503d..74ae7b3a20a 100644 --- a/test/jdk/jdk/internal/jimage/ImageReaderTest.java +++ b/test/jdk/jdk/internal/jimage/ImageReaderTest.java @@ -23,6 +23,7 @@ import jdk.internal.jimage.ImageReader; import jdk.internal.jimage.ImageReader.Node; +import jdk.internal.jimage.PreviewMode; import jdk.test.lib.compiler.InMemoryJavaCompiler; import jdk.test.lib.util.JarBuilder; import jdk.tools.jlink.internal.LinkableRuntimeImage; @@ -43,6 +44,7 @@ import java.util.Set; import java.util.stream.Collectors; +import static java.util.stream.Collectors.toSet; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -63,22 +65,33 @@ * @library /test/jdk/tools/lib * /test/lib * @build tests.* - * @run junit/othervm ImageReaderTest + * @run junit/othervm -esa ImageReaderTest */ /// Using PER_CLASS lifecycle means the (expensive) image file is only build once. /// There is no mutable test instance state to worry about. @TestInstance(PER_CLASS) public class ImageReaderTest { - + // The '@' prefix marks the entry as a preview entry which will be placed in + // the '/modules//META-INF/preview/...' namespace. private static final Map> IMAGE_ENTRIES = Map.of( "modfoo", Arrays.asList( - "com.foo.Alpha", - "com.foo.Beta", - "com.foo.bar.Gamma"), + "com.foo.HasPreviewVersion", + "com.foo.NormalFoo", + "com.foo.bar.NormalBar", + // Replaces original class in preview mode. + "@com.foo.HasPreviewVersion", + // New class in existing package in preview mode. + "@com.foo.bar.IsPreviewOnly"), "modbar", Arrays.asList( "com.bar.One", - "com.bar.Two")); + "com.bar.Two", + // Two new packages in preview mode (new symbolic links). + "@com.bar.preview.stuff.Foo", + "@com.bar.preview.stuff.Bar"), + "modgus", Arrays.asList( + // A second module with a preview-only empty package (preview). + "@com.bar.preview.other.Gus")); private final Path image = buildJImage(IMAGE_ENTRIES); @ParameterizedTest @@ -91,7 +104,7 @@ public class ImageReaderTest { "/modules/modfoo/com/foo", "/modules/modfoo/com/foo/bar"}) public void testModuleDirectories_expected(String name) throws IOException { - try (ImageReader reader = ImageReader.open(image)) { + try (ImageReader reader = ImageReader.open(image, PreviewMode.DISABLED)) { assertDir(reader, name); } } @@ -106,32 +119,32 @@ public void testModuleDirectories_expected(String name) throws IOException { "/modules/modfoo//com", "/modules/modfoo/com/"}) public void testModuleNodes_absent(String name) throws IOException { - try (ImageReader reader = ImageReader.open(image)) { + try (ImageReader reader = ImageReader.open(image, PreviewMode.DISABLED)) { assertAbsent(reader, name); } } @Test public void testModuleResources() throws IOException { - try (ImageReader reader = ImageReader.open(image)) { - assertNode(reader, "/modules/modfoo/com/foo/Alpha.class"); + try (ImageReader reader = ImageReader.open(image, PreviewMode.DISABLED)) { + assertNode(reader, "/modules/modfoo/com/foo/HasPreviewVersion.class"); assertNode(reader, "/modules/modbar/com/bar/One.class"); ImageClassLoader loader = new ImageClassLoader(reader, IMAGE_ENTRIES.keySet()); - assertEquals("Class: com.foo.Alpha", loader.loadAndGetToString("modfoo", "com.foo.Alpha")); - assertEquals("Class: com.foo.Beta", loader.loadAndGetToString("modfoo", "com.foo.Beta")); - assertEquals("Class: com.foo.bar.Gamma", loader.loadAndGetToString("modfoo", "com.foo.bar.Gamma")); + assertEquals("Class: com.foo.HasPreviewVersion", loader.loadAndGetToString("modfoo", "com.foo.HasPreviewVersion")); + assertEquals("Class: com.foo.NormalFoo", loader.loadAndGetToString("modfoo", "com.foo.NormalFoo")); + assertEquals("Class: com.foo.bar.NormalBar", loader.loadAndGetToString("modfoo", "com.foo.bar.NormalBar")); assertEquals("Class: com.bar.One", loader.loadAndGetToString("modbar", "com.bar.One")); } } @ParameterizedTest @CsvSource(delimiter = ':', value = { - "modfoo:com/foo/Alpha.class", + "modfoo:com/foo/HasPreviewVersion.class", "modbar:com/bar/One.class", }) public void testResource_present(String modName, String resPath) throws IOException { - try (ImageReader reader = ImageReader.open(image)) { + try (ImageReader reader = ImageReader.open(image, PreviewMode.DISABLED)) { assertNotNull(reader.findResourceNode(modName, resPath)); assertTrue(reader.containsResource(modName, resPath)); @@ -147,18 +160,18 @@ public void testResource_present(String modName, String resPath) throws IOExcept "modfoo:/com/bar/One.class", // Resource in wrong module. "modfoo:com/bar/One.class", - "modbar:com/foo/Alpha.class", + "modbar:com/foo/HasPreviewVersion.class", // Directories are not returned. "modfoo:com/foo", "modbar:com/bar", // JImage entries exist for these, but they are not resources. - "modules:modfoo/com/foo/Alpha.class", + "modules:modfoo/com/foo/HasPreviewVersion.class", "packages:com.foo/modfoo", // Empty module names/paths do not find resources. - "'':modfoo/com/foo/Alpha.class", + "'':modfoo/com/foo/HasPreviewVersion.class", "modfoo:''"}) public void testResource_absent(String modName, String resPath) throws IOException { - try (ImageReader reader = ImageReader.open(image)) { + try (ImageReader reader = ImageReader.open(image, PreviewMode.DISABLED)) { assertNull(reader.findResourceNode(modName, resPath)); assertFalse(reader.containsResource(modName, resPath)); @@ -175,10 +188,10 @@ public void testResource_absent(String modName, String resPath) throws IOExcepti // Don't permit module names to contain paths. "modfoo/com/bar:One.class", "modfoo/com:bar/One.class", - "modules/modfoo/com:foo/Alpha.class", + "modules/modfoo/com:foo/HasPreviewVersion.class", }) public void testResource_invalid(String modName, String resPath) throws IOException { - try (ImageReader reader = ImageReader.open(image)) { + try (ImageReader reader = ImageReader.open(image, PreviewMode.DISABLED)) { assertThrows(IllegalArgumentException.class, () -> reader.containsResource(modName, resPath)); assertThrows(IllegalArgumentException.class, () -> reader.findResourceNode(modName, resPath)); } @@ -186,9 +199,9 @@ public void testResource_invalid(String modName, String resPath) throws IOExcept @Test public void testPackageDirectories() throws IOException { - try (ImageReader reader = ImageReader.open(image)) { + try (ImageReader reader = ImageReader.open(image, PreviewMode.DISABLED)) { Node root = assertDir(reader, "/packages"); - Set pkgNames = root.getChildNames().collect(Collectors.toSet()); + Set pkgNames = root.getChildNames().collect(toSet()); assertTrue(pkgNames.contains("/packages/com")); assertTrue(pkgNames.contains("/packages/com.foo")); assertTrue(pkgNames.contains("/packages/com.bar")); @@ -203,7 +216,7 @@ public void testPackageDirectories() throws IOException { @Test public void testPackageLinks() throws IOException { - try (ImageReader reader = ImageReader.open(image)) { + try (ImageReader reader = ImageReader.open(image, PreviewMode.DISABLED)) { Node moduleFoo = assertDir(reader, "/modules/modfoo"); Node moduleBar = assertDir(reader, "/modules/modbar"); assertSame(assertLink(reader, "/packages/com.foo/modfoo").resolveLink(), moduleFoo); @@ -211,6 +224,123 @@ public void testPackageLinks() throws IOException { } } + @Test + public void testPreviewResources_disabled() throws IOException { + try (ImageReader reader = ImageReader.open(image, PreviewMode.DISABLED)) { + ImageClassLoader loader = new ImageClassLoader(reader, IMAGE_ENTRIES.keySet()); + + // No preview classes visible. + assertEquals("Class: com.foo.HasPreviewVersion", loader.loadAndGetToString("modfoo", "com.foo.HasPreviewVersion")); + assertEquals("Class: com.foo.NormalFoo", loader.loadAndGetToString("modfoo", "com.foo.NormalFoo")); + assertEquals("Class: com.foo.bar.NormalBar", loader.loadAndGetToString("modfoo", "com.foo.bar.NormalBar")); + + // NormalBar exists but IsPreviewOnly doesn't. + assertResource(reader, "modfoo", "com/foo/bar/NormalBar.class"); + assertAbsent(reader, "/modules/modfoo/com/foo/bar/IsPreviewOnly.class"); + assertDirContents(reader, "/modules/modfoo/com/foo", "HasPreviewVersion.class", "NormalFoo.class", "bar"); + assertDirContents(reader, "/modules/modfoo/com/foo/bar", "NormalBar.class"); + } + } + + @Test + public void testPreviewResources_enabled() throws IOException { + try (ImageReader reader = ImageReader.open(image, PreviewMode.ENABLED)) { + ImageClassLoader loader = new ImageClassLoader(reader, IMAGE_ENTRIES.keySet()); + + // Preview version of classes either overwrite existing entries or are added to directories. + assertEquals("Preview: com.foo.HasPreviewVersion", loader.loadAndGetToString("modfoo", "com.foo.HasPreviewVersion")); + assertEquals("Class: com.foo.NormalFoo", loader.loadAndGetToString("modfoo", "com.foo.NormalFoo")); + assertEquals("Class: com.foo.bar.NormalBar", loader.loadAndGetToString("modfoo", "com.foo.bar.NormalBar")); + assertEquals("Preview: com.foo.bar.IsPreviewOnly", loader.loadAndGetToString("modfoo", "com.foo.bar.IsPreviewOnly")); + + // Both NormalBar and IsPreviewOnly exist (direct lookup and as child nodes). + assertResource(reader, "modfoo", "com/foo/bar/NormalBar.class"); + assertResource(reader, "modfoo", "com/foo/bar/IsPreviewOnly.class"); + assertDirContents(reader, "/modules/modfoo/com/foo", "HasPreviewVersion.class", "NormalFoo.class", "bar"); + assertDirContents(reader, "/modules/modfoo/com/foo/bar", "NormalBar.class", "IsPreviewOnly.class"); + } + } + + @Test + public void testPreviewOnlyPackages_disabled() throws IOException { + try (ImageReader reader = ImageReader.open(image, PreviewMode.DISABLED)) { + ImageClassLoader loader = new ImageClassLoader(reader, IMAGE_ENTRIES.keySet()); + + // No 'preview' package or anything inside it. + assertDirContents(reader, "/modules/modbar/com/bar", "One.class", "Two.class"); + assertAbsent(reader, "/modules/modbar/com/bar/preview"); + assertAbsent(reader, "/modules/modbar/com/bar/preview/stuff/Foo.class"); + + // And no package link. + assertAbsent(reader, "/packages/com.bar.preview"); + } + } + + @Test + public void testPreviewOnlyPackages_enabled() throws IOException { + try (ImageReader reader = ImageReader.open(image, PreviewMode.ENABLED)) { + ImageClassLoader loader = new ImageClassLoader(reader, IMAGE_ENTRIES.keySet()); + + // In preview mode 'preview' package exists with preview only content. + assertDirContents(reader, "/modules/modbar/com/bar", "One.class", "Two.class", "preview"); + assertDirContents(reader, "/modules/modbar/com/bar/preview/stuff", "Foo.class", "Bar.class"); + assertResource(reader, "modbar", "com/bar/preview/stuff/Foo.class"); + + // And package links exists. + assertDirContents(reader, "/packages/com.bar.preview", "modbar", "modgus"); + } + } + + @Test + public void testPreviewModeLinks_disabled() throws IOException { + try (ImageReader reader = ImageReader.open(image, PreviewMode.DISABLED)) { + assertDirContents(reader, "/packages/com.bar", "modbar"); + // Missing symbolic link and directory when not in preview mode. + assertAbsent(reader, "/packages/com.bar.preview"); + assertAbsent(reader, "/packages/com.bar.preview.stuff"); + assertAbsent(reader, "/modules/modbar/com/bar/preview"); + assertAbsent(reader, "/modules/modbar/com/bar/preview/stuff"); + } + } + + @Test + public void testPreviewModeLinks_enabled() throws IOException { + try (ImageReader reader = ImageReader.open(image, PreviewMode.ENABLED)) { + // In preview mode there is a new preview-only module visible. + assertDirContents(reader, "/packages/com.bar", "modbar", "modgus"); + // And additional packages are present. + assertDirContents(reader, "/packages/com.bar.preview", "modbar", "modgus"); + assertDirContents(reader, "/packages/com.bar.preview.stuff", "modbar"); + assertDirContents(reader, "/packages/com.bar.preview.other", "modgus"); + // And the preview-only content appears as we expect. + assertDirContents(reader, "/modules/modbar/com/bar", "One.class", "Two.class", "preview"); + assertDirContents(reader, "/modules/modbar/com/bar/preview", "stuff"); + assertDirContents(reader, "/modules/modbar/com/bar/preview/stuff", "Foo.class", "Bar.class"); + // In both modules in which it was added. + assertDirContents(reader, "/modules/modgus/com/bar", "preview"); + assertDirContents(reader, "/modules/modgus/com/bar/preview", "other"); + assertDirContents(reader, "/modules/modgus/com/bar/preview/other", "Gus.class"); + } + } + + @ParameterizedTest + @ValueSource(booleans = {false, true}) + public void testPreviewEntriesAlwaysHidden(boolean previewMode) throws IOException { + try (ImageReader reader = ImageReader.open(image, previewMode ? PreviewMode.ENABLED : PreviewMode.DISABLED)) { + // The META-INF directory exists, but does not contain the preview directory. + Node dir = assertDir(reader, "/modules/modfoo/META-INF"); + assertEquals(0, dir.getChildNames().filter(n -> n.endsWith("/preview")).count()); + // Neither the preview directory, nor anything in it, can be looked-up directly. + assertAbsent(reader, "/modules/modfoo/META-INF/preview"); + assertAbsent(reader, "/modules/modfoo/META-INF/preview/com/foo"); + // HasPreviewVersion.class is a preview class in the test data, and thus appears in + // two places in the jimage). Ensure the preview version is always hidden. + String alphaPath = "com/foo/HasPreviewVersion.class"; + assertNode(reader, "/modules/modfoo/" + alphaPath); + assertAbsent(reader, "/modules/modfoo/META-INF/preview/" + alphaPath); + } + } + private static ImageReader.Node assertNode(ImageReader reader, String name) throws IOException { ImageReader.Node node = reader.findNode(name); assertNotNull(node, "Could not find node: " + name); @@ -223,9 +353,30 @@ private static ImageReader.Node assertDir(ImageReader reader, String name) throw return dir; } + private static void assertDirContents(ImageReader reader, String name, String... expectedChildNames) throws IOException { + Node dir = assertDir(reader, name); + Set localChildNames = dir.getChildNames() + .peek(s -> assertTrue(s.startsWith(name + "/"))) + .map(s -> s.substring(name.length() + 1)) + .collect(toSet()); + assertEquals( + Set.of(expectedChildNames), + localChildNames, + String.format("Unexpected child names in directory '%s'", name)); + } + + private static void assertResource(ImageReader reader, String modName, String resPath) throws IOException { + assertTrue(reader.containsResource(modName, resPath), "Resource should exist: " + modName + "/" + resPath); + Node resNode = reader.findResourceNode(modName, resPath); + assertTrue(resNode.isResource(), "Node should be a resource: " + resNode.getName()); + String nodeName = "/modules/" + modName + "/" + resPath; + assertEquals(nodeName, resNode.getName()); + assertSame(resNode, reader.findNode(nodeName)); + } + private static ImageReader.Node assertLink(ImageReader reader, String name) throws IOException { ImageReader.Node link = assertNode(reader, name); - assertTrue(link.isLink(), "Node was not a symbolic link: " + name); + assertTrue(link.isLink(), "Node should be a symbolic link: " + link.getName()); return link; } @@ -250,20 +401,23 @@ public static Path buildJImage(Map> entries) { jar.addEntry("module-info.class", InMemoryJavaCompiler.compile("module-info", moduleInfo)); classes.forEach(fqn -> { + boolean isPreviewEntry = fqn.startsWith("@"); + if (isPreviewEntry) { + fqn = fqn.substring(1); + } int lastDot = fqn.lastIndexOf('.'); String pkg = fqn.substring(0, lastDot); String cls = fqn.substring(lastDot + 1); - - String path = fqn.replace('.', '/') + ".class"; String source = String.format( """ package %s; public class %s { public String toString() { - return "Class: %s"; + return "%s: %s"; } } - """, pkg, cls, fqn); + """, pkg, cls, isPreviewEntry ? "Preview" : "Class", fqn); + String path = (isPreviewEntry ? "META-INF/preview/" : "") + fqn.replace('.', '/') + ".class"; jar.addEntry(path, InMemoryJavaCompiler.compile(fqn, source)); }); try { diff --git a/test/jdk/jdk/internal/jimage/JImageReadTest.java b/test/jdk/jdk/internal/jimage/JImageReadTest.java index 35fb2adb687..46e93a8996c 100644 --- a/test/jdk/jdk/internal/jimage/JImageReadTest.java +++ b/test/jdk/jdk/internal/jimage/JImageReadTest.java @@ -42,6 +42,7 @@ import jdk.internal.jimage.ImageReader; import jdk.internal.jimage.ImageLocation; +import jdk.internal.jimage.PreviewMode; import org.testng.annotations.DataProvider; import org.testng.annotations.Optional; import org.testng.annotations.Parameters; @@ -337,16 +338,16 @@ static void test4_nameTooLong() throws IOException { @Test static void test5_imageReaderEndianness() throws IOException { // Will be opened with native byte order. - try (ImageReader nativeReader = ImageReader.open(imageFile)) { + try (ImageReader nativeReader = ImageReader.open(imageFile, PreviewMode.DISABLED)) { // Just ensure something works as expected. Assert.assertNotNull(nativeReader.findNode("/")); - } catch (IOException expected) { + } catch (IOException unexpected) { Assert.fail("Reader should be openable with native byte order."); } // Reader should not be openable with the wrong byte order. ByteOrder otherOrder = ByteOrder.nativeOrder() == BIG_ENDIAN ? LITTLE_ENDIAN : BIG_ENDIAN; - Assert.assertThrows(IOException.class, () -> ImageReader.open(imageFile, otherOrder)); + Assert.assertThrows(IOException.class, () -> ImageReader.open(imageFile, otherOrder, PreviewMode.DISABLED)); } // main method to run standalone from jtreg diff --git a/test/jdk/jdk/internal/jimage/ModuleReferenceTest.java b/test/jdk/jdk/internal/jimage/ModuleReferenceTest.java new file mode 100644 index 00000000000..82b96a98e5c --- /dev/null +++ b/test/jdk/jdk/internal/jimage/ModuleReferenceTest.java @@ -0,0 +1,240 @@ +/* + * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import jdk.internal.jimage.ModuleReference; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +import java.nio.IntBuffer; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.Iterator; +import java.util.List; +import java.util.function.Function; +import java.util.function.Predicate; + +import static java.util.function.Predicate.not; +import static jdk.internal.jimage.ModuleReference.forEmptyPackage; +import static jdk.internal.jimage.ModuleReference.forResource; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/* + * @test + * @summary Tests for ModuleReference. + * @modules java.base/jdk.internal.jimage + * @run junit/othervm -esa ModuleReferenceTest + */ +public final class ModuleReferenceTest { + // Copied (not referenced) for testing. + private static final int FLAGS_HAS_CONTENT = 0x1; + private static final int FLAGS_HAS_NORMAL_VERSION = 0x2; + private static final int FLAGS_HAS_PREVIEW_VERSION = 0x4; + + @ParameterizedTest + @ValueSource(booleans = {false, true}) + public void emptyRefs(boolean isPreview) { + ModuleReference ref = forEmptyPackage("module", isPreview); + + assertEquals("module", ref.name()); + assertFalse(ref.hasContent()); + assertEquals(isPreview, ref.hasPreviewVersion()); + assertEquals(isPreview, ref.isPreviewOnly()); + } + + @ParameterizedTest + @ValueSource(booleans = {false, true}) + public void resourceRefs(boolean isPreview) { + ModuleReference ref = forResource("module", isPreview); + + assertEquals("module", ref.name()); + assertTrue(ref.hasContent()); + assertEquals(isPreview, ref.hasPreviewVersion()); + assertEquals(isPreview, ref.isPreviewOnly()); + } + + @ParameterizedTest + @ValueSource(booleans = {false, true}) + public void mergedRefs(boolean isPreview) { + ModuleReference emptyRef = forEmptyPackage("module", true); + ModuleReference resourceRef = forResource("module", isPreview); + ModuleReference merged = emptyRef.merge(resourceRef); + + // Merging preserves whether there's content. + assertTrue(merged.hasContent()); + // And clears the preview-only status unless it was set in both. + assertEquals(isPreview, merged.isPreviewOnly()); + } + + @Test + public void writeBuffer() { + List refs = Arrays.asList( + forEmptyPackage("alpha", true), + forEmptyPackage("beta", false).merge(forEmptyPackage("beta", true)), + forResource("gamma", false), + forEmptyPackage("zeta", false)); + IntBuffer buffer = IntBuffer.allocate(2 * refs.size()); + ModuleReference.write(refs, buffer, testEncoder()); + assertArrayEquals( + new int[]{ + FLAGS_HAS_PREVIEW_VERSION, 100, + FLAGS_HAS_NORMAL_VERSION | FLAGS_HAS_PREVIEW_VERSION, 101, + FLAGS_HAS_NORMAL_VERSION | FLAGS_HAS_CONTENT, 102, + FLAGS_HAS_NORMAL_VERSION, 103}, + buffer.array()); + } + + @Test + public void writeBuffer_emptyList() { + IntBuffer buffer = IntBuffer.allocate(0); + var err = assertThrows( + IllegalArgumentException.class, + () -> ModuleReference.write(List.of(), buffer, null)); + assertTrue(err.getMessage().contains("non-empty")); + } + + @Test + public void writeBuffer_badCapacity() { + List refs = Arrays.asList( + forResource("first", false), + forEmptyPackage("alpha", false)); + IntBuffer buffer = IntBuffer.allocate(10); + var err = assertThrows( + IllegalArgumentException.class, + () -> ModuleReference.write(refs, buffer, null)); + assertTrue(err.getMessage().contains("buffer capacity")); + } + + @Test + public void writeBuffer_multipleContent() { + // Only one module reference (at most) can have resources. + List refs = Arrays.asList( + forResource("alpha", false), + forResource("beta", false)); + IntBuffer buffer = IntBuffer.allocate(2 * refs.size()); + var err = assertThrows( + IllegalArgumentException.class, + () -> ModuleReference.write(refs, buffer, null)); + assertTrue(err.getMessage().contains("content")); + } + + @Test + public void writeBuffer_badOrdering() { + // Badly ordered because preview references should come first. + List refs = Arrays.asList( + forEmptyPackage("alpha", false), + forEmptyPackage("beta", true)); + IntBuffer buffer = IntBuffer.allocate(2 * refs.size()); + var err = assertThrows( + IllegalArgumentException.class, + () -> ModuleReference.write(refs, buffer, null)); + assertTrue(err.getMessage().contains("strictly ordered")); + } + + @Test + public void writeBuffer_duplicateRef() { + // Technically distinct, and correctly sorted, but with duplicate names. + List refs = Arrays.asList( + forEmptyPackage("duplicate", true), + forEmptyPackage("duplicate", false)); + IntBuffer buffer = IntBuffer.allocate(2 * refs.size()); + var err = assertThrows( + IllegalArgumentException.class, + () -> ModuleReference.write(refs, buffer, null)); + assertTrue(err.getMessage().contains("unique")); + } + + @Test + public void readNameOffsets() { + // Preview versions must be first (important for early exit). + IntBuffer buffer = IntBuffer.wrap(new int[]{ + FLAGS_HAS_NORMAL_VERSION | FLAGS_HAS_PREVIEW_VERSION, 100, + FLAGS_HAS_PREVIEW_VERSION, 101, + FLAGS_HAS_NORMAL_VERSION | FLAGS_HAS_CONTENT, 102, + FLAGS_HAS_NORMAL_VERSION, 103}); + + List normalOffsets = asList(ModuleReference.readNameOffsets(buffer, true, false)); + List previewOffsets = asList(ModuleReference.readNameOffsets(buffer, false, true)); + List allOffsets = asList(ModuleReference.readNameOffsets(buffer, true, true)); + + assertEquals(List.of(100, 102, 103), normalOffsets); + assertEquals(List.of(100, 101), previewOffsets); + assertEquals(List.of(100, 101, 102, 103), allOffsets); + } + + @Test + public void readNameOffsets_badBufferSize() { + var err = assertThrows( + IllegalArgumentException.class, + () -> ModuleReference.readNameOffsets(IntBuffer.allocate(3), true, false)); + assertTrue(err.getMessage().contains("buffer size")); + } + + @Test + public void readNameOffsets_badFlags() { + IntBuffer buffer = IntBuffer.wrap(new int[]{FLAGS_HAS_CONTENT, 100}); + var err = assertThrows( + IllegalArgumentException.class, + () -> ModuleReference.readNameOffsets(buffer, false, false)); + assertTrue(err.getMessage().contains("flags")); + } + + @Test + public void sortOrder_previewFirst() { + List refs = Arrays.asList( + forEmptyPackage("normal.beta", false), + forResource("preview.beta", true), + forEmptyPackage("preview.alpha", true), + forEmptyPackage("normal.alpha", false)); + refs.sort(Comparator.naturalOrder()); + // Non-empty first with remaining sorted by name. + assertEquals( + List.of("preview.alpha", "preview.beta", "normal.alpha", "normal.beta"), + refs.stream().map(ModuleReference::name).toList()); + } + + private static List asList(Iterator src) { + List list = new ArrayList<>(); + src.forEachRemaining(list::add); + return list; + } + + // Encodes strings sequentially starting from index 100. + private static Function testEncoder() { + List cache = new ArrayList<>(); + return s -> { + int i = cache.indexOf(s); + if (i == -1) { + cache.add(s); + return 100 + (cache.size() - 1); + } else { + return 100 + i; + } + }; + } +} diff --git a/test/jdk/tools/jimage/ImageReaderDuplicateChildNodesTest.java b/test/jdk/tools/jimage/ImageReaderDuplicateChildNodesTest.java index 3eed3bf972c..bf0855f273f 100644 --- a/test/jdk/tools/jimage/ImageReaderDuplicateChildNodesTest.java +++ b/test/jdk/tools/jimage/ImageReaderDuplicateChildNodesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,7 +54,7 @@ public static void main(final String[] args) throws Exception { System.out.println("Running test against image " + imagePath); final String integersParentResource = "/modules/java.base/java/lang"; final String integerResource = integersParentResource + "/Integer.class"; - try (final ImageReader reader = ImageReader.open(imagePath)) { + try (final ImageReader reader = ImageReader.open(imagePath, /* previewMode */ false)) { // find the child node/resource first final ImageReader.Node integerNode = reader.findNode(integerResource); if (integerNode == null) { diff --git a/test/jdk/tools/jlink/whitebox/ImageResourcesTreeTestDriver.java b/test/jdk/tools/jlink/whitebox/ImageResourcesTreeTestDriver.java new file mode 100644 index 00000000000..6c1d18d6d46 --- /dev/null +++ b/test/jdk/tools/jlink/whitebox/ImageResourcesTreeTestDriver.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary Whitebox tests for ImageResourcesTree. + * @modules jdk.jlink/jdk.tools.jlink.internal + * @build jdk.jlink/jdk.tools.jlink.internal.ImageResourcesTreeTest + * @run junit/othervm jdk.jlink/jdk.tools.jlink.internal.ImageResourcesTreeTest + */ +public class ImageResourcesTreeTestDriver {} diff --git a/test/jdk/tools/jlink/whitebox/TEST.properties b/test/jdk/tools/jlink/whitebox/TEST.properties new file mode 100644 index 00000000000..35196da49bf --- /dev/null +++ b/test/jdk/tools/jlink/whitebox/TEST.properties @@ -0,0 +1,3 @@ +modules = \ + jdk.jlink/jdk.tools.jlink.internal +bootclasspath.dirs=. diff --git a/test/jdk/tools/jlink/whitebox/jdk.jlink/jdk/tools/jlink/internal/ImageResourcesTreeTest.java b/test/jdk/tools/jlink/whitebox/jdk.jlink/jdk/tools/jlink/internal/ImageResourcesTreeTest.java new file mode 100644 index 00000000000..bb38c93749c --- /dev/null +++ b/test/jdk/tools/jlink/whitebox/jdk.jlink/jdk/tools/jlink/internal/ImageResourcesTreeTest.java @@ -0,0 +1,275 @@ +/* + * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.tools.jlink.internal; + +import jdk.tools.jlink.internal.ImageResourcesTree.Node; +import jdk.tools.jlink.internal.ImageResourcesTree.PackageNode; +import jdk.tools.jlink.internal.ImageResourcesTree.PackageNode.PackageReference; +import jdk.tools.jlink.internal.ImageResourcesTree.ResourceNode; +import jdk.tools.jlink.internal.ImageResourcesTree.Tree; +import org.junit.jupiter.api.Test; + +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class ImageResourcesTreeTest { + + private static final String MODULES_PREFIX = "/modules/"; + private static final String PACKAGES_PREFIX = "/packages/"; + + // Package entry flags copied from ImageResourcesTree. + private static final int PKG_FLAG_HAS_NORMAL_CONTENT = 0x1; + private static final int PKG_FLAG_HAS_PREVIEW_CONTENT = 0x2; + private static final int PKG_FLAG_IS_PREVIEW_ONLY = 0x4; + + @Test + public void directoryNodes() { + List paths = List.of( + "/java.base/java/util/SomeClass.class", + "/java.base/java/util/SomeOtherClass.class", + "/java.base/java/util/resource.txt", + "/java.logging/java/util/logging/LoggingClass.class", + "/java.logging/java/util/logging/OtherLoggingClass.class"); + + Tree tree = new Tree(paths); + Map nodes = tree.getMap(); + + // All paths from the root (but not the root itself). + assertTrue(nodes.containsKey("/modules")); + assertTrue(nodes.containsKey("/modules/java.base")); + assertTrue(nodes.containsKey("/modules/java.base/java")); + assertTrue(nodes.containsKey("/modules/java.base/java/util")); + assertFalse(nodes.containsKey("/")); + + // Check for mismatched modules. + assertTrue(nodes.containsKey("/modules/java.logging/java/util/logging")); + assertFalse(nodes.containsKey("/modules/java.base/java/util/logging")); + + Set dirPaths = nodes.keySet().stream() + .filter(p -> p.startsWith(MODULES_PREFIX)) + .collect(Collectors.toSet()); + for (String path : dirPaths) { + Node dir = nodes.get(path); + assertFalse(dir instanceof ResourceNode, "Unexpected resource: " + dir); + assertEquals(path, dir.getPath()); + assertTrue(path.endsWith("/" + dir.getName()), "Unexpected directory name: " + dir); + } + } + + @Test + public void resourceNodes() { + List paths = List.of( + "/java.base/java/util/SomeClass.class", + "/java.base/java/util/SomeOtherClass.class", + "/java.base/java/util/resource.txt", + "/java.logging/java/util/logging/LoggingClass.class", + "/java.logging/java/util/logging/OtherLoggingClass.class"); + + Tree tree = new Tree(paths); + // This map *does not* contain the resources, only the "directory" nodes. + Map nodes = tree.getMap(); + + assertContainsResources( + nodes.get("/modules/java.base/java/util"), + "SomeClass.class", "SomeOtherClass.class", "resource.txt"); + + assertContainsResources( + nodes.get("/modules/java.logging/java/util/logging"), + "LoggingClass.class", "OtherLoggingClass.class"); + } + + @Test + public void expectedPackages() { + // Paths are only to resources. Packages are inferred. + List paths = List.of( + "/java.base/java/util/SomeClass.class", + "/java.logging/java/util/logging/SomeClass.class"); + + Tree tree = new Tree(paths); + Map nodes = tree.getMap(); + Node packages = nodes.get("/packages"); + List pkgNames = nodes.keySet().stream() + .filter(p -> p.startsWith(PACKAGES_PREFIX)) + .map(p -> p.substring(PACKAGES_PREFIX.length())) + .sorted() + .toList(); + + assertEquals(List.of("java", "java.util", "java.util.logging"), pkgNames); + for (String pkgName : pkgNames) { + PackageNode pkgNode = assertInstanceOf(PackageNode.class, packages.getChildren(pkgName)); + assertSame(nodes.get(PACKAGES_PREFIX + pkgNode.getName()), pkgNode); + } + } + + @Test + public void expectedPackageEntries() { + List paths = List.of( + "/java.base/java/util/SomeClass.class", + "/java.logging/java/util/logging/SomeClass.class"); + + Tree tree = new Tree(paths); + Map nodes = tree.getMap(); + PackageNode pkgUtil = getPackageNode(nodes, "java.util"); + assertEquals(2, pkgUtil.moduleCount()); + List modRefs = pkgUtil.modules().toList(); + + List modNames = modRefs.stream().map(PackageReference::name).toList(); + assertEquals(List.of("java.base", "java.logging"), modNames); + + PackageReference baseRef = modRefs.get(0); + assertNonEmptyRef(baseRef, "java.base"); + assertEquals(PKG_FLAG_HAS_NORMAL_CONTENT, baseRef.flags()); + + PackageReference loggingRef = modRefs.get(1); + assertEmptyRef(loggingRef, "java.logging"); + assertEquals(0, loggingRef.flags()); + } + + @Test + public void expectedPackageEntries_withPreviewResources() { + List paths = List.of( + "/java.base/java/util/SomeClass.class", + "/java.base/java/util/OtherClass.class", + "/java.base/META-INF/preview/java/util/OtherClass.class", + "/java.logging/java/util/logging/SomeClass.class"); + + Tree tree = new Tree(paths); + Map nodes = tree.getMap(); + PackageNode pkgUtil = getPackageNode(nodes, "java.util"); + List modRefs = pkgUtil.modules().toList(); + + PackageReference baseRef = modRefs.get(0); + assertNonEmptyRef(baseRef, "java.base"); + assertEquals(PKG_FLAG_HAS_NORMAL_CONTENT | PKG_FLAG_HAS_PREVIEW_CONTENT, baseRef.flags()); + } + + @Test + public void expectedPackageEntries_withPreviewOnlyPackages() { + List paths = List.of( + "/java.base/java/util/SomeClass.class", + "/java.base/META-INF/preview/java/util/preview/only/PreviewClass.class"); + + Tree tree = new Tree(paths); + Map nodes = tree.getMap(); + + // Preview only package (with content). + PackageNode nonEmptyPkg = getPackageNode(nodes, "java.util.preview.only"); + PackageReference nonEmptyRef = nonEmptyPkg.modules().findFirst().orElseThrow(); + assertNonEmptyPreviewOnlyRef(nonEmptyRef, "java.base"); + assertEquals(PKG_FLAG_IS_PREVIEW_ONLY | PKG_FLAG_HAS_PREVIEW_CONTENT, nonEmptyRef.flags()); + + // Preview only packages can be empty. + PackageNode emptyPkg = getPackageNode(nodes, "java.util.preview"); + PackageReference emptyRef = emptyPkg.modules().findFirst().orElseThrow(); + assertEmptyPreviewOnlyRef(emptyRef, "java.base"); + assertEquals(PKG_FLAG_IS_PREVIEW_ONLY, emptyRef.flags()); + } + + @Test + public void expectedPackageEntries_sharedPackage() { + // Resource in many modules define the same package (java.shared). + // However, the package "java.shared" only has content in one module. + // Order of test data is shuffled to show reordering in entry list. + // "java.preview" would sort before after "java.resource" if it were + // only sorted by name, but the preview flag has precedence. + // Expect: content -> resource{1..6} -> preview{7..8} + List paths = List.of( + "/java.resource1/java/shared/one/SomeClass.class", + "/java.preview7/META-INF/preview/java/shared/foo/SomeClass.class", + "/java.resource3/java/shared/three/SomeClass.class", + "/java.resource6/java/shared/six/SomeClass.class", + "/java.preview8/META-INF/preview/java/shared/bar/SomeClass.class", + "/java.resource5/java/shared/five/SomeClass.class", + "/java.content/java/shared/MainPackageClass.class", + "/java.resource2/java/shared/two/SomeClass.class", + "/java.resource4/java/shared/four/SomeClass.class"); + + Tree tree = new Tree(paths); + Map nodes = tree.getMap(); + + // Preview only package (with content). + PackageNode sharedPkg = getPackageNode(nodes, "java.shared"); + assertEquals(9, sharedPkg.moduleCount()); + + List refs = sharedPkg.modules().toList(); + assertNonEmptyRef(refs.getFirst(), "java.content"); + assertEquals(PKG_FLAG_HAS_NORMAL_CONTENT, refs.getFirst().flags()); + + // Empty non-preview refs after non-empty ref. + int idx = 1; + for (PackageReference emptyRef : refs.subList(1, 7)) { + assertEmptyRef(emptyRef, "java.resource" + idx++); + assertEquals(0, emptyRef.flags()); + } + // Empty preview-only refs last. + for (PackageReference emptyRef : refs.subList(7, 9)) { + assertEmptyPreviewOnlyRef(emptyRef, "java.preview" + idx++); + assertEquals(PKG_FLAG_IS_PREVIEW_ONLY, emptyRef.flags()); + } + } + + static PackageNode getPackageNode(Map nodes, String pkgName) { + return assertInstanceOf(PackageNode.class, nodes.get(PACKAGES_PREFIX + pkgName)); + } + + static void assertContainsResources(Node dirNode, String... resourceNames) { + for (String name : resourceNames) { + Node node = assertInstanceOf(ResourceNode.class, dirNode.getChildren(name)); + assertEquals(name, node.getName()); + assertEquals(dirNode.getPath() + "/" + name, node.getPath()); + } + } + + static void assertNonEmptyRef(PackageReference ref, String modName) { + assertEquals(modName, ref.name(), "Unexpected module name: " + ref); + assertFalse(ref.isEmpty(), "Expected non-empty reference: " + ref); + assertFalse(ref.isPreviewOnly(), "Expected not preview-only: " + ref); + } + + static void assertEmptyRef(PackageReference ref, String modName) { + assertEquals(modName, ref.name(), "Unexpected module name: " + ref); + assertTrue(ref.isEmpty(), "Expected empty reference: " + ref); + assertFalse(ref.isPreviewOnly(), "Expected not preview-only: " + ref); + } + + static void assertNonEmptyPreviewOnlyRef(PackageReference ref, String modName) { + assertEquals(modName, ref.name(), "Unexpected module name: " + ref); + assertFalse(ref.isEmpty(), "Expected empty reference: " + ref); + assertTrue(ref.isPreviewOnly(), "Expected preview-only: " + ref); + } + + static void assertEmptyPreviewOnlyRef(PackageReference ref, String modName) { + assertEquals(modName, ref.name(), "Unexpected module name: " + ref); + assertTrue(ref.isEmpty(), "Expected empty reference: " + ref); + assertTrue(ref.isPreviewOnly(), "Expected preview-only: " + ref); + } +} diff --git a/test/micro/org/openjdk/bench/jdk/internal/jrtfs/ImageReaderBenchmark.java b/test/micro/org/openjdk/bench/jdk/internal/jrtfs/ImageReaderBenchmark.java index 4f97e12171f..f2e30bea2a1 100644 --- a/test/micro/org/openjdk/bench/jdk/internal/jrtfs/ImageReaderBenchmark.java +++ b/test/micro/org/openjdk/bench/jdk/internal/jrtfs/ImageReaderBenchmark.java @@ -24,6 +24,7 @@ import jdk.internal.jimage.ImageReader; import jdk.internal.jimage.ImageReader.Node; +import jdk.internal.jimage.PreviewMode; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; @@ -31,6 +32,7 @@ import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; @@ -39,15 +41,20 @@ import org.openjdk.jmh.infra.Blackhole; import java.io.IOException; -import java.nio.ByteOrder; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; +import static java.util.stream.Collectors.groupingBy; +import static java.util.stream.Collectors.mapping; +import static java.util.stream.Collectors.toList; /// Benchmarks for ImageReader. See individual benchmarks for details on what they /// measure, and their potential applicability for real world conclusions. @@ -67,16 +74,14 @@ public class ImageReaderBenchmark { } /// NOT annotated with `@State` since it needs to potentially be used as a - /// per-benchmark or a per-iteration state object. The subclasses provide + /// per-trial or a per-iteration state object. The subclasses provide /// any lifetime annotations that are needed. static class BaseState { protected Path copiedImageFile; - protected ByteOrder byteOrder; long count = 0; public void setUp() throws IOException { copiedImageFile = Files.createTempFile("copied_jimage", ""); - byteOrder = ByteOrder.nativeOrder(); Files.copy(SYSTEM_IMAGE_FILE, copiedImageFile, REPLACE_EXISTING); } @@ -86,14 +91,18 @@ public void tearDown() throws IOException { } } + /// A {@link Level#Trial per-trial} state which provides an image reader, + /// suitable for {@link Mode#AverageTime average time} benchmarks. @State(Scope.Benchmark) - public static class WarmStartWithImageReader extends BaseState { + public static class WarmStart extends BaseState { + @Param({"DISABLED", "ENABLED"}) + PreviewMode previewMode; ImageReader reader; @Setup(Level.Trial) public void setUp() throws IOException { super.setUp(); - reader = ImageReader.open(copiedImageFile, byteOrder); + reader = ImageReader.open(copiedImageFile, previewMode); } @TearDown(Level.Trial) @@ -102,8 +111,23 @@ public void tearDown() throws IOException { } } + @State(Scope.Benchmark) + public static class WarmStartWithCachedNodes extends WarmStart { + @Setup(Level.Trial) + public void setUp() throws IOException { + super.setUp(); + countAllNodes(reader, reader.findNode("/")); + } + } + + /// A {@link Level#Iteration per-iteration} state suitable for + /// {@link Mode#SingleShotTime single shot} benchmarks. Unlike + /// {@link WarmStart}, this state does not provide a reader instance. @State(Scope.Benchmark) public static class ColdStart extends BaseState { + @Param({"DISABLED", "ENABLED"}) + PreviewMode previewMode; + @Setup(Level.Iteration) public void setUp() throws IOException { super.setUp(); @@ -116,13 +140,13 @@ public void tearDown() throws IOException { } @State(Scope.Benchmark) - public static class ColdStartWithImageReader extends BaseState { + public static class ColdStartWithImageReader extends ColdStart { ImageReader reader; @Setup(Level.Iteration) public void setup() throws IOException { super.setUp(); - reader = ImageReader.open(copiedImageFile, byteOrder); + reader = ImageReader.open(copiedImageFile, previewMode); } @TearDown(Level.Iteration) @@ -137,10 +161,49 @@ public void tearDown() throws IOException { /// so this benchmark should be fast and very stable. @Benchmark @BenchmarkMode(Mode.AverageTime) - public void warmCache_CountAllNodes(WarmStartWithImageReader state) throws IOException { + public void warmStart_CountAllNodes(WarmStartWithCachedNodes state) throws IOException { state.count = countAllNodes(state.reader, state.reader.findNode("/")); } + /// Benchmarks {@link ImageReader#containsResource(String, String)} when no + /// nodes have been cached in the {@link ImageReader}. In non-preview mode, + /// this should be identical to the case where nodes are cached (because the + /// cache isn't used) but in preview mode, the cache will be tested for + /// preview resources, and thus differ depending on whether nodes are present. + /// + /// This doesn't need to be a cold start because it never modifies the nodes + /// cache. + @Benchmark + @BenchmarkMode(Mode.AverageTime) + public void warmStart_ContainsResource_emptyNodeCache(WarmStart state) throws IOException { + state.count = countContainsResource(state.reader, ClassList.pathMap()); + } + + /// As above, but the nodes cache has been filled, giving preview mode a + /// different code path. + @Benchmark + @BenchmarkMode(Mode.AverageTime) + public void warmStart_ContainsResource_fullNodeCache(WarmStartWithCachedNodes state) throws IOException { + state.count = countContainsResource(state.reader, ClassList.pathMap()); + } + + /// As {@link #warmStart_ContainsResource_emptyNodeCache}, but tests + /// {@link ImageReader#findResourceNode(String, String)}. + @Benchmark + @BenchmarkMode(Mode.AverageTime) + public void warmStart_FindResourceNode_emptyNodeCache(WarmStart state) throws IOException { + state.count = countFindResourceNode(state.reader, ClassList.pathMap()); + } + + /// As {@link #warmStart_ContainsResource_fullNodeCache}, but tests + /// {@link ImageReader#findResourceNode(String, String)}. + @Benchmark + @BenchmarkMode(Mode.AverageTime) + public void warmStart_FindResourceNode_fullNodeCache(WarmStartWithCachedNodes state) throws IOException { + state.count = countFindResourceNode(state.reader, ClassList.pathMap()); + } + + /// Benchmarks counting of all nodes in the system image from a "cold start". This /// visits all nodes in depth-first order and counts them. /// @@ -149,12 +212,12 @@ public void warmCache_CountAllNodes(WarmStartWithImageReader state) throws IOExc @Benchmark @BenchmarkMode(Mode.SingleShotTime) public void coldStart_InitAndCount(ColdStart state) throws IOException { - try (var reader = ImageReader.open(state.copiedImageFile, state.byteOrder)) { + try (var reader = ImageReader.open(state.copiedImageFile, state.previewMode)) { state.count = countAllNodes(reader, reader.findNode("/")); } } - /// As above, but includes the time to initialize the `ImageReader`. + /// As above, but excludes the time to initialize the `ImageReader`. @Benchmark @BenchmarkMode(Mode.SingleShotTime) public void coldStart_CountOnly(ColdStartWithImageReader state) throws IOException { @@ -173,8 +236,8 @@ public void coldStart_CountOnly(ColdStartWithImageReader state) throws IOExcepti @BenchmarkMode(Mode.SingleShotTime) public void coldStart_LoadJavacInitClasses(Blackhole bh, ColdStart state) throws IOException { int errors = 0; - try (var reader = ImageReader.open(state.copiedImageFile, state.byteOrder)) { - for (String path : INIT_CLASSES) { + try (var reader = ImageReader.open(state.copiedImageFile, state.previewMode)) { + for (String path : ClassList.names()) { // Path determination isn't perfect so there can be a few "misses" in here. // Report the count of bad paths as the "result", which should be < 20 or so. Node node = reader.findNode(path); @@ -185,9 +248,9 @@ public void coldStart_LoadJavacInitClasses(Blackhole bh, ColdStart state) throws } } } - state.count = INIT_CLASSES.size(); + state.count = ClassList.count(); // Allow up to 2% missing classes before complaining. - if ((100 * errors) / INIT_CLASSES.size() >= 2) { + if ((100 * errors) / ClassList.count() >= 2) { reportMissingClassesAndFail(state, errors); } } @@ -206,12 +269,39 @@ static long countAllNodes(ImageReader reader, Node node) { return count; } + static long countContainsResource(ImageReader reader, Map> modToPaths) + throws IOException { + long count = 0; + for (Map.Entry> e : modToPaths.entrySet()) { + String mod = e.getKey(); + for (String path : e.getValue()) { + if (reader.containsResource(mod, path)) { + count++; + } + } + } + return count; + } + + static long countFindResourceNode(ImageReader reader, Map> modToPaths) throws IOException { + long count = 0; + for (Map.Entry> e : modToPaths.entrySet()) { + String mod = e.getKey(); + for (String path : e.getValue()) { + if (reader.findResourceNode(mod, path) != null) { + count++; + } + } + } + return count; + } + // Run if the INIT_CLASSES list below is sufficiently out-of-date. // DO NOT run this before the benchmark, as it will cache all the nodes! private static void reportMissingClassesAndFail(ColdStart state, int errors) throws IOException { List missing = new ArrayList<>(errors); - try (var reader = ImageReader.open(state.copiedImageFile, state.byteOrder)) { - for (String path : INIT_CLASSES) { + try (var reader = ImageReader.open(state.copiedImageFile, state.previewMode)) { + for (String path : ClassList.names()) { if (reader.findNode(path) == null) { missing.add(path); } @@ -222,858 +312,891 @@ private static void reportMissingClassesAndFail(ColdStart state, int errors) thr "Too many missing classes (%d of %d) in the hardcoded benchmark list.\n" + "Please regenerate it according to instructions in the source code.\n" + "Missing classes:\n\t%s", - errors, INIT_CLASSES.size(), String.join("\n\t", missing))); + errors, ClassList.count(), String.join("\n\t", missing))); } - // Note: This list is inherently a little fragile and may end up being more - // trouble than it's worth to maintain. If it turns out that it needs to be - // regenerated often when this benchmark is run, then a new approach should - // be considered, such as: - // * Limit the list of classes to non-internal ones. - // * Calculate the list dynamically based on the running JVM. - // - // Created by running "java -verbose:class", throwing away anonymous inner - // classes and anything without a reliable name, and grouping by the stated - // source. It's not perfect, but it's representative. - // - // /bin/java -verbose:class HelloWorld 2>&1 \ - // | fgrep '[class,load]' | cut -d' ' -f2 \ - // | tr '.' '/' \ - // | egrep -v '\$[0-9$]' \ - // | fgrep -v 'HelloWorld' \ - // | fgrep -v '/META-INF/preview/' \ - // | while read f ; do echo "${f}.class" ; done \ - // > initclasses.txt - // - // Output: - // java/lang/Object.class - // java/io/Serializable.class - // ... - // - // jimage list /images/jdk/lib/modules \ - // | awk '/^Module: */ { MOD=$2 }; /^ */ { print "/modules/"MOD"/"$1 }' \ - // > fullpaths.txt - // - // Output: - // ... - // /modules/java.base/java/lang/Object.class - // /modules/java.base/java/lang/OutOfMemoryError.class - // ... - // - // while read c ; do grep "/$c" fullpaths.txt ; done < initclasses.txt \ - // | while read c ; do printf ' "%s",\n' "$c" ; done \ - // > initpaths.txt - // - // Output: - private static final Set INIT_CLASSES = Set.of( - "/modules/java.base/java/lang/Object.class", - "/modules/java.base/java/io/Serializable.class", - "/modules/java.base/java/lang/Comparable.class", - "/modules/java.base/java/lang/CharSequence.class", - "/modules/java.base/java/lang/constant/Constable.class", - "/modules/java.base/java/lang/constant/ConstantDesc.class", - "/modules/java.base/java/lang/String.class", - "/modules/java.base/java/lang/reflect/AnnotatedElement.class", - "/modules/java.base/java/lang/reflect/GenericDeclaration.class", - "/modules/java.base/java/lang/reflect/Type.class", - "/modules/java.base/java/lang/invoke/TypeDescriptor.class", - "/modules/java.base/java/lang/invoke/TypeDescriptor$OfField.class", - "/modules/java.base/java/lang/Class.class", - "/modules/java.base/java/lang/Cloneable.class", - "/modules/java.base/java/lang/ClassLoader.class", - "/modules/java.base/java/lang/System.class", - "/modules/java.base/java/lang/Throwable.class", - "/modules/java.base/java/lang/Error.class", - "/modules/java.base/java/lang/Exception.class", - "/modules/java.base/java/lang/RuntimeException.class", - "/modules/java.base/java/security/ProtectionDomain.class", - "/modules/java.base/java/security/SecureClassLoader.class", - "/modules/java.base/java/lang/ReflectiveOperationException.class", - "/modules/java.base/java/lang/ClassNotFoundException.class", - "/modules/java.base/java/lang/Record.class", - "/modules/java.base/java/lang/LinkageError.class", - "/modules/java.base/java/lang/NoClassDefFoundError.class", - "/modules/java.base/java/lang/ClassCastException.class", - "/modules/java.base/java/lang/ArrayStoreException.class", - "/modules/java.base/java/lang/VirtualMachineError.class", - "/modules/java.base/java/lang/InternalError.class", - "/modules/java.base/java/lang/OutOfMemoryError.class", - "/modules/java.base/java/lang/StackOverflowError.class", - "/modules/java.base/java/lang/IllegalMonitorStateException.class", - "/modules/java.base/java/lang/ref/Reference.class", - "/modules/java.base/java/lang/IllegalCallerException.class", - "/modules/java.base/java/lang/ref/SoftReference.class", - "/modules/java.base/java/lang/ref/WeakReference.class", - "/modules/java.base/java/lang/ref/FinalReference.class", - "/modules/java.base/java/lang/ref/PhantomReference.class", - "/modules/java.base/java/lang/ref/Finalizer.class", - "/modules/java.base/java/lang/Runnable.class", - "/modules/java.base/java/lang/Thread.class", - "/modules/java.base/java/lang/Thread$FieldHolder.class", - "/modules/java.base/java/lang/Thread$Constants.class", - "/modules/java.base/java/lang/Thread$UncaughtExceptionHandler.class", - "/modules/java.base/java/lang/ThreadGroup.class", - "/modules/java.base/java/lang/BaseVirtualThread.class", - "/modules/java.base/java/lang/VirtualThread.class", - "/modules/java.base/java/lang/ThreadBuilders$BoundVirtualThread.class", - "/modules/java.base/java/util/Map.class", - "/modules/java.base/java/util/Dictionary.class", - "/modules/java.base/java/util/Hashtable.class", - "/modules/java.base/java/util/Properties.class", - "/modules/java.base/java/lang/Module.class", - "/modules/java.base/java/lang/reflect/AccessibleObject.class", - "/modules/java.base/java/lang/reflect/Member.class", - "/modules/java.base/java/lang/reflect/Field.class", - "/modules/java.base/java/lang/reflect/Parameter.class", - "/modules/java.base/java/lang/reflect/Executable.class", - "/modules/java.base/java/lang/reflect/Method.class", - "/modules/java.base/java/lang/reflect/Constructor.class", - "/modules/java.base/jdk/internal/vm/ContinuationScope.class", - "/modules/java.base/jdk/internal/vm/Continuation.class", - "/modules/java.base/jdk/internal/vm/StackChunk.class", - "/modules/java.base/jdk/internal/reflect/MethodAccessor.class", - "/modules/java.base/jdk/internal/reflect/MethodAccessorImpl.class", - "/modules/java.base/jdk/internal/reflect/ConstantPool.class", - "/modules/java.base/java/lang/annotation/Annotation.class", - "/modules/java.base/jdk/internal/reflect/CallerSensitive.class", - "/modules/java.base/jdk/internal/reflect/ConstructorAccessor.class", - "/modules/java.base/jdk/internal/reflect/ConstructorAccessorImpl.class", - "/modules/java.base/jdk/internal/reflect/DirectConstructorHandleAccessor$NativeAccessor.class", - "/modules/java.base/java/lang/invoke/MethodHandle.class", - "/modules/java.base/java/lang/invoke/DirectMethodHandle.class", - "/modules/java.base/java/lang/invoke/VarHandle.class", - "/modules/java.base/java/lang/invoke/MemberName.class", - "/modules/java.base/java/lang/invoke/ResolvedMethodName.class", - "/modules/java.base/java/lang/invoke/MethodHandleNatives.class", - "/modules/java.base/java/lang/invoke/LambdaForm.class", - "/modules/java.base/java/lang/invoke/TypeDescriptor$OfMethod.class", - "/modules/java.base/java/lang/invoke/MethodType.class", - "/modules/java.base/java/lang/BootstrapMethodError.class", - "/modules/java.base/java/lang/invoke/CallSite.class", - "/modules/java.base/jdk/internal/foreign/abi/NativeEntryPoint.class", - "/modules/java.base/jdk/internal/foreign/abi/ABIDescriptor.class", - "/modules/java.base/jdk/internal/foreign/abi/VMStorage.class", - "/modules/java.base/jdk/internal/foreign/abi/UpcallLinker$CallRegs.class", - "/modules/java.base/java/lang/invoke/ConstantCallSite.class", - "/modules/java.base/java/lang/invoke/MutableCallSite.class", - "/modules/java.base/java/lang/invoke/VolatileCallSite.class", - "/modules/java.base/java/lang/AssertionStatusDirectives.class", - "/modules/java.base/java/lang/Appendable.class", - "/modules/java.base/java/lang/AbstractStringBuilder.class", - "/modules/java.base/java/lang/StringBuffer.class", - "/modules/java.base/java/lang/StringBuilder.class", - "/modules/java.base/jdk/internal/misc/UnsafeConstants.class", - "/modules/java.base/jdk/internal/misc/Unsafe.class", - "/modules/java.base/jdk/internal/module/Modules.class", - "/modules/java.base/java/lang/AutoCloseable.class", - "/modules/java.base/java/io/Closeable.class", - "/modules/java.base/java/io/InputStream.class", - "/modules/java.base/java/io/ByteArrayInputStream.class", - "/modules/java.base/java/net/URL.class", - "/modules/java.base/java/lang/Enum.class", - "/modules/java.base/java/util/jar/Manifest.class", - "/modules/java.base/jdk/internal/loader/BuiltinClassLoader.class", - "/modules/java.base/jdk/internal/loader/ClassLoaders.class", - "/modules/java.base/jdk/internal/loader/ClassLoaders$AppClassLoader.class", - "/modules/java.base/jdk/internal/loader/ClassLoaders$PlatformClassLoader.class", - "/modules/java.base/java/security/CodeSource.class", - "/modules/java.base/java/util/concurrent/ConcurrentMap.class", - "/modules/java.base/java/util/AbstractMap.class", - "/modules/java.base/java/util/concurrent/ConcurrentHashMap.class", - "/modules/java.base/java/lang/Iterable.class", - "/modules/java.base/java/util/Collection.class", - "/modules/java.base/java/util/SequencedCollection.class", - "/modules/java.base/java/util/List.class", - "/modules/java.base/java/util/RandomAccess.class", - "/modules/java.base/java/util/AbstractCollection.class", - "/modules/java.base/java/util/AbstractList.class", - "/modules/java.base/java/util/ArrayList.class", - "/modules/java.base/java/lang/StackTraceElement.class", - "/modules/java.base/java/nio/Buffer.class", - "/modules/java.base/java/lang/StackWalker.class", - "/modules/java.base/java/lang/StackStreamFactory$AbstractStackWalker.class", - "/modules/java.base/java/lang/StackWalker$StackFrame.class", - "/modules/java.base/java/lang/ClassFrameInfo.class", - "/modules/java.base/java/lang/StackFrameInfo.class", - "/modules/java.base/java/lang/LiveStackFrame.class", - "/modules/java.base/java/lang/LiveStackFrameInfo.class", - "/modules/java.base/java/util/concurrent/locks/AbstractOwnableSynchronizer.class", - "/modules/java.base/java/lang/Boolean.class", - "/modules/java.base/java/lang/Character.class", - "/modules/java.base/java/lang/Number.class", - "/modules/java.base/java/lang/Float.class", - "/modules/java.base/java/lang/Double.class", - "/modules/java.base/java/lang/Byte.class", - "/modules/java.base/java/lang/Short.class", - "/modules/java.base/java/lang/Integer.class", - "/modules/java.base/java/lang/Long.class", - "/modules/java.base/java/lang/Void.class", - "/modules/java.base/java/util/Iterator.class", - "/modules/java.base/java/lang/reflect/RecordComponent.class", - "/modules/java.base/jdk/internal/vm/vector/VectorSupport.class", - "/modules/java.base/jdk/internal/vm/vector/VectorSupport$VectorPayload.class", - "/modules/java.base/jdk/internal/vm/vector/VectorSupport$Vector.class", - "/modules/java.base/jdk/internal/vm/vector/VectorSupport$VectorMask.class", - "/modules/java.base/jdk/internal/vm/vector/VectorSupport$VectorShuffle.class", - "/modules/java.base/jdk/internal/vm/FillerObject.class", - "/modules/java.base/java/lang/NullPointerException.class", - "/modules/java.base/java/lang/ArithmeticException.class", - "/modules/java.base/java/lang/IndexOutOfBoundsException.class", - "/modules/java.base/java/lang/ArrayIndexOutOfBoundsException.class", - "/modules/java.base/java/io/ObjectStreamField.class", - "/modules/java.base/java/util/Comparator.class", - "/modules/java.base/java/lang/String$CaseInsensitiveComparator.class", - "/modules/java.base/jdk/internal/misc/VM.class", - "/modules/java.base/java/lang/Module$ArchivedData.class", - "/modules/java.base/jdk/internal/misc/CDS.class", - "/modules/java.base/java/util/Set.class", - "/modules/java.base/java/util/ImmutableCollections$AbstractImmutableCollection.class", - "/modules/java.base/java/util/ImmutableCollections$AbstractImmutableSet.class", - "/modules/java.base/java/util/ImmutableCollections$Set12.class", - "/modules/java.base/java/util/Objects.class", - "/modules/java.base/java/util/ImmutableCollections.class", - "/modules/java.base/java/util/ImmutableCollections$AbstractImmutableList.class", - "/modules/java.base/java/util/ImmutableCollections$ListN.class", - "/modules/java.base/java/util/ImmutableCollections$SetN.class", - "/modules/java.base/java/util/ImmutableCollections$AbstractImmutableMap.class", - "/modules/java.base/java/util/ImmutableCollections$MapN.class", - "/modules/java.base/jdk/internal/access/JavaLangReflectAccess.class", - "/modules/java.base/java/lang/reflect/ReflectAccess.class", - "/modules/java.base/jdk/internal/access/SharedSecrets.class", - "/modules/java.base/jdk/internal/reflect/ReflectionFactory.class", - "/modules/java.base/java/io/ObjectStreamClass.class", - "/modules/java.base/java/lang/Math.class", - "/modules/java.base/jdk/internal/reflect/ReflectionFactory$Config.class", - "/modules/java.base/jdk/internal/access/JavaLangRefAccess.class", - "/modules/java.base/java/lang/ref/ReferenceQueue.class", - "/modules/java.base/java/lang/ref/ReferenceQueue$Null.class", - "/modules/java.base/java/lang/ref/ReferenceQueue$Lock.class", - "/modules/java.base/jdk/internal/access/JavaLangAccess.class", - "/modules/java.base/jdk/internal/util/SystemProps.class", - "/modules/java.base/jdk/internal/util/SystemProps$Raw.class", - "/modules/java.base/java/nio/charset/Charset.class", - "/modules/java.base/java/nio/charset/spi/CharsetProvider.class", - "/modules/java.base/sun/nio/cs/StandardCharsets.class", - "/modules/java.base/java/lang/StringLatin1.class", - "/modules/java.base/sun/nio/cs/HistoricallyNamedCharset.class", - "/modules/java.base/sun/nio/cs/Unicode.class", - "/modules/java.base/sun/nio/cs/UTF_8.class", - "/modules/java.base/java/util/HashMap.class", - "/modules/java.base/java/lang/StrictMath.class", - "/modules/java.base/jdk/internal/util/ArraysSupport.class", - "/modules/java.base/java/util/Map$Entry.class", - "/modules/java.base/java/util/HashMap$Node.class", - "/modules/java.base/java/util/LinkedHashMap$Entry.class", - "/modules/java.base/java/util/HashMap$TreeNode.class", - "/modules/java.base/java/lang/StringConcatHelper.class", - "/modules/java.base/java/lang/VersionProps.class", - "/modules/java.base/java/lang/Runtime.class", - "/modules/java.base/java/util/concurrent/locks/Lock.class", - "/modules/java.base/java/util/concurrent/locks/ReentrantLock.class", - "/modules/java.base/java/util/concurrent/ConcurrentHashMap$Segment.class", - "/modules/java.base/java/util/concurrent/ConcurrentHashMap$CounterCell.class", - "/modules/java.base/java/util/concurrent/ConcurrentHashMap$Node.class", - "/modules/java.base/java/util/concurrent/locks/LockSupport.class", - "/modules/java.base/java/util/concurrent/ConcurrentHashMap$ReservationNode.class", - "/modules/java.base/java/util/AbstractSet.class", - "/modules/java.base/java/util/HashMap$EntrySet.class", - "/modules/java.base/java/util/HashMap$HashIterator.class", - "/modules/java.base/java/util/HashMap$EntryIterator.class", - "/modules/java.base/jdk/internal/util/StaticProperty.class", - "/modules/java.base/java/io/FileInputStream.class", - "/modules/java.base/java/lang/System$In.class", - "/modules/java.base/java/io/FileDescriptor.class", - "/modules/java.base/jdk/internal/access/JavaIOFileDescriptorAccess.class", - "/modules/java.base/java/io/Flushable.class", - "/modules/java.base/java/io/OutputStream.class", - "/modules/java.base/java/io/FileOutputStream.class", - "/modules/java.base/java/lang/System$Out.class", - "/modules/java.base/java/io/FilterInputStream.class", - "/modules/java.base/java/io/BufferedInputStream.class", - "/modules/java.base/java/io/FilterOutputStream.class", - "/modules/java.base/java/io/PrintStream.class", - "/modules/java.base/java/io/BufferedOutputStream.class", - "/modules/java.base/java/io/Writer.class", - "/modules/java.base/java/io/OutputStreamWriter.class", - "/modules/java.base/sun/nio/cs/StreamEncoder.class", - "/modules/java.base/java/nio/charset/CharsetEncoder.class", - "/modules/java.base/sun/nio/cs/UTF_8$Encoder.class", - "/modules/java.base/java/nio/charset/CodingErrorAction.class", - "/modules/java.base/java/util/Arrays.class", - "/modules/java.base/java/nio/ByteBuffer.class", - "/modules/java.base/jdk/internal/misc/ScopedMemoryAccess.class", - "/modules/java.base/java/util/function/Function.class", - "/modules/java.base/jdk/internal/util/Preconditions.class", - "/modules/java.base/java/util/function/BiFunction.class", - "/modules/java.base/jdk/internal/access/JavaNioAccess.class", - "/modules/java.base/java/nio/HeapByteBuffer.class", - "/modules/java.base/java/nio/ByteOrder.class", - "/modules/java.base/java/io/BufferedWriter.class", - "/modules/java.base/java/lang/Terminator.class", - "/modules/java.base/jdk/internal/misc/Signal$Handler.class", - "/modules/java.base/jdk/internal/misc/Signal.class", - "/modules/java.base/java/util/Hashtable$Entry.class", - "/modules/java.base/jdk/internal/misc/Signal$NativeHandler.class", - "/modules/java.base/java/lang/Integer$IntegerCache.class", - "/modules/java.base/jdk/internal/misc/OSEnvironment.class", - "/modules/java.base/java/lang/Thread$State.class", - "/modules/java.base/java/lang/ref/Reference$ReferenceHandler.class", - "/modules/java.base/java/lang/Thread$ThreadIdentifiers.class", - "/modules/java.base/java/lang/ref/Finalizer$FinalizerThread.class", - "/modules/java.base/jdk/internal/ref/Cleaner.class", - "/modules/java.base/java/util/Collections.class", - "/modules/java.base/java/util/Collections$EmptySet.class", - "/modules/java.base/java/util/Collections$EmptyList.class", - "/modules/java.base/java/util/Collections$EmptyMap.class", - "/modules/java.base/java/lang/IllegalArgumentException.class", - "/modules/java.base/java/lang/invoke/MethodHandleStatics.class", - "/modules/java.base/java/lang/reflect/ClassFileFormatVersion.class", - "/modules/java.base/java/lang/CharacterData.class", - "/modules/java.base/java/lang/CharacterDataLatin1.class", - "/modules/java.base/jdk/internal/util/ClassFileDumper.class", - "/modules/java.base/java/util/HexFormat.class", - "/modules/java.base/java/lang/Character$CharacterCache.class", - "/modules/java.base/java/util/concurrent/atomic/AtomicInteger.class", - "/modules/java.base/jdk/internal/module/ModuleBootstrap.class", - "/modules/java.base/java/lang/module/ModuleDescriptor.class", - "/modules/java.base/java/lang/invoke/MethodHandles.class", - "/modules/java.base/java/lang/invoke/MemberName$Factory.class", - "/modules/java.base/jdk/internal/reflect/Reflection.class", - "/modules/java.base/java/lang/invoke/MethodHandles$Lookup.class", - "/modules/java.base/java/util/ImmutableCollections$MapN$MapNIterator.class", - "/modules/java.base/java/util/KeyValueHolder.class", - "/modules/java.base/sun/invoke/util/VerifyAccess.class", - "/modules/java.base/java/lang/reflect/Modifier.class", - "/modules/java.base/jdk/internal/access/JavaLangModuleAccess.class", - "/modules/java.base/java/io/File.class", - "/modules/java.base/java/io/DefaultFileSystem.class", - "/modules/java.base/java/io/FileSystem.class", - "/modules/java.base/java/io/UnixFileSystem.class", - "/modules/java.base/jdk/internal/util/DecimalDigits.class", - "/modules/java.base/jdk/internal/module/ModulePatcher.class", - "/modules/java.base/jdk/internal/module/ModuleBootstrap$IllegalNativeAccess.class", - "/modules/java.base/java/util/HashSet.class", - "/modules/java.base/jdk/internal/module/ModuleLoaderMap.class", - "/modules/java.base/jdk/internal/module/ModuleLoaderMap$Modules.class", - "/modules/java.base/jdk/internal/module/ModuleBootstrap$Counters.class", - "/modules/java.base/jdk/internal/module/ArchivedBootLayer.class", - "/modules/java.base/jdk/internal/module/ArchivedModuleGraph.class", - "/modules/java.base/jdk/internal/module/SystemModuleFinders.class", - "/modules/java.base/java/net/URI.class", - "/modules/java.base/jdk/internal/access/JavaNetUriAccess.class", - "/modules/java.base/jdk/internal/module/SystemModulesMap.class", - "/modules/java.base/jdk/internal/module/SystemModules.class", - "/modules/java.base/jdk/internal/module/ExplodedSystemModules.class", - "/modules/java.base/java/nio/file/Watchable.class", - "/modules/java.base/java/nio/file/Path.class", - "/modules/java.base/java/nio/file/FileSystems.class", - "/modules/java.base/sun/nio/fs/DefaultFileSystemProvider.class", - "/modules/java.base/java/nio/file/spi/FileSystemProvider.class", - "/modules/java.base/sun/nio/fs/AbstractFileSystemProvider.class", - "/modules/java.base/sun/nio/fs/UnixFileSystemProvider.class", - "/modules/java.base/sun/nio/fs/LinuxFileSystemProvider.class", - "/modules/java.base/java/nio/file/OpenOption.class", - "/modules/java.base/java/nio/file/StandardOpenOption.class", - "/modules/java.base/java/nio/file/FileSystem.class", - "/modules/java.base/sun/nio/fs/UnixFileSystem.class", - "/modules/java.base/sun/nio/fs/LinuxFileSystem.class", - "/modules/java.base/sun/nio/fs/UnixPath.class", - "/modules/java.base/sun/nio/fs/Util.class", - "/modules/java.base/java/lang/StringCoding.class", - "/modules/java.base/sun/nio/fs/UnixNativeDispatcher.class", - "/modules/java.base/jdk/internal/loader/BootLoader.class", - "/modules/java.base/java/lang/Module$EnableNativeAccess.class", - "/modules/java.base/jdk/internal/loader/NativeLibraries.class", - "/modules/java.base/jdk/internal/loader/ClassLoaderHelper.class", - "/modules/java.base/java/util/concurrent/ConcurrentHashMap$CollectionView.class", - "/modules/java.base/java/util/concurrent/ConcurrentHashMap$KeySetView.class", - "/modules/java.base/jdk/internal/loader/NativeLibraries$LibraryPaths.class", - "/modules/java.base/java/io/File$PathStatus.class", - "/modules/java.base/jdk/internal/loader/NativeLibraries$CountedLock.class", - "/modules/java.base/java/util/concurrent/locks/AbstractQueuedSynchronizer.class", - "/modules/java.base/java/util/concurrent/locks/ReentrantLock$Sync.class", - "/modules/java.base/java/util/concurrent/locks/ReentrantLock$NonfairSync.class", - "/modules/java.base/jdk/internal/loader/NativeLibraries$NativeLibraryContext.class", - "/modules/java.base/java/util/Queue.class", - "/modules/java.base/java/util/Deque.class", - "/modules/java.base/java/util/ArrayDeque.class", - "/modules/java.base/java/util/ArrayDeque$DeqIterator.class", - "/modules/java.base/jdk/internal/loader/NativeLibrary.class", - "/modules/java.base/jdk/internal/loader/NativeLibraries$NativeLibraryImpl.class", - "/modules/java.base/java/security/cert/Certificate.class", - "/modules/java.base/java/util/concurrent/ConcurrentHashMap$ValuesView.class", - "/modules/java.base/java/util/Enumeration.class", - "/modules/java.base/java/util/concurrent/ConcurrentHashMap$Traverser.class", - "/modules/java.base/java/util/concurrent/ConcurrentHashMap$BaseIterator.class", - "/modules/java.base/java/util/concurrent/ConcurrentHashMap$ValueIterator.class", - "/modules/java.base/java/nio/file/attribute/BasicFileAttributes.class", - "/modules/java.base/java/nio/file/attribute/PosixFileAttributes.class", - "/modules/java.base/sun/nio/fs/UnixFileAttributes.class", - "/modules/java.base/sun/nio/fs/UnixFileStoreAttributes.class", - "/modules/java.base/sun/nio/fs/UnixMountEntry.class", - "/modules/java.base/java/nio/file/CopyOption.class", - "/modules/java.base/java/nio/file/LinkOption.class", - "/modules/java.base/java/nio/file/Files.class", - "/modules/java.base/sun/nio/fs/NativeBuffers.class", - "/modules/java.base/java/lang/ThreadLocal.class", - "/modules/java.base/jdk/internal/misc/CarrierThreadLocal.class", - "/modules/java.base/jdk/internal/misc/TerminatingThreadLocal.class", - "/modules/java.base/java/lang/ThreadLocal$ThreadLocalMap.class", - "/modules/java.base/java/lang/ThreadLocal$ThreadLocalMap$Entry.class", - "/modules/java.base/java/util/IdentityHashMap.class", - "/modules/java.base/java/util/Collections$SetFromMap.class", - "/modules/java.base/java/util/IdentityHashMap$KeySet.class", - "/modules/java.base/sun/nio/fs/NativeBuffer.class", - "/modules/java.base/jdk/internal/ref/CleanerFactory.class", - "/modules/java.base/java/util/concurrent/ThreadFactory.class", - "/modules/java.base/java/lang/ref/Cleaner.class", - "/modules/java.base/jdk/internal/ref/CleanerImpl.class", - "/modules/java.base/jdk/internal/ref/CleanerImpl$CleanableList.class", - "/modules/java.base/jdk/internal/ref/CleanerImpl$CleanableList$Node.class", - "/modules/java.base/java/lang/ref/Cleaner$Cleanable.class", - "/modules/java.base/jdk/internal/ref/PhantomCleanable.class", - "/modules/java.base/jdk/internal/ref/CleanerImpl$CleanerCleanable.class", - "/modules/java.base/jdk/internal/misc/InnocuousThread.class", - "/modules/java.base/sun/nio/fs/NativeBuffer$Deallocator.class", - "/modules/java.base/jdk/internal/ref/CleanerImpl$PhantomCleanableRef.class", - "/modules/java.base/java/lang/module/ModuleFinder.class", - "/modules/java.base/jdk/internal/module/ModulePath.class", - "/modules/java.base/java/util/jar/Attributes$Name.class", - "/modules/java.base/java/lang/reflect/Array.class", - "/modules/java.base/jdk/internal/perf/PerfCounter.class", - "/modules/java.base/jdk/internal/perf/Perf.class", - "/modules/java.base/sun/nio/ch/DirectBuffer.class", - "/modules/java.base/java/nio/MappedByteBuffer.class", - "/modules/java.base/java/nio/DirectByteBuffer.class", - "/modules/java.base/java/nio/Bits.class", - "/modules/java.base/java/util/concurrent/atomic/AtomicLong.class", - "/modules/java.base/jdk/internal/misc/VM$BufferPool.class", - "/modules/java.base/java/nio/LongBuffer.class", - "/modules/java.base/java/nio/DirectLongBufferU.class", - "/modules/java.base/java/util/zip/ZipConstants.class", - "/modules/java.base/java/util/zip/ZipFile.class", - "/modules/java.base/java/util/jar/JarFile.class", - "/modules/java.base/java/util/BitSet.class", - "/modules/java.base/jdk/internal/access/JavaUtilZipFileAccess.class", - "/modules/java.base/jdk/internal/access/JavaUtilJarAccess.class", - "/modules/java.base/java/util/jar/JavaUtilJarAccessImpl.class", - "/modules/java.base/java/lang/Runtime$Version.class", - "/modules/java.base/java/util/ImmutableCollections$List12.class", - "/modules/java.base/java/util/Optional.class", - "/modules/java.base/java/nio/file/attribute/DosFileAttributes.class", - "/modules/java.base/java/nio/file/attribute/AttributeView.class", - "/modules/java.base/java/nio/file/attribute/FileAttributeView.class", - "/modules/java.base/java/nio/file/attribute/BasicFileAttributeView.class", - "/modules/java.base/java/nio/file/attribute/DosFileAttributeView.class", - "/modules/java.base/java/nio/file/attribute/UserDefinedFileAttributeView.class", - "/modules/java.base/sun/nio/fs/UnixFileAttributeViews.class", - "/modules/java.base/sun/nio/fs/DynamicFileAttributeView.class", - "/modules/java.base/sun/nio/fs/AbstractBasicFileAttributeView.class", - "/modules/java.base/sun/nio/fs/UnixFileAttributeViews$Basic.class", - "/modules/java.base/sun/nio/fs/UnixFileAttributes$UnixAsBasicFileAttributes.class", - "/modules/java.base/java/nio/file/DirectoryStream$Filter.class", - "/modules/java.base/java/nio/file/Files$AcceptAllFilter.class", - "/modules/java.base/java/nio/file/DirectoryStream.class", - "/modules/java.base/java/nio/file/SecureDirectoryStream.class", - "/modules/java.base/sun/nio/fs/UnixSecureDirectoryStream.class", - "/modules/java.base/sun/nio/fs/UnixDirectoryStream.class", - "/modules/java.base/java/util/concurrent/locks/ReadWriteLock.class", - "/modules/java.base/java/util/concurrent/locks/ReentrantReadWriteLock.class", - "/modules/java.base/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.class", - "/modules/java.base/java/util/concurrent/locks/ReentrantReadWriteLock$Sync.class", - "/modules/java.base/java/util/concurrent/locks/ReentrantReadWriteLock$FairSync.class", - "/modules/java.base/java/util/concurrent/locks/ReentrantReadWriteLock$Sync$ThreadLocalHoldCounter.class", - "/modules/java.base/java/util/concurrent/locks/ReentrantReadWriteLock$ReadLock.class", - "/modules/java.base/java/util/concurrent/locks/ReentrantReadWriteLock$WriteLock.class", - "/modules/java.base/sun/nio/fs/UnixDirectoryStream$UnixDirectoryIterator.class", - "/modules/java.base/java/nio/file/attribute/FileAttribute.class", - "/modules/java.base/sun/nio/fs/UnixFileModeAttribute.class", - "/modules/java.base/sun/nio/fs/UnixChannelFactory.class", - "/modules/java.base/sun/nio/fs/UnixChannelFactory$Flags.class", - "/modules/java.base/java/util/Collections$EmptyIterator.class", - "/modules/java.base/java/nio/channels/Channel.class", - "/modules/java.base/java/nio/channels/ReadableByteChannel.class", - "/modules/java.base/java/nio/channels/WritableByteChannel.class", - "/modules/java.base/java/nio/channels/ByteChannel.class", - "/modules/java.base/java/nio/channels/SeekableByteChannel.class", - "/modules/java.base/java/nio/channels/GatheringByteChannel.class", - "/modules/java.base/java/nio/channels/ScatteringByteChannel.class", - "/modules/java.base/java/nio/channels/InterruptibleChannel.class", - "/modules/java.base/java/nio/channels/spi/AbstractInterruptibleChannel.class", - "/modules/java.base/java/nio/channels/FileChannel.class", - "/modules/java.base/sun/nio/ch/FileChannelImpl.class", - "/modules/java.base/sun/nio/ch/NativeDispatcher.class", - "/modules/java.base/sun/nio/ch/FileDispatcher.class", - "/modules/java.base/sun/nio/ch/UnixFileDispatcherImpl.class", - "/modules/java.base/sun/nio/ch/FileDispatcherImpl.class", - "/modules/java.base/sun/nio/ch/IOUtil.class", - "/modules/java.base/sun/nio/ch/Interruptible.class", - "/modules/java.base/sun/nio/ch/NativeThreadSet.class", - "/modules/java.base/sun/nio/ch/FileChannelImpl$Closer.class", - "/modules/java.base/java/nio/channels/Channels.class", - "/modules/java.base/sun/nio/ch/Streams.class", - "/modules/java.base/sun/nio/ch/SelChImpl.class", - "/modules/java.base/java/nio/channels/NetworkChannel.class", - "/modules/java.base/java/nio/channels/SelectableChannel.class", - "/modules/java.base/java/nio/channels/spi/AbstractSelectableChannel.class", - "/modules/java.base/java/nio/channels/SocketChannel.class", - "/modules/java.base/sun/nio/ch/SocketChannelImpl.class", - "/modules/java.base/sun/nio/ch/ChannelInputStream.class", - "/modules/java.base/java/lang/invoke/LambdaMetafactory.class", - "/modules/java.base/java/util/function/Supplier.class", - "/modules/java.base/jdk/internal/util/ReferencedKeySet.class", - "/modules/java.base/jdk/internal/util/ReferencedKeyMap.class", - "/modules/java.base/jdk/internal/util/ReferenceKey.class", - "/modules/java.base/jdk/internal/util/StrongReferenceKey.class", - "/modules/java.base/java/lang/invoke/MethodTypeForm.class", - "/modules/java.base/jdk/internal/util/WeakReferenceKey.class", - "/modules/java.base/sun/invoke/util/Wrapper.class", - "/modules/java.base/sun/invoke/util/Wrapper$Format.class", - "/modules/java.base/java/lang/constant/ConstantDescs.class", - "/modules/java.base/java/lang/constant/ClassDesc.class", - "/modules/java.base/jdk/internal/constant/ClassOrInterfaceDescImpl.class", - "/modules/java.base/jdk/internal/constant/ArrayClassDescImpl.class", - "/modules/java.base/jdk/internal/constant/ConstantUtils.class", - "/modules/java.base/java/lang/constant/DirectMethodHandleDesc$Kind.class", - "/modules/java.base/java/lang/constant/MethodTypeDesc.class", - "/modules/java.base/jdk/internal/constant/MethodTypeDescImpl.class", - "/modules/java.base/java/lang/constant/MethodHandleDesc.class", - "/modules/java.base/java/lang/constant/DirectMethodHandleDesc.class", - "/modules/java.base/jdk/internal/constant/DirectMethodHandleDescImpl.class", - "/modules/java.base/java/lang/constant/DynamicConstantDesc.class", - "/modules/java.base/jdk/internal/constant/PrimitiveClassDescImpl.class", - "/modules/java.base/java/lang/constant/DynamicConstantDesc$AnonymousDynamicConstantDesc.class", - "/modules/java.base/java/lang/invoke/LambdaForm$NamedFunction.class", - "/modules/java.base/java/lang/invoke/DirectMethodHandle$Holder.class", - "/modules/java.base/sun/invoke/util/ValueConversions.class", - "/modules/java.base/java/lang/invoke/MethodHandleImpl.class", - "/modules/java.base/java/lang/invoke/Invokers.class", - "/modules/java.base/java/lang/invoke/LambdaForm$Kind.class", - "/modules/java.base/java/lang/NoSuchMethodException.class", - "/modules/java.base/java/lang/invoke/LambdaForm$BasicType.class", - "/modules/java.base/java/lang/classfile/TypeKind.class", - "/modules/java.base/java/lang/invoke/LambdaForm$Name.class", - "/modules/java.base/java/lang/invoke/LambdaForm$Holder.class", - "/modules/java.base/java/lang/invoke/InvokerBytecodeGenerator.class", - "/modules/java.base/java/lang/classfile/AnnotationElement.class", - "/modules/java.base/java/lang/classfile/Annotation.class", - "/modules/java.base/java/lang/classfile/constantpool/ConstantPool.class", - "/modules/java.base/java/lang/classfile/constantpool/ConstantPoolBuilder.class", - "/modules/java.base/jdk/internal/classfile/impl/TemporaryConstantPool.class", - "/modules/java.base/java/lang/classfile/constantpool/PoolEntry.class", - "/modules/java.base/java/lang/classfile/constantpool/AnnotationConstantValueEntry.class", - "/modules/java.base/java/lang/classfile/constantpool/Utf8Entry.class", - "/modules/java.base/jdk/internal/classfile/impl/AbstractPoolEntry.class", - "/modules/java.base/jdk/internal/classfile/impl/AbstractPoolEntry$Utf8EntryImpl.class", - "/modules/java.base/jdk/internal/classfile/impl/AbstractPoolEntry$Utf8EntryImpl$State.class", - "/modules/java.base/jdk/internal/classfile/impl/AnnotationImpl.class", - "/modules/java.base/java/lang/classfile/ClassFileElement.class", - "/modules/java.base/java/lang/classfile/Attribute.class", - "/modules/java.base/java/lang/classfile/ClassElement.class", - "/modules/java.base/java/lang/classfile/MethodElement.class", - "/modules/java.base/java/lang/classfile/FieldElement.class", - "/modules/java.base/java/lang/classfile/attribute/RuntimeVisibleAnnotationsAttribute.class", - "/modules/java.base/jdk/internal/classfile/impl/Util$Writable.class", - "/modules/java.base/jdk/internal/classfile/impl/AbstractElement.class", - "/modules/java.base/jdk/internal/classfile/impl/UnboundAttribute.class", - "/modules/java.base/jdk/internal/classfile/impl/UnboundAttribute$UnboundRuntimeVisibleAnnotationsAttribute.class", - "/modules/java.base/java/lang/classfile/Attributes.class", - "/modules/java.base/java/lang/classfile/AttributeMapper.class", - "/modules/java.base/jdk/internal/classfile/impl/AbstractAttributeMapper.class", - "/modules/java.base/jdk/internal/classfile/impl/AbstractAttributeMapper$RuntimeVisibleAnnotationsMapper.class", - "/modules/java.base/java/lang/classfile/AttributeMapper$AttributeStability.class", - "/modules/java.base/java/lang/invoke/MethodHandleImpl$Intrinsic.class", - "/modules/java.base/jdk/internal/classfile/impl/SplitConstantPool.class", - "/modules/java.base/java/lang/classfile/BootstrapMethodEntry.class", - "/modules/java.base/jdk/internal/classfile/impl/BootstrapMethodEntryImpl.class", - "/modules/java.base/jdk/internal/classfile/impl/EntryMap.class", - "/modules/java.base/jdk/internal/classfile/impl/Util.class", - "/modules/java.base/java/lang/classfile/constantpool/LoadableConstantEntry.class", - "/modules/java.base/java/lang/classfile/constantpool/ClassEntry.class", - "/modules/java.base/jdk/internal/classfile/impl/AbstractPoolEntry$AbstractRefEntry.class", - "/modules/java.base/jdk/internal/classfile/impl/AbstractPoolEntry$AbstractNamedEntry.class", - "/modules/java.base/jdk/internal/classfile/impl/AbstractPoolEntry$ClassEntryImpl.class", - "/modules/java.base/java/util/function/Consumer.class", - "/modules/java.base/java/lang/classfile/ClassFile.class", - "/modules/java.base/jdk/internal/classfile/impl/ClassFileImpl.class", - "/modules/java.base/java/lang/classfile/ClassFileBuilder.class", - "/modules/java.base/java/lang/classfile/ClassBuilder.class", - "/modules/java.base/jdk/internal/classfile/impl/AbstractDirectBuilder.class", - "/modules/java.base/jdk/internal/classfile/impl/DirectClassBuilder.class", - "/modules/java.base/jdk/internal/classfile/impl/AttributeHolder.class", - "/modules/java.base/java/lang/classfile/Superclass.class", - "/modules/java.base/jdk/internal/classfile/impl/SuperclassImpl.class", - "/modules/java.base/java/lang/classfile/attribute/SourceFileAttribute.class", - "/modules/java.base/jdk/internal/classfile/impl/UnboundAttribute$UnboundSourceFileAttribute.class", - "/modules/java.base/jdk/internal/classfile/impl/AbstractAttributeMapper$SourceFileMapper.class", - "/modules/java.base/jdk/internal/classfile/impl/BoundAttribute.class", - "/modules/java.base/java/lang/classfile/MethodBuilder.class", - "/modules/java.base/jdk/internal/classfile/impl/MethodInfo.class", - "/modules/java.base/jdk/internal/classfile/impl/TerminalMethodBuilder.class", - "/modules/java.base/jdk/internal/classfile/impl/DirectMethodBuilder.class", - "/modules/java.base/java/lang/classfile/constantpool/NameAndTypeEntry.class", - "/modules/java.base/jdk/internal/classfile/impl/AbstractPoolEntry$AbstractRefsEntry.class", - "/modules/java.base/jdk/internal/classfile/impl/AbstractPoolEntry$NameAndTypeEntryImpl.class", - "/modules/java.base/java/lang/classfile/constantpool/MemberRefEntry.class", - "/modules/java.base/java/lang/classfile/constantpool/FieldRefEntry.class", - "/modules/java.base/jdk/internal/classfile/impl/AbstractPoolEntry$AbstractMemberRefEntry.class", - "/modules/java.base/jdk/internal/classfile/impl/AbstractPoolEntry$FieldRefEntryImpl.class", - "/modules/java.base/java/lang/invoke/InvokerBytecodeGenerator$ClassData.class", - "/modules/java.base/java/lang/classfile/CodeBuilder.class", - "/modules/java.base/jdk/internal/classfile/impl/LabelContext.class", - "/modules/java.base/jdk/internal/classfile/impl/TerminalCodeBuilder.class", - "/modules/java.base/jdk/internal/classfile/impl/DirectCodeBuilder.class", - "/modules/java.base/java/lang/classfile/CodeElement.class", - "/modules/java.base/java/lang/classfile/PseudoInstruction.class", - "/modules/java.base/java/lang/classfile/instruction/CharacterRange.class", - "/modules/java.base/java/lang/classfile/instruction/LocalVariable.class", - "/modules/java.base/java/lang/classfile/instruction/LocalVariableType.class", - "/modules/java.base/jdk/internal/classfile/impl/DirectCodeBuilder$DeferredLabel.class", - "/modules/java.base/java/lang/classfile/BufWriter.class", - "/modules/java.base/jdk/internal/classfile/impl/BufWriterImpl.class", - "/modules/java.base/java/lang/classfile/Label.class", - "/modules/java.base/java/lang/classfile/instruction/LabelTarget.class", - "/modules/java.base/jdk/internal/classfile/impl/LabelImpl.class", - "/modules/java.base/sun/invoke/util/VerifyType.class", - "/modules/java.base/java/lang/classfile/Opcode.class", - "/modules/java.base/java/lang/classfile/Opcode$Kind.class", - "/modules/java.base/java/lang/classfile/constantpool/MethodRefEntry.class", - "/modules/java.base/jdk/internal/classfile/impl/AbstractPoolEntry$MethodRefEntryImpl.class", - "/modules/java.base/sun/invoke/empty/Empty.class", - "/modules/java.base/jdk/internal/classfile/impl/BytecodeHelpers.class", - "/modules/java.base/jdk/internal/classfile/impl/UnboundAttribute$AdHocAttribute.class", - "/modules/java.base/jdk/internal/classfile/impl/AbstractAttributeMapper$CodeMapper.class", - "/modules/java.base/java/lang/classfile/FieldBuilder.class", - "/modules/java.base/jdk/internal/classfile/impl/TerminalFieldBuilder.class", - "/modules/java.base/jdk/internal/classfile/impl/DirectFieldBuilder.class", - "/modules/java.base/java/lang/classfile/CustomAttribute.class", - "/modules/java.base/jdk/internal/classfile/impl/AnnotationReader.class", - "/modules/java.base/java/util/ListIterator.class", - "/modules/java.base/java/util/ImmutableCollections$ListItr.class", - "/modules/java.base/jdk/internal/classfile/impl/StackMapGenerator.class", - "/modules/java.base/jdk/internal/classfile/impl/StackMapGenerator$Frame.class", - "/modules/java.base/jdk/internal/classfile/impl/StackMapGenerator$Type.class", - "/modules/java.base/jdk/internal/classfile/impl/RawBytecodeHelper.class", - "/modules/java.base/jdk/internal/classfile/impl/RawBytecodeHelper$CodeRange.class", - "/modules/java.base/jdk/internal/classfile/impl/ClassHierarchyImpl.class", - "/modules/java.base/java/lang/classfile/ClassHierarchyResolver.class", - "/modules/java.base/jdk/internal/classfile/impl/ClassHierarchyImpl$ClassLoadingClassHierarchyResolver.class", - "/modules/java.base/jdk/internal/classfile/impl/ClassHierarchyImpl$CachedClassHierarchyResolver.class", - "/modules/java.base/java/lang/classfile/ClassHierarchyResolver$ClassHierarchyInfo.class", - "/modules/java.base/jdk/internal/classfile/impl/ClassHierarchyImpl$ClassHierarchyInfoImpl.class", - "/modules/java.base/java/lang/classfile/ClassReader.class", - "/modules/java.base/jdk/internal/classfile/impl/ClassReaderImpl.class", - "/modules/java.base/jdk/internal/util/ModifiedUtf.class", - "/modules/java.base/java/lang/invoke/MethodHandles$Lookup$ClassDefiner.class", - "/modules/java.base/java/lang/IncompatibleClassChangeError.class", - "/modules/java.base/java/lang/NoSuchMethodError.class", - "/modules/java.base/java/lang/invoke/BootstrapMethodInvoker.class", - "/modules/java.base/java/lang/invoke/AbstractValidatingLambdaMetafactory.class", - "/modules/java.base/java/lang/invoke/InnerClassLambdaMetafactory.class", - "/modules/java.base/java/lang/invoke/MethodHandleInfo.class", - "/modules/java.base/java/lang/invoke/InfoFromMemberName.class", - "/modules/java.base/java/util/ImmutableCollections$Access.class", - "/modules/java.base/jdk/internal/access/JavaUtilCollectionAccess.class", - "/modules/java.base/java/lang/classfile/Interfaces.class", - "/modules/java.base/jdk/internal/classfile/impl/InterfacesImpl.class", - "/modules/java.base/java/lang/invoke/TypeConvertingMethodAdapter.class", - "/modules/java.base/java/lang/invoke/DirectMethodHandle$Constructor.class", - "/modules/java.base/jdk/internal/access/JavaLangInvokeAccess.class", - "/modules/java.base/java/lang/invoke/VarHandle$AccessMode.class", - "/modules/java.base/java/lang/invoke/VarHandle$AccessType.class", - "/modules/java.base/java/lang/invoke/Invokers$Holder.class", - "/modules/java.base/jdk/internal/module/ModuleInfo.class", - "/modules/java.base/java/io/DataInput.class", - "/modules/java.base/java/io/DataInputStream.class", - "/modules/java.base/jdk/internal/module/ModuleInfo$CountingDataInput.class", - "/modules/java.base/sun/nio/ch/NativeThread.class", - "/modules/java.base/jdk/internal/misc/Blocker.class", - "/modules/java.base/sun/nio/ch/Util.class", - "/modules/java.base/sun/nio/ch/Util$BufferCache.class", - "/modules/java.base/sun/nio/ch/IOStatus.class", - "/modules/java.base/jdk/internal/util/ByteArray.class", - "/modules/java.base/java/lang/invoke/VarHandles.class", - "/modules/java.base/java/lang/invoke/VarHandleByteArrayAsShorts$ByteArrayViewVarHandle.class", - "/modules/java.base/java/lang/invoke/VarHandleByteArrayAsShorts$ArrayHandle.class", - "/modules/java.base/java/lang/invoke/VarHandleGuards.class", - "/modules/java.base/java/lang/invoke/VarForm.class", - "/modules/java.base/java/lang/invoke/VarHandleByteArrayAsChars$ByteArrayViewVarHandle.class", - "/modules/java.base/java/lang/invoke/VarHandleByteArrayAsChars$ArrayHandle.class", - "/modules/java.base/java/lang/invoke/VarHandleByteArrayAsInts$ByteArrayViewVarHandle.class", - "/modules/java.base/java/lang/invoke/VarHandleByteArrayAsInts$ArrayHandle.class", - "/modules/java.base/java/lang/invoke/VarHandleByteArrayAsFloats$ByteArrayViewVarHandle.class", - "/modules/java.base/java/lang/invoke/VarHandleByteArrayAsFloats$ArrayHandle.class", - "/modules/java.base/java/lang/invoke/VarHandleByteArrayAsLongs$ByteArrayViewVarHandle.class", - "/modules/java.base/java/lang/invoke/VarHandleByteArrayAsLongs$ArrayHandle.class", - "/modules/java.base/java/lang/invoke/VarHandleByteArrayAsDoubles$ByteArrayViewVarHandle.class", - "/modules/java.base/java/lang/invoke/VarHandleByteArrayAsDoubles$ArrayHandle.class", - "/modules/java.base/java/lang/invoke/VarHandle$AccessDescriptor.class", - "/modules/java.base/jdk/internal/module/ModuleInfo$ConstantPool.class", - "/modules/java.base/jdk/internal/module/ModuleInfo$ConstantPool$Entry.class", - "/modules/java.base/jdk/internal/module/ModuleInfo$ConstantPool$IndexEntry.class", - "/modules/java.base/java/nio/charset/StandardCharsets.class", - "/modules/java.base/sun/nio/cs/US_ASCII.class", - "/modules/java.base/sun/nio/cs/ISO_8859_1.class", - "/modules/java.base/sun/nio/cs/UTF_16BE.class", - "/modules/java.base/sun/nio/cs/UTF_16LE.class", - "/modules/java.base/sun/nio/cs/UTF_16.class", - "/modules/java.base/sun/nio/cs/UTF_32BE.class", - "/modules/java.base/sun/nio/cs/UTF_32LE.class", - "/modules/java.base/sun/nio/cs/UTF_32.class", - "/modules/java.base/jdk/internal/module/ModuleInfo$ConstantPool$ValueEntry.class", - "/modules/java.base/java/lang/module/ModuleDescriptor$Builder.class", - "/modules/java.base/java/lang/module/ModuleDescriptor$Modifier.class", - "/modules/java.base/java/lang/reflect/AccessFlag.class", - "/modules/java.base/java/lang/reflect/AccessFlag$Location.class", - "/modules/java.base/java/lang/module/ModuleDescriptor$Requires$Modifier.class", - "/modules/java.base/java/lang/module/ModuleDescriptor$Requires.class", - "/modules/java.base/java/util/HashMap$KeySet.class", - "/modules/java.base/java/util/HashMap$KeyIterator.class", - "/modules/java.base/jdk/internal/module/Checks.class", - "/modules/java.base/java/util/ArrayList$Itr.class", - "/modules/java.base/java/lang/module/ModuleDescriptor$Provides.class", - "/modules/java.base/java/util/Collections$UnmodifiableCollection.class", - "/modules/java.base/java/util/Collections$UnmodifiableSet.class", - "/modules/java.base/java/util/HashMap$Values.class", - "/modules/java.base/java/util/HashMap$ValueIterator.class", - "/modules/java.base/java/util/ImmutableCollections$SetN$SetNIterator.class", - "/modules/java.base/jdk/internal/module/ModuleInfo$Attributes.class", - "/modules/java.base/jdk/internal/module/ModuleReferences.class", - "/modules/java.base/java/lang/module/ModuleReader.class", - "/modules/java.base/sun/nio/fs/UnixUriUtils.class", - "/modules/java.base/java/net/URI$Parser.class", - "/modules/java.base/java/lang/module/ModuleReference.class", - "/modules/java.base/jdk/internal/module/ModuleReferenceImpl.class", - "/modules/java.base/java/lang/module/ModuleDescriptor$Exports.class", - "/modules/java.base/java/lang/module/ModuleDescriptor$Opens.class", - "/modules/java.base/sun/nio/fs/UnixException.class", - "/modules/java.base/java/io/IOException.class", - "/modules/java.base/jdk/internal/loader/ArchivedClassLoaders.class", - "/modules/java.base/jdk/internal/loader/ClassLoaders$BootClassLoader.class", - "/modules/java.base/java/lang/ClassLoader$ParallelLoaders.class", - "/modules/java.base/java/util/WeakHashMap.class", - "/modules/java.base/java/util/WeakHashMap$Entry.class", - "/modules/java.base/java/util/WeakHashMap$KeySet.class", - "/modules/java.base/java/security/Principal.class", - "/modules/java.base/jdk/internal/loader/URLClassPath.class", - "/modules/java.base/java/net/URLStreamHandlerFactory.class", - "/modules/java.base/java/net/URL$DefaultFactory.class", - "/modules/java.base/jdk/internal/access/JavaNetURLAccess.class", - "/modules/java.base/sun/net/www/ParseUtil.class", - "/modules/java.base/java/net/URLStreamHandler.class", - "/modules/java.base/sun/net/www/protocol/file/Handler.class", - "/modules/java.base/sun/net/util/IPAddressUtil.class", - "/modules/java.base/sun/net/util/IPAddressUtil$MASKS.class", - "/modules/java.base/sun/net/www/protocol/jar/Handler.class", - "/modules/java.base/jdk/internal/module/ServicesCatalog.class", - "/modules/java.base/jdk/internal/loader/AbstractClassLoaderValue.class", - "/modules/java.base/jdk/internal/loader/ClassLoaderValue.class", - "/modules/java.base/jdk/internal/loader/BuiltinClassLoader$LoadedModule.class", - "/modules/java.base/jdk/internal/module/DefaultRoots.class", - "/modules/java.base/java/util/Spliterator.class", - "/modules/java.base/java/util/HashMap$HashMapSpliterator.class", - "/modules/java.base/java/util/HashMap$ValueSpliterator.class", - "/modules/java.base/java/util/stream/StreamSupport.class", - "/modules/java.base/java/util/stream/BaseStream.class", - "/modules/java.base/java/util/stream/Stream.class", - "/modules/java.base/java/util/stream/PipelineHelper.class", - "/modules/java.base/java/util/stream/AbstractPipeline.class", - "/modules/java.base/java/util/stream/ReferencePipeline.class", - "/modules/java.base/java/util/stream/ReferencePipeline$Head.class", - "/modules/java.base/java/util/stream/StreamOpFlag.class", - "/modules/java.base/java/util/stream/StreamOpFlag$Type.class", - "/modules/java.base/java/util/stream/StreamOpFlag$MaskBuilder.class", - "/modules/java.base/java/util/EnumMap.class", - "/modules/java.base/java/lang/Class$ReflectionData.class", - "/modules/java.base/java/lang/Class$Atomic.class", - "/modules/java.base/java/lang/PublicMethods$MethodList.class", - "/modules/java.base/java/lang/PublicMethods$Key.class", - "/modules/java.base/sun/reflect/annotation/AnnotationParser.class", - "/modules/java.base/jdk/internal/reflect/MethodHandleAccessorFactory.class", - "/modules/java.base/jdk/internal/reflect/MethodHandleAccessorFactory$LazyStaticHolder.class", - "/modules/java.base/java/lang/invoke/BoundMethodHandle.class", - "/modules/java.base/java/lang/invoke/ClassSpecializer.class", - "/modules/java.base/java/lang/invoke/BoundMethodHandle$Specializer.class", - "/modules/java.base/jdk/internal/vm/annotation/Stable.class", - "/modules/java.base/java/lang/invoke/ClassSpecializer$SpeciesData.class", - "/modules/java.base/java/lang/invoke/BoundMethodHandle$SpeciesData.class", - "/modules/java.base/java/lang/invoke/ClassSpecializer$Factory.class", - "/modules/java.base/java/lang/invoke/BoundMethodHandle$Specializer$Factory.class", - "/modules/java.base/java/lang/invoke/SimpleMethodHandle.class", - "/modules/java.base/java/lang/NoSuchFieldException.class", - "/modules/java.base/java/lang/invoke/BoundMethodHandle$Species_L.class", - "/modules/java.base/java/lang/invoke/DirectMethodHandle$Accessor.class", - "/modules/java.base/java/lang/invoke/DelegatingMethodHandle.class", - "/modules/java.base/java/lang/invoke/DelegatingMethodHandle$Holder.class", - "/modules/java.base/java/lang/invoke/LambdaFormEditor.class", - "/modules/java.base/java/lang/invoke/LambdaFormEditor$TransformKey.class", - "/modules/java.base/java/lang/invoke/LambdaFormBuffer.class", - "/modules/java.base/java/lang/invoke/LambdaFormEditor$Transform.class", - "/modules/java.base/jdk/internal/reflect/DirectMethodHandleAccessor.class", - "/modules/java.base/java/util/stream/Collectors.class", - "/modules/java.base/java/util/stream/Collector$Characteristics.class", - "/modules/java.base/java/util/EnumSet.class", - "/modules/java.base/java/util/RegularEnumSet.class", - "/modules/java.base/java/util/stream/Collector.class", - "/modules/java.base/java/util/stream/Collectors$CollectorImpl.class", - "/modules/java.base/java/util/function/BiConsumer.class", - "/modules/java.base/java/lang/invoke/DirectMethodHandle$Interface.class", - "/modules/java.base/java/lang/classfile/constantpool/InterfaceMethodRefEntry.class", - "/modules/java.base/jdk/internal/classfile/impl/AbstractPoolEntry$InterfaceMethodRefEntryImpl.class", - "/modules/java.base/java/util/function/BinaryOperator.class", - "/modules/java.base/java/util/stream/ReduceOps.class", - "/modules/java.base/java/util/stream/TerminalOp.class", - "/modules/java.base/java/util/stream/ReduceOps$ReduceOp.class", - "/modules/java.base/java/util/stream/StreamShape.class", - "/modules/java.base/java/util/stream/Sink.class", - "/modules/java.base/java/util/stream/TerminalSink.class", - "/modules/java.base/java/util/stream/ReduceOps$AccumulatingSink.class", - "/modules/java.base/java/util/stream/ReduceOps$Box.class", - "/modules/java.base/java/util/HashMap$KeySpliterator.class", - "/modules/java.base/java/util/function/Predicate.class", - "/modules/java.base/java/util/stream/ReferencePipeline$StatelessOp.class", - "/modules/java.base/java/util/stream/Sink$ChainedReference.class", - "/modules/java.base/jdk/internal/module/ModuleResolution.class", - "/modules/java.base/java/util/stream/FindOps.class", - "/modules/java.base/java/util/stream/FindOps$FindSink.class", - "/modules/java.base/java/util/stream/FindOps$FindSink$OfRef.class", - "/modules/java.base/java/util/stream/FindOps$FindOp.class", - "/modules/java.base/java/util/Spliterators.class", - "/modules/java.base/java/util/Spliterators$IteratorSpliterator.class", - "/modules/java.base/java/lang/module/Configuration.class", - "/modules/java.base/java/lang/module/Resolver.class", - "/modules/java.base/java/lang/ModuleLayer.class", - "/modules/java.base/java/util/SequencedSet.class", - "/modules/java.base/java/util/LinkedHashSet.class", - "/modules/java.base/java/util/SequencedMap.class", - "/modules/java.base/java/util/LinkedHashMap.class", - "/modules/java.base/java/lang/module/ResolvedModule.class", - "/modules/java.base/jdk/internal/module/ModuleLoaderMap$Mapper.class", - "/modules/java.base/jdk/internal/loader/AbstractClassLoaderValue$Memoizer.class", - "/modules/java.base/jdk/internal/module/ServicesCatalog$ServiceProvider.class", - "/modules/java.base/java/util/concurrent/CopyOnWriteArrayList.class", - "/modules/java.base/java/lang/ModuleLayer$Controller.class", - "/modules/java.base/jdk/internal/module/ModuleBootstrap$SafeModuleFinder.class", - "/modules/java.base/jdk/internal/vm/ContinuationSupport.class", - "/modules/java.base/jdk/internal/vm/Continuation$Pinned.class", - "/modules/java.base/sun/launcher/LauncherHelper.class", - "/modules/java.base/sun/net/util/URLUtil.class", - "/modules/java.base/jdk/internal/loader/URLClassPath$Loader.class", - "/modules/java.base/jdk/internal/loader/URLClassPath$FileLoader.class", - "/modules/java.base/jdk/internal/loader/Resource.class", - "/modules/java.base/java/io/FileCleanable.class", - "/modules/java.base/sun/nio/ByteBuffered.class", - "/modules/java.base/java/security/SecureClassLoader$CodeSourceKey.class", - "/modules/java.base/java/security/PermissionCollection.class", - "/modules/java.base/java/security/Permissions.class", - "/modules/java.base/java/lang/NamedPackage.class", - "/modules/java.base/jdk/internal/misc/MethodFinder.class", - "/modules/java.base/java/lang/Readable.class", - "/modules/java.base/java/nio/CharBuffer.class", - "/modules/java.base/java/nio/HeapCharBuffer.class", - "/modules/java.base/java/nio/charset/CoderResult.class", - "/modules/java.base/java/util/IdentityHashMap$IdentityHashMapIterator.class", - "/modules/java.base/java/util/IdentityHashMap$KeyIterator.class", - "/modules/java.base/java/lang/Shutdown.class", - "/modules/java.base/java/lang/Shutdown$Lock.class"); + /// Note: This list is inherently a little fragile and may end up being more + /// trouble than it's worth to maintain. If it turns out that it needs to be + /// regenerated often when this benchmark is run, then a new approach should + /// be considered, such as: + /// * Limit the list of classes to non-internal ones. + /// * Calculate the list dynamically based on the running JVM. + /// * Build a custom jimage file similar to ImageReaderTest + private static final class ClassList { + /// Returns the names of resource nodes expected to be present in the + /// reader, excluding preview mode paths (i.e. "/META-INF/preview/"). + private static Set names() { + return INIT_CLASSES; + } + + /// Returns the number of resources present. + private static int count() { + return INIT_CLASSES.size(); + } + + /// Returns the resource nodes represented as a map from module name to + /// resource path. This is suitable for testing functions like + /// {@link ImageReader#containsResource(String, String)} without the + /// overhead of splitting resource names during the trial. + private static Map> pathMap() { + return MODULE_TO_PATHS; + } + + // Created by running "java -verbose:class", throwing away anonymous inner + // classes and anything without a reliable name, and grouping by the stated + // source. It's not perfect, but it's representative. + // + // /bin/java -verbose:class HelloWorld 2>&1 \ + // | fgrep '[class,load]' | cut -d' ' -f2 \ + // | tr '.' '/' \ + // | egrep -v '\$[0-9$]' \ + // | fgrep -v 'HelloWorld' \ + // | fgrep -v '/META-INF/preview/' \ + // | while read f ; do echo "${f}.class" ; done \ + // > initclasses.txt + // + // Output: + // java/lang/Object.class + // java/io/Serializable.class + // ... + // + // jimage list /images/jdk/lib/modules \ + // | awk '/^Module: */ { MOD=$2 }; /^ */ { print "/modules/"MOD"/"$1 }' \ + // > fullpaths.txt + // + // Output: + // ... + // /modules/java.base/java/lang/Object.class + // /modules/java.base/java/lang/OutOfMemoryError.class + // ... + // + // while read c ; do grep "/$c" fullpaths.txt ; done < initclasses.txt \ + // | while read c ; do printf ' "%s",\n' "$c" ; done \ + // > initpaths.txt + // + // Output: + private static final Set INIT_CLASSES = Set.of( + "/modules/java.base/java/lang/Object.class", + "/modules/java.base/java/io/Serializable.class", + "/modules/java.base/java/lang/Comparable.class", + "/modules/java.base/java/lang/CharSequence.class", + "/modules/java.base/java/lang/constant/Constable.class", + "/modules/java.base/java/lang/constant/ConstantDesc.class", + "/modules/java.base/java/lang/String.class", + "/modules/java.base/java/lang/reflect/AnnotatedElement.class", + "/modules/java.base/java/lang/reflect/GenericDeclaration.class", + "/modules/java.base/java/lang/reflect/Type.class", + "/modules/java.base/java/lang/invoke/TypeDescriptor.class", + "/modules/java.base/java/lang/invoke/TypeDescriptor$OfField.class", + "/modules/java.base/java/lang/Class.class", + "/modules/java.base/java/lang/Cloneable.class", + "/modules/java.base/java/lang/ClassLoader.class", + "/modules/java.base/java/lang/System.class", + "/modules/java.base/java/lang/Throwable.class", + "/modules/java.base/java/lang/Error.class", + "/modules/java.base/java/lang/Exception.class", + "/modules/java.base/java/lang/RuntimeException.class", + "/modules/java.base/java/security/ProtectionDomain.class", + "/modules/java.base/java/security/SecureClassLoader.class", + "/modules/java.base/java/lang/ReflectiveOperationException.class", + "/modules/java.base/java/lang/ClassNotFoundException.class", + "/modules/java.base/java/lang/Record.class", + "/modules/java.base/java/lang/LinkageError.class", + "/modules/java.base/java/lang/NoClassDefFoundError.class", + "/modules/java.base/java/lang/ClassCastException.class", + "/modules/java.base/java/lang/ArrayStoreException.class", + "/modules/java.base/java/lang/VirtualMachineError.class", + "/modules/java.base/java/lang/InternalError.class", + "/modules/java.base/java/lang/OutOfMemoryError.class", + "/modules/java.base/java/lang/StackOverflowError.class", + "/modules/java.base/java/lang/IllegalMonitorStateException.class", + "/modules/java.base/java/lang/ref/Reference.class", + "/modules/java.base/java/lang/IllegalCallerException.class", + "/modules/java.base/java/lang/ref/SoftReference.class", + "/modules/java.base/java/lang/ref/WeakReference.class", + "/modules/java.base/java/lang/ref/FinalReference.class", + "/modules/java.base/java/lang/ref/PhantomReference.class", + "/modules/java.base/java/lang/ref/Finalizer.class", + "/modules/java.base/java/lang/Runnable.class", + "/modules/java.base/java/lang/Thread.class", + "/modules/java.base/java/lang/Thread$FieldHolder.class", + "/modules/java.base/java/lang/Thread$Constants.class", + "/modules/java.base/java/lang/Thread$UncaughtExceptionHandler.class", + "/modules/java.base/java/lang/ThreadGroup.class", + "/modules/java.base/java/lang/BaseVirtualThread.class", + "/modules/java.base/java/lang/VirtualThread.class", + "/modules/java.base/java/lang/ThreadBuilders$BoundVirtualThread.class", + "/modules/java.base/java/util/Map.class", + "/modules/java.base/java/util/Dictionary.class", + "/modules/java.base/java/util/Hashtable.class", + "/modules/java.base/java/util/Properties.class", + "/modules/java.base/java/lang/Module.class", + "/modules/java.base/java/lang/reflect/AccessibleObject.class", + "/modules/java.base/java/lang/reflect/Member.class", + "/modules/java.base/java/lang/reflect/Field.class", + "/modules/java.base/java/lang/reflect/Parameter.class", + "/modules/java.base/java/lang/reflect/Executable.class", + "/modules/java.base/java/lang/reflect/Method.class", + "/modules/java.base/java/lang/reflect/Constructor.class", + "/modules/java.base/jdk/internal/vm/ContinuationScope.class", + "/modules/java.base/jdk/internal/vm/Continuation.class", + "/modules/java.base/jdk/internal/vm/StackChunk.class", + "/modules/java.base/jdk/internal/reflect/MethodAccessor.class", + "/modules/java.base/jdk/internal/reflect/MethodAccessorImpl.class", + "/modules/java.base/jdk/internal/reflect/ConstantPool.class", + "/modules/java.base/java/lang/annotation/Annotation.class", + "/modules/java.base/jdk/internal/reflect/CallerSensitive.class", + "/modules/java.base/jdk/internal/reflect/ConstructorAccessor.class", + "/modules/java.base/jdk/internal/reflect/ConstructorAccessorImpl.class", + "/modules/java.base/jdk/internal/reflect/DirectConstructorHandleAccessor$NativeAccessor.class", + "/modules/java.base/java/lang/invoke/MethodHandle.class", + "/modules/java.base/java/lang/invoke/DirectMethodHandle.class", + "/modules/java.base/java/lang/invoke/VarHandle.class", + "/modules/java.base/java/lang/invoke/MemberName.class", + "/modules/java.base/java/lang/invoke/ResolvedMethodName.class", + "/modules/java.base/java/lang/invoke/MethodHandleNatives.class", + "/modules/java.base/java/lang/invoke/LambdaForm.class", + "/modules/java.base/java/lang/invoke/TypeDescriptor$OfMethod.class", + "/modules/java.base/java/lang/invoke/MethodType.class", + "/modules/java.base/java/lang/BootstrapMethodError.class", + "/modules/java.base/java/lang/invoke/CallSite.class", + "/modules/java.base/jdk/internal/foreign/abi/NativeEntryPoint.class", + "/modules/java.base/jdk/internal/foreign/abi/ABIDescriptor.class", + "/modules/java.base/jdk/internal/foreign/abi/VMStorage.class", + "/modules/java.base/jdk/internal/foreign/abi/UpcallLinker$CallRegs.class", + "/modules/java.base/java/lang/invoke/ConstantCallSite.class", + "/modules/java.base/java/lang/invoke/MutableCallSite.class", + "/modules/java.base/java/lang/invoke/VolatileCallSite.class", + "/modules/java.base/java/lang/AssertionStatusDirectives.class", + "/modules/java.base/java/lang/Appendable.class", + "/modules/java.base/java/lang/AbstractStringBuilder.class", + "/modules/java.base/java/lang/StringBuffer.class", + "/modules/java.base/java/lang/StringBuilder.class", + "/modules/java.base/jdk/internal/misc/UnsafeConstants.class", + "/modules/java.base/jdk/internal/misc/Unsafe.class", + "/modules/java.base/jdk/internal/module/Modules.class", + "/modules/java.base/java/lang/AutoCloseable.class", + "/modules/java.base/java/io/Closeable.class", + "/modules/java.base/java/io/InputStream.class", + "/modules/java.base/java/io/ByteArrayInputStream.class", + "/modules/java.base/java/net/URL.class", + "/modules/java.base/java/lang/Enum.class", + "/modules/java.base/java/util/jar/Manifest.class", + "/modules/java.base/jdk/internal/loader/BuiltinClassLoader.class", + "/modules/java.base/jdk/internal/loader/ClassLoaders.class", + "/modules/java.base/jdk/internal/loader/ClassLoaders$AppClassLoader.class", + "/modules/java.base/jdk/internal/loader/ClassLoaders$PlatformClassLoader.class", + "/modules/java.base/java/security/CodeSource.class", + "/modules/java.base/java/util/concurrent/ConcurrentMap.class", + "/modules/java.base/java/util/AbstractMap.class", + "/modules/java.base/java/util/concurrent/ConcurrentHashMap.class", + "/modules/java.base/java/lang/Iterable.class", + "/modules/java.base/java/util/Collection.class", + "/modules/java.base/java/util/SequencedCollection.class", + "/modules/java.base/java/util/List.class", + "/modules/java.base/java/util/RandomAccess.class", + "/modules/java.base/java/util/AbstractCollection.class", + "/modules/java.base/java/util/AbstractList.class", + "/modules/java.base/java/util/ArrayList.class", + "/modules/java.base/java/lang/StackTraceElement.class", + "/modules/java.base/java/nio/Buffer.class", + "/modules/java.base/java/lang/StackWalker.class", + "/modules/java.base/java/lang/StackStreamFactory$AbstractStackWalker.class", + "/modules/java.base/java/lang/StackWalker$StackFrame.class", + "/modules/java.base/java/lang/ClassFrameInfo.class", + "/modules/java.base/java/lang/StackFrameInfo.class", + "/modules/java.base/java/lang/LiveStackFrame.class", + "/modules/java.base/java/lang/LiveStackFrameInfo.class", + "/modules/java.base/java/util/concurrent/locks/AbstractOwnableSynchronizer.class", + "/modules/java.base/java/lang/Boolean.class", + "/modules/java.base/java/lang/Character.class", + "/modules/java.base/java/lang/Number.class", + "/modules/java.base/java/lang/Float.class", + "/modules/java.base/java/lang/Double.class", + "/modules/java.base/java/lang/Byte.class", + "/modules/java.base/java/lang/Short.class", + "/modules/java.base/java/lang/Integer.class", + "/modules/java.base/java/lang/Long.class", + "/modules/java.base/java/lang/Void.class", + "/modules/java.base/java/util/Iterator.class", + "/modules/java.base/java/lang/reflect/RecordComponent.class", + "/modules/java.base/jdk/internal/vm/vector/VectorSupport.class", + "/modules/java.base/jdk/internal/vm/vector/VectorSupport$VectorPayload.class", + "/modules/java.base/jdk/internal/vm/vector/VectorSupport$Vector.class", + "/modules/java.base/jdk/internal/vm/vector/VectorSupport$VectorMask.class", + "/modules/java.base/jdk/internal/vm/vector/VectorSupport$VectorShuffle.class", + "/modules/java.base/jdk/internal/vm/FillerObject.class", + "/modules/java.base/java/lang/NullPointerException.class", + "/modules/java.base/java/lang/ArithmeticException.class", + "/modules/java.base/java/lang/IndexOutOfBoundsException.class", + "/modules/java.base/java/lang/ArrayIndexOutOfBoundsException.class", + "/modules/java.base/java/io/ObjectStreamField.class", + "/modules/java.base/java/util/Comparator.class", + "/modules/java.base/java/lang/String$CaseInsensitiveComparator.class", + "/modules/java.base/jdk/internal/misc/VM.class", + "/modules/java.base/java/lang/Module$ArchivedData.class", + "/modules/java.base/jdk/internal/misc/CDS.class", + "/modules/java.base/java/util/Set.class", + "/modules/java.base/java/util/ImmutableCollections$AbstractImmutableCollection.class", + "/modules/java.base/java/util/ImmutableCollections$AbstractImmutableSet.class", + "/modules/java.base/java/util/ImmutableCollections$Set12.class", + "/modules/java.base/java/util/Objects.class", + "/modules/java.base/java/util/ImmutableCollections.class", + "/modules/java.base/java/util/ImmutableCollections$AbstractImmutableList.class", + "/modules/java.base/java/util/ImmutableCollections$ListN.class", + "/modules/java.base/java/util/ImmutableCollections$SetN.class", + "/modules/java.base/java/util/ImmutableCollections$AbstractImmutableMap.class", + "/modules/java.base/java/util/ImmutableCollections$MapN.class", + "/modules/java.base/jdk/internal/access/JavaLangReflectAccess.class", + "/modules/java.base/java/lang/reflect/ReflectAccess.class", + "/modules/java.base/jdk/internal/access/SharedSecrets.class", + "/modules/java.base/jdk/internal/reflect/ReflectionFactory.class", + "/modules/java.base/java/io/ObjectStreamClass.class", + "/modules/java.base/java/lang/Math.class", + "/modules/java.base/jdk/internal/reflect/ReflectionFactory$Config.class", + "/modules/java.base/jdk/internal/access/JavaLangRefAccess.class", + "/modules/java.base/java/lang/ref/ReferenceQueue.class", + "/modules/java.base/java/lang/ref/ReferenceQueue$Null.class", + "/modules/java.base/java/lang/ref/ReferenceQueue$Lock.class", + "/modules/java.base/jdk/internal/access/JavaLangAccess.class", + "/modules/java.base/jdk/internal/util/SystemProps.class", + "/modules/java.base/jdk/internal/util/SystemProps$Raw.class", + "/modules/java.base/java/nio/charset/Charset.class", + "/modules/java.base/java/nio/charset/spi/CharsetProvider.class", + "/modules/java.base/sun/nio/cs/StandardCharsets.class", + "/modules/java.base/java/lang/StringLatin1.class", + "/modules/java.base/sun/nio/cs/HistoricallyNamedCharset.class", + "/modules/java.base/sun/nio/cs/Unicode.class", + "/modules/java.base/sun/nio/cs/UTF_8.class", + "/modules/java.base/java/util/HashMap.class", + "/modules/java.base/java/lang/StrictMath.class", + "/modules/java.base/jdk/internal/util/ArraysSupport.class", + "/modules/java.base/java/util/Map$Entry.class", + "/modules/java.base/java/util/HashMap$Node.class", + "/modules/java.base/java/util/LinkedHashMap$Entry.class", + "/modules/java.base/java/util/HashMap$TreeNode.class", + "/modules/java.base/java/lang/StringConcatHelper.class", + "/modules/java.base/java/lang/VersionProps.class", + "/modules/java.base/java/lang/Runtime.class", + "/modules/java.base/java/util/concurrent/locks/Lock.class", + "/modules/java.base/java/util/concurrent/locks/ReentrantLock.class", + "/modules/java.base/java/util/concurrent/ConcurrentHashMap$Segment.class", + "/modules/java.base/java/util/concurrent/ConcurrentHashMap$CounterCell.class", + "/modules/java.base/java/util/concurrent/ConcurrentHashMap$Node.class", + "/modules/java.base/java/util/concurrent/locks/LockSupport.class", + "/modules/java.base/java/util/concurrent/ConcurrentHashMap$ReservationNode.class", + "/modules/java.base/java/util/AbstractSet.class", + "/modules/java.base/java/util/HashMap$EntrySet.class", + "/modules/java.base/java/util/HashMap$HashIterator.class", + "/modules/java.base/java/util/HashMap$EntryIterator.class", + "/modules/java.base/jdk/internal/util/StaticProperty.class", + "/modules/java.base/java/io/FileInputStream.class", + "/modules/java.base/java/lang/System$In.class", + "/modules/java.base/java/io/FileDescriptor.class", + "/modules/java.base/jdk/internal/access/JavaIOFileDescriptorAccess.class", + "/modules/java.base/java/io/Flushable.class", + "/modules/java.base/java/io/OutputStream.class", + "/modules/java.base/java/io/FileOutputStream.class", + "/modules/java.base/java/lang/System$Out.class", + "/modules/java.base/java/io/FilterInputStream.class", + "/modules/java.base/java/io/BufferedInputStream.class", + "/modules/java.base/java/io/FilterOutputStream.class", + "/modules/java.base/java/io/PrintStream.class", + "/modules/java.base/java/io/BufferedOutputStream.class", + "/modules/java.base/java/io/Writer.class", + "/modules/java.base/java/io/OutputStreamWriter.class", + "/modules/java.base/sun/nio/cs/StreamEncoder.class", + "/modules/java.base/java/nio/charset/CharsetEncoder.class", + "/modules/java.base/sun/nio/cs/UTF_8$Encoder.class", + "/modules/java.base/java/nio/charset/CodingErrorAction.class", + "/modules/java.base/java/util/Arrays.class", + "/modules/java.base/java/nio/ByteBuffer.class", + "/modules/java.base/jdk/internal/misc/ScopedMemoryAccess.class", + "/modules/java.base/java/util/function/Function.class", + "/modules/java.base/jdk/internal/util/Preconditions.class", + "/modules/java.base/java/util/function/BiFunction.class", + "/modules/java.base/jdk/internal/access/JavaNioAccess.class", + "/modules/java.base/java/nio/HeapByteBuffer.class", + "/modules/java.base/java/nio/ByteOrder.class", + "/modules/java.base/java/io/BufferedWriter.class", + "/modules/java.base/java/lang/Terminator.class", + "/modules/java.base/jdk/internal/misc/Signal$Handler.class", + "/modules/java.base/jdk/internal/misc/Signal.class", + "/modules/java.base/java/util/Hashtable$Entry.class", + "/modules/java.base/jdk/internal/misc/Signal$NativeHandler.class", + "/modules/java.base/java/lang/Integer$IntegerCache.class", + "/modules/java.base/jdk/internal/misc/OSEnvironment.class", + "/modules/java.base/java/lang/Thread$State.class", + "/modules/java.base/java/lang/ref/Reference$ReferenceHandler.class", + "/modules/java.base/java/lang/Thread$ThreadIdentifiers.class", + "/modules/java.base/java/lang/ref/Finalizer$FinalizerThread.class", + "/modules/java.base/jdk/internal/ref/Cleaner.class", + "/modules/java.base/java/util/Collections.class", + "/modules/java.base/java/util/Collections$EmptySet.class", + "/modules/java.base/java/util/Collections$EmptyList.class", + "/modules/java.base/java/util/Collections$EmptyMap.class", + "/modules/java.base/java/lang/IllegalArgumentException.class", + "/modules/java.base/java/lang/invoke/MethodHandleStatics.class", + "/modules/java.base/java/lang/reflect/ClassFileFormatVersion.class", + "/modules/java.base/java/lang/CharacterData.class", + "/modules/java.base/java/lang/CharacterDataLatin1.class", + "/modules/java.base/jdk/internal/util/ClassFileDumper.class", + "/modules/java.base/java/util/HexFormat.class", + "/modules/java.base/java/lang/Character$CharacterCache.class", + "/modules/java.base/java/util/concurrent/atomic/AtomicInteger.class", + "/modules/java.base/jdk/internal/module/ModuleBootstrap.class", + "/modules/java.base/java/lang/module/ModuleDescriptor.class", + "/modules/java.base/java/lang/invoke/MethodHandles.class", + "/modules/java.base/java/lang/invoke/MemberName$Factory.class", + "/modules/java.base/jdk/internal/reflect/Reflection.class", + "/modules/java.base/java/lang/invoke/MethodHandles$Lookup.class", + "/modules/java.base/java/util/ImmutableCollections$MapN$MapNIterator.class", + "/modules/java.base/java/util/KeyValueHolder.class", + "/modules/java.base/sun/invoke/util/VerifyAccess.class", + "/modules/java.base/java/lang/reflect/Modifier.class", + "/modules/java.base/jdk/internal/access/JavaLangModuleAccess.class", + "/modules/java.base/java/io/File.class", + "/modules/java.base/java/io/DefaultFileSystem.class", + "/modules/java.base/java/io/FileSystem.class", + "/modules/java.base/java/io/UnixFileSystem.class", + "/modules/java.base/jdk/internal/util/DecimalDigits.class", + "/modules/java.base/jdk/internal/module/ModulePatcher.class", + "/modules/java.base/jdk/internal/module/ModuleBootstrap$IllegalNativeAccess.class", + "/modules/java.base/java/util/HashSet.class", + "/modules/java.base/jdk/internal/module/ModuleLoaderMap.class", + "/modules/java.base/jdk/internal/module/ModuleLoaderMap$Modules.class", + "/modules/java.base/jdk/internal/module/ModuleBootstrap$Counters.class", + "/modules/java.base/jdk/internal/module/ArchivedBootLayer.class", + "/modules/java.base/jdk/internal/module/ArchivedModuleGraph.class", + "/modules/java.base/jdk/internal/module/SystemModuleFinders.class", + "/modules/java.base/java/net/URI.class", + "/modules/java.base/jdk/internal/access/JavaNetUriAccess.class", + "/modules/java.base/jdk/internal/module/SystemModulesMap.class", + "/modules/java.base/jdk/internal/module/SystemModules.class", + "/modules/java.base/jdk/internal/module/ExplodedSystemModules.class", + "/modules/java.base/java/nio/file/Watchable.class", + "/modules/java.base/java/nio/file/Path.class", + "/modules/java.base/java/nio/file/FileSystems.class", + "/modules/java.base/sun/nio/fs/DefaultFileSystemProvider.class", + "/modules/java.base/java/nio/file/spi/FileSystemProvider.class", + "/modules/java.base/sun/nio/fs/AbstractFileSystemProvider.class", + "/modules/java.base/sun/nio/fs/UnixFileSystemProvider.class", + "/modules/java.base/sun/nio/fs/LinuxFileSystemProvider.class", + "/modules/java.base/java/nio/file/OpenOption.class", + "/modules/java.base/java/nio/file/StandardOpenOption.class", + "/modules/java.base/java/nio/file/FileSystem.class", + "/modules/java.base/sun/nio/fs/UnixFileSystem.class", + "/modules/java.base/sun/nio/fs/LinuxFileSystem.class", + "/modules/java.base/sun/nio/fs/UnixPath.class", + "/modules/java.base/sun/nio/fs/Util.class", + "/modules/java.base/java/lang/StringCoding.class", + "/modules/java.base/sun/nio/fs/UnixNativeDispatcher.class", + "/modules/java.base/jdk/internal/loader/BootLoader.class", + "/modules/java.base/java/lang/Module$EnableNativeAccess.class", + "/modules/java.base/jdk/internal/loader/NativeLibraries.class", + "/modules/java.base/jdk/internal/loader/ClassLoaderHelper.class", + "/modules/java.base/java/util/concurrent/ConcurrentHashMap$CollectionView.class", + "/modules/java.base/java/util/concurrent/ConcurrentHashMap$KeySetView.class", + "/modules/java.base/jdk/internal/loader/NativeLibraries$LibraryPaths.class", + "/modules/java.base/java/io/File$PathStatus.class", + "/modules/java.base/jdk/internal/loader/NativeLibraries$CountedLock.class", + "/modules/java.base/java/util/concurrent/locks/AbstractQueuedSynchronizer.class", + "/modules/java.base/java/util/concurrent/locks/ReentrantLock$Sync.class", + "/modules/java.base/java/util/concurrent/locks/ReentrantLock$NonfairSync.class", + "/modules/java.base/jdk/internal/loader/NativeLibraries$NativeLibraryContext.class", + "/modules/java.base/java/util/Queue.class", + "/modules/java.base/java/util/Deque.class", + "/modules/java.base/java/util/ArrayDeque.class", + "/modules/java.base/java/util/ArrayDeque$DeqIterator.class", + "/modules/java.base/jdk/internal/loader/NativeLibrary.class", + "/modules/java.base/jdk/internal/loader/NativeLibraries$NativeLibraryImpl.class", + "/modules/java.base/java/security/cert/Certificate.class", + "/modules/java.base/java/util/concurrent/ConcurrentHashMap$ValuesView.class", + "/modules/java.base/java/util/Enumeration.class", + "/modules/java.base/java/util/concurrent/ConcurrentHashMap$Traverser.class", + "/modules/java.base/java/util/concurrent/ConcurrentHashMap$BaseIterator.class", + "/modules/java.base/java/util/concurrent/ConcurrentHashMap$ValueIterator.class", + "/modules/java.base/java/nio/file/attribute/BasicFileAttributes.class", + "/modules/java.base/java/nio/file/attribute/PosixFileAttributes.class", + "/modules/java.base/sun/nio/fs/UnixFileAttributes.class", + "/modules/java.base/sun/nio/fs/UnixFileStoreAttributes.class", + "/modules/java.base/sun/nio/fs/UnixMountEntry.class", + "/modules/java.base/java/nio/file/CopyOption.class", + "/modules/java.base/java/nio/file/LinkOption.class", + "/modules/java.base/java/nio/file/Files.class", + "/modules/java.base/sun/nio/fs/NativeBuffers.class", + "/modules/java.base/java/lang/ThreadLocal.class", + "/modules/java.base/jdk/internal/misc/CarrierThreadLocal.class", + "/modules/java.base/jdk/internal/misc/TerminatingThreadLocal.class", + "/modules/java.base/java/lang/ThreadLocal$ThreadLocalMap.class", + "/modules/java.base/java/lang/ThreadLocal$ThreadLocalMap$Entry.class", + "/modules/java.base/java/util/IdentityHashMap.class", + "/modules/java.base/java/util/Collections$SetFromMap.class", + "/modules/java.base/java/util/IdentityHashMap$KeySet.class", + "/modules/java.base/sun/nio/fs/NativeBuffer.class", + "/modules/java.base/jdk/internal/ref/CleanerFactory.class", + "/modules/java.base/java/util/concurrent/ThreadFactory.class", + "/modules/java.base/java/lang/ref/Cleaner.class", + "/modules/java.base/jdk/internal/ref/CleanerImpl.class", + "/modules/java.base/jdk/internal/ref/CleanerImpl$CleanableList.class", + "/modules/java.base/jdk/internal/ref/CleanerImpl$CleanableList$Node.class", + "/modules/java.base/java/lang/ref/Cleaner$Cleanable.class", + "/modules/java.base/jdk/internal/ref/PhantomCleanable.class", + "/modules/java.base/jdk/internal/ref/CleanerImpl$CleanerCleanable.class", + "/modules/java.base/jdk/internal/misc/InnocuousThread.class", + "/modules/java.base/sun/nio/fs/NativeBuffer$Deallocator.class", + "/modules/java.base/jdk/internal/ref/CleanerImpl$PhantomCleanableRef.class", + "/modules/java.base/java/lang/module/ModuleFinder.class", + "/modules/java.base/jdk/internal/module/ModulePath.class", + "/modules/java.base/java/util/jar/Attributes$Name.class", + "/modules/java.base/java/lang/reflect/Array.class", + "/modules/java.base/jdk/internal/perf/PerfCounter.class", + "/modules/java.base/jdk/internal/perf/Perf.class", + "/modules/java.base/sun/nio/ch/DirectBuffer.class", + "/modules/java.base/java/nio/MappedByteBuffer.class", + "/modules/java.base/java/nio/DirectByteBuffer.class", + "/modules/java.base/java/nio/Bits.class", + "/modules/java.base/java/util/concurrent/atomic/AtomicLong.class", + "/modules/java.base/jdk/internal/misc/VM$BufferPool.class", + "/modules/java.base/java/nio/LongBuffer.class", + "/modules/java.base/java/nio/DirectLongBufferU.class", + "/modules/java.base/java/util/zip/ZipConstants.class", + "/modules/java.base/java/util/zip/ZipFile.class", + "/modules/java.base/java/util/jar/JarFile.class", + "/modules/java.base/java/util/BitSet.class", + "/modules/java.base/jdk/internal/access/JavaUtilZipFileAccess.class", + "/modules/java.base/jdk/internal/access/JavaUtilJarAccess.class", + "/modules/java.base/java/util/jar/JavaUtilJarAccessImpl.class", + "/modules/java.base/java/lang/Runtime$Version.class", + "/modules/java.base/java/util/ImmutableCollections$List12.class", + "/modules/java.base/java/util/Optional.class", + "/modules/java.base/java/nio/file/attribute/DosFileAttributes.class", + "/modules/java.base/java/nio/file/attribute/AttributeView.class", + "/modules/java.base/java/nio/file/attribute/FileAttributeView.class", + "/modules/java.base/java/nio/file/attribute/BasicFileAttributeView.class", + "/modules/java.base/java/nio/file/attribute/DosFileAttributeView.class", + "/modules/java.base/java/nio/file/attribute/UserDefinedFileAttributeView.class", + "/modules/java.base/sun/nio/fs/UnixFileAttributeViews.class", + "/modules/java.base/sun/nio/fs/DynamicFileAttributeView.class", + "/modules/java.base/sun/nio/fs/AbstractBasicFileAttributeView.class", + "/modules/java.base/sun/nio/fs/UnixFileAttributeViews$Basic.class", + "/modules/java.base/sun/nio/fs/UnixFileAttributes$UnixAsBasicFileAttributes.class", + "/modules/java.base/java/nio/file/DirectoryStream$Filter.class", + "/modules/java.base/java/nio/file/Files$AcceptAllFilter.class", + "/modules/java.base/java/nio/file/DirectoryStream.class", + "/modules/java.base/java/nio/file/SecureDirectoryStream.class", + "/modules/java.base/sun/nio/fs/UnixSecureDirectoryStream.class", + "/modules/java.base/sun/nio/fs/UnixDirectoryStream.class", + "/modules/java.base/java/util/concurrent/locks/ReadWriteLock.class", + "/modules/java.base/java/util/concurrent/locks/ReentrantReadWriteLock.class", + "/modules/java.base/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.class", + "/modules/java.base/java/util/concurrent/locks/ReentrantReadWriteLock$Sync.class", + "/modules/java.base/java/util/concurrent/locks/ReentrantReadWriteLock$FairSync.class", + "/modules/java.base/java/util/concurrent/locks/ReentrantReadWriteLock$Sync$ThreadLocalHoldCounter.class", + "/modules/java.base/java/util/concurrent/locks/ReentrantReadWriteLock$ReadLock.class", + "/modules/java.base/java/util/concurrent/locks/ReentrantReadWriteLock$WriteLock.class", + "/modules/java.base/sun/nio/fs/UnixDirectoryStream$UnixDirectoryIterator.class", + "/modules/java.base/java/nio/file/attribute/FileAttribute.class", + "/modules/java.base/sun/nio/fs/UnixFileModeAttribute.class", + "/modules/java.base/sun/nio/fs/UnixChannelFactory.class", + "/modules/java.base/sun/nio/fs/UnixChannelFactory$Flags.class", + "/modules/java.base/java/util/Collections$EmptyIterator.class", + "/modules/java.base/java/nio/channels/Channel.class", + "/modules/java.base/java/nio/channels/ReadableByteChannel.class", + "/modules/java.base/java/nio/channels/WritableByteChannel.class", + "/modules/java.base/java/nio/channels/ByteChannel.class", + "/modules/java.base/java/nio/channels/SeekableByteChannel.class", + "/modules/java.base/java/nio/channels/GatheringByteChannel.class", + "/modules/java.base/java/nio/channels/ScatteringByteChannel.class", + "/modules/java.base/java/nio/channels/InterruptibleChannel.class", + "/modules/java.base/java/nio/channels/spi/AbstractInterruptibleChannel.class", + "/modules/java.base/java/nio/channels/FileChannel.class", + "/modules/java.base/sun/nio/ch/FileChannelImpl.class", + "/modules/java.base/sun/nio/ch/NativeDispatcher.class", + "/modules/java.base/sun/nio/ch/FileDispatcher.class", + "/modules/java.base/sun/nio/ch/UnixFileDispatcherImpl.class", + "/modules/java.base/sun/nio/ch/FileDispatcherImpl.class", + "/modules/java.base/sun/nio/ch/IOUtil.class", + "/modules/java.base/sun/nio/ch/Interruptible.class", + "/modules/java.base/sun/nio/ch/NativeThreadSet.class", + "/modules/java.base/sun/nio/ch/FileChannelImpl$Closer.class", + "/modules/java.base/java/nio/channels/Channels.class", + "/modules/java.base/sun/nio/ch/Streams.class", + "/modules/java.base/sun/nio/ch/SelChImpl.class", + "/modules/java.base/java/nio/channels/NetworkChannel.class", + "/modules/java.base/java/nio/channels/SelectableChannel.class", + "/modules/java.base/java/nio/channels/spi/AbstractSelectableChannel.class", + "/modules/java.base/java/nio/channels/SocketChannel.class", + "/modules/java.base/sun/nio/ch/SocketChannelImpl.class", + "/modules/java.base/sun/nio/ch/ChannelInputStream.class", + "/modules/java.base/java/lang/invoke/LambdaMetafactory.class", + "/modules/java.base/java/util/function/Supplier.class", + "/modules/java.base/jdk/internal/util/ReferencedKeySet.class", + "/modules/java.base/jdk/internal/util/ReferencedKeyMap.class", + "/modules/java.base/jdk/internal/util/ReferenceKey.class", + "/modules/java.base/jdk/internal/util/StrongReferenceKey.class", + "/modules/java.base/java/lang/invoke/MethodTypeForm.class", + "/modules/java.base/jdk/internal/util/WeakReferenceKey.class", + "/modules/java.base/sun/invoke/util/Wrapper.class", + "/modules/java.base/sun/invoke/util/Wrapper$Format.class", + "/modules/java.base/java/lang/constant/ConstantDescs.class", + "/modules/java.base/java/lang/constant/ClassDesc.class", + "/modules/java.base/jdk/internal/constant/ClassOrInterfaceDescImpl.class", + "/modules/java.base/jdk/internal/constant/ArrayClassDescImpl.class", + "/modules/java.base/jdk/internal/constant/ConstantUtils.class", + "/modules/java.base/java/lang/constant/DirectMethodHandleDesc$Kind.class", + "/modules/java.base/java/lang/constant/MethodTypeDesc.class", + "/modules/java.base/jdk/internal/constant/MethodTypeDescImpl.class", + "/modules/java.base/java/lang/constant/MethodHandleDesc.class", + "/modules/java.base/java/lang/constant/DirectMethodHandleDesc.class", + "/modules/java.base/jdk/internal/constant/DirectMethodHandleDescImpl.class", + "/modules/java.base/java/lang/constant/DynamicConstantDesc.class", + "/modules/java.base/jdk/internal/constant/PrimitiveClassDescImpl.class", + "/modules/java.base/java/lang/constant/DynamicConstantDesc$AnonymousDynamicConstantDesc.class", + "/modules/java.base/java/lang/invoke/LambdaForm$NamedFunction.class", + "/modules/java.base/java/lang/invoke/DirectMethodHandle$Holder.class", + "/modules/java.base/sun/invoke/util/ValueConversions.class", + "/modules/java.base/java/lang/invoke/MethodHandleImpl.class", + "/modules/java.base/java/lang/invoke/Invokers.class", + "/modules/java.base/java/lang/invoke/LambdaForm$Kind.class", + "/modules/java.base/java/lang/NoSuchMethodException.class", + "/modules/java.base/java/lang/invoke/LambdaForm$BasicType.class", + "/modules/java.base/java/lang/classfile/TypeKind.class", + "/modules/java.base/java/lang/invoke/LambdaForm$Name.class", + "/modules/java.base/java/lang/invoke/LambdaForm$Holder.class", + "/modules/java.base/java/lang/invoke/InvokerBytecodeGenerator.class", + "/modules/java.base/java/lang/classfile/AnnotationElement.class", + "/modules/java.base/java/lang/classfile/Annotation.class", + "/modules/java.base/java/lang/classfile/constantpool/ConstantPool.class", + "/modules/java.base/java/lang/classfile/constantpool/ConstantPoolBuilder.class", + "/modules/java.base/jdk/internal/classfile/impl/TemporaryConstantPool.class", + "/modules/java.base/java/lang/classfile/constantpool/PoolEntry.class", + "/modules/java.base/java/lang/classfile/constantpool/AnnotationConstantValueEntry.class", + "/modules/java.base/java/lang/classfile/constantpool/Utf8Entry.class", + "/modules/java.base/jdk/internal/classfile/impl/AbstractPoolEntry.class", + "/modules/java.base/jdk/internal/classfile/impl/AbstractPoolEntry$Utf8EntryImpl.class", + "/modules/java.base/jdk/internal/classfile/impl/AbstractPoolEntry$Utf8EntryImpl$State.class", + "/modules/java.base/jdk/internal/classfile/impl/AnnotationImpl.class", + "/modules/java.base/java/lang/classfile/ClassFileElement.class", + "/modules/java.base/java/lang/classfile/Attribute.class", + "/modules/java.base/java/lang/classfile/ClassElement.class", + "/modules/java.base/java/lang/classfile/MethodElement.class", + "/modules/java.base/java/lang/classfile/FieldElement.class", + "/modules/java.base/java/lang/classfile/attribute/RuntimeVisibleAnnotationsAttribute.class", + "/modules/java.base/jdk/internal/classfile/impl/Util$Writable.class", + "/modules/java.base/jdk/internal/classfile/impl/AbstractElement.class", + "/modules/java.base/jdk/internal/classfile/impl/UnboundAttribute.class", + "/modules/java.base/jdk/internal/classfile/impl/UnboundAttribute$UnboundRuntimeVisibleAnnotationsAttribute.class", + "/modules/java.base/java/lang/classfile/Attributes.class", + "/modules/java.base/java/lang/classfile/AttributeMapper.class", + "/modules/java.base/jdk/internal/classfile/impl/AbstractAttributeMapper.class", + "/modules/java.base/jdk/internal/classfile/impl/AbstractAttributeMapper$RuntimeVisibleAnnotationsMapper.class", + "/modules/java.base/java/lang/classfile/AttributeMapper$AttributeStability.class", + "/modules/java.base/java/lang/invoke/MethodHandleImpl$Intrinsic.class", + "/modules/java.base/jdk/internal/classfile/impl/SplitConstantPool.class", + "/modules/java.base/java/lang/classfile/BootstrapMethodEntry.class", + "/modules/java.base/jdk/internal/classfile/impl/BootstrapMethodEntryImpl.class", + "/modules/java.base/jdk/internal/classfile/impl/EntryMap.class", + "/modules/java.base/jdk/internal/classfile/impl/Util.class", + "/modules/java.base/java/lang/classfile/constantpool/LoadableConstantEntry.class", + "/modules/java.base/java/lang/classfile/constantpool/ClassEntry.class", + "/modules/java.base/jdk/internal/classfile/impl/AbstractPoolEntry$AbstractRefEntry.class", + "/modules/java.base/jdk/internal/classfile/impl/AbstractPoolEntry$AbstractNamedEntry.class", + "/modules/java.base/jdk/internal/classfile/impl/AbstractPoolEntry$ClassEntryImpl.class", + "/modules/java.base/java/util/function/Consumer.class", + "/modules/java.base/java/lang/classfile/ClassFile.class", + "/modules/java.base/jdk/internal/classfile/impl/ClassFileImpl.class", + "/modules/java.base/java/lang/classfile/ClassFileBuilder.class", + "/modules/java.base/java/lang/classfile/ClassBuilder.class", + "/modules/java.base/jdk/internal/classfile/impl/AbstractDirectBuilder.class", + "/modules/java.base/jdk/internal/classfile/impl/DirectClassBuilder.class", + "/modules/java.base/jdk/internal/classfile/impl/AttributeHolder.class", + "/modules/java.base/java/lang/classfile/Superclass.class", + "/modules/java.base/jdk/internal/classfile/impl/SuperclassImpl.class", + "/modules/java.base/java/lang/classfile/attribute/SourceFileAttribute.class", + "/modules/java.base/jdk/internal/classfile/impl/UnboundAttribute$UnboundSourceFileAttribute.class", + "/modules/java.base/jdk/internal/classfile/impl/AbstractAttributeMapper$SourceFileMapper.class", + "/modules/java.base/jdk/internal/classfile/impl/BoundAttribute.class", + "/modules/java.base/java/lang/classfile/MethodBuilder.class", + "/modules/java.base/jdk/internal/classfile/impl/MethodInfo.class", + "/modules/java.base/jdk/internal/classfile/impl/TerminalMethodBuilder.class", + "/modules/java.base/jdk/internal/classfile/impl/DirectMethodBuilder.class", + "/modules/java.base/java/lang/classfile/constantpool/NameAndTypeEntry.class", + "/modules/java.base/jdk/internal/classfile/impl/AbstractPoolEntry$AbstractRefsEntry.class", + "/modules/java.base/jdk/internal/classfile/impl/AbstractPoolEntry$NameAndTypeEntryImpl.class", + "/modules/java.base/java/lang/classfile/constantpool/MemberRefEntry.class", + "/modules/java.base/java/lang/classfile/constantpool/FieldRefEntry.class", + "/modules/java.base/jdk/internal/classfile/impl/AbstractPoolEntry$AbstractMemberRefEntry.class", + "/modules/java.base/jdk/internal/classfile/impl/AbstractPoolEntry$FieldRefEntryImpl.class", + "/modules/java.base/java/lang/invoke/InvokerBytecodeGenerator$ClassData.class", + "/modules/java.base/java/lang/classfile/CodeBuilder.class", + "/modules/java.base/jdk/internal/classfile/impl/LabelContext.class", + "/modules/java.base/jdk/internal/classfile/impl/TerminalCodeBuilder.class", + "/modules/java.base/jdk/internal/classfile/impl/DirectCodeBuilder.class", + "/modules/java.base/java/lang/classfile/CodeElement.class", + "/modules/java.base/java/lang/classfile/PseudoInstruction.class", + "/modules/java.base/java/lang/classfile/instruction/CharacterRange.class", + "/modules/java.base/java/lang/classfile/instruction/LocalVariable.class", + "/modules/java.base/java/lang/classfile/instruction/LocalVariableType.class", + "/modules/java.base/jdk/internal/classfile/impl/DirectCodeBuilder$DeferredLabel.class", + "/modules/java.base/java/lang/classfile/BufWriter.class", + "/modules/java.base/jdk/internal/classfile/impl/BufWriterImpl.class", + "/modules/java.base/java/lang/classfile/Label.class", + "/modules/java.base/java/lang/classfile/instruction/LabelTarget.class", + "/modules/java.base/jdk/internal/classfile/impl/LabelImpl.class", + "/modules/java.base/sun/invoke/util/VerifyType.class", + "/modules/java.base/java/lang/classfile/Opcode.class", + "/modules/java.base/java/lang/classfile/Opcode$Kind.class", + "/modules/java.base/java/lang/classfile/constantpool/MethodRefEntry.class", + "/modules/java.base/jdk/internal/classfile/impl/AbstractPoolEntry$MethodRefEntryImpl.class", + "/modules/java.base/sun/invoke/empty/Empty.class", + "/modules/java.base/jdk/internal/classfile/impl/BytecodeHelpers.class", + "/modules/java.base/jdk/internal/classfile/impl/UnboundAttribute$AdHocAttribute.class", + "/modules/java.base/jdk/internal/classfile/impl/AbstractAttributeMapper$CodeMapper.class", + "/modules/java.base/java/lang/classfile/FieldBuilder.class", + "/modules/java.base/jdk/internal/classfile/impl/TerminalFieldBuilder.class", + "/modules/java.base/jdk/internal/classfile/impl/DirectFieldBuilder.class", + "/modules/java.base/java/lang/classfile/CustomAttribute.class", + "/modules/java.base/jdk/internal/classfile/impl/AnnotationReader.class", + "/modules/java.base/java/util/ListIterator.class", + "/modules/java.base/java/util/ImmutableCollections$ListItr.class", + "/modules/java.base/jdk/internal/classfile/impl/StackMapGenerator.class", + "/modules/java.base/jdk/internal/classfile/impl/StackMapGenerator$Frame.class", + "/modules/java.base/jdk/internal/classfile/impl/StackMapGenerator$Type.class", + "/modules/java.base/jdk/internal/classfile/impl/RawBytecodeHelper.class", + "/modules/java.base/jdk/internal/classfile/impl/RawBytecodeHelper$CodeRange.class", + "/modules/java.base/jdk/internal/classfile/impl/ClassHierarchyImpl.class", + "/modules/java.base/java/lang/classfile/ClassHierarchyResolver.class", + "/modules/java.base/jdk/internal/classfile/impl/ClassHierarchyImpl$ClassLoadingClassHierarchyResolver.class", + "/modules/java.base/jdk/internal/classfile/impl/ClassHierarchyImpl$CachedClassHierarchyResolver.class", + "/modules/java.base/java/lang/classfile/ClassHierarchyResolver$ClassHierarchyInfo.class", + "/modules/java.base/jdk/internal/classfile/impl/ClassHierarchyImpl$ClassHierarchyInfoImpl.class", + "/modules/java.base/java/lang/classfile/ClassReader.class", + "/modules/java.base/jdk/internal/classfile/impl/ClassReaderImpl.class", + "/modules/java.base/jdk/internal/util/ModifiedUtf.class", + "/modules/java.base/java/lang/invoke/MethodHandles$Lookup$ClassDefiner.class", + "/modules/java.base/java/lang/IncompatibleClassChangeError.class", + "/modules/java.base/java/lang/NoSuchMethodError.class", + "/modules/java.base/java/lang/invoke/BootstrapMethodInvoker.class", + "/modules/java.base/java/lang/invoke/AbstractValidatingLambdaMetafactory.class", + "/modules/java.base/java/lang/invoke/InnerClassLambdaMetafactory.class", + "/modules/java.base/java/lang/invoke/MethodHandleInfo.class", + "/modules/java.base/java/lang/invoke/InfoFromMemberName.class", + "/modules/java.base/java/util/ImmutableCollections$Access.class", + "/modules/java.base/jdk/internal/access/JavaUtilCollectionAccess.class", + "/modules/java.base/java/lang/classfile/Interfaces.class", + "/modules/java.base/jdk/internal/classfile/impl/InterfacesImpl.class", + "/modules/java.base/java/lang/invoke/TypeConvertingMethodAdapter.class", + "/modules/java.base/java/lang/invoke/DirectMethodHandle$Constructor.class", + "/modules/java.base/jdk/internal/access/JavaLangInvokeAccess.class", + "/modules/java.base/java/lang/invoke/VarHandle$AccessMode.class", + "/modules/java.base/java/lang/invoke/VarHandle$AccessType.class", + "/modules/java.base/java/lang/invoke/Invokers$Holder.class", + "/modules/java.base/jdk/internal/module/ModuleInfo.class", + "/modules/java.base/java/io/DataInput.class", + "/modules/java.base/java/io/DataInputStream.class", + "/modules/java.base/jdk/internal/module/ModuleInfo$CountingDataInput.class", + "/modules/java.base/sun/nio/ch/NativeThread.class", + "/modules/java.base/jdk/internal/misc/Blocker.class", + "/modules/java.base/sun/nio/ch/Util.class", + "/modules/java.base/sun/nio/ch/Util$BufferCache.class", + "/modules/java.base/sun/nio/ch/IOStatus.class", + "/modules/java.base/jdk/internal/util/ByteArray.class", + "/modules/java.base/java/lang/invoke/VarHandles.class", + "/modules/java.base/java/lang/invoke/VarHandleByteArrayAsShorts$ByteArrayViewVarHandle.class", + "/modules/java.base/java/lang/invoke/VarHandleByteArrayAsShorts$ArrayHandle.class", + "/modules/java.base/java/lang/invoke/VarHandleGuards.class", + "/modules/java.base/java/lang/invoke/VarForm.class", + "/modules/java.base/java/lang/invoke/VarHandleByteArrayAsChars$ByteArrayViewVarHandle.class", + "/modules/java.base/java/lang/invoke/VarHandleByteArrayAsChars$ArrayHandle.class", + "/modules/java.base/java/lang/invoke/VarHandleByteArrayAsInts$ByteArrayViewVarHandle.class", + "/modules/java.base/java/lang/invoke/VarHandleByteArrayAsInts$ArrayHandle.class", + "/modules/java.base/java/lang/invoke/VarHandleByteArrayAsFloats$ByteArrayViewVarHandle.class", + "/modules/java.base/java/lang/invoke/VarHandleByteArrayAsFloats$ArrayHandle.class", + "/modules/java.base/java/lang/invoke/VarHandleByteArrayAsLongs$ByteArrayViewVarHandle.class", + "/modules/java.base/java/lang/invoke/VarHandleByteArrayAsLongs$ArrayHandle.class", + "/modules/java.base/java/lang/invoke/VarHandleByteArrayAsDoubles$ByteArrayViewVarHandle.class", + "/modules/java.base/java/lang/invoke/VarHandleByteArrayAsDoubles$ArrayHandle.class", + "/modules/java.base/java/lang/invoke/VarHandle$AccessDescriptor.class", + "/modules/java.base/jdk/internal/module/ModuleInfo$ConstantPool.class", + "/modules/java.base/jdk/internal/module/ModuleInfo$ConstantPool$Entry.class", + "/modules/java.base/jdk/internal/module/ModuleInfo$ConstantPool$IndexEntry.class", + "/modules/java.base/java/nio/charset/StandardCharsets.class", + "/modules/java.base/sun/nio/cs/US_ASCII.class", + "/modules/java.base/sun/nio/cs/ISO_8859_1.class", + "/modules/java.base/sun/nio/cs/UTF_16BE.class", + "/modules/java.base/sun/nio/cs/UTF_16LE.class", + "/modules/java.base/sun/nio/cs/UTF_16.class", + "/modules/java.base/sun/nio/cs/UTF_32BE.class", + "/modules/java.base/sun/nio/cs/UTF_32LE.class", + "/modules/java.base/sun/nio/cs/UTF_32.class", + "/modules/java.base/jdk/internal/module/ModuleInfo$ConstantPool$ValueEntry.class", + "/modules/java.base/java/lang/module/ModuleDescriptor$Builder.class", + "/modules/java.base/java/lang/module/ModuleDescriptor$Modifier.class", + "/modules/java.base/java/lang/reflect/AccessFlag.class", + "/modules/java.base/java/lang/reflect/AccessFlag$Location.class", + "/modules/java.base/java/lang/module/ModuleDescriptor$Requires$Modifier.class", + "/modules/java.base/java/lang/module/ModuleDescriptor$Requires.class", + "/modules/java.base/java/util/HashMap$KeySet.class", + "/modules/java.base/java/util/HashMap$KeyIterator.class", + "/modules/java.base/jdk/internal/module/Checks.class", + "/modules/java.base/java/util/ArrayList$Itr.class", + "/modules/java.base/java/lang/module/ModuleDescriptor$Provides.class", + "/modules/java.base/java/util/Collections$UnmodifiableCollection.class", + "/modules/java.base/java/util/Collections$UnmodifiableSet.class", + "/modules/java.base/java/util/HashMap$Values.class", + "/modules/java.base/java/util/HashMap$ValueIterator.class", + "/modules/java.base/java/util/ImmutableCollections$SetN$SetNIterator.class", + "/modules/java.base/jdk/internal/module/ModuleInfo$Attributes.class", + "/modules/java.base/jdk/internal/module/ModuleReferences.class", + "/modules/java.base/java/lang/module/ModuleReader.class", + "/modules/java.base/sun/nio/fs/UnixUriUtils.class", + "/modules/java.base/java/net/URI$Parser.class", + "/modules/java.base/java/lang/module/ModuleReference.class", + "/modules/java.base/jdk/internal/module/ModuleReferenceImpl.class", + "/modules/java.base/java/lang/module/ModuleDescriptor$Exports.class", + "/modules/java.base/java/lang/module/ModuleDescriptor$Opens.class", + "/modules/java.base/sun/nio/fs/UnixException.class", + "/modules/java.base/java/io/IOException.class", + "/modules/java.base/jdk/internal/loader/ArchivedClassLoaders.class", + "/modules/java.base/jdk/internal/loader/ClassLoaders$BootClassLoader.class", + "/modules/java.base/java/lang/ClassLoader$ParallelLoaders.class", + "/modules/java.base/java/util/WeakHashMap.class", + "/modules/java.base/java/util/WeakHashMap$Entry.class", + "/modules/java.base/java/util/WeakHashMap$KeySet.class", + "/modules/java.base/java/security/Principal.class", + "/modules/java.base/jdk/internal/loader/URLClassPath.class", + "/modules/java.base/java/net/URLStreamHandlerFactory.class", + "/modules/java.base/java/net/URL$DefaultFactory.class", + "/modules/java.base/jdk/internal/access/JavaNetURLAccess.class", + "/modules/java.base/sun/net/www/ParseUtil.class", + "/modules/java.base/java/net/URLStreamHandler.class", + "/modules/java.base/sun/net/www/protocol/file/Handler.class", + "/modules/java.base/sun/net/util/IPAddressUtil.class", + "/modules/java.base/sun/net/util/IPAddressUtil$MASKS.class", + "/modules/java.base/sun/net/www/protocol/jar/Handler.class", + "/modules/java.base/jdk/internal/module/ServicesCatalog.class", + "/modules/java.base/jdk/internal/loader/AbstractClassLoaderValue.class", + "/modules/java.base/jdk/internal/loader/ClassLoaderValue.class", + "/modules/java.base/jdk/internal/loader/BuiltinClassLoader$LoadedModule.class", + "/modules/java.base/jdk/internal/module/DefaultRoots.class", + "/modules/java.base/java/util/Spliterator.class", + "/modules/java.base/java/util/HashMap$HashMapSpliterator.class", + "/modules/java.base/java/util/HashMap$ValueSpliterator.class", + "/modules/java.base/java/util/stream/StreamSupport.class", + "/modules/java.base/java/util/stream/BaseStream.class", + "/modules/java.base/java/util/stream/Stream.class", + "/modules/java.base/java/util/stream/PipelineHelper.class", + "/modules/java.base/java/util/stream/AbstractPipeline.class", + "/modules/java.base/java/util/stream/ReferencePipeline.class", + "/modules/java.base/java/util/stream/ReferencePipeline$Head.class", + "/modules/java.base/java/util/stream/StreamOpFlag.class", + "/modules/java.base/java/util/stream/StreamOpFlag$Type.class", + "/modules/java.base/java/util/stream/StreamOpFlag$MaskBuilder.class", + "/modules/java.base/java/util/EnumMap.class", + "/modules/java.base/java/lang/Class$ReflectionData.class", + "/modules/java.base/java/lang/Class$Atomic.class", + "/modules/java.base/java/lang/PublicMethods$MethodList.class", + "/modules/java.base/java/lang/PublicMethods$Key.class", + "/modules/java.base/sun/reflect/annotation/AnnotationParser.class", + "/modules/java.base/jdk/internal/reflect/MethodHandleAccessorFactory.class", + "/modules/java.base/jdk/internal/reflect/MethodHandleAccessorFactory$LazyStaticHolder.class", + "/modules/java.base/java/lang/invoke/BoundMethodHandle.class", + "/modules/java.base/java/lang/invoke/ClassSpecializer.class", + "/modules/java.base/java/lang/invoke/BoundMethodHandle$Specializer.class", + "/modules/java.base/jdk/internal/vm/annotation/Stable.class", + "/modules/java.base/java/lang/invoke/ClassSpecializer$SpeciesData.class", + "/modules/java.base/java/lang/invoke/BoundMethodHandle$SpeciesData.class", + "/modules/java.base/java/lang/invoke/ClassSpecializer$Factory.class", + "/modules/java.base/java/lang/invoke/BoundMethodHandle$Specializer$Factory.class", + "/modules/java.base/java/lang/invoke/SimpleMethodHandle.class", + "/modules/java.base/java/lang/NoSuchFieldException.class", + "/modules/java.base/java/lang/invoke/BoundMethodHandle$Species_L.class", + "/modules/java.base/java/lang/invoke/DirectMethodHandle$Accessor.class", + "/modules/java.base/java/lang/invoke/DelegatingMethodHandle.class", + "/modules/java.base/java/lang/invoke/DelegatingMethodHandle$Holder.class", + "/modules/java.base/java/lang/invoke/LambdaFormEditor.class", + "/modules/java.base/java/lang/invoke/LambdaFormEditor$TransformKey.class", + "/modules/java.base/java/lang/invoke/LambdaFormBuffer.class", + "/modules/java.base/java/lang/invoke/LambdaFormEditor$Transform.class", + "/modules/java.base/jdk/internal/reflect/DirectMethodHandleAccessor.class", + "/modules/java.base/java/util/stream/Collectors.class", + "/modules/java.base/java/util/stream/Collector$Characteristics.class", + "/modules/java.base/java/util/EnumSet.class", + "/modules/java.base/java/util/RegularEnumSet.class", + "/modules/java.base/java/util/stream/Collector.class", + "/modules/java.base/java/util/stream/Collectors$CollectorImpl.class", + "/modules/java.base/java/util/function/BiConsumer.class", + "/modules/java.base/java/lang/invoke/DirectMethodHandle$Interface.class", + "/modules/java.base/java/lang/classfile/constantpool/InterfaceMethodRefEntry.class", + "/modules/java.base/jdk/internal/classfile/impl/AbstractPoolEntry$InterfaceMethodRefEntryImpl.class", + "/modules/java.base/java/util/function/BinaryOperator.class", + "/modules/java.base/java/util/stream/ReduceOps.class", + "/modules/java.base/java/util/stream/TerminalOp.class", + "/modules/java.base/java/util/stream/ReduceOps$ReduceOp.class", + "/modules/java.base/java/util/stream/StreamShape.class", + "/modules/java.base/java/util/stream/Sink.class", + "/modules/java.base/java/util/stream/TerminalSink.class", + "/modules/java.base/java/util/stream/ReduceOps$AccumulatingSink.class", + "/modules/java.base/java/util/stream/ReduceOps$Box.class", + "/modules/java.base/java/util/HashMap$KeySpliterator.class", + "/modules/java.base/java/util/function/Predicate.class", + "/modules/java.base/java/util/stream/ReferencePipeline$StatelessOp.class", + "/modules/java.base/java/util/stream/Sink$ChainedReference.class", + "/modules/java.base/jdk/internal/module/ModuleResolution.class", + "/modules/java.base/java/util/stream/FindOps.class", + "/modules/java.base/java/util/stream/FindOps$FindSink.class", + "/modules/java.base/java/util/stream/FindOps$FindSink$OfRef.class", + "/modules/java.base/java/util/stream/FindOps$FindOp.class", + "/modules/java.base/java/util/Spliterators.class", + "/modules/java.base/java/util/Spliterators$IteratorSpliterator.class", + "/modules/java.base/java/lang/module/Configuration.class", + "/modules/java.base/java/lang/module/Resolver.class", + "/modules/java.base/java/lang/ModuleLayer.class", + "/modules/java.base/java/util/SequencedSet.class", + "/modules/java.base/java/util/LinkedHashSet.class", + "/modules/java.base/java/util/SequencedMap.class", + "/modules/java.base/java/util/LinkedHashMap.class", + "/modules/java.base/java/lang/module/ResolvedModule.class", + "/modules/java.base/jdk/internal/module/ModuleLoaderMap$Mapper.class", + "/modules/java.base/jdk/internal/loader/AbstractClassLoaderValue$Memoizer.class", + "/modules/java.base/jdk/internal/module/ServicesCatalog$ServiceProvider.class", + "/modules/java.base/java/util/concurrent/CopyOnWriteArrayList.class", + "/modules/java.base/java/lang/ModuleLayer$Controller.class", + "/modules/java.base/jdk/internal/module/ModuleBootstrap$SafeModuleFinder.class", + "/modules/java.base/jdk/internal/vm/ContinuationSupport.class", + "/modules/java.base/jdk/internal/vm/Continuation$Pinned.class", + "/modules/java.base/sun/launcher/LauncherHelper.class", + "/modules/java.base/sun/net/util/URLUtil.class", + "/modules/java.base/jdk/internal/loader/URLClassPath$Loader.class", + "/modules/java.base/jdk/internal/loader/URLClassPath$FileLoader.class", + "/modules/java.base/jdk/internal/loader/Resource.class", + "/modules/java.base/java/io/FileCleanable.class", + "/modules/java.base/sun/nio/ByteBuffered.class", + "/modules/java.base/java/security/SecureClassLoader$CodeSourceKey.class", + "/modules/java.base/java/security/PermissionCollection.class", + "/modules/java.base/java/security/Permissions.class", + "/modules/java.base/java/lang/NamedPackage.class", + "/modules/java.base/jdk/internal/misc/MethodFinder.class", + "/modules/java.base/java/lang/Readable.class", + "/modules/java.base/java/nio/CharBuffer.class", + "/modules/java.base/java/nio/HeapCharBuffer.class", + "/modules/java.base/java/nio/charset/CoderResult.class", + "/modules/java.base/java/util/IdentityHashMap$IdentityHashMapIterator.class", + "/modules/java.base/java/util/IdentityHashMap$KeyIterator.class", + "/modules/java.base/java/lang/Shutdown.class", + "/modules/java.base/java/lang/Shutdown$Lock.class"); + + private static final Pattern SPLIT_MODULE_AND_PATH = Pattern.compile("/modules/([^/]+)/(.*)"); + + private static final Map> MODULE_TO_PATHS = INIT_CLASSES.stream() + .map(name -> { + Matcher m = SPLIT_MODULE_AND_PATH.matcher(name); + if (!m.matches()) { + throw new IllegalArgumentException("Bad resource name: " + name); + } + return m.toMatchResult(); + }) + .collect(groupingBy(m -> m.group(1), mapping(m -> m.group(2), toList()))); + } }