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;
}