[ https://issues.apache.org/jira/browse/GROOVY-10937?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17692954#comment-17692954 ]
Eric Milles edited comment on GROOVY-10937 at 2/24/23 6:44 PM: --------------------------------------------------------------- https://github.com/apache/groovy/commit/e5ca7e630e4bffd368d27eabb30c6158fad4d23c https://github.com/apache/groovy/commit/99af5dfacce807e7ba95fa2dff5e505cd489f610 was (Author: emilles): https://github.com/apache/groovy/commit/e5ca7e630e4bffd368d27eabb30c6158fad4d23c > record + lombok + groovy == Cannot specify duplicate annotation on the same > member : lombok.NonNull > --------------------------------------------------------------------------------------------------- > > Key: GROOVY-10937 > URL: https://issues.apache.org/jira/browse/GROOVY-10937 > Project: Groovy > Issue Type: Bug > Components: Compiler > Affects Versions: 4.0.9 > Reporter: Marcin Zajaczkowski > Assignee: Eric Milles > Priority: Minor > Fix For: 4.0.10 > > > I've bumped into a strange looking compilation error in a project using JDK > 17 record, Lombok's @NotNull and Groovy for tests. It took me a while to find > a construction which causes that, as: > # Compilation error occurs in a Groovy class not related to the problematic > Java record. > # Groovy class must have (non related) inner interface or class. > # Record has must have two (or more) fields with @NotNull annotation from > Lombok. > # Some (other) Groovy class has to refer to that record. > For example: > {code:java} > // Java > public record SampleRecordWithNonNullFromLombok( > @NonNull > String nonNullField, > @NonNull //Two or more @NulNull annotated fields are required > to trigger the problem > String nonNullField2 > ) {} > //Groovy > class ClassWithReferenceToRecord { > private SampleRecordWithNonNullFromLombok sampleRecord > } > class ReproducerClass { //it fails to compile > interface RequiredToReproduceProblem { > } > }{code} > The error is: > {code:java} > [ERROR] Failed to execute goal > org.codehaus.gmavenplus:gmavenplus-plugin:1.13.1:compileTests (default) on > project record-lombok-groovy: Error occurred while calling a method on a > Groovy class from classpath.: InvocationTargetException: startup failed: > [ERROR] .../ReproducerClass.groovy: -1: Cannot specify duplicate annotation > on the same member : lombok.NonNull > [ERROR] @ line -1, column -1. > [ERROR] 1 error > {code} > I created a shrank version of a reproducer: > [https://github.com/szpak/code-examples-and-poc/tree/master/record-lombok-groovy] > > It might be a problem with the way how Lombok generates .class for Java > record, however, I start here as Groovy compilation is the final reason. > I have observed that error occasionally with Groovy 3(.0.14), but it occurs > every time with 4(0.9). -- This message was sent by Atlassian Jira (v8.20.10#820010)