I have problems getting my code to compile with maven.
I'm using these dependencies:
<dependencies>
<dependency>
<groupId>org.immutables</groupId>
<artifactId>value</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.immutables</groupId>
<artifactId>value</artifactId>
<version>2.9.0</version>
</path>
</annotationProcessorPaths>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
</plugins>
</build>
One class looks like this:
@Value.Immutable
public interface Foo {
Optional<List<@NotNull @Valid Bar>> getBar();
}
And the other like this:
@Value.Immutable
public interface Bar {
}
And when I try to build the maven project with mvn clean install I get this error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project Testing: Compilation failure
[ERROR] org.immutables.value.internal.$processor$.$Processor threw org.immutables.value.internal.$guava$.base.$VerifyException: [E] =/> [@javax.validation.constraints.NotNull, @javax.validation.Validcom.exam
ple.Bar]
[ERROR] at org.immutables.value.internal.$guava$.base.$Verify.verify($Verify.java:125)
[ERROR] at org.immutables.value.internal.$generator$.$TypeHierarchyCollector$TypevarContext.<init>($TypeHierarchyCollector.java:59)
[ERROR] at org.immutables.value.internal.$generator$.$TypeHierarchyCollector.collectHierarchyMirrors($TypeHierarchyCollector.java:106)
[ERROR] at org.immutables.value.internal.$generator$.$TypeHierarchyCollector.collectFrom($TypeHierarchyCollector.java:69)
[ERROR] at org.immutables.value.internal.$processor$.meta.$TypeIntrospectionBase.collectTypeHierarchy($TypeIntrospectionBase.java:155)
[ERROR] at org.immutables.value.internal.$processor$.meta.$TypeIntrospectionBase.introspectTypeMirror($TypeIntrospectionBase.java:147)
[ERROR] at org.immutables.value.internal.$processor$.meta.$ValueAttribute.introspectType($ValueAttribute.java:881)
[ERROR] at org.immutables.value.internal.$processor$.meta.$TypeIntrospectionBase.ensureTypeIntrospected($TypeIntrospectionBase.java:81)
[ERROR] at org.immutables.value.internal.$processor$.meta.$ValueAttribute.initTypeKind($ValueAttribute.java:1441)
[ERROR] at org.immutables.value.internal.$processor$.meta.$ValueAttribute.initAndValidate($ValueAttribute.java:1210)
[ERROR] at org.immutables.value.internal.$processor$.meta.$AccessorAttributesCollector.collect($AccessorAttributesCollector.java:95)
[ERROR] at org.immutables.value.internal.$processor$.meta.$ValueTypeComposer.compose($ValueTypeComposer.java:67)
[ERROR] at org.immutables.value.internal.$processor$.meta.$Round.composeValue($Round.java:181)
[ERROR] at org.immutables.value.internal.$processor$.meta.$Round.collectValues($Round.java:95)
[ERROR] at org.immutables.value.internal.$processor$.$Processor.process($Processor.java:79)
[ERROR] at org.immutables.value.internal.$generator$.$AbstractGenerator.process($AbstractGenerator.java:93)
[ERROR] at org.immutables.processor.ProxyProcessor.process(ProxyProcessor.java:72)
[ERROR] at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:1023)
[ERROR] at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:939)
[ERROR] at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1267)
[ERROR] at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1382)
[ERROR] at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1234)
[ERROR] at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:916)
[ERROR] at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104)
[ERROR] at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.invocationHelper(JavacTaskImpl.java:152)
[ERROR] at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100)
[ERROR] at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94)
[ERROR] at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:126)
[ERROR] at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:174)
[ERROR] at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:1134)
[ERROR] at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:187)
[ERROR] at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
[ERROR] at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
[ERROR] at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
[ERROR] at org.apache.maven.cli.MavenCli.execute(MavenCli.java:972)
[ERROR] at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:293)
[ERROR] at org.apache.maven.cli.MavenCli.main(MavenCli.java:196)
[ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
[ERROR] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.base/java.lang.reflect.Method.invoke(Method.java:568)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
[ERROR]
[ERROR]
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
This error seem to only appear when I annotate the Optional<List> with both @NotNull and @Valid at the same time. This doesn't happen when I only use one annotation. Also this error is not present when the List isn't Optional.
This code compiles and builds as intended on Java 8. This error appeared when I started upgrading my project from java 8 to java 17 (also tested with java11, and I get the same error).
Any ideas on how I can fix this problem?
Have made a table to show what I tested and when it fails.