ADDITIONAL SYSTEM INFORMATION :
18-ea+14-756
A DESCRIPTION OF THE PROBLEM :
JShell fails to parse certain switch expressions when entered interactively line by line, giving "Error: reached end of file while parsing"
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Enter the following, line per line, in JShell:
void foo(String bar) {
int v = switch(bar) {
case "one" -> throw new RuntimeException();
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
JShell displays the prompt to enter the next line
ACTUAL -
| Error:
| reached end of file while parsing
| case "one" -> throw new RuntimeException();
| ^
CUSTOMER SUBMITTED WORKAROUND :
Enter everything on a single line. For example, entering the following line works:
void foo(String bar) { int v = switch(bar) { case "one" -> throw new RuntimeException(); default -> 2;};}
18-ea+14-756
A DESCRIPTION OF THE PROBLEM :
JShell fails to parse certain switch expressions when entered interactively line by line, giving "Error: reached end of file while parsing"
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Enter the following, line per line, in JShell:
void foo(String bar) {
int v = switch(bar) {
case "one" -> throw new RuntimeException();
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
JShell displays the prompt to enter the next line
ACTUAL -
| Error:
| reached end of file while parsing
| case "one" -> throw new RuntimeException();
| ^
CUSTOMER SUBMITTED WORKAROUND :
Enter everything on a single line. For example, entering the following line works:
void foo(String bar) { int v = switch(bar) { case "one" -> throw new RuntimeException(); default -> 2;};}
- duplicates
-
JDK-8277387 Use the switch expression in JShell and report an error at the end
-
- Closed
-