Anonymous value classes

Dan Smith daniel.smith at oracle.com
Mon Jun 6 17:56:40 UTC 2022


> On Jun 4, 2022, at 3:33 AM, forax at univ-mlv.fr wrote:
> 
> there is a lot of libraries that have APIs using interfaces that are implemented by anonymous classes, the collection API is one of them, fluent loggers (anything fluent in fact) is another, and those will benefit to have better than escape analysis performance.

This could use validation. My very high-level sense is that within inlined code, escape analysis will do just fine with identity classes, with no observable performance gain when switching to a value class. *Across calls*, we can do much better with value classes, but at that point current HotSpot optimizations need a name in the descriptor. (Huge caveat that my understanding of this situation is very high-level, and there may be important things I'm missing.)

Also note that if it's necessary to opt in anyway, it's not particularly much to ask these performance-sensitive users to declare a local class rather than an anonymous value class.


More information about the valhalla-spec-observers mailing list