-1

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

Kapil Arora
  • 151
  • 1
  • 12

1 Answers1

0

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.

Community
  • 1
  • 1
Jeff Scott Brown
  • 26,804
  • 2
  • 30
  • 47
  • But in 2.5.4 injected services and servlet context was working fine but here in 3.3.3/4 it's not working it gives NPE. So what should we do – Kapil Arora Apr 10 '18 at 05:18
  • I don't think that has anything to do with private methods. What to do depends on what is going wrong. If this is happening in a domain class then the explanation is likely that you are relying on dependency injection which is disabled for domain classes by default. – Jeff Scott Brown Apr 10 '18 at 14:50