Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-10553

Regression: Annotation on trait field is illegally duplicated

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 4.0.1
    • 4.0.2
    • Compiler
    • None

    Description

      I have the following types:

      trait ShipmentRelated {
        @NotBlank
        String shipmentId
      }
      
      class ShipmentLocationRequest extends Base implements ShipmentRelated {}
      

      In Groovy 3, this compiles correctly:

        private java.lang.String com_example_logistics_ShipmentRelated__shipmentId;
          descriptor: Ljava/lang/String;
          flags: (0x0002) ACC_PRIVATE
          RuntimeVisibleAnnotations:
            0: #17()        javax.validation.constraints.NotBlank
      

      In Groovy 4 with identical source, I get duplicate annotations (annotation sections?):

        private java.lang.String com_example_logistics_ShipmentRelated__shipmentId;
          descriptor: Ljava/lang/String;
          flags: (0x0002) ACC_PRIVATE
          RuntimeVisibleAnnotations:
            0: #17()        javax.validation.constraints.NotBlank
          RuntimeVisibleTypeAnnotations:
            0: #17(): FIELD        javax.validation.constraints.NotBlank
      

      This causes an AnnotationFormatError at runtime.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            emilles Eric Milles
            chrylis Christopher Smith
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment