The following code sets a private method. So how private really is private?
public class Person {
private String name
}
def u = new Person(name:"Ron")
println u.name
The following code sets a private method. So how private really is private?
public class Person {
private String name
}
def u = new Person(name:"Ron")
println u.name
By design Groovy should respect the private modifier, however the current implementation takes no account of it.
There are further details in groovy call private method in Java super class
I think we can access this because groovy adds getters and setters for all the variables. These methods are public, and hence private variables can be accessed outside the scope, that you would expect them be.
As in case of private methods, well you can get around anywhere with the concept of MetaClass.