Java Cup
Inside Java

News and views from members of the Java team at Oracle

Value Classes Still Need Compiler Sympathy

Declaring a value class is first and foremost a semantic decision. It tells our fellow programmers that its instances are defined entirely by their state and do not need identity. That clearer model is valuable in itself! The JVM’s additional freedom to optimize how those values are represented is a welcome bonus. C2 can do amazing things with that freedom, but it cannot always recover information hidden behind abstraction boundaries. Profiling and inspecting the generated code remain the best ways to understand what is happening. To get the best results, we may still need to have a little sympathy for the compiler.


More at https://johan-sjolen.github.io/post/compiler-sympathy/compiler-sympathy/.