提交 2cc0c30d 编写于 作者: K ksrini

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
上级 b17cc21a
......@@ -176,10 +176,10 @@ public enum LauncherHelper {
* @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 @@ public enum LauncherHelper {
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;
......
......@@ -23,10 +23,10 @@
/**
* @test
* @compile -XDignore.symbol.file Arrrghs.java TestHelper.java
* @bug 5030233 6214916 6356475 6571029 6684582 6742159 4459600
* @run main Arrrghs
* @bug 5030233 6214916 6356475 6571029 6684582 6742159 4459600 6758881
* @summary Argument parsing validation.
* @compile Arrrghs.java TestHelper.java
* @run main Arrrghs
*/
import java.io.BufferedReader;
......@@ -235,11 +235,13 @@ public class Arrrghs {
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 class Arrrghs {
*/
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");
}
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册