Details
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.