Hi, private final sounds strange to me. In older versions of Java, you could use final as an indication to the hotspot for better performance (inlining for example), but this is no longer the case with recent vms. For example, I've seen the jvm inline method calls through instance methods of enums. That's at least 3 levels deep and none of them where final.
(private|protected)? static is a different thing. private static makes perfect sense for private methods or variables. protected or default is not used that often with static, but it's still valid. I'm ok with changing protected static methods to public where needed to get Scala working, but I wouldn't change them all. The general rule for static is that methods that don't use any of the object's state could be marked static. It might perform a little better, but with recent jvms, you never know. It's possible that the jvm transforms an instance method into a static method internally to get better performance. It might also safe some space on the stack. In general I think it's a good design practice to mark these methods static. Best regards, Emond On Monday 29 October 2012 13:20:17 Martin Grigorov wrote: > Hi, > > In some of the Wicket code we may see method signatures like: > - protected static > - private static > - private final > > I wonder what are your reasons to use them ? > - do they improve performance ? > - do they save some bytes ? (in PermGen maybe ?!) > - do you need the 'static' just for the unit tests ? > - something else > > My drivers to touch such signatures are: > - I don't see a reason to have 'final' in 'private final' method. And > my IDE also notifies me about this. > - Scala has problems seeing 'protected static' methods from Java. > > I want to check with you before modifying them.
