RFR: 4860681: (bf) Add CharBuffer absolute bulk put method for CharSequence [v5]

Roger Riggs rriggs at openjdk.org
Mon Oct 9 20:47:06 UTC 2023


On Mon, 9 Oct 2023 17:08:53 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> Add to `java.nio.CharBuffer` an absolute bulk put method which takes a `CharSequence` as its source of `char`s.
>
> Brian Burkhalter has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains seven additional commits since the last revision:
> 
>  - Merge
>  - 4860681: Heap and direct buffer specializations
>  - 4860681: Change some {@code ...} to <code>...</code> to prevent line breaking
>  - 4860681: Modify existing test
>  - Merge
>  - 4860681: Add spaces to parameter lists in @see tag
>  - 4860681: (bf) Add CharBuffer absolute bulk put method for CharSequence

The API spec for put looks fine.

src/java.base/share/classes/java/nio/Direct-X-Buffer.java.template line 542:

> 540:                     sb.getChars(start, start + count, buf, 0);
> 541:                 } else if (csq instanceof StringBuffer sb) {
> 542:                     sb.getChars(start, start + count, buf, 0);

Can the allocation and double copy be avoided?
But I guess the combinatorics of latin1/utf16 string encoding and the memory and byte order make it difficult.

test/jdk/java/nio/Buffer/Basic-X.java.template line 636:

> 634:         long seed = System.nanoTime();
> 635:         Random rnd = new Random(seed);
> 636: 

Printing the seed would make it possible to repeat the same test.

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

PR Review: https://git.openjdk.org/jdk/pull/13744#pullrequestreview-1665197849
PR Review Comment: https://git.openjdk.org/jdk/pull/13744#discussion_r1350764882
PR Review Comment: https://git.openjdk.org/jdk/pull/13744#discussion_r1350754116


More information about the nio-dev mailing list