It seems logical to do some optimization around static final constants ( e.g. replace the variable with literals etc ) to improve the performance
Yes, javac
already does this (assuming your static final
fields are for a primitive type or String
): the constant value is "pasted in" directly at the point of use.
Of course, the downside to this is that if you change the field and forget to recompile the classes that use that field, then the value will be stale....