@NotNull 在 Antlr 4.6+ 中已被弃用。应使用什么替代?

huangapple 未分类评论43阅读模式
英文:

@NotNull Deprecated in Antlr 4.6+ What to use instead?

问题

我正在使用 Antlr 4.8 构建解析器,而 @NotNull 注解被标记为已弃用:

org.antlr.v4.runtime.misc
注解类型 NotNull
已弃用。
此仅用于与 4.5 版本向后兼容。它将在 4.6+ 版本中被移除。

我已经搜索过,但没有找到有关将替换此注解的任何文档。显然它在 4.6+ 版本中并未消失,但我希望在迁移到 Antlr 的新版本时避免问题。

是否有人知道是否有此注解的替代品?

英文:

I'm building a parser using Antlr 4.8, and the @NotNull annotation is marked as deprecated:

org.antlr.v4.runtime.misc
Annotation Type NotNull
Deprecated.
THIS IS HERE FOR BACKWARD COMPATIBILITY WITH 4.5 ONLY. It will disappear in 4.6+

I have searched but haven't found any documentation on what would replace this annotation. Obviously it hasn't disappeared in 4.6+, but I'd like to avoid issues as I move to new versions of Antlr.

Anyone know if there is a replacement for this annotation?

答案1

得分: 0

你可以通过以下方式使用 @NonNull:

import org.checkerframework.checker.nullness.qual.NonNull;

如果你正在使用 Maven,以下是导入依赖的代码:

<dependency>
    <groupId>org.checkerframework</groupId>
    <artifactId>checker-qual</artifactId>
    <version>2.10.0</version>
</dependency>
英文:

You can use @NonNull via

import org.checkerframework.checker.nullness.qual.NonNull;

Here's the import if you're using Maven:

&lt;dependency&gt;
    &lt;groupId&gt;org.checkerframework&lt;/groupId&gt;
    &lt;artifactId&gt;checker-qual&lt;/artifactId&gt;
    &lt;version&gt;2.10.0&lt;/version&gt;
&lt;/dependency&gt;

答案2

得分: 0

因为你说你的项目正在使用 Antler 4.8,所以你会想要将你所使用的 antlr4-maven-plugin 版本设置为 4.8。

将它设置为 4.6 也消除了错误,但我认为将 antlr 插件和运行时版本保持一致是有道理的。

英文:

Since you say you are using Antler 4.8 for your project, you'll want to set the version of the antlr4-maven-plugin that you are using to version 4.8.

Setting it to 4.6 also got rid of the error, but really I think it makes sense to keep the antlr plugin and runtime at the same version.

huangapple
  • 本文由 发表于 2020年4月4日 02:14:36
  • 转载请务必保留本文链接:https://java.coder-hub.com/61018019.html
匿名

发表评论

匿名网友

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

确定