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

ApplyFakeOverrides erase the annotation of return type #786

Open
Ao-senXiong opened this issue Jun 19, 2024 · 5 comments · May be fixed by #787
Open

ApplyFakeOverrides erase the annotation of return type #786

Ao-senXiong opened this issue Jun 19, 2024 · 5 comments · May be fixed by #787
Labels

Comments

@Ao-senXiong
Copy link
Member

Ao-senXiong commented Jun 19, 2024

Script

./checker/bin/javac -cp "framework/build/classes/java/main:framework/build/classes/java/test" -processorpath "checker/dist/checker.jar:framework/build/classes/java/test" -processor viewpointtest.ViewpointTestChecker Test.java

code

import javax.lang.model.element.TypeElement;

public class Test {
    void test(TypeElement element) {
        element.asType();
    }
}

Stacktrace:

error: Error in AnnotatedTypeMirror.fromExpression(ViewpointTestAnnotatedTypeFactory, element.asType()): Unexpected null argument:  compareByName(null, @viewpointtest.quals.ReceiverDependentQual)
  ; The Checker Framework crashed.  Please report the crash.  Version: Checker Framework 3.42.0-eisop4-SNAPSHOT, branch clearAnnotation-only-typevar, 2024-06-20, commit b5fc573, dirty=true. 
  Checker: class viewpointtest.ViewpointTestChecker
  Visitor: class org.checkerframework.common.basetype.BaseTypeVisitor
  Compilation unit: Tester.java
  Last visited tree at line 6 column 1:
  public class Tester {
  Exception: org.checkerframework.javacutil.BugInCF: Unexpected null argument:  compareByName(null, @viewpointtest.quals.ReceiverDependentQual); org.checkerframework.javacutil.BugInCF: Unexpected null argument:  compareByName(null, @viewpointtest.quals.ReceiverDependentQual)
        at org.checkerframework.javacutil.AnnotationUtils.compareByName(AnnotationUtils.java:135)
        at org.checkerframework.javacutil.AnnotationUtils.areSameByName(AnnotationUtils.java:162)
        at org.checkerframework.javacutil.AnnotationUtils.areSame(AnnotationUtils.java:113)
        at viewpointtest.ViewpointTestViewpointAdapter.combineAnnotationWithAnnotation(ViewpointTestViewpointAdapter.java:40)
        at org.checkerframework.framework.type.AbstractViewpointAdapter.combineAnnotationWithType(AbstractViewpointAdapter.java:313)
        at org.checkerframework.framework.type.AbstractViewpointAdapter.combineTypeWithType(AbstractViewpointAdapter.java:245)
        at org.checkerframework.framework.type.AbstractViewpointAdapter.viewpointAdaptMethod(AbstractViewpointAdapter.java:176)
        at org.checkerframework.framework.type.AnnotatedTypeFactory.methodFromUse(AnnotatedTypeFactory.java:2570)
        at org.checkerframework.framework.type.AnnotatedTypeFactory.methodFromUse(AnnotatedTypeFactory.java:2512)
        at org.checkerframework.framework.type.GenericAnnotatedTypeFactory.methodFromUse(GenericAnnotatedTypeFactory.java:2299)
        at org.checkerframework.framework.type.TypeFromExpressionVisitor.visitMethodInvocation(TypeFromExpressionVisitor.java:413)
        at org.checkerframework.framework.type.TypeFromExpressionVisitor.visitMethodInvocation(TypeFromExpressionVisitor.java:81)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1666)
        at jdk.compiler/com.sun.source.util.SimpleTreeVisitor.visit(SimpleTreeVisitor.java:80)
        at org.checkerframework.framework.type.TypeFromTree.fromExpression(TypeFromTree.java:42)
        at org.checkerframework.framework.type.AnnotatedTypeFactory.fromExpression(AnnotatedTypeFactory.java:1852)
        at org.checkerframework.framework.type.AnnotatedTypeFactory.getAnnotatedType(AnnotatedTypeFactory.java:1495)
        at org.checkerframework.framework.flow.CFAbstractTransfer.getValueFromFactory(CFAbstractTransfer.java:215)
        at org.checkerframework.framework.flow.CFAbstractTransfer.visitMethodInvocation(CFAbstractTransfer.java:999)
        at org.checkerframework.framework.flow.CFAbstractTransfer.visitMethodInvocation(CFAbstractTransfer.java:97)
        at org.checkerframework.dataflow.cfg.node.MethodInvocationNode.accept(MethodInvocationNode.java:124)
        at org.checkerframework.dataflow.analysis.AbstractAnalysis.callTransferFunction(AbstractAnalysis.java:356)
        at org.checkerframework.dataflow.analysis.ForwardAnalysisImpl.callTransferFunction(ForwardAnalysisImpl.java:393)
        at org.checkerframework.dataflow.analysis.ForwardAnalysisImpl.performAnalysisBlock(ForwardAnalysisImpl.java:157)
        at org.checkerframework.dataflow.analysis.ForwardAnalysisImpl.performAnalysis(ForwardAnalysisImpl.java:110)
        at org.checkerframework.framework.flow.CFAbstractAnalysis.performAnalysis(CFAbstractAnalysis.java:150)
        at org.checkerframework.framework.type.GenericAnnotatedTypeFactory.analyze(GenericAnnotatedTypeFactory.java:1624)
        at org.checkerframework.framework.type.GenericAnnotatedTypeFactory.performFlowAnalysis(GenericAnnotatedTypeFactory.java:1513)
        at org.checkerframework.framework.type.GenericAnnotatedTypeFactory.checkAndPerformFlowAnalysis(GenericAnnotatedTypeFactory.java:2101)
        at org.checkerframework.framework.type.GenericAnnotatedTypeFactory.preProcessClassTree(GenericAnnotatedTypeFactory.java:435)
        at org.checkerframework.common.basetype.BaseTypeVisitor.visitClass(BaseTypeVisitor.java:591)
        at org.checkerframework.common.basetype.BaseTypeVisitor.visitClass(BaseTypeVisitor.java:195)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:808)
        at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:56)
        at org.checkerframework.framework.source.SourceVisitor.visit(SourceVisitor.java:89)
        at org.checkerframework.framework.source.SourceChecker.typeProcess(SourceChecker.java:1136)
        at org.checkerframework.common.basetype.BaseTypeChecker.typeProcess(BaseTypeChecker.java:556)
        at org.checkerframework.javacutil.AbstractTypeProcessor$AttributionTaskListener.finished(AbstractTypeProcessor.java:193)
        at jdk.compiler/com.sun.tools.javac.api.ClientCodeWrapper$WrappedTaskListener.finished(ClientCodeWrapper.java:828)
        at jdk.compiler/com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:132)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1417)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1374)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:973)
        at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:311)
        at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:170)
        at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
        at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)
  Caused by: java.lang.Throwable
        at org.checkerframework.javacutil.BugInCF.<init>(BugInCF.java:34)
        ... 47 more
  
  Underlying Exception: java.lang.Throwable; java.lang.Throwable
        at org.checkerframework.javacutil.BugInCF.<init>(BugInCF.java:34)
        at org.checkerframework.javacutil.AnnotationUtils.compareByName(AnnotationUtils.java:135)
        at org.checkerframework.javacutil.AnnotationUtils.areSameByName(AnnotationUtils.java:162)
        at org.checkerframework.javacutil.AnnotationUtils.areSame(AnnotationUtils.java:113)
        at viewpointtest.ViewpointTestViewpointAdapter.combineAnnotationWithAnnotation(ViewpointTestViewpointAdapter.java:40)
        at org.checkerframework.framework.type.AbstractViewpointAdapter.combineAnnotationWithType(AbstractViewpointAdapter.java:313)
        at org.checkerframework.framework.type.AbstractViewpointAdapter.combineTypeWithType(AbstractViewpointAdapter.java:245)
        at org.checkerframework.framework.type.AbstractViewpointAdapter.viewpointAdaptMethod(AbstractViewpointAdapter.java:176)
        at org.checkerframework.framework.type.AnnotatedTypeFactory.methodFromUse(AnnotatedTypeFactory.java:2570)
        at org.checkerframework.framework.type.AnnotatedTypeFactory.methodFromUse(AnnotatedTypeFactory.java:2512)
        at org.checkerframework.framework.type.GenericAnnotatedTypeFactory.methodFromUse(GenericAnnotatedTypeFactory.java:2299)
        at org.checkerframework.framework.type.TypeFromExpressionVisitor.visitMethodInvocation(TypeFromExpressionVisitor.java:413)
        at org.checkerframework.framework.type.TypeFromExpressionVisitor.visitMethodInvocation(TypeFromExpressionVisitor.java:81)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1666)
        at jdk.compiler/com.sun.source.util.SimpleTreeVisitor.visit(SimpleTreeVisitor.java:80)
        at org.checkerframework.framework.type.TypeFromTree.fromExpression(TypeFromTree.java:42)
        at org.checkerframework.framework.type.AnnotatedTypeFactory.fromExpression(AnnotatedTypeFactory.java:1852)
        at org.checkerframework.framework.type.AnnotatedTypeFactory.getAnnotatedType(AnnotatedTypeFactory.java:1495)
        at org.checkerframework.framework.flow.CFAbstractTransfer.getValueFromFactory(CFAbstractTransfer.java:215)
        at org.checkerframework.framework.flow.CFAbstractTransfer.visitMethodInvocation(CFAbstractTransfer.java:999)
        at org.checkerframework.framework.flow.CFAbstractTransfer.visitMethodInvocation(CFAbstractTransfer.java:97)
        at org.checkerframework.dataflow.cfg.node.MethodInvocationNode.accept(MethodInvocationNode.java:124)
        at org.checkerframework.dataflow.analysis.AbstractAnalysis.callTransferFunction(AbstractAnalysis.java:356)
        at org.checkerframework.dataflow.analysis.ForwardAnalysisImpl.callTransferFunction(ForwardAnalysisImpl.java:393)
        at org.checkerframework.dataflow.analysis.ForwardAnalysisImpl.performAnalysisBlock(ForwardAnalysisImpl.java:157)
        at org.checkerframework.dataflow.analysis.ForwardAnalysisImpl.performAnalysis(ForwardAnalysisImpl.java:110)
        at org.checkerframework.framework.flow.CFAbstractAnalysis.performAnalysis(CFAbstractAnalysis.java:150)
        at org.checkerframework.framework.type.GenericAnnotatedTypeFactory.analyze(GenericAnnotatedTypeFactory.java:1624)
        at org.checkerframework.framework.type.GenericAnnotatedTypeFactory.performFlowAnalysis(GenericAnnotatedTypeFactory.java:1513)
        at org.checkerframework.framework.type.GenericAnnotatedTypeFactory.checkAndPerformFlowAnalysis(GenericAnnotatedTypeFactory.java:2101)
        at org.checkerframework.framework.type.GenericAnnotatedTypeFactory.preProcessClassTree(GenericAnnotatedTypeFactory.java:435)
        at org.checkerframework.common.basetype.BaseTypeVisitor.visitClass(BaseTypeVisitor.java:591)
        at org.checkerframework.common.basetype.BaseTypeVisitor.visitClass(BaseTypeVisitor.java:195)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:808)
        at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:56)
        at org.checkerframework.framework.source.SourceVisitor.visit(SourceVisitor.java:89)
        at org.checkerframework.framework.source.SourceChecker.typeProcess(SourceChecker.java:1136)
        at org.checkerframework.common.basetype.BaseTypeChecker.typeProcess(BaseTypeChecker.java:556)
        at org.checkerframework.javacutil.AbstractTypeProcessor$AttributionTaskListener.finished(AbstractTypeProcessor.java:193)
        at jdk.compiler/com.sun.tools.javac.api.ClientCodeWrapper$WrappedTaskListener.finished(ClientCodeWrapper.java:828)
        at jdk.compiler/com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:132)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1417)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1374)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:973)
        at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:311)
        at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:170)
        at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
        at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)

Reason (Java 11):
image

Java 17:
image

@Ao-senXiong
Copy link
Member Author

apprently, this clearAnnotations clear everything

.

@wmdietl
Copy link
Member

wmdietl commented Jun 21, 2024

A side comment: you are using ./checker/bin/javac which automatically adds all CF jar files. You only need to add the directories with the test annotations, if they are necessary.

@Ao-senXiong
Copy link
Member Author

A side comment: you are using ./checker/bin/javac which automatically adds all CF jar files. You only need to add the directories with the test annotations, if they are necessary.

Thanks, I have updated the description.

@Ao-senXiong
Copy link
Member Author

Based on the furthur debugging, looks like this issue is related to stubTypes field is different in Java 11 and Java 17

@Ao-senXiong
Copy link
Member Author

More specificly, this field in AnnotationFileElementTypes.AnnotationFileParser.

public final Map<ExecutableElement, List<IPair<TypeMirror, AnnotatedTypeMirror>>>

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

Successfully merging a pull request may close this issue.

2 participants