Does the JVM Eliminate Allocations of Temporary Objects?

Should you be concerned about temporary Java objects or can the JVM eliminate them for you, maybe by replacing them with implicit static instances?

Consider the following example: