4 ms·
In Java static methods are a particularly simple way making clear to the compiler and runtime that a given functions does not have side effects (to instances of
by michaelg7x 9y ago
In Java static methods are a particularly simple way making clear to the compiler and runtime that a given functions does not have side effects (to instances of the owning class). I can imagine that, as a pattern, they would assist escape analysis.
- maxxxxx 9y agoIn C# you can have static classes. I often use these to group simple functions together.
- lederhosen 9y agoA static method can of course mutate an object of the same class (give the object as an argument (direct or indirect) or use a static variable of the class) I can not see how they could be used to help escape analysis more than that you have one less reference (this).
- michaelg7x 9y agoYes, of course that's possible. I was trying to point out their usefulness to the programmer as well as potentially to the runtime/JIT. Next time I'll list the obvious exceptions!