6758881: (launcher) needs to throw NoClassDefFoundError instead of JavaRuntimeException
authorksrini
Tue, 14 Oct 2008 13:02:30 -0700
changeset 1343 ecc86134ee4c
parent 1342 c53ca7b8f44b
child 1344 1b948c48b8e9
6758881: (launcher) needs to throw NoClassDefFoundError instead of JavaRuntimeException Summary: The launcher will throw the Error vs. Exception, also fixed some minor issues with the tests. Reviewed-by: darcy
jdk/src/share/classes/sun/launcher/LauncherHelper.java
jdk/test/tools/launcher/Arrrghs.java
--- a/jdk/src/share/classes/sun/launcher/LauncherHelper.java	Fri Oct 10 13:28:14 2008 -0700
+++ b/jdk/src/share/classes/sun/launcher/LauncherHelper.java	Tue Oct 14 13:02:30 2008 -0700
@@ -176,10 +176,10 @@
      * @param isJar
      * @param name
      * @return
-     * @throws java.lang.Exception
+     * @throws java.io.IOException
      */
     public static Object checkAndLoadMain(boolean printToStderr,
-            boolean isJar, String name) throws Exception {
+            boolean isJar, String name) throws IOException {
         // get the class name
         String classname = (isJar) ? getMainClassFromJar(name) : name;
         classname = classname.replace('/', '.');
@@ -190,7 +190,9 @@
             clazz = loader.loadClass(classname);
         } catch (ClassNotFoundException cnfe) {
             ostream.println(getLocalizedMessage("java.launcher.cls.error1", classname));
-            throw new RuntimeException("Could not find the main class " + classname);
+            NoClassDefFoundError ncdfe = new NoClassDefFoundError(classname);
+            ncdfe.initCause(cnfe);
+            throw ncdfe;
         }
         signatureDiagnostic(ostream, clazz);
         return clazz;
--- a/jdk/test/tools/launcher/Arrrghs.java	Fri Oct 10 13:28:14 2008 -0700
+++ b/jdk/test/tools/launcher/Arrrghs.java	Tue Oct 14 13:02:30 2008 -0700
@@ -23,10 +23,10 @@
 
 /**
  * @test
- * @compile  -XDignore.symbol.file Arrrghs.java TestHelper.java
- * @bug 5030233 6214916 6356475 6571029 6684582 6742159 4459600
+ * @bug 5030233 6214916 6356475 6571029 6684582 6742159 4459600 6758881
+ * @summary Argument parsing validation.
+ * @compile Arrrghs.java TestHelper.java
  * @run main Arrrghs
- * @summary Argument parsing validation.
  */
 
 import java.io.BufferedReader;
@@ -235,11 +235,13 @@
         TestHelper.createJar("MIA", new File("some.jar"), new File("Foo"),
                 (String[])null);
         tr = TestHelper.doExec(TestHelper.javaCmd, "-jar", "some.jar");
-        tr.contains("MIA");
+        tr.contains("Error: Could not find main class MIA");
+        tr.contains("java.lang.NoClassDefFoundError: MIA");
         System.out.println(tr);
         // use classpath to check
         tr = TestHelper.doExec(TestHelper.javaCmd, "-cp", "some.jar", "MIA");
         tr.contains("Error: Could not find main class MIA");
+        tr.contains("java.lang.NoClassDefFoundError: MIA");
         System.out.println(tr);
 
         // incorrect method access
@@ -316,14 +318,14 @@
      */
     public static void main(String[] args) throws FileNotFoundException {
         if (TestHelper.debug) System.out.println("Starting Arrrghs tests");
-        quoteParsingTests();
-        runBasicErrorMessageTests();
-        runMainMethodTests();
-        if (TestHelper.testExitValue > 0) {
-            System.out.println("Total of " + TestHelper.testExitValue + " failed");
-            System.exit(1);
-        } else {
-            System.out.println("All tests pass");
+            quoteParsingTests();
+            runBasicErrorMessageTests();
+            runMainMethodTests();
+            if (TestHelper.testExitValue > 0) {
+                System.out.println("Total of " + TestHelper.testExitValue + " failed");
+                System.exit(1);
+            } else {
+                System.out.println("All tests pass");
+            }
         }
     }
-}