Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDK (java/time/chrono/HijrahChronology.java) causes assertion in BadInstanceof #2640

Open
iignatev opened this issue Oct 20, 2021 · 1 comment

Comments

@iignatev
Copy link
Contributor

w/ FallThrough and ReferenceEquality being disabled due to #2638 and #2639 respectively, compiling JDK w/ error-prone leads to c.g.c.util.concurrent.ExecutionError: java.lang.AssertionError: case visitor is implemented in SwitchBuilder :

/Users/iignatye/ws/jdk/open/src/java.base/share/classes/java/time/chrono/HijrahChronology.java:536: error: An unhandled exception was thrown by the Error Prone static analysis plugin.
        if (field instanceof ChronoField) {
                  ^
     Please report this at https://github.com/google/error-prone/issues/new and include the following:
  
     error-prone version: 2.9.0
     BugPattern: BadInstanceof
     Stack Trace:
     com.google.common.util.concurrent.ExecutionError: java.lang.AssertionError: case visitor is implemented in SwitchBuilder
  	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2049)
  	at com.google.common.cache.LocalCache.get(LocalCache.java:3951)
  	at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3974)
  	at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4935)
  	at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4941)
  	at com.google.errorprone.dataflow.DataFlow.methodDataflow(DataFlow.java:176)
  	at com.google.errorprone.dataflow.DataFlow.expressionDataflow(DataFlow.java:236)
  	at com.google.errorprone.dataflow.nullnesspropagation.NullnessAnalysis.getNullness(NullnessAnalysis.java:59)
  	at com.google.errorprone.matchers.NullnessMatcher.matches(NullnessMatcher.java:35)
  	at com.google.errorprone.matchers.NullnessMatcher.matches(NullnessMatcher.java:25)
  	at com.google.errorprone.bugpatterns.BadInstanceof.matchInstanceOf(BadInstanceof.java:62)
  	at com.google.errorprone.scanner.ErrorProneScanner.processMatchers(ErrorProneScanner.java:450)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitInstanceOf(ErrorProneScanner.java:668)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitInstanceOf(ErrorProneScanner.java:151)
  	at jdk.compiler.interim/com.sun.tools.javac.tree.JCTree$JCInstanceOf.accept(JCTree.java:2230)
  	at jdk.compiler.interim/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:86)
  	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
  	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
  	at jdk.compiler.interim/com.sun.source.util.TreeScanner.visitParenthesized(TreeScanner.java:661)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitParenthesized(ErrorProneScanner.java:800)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitParenthesized(ErrorProneScanner.java:151)
  	at jdk.compiler.interim/com.sun.tools.javac.tree.JCTree$JCParens.accept(JCTree.java:2022)
  	at jdk.compiler.interim/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:86)
  	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
  	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
  	at jdk.compiler.interim/com.sun.source.util.TreeScanner.visitIf(TreeScanner.java:485)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitIf(ErrorProneScanner.java:655)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitIf(ErrorProneScanner.java:151)
  	at jdk.compiler.interim/com.sun.tools.javac.tree.JCTree$JCIf.accept(JCTree.java:1565)
  	at jdk.compiler.interim/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:86)
  	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
  	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
  	at jdk.compiler.interim/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:96)
  	at jdk.compiler.interim/com.sun.source.util.TreeScanner.scan(TreeScanner.java:111)
  	at jdk.compiler.interim/com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:272)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitBlock(ErrorProneScanner.java:521)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitBlock(ErrorProneScanner.java:151)
  	at jdk.compiler.interim/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1103)
  	at jdk.compiler.interim/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:86)
  	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
  	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
  	at jdk.compiler.interim/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:96)
  	at jdk.compiler.interim/com.sun.source.util.TreeScanner.visitMethod(TreeScanner.java:224)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitMethod(ErrorProneScanner.java:741)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitMethod(ErrorProneScanner.java:151)
  	at jdk.compiler.interim/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:953)
  	at jdk.compiler.interim/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:86)
  	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
  	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
  	at jdk.compiler.interim/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:96)
  	at jdk.compiler.interim/com.sun.source.util.TreeScanner.scan(TreeScanner.java:111)
  	at jdk.compiler.interim/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:119)
  	at jdk.compiler.interim/com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:203)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:549)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:151)
  	at jdk.compiler.interim/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:860)
  	at jdk.compiler.interim/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:86)
  	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
  	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
  	at jdk.compiler.interim/com.sun.source.util.TreeScanner.scan(TreeScanner.java:111)
  	at jdk.compiler.interim/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:119)
  	at jdk.compiler.interim/com.sun.source.util.TreeScanner.visitCompilationUnit(TreeScanner.java:152)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:561)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:151)
  	at jdk.compiler.interim/com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:614)
  	at jdk.compiler.interim/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:60)
  	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:58)
  	at com.google.errorprone.scanner.ErrorProneScannerTransformer.apply(ErrorProneScannerTransformer.java:43)
  	at com.google.errorprone.ErrorProneAnalyzer.finished(ErrorProneAnalyzer.java:152)
  	at jdk.compiler.interim/com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:132)
  	at jdk.compiler.interim/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1394)
  	at jdk.compiler.interim/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1341)
  	at jdk.compiler.interim/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:933)
  	at jdk.compiler.interim/com.sun.tools.javac.main.Main.compile(Main.java:317)
  	at jdk.compiler.interim/com.sun.tools.javac.main.Main.compile(Main.java:176)
  	at jdk.compiler.interim/com.sun.tools.javac.Main.compile(Main.java:64)
  	at jdk.compiler.interim/com.sun.tools.javac.Main.main(Main.java:50)
  Caused by: java.lang.AssertionError: case visitor is implemented in SwitchBuilder
  	at org.checkerframework.errorprone.dataflow.cfg.builder.CFGTranslationPhaseOne.visitCase(CFGTranslationPhaseOne.java:2200)
  	at org.checkerframework.errorprone.dataflow.cfg.builder.CFGTranslationPhaseOne.visitCase(CFGTranslationPhaseOne.java:198)
  	at jdk.compiler.interim/com.sun.tools.javac.tree.JCTree$JCCase.accept(JCTree.java:1357)
  	at jdk.compiler.interim/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:86)
  	at jdk.compiler.interim/com.sun.source.util.TreeScanner.scan(TreeScanner.java:111)
  	at jdk.compiler.interim/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:119)
  	at jdk.compiler.interim/com.sun.source.util.TreeScanner.visitSwitchExpression(TreeScanner.java:384)
  	at jdk.compiler.interim/com.sun.tools.javac.tree.JCTree$JCSwitchExpression.accept(JCTree.java:1390)
  	at jdk.compiler.interim/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:86)
  	at org.checkerframework.errorprone.dataflow.cfg.builder.CFGTranslationPhaseOne.visitReturn(CFGTranslationPhaseOne.java:2931)
  	at org.checkerframework.errorprone.dataflow.cfg.builder.CFGTranslationPhaseOne.visitReturn(CFGTranslationPhaseOne.java:198)
  	at jdk.compiler.interim/com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1717)
  	at jdk.compiler.interim/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:86)
  	at org.checkerframework.errorprone.dataflow.cfg.builder.CFGTranslationPhaseOne.visitBlock(CFGTranslationPhaseOne.java:2062)
  	at org.checkerframework.errorprone.dataflow.cfg.builder.CFGTranslationPhaseOne.visitBlock(CFGTranslationPhaseOne.java:198)
  	at jdk.compiler.interim/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1103)
  	at jdk.compiler.interim/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:86)
  	at org.checkerframework.errorprone.dataflow.cfg.builder.CFGTranslationPhaseOne.visitIf(CFGTranslationPhaseOne.java:2741)
  	at org.checkerframework.errorprone.dataflow.cfg.builder.CFGTranslationPhaseOne.visitIf(CFGTranslationPhaseOne.java:198)
  	at jdk.compiler.interim/com.sun.tools.javac.tree.JCTree$JCIf.accept(JCTree.java:1565)
  	at jdk.compiler.interim/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:86)
  	at org.checkerframework.errorprone.dataflow.cfg.builder.CFGTranslationPhaseOne.visitBlock(CFGTranslationPhaseOne.java:2062)
  	at org.checkerframework.errorprone.dataflow.cfg.builder.CFGTranslationPhaseOne.visitBlock(CFGTranslationPhaseOne.java:198)
  	at jdk.compiler.interim/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1103)
  	at jdk.compiler.interim/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:60)
  	at org.checkerframework.errorprone.dataflow.cfg.builder.CFGTranslationPhaseOne.process(CFGTranslationPhaseOne.java:428)
  	at org.checkerframework.errorprone.dataflow.cfg.builder.CFGTranslationPhaseOne.process(CFGTranslationPhaseOne.java:467)
  	at org.checkerframework.errorprone.dataflow.cfg.builder.CFGBuilder.build(CFGBuilder.java:70)
  	at com.google.errorprone.dataflow.DataFlow$2.load(DataFlow.java:127)
  	at com.google.errorprone.dataflow.DataFlow$2.load(DataFlow.java:95)
  	at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3529)
  	at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2278)
  	at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2155)
  	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2045)
  	... 76 more
@cushon
Copy link
Collaborator

cushon commented Oct 21, 2021

Thanks for the report!

     com.google.common.util.concurrent.ExecutionError: java.lang.AssertionError: case visitor is implemented in SwitchBuilder
...
  	at com.google.errorprone.dataflow.DataFlow.methodDataflow(DataFlow.java:176)

I think this one is a limitation of the Checker Framework dataflow library we're using, which is being tracked here: typetools/checker-framework#2373

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants