“Glacier Class Immutable Checker在Checker Framework 3.6.0上不起作用。”

huangapple go评论93阅读模式
英文:

Glacier Class Immutable Checker does not works on Checker Framework 3.6.0

问题

我尝试使用Glacier类的不可变性检查器,在Checker Framework 3.6.0上无法工作。

我使用Maven获取Glacier 0.1。
(http://mcoblenz.github.io/Glacier/)

然后,我尝试检查示例源代码,但出现错误。
我能在Checker Framework 3.6.0上使用Glacier类的不可变性检查器吗?

> [jsr308.javac] javac 11.0.7
> [jsr308.javac] 错误:调用edu.cmu.cs.glacier.GlacierAnnotatedTypeFactory类构造函数时出现InvocationTargetException,参数为[edu.cmu.cs.glacier.GlacierChecker@625732];根本原因:java.lang.NoSuchMethodError: 'javax.lang.model.element.AnnotationMirror org.checkerframework.javacutil.AnnotationUtils.fromClass(javax.lang.model.util.Elements, java.lang.Class)'
> [jsr308.javac] ; Checker Framework崩溃。 请报告此崩溃。
> [jsr308.javac] 异常:java.lang.reflect.InvocationTargetException;java.lang.reflect.InvocationTargetException
> [jsr308.javac] at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(本地方法)
...(以下为堆栈跟踪,省略)

英文:

I try to use Glacier Class Immutable Checker does not works on Checker Framework 3.6.0.

I get Glacier 0.1 with Maven.
(http://mcoblenz.github.io/Glacier/)

Then, I tried to check the sample source, but an error occurs.
Can I use Glacier Class Immutable Checker with 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.<init>(BaseTypeVisitor.java:217)
> [jsr308.javac] at org.checkerframework.common.basetype.BaseTypeVisitor.<init>(BaseTypeVisitor.java:206)
> [jsr308.javac] at edu.cmu.cs.glacier.GlacierVisitor.<init>(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.<init>(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.<init>(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.<init>(BaseTypeVisitor.java:217)
> [jsr308.javac] at org.checkerframework.common.basetype.BaseTypeVisitor.<init>(BaseTypeVisitor.java:206)
> [jsr308.javac] at edu.cmu.cs.glacier.GlacierVisitor.<init>(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

答案1

得分: 2

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

Glacier 已不再维护。其问题追踪器包含了您提出的同一 问题 —— 使用更新版本的 Checker Framework 运行 Glacier —— 但维护者表示“我现在没有时间处理这个”。

如果您想自行更新 Glacier,您可以查看 拉取请求,该请求更新了 Glacier,使其适用于 Checker Framework 2.3.2。您需要从源代码构建 Glacier 以使用 Checker Framework 的该版本。该版本的 Checker Framework 可在 Maven Central 上获得。

英文:

The replication package that is downloadable from http://mcoblenz.github.io/Glacier/ contains its own copy of the Checker Framework (files checker.jar and framework.jar), and you should use that.

Glacier is no longer maintained. Its issue tracker contains the same issue you raised -- running Glacier with a newer version of the Checker Framework -- but the maintainer says "I don't have any time to work on this right now".

If you want to update Glacier yourself, you can see the 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.

答案2

得分: 1

我阅读了“《Checker Framework 手册 3.6.0 版(2020年8月3日)》”。

> 25.5 冰川:类不可变性 冰川[CNA+17] 在 Java 中强制执行类的传递性不可变性。根据它的网页:

> 25.9 不可变性检查器:IGJ、OIGJ 和 Javari Javari [TE05]、IGJ [ZPA+07] 和 OIGJ [ZPL+10] 是强制执行不可变性约束的类型系统。
> 所有三种类型系统的类型检查器都随 Checker Framework 发行到 1.9.13 版(日期为2016年4月1日)。如果您希望使用它们,请安装 Checker Framework 版本 1.9.13。

然后,我认为“冰川”是可用的,但“不可变性检查器”在“Checker Framework 3.6.0”上不可用。

谢谢 mernst。

我理解不仅“不可变性检查器”,而且“冰川”也不能在 Checker Framework 3.6.0 版中使用。

我尝试使用“net.jcip.annotations.Immutable”来使用 SpotBugs 检查示例源代码。
看起来它是有效的。

我将使用 SpotBugs。

感谢阅读我糟糕的英文。

英文:

I read "The Checker Framework Manual Version 3.6.0 (3 Aug 2020)".

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

and

> 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.

Then, I thought that "Glacier" is work and "Immutability checkers" is not work on "Checker Framework 3.6.0".

Thanks mernst.

I understood that not only "Immutability checkers" but also "Glacier" do not work with Checker Framework Version 3.6.0. actually.

I tried to check a sample source using SpotBugs with "net.jcip.annotations.Immutable".
I seems that it works.

I will use SpotBugs.

Thanks for reading my poor English.

huangapple
  • 本文由 发表于 2020年8月29日 02:55:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/63639465.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定