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

CCE: AnnotatedWildcardType cannot be cast to class AnnotatedTypeMirror$AnnotatedDeclaredType #6871

Open
theosotr opened this issue Oct 23, 2024 · 0 comments
Assignees
Labels

Comments

@theosotr
Copy link

The bug-triggering program is somewhat similar to that of #6867, but causes a different issue.

Command

javac -J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
  -J--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED \
  -J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
  -J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED \
  -J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED \
  -J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED \
  -J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
  -J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED \
  -J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED \
-processor org.checkerframework.checker.nullness.NullnessChecker \
-cp checker-framework/checker/dist/checker.jar -Aignorejdkastub Test.java

File

interface A<T extends Number> {}

class B<T extends A<? super Number>> {}

public class Test {
    public static void main(String[] args) {
        B<? super A<Number>> x = new B<A<Number>>();
    }
}

Actual behavior

error: SourceChecker.typeProcess: unexpected Throwable (ClassCastException) while processing Test.java; message: class org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedWildcardType cannot be cast to class org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedDeclaredType (org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedWildcardType and org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedDeclaredType are in unnamed module of loader java.net.URLClassLoader @382db087)
  ; The Checker Framework crashed.  Please report the crash.  Version: Checker Framework 3.48.2-SNAPSHOT, branch master, 2024-10-20, commit b7d9092, dirty=true. 
  Compilation unit: Test.java
  Last visited tree at line 7 column 9:
          B<? super A<Number>> x = new B<A<Number>>();
  Exception: java.lang.ClassCastException: class org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedWildcardType cannot be cast to class org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedDeclaredType (org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedWildcardType and org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedDeclaredType are in unnamed module of loader java.net.URLClassLoader @382db087); java.lang.ClassCastException: class org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedWildcardType cannot be cast to class org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedDeclaredType (org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedWildcardType and org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedDeclaredType are in unnamed module of loader java.net.URLClassLoader @382db087)
  	at org.checkerframework.framework.type.visitor.DoubleAnnotatedTypeScanner.visitDeclared(DoubleAnnotatedTypeScanner.java:112)
  	at org.checkerframework.framework.type.visitor.DoubleAnnotatedTypeScanner.visitDeclared(DoubleAnnotatedTypeScanner.java:28)
  	at org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedDeclaredType.accept(AnnotatedTypeMirror.java:1051)
  	at org.checkerframework.framework.type.visitor.AnnotatedTypeScanner.scan(AnnotatedTypeScanner.java:206)
  	at org.checkerframework.framework.type.visitor.DoubleAnnotatedTypeScanner.scan(DoubleAnnotatedTypeScanner.java:106)
  	at org.checkerframework.framework.type.visitor.DoubleAnnotatedTypeScanner.scan(DoubleAnnotatedTypeScanner.java:78)
  	at org.checkerframework.framework.type.visitor.DoubleAnnotatedTypeScanner.visitDeclared(DoubleAnnotatedTypeScanner.java:112)
  	at org.checkerframework.framework.type.visitor.DoubleAnnotatedTypeScanner.visitDeclared(DoubleAnnotatedTypeScanner.java:28)
  	at org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedDeclaredType.accept(AnnotatedTypeMirror.java:1051)
  	at org.checkerframework.framework.type.visitor.AnnotatedTypeScanner.scan(AnnotatedTypeScanner.java:206)
  	at org.checkerframework.framework.type.visitor.DoubleAnnotatedTypeScanner.scan(DoubleAnnotatedTypeScanner.java:106)
  	at org.checkerframework.framework.type.visitor.DoubleAnnotatedTypeScanner.scan(DoubleAnnotatedTypeScanner.java:28)
  	at org.checkerframework.framework.type.visitor.AnnotatedTypeScanner.visit(AnnotatedTypeScanner.java:194)
  	at org.checkerframework.framework.type.AnnotatedTypeFactory.replaceAnnotations(AnnotatedTypeFactory.java:4482)
  	at org.checkerframework.framework.type.AnnotatedTypeFactory.applyCaptureConversion(AnnotatedTypeFactory.java:5014)
  	at org.checkerframework.framework.type.AnnotatedTypeFactory.applyCaptureConversion(AnnotatedTypeFactory.java:4921)
  	at org.checkerframework.common.basetype.BaseTypeValidator.visitParameterizedType(BaseTypeValidator.java:557)
  	at org.checkerframework.common.basetype.BaseTypeValidator.visitDeclared(BaseTypeValidator.java:343)
  	at org.checkerframework.common.basetype.BaseTypeValidator.visitDeclared(BaseTypeValidator.java:60)
  	at org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedDeclaredType.accept(AnnotatedTypeMirror.java:1051)
  	at org.checkerframework.framework.type.visitor.AnnotatedTypeScanner.scan(AnnotatedTypeScanner.java:206)
  	at org.checkerframework.framework.type.visitor.AnnotatedTypeScanner.visit(AnnotatedTypeScanner.java:194)
  	at org.checkerframework.common.basetype.BaseTypeValidator.isValid(BaseTypeValidator.java:116)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.validateType(BaseTypeVisitor.java:4840)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.commonAssignmentCheck(BaseTypeVisitor.java:3016)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitVariable(BaseTypeVisitor.java:1608)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitVariable(BaseTypeVisitor.java:189)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:974)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
  	at org.checkerframework.framework.source.SourceVisitor.scan(SourceVisitor.java:92)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:408)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:189)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:105)
  	at jdk.compiler/com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:248)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1032)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
  	at org.checkerframework.framework.source.SourceVisitor.scan(SourceVisitor.java:92)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:408)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:189)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:90)
  	at jdk.compiler/com.sun.source.util.TreeScanner.visitMethod(TreeScanner.java:206)
  	at org.checkerframework.framework.source.SourceVisitor.visitMethod(SourceVisitor.java:110)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.processMethodTree(BaseTypeVisitor.java:1058)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitMethod(BaseTypeVisitor.java:954)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitMethod(BaseTypeVisitor.java:189)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:898)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
  	at org.checkerframework.framework.source.SourceVisitor.scan(SourceVisitor.java:92)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:408)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:189)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:90)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:105)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:113)
  	at jdk.compiler/com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:187)
  	at org.checkerframework.framework.source.SourceVisitor.visitClass(SourceVisitor.java:98)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.processClassTree(BaseTypeVisitor.java:603)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitClass(BaseTypeVisitor.java:558)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitClass(BaseTypeVisitor.java:189)
  	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:86)
  	at org.checkerframework.framework.source.SourceChecker.typeProcess(SourceChecker.java:1347)
  	at org.checkerframework.framework.source.SourceChecker.typeProcess(SourceChecker.java:1268)
  	at org.checkerframework.javacutil.AbstractTypeProcessor$AttributionTaskListener.finished(AbstractTypeProcessor.java:188)
  	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:1418)
  	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1375)
  	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)
