[ 
https://issues.apache.org/jira/browse/GROOVY-12434?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18125180#comment-18125180
 ] 

ASF GitHub Bot commented on GROOVY-12434:
-----------------------------------------

codecov-commenter commented on PR #2961:
URL: https://github.com/apache/groovy/pull/2961#issuecomment-6066000661

   ## 
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/2961?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 Report
   :x: Patch coverage is `73.52941%` with `9 lines` in your changes missing 
coverage. Please review.
   :white_check_mark: Project coverage is 71.6053%. Comparing base 
([`137afab`](https://app.codecov.io/gh/apache/groovy/commit/137afabf821980a1737a82f767fdc4a51a4bb3ce?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
 to head 
([`6218d67`](https://app.codecov.io/gh/apache/groovy/commit/6218d6793f717a6f1ec695614cdebeb8e72b6811?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/2961?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Patch % | Lines |
   |---|---|---|
   | 
[...in/java/org/codehaus/groovy/vmplugin/v8/Java8.java](https://app.codecov.io/gh/apache/groovy/pull/2961?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fvmplugin%2Fv8%2FJava8.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3ZtcGx1Z2luL3Y4L0phdmE4LmphdmE=)
 | 70.0000% | [2 Missing and 4 partials :warning: 
](https://app.codecov.io/gh/apache/groovy/pull/2961?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 |
   | 
[...org/codehaus/groovy/classgen/ExtendedVerifier.java](https://app.codecov.io/gh/apache/groovy/pull/2961?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2FExtendedVerifier.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL0V4dGVuZGVkVmVyaWZpZXIuamF2YQ==)
 | 76.9231% | [0 Missing and 3 partials :warning: 
](https://app.codecov.io/gh/apache/groovy/pull/2961?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   [![Impacted file tree 
graph](https://app.codecov.io/gh/apache/groovy/pull/2961/graphs/tree.svg?width=650&height=150&src=pr&token=1r45138NfQ&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)](https://app.codecov.io/gh/apache/groovy/pull/2961?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                  Coverage Diff                   @@
   ##             GROOVY_6_0_X      #2961        +/-   ##
   ======================================================
   - Coverage         71.6061%   71.6053%   -0.0008%     
   - Complexity          38057      38061         +4     
   ======================================================
     Files                1588       1588                
     Lines              137075     137096        +21     
     Branches            25502      25507         +5     
   ======================================================
   + Hits                98154      98168        +14     
   + Misses              30019      30018         -1     
   - Partials             8902       8910         +8     
   ```
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/2961?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Coverage Δ | |
   |---|---|---|
   | 
[.../java/org/codehaus/groovy/vmplugin/v16/Java16.java](https://app.codecov.io/gh/apache/groovy/pull/2961?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fvmplugin%2Fv16%2FJava16.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3ZtcGx1Z2luL3YxNi9KYXZhMTYuamF2YQ==)
 | `52.0000% <100.0000%> (ø)` | |
   | 
[...org/codehaus/groovy/classgen/ExtendedVerifier.java](https://app.codecov.io/gh/apache/groovy/pull/2961?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2FExtendedVerifier.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL0V4dGVuZGVkVmVyaWZpZXIuamF2YQ==)
 | `93.7500% <76.9231%> (-0.8654%)` | :arrow_down: |
   | 
[...in/java/org/codehaus/groovy/vmplugin/v8/Java8.java](https://app.codecov.io/gh/apache/groovy/pull/2961?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fvmplugin%2Fv8%2FJava8.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3ZtcGx1Z2luL3Y4L0phdmE4LmphdmE=)
 | `77.6280% <70.0000%> (+0.0037%)` | :arrow_up: |
   
   ... and [11 files with indirect coverage 
changes](https://app.codecov.io/gh/apache/groovy/pull/2961/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   </details>
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test 
Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, 
report on failures, and find test suite problems.
   - :package: [JS Bundle 
Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save 
yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>




> Implementing a precompiled trait fails with "Duplicate annotation" when a 
> trait method has a TYPE_USE annotation on its return type
> -----------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12434
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12434
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 6.0.0
>            Reporter: Mattias Reichel
>            Assignee: Paul King
>            Priority: Major
>
> When a trait method's return type carries a {{TYPE_USE}} annotation, such as 
> JSpecify's {{@Nullable}}, the trait is written with that annotation twice. A 
> class in a later compilation that implements the trait then fails to compile 
> on Groovy 6.0.0 with {{java.lang.annotation.AnnotationFormatError: Duplicate 
> annotation}}.
> This compiles on Groovy 5.1.3 and fails on 6.0.0. It does not happen when the 
> trait and the implementing class are in the same compilation, or when the 
> annotation is on a parameter instead of the return type. It fails whether the 
> trait was compiled by 5.1.3 or by 6.0.0, so traits in existing jars built 
> with Groovy 5 are affected too.
> h3. Steps to reproduce
> {code:title=trait/MaybeNull.java}
> import java.lang.annotation.ElementType;
> import java.lang.annotation.Retention;
> import java.lang.annotation.RetentionPolicy;
> import java.lang.annotation.Target;
> @Retention(RetentionPolicy.RUNTIME)
> @Target(ElementType.TYPE_USE)
> public @interface MaybeNull { }
> {code}
> {code:title=trait/Named.groovy}
> trait Named {
>     @MaybeNull String getName() { null }
> }
> {code}
> {code:title=src/Person.groovy}
> class Person implements Named { }
> {code}
> {noformat}
> mkdir lib out
> javac -d lib trait/MaybeNull.java
> java -cp groovy-6.0.0.jar:lib org.codehaus.groovy.tools.FileSystemCompiler 
> -cp lib -d lib trait/Named.groovy
> java -cp groovy-6.0.0.jar org.codehaus.groovy.tools.FileSystemCompiler -cp 
> lib -d out src/Person.groovy
> {noformat}
> h3. Expected
> Compilation succeeds, as on Groovy 5.1.3.
> h3. Actual
> {noformat}
> >>> a serious error occurred: Duplicate annotation for class: interface 
> >>> MaybeNull: @MaybeNull()
> >>> stacktrace:
> java.lang.annotation.AnnotationFormatError: Duplicate annotation for class: 
> interface MaybeNull: @MaybeNull()
>       at 
> java.base/sun.reflect.annotation.TypeAnnotationParser.mapTypeAnnotations(TypeAnnotationParser.java:382)
>       at 
> java.base/sun.reflect.annotation.AnnotatedTypeFactory$AnnotatedTypeBaseImpl.<init>(AnnotatedTypeFactory.java:138)
>       ...
>       at 
> org.codehaus.groovy.vmplugin.v8.Java8.configureClassNode(Java8.java:392)
>       at org.codehaus.groovy.ast.ClassNode.lazyClassInit(ClassNode.java:192)
>       at org.codehaus.groovy.ast.ClassNode.getMethods(ClassNode.java:1090)
>       at org.codehaus.groovy.ast.ClassNode.getMethods(ClassNode.java:1089)
>       at 
> org.codehaus.groovy.transform.trait.TraitComposer.applyTrait(TraitComposer.java:134)
>       at 
> org.codehaus.groovy.transform.trait.TraitComposer.doExtendTraits(TraitComposer.java:110)
>       ...
> {noformat}
> h3. Notes
> {{javap -v}} shows the return type annotation twice on the trait's interface 
> method and on its helper method. The class files are the same whether the 
> trait is compiled by 5.1.3 or by 6.0.0:
> {noformat}
>   public abstract java.lang.String getName();
>     descriptor: ()Ljava/lang/String;
>     flags: (0x0401) ACC_PUBLIC, ACC_ABSTRACT
>     RuntimeVisibleAnnotations:
>       0: #9()
>         org.codehaus.groovy.transform.trait.Traits$Implemented
>     RuntimeVisibleTypeAnnotations:
>       0: #10(): METHOD_RETURN
>         MaybeNull
>       1: #10(): METHOD_RETURN
>         MaybeNull
> {noformat}
> {{Named$Trait$Helper.getName(Named)}} has the same two {{METHOD_RETURN}} 
> entries. The same method on a plain class or interface is written with a 
> single entry.
> Groovy 5.1.3 accepts the duplicate because it does not read the annotated 
> return type when it initializes the trait's {{ClassNode}}. Groovy 6.0.0 reads 
> it through reflection in {{Java8.configureClassNode}}, where the JDK rejects 
> the duplicate. Groovy 5.1.3 can still implement a trait compiled by 6.0.0.
> GROOVY-12413 fixed similar duplicated {{TYPE_USE}} annotations on record 
> components and tuple-constructor parameters. The trait transform seems to 
> copy the return type annotations as well as the method annotations.
> Found while moving Apache Grails to Groovy 6: a JSpecify {{@Nullable}} on a 
> return type in the Grails unit testing traits ({{ControllerUnitTest}}, 
> {{UrlMappingsUnitTest}}, {{InterceptorUnitTest}}) makes every test class that 
> implements them fail to compile. The workaround is to leave {{TYPE_USE}} 
> annotations off trait method return types.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to