----- Original Message -----
> From: "daniel smith" <daniel.sm...@oracle.com>
> To: "Remi Forax" <fo...@univ-mlv.fr>
> Cc: "Maurizio Cimadamore" <maurizio.cimadam...@oracle.com>, "Brian Goetz" 
> <brian.go...@oracle.com>,
> "valhalla-spec-experts" <valhalla-spec-experts@openjdk.java.net>
> Sent: Monday, June 6, 2022 7:56:40 PM
> Subject: Re: Anonymous value classes

>> On Jun 4, 2022, at 3:33 AM, fo...@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. 

In practice, escape analysis is weaker than what you think. That's why we need 
Valhalla in the first place, i believe John has written a text about why Escape 
Analysis is not good enough at the start of the project.

> *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.)

Anonymous class are only anonymous for the Java code not for the VM,
javac desugars anonymous classes to real classes with a funny names full or '$' 
so the VM considers them as real classes.

> 
> 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.

I understand the initial reaction in front of a
  new value AbstractList<>() { ... }

We can single out anonymous class as as you propose, but not if it's based on a 
misunderstanding (anonymous class name can not appear in descriptor) or because 
the syntax is a kind of ugly (the whole anonymous class syntax is ugly).

RĂ©mi

Reply via email to