Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.7.3
-
None
-
None
Description
This issue tracks partial implementation of this functionality. See note at end of description.
Given this Java class (note the static inner class):
package pkg; public class Outer { public static class Inner {} }
The inner class can be printed from Java using this:
import pkg.Outer.Inner; //import static pkg.Outer.Inner; public class Main { public static void main(String[] args) { System.out.println(Inner.class.getName()); } }
Note that both the non-static or static version (shown commented out) will work.
For Groovy, the non-static version works:
import pkg.Outer.Inner println Inner.class.name
but the static version doesn't:
import static pkg.Outer.Inner println Inner.class.name
instead, it fails with:
Caught: groovy.lang.MissingPropertyException: No such property: Inner for class: TestStaticImport
NOTE: The initial implementation of functionality for this issue works for external jars/classes on the classpath and for classes included in the same file but doesn't work for the critical case of external groovy files. As that case also doesn't work for attempts to import using a non-static variation of import, I think it is worthy of its own issue and so GROOVY-4287 has been created to track remaining work.