Groovy adds a lot of useful methods to standard Java classes. The source of this code can be found in org.codehaus.groovy.runtime.DefaultGroovyMethods
, org.codehaus.groovy.runtime.DefaultGroovyStaticMethods
and org.codehaus.groovy.vmplugin.v5.PluginDefaultGroovyMethods
. These are a nice read to see how the magic is happening.