On Tue, 8 Mar 2022 15:48:56 GMT, Maurizio Cimadamore <mcimadam...@openjdk.org> 
wrote:

>> We propose to provide a runtime anonymous carrier class object generator; 
>> java.lang.runtime.Carrier. This generator class is designed to share 
>> anonymous classes when shapes are similar. For example, if several clients 
>> require objects containing two integer fields, then Carrier will ensure that 
>> each client generates carrier objects using the same underlying anonymous 
>> class. 
>> 
>> See JBS for details.
>
> src/java.base/share/classes/java/lang/runtime/Carrier.java line 129:
> 
>> 127: 
>> 128:     /**
>> 129:      * Factory for array based carrier. Array wrapped in object to 
>> provide
> 
> I found this comment hard to parse - or unhelpful to understand how the 
> factory really worked. IIUC, this factory captures all parameters into an 
> Object[] (using a collector MH) and returns that Object[] (which acts as the 
> carrier object). I'm not sure I see anything here that would prevent the user 
> from building a carrier and casting to Object[] ?

Clarified the comment. You are right. When I reworked the original code I 
dropped the intermediate object. For my purposes, it was about performance. If 
the object needs to be protected then it's up to the client to protect.  The 
same would be true if I add byte[] for all binary carriers.

-------------

PR: https://git.openjdk.java.net/jdk/pull/7744

Reply via email to