Class files in ByteBuffer

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Wed Mar 12 16:51:41 UTC 2025


On 12/03/2025 16:25, Brian Goetz wrote:
> That does seem like a more future-proof choice.  (I suspect too it 
> would be less intrusive to adapt the internals to MS than BB.)

They are probably similar in spirit -- but at least you would know that 
the MS path is more aggressively/actively optimized.

I do share some of Chen's concerns -- random access on MS (and BB) is 
not comparable to random access on a byte[]. So changing the internals 
of the classfile API to use MS/BB is something that needs to be done 
carefully (and with benchmarks at hands).

One possible area where adopting a "more raw" buffer would be beneficial 
is when writing/reading custom attributes -- since BB/MS will already 
provide the primitives we need to access load/store primitive values 
from/in the buffer. But -- again, something that requires care and 
consideration, it's not a slam dunk.

Maurizio

>
> On 3/12/2025 11:53 AM, Maurizio Cimadamore wrote:
>>
>> On 10/03/2025 17:52, Brian Goetz wrote:
>>> My first reaction is that the first seems fine in theory
>>
>> I wonder if an API accepting a MemorySegment would be more general -- 
>> you can construct a MS from a BB and you can of course go from MS to 
>> byte[] (which is what the impl needs). So I wonder if that would be 
>> more future-proof. (We can, of course, also provide both).
>>
>> Maurizio
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/classfile-api-dev/attachments/20250312/c22e6cd2/attachment.htm>


More information about the classfile-api-dev mailing list