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

@AutoImplement for method with type parameter(s)

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

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.5.15, 3.0.10, 4.0.1
    • 2.5.17, 3.0.11, 4.0.2
    • None
    • None
    • Ubuntu 20.04 / Groovy 4.0.1 / OpenJDK 8

    Description

      I have tried a few permutations of Groovy versions and Java versions, and I can't get this to work with anything I've tried that is above Groovy version 2.5.12:

      import groovy.transform.AutoImplement
      
      public class AutoImplementExample {
          public static void main(String ... args) {
              def c = new DummyConnection()
              c.commit()
          }
      }
      
      @AutoImplement
      class DummyConnection implements java.sql.Connection {}
      
      // Name this file AutoImplementExample.groovy and try to compile and run

       

      For example, with Groovy 4.0.1, JDK 8, and my GROOVY_HOME, PATH, and JAVA_HOME set up as instructed in the installation page for Groovy:

      ~/groovy-autoimplement$ groovy -version
      Groovy Version: 4.0.1 JVM: 1.8.0_312 Vendor: Private Build OS: Linux
      
      ~/groovy-autoimplement$ java -version
      openjdk version "1.8.0_312"
      OpenJDK Runtime Environment (build 1.8.0_312-8u312-b07-0ubuntu1~20.04-b07)
      OpenJDK 64-Bit Server VM (build 25.312-b07, mixed mode)
      
      ~/groovy-autoimplement$ groovyc ./AutoImplementExample.groovy
      
      ~/groovy-autoimplement$ groovy AutoImplementExample
      Caught: java.lang.NullPointerException
      java.lang.NullPointerException
          at com.sun.beans.TypeResolver.resolve(TypeResolver.java:203)
          at com.sun.beans.TypeResolver.resolve(TypeResolver.java:218)
          at com.sun.beans.TypeResolver.resolve(TypeResolver.java:169)
          at com.sun.beans.TypeResolver.resolve(TypeResolver.java:218)
          at com.sun.beans.TypeResolver.resolveInClass(TypeResolver.java:96)
          at AutoImplementExample.main(AutoImplementExample.groovy:5)
      
      ~/groovy-autoimplement$ 

       

      This stacktrace looks similar to the error I see with other Groovy versions and JDK 8.  The trace looks slightly longer with JDK 11, but everything from AutoImplementExample.groovy:5 and above looks the same, right down to the line numbers.

      I've also run this with java (after compiling with groovyc) to make sure there is nothing funny going on when running directly with groovy that could be sullying the results.  That's a bit messier to run in that I have to construct a long classpath for all the groovy jars, and for that effort I just get a longer stack trace with the same bits at the top.

      Attachments

        Activity

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

          People

            emilles Eric Milles
            g1l3sp Peter Giles
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment