RFR: 8276149: jshell throws EOF error when throwing exception inside switch expression

Jan Lahoda jlahoda at openjdk.java.net
Tue Nov 2 05:54:26 UTC 2021


The completeness analysis does not correctly handle `case ... -> throw`, as it does not expect that `->` can be followed by `throw`, and as an ultimate consequence, it will consider this to be a complete snippet:

void t(int i) {
     int v = switch (i) {
          case 0 -> throw new IllegalStateException();


While it apparently isn't a complete snippet.

The proposed solution is to add a special-case handling for this specific combination, which will ensure JShell will wait for more input for this snippet.

-------------

Commit messages:
 - 8276149: jshell throws EOF error when throwing exception inside switch expression

Changes: https://git.openjdk.java.net/jdk/pull/6207/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=6207&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8276149
  Stats: 13 lines in 2 files changed: 8 ins; 0 del; 5 mod
  Patch: https://git.openjdk.java.net/jdk/pull/6207.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/6207/head:pull/6207

PR: https://git.openjdk.java.net/jdk/pull/6207


More information about the kulla-dev mailing list