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

Vicente Romero vromero at openjdk.java.net
Fri Nov 5 18:46:38 UTC 2021


On Mon, 11 Oct 2021 16:48:07 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

> 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.

lgtm

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

Marked as reviewed by vromero (Reviewer).

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


More information about the compiler-dev mailing list