MyClass.java
println MyClass.class.getPackage()
>my.package
MyClass.groovy
println MyClass.class.getPackage()
>null
The Java class gives the correct answer whether it is loaded by ClasspathClassLoader or by JarClassLoader. However, the Groovy class only works when called by ClasspathClassLoader, not by JarClassLoader.