|
[
Permalink
| « Hide
]
Jochen Theodorou added a comment - 20/Jul/07 11:42 AM
ok, after looking into this I found the reason... at the point the ResolveVisitor finds the static import the class is not yet parsed. Which means finding the static method must be done at a later step than it is currently done.
I splitted ResolveVisitor inot the normal resolving process and a StaticImportVisitor that is doing only static imports. The new class works after ResolveVisitor was run and should then no longer have a problem with not yet parsed classes.
I'm using snapshot build 447 and this still isn't working for me:
[nvw384@ma34jasper sandbox]$ groovy -version nvw384@ma34jasper sandbox]$ echo $GROOVY_HOME [nvw384@ma34jasper sandbox]$ less test1/mytest.groovy import static test1.test2.Utils.* printMe(); [nvw384@ma34jasper sandbox]$ less test1/test2/Utils.groovy class Utils { I did a quick jad of code generated using groovyc. For this code:
import static java.lang.Math.* println cos(2*PI) beta-2 generates: ...
ScriptBytecodeAdapter.invokeStaticMethodN(class1, java.lang.Math.class, "cos", new Object[] {
ScriptBytecodeAdapter.invokeMethodN(class1, new Integer(2), "multiply", new Object[] {
ScriptBytecodeAdapter.getProperty(class1, java.lang.Math.class, "PI")
})
})
...
beta-3-SNAPSHOT generates: ...
ScriptBytecodeAdapter.invokeMethodOnCurrentN(class1, (GroovyObject)ScriptBytecodeAdapter.castToType(this, groovy.lang.GroovyObject.class), "cos", new Object[] {
ScriptBytecodeAdapter.invokeMethodN(class1, new Integer(2), "multiply", new Object[] {
ScriptBytecodeAdapter.getGroovyObjectProperty(class1, this, "PI")
})
})
...
The static import visitor seems to be doing the right thing but that isn't reflected in the generated code. Can you try again with HEAD.
If you can't reproduce it with beta-3, you can close it.
Thanks for the nudge. Sorry, I've been so busy. Using the same example code listed in my previous comment, I can see that this is fixed. And.....THANK YOU.
[nvw384@ma34jasper 1978]$ groovy -version [nvw384@ma34jasper 1978]$ groovy test1/mytest.groovy [nvw384@ma34jasper 1978]$ /opt/groovy-1.1-beta-3/bin/groovy test1/mytest.groovy |
|||||||||||||||||||||||||||||||||||||||||||||||