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

Stack overflow in combineAnnotationWithType when check generics extends itself to list #778

Open
Ao-senXiong opened this issue Jun 3, 2024 · 1 comment · May be fixed by #788
Open

Stack overflow in combineAnnotationWithType when check generics extends itself to list #778

Ao-senXiong opened this issue Jun 3, 2024 · 1 comment · May be fixed by #788
Labels

Comments

@Ao-senXiong
Copy link
Member

command:

./checker/bin/javac -cp "framework/build/libs/framework-3.42.0-eisop4-SNAPSHOT.jar:framework/build/classes/java/main:framework/build/classes/java/test:javacutil/libs/javacutil-3.42.0-eisop4-SANPSHOT.jar:javacutil/build/classes/java/main:javacutil/build/classes/java/test" -processorpath "framework/build/classes/java/test" -processor viewpointtest.ViewpointTestChecker Test.java

code:

import org.checkerframework.common.basetype.BaseAnnotatedTypeFactory;
import org.checkerframework.common.basetype.BaseTypeChecker;
import org.checkerframework.framework.type.typeannotator.IrrelevantTypeAnnotator;
import org.checkerframework.framework.type.typeannotator.TypeAnnotator;
import java.util.ArrayList;
import java.util.List;

public class Test extends BaseAnnotatedTypeFactory {
    public Test(BaseTypeChecker checker, boolean useFlow) {
        super(checker, useFlow);
    }

    void foo() {
        List<TypeAnnotator> typeAnnotators = new ArrayList<>();
        typeAnnotators.add(new IrrelevantTypeAnnotator(this));
    }
}

error:

