1

我不能再用检查器框架构建我的代码了。当我注释掉检查器框架注释处理器时,我的代码编译得很好,所以问题不在于我的代码。使用该框架,我收到以下错误消息:

[ERROR] InvocationTargetException when invoking constructor for class 
org.checkerframework.checker.nullness.KeyForAnnotatedTypeFactory; Underlying cause: 
java.lang.NoSuchFieldError: RELEASE
  Exception: java.lang.reflect.InvocationTargetException; Stack trace: sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) 
  sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  java.lang.reflect.Constructor.newInstance(Constructor.java:423)
  org.checkerframework.common.basetype.BaseTypeChecker.invokeConstructorFor(BaseTypeChecker.java:275)
  org.checkerframework.common.basetype.BaseTypeVisitor.createTypeFactory(BaseTypeVisitor.java:261)
  ...

(完整的堆栈跟踪位于底部。)

此堆栈跟踪没有引用我的代码中的任何内容。这似乎是空值检查器中的一个错误。

我正在使用当前版本的 maven (3.6.3) 和 maven 编译器插件 (3.8.1)。我正在使用 JDK 1.8。

要查看 pom.xml 文件和代码,请查看位于https://github.com/SwingGuy1024/CheckerNoSuchFieldErrorBug的存储库 这是 pom 文件的链接:https ://github.com/SwingGuy1024/CheckerNoSuchFieldErrorBug/blob/master /pom.xml

要使用 Maven 重现错误,请下载存储库并键入mvn clean install

这是完整的堆栈跟踪:

[ERROR] InvocationTargetException when invoking constructor for class org.checkerframework.checker.nullness.KeyForAnnotatedTypeFactory; Underlying cause: java.lang.NoSuchFieldError: RELEASE
  Exception: java.lang.reflect.InvocationTargetException; Stack trace: sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
  sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  java.lang.reflect.Constructor.newInstance(Constructor.java:423)
  org.checkerframework.common.basetype.BaseTypeChecker.invokeConstructorFor(BaseTypeChecker.java:275)
  org.checkerframework.common.basetype.BaseTypeVisitor.createTypeFactory(BaseTypeVisitor.java:261)
  org.checkerframework.common.basetype.BaseTypeVisitor.<init>(BaseTypeVisitor.java:220)
  org.checkerframework.common.basetype.BaseTypeVisitor.<init>(BaseTypeVisitor.java:209)
  org.checkerframework.common.basetype.BaseTypeChecker.createSourceVisitor(BaseTypeChecker.java:224)
  org.checkerframework.common.basetype.BaseTypeChecker.createSourceVisitor(BaseTypeChecker.java:85)
  org.checkerframework.framework.source.SourceChecker.initChecker(SourceChecker.java:904)
  org.checkerframework.common.basetype.BaseTypeChecker.initChecker(BaseTypeChecker.java:100)
  org.checkerframework.common.basetype.BaseTypeChecker.initChecker(BaseTypeChecker.java:91)
  org.checkerframework.framework.source.SourceChecker.typeProcessingStart(SourceChecker.java:860)
  org.checkerframework.javacutil.AbstractTypeProcessor$AttributionTaskListener.finished(AbstractTypeProcessor.java:157)
  com.sun.tools.javac.api.ClientCodeWrapper$WrappedTaskListener.finished(ClientCodeWrapper.java:681)
  com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:111)
  com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1342)
  com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1296)
  com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:901)
  com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:860)
  com.sun.tools.javac.main.Main.compile(Main.java:523)
  com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
  com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
  org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:126)
  org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:174)
  org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:1134)
  org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:187)
  org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
  org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
  org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
  org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
  org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
  org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
  org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
  org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
  org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
  org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
  org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
  org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
  org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
  org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
  sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  java.lang.reflect.Method.invoke(Method.java:498)
  org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
  org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
  org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
  org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
  org.codehaus.classworlds.Launcher.main(Launcher.java:47)
  Underlying Exception: java.lang.NoSuchFieldError: RELEASE; Stack trace: org.checkerframework.javacutil.PluginUtil.getReleaseValue(PluginUtil.java:617)
  org.checkerframework.framework.stub.StubTypes.<init>(StubTypes.java:81)
  org.checkerframework.framework.type.AnnotatedTypeFactory.<init>(AnnotatedTypeFactory.java:397)
  org.checkerframework.framework.type.GenericAnnotatedTypeFactory.<init>(GenericAnnotatedTypeFactory.java:202)
  org.checkerframework.checker.nullness.KeyForAnnotatedTypeFactory.<init>(KeyForAnnotatedTypeFactory.java:65)
  sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
  sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  java.lang.reflect.Constructor.newInstance(Constructor.java:423)
  org.checkerframework.common.basetype.BaseTypeChecker.invokeConstructorFor(BaseTypeChecker.java:275)
  org.checkerframework.common.basetype.BaseTypeVisitor.createTypeFactory(BaseTypeVisitor.java:261)
  org.checkerframework.common.basetype.BaseTypeVisitor.<init>(BaseTypeVisitor.java:220)
  org.checkerframework.common.basetype.BaseTypeVisitor.<init>(BaseTypeVisitor.java:209)
  org.checkerframework.common.basetype.BaseTypeChecker.createSourceVisitor(BaseTypeChecker.java:224)
  org.checkerframework.common.basetype.BaseTypeChecker.createSourceVisitor(BaseTypeChecker.java:85)
  org.checkerframework.framework.source.SourceChecker.initChecker(SourceChecker.java:904)
  org.checkerframework.common.basetype.BaseTypeChecker.initChecker(BaseTypeChecker.java:100)
  org.checkerframework.common.basetype.BaseTypeChecker.initChecker(BaseTypeChecker.java:91)
  org.checkerframework.framework.source.SourceChecker.typeProcessingStart(SourceChecker.java:860)
  org.checkerframework.javacutil.AbstractTypeProcessor$AttributionTaskListener.finished(AbstractTypeProcessor.java:157)
  com.sun.tools.javac.api.ClientCodeWrapper$WrappedTaskListener.finished(ClientCodeWrapper.java:681)
  com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:111)
  com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1342)
  com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1296)
  com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:901)
  com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:860)
  com.sun.tools.javac.main.Main.compile(Main.java:523)
  com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
  com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
  org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:126)
  org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:174)
  org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:1134)
  org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:187)
  org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
  org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
  org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
  org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
  org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
  org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
  org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
  org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
  org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
  org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
  org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
  org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
  org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
  org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
  sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  java.lang.reflect.Method.invoke(Method.java:498)
  org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
  org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
  org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
  org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
  org.codehaus.classworlds.Launcher.main(Launcher.java:47)
4

1 回答 1

1

问题是pom.xml文件不正确,是由于未遵循Checker Framework Manual 中的说明造成的。

即使经过多次修复(请参阅原始帖子的评论),该pom.xml文件仍包含此无意义的行,它覆盖了文件中前面的正确行:

        <errorProneJavac>.m2/repository/com/google/errorprone/${checkerVersion}:javac:jar</errorProneJavac>

当该行存在时,构建会产生java.lang.NoSuchFieldError: RELEASE.

删除该行(即按照手册中的说明)使项目构建。

这是一个清除文件中一些错误部分的差异pom.xml

于 2020-01-24T01:42:33.803 回答