When you don\'t declare a type for a variable in groovy, it is my understanding that the java virtual machine has to use reflection in order to figure out what type the obje
It still makes heavy use of reflection.
One of the things you must have in mind, is that the methods calls are resolved at runtime.
Easiest way to see it
Integer.metaClass.xxx << {println "hi"}
Integer ten = 10
ten.xxx()
This compiles, even though a normal Integer 100 would not have method xxx.
The first line adds the method to the class, but the compiler would not know this at compile time (the method is added at runtime).
It does not matter that the type is known, groovy still uses reflection to perform the calls.
Another example.
def (Number i, Number l) = [100, 100L]
print i
print l
def print(Number n) {println "Number $n"}
def print(Integer n) {println "Integer $n"}
In java, it would print Number 100 twice, as the method is statically selected.
Groovy doesn't care and just selects the method based on the class of the arguments at runtime.