Details
-
Type:
Sub-task
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 1.1-beta-2
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Environment:Windows XP, Java 1.5, also Ubuntu 7.04 "Feisty Fawn" (JDK 1.6.0) + Groovy Subversion r6911
-
Number of attachments :
Description
Groovysh lets you set & read private member fields, as long as they're static:
groovy> class C
{ private static x }groovy> C.x = new Integer(10)
groovy> println C.x
groovy> go
10
Note that it doesn't let you access regular private fields:
groovy> class B
{ private x }groovy> b = new B()
groovy> b.x = new Integer(10)
groovy> go
Caught: groovy.lang.IllegalPropertyAccessException: Can not access the
private field x in class B
Issue Links
- is related to
-
GROOVY-1591
Private Fields Are Accessible From Other Classes
-
-
GROOVY-1875
private fields and private methods are not private
-
With jsr-03, IllegalPropertyAccessException has been thrown.
But with the current jsr-04-SNAPSHOT (CVS HEAD), it looks to work fine.
Lets get Groovy!
================
Version: 1.0-jsr-04-SNAPSHOT JVM: 1.4.2_07-b05
Type 'exit' to terminate the shell
Type 'help' for command help
Type 'go' to execute the statements
groovy> class B
{ private x }groovy> b = new B()
groovy> b.x = new Integer(10)
groovy> println b.x
groovy> go
10