error: SourceChecker.typeProcess: unexpected Throwable (ClassCastException) while processing Test.java; message: class org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedWildcardType cannot be cast to class org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedDeclaredType (org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedWildcardType and org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedDeclaredType are in unnamed module of loader java.net.URLClassLoader @382db087)
  ; The Checker Framework crashed.  Please report the crash.  Version: Checker Framework 3.48.2-SNAPSHOT, branch master, 2024-10-20, commit b7d9092, dirty=true. 
  Compilation unit: Test.java
  Last visited tree at line 7 column 9:
          B<? super A<Number>> x = new B<A<Number>>();
  Exception: java.lang.ClassCastException: class org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedWildcardType cannot be cast to class org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedDeclaredType (org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedWildcardType and org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedDeclaredType are in unnamed module of loader java.net.URLClassLoader @382db087); java.lang.ClassCastException: class org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedWildcardType cannot be cast to class org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedDeclaredType (org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedWildcardType and org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedDeclaredType are in unnamed module of loader java.net.URLClassLoader @382db087)
  	at org.checkerframework.framework.type.visitor.DoubleAnnotatedTypeScanner.visitDeclared(DoubleAnnotatedTypeScanner.java:112)
  	at org.checkerframework.framework.type.visitor.DoubleAnnotatedTypeScanner.visitDeclared(DoubleAnnotatedTypeScanner.java:28)
  	at org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedDeclaredType.accept(AnnotatedTypeMirror.java:1051)
  	at org.checkerframework.framework.type.visitor.AnnotatedTypeScanner.scan(AnnotatedTypeScanner.java:206)
  	at org.checkerframework.framework.type.visitor.DoubleAnnotatedTypeScanner.scan(DoubleAnnotatedTypeScanner.java:106)
  	at org.checkerframework.framework.type.visitor.DoubleAnnotatedTypeScanner.scan(DoubleAnnotatedTypeScanner.java:78)
  	at org.checkerframework.framework.type.visitor.DoubleAnnotatedTypeScanner.visitDeclared(DoubleAnnotatedTypeScanner.java:112)
  	at org.checkerframework.framework.type.visitor.DoubleAnnotatedTypeScanner.visitDeclared(DoubleAnnotatedTypeScanner.java:28)
  	at org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedDeclaredType.accept(AnnotatedTypeMirror.java:1051)
  	at org.checkerframework.framework.type.visitor.AnnotatedTypeScanner.scan(AnnotatedTypeScanner.java:206)
  	at org.checkerframework.framework.type.visitor.DoubleAnnotatedTypeScanner.scan(DoubleAnnotatedTypeScanner.java:106)
  	at org.checkerframework.framework.type.visitor.DoubleAnnotatedTypeScanner.scan(DoubleAnnotatedTypeScanner.java:28)
  	at org.checkerframework.framework.type.visitor.AnnotatedTypeScanner.visit(AnnotatedTypeScanner.java:194)
  	at org.checkerframework.framework.type.AnnotatedTypeFactory.replaceAnnotations(AnnotatedTypeFactory.java:4482)
  	at org.checkerframework.framework.type.AnnotatedTypeFactory.applyCaptureConversion(AnnotatedTypeFactory.java:5014)
  	at org.checkerframework.framework.type.AnnotatedTypeFactory.applyCaptureConversion(AnnotatedTypeFactory.java:4921)
  	at org.checkerframework.common.basetype.BaseTypeValidator.visitParameterizedType(BaseTypeValidator.java:557)
  	at org.checkerframework.common.basetype.BaseTypeValidator.visitDeclared(BaseTypeValidator.java:343)
  	at org.checkerframework.common.basetype.BaseTypeValidator.visitDeclared(BaseTypeValidator.java:60)
  	at org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedDeclaredType.accept(AnnotatedTypeMirror.java:1051)
  	at org.checkerframework.framework.type.visitor.AnnotatedTypeScanner.scan(AnnotatedTypeScanner.java:206)
  	at org.checkerframework.framework.type.visitor.AnnotatedTypeScanner.visit(AnnotatedTypeScanner.java:194)
  	at org.checkerframework.common.basetype.BaseTypeValidator.isValid(BaseTypeValidator.java:116)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.validateType(BaseTypeVisitor.java:4840)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.commonAssignmentCheck(BaseTypeVisitor.java:3016)
  	at org.checkerframework.checker.initialization.InitializationVisitor.commonAssignmentCheck(InitializationVisitor.java:136)
  	at org.checkerframework.checker.nullness.NullnessVisitor.commonAssignmentCheck(NullnessVisitor.java:166)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitVariable(BaseTypeVisitor.java:1608)
  	at org.checkerframework.checker.initialization.InitializationVisitor.visitVariable(InitializationVisitor.java:158)
  	at org.checkerframework.checker.initialization.InitializationVisitor.visitVariable(InitializationVisitor.java:51)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:974)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
  	at org.checkerframework.framework.source.SourceVisitor.scan(SourceVisitor.java:92)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:408)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:189)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:105)
  	at jdk.compiler/com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:248)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1032)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
  	at org.checkerframework.framework.source.SourceVisitor.scan(SourceVisitor.java:92)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:408)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:189)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:90)
  	at jdk.compiler/com.sun.source.util.TreeScanner.visitMethod(TreeScanner.java:206)
  	at org.checkerframework.framework.source.SourceVisitor.visitMethod(SourceVisitor.java:110)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.processMethodTree(BaseTypeVisitor.java:1058)
  	at org.checkerframework.checker.initialization.InitializationVisitor.processMethodTree(InitializationVisitor.java:293)
  	at org.checkerframework.checker.nullness.NullnessVisitor.processMethodTree(NullnessVisitor.java:528)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitMethod(BaseTypeVisitor.java:954)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitMethod(BaseTypeVisitor.java:189)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:898)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
  	at org.checkerframework.framework.source.SourceVisitor.scan(SourceVisitor.java:92)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:408)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:189)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:90)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:105)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:113)
  	at jdk.compiler/com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:187)
  	at org.checkerframework.framework.source.SourceVisitor.visitClass(SourceVisitor.java:98)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.processClassTree(BaseTypeVisitor.java:603)
  	at org.checkerframework.checker.initialization.InitializationVisitor.processClassTree(InitializationVisitor.java:246)
  	at org.checkerframework.checker.nullness.NullnessVisitor.processClassTree(NullnessVisitor.java:592)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitClass(BaseTypeVisitor.java:558)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitClass(BaseTypeVisitor.java:189)
  	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:86)
  	at org.checkerframework.framework.source.SourceChecker.typeProcess(SourceChecker.java:1347)
  	at org.checkerframework.javacutil.AbstractTypeProcessor$AttributionTaskListener.finished(AbstractTypeProcessor.java:188)
  	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:1418)
  	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1375)
  	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)
2 errors
@smillst smillst self-assigned this Oct 23, 2024
@smillst smillst added the crash label Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants