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

Script @groovy.transform.Field AST transformation generics handling with fully qualified types

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.4.21, 2.5.15, 3.0.9
    • 2.5.16, 3.0.10, 4.0.0
    • None
    • None

    Description

      Groovy 2.4.21 / 2.5.14 / 3.0.9

      Script.groovy
      @groovy.transform.Field
      java.util.List list
      

      produces the following error:

      startup failed:
      xxx\Script.groovy: 1: A transform used a generics containing ClassNode java.util.List <E extends java.lang.Object> for the field list directly. You are not supposed to do this. Please create a new ClassNode referring to the old ClassNode and use the new ClassNode instead of the old one. Otherwise the compiler will create wrong descriptors and a potential NullPointerException in TypeResolver in the OpenJDK. If this is not your own doing, please report this bug to the writer of the transform.
       @ line 1, column 1.
         @groovy.transform.Field
         ^
      
      xxx\Script.groovy: -1: A transform used a generics containing ClassNode java.util.List <E extends java.lang.Object> for the method public void setList(java.util.List list)  { ... } directly. You are not supposed to do this. Please create a new ClassNode referring to the old ClassNode and use the new ClassNode instead of the old one. Otherwise the compiler will create wrong descriptors and a potential NullPointerException in TypeResolver in the OpenJDK. If this is not your own doing, please report this bug to the writer of the transform.
       @ line -1, column -1.
      2 errors
      
      

      This does not happen when the code relies on implicit imports:

      Script.groovy
      @groovy.transform.Field
      List list
      

      This also seems fine with Groovy 4.0.0

      Attachments

        Activity

          People

            emilles Eric Milles
            chuong_f Frédéric Chuong
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 0.5h
                0.5h