Java interop #2: 'Groovy bean properties' are exposed as (public?) fields
Second part
-
Java module has Groovy facet and contains a groovy class.
Groovy code (GroovyBean.groovy):
-
class GroovyBean {
String someString;
}
-
Java client calling above groovy class (JavaClient.java):
-
public class JavaClient {
public static void main(String[] args) {
GroovyBean b = new GroovyBean();
b.someString = "abc"; // should be "red" but is "green"
}
}
-
Look at the bytecode emitted by 'groovyc' for "GroovyBean.groovy":
-field "someString" has modifier "private"
However IDEA/Groovy PSI seem to treat is as public.
Now try this:
1) compile "GrooyBean.groovy" using standalone "groovyc" compiler
2) attach resulting class as module library
3) remove original source
Now suddenly (as it should) IDEA complains that "field 'someString' has private
access"
The point is that the PSI exposed from Groovy to Java should either:
a) not expose a PsiField for such 'Groovy properties'
b) or, if it is exposed, appropriately mark it as private
Again, description on this page seems complete and consistent with bytecode
emitted by groovyc:
http://groovy.codehaus.org/Groovy+Beans
-tt
请先登录再写评论。
Again a bug, the field should be private.
Note that both of the issues you list here differ from your original request that was marked "Won't fix"
Hello Taras,
I don't think so :)
Either way, I've managed to cleary explain the problems this time.
Shall I create two new JIRA issues for these problems?
Regards,
Taras