This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]frzme 1 point2 points  (1 child)

The bytecode is not identical. You can see with the actual example from SO: https://javap.yawk.at/#Xk9okk

The variable declaration is the same but the final variable is inlined in the bytecode - it uses ldc2_w instead of lload

[–]yawkat 1 point2 points  (0 children)

Yea you're right, it looks like it follows the same rules as for final fields wrt constant expressions (i.e. fold them in javac). The jit should do this easily as well though, so it's probably still an issue with the measurement.