Dibyendu Majumdar wrote:

2) Such constants would probably no-longer be in-lined by the java compiler, leading to potentially slower code as a field lookup is needed.

Not sure about this, as a final value should be in-lined regardless of how it is initialized. But this can be tested, I suppose.

I mean a final field in class A can only be in-lined in class B at compile (java source to byte-code) time if the compiler can determine its value. I think this is only currently true if the field is a literal (or set to another final field that is sourced from a literal). If the final value comes from file through a method call then the compile will not be able to in-line it.

At runtime the jit can probably in-line, but that's not what I meant.

Dan.

Reply via email to