error: Error in AnnotatedTypeMirror.fromExpression(ViewpointTestAnnotatedTypeFactory, new IrrelevantTypeAnnotator(this)): null
  ; The Checker Framework crashed.  Please report the crash.  Version: Checker Framework 3.42.0-eisop4-SNAPSHOT, branch master, 2024-05-31, commit 97503e1, dirty=true. 
  Checker: class viewpointtest.ViewpointTestChecker
  Visitor: class org.checkerframework.common.basetype.BaseTypeVisitor
  Compilation unit: Test.java
  Last visited tree at line 9 column 1:
  public class Test extends BaseAnnotatedTypeFactory {
  Exception: java.lang.StackOverflowError; java.lang.StackOverflowError
        at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.getEnclosedElements(Symbol.java:1375)
        at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.getEnclosedElements(Symbol.java:1257)
        at org.checkerframework.javacutil.AnnotationUtils.compareAnnotationMirrors(AnnotationUtils.java:383)
        at java.base/java.util.TreeMap.compare(TreeMap.java:1570)
        at java.base/java.util.TreeMap.addEntryToEmptyMap(TreeMap.java:776)
        at java.base/java.util.TreeMap.put(TreeMap.java:785)
        at java.base/java.util.TreeMap.put(TreeMap.java:534)
        at java.base/java.util.TreeSet.add(TreeSet.java:255)
        at org.checkerframework.javacutil.AnnotationMirrorSet.add(AnnotationMirrorSet.java:170)
        at org.checkerframework.framework.type.AnnotatedTypeMirror.addAnnotation(AnnotatedTypeMirror.java:637)
        at org.checkerframework.framework.type.AnnotatedTypeMirror.addAnnotations(AnnotatedTypeMirror.java:684)
        at org.checkerframework.framework.type.AnnotatedTypeCopier.maybeCopyPrimaryAnnotations(AnnotatedTypeCopier.java:394)
        at org.checkerframework.framework.type.AnnotatedTypeCopier.makeCopy(AnnotatedTypeCopier.java:378)
        at org.checkerframework.framework.type.AnnotatedTypeCopier.makeOrReturnCopy(AnnotatedTypeCopier.java:356)
        at org.checkerframework.framework.type.AnnotatedTypeCopier.visitDeclared(AnnotatedTypeCopier.java:113)
        at org.checkerframework.framework.type.AnnotatedTypeCopier.visitDeclared(AnnotatedTypeCopier.java:44)
        at org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedDeclaredType.accept(AnnotatedTypeMirror.java:1058)
        at org.checkerframework.framework.type.AnnotatedTypeCopier.visit(AnnotatedTypeCopier.java:102)
        at org.checkerframework.framework.type.AnnotatedTypeCopier.visitWildcard(AnnotatedTypeCopier.java:321)
        at org.checkerframework.framework.type.AnnotatedTypeCopier.visitWildcard(AnnotatedTypeCopier.java:44)
        at org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedWildcardType.accept(AnnotatedTypeMirror.java:2323)
        at org.checkerframework.framework.type.AnnotatedTypeCopier.visit(AnnotatedTypeCopier.java:95)
        at org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedWildcardType.deepCopy(AnnotatedTypeMirror.java:2333)
        at org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedWildcardType.shallowCopy(AnnotatedTypeMirror.java:2345)
        at org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedWildcardType.shallowCopy(AnnotatedTypeMirror.java:2354)
        at org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedWildcardType.shallowCopy(AnnotatedTypeMirror.java:2184)
        at org.checkerframework.framework.type.AbstractViewpointAdapter.combineAnnotationWithType(AbstractViewpointAdapter.java:338)
        at org.checkerframework.framework.type.AbstractViewpointAdapter.combineAnnotationWithType(AbstractViewpointAdapter.java:311)
        at org.checkerframework.framework.type.AbstractViewpointAdapter.combineAnnotationWithType(AbstractViewpointAdapter.java:350)
        at org.checkerframework.framework.type.AbstractViewpointAdapter.combineAnnotationWithType(AbstractViewpointAdapter.java:311)
        at org.checkerframework.framework.type.AbstractViewpointAdapter.combineAnnotationWithType(AbstractViewpointAdapter.java:350)
        at org.checkerframework.framework.type.AbstractViewpointAdapter.combineAnnotationWithType(AbstractViewpointAdapter.java:311)
        at org.checkerframework.framework.type.AbstractViewpointAdapter.combineAnnotationWithType(AbstractViewpointAdapter.java:350)
        at org.checkerframework.framework.type.AbstractViewpointAdapter.combineAnnotationWithType(AbstractViewpointAdapter.java:311)
        at org.checkerframework.framework.type.AbstractViewpointAdapter.combineAnnotationWithType(AbstractViewpointAdapter.java:350)
        at org.checkerframework.framework.type.AbstractViewpointAdapter.combineAnnotationWithType(AbstractViewpointAdapter.java:311)
        at org.checkerframework.framework.type.AbstractViewpointAdapter.combineAnnotationWithType(AbstractViewpointAdapter.java:350)
        at org.checkerframework.framework.type.AbstractViewpointAdapter.combineAnnotationWithType(AbstractViewpointAdapter.java:311)
        at org.checkerframework.framework.type.AbstractViewpointAdapter.combineAnnotationWithType(AbstractViewpointAdapter.java:350)
        at org.checkerframework.framework.type.AbstractViewpointAdapter.combineAnnotationWithType(AbstractViewpointAdapter.java:311)
        at org.checkerframework.framework.type.AbstractViewpointAdapter.combineAnnotationWithType(AbstractViewpointAdapter.java:350)
        at org.checkerframework.framework.type.AbstractViewpointAdapter.combineAnnotationWithType(AbstractViewpointAdapter.java:311)
        at org.checkerframework.framework.type.AbstractViewpointAdapter.combineAnnotationWithType(AbstractViewpointAdapter.java:350)
        at org.checkerframework.framework.type.AbstractViewpointAdapter.combineAnnotationWithType(AbstractViewpointAdapter.java:311)
        at org.checkerframework.framework.type.AbstractViewpointAdapter.combineAnnotationWithType(AbstractViewpointAdapter.java:350)
        at org.checkerframework.framework.type.AbstractViewpointAdapter.combineAnnotationWithType(AbstractViewpointAdapter.java:311)
        at org.checkerframework.framework.type.AbstractViewpointAdapter.combineAnnotationWithType(AbstractViewpointAdapter.java:350)
@Ao-senXiong
Copy link
Member Author

Updated:
a better example:

public class Test<A extends Test<A>> {

    void foo() {
        Test a = new Test();
    }
}

@Ao-senXiong Ao-senXiong changed the title Stack overflow when using adding IrrelevantTypeAnnotator to list Stack overflow in combineAnnotationWithType when check generics extends itself to list Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant