Small VM change #2: JVM_ entry point to extend the boot class path
Mark Reinhold
mr at sun.com
Mon May 18 12:55:22 PDT 2009
As I hinted last week, the Jigsaw runtime needs the ability to extend the
bootstrap class path after the VM has been initialized.
Why does it need this? The java launcher knows only about the JDK "boot"
module, but almost every application will need other JDK modules as well.
To ensure compatibility, and to allow JDK packages to be split statically
across multiple modules, the additional JDK modules must be loaded into
the same module class loader as the boot module.
In theory it's possible for the java launcher to figure out what those
modules are, but it's vastly easier to defer this to the Jigsaw runtime
code. So what I have working now is a modified BootLoader class which,
upon initialization, adds the classes from all the other JDK modules
required by the application to the boot class path.
(This isn't the only way to solve this problem, and indeed later on it
might be better to create a more intimate connection between the VM's
boot class loader and the Jigsaw runtime, but this will do for now.)
Patch attached, since this is a pretty simple change, though I can
produce a webrev if preferred. All I've really done is to expose the
existing ClassLoader::update_class_path_entry_list procedure as the new
JVM_ entry point JVM_ExtendBootClassPath. I've copied the locking
protocol from SystemDictionary::download_and_retry_class_load, which does
a very similar thing, but I'm far from an expert on internal locking in
HotSpot so please do point out anything I've gotten wrong here.
I've updated the Linux mapfiles but not those for Solaris. I'm not doing
Solaris (or Windows) builds at the moment, and if I forget to fix those
mapfiles later then the problem will be glaringly obvious, so for the
sake of expedience I'd like to make this change now and clean up the
other builds later on.
Karen -- Okay to push?
Thanks,
- Mark
-------------- next part --------------
diff -r 403a1b93874f make/linux/makefiles/mapfile-vers-debug
--- a/make/linux/makefiles/mapfile-vers-debug Thu May 14 14:48:35 2009 -0700
+++ b/make/linux/makefiles/mapfile-vers-debug Mon May 18 12:33:07 2009 -0700
@@ -87,6 +87,7 @@
JVM_DumpThreads;
JVM_EnableCompiler;
JVM_Exit;
+ JVM_ExtendBootClassPath;
JVM_FillInStackTrace;
JVM_FindClassFromClass;
JVM_FindClassFromClassLoader;
diff -r 403a1b93874f make/linux/makefiles/mapfile-vers-product
--- a/make/linux/makefiles/mapfile-vers-product Thu May 14 14:48:35 2009 -0700
+++ b/make/linux/makefiles/mapfile-vers-product Mon May 18 12:33:07 2009 -0700
@@ -87,6 +87,7 @@
JVM_DumpThreads;
JVM_EnableCompiler;
JVM_Exit;
+ JVM_ExtendBootClassPath;
JVM_FillInStackTrace;
JVM_FindClassFromClass;
JVM_FindClassFromClassLoader;
diff -r 403a1b93874f src/share/vm/classfile/classLoader.hpp
--- a/src/share/vm/classfile/classLoader.hpp Thu May 14 14:48:35 2009 -0700
+++ b/src/share/vm/classfile/classLoader.hpp Mon May 18 12:33:07 2009 -0700
@@ -190,7 +190,7 @@
// to avoid confusing the zip library
static bool get_canonical_path(char* orig, char* out, int len);
public:
- // Used by the kernel jvm.
+ // Used by the kernel jvm, and by Jigsaw via JVM_ExtendBootClassPath
static void update_class_path_entry_list(const char *path,
bool check_for_duplicates);
static void print_bootclasspath();
diff -r 403a1b93874f src/share/vm/prims/jvm.cpp
--- a/src/share/vm/prims/jvm.cpp Thu May 14 14:48:35 2009 -0700
+++ b/src/share/vm/prims/jvm.cpp Mon May 18 12:33:07 2009 -0700
@@ -851,6 +851,18 @@
(jclass) JNIHandles::make_local(env, Klass::cast(k)->java_mirror());
JVM_END
+JVM_ENTRY(void, JVM_ExtendBootClassPath(JNIEnv *env, jclass cls, const char *path))
+ JVMWrapper2("JVM_ExtendBootClassPath(%s)", path)
+ {
+ // cf. SystemDictionary::download_and_retry_class_load
+ HandleMark hm(THREAD);
+ ResourceMark rm(THREAD);
+ Handle loader_lock(THREAD, SystemDictionary::system_loader_lock());
+ ObjectLocker ol(loader_lock, THREAD);
+ ClassLoader::update_class_path_entry_list(path, true);
+ }
+ ClassLoader::print_bootclasspath();
+JVM_END
// Reflection support //////////////////////////////////////////////////////////////////////////////
diff -r 403a1b93874f src/share/vm/prims/jvm.h
--- a/src/share/vm/prims/jvm.h Thu May 14 14:48:35 2009 -0700
+++ b/src/share/vm/prims/jvm.h Mon May 18 12:33:07 2009 -0700
@@ -438,6 +438,12 @@
jobjectArray constants);
/*
+ * Append a path to the boot class path
+ */
+JNIEXPORT void JNICALL
+JVM_ExtendBootClassPath(JNIEnv *env, jclass cls, const char *path);
+
+/*
* Reflection support functions
*/
More information about the jigsaw-dev
mailing list