Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8228221 | 13.0.2 | Robert Field | P4 | Resolved | Fixed | b01 |
JDK-8228006 | 13.0.1 | Robert Field | P4 | Resolved | Fixed | master |
JDK-8226281 | 13 | Robert Field | P4 | Resolved | Fixed | b26 |
JDK-8244372 | 11.0.9-oracle | Adam Sotona | P4 | Resolved | Fixed | b01 |
JDK-8241324 | 11.0.8 | Robert Field | P4 | Resolved | Fixed | b01 |
A DESCRIPTION OF THE PROBLEM :
For some multiline snippets the JShell produces the wrong line number in the stack trace. This can either be observed directly in the JShell or in EvalExceptions obtained by an instance of the class jdk.jshell.JShell.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Open a jshell console and type the following code
jshell> if (true) {
...> int x = 10;
...> int y = 10 / 0;}
| java.lang.ArithmeticException thrown: / by zero
| at (#1:1)
My original example was a snippet from a larger file which had leading newlines (see test case below): "\n\nint y = 10 / 0;"
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The exception should be reported on line 3 of this snippet.
For example, the following code works as expected:
jshell> if (true) {
...> int x = 10;
...> int y = 10 / 0;
...> }
| java.lang.ArithmeticException thrown: / by zero
| at (#2:3)
The only difference in this example is the additional line break before the closing brace. However, beyond this example I could not identify any pattern which code leads to errors and which does not.
ACTUAL -
The exception is reported on line 1 instead of line 3.
---------- BEGIN SOURCE ----------
import jdk.jshell.JShell;
public class EvalLines {
public static void main(String[] args) {
JShell shell = JShell.create();
shell.eval("\n\nint y = 10/0;").get(0).exception().printStackTrace();
System.out.println("-----");
System.out.println(shell.snippets().findFirst().get().source());
System.out.println("-----");
}
}
---------- END SOURCE ----------
FREQUENCY : always
For some multiline snippets the JShell produces the wrong line number in the stack trace. This can either be observed directly in the JShell or in EvalExceptions obtained by an instance of the class jdk.jshell.JShell.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Open a jshell console and type the following code
jshell> if (true) {
...> int x = 10;
...> int y = 10 / 0;}
| java.lang.ArithmeticException thrown: / by zero
| at (#1:1)
My original example was a snippet from a larger file which had leading newlines (see test case below): "\n\nint y = 10 / 0;"
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The exception should be reported on line 3 of this snippet.
For example, the following code works as expected:
jshell> if (true) {
...> int x = 10;
...> int y = 10 / 0;
...> }
| java.lang.ArithmeticException thrown: / by zero
| at (#2:3)
The only difference in this example is the additional line break before the closing brace. However, beyond this example I could not identify any pattern which code leads to errors and which does not.
ACTUAL -
The exception is reported on line 1 instead of line 3.
---------- BEGIN SOURCE ----------
import jdk.jshell.JShell;
public class EvalLines {
public static void main(String[] args) {
JShell shell = JShell.create();
shell.eval("\n\nint y = 10/0;").get(0).exception().printStackTrace();
System.out.println("-----");
System.out.println(shell.snippets().findFirst().get().source());
System.out.println("-----");
}
}
---------- END SOURCE ----------
FREQUENCY : always
- backported by
-
JDK-8226281 JShell : Stack trace of exception has wrong line number
- Resolved
-
JDK-8228006 JShell : Stack trace of exception has wrong line number
- Resolved
-
JDK-8228221 JShell : Stack trace of exception has wrong line number
- Resolved
-
JDK-8241324 JShell : Stack trace of exception has wrong line number
- Resolved
-
JDK-8244372 JShell : Stack trace of exception has wrong line number
- Resolved
- relates to
-
JDK-8200701 jdk/jshell/ExceptionsTest.java fails on Windows, after JDK-8198801
- Closed
(1 relates to)