Groovy extension methods in statically compiled code

410 Views Asked by At

There are many ways how to define extension methods for existing types in Groovy, e.g. meta-class, categories, extension modules etc. I'd like to know, which of them are compatible with static compilation via @CompileStatic. I know that it is possible to put a pre-built extension module jar into the classpath providing an extension method for e.g. String and then write a @CompileStatic Groovy class which uses the extension methods from the extension module. However, I'd like to have a solution where I can define extension methods in the same project so that I don't have to build the extension module in advance. Is this possible in Groovy?

1

There are 1 best solutions below

0
On BEST ANSWER

Answer from tim_yates in the comments: Most probably not possible, see here.