Failed to find an injectable constructor for com.google.errorprone.bugpatterns.AlwaysThrows requested by AlwaysThrows

34 views
Skip to first unread message

Anthony Goubard

unread,
Oct 8, 2023, 6:54:40 AM10/8/23
to error-prone-discuss
Hi,

 I'm trying to use error prone but get this weird error. Any idea?
 Here is my build target (Apache Ant):
  <target name="error-prone" depends="init, clean">
    <echo message="Ant version ${ant.version} ${ant.home}" />
    <path id="processorpath.ref">
      <pathelement location="C:\Java\Utils\pmd\lib\error_prone_core-2.22.0-with-dependencies.jar"/>
      <pathelement location="C:\Java\Utils\pmd\lib\dataflow-errorprone-3.39.0.jar"/>
    </path>

    <javac srcdir="src" destdir="classes" fork="yes" includeantruntime="no">
      <compilerarg value="-XDcompilePolicy=simple"/>
      <compilerarg value="-processorpath"/>
      <compilerarg pathref="processorpath.ref"/>
      <compilerarg value="-Xplugin:ErrorProne -Xep:DeadException:ERROR" />
      <compilerarg value="-J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED" />
      <compilerarg value="-J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED" />
      <compilerarg value="-J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED" />
      <compilerarg value="-J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED" />
      <compilerarg value="-J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED" />
      <compilerarg value="-J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED" />
      <compilerarg value="-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED" />
      <compilerarg value="-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED" />
      <compilerarg value="-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED" />
      <compilerarg value="-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED" />
      <classpath>
        <fileset dir="${template.dir}" includes="${template.lib} lib/JapplisAppFramework.jar" />
        <fileset dir="." includes="${compile.lib}" if:set="compile.lib.yes" />
      </classpath>
    </javac>
  </target>


And here is the stack trace
error-prone:
Ant version Apache Ant(TM) version 1.10.14 compiled on August 16 2023 C:\Java\ant
Compiling 22 source files to C:\Java\projects\Toolbox\classes
Note: C:\Java\projects\Toolbox\src\com\japplis\toolbox\panels\CharacteristicsPanel.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
An exception has occurred in the compiler (17.0.7). Please file a bug against the Java compiler via the Java bug reporting page (https://bugreport.java.com) after checking the Bug Database (https://bugs.java.com) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you.
java.lang.AssertionError: com.google.errorprone.scanner.ErrorProneInjector$ProvisionException: Failed to find an injectable constructor for com.google.errorprone.bugpatterns.AlwaysThrows requested by AlwaysThrows
at com.google.errorprone.ErrorProneAnalyzer.lambda$scansPlugins$0(ErrorProneAnalyzer.java:85)
at com.google.common.base.Suppliers$NonSerializableMemoizingSupplier.get(Suppliers.java:181)
at com.google.errorprone.ErrorProneAnalyzer.finished(ErrorProneAnalyzer.java:156)
at jdk.compiler/com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:132)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1394)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1341)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:933)
at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:317)
at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:176)
at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:64)
at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:50)
Caused by: com.google.errorprone.scanner.ErrorProneInjector$ProvisionException: Failed to find an injectable constructor for com.google.errorprone.bugpatterns.AlwaysThrows requested by AlwaysThrows
at com.google.errorprone.scanner.ErrorProneInjector.lambda$getInstance$0(ErrorProneInjector.java:82)
at java.base/java.util.Optional.orElseThrow(Optional.java:403)
at com.google.errorprone.scanner.ErrorProneInjector.getInstance(ErrorProneInjector.java:76)
at com.google.errorprone.scanner.ErrorProneInjector.getInstance(ErrorProneInjector.java:65)
at com.google.errorprone.scanner.ScannerSupplierImpl.instantiateChecker(ScannerSupplierImpl.java:66)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at com.google.errorprone.scanner.ScannerSupplierImpl.get(ScannerSupplierImpl.java:74)
at com.google.errorprone.scanner.ScannerSupplierImpl.get(ScannerSupplierImpl.java:37)
at com.google.errorprone.ErrorProneAnalyzer.lambda$scansPlugins$0(ErrorProneAnalyzer.java:80)
... 10 more
printing javac parameters to: C:\Java\projects\Toolbox\javac.20231008_124417.args
c:\java\projects\_template\build\build.xml:382: Compile failed; see the compiler error output for details.


Best regards,
Anthony

Liam Miller-Cushon

unread,
Oct 8, 2023, 1:38:36 PM10/8/23
to error-pro...@googlegroups.com
Hello, I think you encountered the same issue discussed here: https://github.com/google/error-prone/issues/3897

Adding this jar to the classpaths should fix the error: https://repo1.maven.org/maven2/javax/inject/javax.inject/1/javax.inject-1.jar

I'll look at getting that jar included in the next release of the '-with-dependencies.jar' jar, so it will work without adding the additional dependency.

--
Googlers: This an external list. Please be careful when posting.
---
You received this message because you are subscribed to the Google Groups "error-prone-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to error-prone-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/error-prone-discuss/ca2beeda-c336-4a83-af30-f2c3fe08c1f3n%40googlegroups.com.

Anthony Goubard

unread,
Oct 9, 2023, 4:50:27 AM10/9/23
to error-prone-discuss
Hello,

 Thank you. Indeed adding javax.inject-1.jar fixed the problem.
 Depending on how often you create new releases, you might consider updating the documentation: https://errorprone.info/docs/installation

Best regards,
Anthony

Reply all
Reply to author
Forward
0 new messages