What does 'private' mean in Groovy?
11,477
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
Related videos on Youtube
Comments
-
ripper234 about 4 years
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
-
tim_yates over 13 years
-
ripper234 over 13 years@James - try it, it compiles without errors.
-
dnim over 10 yearsGroovy generates gettes/setters for private fields and if you try hit the private field like u.name Groovy invokes u.getName(){this.name} generated or declared method for it. So this behavior looks fine for me. Anyway Groovy has a lot of the issues with privacy ;)
-