Kapil Arora
Kapil Arora

Reputation: 161

Grails 2 and Grails 3 calling private method from other classes

I have observed one strange behaviour in grails 2.5.4 as well as grails 3.3.2/3/4 .

The issue I feel and face is they allow one class to call private method of another class and it's going on till the latest version of grails.

However only difference I found is that in grails 2.5.4, it was able to detect all the dependency injected into the called class while in grails 3.3.x dependency is not injected which is correct but overall private method should not be called outside the class as per java

Upvotes: -1

Views: 322

Answers (1)

Jeff Scott Brown
Jeff Scott Brown

Reputation: 27255

The issue I feel and face is they allow one class to call private method of another class and it's going on till the latest version of grails.

...but overall private method should not be called outside the class as per java

It is true that Java does not allow you call private methods from outside of the defining class, but that is not the case with Groovy. Groovy has always allowed that.

Upvotes: 0

Related Questions