RFR: 8273039: JShell crashes when naming variable or method "abstract" or "strictfp"

Jan Lahoda jlahoda at openjdk.java.net
Wed Oct 13 07:00:10 UTC 2021


When JShell processes `int strictfp = 0;` (which is obviously erroneous), it will speculativelly try to parse and attribute code along these lines:

package REPL;
import java.io.*;import java.math.*;import java.net.*;import java.nio.file.*;import java.util.*;import java.util.concurrent.*;import java.util.function.*;import java.util.prefs.*;import java.util.regex.*;import java.util.stream.*;
class $JShell$DOESNOTMATTER {
    public static Object do_it$() throws Throwable {
        return int strictfp = 0;
    }
}


This crashes `Attr`, as the `strictfp` will be wrapped in `JCModifiers`, wrapped inside an erroneous tree, and `Attr` does not handle modifiers.

The proposal is to let `Attr` "handle" the `JCModifiers` in an error-recovery situation.

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

Commit messages:
 - Removing trailing whitespace
 - 8273039: JShell crashes when naming variable or method "abstract" or "strictfp"

Changes: https://git.openjdk.java.net/jdk/pull/5897/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=5897&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8273039
  Stats: 182 lines in 3 files changed: 181 ins; 0 del; 1 mod
  Patch: https://git.openjdk.java.net/jdk/pull/5897.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/5897/head:pull/5897

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


More information about the compiler-dev mailing list