17 Jun 2012 12:16
[groovy-dev] Type Checking Bug around static methods
Again this is using Groovy 2, rc-3. Minimal example program:
import groovy.transform.TypeChecked
import java.util.Arrays
<at> TypeChecked
class ArrayCopying {
public static void main(String[] args) {
def acopy = Arrays.copyOf(args, 1)
}
}
-----------------------------------------
I get the following error:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
ArrayCopying.groovy: 9: [Static type checking] - Cannot find matching
method java.lang.Class#copyOf([Ljava.lang.String;, int)
<at> line 9, column 21.
def acopy = Arrays.copyOf(args, 1)
^
1 error
Now if I remove the <at> TypeChecked annotation, it not only compiles, but
executes without error. It seems like the type checker hasn't figured
out that I'm trying to invoke the static method copyOf from the class
(Continue reading)
RSS Feed