Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8269354

javac crashes when processing parenthesized pattern in instanceof

    XMLWordPrintable

Details

    • b30

    Backports

      Description

        Consider this code:
        ---
        public class PatternTest {
            public static void main(String[] args) {
                Object expr = "a";
                boolean b = expr instanceof (String a && a.equals("a"));
            }
        }
        ---

        This crashes javac:
        $ javac --enable-preview -source 17 PatternTest.java
        Note: PatternTest.java uses preview features of Java SE 17.
        Note: Recompile with -Xlint:preview for details.
        An exception has occurred in the compiler (17-internal). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you.
        java.lang.NullPointerException: Cannot read field "sym" because "this.lvar[3]" is null
                at jdk.compiler/com.sun.tools.javac.jvm.Code.emitop0(Code.java:577)
                at jdk.compiler/com.sun.tools.javac.jvm.Items$LocalItem.load(Items.java:399)
                at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitSelect(Gen.java:2339)
                at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:2450)
        ...
        ---

        Attachments

          Issue Links

            Activity

              People

                jlahoda Jan Lahoda
                jlahoda Jan Lahoda
                Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: