Closed akryzhn closed 4 years ago
I'm sorry you are having trouble. Could you please provide a reproducible example, as explained in the manual? That will enable us to reproduce the problem and verify a fix.
Which version of Java are you using? Can you please try to reproduce this problem using the Java 8 compiler, version 211 or later? Version 211 fixes some bugs, whereas previous versions create incorrect .class files for certain code that uses wildcards.
Possibly related: #2173.
I am closing this because there is not sufficient information to reproduce the problem. We can reopen it if someone is able to provide the needed information.
I'm facing same problem, just by adding a validation annotation on generic type causes checker framework to crash, tried both "'2.9.0" and "'2.10.0", java 8, example:
@Value @Builder @AllArgsConstructor public class request {
@JsonProperty("fooList") private List<@Positive Integer> fooList; }
error: handleInvalid(this=org.checkerframework.framework.util.element.MethodApplier):
Invalid variable and element passed to extractAndApply; type: List getFooList(request this)
element: getFooList() (kind: METHOD)
invalid annotations: @javax.validation.constraints.Positive
Targeted annotations: METHOD_RECEIVER, METHOD_RETURN, THROWS
Valid annotations: LOCAL_VARIABLE, RESOURCE_VARIABLE, EXCEPTION_PARAMETER, NEW, CAST, INSTANCEOF, METHOD_INVOCATION_TYPE_ARGUMENT, CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT, METHOD_REFERENCE, CONSTRUCTOR_REFERENCE, METHOD_REFERENCE_TYPE_ARGUMENT, CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT, METHOD_TYPE_PARAMETER, METHOD_TYPE_PARAMETER_BOUND, METHOD_FORMAL_PARAMETER
Compilation unit :..... /request.java
Last visited tree at line 20 column 1:
@Value
Exception: java.lang.Throwable; Stack trace: org.checkerframework.javacutil.BugInCF.
version 2.11.0 causes another crash
message: com.sun.tools.javac.code.Type.stripMetadata()Lcom/sun/tools/javac/code/Type; Exception: java.lang.NoSuchMethodError: com.sun.tools.javac.code.Type.stripMetadata()Lcom/sun/tools/javac/code/Type;; Stack trace: org.checkerframework.javacutil.TypeAnnotationUtils.unannotatedType(TypeAnnotationUtils.java:558) org.checkerframework.framework.type.BoundsInitializer.initializeTypeArgs(BoundsInitializer.java:99) org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedDeclaredType.getTypeArguments(AnnotatedTypeMirror.java:899) org.checkerframework.framework.util.element.TypeDeclarationApplier.extractAndApply(TypeDeclarationApplier.java:111)
I'm sorry you are having trouble. Could you please provide a reproducible test case? For example, you didn't say what checker you are running. The manual gives instructions for reporting a bug: https://checkerframework.org/manual/#reporting-bugs . Also, it is most helpful to test with the current version (3.0.0) rather than an old one. Thanks.
3.0.0 crashes with different stack trace, (javac 1.8.0_181)
error: SourceChecker.typeProcessingStart: unexpected Throwable (NoSuchMethodError); message: com.sun.tools.javac.code.Type.stripMetadata()Lcom/sun/tools/javac/code/Type;
Exception: java.lang.NoSuchMethodError: com.sun.tools.javac.code.Type.stripMetadata()Lcom/sun/tools/javac/code/Type;; Stack trace: org.checkerframework.javacutil.TypeAnnotationUtils.unannotatedType(TypeAnnotationUtils.java:558)
org.checkerframework.framework.type.BoundsInitializer.initializeTypeArgs(BoundsInitializer.java:99)
org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedDeclaredType.getTypeArguments(AnnotatedTypeMirror.java:897)
org.checkerframework.framework.util.element.TypeDeclarationApplier.extractAndApply(TypeDeclarationApplier.java:115)
org.checkerframework.framework.util.element.TypeDeclarationApplier.apply(TypeDeclarationApplier.java:23)
org.checkerframework.framework.type.ElementAnnotationApplier.applyInternal(ElementAnnotationApplier.java:134)
org.checkerframework.framework.type.ElementAnnotationApplier.apply(ElementAnnotationApplier.java:79)
org.checkerframework.framework.type.AnnotatedTypeFactory.fromElement(AnnotatedTypeFactory.java:1129)
org.checkerframework.framework.type.AnnotatedTypeFactory.fromElement(AnnotatedTypeFactory.java:2357)
org.checkerframework.common.basetype.BaseTypeVisitor.
The Checker Framework now has different setup when running on JDK 8. See https://checkerframework.org/manual/#java8-install for details.
The Checker Framework now has different setup when running on JDK 8. See https://checkerframework.org/manual/#java8-install for details.
here is how it is configured in gradle allprojects { tasks.getByName('compileJava') { JavaCompile compile -> compile.options.compilerArgs = [ '-processor', 'org.checkerframework.checker.nullness.NullnessChecker,lombok.launch.AnnotationProcessorHider$AnnotationProcessor', '-processorpath', "${configurations.checkerFramework.asPath}", "-Xbootclasspath/p:${configurations.checkerFrameworkAnnotatedJDK.asPath}" ] } }
Please use the Gradle plugin. https://checkerframework.org/manual/#gradle.
not sure how this will fix the crash. the crash happens only if I add annotation on the generic type i.e. List<@Positive Integer>
In order for us to fix the crash, we need a reproducible test case using the latest version of the Checker Framework. Your current setup will not work with the latest version of the Checker Framework. Since you are using Gradle, the easiest way to configure Gradle to run a checker is to use the Checker Framework Gradle plugin. If you wish to build using some other tool, please follow the instructions for that tool: https://checkerframework.org/manual/#external-tools.
OK. I applied the plugin, has checker version 3.0.0 and got the same error
Can you please provide a complete, reproducible bug report with all of the information requested at https://checkerframework.org/manual/#reporting-bugs, in one place? We need that in order to reproduce your report and fix the problem. Thanks for helping us help you.
Checkerframework doesn't seem to like embedded validation annotations as you see for the Map Strings in the example below.
I get the following error from checkergramework:
Checkerframework version:
ext.checkerFrameworkVersion = '2.8.0'