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

ThisEscapeAnalyzer crashes for erroneous code

XMLWordPrintable

    • b04

        Consider this class:
        ---
        package test;

        public class Demo {

            public Demo() {
                Unknown.test();
            }

        }
        ---

        When compiled with -Xlint:this-escape and should-stop at FLOW, this will crash:
        ---
        $ ./build/linux-x86_64-server-release/images/jdk/bin/javac -Xlint:all -XDshould-stop.at=FLOW -XDdev /tmp/Demo.java
        /tmp/Demo.java:6: error: cannot find symbol
                Unknown.test();
                ^
          symbol: variable Unknown
          location: class Demo
        1 error
        An exception has occurred in the compiler (23.0.1-internal). Please file a bug against the Java compiler via the Java bug reporting page (https://bugreport.java.com) after checking the Bug Database (https://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.ClassCastException: class com.sun.tools.javac.code.Symbol$ClassSymbol cannot be cast to class com.sun.tools.javac.code.Symbol$MethodSymbol (com.sun.tools.javac.code.Symbol$ClassSymbol and com.sun.tools.javac.code.Symbol$MethodSymbol are in module jdk.compiler of loader 'app')
                at jdk.compiler/com.sun.tools.javac.comp.ThisEscapeAnalyzer.visitApply(ThisEscapeAnalyzer.java:509)
                at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1819)
                at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:50)
                at jdk.compiler/com.sun.tools.javac.comp.ThisEscapeAnalyzer.scan(ThisEscapeAnalyzer.java:462)
                at jdk.compiler/com.sun.tools.javac.comp.ThisEscapeAnalyzer.visitExec(ThisEscapeAnalyzer.java:922)
                at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1606)
                at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:50)
                at jdk.compiler/com.sun.tools.javac.comp.ThisEscapeAnalyzer.scan(ThisEscapeAnalyzer.java:462)
                at jdk.compiler/com.sun.tools.javac.comp.ThisEscapeAnalyzer.analyzeStatements(ThisEscapeAnalyzer.java:419)
                at jdk.compiler/com.sun.tools.javac.comp.ThisEscapeAnalyzer.lambda$analyzeTree$6(ThisEscapeAnalyzer.java:358)
                at jdk.compiler/com.sun.tools.javac.comp.ThisEscapeAnalyzer.visitScoped(ThisEscapeAnalyzer.java:1109)
                at jdk.compiler/com.sun.tools.javac.comp.ThisEscapeAnalyzer.visitTopLevel(ThisEscapeAnalyzer.java:1059)
                at jdk.compiler/com.sun.tools.javac.comp.ThisEscapeAnalyzer.lambda$analyzeTree$7(ThisEscapeAnalyzer.java:357)
                at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
                at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:194)
                at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
                at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1939)
                at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:556)
                at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:546)
                at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
                at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
                at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:265)
                at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:611)
                at jdk.compiler/com.sun.tools.javac.comp.ThisEscapeAnalyzer.analyzeTree(ThisEscapeAnalyzer.java:356)
                at jdk.compiler/com.sun.tools.javac.comp.Flow.analyzeTree(Flow.java:234)
                at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1426)
                at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1400)
                at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:976)
                at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:319)
                at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:178)
                at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:66)
                at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:52)
        printing javac parameters to: /home/jlahoda/src/jdk/jdk/javac.20231215_075855.args
        ---

        Originally reported as:
        https://github.com/apache/netbeans/issues/6826

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

                Created:
                Updated:
                Resolved: