Glacier Class 不可变检查器不适用于 Checker Framework 3.6.0

Glacier Class Immutable Checker does not works on Checker Framework 3.6.0

我尝试使用 Glacier Class 不可变检查器不适用于 Checker Framework 3.6.0。

我通过 Maven 获得了 Glacier 0.1。 (http://mcoblenz.github.io/Glacier/)

然后,我尝试查看示例源,但出现错误。 我可以将 Glacier Class 不可变检查器与 Checker Framework 3.6.0 一起使用吗?

[jsr308.javac] javac 11.0.7 [jsr308.javac] error: InvocationTargetException when invoking constructor for class edu.cmu.cs.glacier.GlacierAnnotatedTypeFactory on args [edu.cmu.cs.glacier.GlacierChecker@625732]; Underlying cause: java.lang.NoSuchMethodError: 'javax.lang.model.element.AnnotationMirror org.checkerframework.javacutil.AnnotationUtils.fromClass(javax.lang.model.util.Elements, java.lang.Class)' [jsr308.javac] ; The Checker Framework crashed. Please report the crash. [jsr308.javac] Exception: java.lang.reflect.InvocationTargetException; java.lang.reflect.InvocationTargetException [jsr308.javac] at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [jsr308.javac] at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) [jsr308.javac] at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [jsr308.javac] at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) [jsr308.javac] at org.checkerframework.common.basetype.BaseTypeChecker.invokeConstructorFor(BaseTypeChecker.java:300) [jsr308.javac] at org.checkerframework.common.basetype.BaseTypeVisitor.createTypeFactory(BaseTypeVisitor.java:249) [jsr308.javac] at org.checkerframework.common.basetype.BaseTypeVisitor.(BaseTypeVisitor.java:217) [jsr308.javac] at org.checkerframework.common.basetype.BaseTypeVisitor.(BaseTypeVisitor.java:206) [jsr308.javac] at edu.cmu.cs.glacier.GlacierVisitor.(GlacierVisitor.java:54) [jsr308.javac] at edu.cmu.cs.glacier.GlacierChecker.createSourceVisitor(GlacierChecker.java:8) [jsr308.javac] at edu.cmu.cs.glacier.GlacierChecker.createSourceVisitor(GlacierChecker.java:5) [jsr308.javac] at org.checkerframework.framework.source.SourceChecker.initChecker(SourceChecker.java:820) [jsr308.javac] at org.checkerframework.common.basetype.BaseTypeChecker.initChecker(BaseTypeChecker.java:111) [jsr308.javac] at org.checkerframework.framework.source.SourceChecker.typeProcessingStart(SourceChecker.java:771) [jsr308.javac] at org.checkerframework.javacutil.AbstractTypeProcessor$AttributionTaskListener.finished(AbstractTypeProcessor.java:167) [jsr308.javac] at jdk.compiler/com.sun.tools.javac.api.ClientCodeWrapper$WrappedTaskListener.finished(ClientCodeWrapper.java:828) [jsr308.javac] at jdk.compiler/com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:132) [jsr308.javac] at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1418) [jsr308.javac] at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1375) [jsr308.javac] at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:973) [jsr308.javac] at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:311) [jsr308.javac] at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:170) [jsr308.javac] at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57) [jsr308.javac] at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43) [jsr308.javac] Caused by: java.lang.NoSuchMethodError: 'javax.lang.model.element.AnnotationMirror org.checkerframework.javacutil.AnnotationUtils.fromClass(javax.lang.model.util.Elements, java.lang.Class)' [jsr308.javac] at edu.cmu.cs.glacier.GlacierAnnotatedTypeFactory.(GlacierAnnotatedTypeFactory.java:46) [jsr308.javac] ... 24 more [jsr308.javac]
[jsr308.javac] Underlying Exception: java.lang.NoSuchMethodError: 'javax.lang.model.element.AnnotationMirror org.checkerframework.javacutil.AnnotationUtils.fromClass(javax.lang.model.util.Elements, java.lang.Class)'; java.lang.NoSuchMethodError: 'javax.lang.model.element.AnnotationMirror org.checkerframework.javacutil.AnnotationUtils.fromClass(javax.lang.model.util.Elements, java.lang.Class)' [jsr308.javac] at edu.cmu.cs.glacier.GlacierAnnotatedTypeFactory.(GlacierAnnotatedTypeFactory.java:46) [jsr308.javac] at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [jsr308.javac] at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) [jsr308.javac] at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [jsr308.javac] at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) [jsr308.javac] at org.checkerframework.common.basetype.BaseTypeChecker.invokeConstructorFor(BaseTypeChecker.java:300) [jsr308.javac] at org.checkerframework.common.basetype.BaseTypeVisitor.createTypeFactory(BaseTypeVisitor.java:249) [jsr308.javac] at org.checkerframework.common.basetype.BaseTypeVisitor.(BaseTypeVisitor.java:217) [jsr308.javac] at org.checkerframework.common.basetype.BaseTypeVisitor.(BaseTypeVisitor.java:206) [jsr308.javac] at edu.cmu.cs.glacier.GlacierVisitor.(GlacierVisitor.java:54) [jsr308.javac] at edu.cmu.cs.glacier.GlacierChecker.createSourceVisitor(GlacierChecker.java:8) [jsr308.javac] at edu.cmu.cs.glacier.GlacierChecker.createSourceVisitor(GlacierChecker.java:5) [jsr308.javac] at org.checkerframework.framework.source.SourceChecker.initChecker(SourceChecker.java:820) [jsr308.javac] at org.checkerframework.common.basetype.BaseTypeChecker.initChecker(BaseTypeChecker.java:111) [jsr308.javac] at org.checkerframework.framework.source.SourceChecker.typeProcessingStart(SourceChecker.java:771) [jsr308.javac] at org.checkerframework.javacutil.AbstractTypeProcessor$AttributionTaskListener.finished(AbstractTypeProcessor.java:167) [jsr308.javac] at jdk.compiler/com.sun.tools.javac.api.ClientCodeWrapper$WrappedTaskListener.finished(ClientCodeWrapper.java:828) [jsr308.javac] at jdk.compiler/com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:132) [jsr308.javac] at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1418) [jsr308.javac] at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1375) [jsr308.javac] at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:973) [jsr308.javac] at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:311) [jsr308.javac] at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:170) [jsr308.javac] at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57) [jsr308.javac] at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43) [jsr308.javac] 1 error

可从 http://mcoblenz.github.io/Glacier/ 下载的复制包包含自己的 Checker Framework 副本(文件 checker.jarframework.jar),您应该使用它。

冰川不再维护。它的问题跟踪器包含与您提出的相同 issue -- 运行 Glacier 和更新版本的 Checker Framework -- 但维护者说“我现在没有时间处理这个” .

如果您想自己更新 Glacier,可以查看 pull request that updated Glacier to work with Checker Framework 2.3.2. You will need to build Glacier from source to use that version of the Checker Framework. That version of the Checker Framework is available in Maven Central

我阅读了“Checker 框架手册版本 3.6.0(2020 年 8 月 3 日)”。

25.5 Glacier: Class immutability Glacier [CNA+17] enforces transitive class immutability in Java. According to its webpage:

25.9 Immutability checkers: IGJ, OIGJ, and Javari Javari [TE05], IGJ [ZPA+07], and OIGJ [ZPL+10] are type systems that enforce immutability constraints. Type-checkers for all three type systems were distributed with the Checker Framework through release 1.9.13 (dated 1 April 2016). If you wish to use them, install Checker Framework version 1.9.13.

然后,我认为“Glacier”在“Checker Framework 3.6.0”上工作,“Immutability checkers”不工作。

谢谢默恩斯特。

我了解到不仅“不变性检查器”而且“Glacier”都不适用于 Checker Framework 版本 3.6.0。其实

我尝试使用带“net.jcip.annotations.Immutable”的 SpotBugs 检查示例源。 我好像有用。

我会使用 SpotBugs。

感谢阅读我糟糕的英语。