JDK-8263421 : Module image file is opened twice during VM startup
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 17
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2021-03-11
  • Updated: 2022-11-03
  • Resolved: 2021-04-27
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 17
17 b20Fixed
Related Reports
Relates :  
Description
This is called at VM startup. It opens the module image file, reads a small amount of info from it, and closes it.

We should save this opened image file, so it doesn't need to be opened again in ClassLoader::create_class_path_entry().

https://github.com/openjdk/jdk/blob/7988c1d9aa7e3b990c17fdf5e31195e66e7fc5f2/src/hotspot/share/classfile/classLoader.cpp#L1467

char* ClassLoader::lookup_vm_options() {
  jint error;
  char modules_path[JVM_MAXPATHLEN];
  const char* fileSep = os::file_separator();

  // Initialize jimage library entry points
  load_jimage_library();

  jio_snprintf(modules_path, JVM_MAXPATHLEN, "%s%slib%smodules", Arguments::get_java_home(), fileSep, fileSep);
  JImageFile* jimage =(*JImageOpen)(modules_path, &error);
  if (jimage == NULL) {
    return NULL;
  }

  const char *jimage_version = get_jimage_version_string();
  char *options = lookup_vm_resource(jimage, jimage_version, "jdk/internal/vm/options");

  (*JImageClose)(jimage);
  return options;
}

Comments
Changeset: dc323a93 Author: Harold Seigel <hseigel@openjdk.org> Date: 2021-04-27 13:31:55 +0000 URL: https://git.openjdk.java.net/jdk/commit/dc323a93
27-04-2021