My specific question is: do compilers inline the Static Final Interface code within other compiled methods? I've been out of the loop for a while on this type of optimization, and wanted to know if this is still performed.
Asked
Active
Viewed 385 times
8
-
2static and final are mutually exclusive anyway. You cannot override a static method, so it's always final. – daniu Aug 23 '17 at 12:33
-
1Are you asking if they're inlined? – John Kugelman Aug 23 '17 at 12:34
-
1Considering the tiny amount of optimization `javac` does, I wouldn't count on it. Why don't you fire up `javap` and see. – Kayaman Aug 23 '17 at 12:36
-
download a java decompiler and check yourself if final was added. – Dmytro Aug 23 '17 at 12:41
-
@JohnKugelman Correct. – Lukas Bradley Aug 23 '17 at 12:43
-
2Behaviour of final static method: https://stackoverflow.com/questions/1743715/behaviour-of-final-static-method @daniu While they can't be overridden, they can be hidden. `final` prevents this. I would think that this implies that final is NOT added by the compiler to a non-final class, but could possibly be added to a final class. – Novaterata Aug 23 '17 at 12:43
-
@Kayaman Will do so unless someone knows offhand. – Lukas Bradley Aug 23 '17 at 12:43
1 Answers
1
javac
will not inline
anything - it does very little optimization anyway. The JIT
might inline that indeed, depending on the fact if that method is hot enough and can be inlined and no threshold has been reached.

Eugene
- 117,005
- 15
- 201
- 306