JIT / Java , , . , , static final , final.
, (an int), ; , . , , - ; final int:
void foo() {
final Object o = new SomeObject();
}
, final , , o , , .. == o . , .
It’s not clear to me whether JIT needs to optimize or not optimize primitives finalin methods, because it could only optimize it if it is stored in one place, but it is clear that for reference types, the class member will be (slightly) lower invoice in terms of memory / CPU.
source
share