Details
-
Bug
-
Resolution: Fixed
-
P3
-
11, 12, 13
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8225898 | 14 | Robert Field | P3 | Resolved | Fixed | team |
JDK-8254618 | 11.0.11-oracle | Robert Field | P3 | Resolved | Fixed | b01 |
JDK-8251149 | 11.0.9 | Robert Field | P3 | Resolved | Fixed | b03 |
Description
ADDITIONAL SYSTEM INFORMATION :
$ jshell --version
jshell 11.0.2
$ java --version
openjdk 11.0.2 2019-01-15
OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)
$javac --version
javac 11.0.2
$ uname -a
Darwin <REDACTED> 18.5.0 Darwin Kernel Version 18.5.0: Mon Mar 11 20:40:32 PDT 2019; root:xnu-4903.251.3~3/RELEASE_X86_64 x86_64
A DESCRIPTION OF THE PROBLEM :
JShell crashes when the user tries to instantiate a generic anonymous class without using type parameters if the type parameter is a formal parameter of the chosen constructor. This bug is reminiscent ofJDK-8221937 but presents a new failure case.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
$ jshell
| Welcome to JShell -- Version 11.0.2
| For an introduction type: /help intro
jshell> abstract class A {}
| created class A
jshell> new A() {}
$2 ==> $0@7f9a81e8
jshell> abstract class A<T> {}
| modified class A
jshell> new A() {}
$4 ==> $1@735b5592
jshell> abstract class A<T> { A(T t){} }
| replaced class A
jshell> new A<String>("") {}
$6 ==> $2@d2cc05a
jshell> new A("") {}
| Warning:
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: begin 0, end -2, length 12
at java.base/java.lang.String.checkBoundsBeginEnd(String.java:3319)
at java.base/java.lang.String.substring(String.java:1874)
at jdk.jshell/jdk.internal.jshell.tool.JShellTool.displayableDiagnostic(JShellTool.java:3509)
at jdk.jshell/jdk.internal.jshell.tool.JShellTool.displayDiagnostics(JShellTool.java:3472)
at jdk.jshell/jdk.internal.jshell.tool.JShellTool.handleEvent(JShellTool.java:3578)
at jdk.jshell/jdk.internal.jshell.tool.JShellTool.processSource(JShellTool.java:3550)
at jdk.jshell/jdk.internal.jshell.tool.JShellTool.processSourceCatchingReset(JShellTool.java:1301)
at jdk.jshell/jdk.internal.jshell.tool.JShellTool.processInput(JShellTool.java:1203)
at jdk.jshell/jdk.internal.jshell.tool.JShellTool.run(JShellTool.java:1176)
at jdk.jshell/jdk.internal.jshell.tool.JShellTool.start(JShellTool.java:975)
at jdk.jshell/jdk.internal.jshell.tool.JShellToolBuilder.start(JShellToolBuilder.java:254)
at jdk.jshell/jdk.internal.jshell.tool.JShellToolProvider.main(JShellToolProvider.java:120)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Creation and instantiation of an anonymous subclass of A
OR
A warning explaining that this is an unchecked calls (e.g. warning: [unchecked] unchecked call to A(T) as a member of the raw type A)
ACTUAL -
JShell crashes
---------- BEGIN SOURCE ----------
See above. Note that failure persists even if class A is not abstract.
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None known
FREQUENCY : always
$ jshell --version
jshell 11.0.2
$ java --version
openjdk 11.0.2 2019-01-15
OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)
$javac --version
javac 11.0.2
$ uname -a
Darwin <REDACTED> 18.5.0 Darwin Kernel Version 18.5.0: Mon Mar 11 20:40:32 PDT 2019; root:xnu-4903.251.3~3/RELEASE_X86_64 x86_64
A DESCRIPTION OF THE PROBLEM :
JShell crashes when the user tries to instantiate a generic anonymous class without using type parameters if the type parameter is a formal parameter of the chosen constructor. This bug is reminiscent of
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
$ jshell
| Welcome to JShell -- Version 11.0.2
| For an introduction type: /help intro
jshell> abstract class A {}
| created class A
jshell> new A() {}
$2 ==> $0@7f9a81e8
jshell> abstract class A<T> {}
| modified class A
jshell> new A() {}
$4 ==> $1@735b5592
jshell> abstract class A<T> { A(T t){} }
| replaced class A
jshell> new A<String>("") {}
$6 ==> $2@d2cc05a
jshell> new A("") {}
| Warning:
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: begin 0, end -2, length 12
at java.base/java.lang.String.checkBoundsBeginEnd(String.java:3319)
at java.base/java.lang.String.substring(String.java:1874)
at jdk.jshell/jdk.internal.jshell.tool.JShellTool.displayableDiagnostic(JShellTool.java:3509)
at jdk.jshell/jdk.internal.jshell.tool.JShellTool.displayDiagnostics(JShellTool.java:3472)
at jdk.jshell/jdk.internal.jshell.tool.JShellTool.handleEvent(JShellTool.java:3578)
at jdk.jshell/jdk.internal.jshell.tool.JShellTool.processSource(JShellTool.java:3550)
at jdk.jshell/jdk.internal.jshell.tool.JShellTool.processSourceCatchingReset(JShellTool.java:1301)
at jdk.jshell/jdk.internal.jshell.tool.JShellTool.processInput(JShellTool.java:1203)
at jdk.jshell/jdk.internal.jshell.tool.JShellTool.run(JShellTool.java:1176)
at jdk.jshell/jdk.internal.jshell.tool.JShellTool.start(JShellTool.java:975)
at jdk.jshell/jdk.internal.jshell.tool.JShellToolBuilder.start(JShellToolBuilder.java:254)
at jdk.jshell/jdk.internal.jshell.tool.JShellToolProvider.main(JShellToolProvider.java:120)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Creation and instantiation of an anonymous subclass of A
OR
A warning explaining that this is an unchecked calls (e.g. warning: [unchecked] unchecked call to A(T) as a member of the raw type A)
ACTUAL -
JShell crashes
---------- BEGIN SOURCE ----------
See above. Note that failure persists even if class A is not abstract.
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None known
FREQUENCY : always
Attachments
Issue Links
- backported by
-
JDK-8225898 JShell: crash on the instantiation of raw anonymous class
-
- Resolved
-
-
JDK-8251149 JShell: crash on the instantiation of raw anonymous class
-
- Resolved
-
-
JDK-8254618 JShell: crash on the instantiation of raw anonymous class
-
- Resolved
-
- duplicates
-
JDK-8221937 JShell: Crash on the instantiation of an anonymous class
-
- Resolved
-