On Thu, 20 Mar 2025 21:11:41 GMT, Chen Liang <[email protected]> wrote:
>> Provide method overloads to the ClassFile interface of the
>> java.lang.classfile API which allow parsing of classes found in byte buffers
>> and memory segments, as well as allowing built class files to be output to
>> these types.
>
> src/java.base/share/classes/jdk/internal/classfile/impl/ClassFileImpl.java
> line 159:
>
>> 157: public ClassModel parse(final ByteBuffer bytes) {
>> 158: // defensive copy
>> 159: ByteBuffer dup = bytes.duplicate();
>
> The array version has no defensive copy. Doesn't this defeat the performance
> goal of the API?
No; duplicating a buffer does not duplicate its contents, only the wrapping
object.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24139#discussion_r2007373107