8210527: JShell: NullPointerException in jdk.jshell.Eval.translateExceptionStack
8232855: jshell missing word in /help help Reviewed-by: jlahoda
This commit is contained in:
parent
dd321330ce
commit
dca6e34397
@ -488,9 +488,9 @@ Display information about using the jshell tool.\n\
|
||||
/help\n\t\
|
||||
List the jshell tool commands and help subjects\n\n\
|
||||
/help <command>\n\t\
|
||||
Display information about the specified command. The slash must be included.\n\t\
|
||||
Only the first few letters of the command are needed -- if more than one\n\t\
|
||||
each will be displayed. Example: /help /li\n\n\
|
||||
Display information about the specified command.\n\t\
|
||||
Only the first few letters of the command are needed -- if there is more than\n\t\
|
||||
one match, each will be displayed. Example: /help /li\n\n\
|
||||
/help <subject>\n\t\
|
||||
Display information about the specified help subject. Example: /help intro
|
||||
|
||||
@ -529,9 +529,9 @@ Display information about using the jshell tool (abbreviation for /help).\n\
|
||||
/?\n\t\
|
||||
Display list of commands and help subjects\n\
|
||||
/? <command>\n\t\
|
||||
Display information about the specified command. The slash must be included.\n\t\
|
||||
Only the first few letters of the command are needed -- if more than one\n\t\
|
||||
match, each will be displayed. Example: /? /li\n\
|
||||
Display information about the specified command.\n\t\
|
||||
Only the first few letters of the command are needed -- if there is more than\n\t\
|
||||
one match, each will be displayed. Example: /? /li\n\n\
|
||||
/? <subject>\n\t\
|
||||
Display information about the specified help subject. Example: /? intro
|
||||
|
||||
|
@ -1110,7 +1110,7 @@ class Eval {
|
||||
Snippet sn = outer.wrapLineToSnippet(wln);
|
||||
String file = "#" + sn.id();
|
||||
elems[i] = new StackTraceElement(klass, method, file, line);
|
||||
} else if (r.getFileName().equals("<none>")) {
|
||||
} else if ("<none>".equals(r.getFileName())) {
|
||||
elems[i] = new StackTraceElement(r.getClassName(), r.getMethodName(), null, r.getLineNumber());
|
||||
} else {
|
||||
elems[i] = r;
|
||||
|
@ -24,8 +24,13 @@
|
||||
/*
|
||||
* @test
|
||||
* @summary Tests for exceptions
|
||||
* @bug 8198801 8212167
|
||||
* @build KullaTesting TestingInputStream
|
||||
* @bug 8198801 8212167 8210527
|
||||
* @modules jdk.compiler/com.sun.tools.javac.api
|
||||
* jdk.compiler/com.sun.tools.javac.main
|
||||
* jdk.jdeps/com.sun.tools.javap
|
||||
* @library /tools/lib
|
||||
* @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask
|
||||
* @build KullaTesting TestingInputStream Compiler
|
||||
* @run testng ExceptionsTest
|
||||
*/
|
||||
|
||||
@ -38,6 +43,9 @@ import jdk.jshell.Snippet;
|
||||
import jdk.jshell.SnippetEvent;
|
||||
import jdk.jshell.UnresolvedReferenceException;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
@ -45,6 +53,9 @@ import static org.testng.Assert.*;
|
||||
@Test
|
||||
public class ExceptionsTest extends KullaTesting {
|
||||
|
||||
private final Compiler compiler = new Compiler();
|
||||
private final Path outDir = Paths.get("test_class_path");
|
||||
|
||||
public void throwUncheckedException() {
|
||||
String message = "error_message";
|
||||
SnippetEvent cr = assertEvalException("throw new RuntimeException(\"" + message + "\");");
|
||||
@ -207,6 +218,36 @@ public class ExceptionsTest extends KullaTesting {
|
||||
newStackTraceElement("", "", cr2.snippet(), 1)));
|
||||
}
|
||||
|
||||
// test 8210527
|
||||
public void throwFromWithoutSource() {
|
||||
String message = "show this";
|
||||
SnippetEvent se = assertEvalException("java.lang.reflect.Proxy.newProxyInstance(" +
|
||||
"Thread.currentThread().getContextClassLoader(), new Class[] {}," +
|
||||
"(p, m, a) -> { throw new IllegalStateException(\"" + message + "\"); }).hashCode()");
|
||||
assertExceptionMatch(se,
|
||||
new ExceptionInfo(IllegalStateException.class, message,
|
||||
newStackTraceElement("", "lambda$do_it$$0", se.snippet(), 1),
|
||||
new StackTraceElement("com.sun.proxy.$Proxy0", "hashCode", null, -1),
|
||||
newStackTraceElement("", "", se.snippet(), 1)));
|
||||
}
|
||||
|
||||
// test 8210527
|
||||
public void throwFromNoSource() {
|
||||
Path path = outDir.resolve("fail");
|
||||
compiler.compile(path,
|
||||
"package fail;\n" +
|
||||
"public class Fail {\n" +
|
||||
" static { int x = 1 / 0; }\n" +
|
||||
"}\n");
|
||||
addToClasspath(compiler.getPath(path));
|
||||
SnippetEvent se = assertEvalException("Class.forName(\"fail.Fail\")");
|
||||
assertExceptionMatch(se,
|
||||
new ExceptionInfo(ExceptionInInitializerError.class, null,
|
||||
new StackTraceElement("java.lang.Class", "forName0", "Class.java", -2),
|
||||
new StackTraceElement("java.lang.Class", "forName", "Class.java", -2),
|
||||
newStackTraceElement("", "", se.snippet(), 1)));
|
||||
}
|
||||
|
||||
// test 8212167
|
||||
public void throwLineFormat1() {
|
||||
SnippetEvent se = assertEvalException(
|
||||
@ -367,17 +408,19 @@ public class ExceptionsTest extends KullaTesting {
|
||||
for (int i = 0; i < actual.length; ++i) {
|
||||
StackTraceElement actualElement = actual[i];
|
||||
StackTraceElement expectedElement = expected[i];
|
||||
assertEquals(actualElement.getClassName(), expectedElement.getClassName(), message + " : class names");
|
||||
assertEquals(actualElement.getClassName(), expectedElement.getClassName(), message + " : class names [" + i + "]");
|
||||
String expectedMethodName = expectedElement.getMethodName();
|
||||
if (expectedMethodName.startsWith("lambda$")) {
|
||||
assertTrue(actualElement.getMethodName().startsWith("lambda$"), message + " : method names");
|
||||
} else {
|
||||
assertEquals(actualElement.getMethodName(), expectedElement.getMethodName(), message + " : method names");
|
||||
assertEquals(actualElement.getMethodName(), expectedElement.getMethodName(), message + " : method names [" + i + "]");
|
||||
}
|
||||
assertEquals(actualElement.getFileName(), expectedElement.getFileName(), message + " : file names [" + i + "]");
|
||||
if (expectedElement.getLineNumber() >= 0) {
|
||||
assertEquals(actualElement.getLineNumber(), expectedElement.getLineNumber(), message + " : line numbers [" + i + "]"
|
||||
+ " -- actual: " + actualElement.getLineNumber() + ", expected: " + expectedElement.getLineNumber() +
|
||||
" -- in: " + actualElement.getClassName());
|
||||
}
|
||||
assertEquals(actualElement.getFileName(), expectedElement.getFileName(), message + " : file names");
|
||||
assertEquals(actualElement.getLineNumber(), expectedElement.getLineNumber(), message + " : line numbers"
|
||||
+ " -- actual: " + actualElement.getLineNumber() + ", expected: " + expectedElement.getLineNumber() +
|
||||
" -- in: " + actualElement.getClassName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user