Details
-
Improvement
-
Status: Open
-
Major
-
Resolution: Unresolved
-
1.8.0
-
None
-
None
-
Linux x86, Java 1.7.0 b-134 (supposed to be environment independent)
GMaven 1.4
Description
AstBuilding of class names makes me headache (see below) :
new AstBuilder().buildFromString(CompilePhase.CANONICALIZATION, "some.fully.qualified.ClassName.staticMethodCall(someArgument)")
The correct compilation of the class name some.fully.qualified.ClassName depends on what is in the class loader:
- If the class some.fully.qualified.ClassName has already been compiled, it yields to a ClassExpression
- If the class has not been compiled yet, it yields to a succession of VariableExpression with more ore less the same semantics than this.some.fully.qualified.ClassName. It obviously results in execution error groovy.lang.MissingPropertyException: No such property: some for class: some.other.package.MyClass
I encounter the when writing ASTTransformation in a Gmaven 1.4-SNAPSHOT project. The result of the compilation is unstable, as it depends on the order Gmaven compiles the classes.
There are many workaround candidates:
- Configuring Gmaven to generate class stub for Java. It would make the class names recognized as class identifiers;
- Using buildFromBlock
- Building nodes at hands;
Possible definitive solution to the problem would be:
- Adding parameters to AstBuilder in order to tell what is a class name, and what is not;
- Adding a syntax to the Groovy language to denote class constants irrespective to the class loader context.
Which solution design has your preference?