Escape-this analysis throw an exception

Remi Forax forax at univ-mlv.fr
Sun Oct 1 17:26:35 UTC 2023


Hello,
while playing with the escape-this new analysis, i've found a bug

import java.util.function.Supplier;

public class EscapeThis4 {
  public EscapeThis4() {
    System.out.println((Supplier<Object>)  () -> this);
  }
}


% javac -Xlint:all EscapeThis4.java
An exception has occurred in the compiler (21). 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.AssertionError
        at jdk.compiler/com.sun.tools.javac.util.Assert.error(Assert.java:155)
        at jdk.compiler/com.sun.tools.javac.util.Assert.check(Assert.java:46)
        at jdk.compiler/com.sun.tools.javac.comp.ThisEscapeAnalyzer.checkInvariants(ThisEscapeAnalyzer.java:1209)
        at jdk.compiler/com.sun.tools.javac.comp.ThisEscapeAnalyzer.visitScoped(ThisEscapeAnalyzer.java:1103)
        at jdk.compiler/com.sun.tools.javac.comp.ThisEscapeAnalyzer.lambda$visitLambda$24(ThisEscapeAnalyzer.java:732)
        at jdk.compiler/com.sun.tools.javac.comp.ThisEscapeAnalyzer.visitDeferred(ThisEscapeAnalyzer.java:1073)
        at jdk.compiler/com.sun.tools.javac.comp.ThisEscapeAnalyzer.visitLambda(ThisEscapeAnalyzer.java:732)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1993)
        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.visitTypeCast(ThisEscapeAnalyzer.java:949)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCTypeCast.accept(JCTree.java:2204)
        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.invokeUnknown(ThisEscapeAnalyzer.java:623)
        at jdk.compiler/com.sun.tools.javac.comp.ThisEscapeAnalyzer.invoke(ThisEscapeAnalyzer.java:552)
        at jdk.compiler/com.sun.tools.javac.comp.ThisEscapeAnalyzer.visitApply(ThisEscapeAnalyzer.java:530)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1816)
        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:915)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1603)
        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:1102)
        at jdk.compiler/com.sun.tools.javac.comp.ThisEscapeAnalyzer.visitTopLevel(ThisEscapeAnalyzer.java:1052)
        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:179)
        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:509)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        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:234)
        at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
        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:233)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1418)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1392)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:978)
        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:64)
        at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:50)

regards,
Rémi


More information about the compiler-dev mailing list