6909573: Temporary launcher support to add modules in the bootclasspath
authormchung
Fri, 18 Dec 2009 11:42:03 -0800
changeset 4525 80191930aa5f
parent 4524 697144bd8b04
child 4526 158aca5e2b0c
6909573: Temporary launcher support to add modules in the bootclasspath Summary: Add the list of modules to the bootclasspath if lib/rt.jar and classes don't exist Reviewed-by: alanb, ohair, ksrini
jdk/src/share/bin/java.c
--- a/jdk/src/share/bin/java.c	Fri Dec 18 11:36:23 2009 -0800
+++ b/jdk/src/share/bin/java.c	Fri Dec 18 11:42:03 2009 -0800
@@ -93,6 +93,7 @@
  * Prototypes for functions internal to launcher.
  */
 static void SetClassPath(const char *s);
+static void SetModulesBootClassPath(const char *s);
 static void SelectVersion(int argc, char **argv, char **main_class);
 static jboolean ParseArguments(int *pargc, char ***pargv, char **pjarfile,
                                char **pclassname, int *pret, const char *jvmpath);
@@ -277,6 +278,9 @@
         return(ret);
     }
 
+    /* Set bootclasspath for modules */
+    SetModulesBootClassPath(jrepath);
+
     /* Override class path if -jar flag was specified */
     if (jarfile != 0) {
         SetClassPath(jarfile);
@@ -694,6 +698,44 @@
 }
 
 /*
+ * Set the bootclasspath for modules.
+ * A temporary workaround until jigsaw is integrated into JDK 7.
+ */
+static void
+SetModulesBootClassPath(const char *jrepath)
+{
+    char *def, *s;
+    char pathname[MAXPATHLEN];
+    const char separator[] = { FILE_SEPARATOR, '\0' };
+    const char *orig = jrepath;
+    static const char format[] = "-Xbootclasspath/p:%s";
+    struct stat statbuf;
+
+    /* return if jre/lib/rt.jar exists */
+    sprintf(pathname, "%s%slib%srt.jar", jrepath, separator, separator);
+    if (stat(pathname, &statbuf) == 0) {
+        return;
+    }
+
+    /* return if jre/classes exists */
+    sprintf(pathname, "%s%sclasses", jrepath, separator);
+    if (stat(pathname, &statbuf) == 0) {
+        return;
+    }
+
+    /* modularized jre */
+    sprintf(pathname, "%s%slib%s*", jrepath, separator, separator);
+    s = (char *) JLI_WildcardExpandClasspath(pathname);
+    def = JLI_MemAlloc(sizeof(format)
+                       - 2 /* strlen("%s") */
+                       + JLI_StrLen(s));
+    sprintf(def, format, s);
+    AddOption(def, NULL);
+    if (s != orig)
+        JLI_MemFree((char *) s);
+}
+
+/*
  * The SelectVersion() routine ensures that an appropriate version of
  * the JRE is running.  The specification for the appropriate version
  * is obtained from either the manifest of a jar file (preferred) or