From c56c6f7420c880e4911bfedec9844e0fba2c31b5 Mon Sep 17 00:00:00 2001 From: Markus KARG Date: Sat, 5 Oct 2024 22:05:07 +0000 Subject: [PATCH 01/15] Draft: CharSequence.getChars --- .../share/classes/java/io/Reader.java | 11 +----- .../share/classes/java/lang/CharSequence.java | 39 +++++++++++++++++++ .../classes/java/nio/X-Buffer.java.template | 23 +++++++++++ 3 files changed, 63 insertions(+), 10 deletions(-) diff --git a/src/java.base/share/classes/java/io/Reader.java b/src/java.base/share/classes/java/io/Reader.java index 9fca28a3a96cf..e4d50f9f8069a 100644 --- a/src/java.base/share/classes/java/io/Reader.java +++ b/src/java.base/share/classes/java/io/Reader.java @@ -194,16 +194,7 @@ public int read(char[] cbuf, int off, int len) throws IOException { if (next >= length) return -1; int n = Math.min(length - next, len); - switch (cs) { - case String s -> s.getChars(next, next + n, cbuf, off); - case StringBuilder sb -> sb.getChars(next, next + n, cbuf, off); - case StringBuffer sb -> sb.getChars(next, next + n, cbuf, off); - case CharBuffer cb -> cb.get(next, cbuf, off, n); - default -> { - for (int i = 0; i < n; i++) - cbuf[off + i] = cs.charAt(next + i); - } - } + cs.getChars(next, next + n, cbuf, off); next += n; return n; } diff --git a/src/java.base/share/classes/java/lang/CharSequence.java b/src/java.base/share/classes/java/lang/CharSequence.java index 87bc4a5525a85..0cd3686f80b9d 100644 --- a/src/java.base/share/classes/java/lang/CharSequence.java +++ b/src/java.base/share/classes/java/lang/CharSequence.java @@ -302,4 +302,43 @@ public static int compare(CharSequence cs1, CharSequence cs2) { return cs1.length() - cs2.length(); } + /** + * Characters are copied from this sequence into the + * destination character array {@code dst}. The first character to + * be copied is at index {@code srcBegin}; the last character to + * be copied is at index {@code srcEnd-1}. The total number of + * characters to be copied is {@code srcEnd-srcBegin}. The + * characters are copied into the subarray of {@code dst} starting + * at index {@code dstBegin} and ending at index: + *
{@code
+     * dstbegin + (srcEnd-srcBegin) - 1
+     * }
+ * + * @param srcBegin start copying at this offset. + * @param srcEnd stop copying at this offset. + * @param dst the array to copy the data into. + * @param dstBegin offset into {@code dst}. + * @throws IndexOutOfBoundsException if any of the following is true: + * + * + * @implSpec + * The default implementation iterates over {@link #charAt(int)}. + * + * @since 24 + */ + public default void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) { + Objects.checkFromToIndex(srcBegin, srcEnd, length()); + Objects.checkFromIndexSize(dstBegin, srcEnd - srcBegin, dst.length); + while (srcBegin < srcEnd) + dst[dstBegin++] = charAt(srcBegin++); + } } diff --git a/src/java.base/share/classes/java/nio/X-Buffer.java.template b/src/java.base/share/classes/java/nio/X-Buffer.java.template index 1b378a2ef4a91..0a66fe2d3b9af 100644 --- a/src/java.base/share/classes/java/nio/X-Buffer.java.template +++ b/src/java.base/share/classes/java/nio/X-Buffer.java.template @@ -2333,4 +2333,27 @@ public abstract sealed class $Type$Buffer #end[streamableType] +#if[char] + /** + * {@inheritDoc} + * + * @apiNote This method exists solely to implement + * {@link CharSequence#getChars(int,int,char[],int)}. + * It has no additional benefit over {@link #get(int, char[], int, int)}. + * + * @implSpec This method is equivalent to + * {@code get(srcBegin, dst, dstBegin, srcEnd - srcBegin)}. + * + * @implNote This method allows for superior performance over the default + * implementation in {@code CharSequence}. It performs a direct + * buffer-to-array copy of the complete specified region. + * + * @since 24 + */ + @Override + public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) { + get(srcBegin, dst, dstBegin, srcEnd - srcBegin); + } +#end[char] + } From e912ad8786160a212c4b9027513f18e21aa206d1 Mon Sep 17 00:00:00 2001 From: Markus KARG Date: Sat, 8 Feb 2025 18:54:17 +0000 Subject: [PATCH 02/15] @Override --- src/java.base/share/classes/java/lang/AbstractStringBuilder.java | 1 + src/java.base/share/classes/java/lang/String.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/java.base/share/classes/java/lang/AbstractStringBuilder.java b/src/java.base/share/classes/java/lang/AbstractStringBuilder.java index e0c3aa19f5437..7bbfad06cd462 100644 --- a/src/java.base/share/classes/java/lang/AbstractStringBuilder.java +++ b/src/java.base/share/classes/java/lang/AbstractStringBuilder.java @@ -511,6 +511,7 @@ public int offsetByCodePoints(int index, int codePointOffset) { * {@code dst.length} * */ + @Override public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) { Preconditions.checkFromToIndex(srcBegin, srcEnd, count, Preconditions.SIOOBE_FORMATTER); // compatible to old version diff --git a/src/java.base/share/classes/java/lang/String.java b/src/java.base/share/classes/java/lang/String.java index 3d8481be1c3ad..cbb6d7fe887eb 100644 --- a/src/java.base/share/classes/java/lang/String.java +++ b/src/java.base/share/classes/java/lang/String.java @@ -1778,6 +1778,7 @@ public int offsetByCodePoints(int index, int codePointOffset) { *
  • {@code dstBegin+(srcEnd-srcBegin)} is larger than * {@code dst.length} */ + @Override public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) { checkBoundsBeginEnd(srcBegin, srcEnd, length()); checkBoundsOffCount(dstBegin, srcEnd - srcBegin, dst.length); From 5da2f4b8d6cdfeb2be08592a7ac04a1f647a8006 Mon Sep 17 00:00:00 2001 From: Markus KARG Date: Sun, 9 Feb 2025 18:10:41 +0000 Subject: [PATCH 03/15] Copyright (C) 2025 --- src/java.base/share/classes/java/io/Reader.java | 2 +- .../share/classes/java/lang/AbstractStringBuilder.java | 2 +- src/java.base/share/classes/java/lang/CharSequence.java | 4 ++-- src/java.base/share/classes/java/lang/String.java | 2 +- src/java.base/share/classes/java/nio/X-Buffer.java.template | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/java.base/share/classes/java/io/Reader.java b/src/java.base/share/classes/java/io/Reader.java index e4d50f9f8069a..ad420d8401ded 100644 --- a/src/java.base/share/classes/java/io/Reader.java +++ b/src/java.base/share/classes/java/io/Reader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/src/java.base/share/classes/java/lang/AbstractStringBuilder.java b/src/java.base/share/classes/java/lang/AbstractStringBuilder.java index 7bbfad06cd462..3cded85044c28 100644 --- a/src/java.base/share/classes/java/lang/AbstractStringBuilder.java +++ b/src/java.base/share/classes/java/lang/AbstractStringBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/src/java.base/share/classes/java/lang/CharSequence.java b/src/java.base/share/classes/java/lang/CharSequence.java index 0cd3686f80b9d..17198893736a8 100644 --- a/src/java.base/share/classes/java/lang/CharSequence.java +++ b/src/java.base/share/classes/java/lang/CharSequence.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -333,7 +333,7 @@ public static int compare(CharSequence cs1, CharSequence cs2) { * @implSpec * The default implementation iterates over {@link #charAt(int)}. * - * @since 24 + * @since 25 */ public default void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) { Objects.checkFromToIndex(srcBegin, srcEnd, length()); diff --git a/src/java.base/share/classes/java/lang/String.java b/src/java.base/share/classes/java/lang/String.java index cbb6d7fe887eb..16d1c249bb9bb 100644 --- a/src/java.base/share/classes/java/lang/String.java +++ b/src/java.base/share/classes/java/lang/String.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/src/java.base/share/classes/java/nio/X-Buffer.java.template b/src/java.base/share/classes/java/nio/X-Buffer.java.template index 0a66fe2d3b9af..686bf2ad7beb8 100644 --- a/src/java.base/share/classes/java/nio/X-Buffer.java.template +++ b/src/java.base/share/classes/java/nio/X-Buffer.java.template @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -2348,7 +2348,7 @@ public abstract sealed class $Type$Buffer * implementation in {@code CharSequence}. It performs a direct * buffer-to-array copy of the complete specified region. * - * @since 24 + * @since 25 */ @Override public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) { From a3c2add9c16e4c7331c5a7c2848f27b6c0330a17 Mon Sep 17 00:00:00 2001 From: Markus KARG Date: Sun, 23 Mar 2025 10:30:41 +0000 Subject: [PATCH 04/15] Applied changes requested by Chen --- .../share/classes/java/lang/CharSequence.java | 3 +- .../classes/java/nio/X-Buffer.java.template | 44 +++++++++---------- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/java.base/share/classes/java/lang/CharSequence.java b/src/java.base/share/classes/java/lang/CharSequence.java index 17198893736a8..467cbf3238bee 100644 --- a/src/java.base/share/classes/java/lang/CharSequence.java +++ b/src/java.base/share/classes/java/lang/CharSequence.java @@ -329,6 +329,7 @@ public static int compare(CharSequence cs1, CharSequence cs2) { *
  • {@code dstBegin+srcEnd-srcBegin} is greater than * {@code dst.length} * + * @throws NullPointerException if {@code dst} is {@code null} * * @implSpec * The default implementation iterates over {@link #charAt(int)}. @@ -337,7 +338,7 @@ public static int compare(CharSequence cs1, CharSequence cs2) { */ public default void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) { Objects.checkFromToIndex(srcBegin, srcEnd, length()); - Objects.checkFromIndexSize(dstBegin, srcEnd - srcBegin, dst.length); + Objects.checkIndex(dstBegin, dst.length - (srcEnd - srcBegin) + 1); while (srcBegin < srcEnd) dst[dstBegin++] = charAt(srcBegin++); } diff --git a/src/java.base/share/classes/java/nio/X-Buffer.java.template b/src/java.base/share/classes/java/nio/X-Buffer.java.template index 08c8f226dd1ff..f3daf9bf3c623 100644 --- a/src/java.base/share/classes/java/nio/X-Buffer.java.template +++ b/src/java.base/share/classes/java/nio/X-Buffer.java.template @@ -1896,6 +1896,27 @@ public abstract sealed class $Type$Buffer #if[char] + /** + * {@inheritDoc} + * + * @apiNote This method exists solely to implement + * {@link CharSequence#getChars(int,int,char[],int)}. + * It has no additional benefit over {@link #get(int, char[], int, int)}. + * + * @implSpec This method is equivalent to + * {@code get(srcBegin, dst, dstBegin, srcEnd - srcBegin)}. + * + * @implNote This method allows for superior performance over the default + * implementation in {@code CharSequence}. It performs a direct + * buffer-to-array copy of the complete specified region. + * + * @since 25 + */ + @Override + public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) { + get(srcBegin, dst, dstBegin, srcEnd - srcBegin); + } + /** * Returns a string containing the characters in this buffer. * @@ -2353,27 +2374,4 @@ public abstract sealed class $Type$Buffer #end[streamableType] -#if[char] - /** - * {@inheritDoc} - * - * @apiNote This method exists solely to implement - * {@link CharSequence#getChars(int,int,char[],int)}. - * It has no additional benefit over {@link #get(int, char[], int, int)}. - * - * @implSpec This method is equivalent to - * {@code get(srcBegin, dst, dstBegin, srcEnd - srcBegin)}. - * - * @implNote This method allows for superior performance over the default - * implementation in {@code CharSequence}. It performs a direct - * buffer-to-array copy of the complete specified region. - * - * @since 25 - */ - @Override - public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) { - get(srcBegin, dst, dstBegin, srcEnd - srcBegin); - } -#end[char] - } From d27d1bd85458f02e859a9653805d96ff79473124 Mon Sep 17 00:00:00 2001 From: Markus KARG Date: Mon, 24 Mar 2025 12:51:59 +0100 Subject: [PATCH 05/15] Removed apiNote and implNote from CharBuffer, as suggested by Chen --- .../share/classes/java/nio/X-Buffer.java.template | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/java.base/share/classes/java/nio/X-Buffer.java.template b/src/java.base/share/classes/java/nio/X-Buffer.java.template index f3daf9bf3c623..3137e3436755e 100644 --- a/src/java.base/share/classes/java/nio/X-Buffer.java.template +++ b/src/java.base/share/classes/java/nio/X-Buffer.java.template @@ -1899,17 +1899,9 @@ public abstract sealed class $Type$Buffer /** * {@inheritDoc} * - * @apiNote This method exists solely to implement - * {@link CharSequence#getChars(int,int,char[],int)}. - * It has no additional benefit over {@link #get(int, char[], int, int)}. - * * @implSpec This method is equivalent to * {@code get(srcBegin, dst, dstBegin, srcEnd - srcBegin)}. * - * @implNote This method allows for superior performance over the default - * implementation in {@code CharSequence}. It performs a direct - * buffer-to-array copy of the complete specified region. - * * @since 25 */ @Override From 29e1521fa25ba88dbbe4af077888044666f790f6 Mon Sep 17 00:00:00 2001 From: Markus KARG Date: Sat, 29 Mar 2025 09:52:29 +0000 Subject: [PATCH 06/15] Replaced JavaDocs of CharBuffer, as suggested by Alan --- .../classes/java/nio/X-Buffer.java.template | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/java.base/share/classes/java/nio/X-Buffer.java.template b/src/java.base/share/classes/java/nio/X-Buffer.java.template index 3137e3436755e..283f553459778 100644 --- a/src/java.base/share/classes/java/nio/X-Buffer.java.template +++ b/src/java.base/share/classes/java/nio/X-Buffer.java.template @@ -1897,10 +1897,35 @@ public abstract sealed class $Type$Buffer #if[char] /** - * {@inheritDoc} + * Absolute bulk get method. + * + *

    This method transfers {@code srcEnd-srcBegin} characters from this + * buffer into the given array, starting at index {@code srcBegin} in this + * buffer and at offset {@code dstBegin} in the array. The position of this + * buffer is unchanged. + * + * @param srcBegin + * The index in this buffer from which the first character will be + * read; must be non-negative and less than {@code limit()} + * + * @param srcEnd + * The index in this buffer directly before the last character to + * read; must be non-negative and less or equal than {@code limit()} + * and must be greater or equal than {@code srcBegin} + * + * @param dst + * The destination array + * + * @param dstBegin + * The offset within the array of the first character to be + * written; must be non-negative and less than {@code dst.length} + * + * @throws IndexOutOfBoundsException + * If the preconditions on the {@code srcBegin}, {@code srcEnd}, + * and {@code dstBegin} parameters do not hold * * @implSpec This method is equivalent to - * {@code get(srcBegin, dst, dstBegin, srcEnd - srcBegin)}. + * {@code get(srcBegin, dst, dstBegin, srcEnd - srcBegin)}. * * @since 25 */ From a7f56f4ecba4be1a28e551e8a247998db7d7cb79 Mon Sep 17 00:00:00 2001 From: Markus KARG Date: Sat, 29 Mar 2025 09:57:48 +0000 Subject: [PATCH 07/15] Applied changes requested by Alan: Copies chars from this sequence into the given destination array --- src/java.base/share/classes/java/lang/CharSequence.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/java.base/share/classes/java/lang/CharSequence.java b/src/java.base/share/classes/java/lang/CharSequence.java index 467cbf3238bee..cef71d885ce06 100644 --- a/src/java.base/share/classes/java/lang/CharSequence.java +++ b/src/java.base/share/classes/java/lang/CharSequence.java @@ -303,10 +303,9 @@ public static int compare(CharSequence cs1, CharSequence cs2) { } /** - * Characters are copied from this sequence into the - * destination character array {@code dst}. The first character to - * be copied is at index {@code srcBegin}; the last character to - * be copied is at index {@code srcEnd-1}. The total number of + * Copies characters from this sequence into the given destination array. + * The first character to be copied is at index {@code srcBegin}; the last + * character to be copied is at index {@code srcEnd-1}. The total number of * characters to be copied is {@code srcEnd-srcBegin}. The * characters are copied into the subarray of {@code dst} starting * at index {@code dstBegin} and ending at index: From a5d26c5bc143e37520e5f42bcb0299d4e12784b0 Mon Sep 17 00:00:00 2001 From: Markus KARG Date: Sat, 29 Mar 2025 10:02:57 +0000 Subject: [PATCH 08/15] Applied changes requested by Alan: This sentence doesn't make sense, did something get deleted? --- src/java.base/share/classes/java/lang/CharSequence.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/java.base/share/classes/java/lang/CharSequence.java b/src/java.base/share/classes/java/lang/CharSequence.java index cef71d885ce06..752ccdeb0a11d 100644 --- a/src/java.base/share/classes/java/lang/CharSequence.java +++ b/src/java.base/share/classes/java/lang/CharSequence.java @@ -331,7 +331,8 @@ public static int compare(CharSequence cs1, CharSequence cs2) { * @throws NullPointerException if {@code dst} is {@code null} * * @implSpec - * The default implementation iterates over {@link #charAt(int)}. + * The default implementation invokes {@link #charAt(int index)} in a loop + * iterating {@code index} from {@code srcBegin} to {@code srcEnd-1} * * @since 25 */ From d2ccf42cec148a86b17753d160df211925f75858 Mon Sep 17 00:00:00 2001 From: Markus KARG Date: Sun, 30 Mar 2025 12:16:59 +0000 Subject: [PATCH 09/15] Applied changes requested by Chen: 'We might need to specify the IOOBE behavior - when an IOOBE is thrown, some characters may be already transferred (this is important for concurrent char sequences)' --- src/java.base/share/classes/java/lang/CharSequence.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/java.base/share/classes/java/lang/CharSequence.java b/src/java.base/share/classes/java/lang/CharSequence.java index 752ccdeb0a11d..2732ee35933d6 100644 --- a/src/java.base/share/classes/java/lang/CharSequence.java +++ b/src/java.base/share/classes/java/lang/CharSequence.java @@ -332,7 +332,10 @@ public static int compare(CharSequence cs1, CharSequence cs2) { * * @implSpec * The default implementation invokes {@link #charAt(int index)} in a loop - * iterating {@code index} from {@code srcBegin} to {@code srcEnd-1} + * iterating {@code index} from {@code srcBegin} to {@code srcEnd-1}. + * Concurrent truncation of this character sequence can throw + * {@code IndexOutOfBoundsException}. In this case, some characters, but not + * all, may be already transferred. * * @since 25 */ From 884e7dc14c25b47ff6e5056fb663cfccf17f243e Mon Sep 17 00:00:00 2001 From: Markus KARG Date: Thu, 17 Apr 2025 21:05:53 +0000 Subject: [PATCH 10/15] Applied changes requested by Chen and Jaikiran: Unit tests for default implementation of CharSequence.getChars() and for CharBuffer.getChars() --- test/jdk/java/lang/CharSequence/GetChars.java | 109 ++++++++++++++++++ test/jdk/java/nio/CharBuffer/GetChars.java | 94 +++++++++++++++ 2 files changed, 203 insertions(+) create mode 100644 test/jdk/java/lang/CharSequence/GetChars.java create mode 100644 test/jdk/java/nio/CharBuffer/GetChars.java diff --git a/test/jdk/java/lang/CharSequence/GetChars.java b/test/jdk/java/lang/CharSequence/GetChars.java new file mode 100644 index 0000000000000..5d0594a08975a --- /dev/null +++ b/test/jdk/java/lang/CharSequence/GetChars.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import org.testng.Assert; +import org.testng.annotations.Test; + +/** + * @test + * @bug 8343110 + * @summary Check for expected behavior of default implementation of + * CharSequence.getChars(). + * @run testng GetChars + */ +public class GetChars { + private static CharSequence CS = new CharSequence() { + @Override + public int length() { + return 4; + } + + @Override + public char charAt(int index) { + return "Test".charAt(index); + } + + @Override + public CharSequence subSequence(int start, int end) { + throw new UnsupportedOperationException(); + } + }; + + @Test + public void testExactCopy() { + var dst = new char[4]; + CS.getChars(0, 4, dst, 0); + Assert.assertEquals(dst, new char[] {'T', 'e', 's', 't'}); + } + + @Test + public void testPartialCopy() { + var dst = new char[2]; + CS.getChars(1, 3, dst, 0); + Assert.assertEquals(dst, new char[] {'e', 's'}); + } + + @Test + public void testPositionedCopy() { + var dst = new char[] {1, 2, 3, 4, 5, 6}; + CS.getChars(0, 4, dst, 1); + Assert.assertEquals(dst, new char[] {1, 'T', 'e', 's', 't', 6}); + } + + @Test + public void testSrcBeginIsNegative() { + Assert.assertThrows(IndexOutOfBoundsException.class, + () -> CS.getChars(-1, 3, new char[4], 0)); + } + + @Test + public void testDstBeginIsNegative() { + Assert.assertThrows(IndexOutOfBoundsException.class, + () -> CS.getChars(0, 4, new char[4], -1)); + } + + @Test + public void testSrcBeginIsGreaterThanSrcEnd() { + Assert.assertThrows(IndexOutOfBoundsException.class, + () -> CS.getChars(4, 0, new char[4], 0)); + } + + @Test + public void testSrcEndIsGreaterThanSequenceLength() { + Assert.assertThrows(IndexOutOfBoundsException.class, + () -> CS.getChars(0, 5, new char[4], 0)); + } + + @Test + public void testRequestedLengthIsGreaterThanDstLength() { + Assert.assertThrows(IndexOutOfBoundsException.class, + () -> CS.getChars(0, 4, new char[3], 0)); + } + + @Test + public void testDstIsNull() { + Assert.assertThrows(NullPointerException.class, + () -> CS.getChars(0, 4, null, 0)); + } + +} diff --git a/test/jdk/java/nio/CharBuffer/GetChars.java b/test/jdk/java/nio/CharBuffer/GetChars.java new file mode 100644 index 0000000000000..8ddd8dd0207f8 --- /dev/null +++ b/test/jdk/java/nio/CharBuffer/GetChars.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.nio.CharBuffer; +import org.testng.Assert; +import org.testng.annotations.Test; + +/** + * @test + * @bug 8343110 + * @summary Check for expected behavior of CharBuffer.getChars(). + * @run testng GetChars + */ +public class GetChars { + private static CharBuffer CB = CharBuffer.wrap("Test"); + + @Test + public void testExactCopy() { + var dst = new char[4]; + CB.getChars(0, 4, dst, 0); + Assert.assertEquals(dst, new char[] {'T', 'e', 's', 't'}); + } + + @Test + public void testPartialCopy() { + var dst = new char[2]; + CB.getChars(1, 3, dst, 0); + Assert.assertEquals(dst, new char[] {'e', 's'}); + } + + @Test + public void testPositionedCopy() { + var dst = new char[] {1, 2, 3, 4, 5, 6}; + CB.getChars(0, 4, dst, 1); + Assert.assertEquals(dst, new char[] {1, 'T', 'e', 's', 't', 6}); + } + + @Test + public void testSrcBeginIsNegative() { + Assert.assertThrows(IndexOutOfBoundsException.class, + () -> CB.getChars(-1, 3, new char[4], 0)); + } + + @Test + public void testDstBeginIsNegative() { + Assert.assertThrows(IndexOutOfBoundsException.class, + () -> CB.getChars(0, 4, new char[4], -1)); + } + + @Test + public void testSrcBeginIsGreaterThanSrcEnd() { + Assert.assertThrows(IndexOutOfBoundsException.class, + () -> CB.getChars(4, 0, new char[4], 0)); + } + + @Test + public void testSrcEndIsGreaterThanSequenceLength() { + Assert.assertThrows(IndexOutOfBoundsException.class, + () -> CB.getChars(0, 5, new char[4], 0)); + } + + @Test + public void testRequestedLengthIsGreaterThanDstLength() { + Assert.assertThrows(IndexOutOfBoundsException.class, + () -> CB.getChars(0, 4, new char[3], 0)); + } + + @Test + public void testDstIsNull() { + Assert.assertThrows(NullPointerException.class, + () -> CB.getChars(0, 4, null, 0)); + } + +} From cb2a2efbc3ee28df0378fe1894672ae9c53ee11c Mon Sep 17 00:00:00 2001 From: Markus KARG Date: Fri, 18 Apr 2025 11:17:09 +0000 Subject: [PATCH 11/15] Applied changes requestes by Alan: Aligning unit test for CharBuffer.getChars() with unit test for CharBuffer.chars() --- test/jdk/java/nio/Buffer/GetChars.java | 207 +++++++++++++++++++++ test/jdk/java/nio/CharBuffer/GetChars.java | 94 ---------- 2 files changed, 207 insertions(+), 94 deletions(-) create mode 100644 test/jdk/java/nio/Buffer/GetChars.java delete mode 100644 test/jdk/java/nio/CharBuffer/GetChars.java diff --git a/test/jdk/java/nio/Buffer/GetChars.java b/test/jdk/java/nio/Buffer/GetChars.java new file mode 100644 index 0000000000000..8633482871751 --- /dev/null +++ b/test/jdk/java/nio/Buffer/GetChars.java @@ -0,0 +1,207 @@ +/* + * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.CharBuffer; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; + +/** + * @test + * @bug 8343110 + * @summary Check for expected behavior of CharBuffer.getChars(). + * @run testng GetChars + * @key randomness + */ +public class GetChars { + private static CharBuffer CB = CharBuffer.wrap("Test"); + + @Test + public void testExactCopy() { + var dst = new char[4]; + CB.getChars(0, 4, dst, 0); + Assert.assertEquals(dst, new char[] {'T', 'e', 's', 't'}); + } + + @Test + public void testPartialCopy() { + var dst = new char[2]; + CB.getChars(1, 3, dst, 0); + Assert.assertEquals(dst, new char[] {'e', 's'}); + } + + @Test + public void testPositionedCopy() { + var dst = new char[] {1, 2, 3, 4, 5, 6}; + CB.getChars(0, 4, dst, 1); + Assert.assertEquals(dst, new char[] {1, 'T', 'e', 's', 't', 6}); + } + + @Test + public void testSrcBeginIsNegative() { + Assert.assertThrows(IndexOutOfBoundsException.class, + () -> CB.getChars(-1, 3, new char[4], 0)); + } + + @Test + public void testDstBeginIsNegative() { + Assert.assertThrows(IndexOutOfBoundsException.class, + () -> CB.getChars(0, 4, new char[4], -1)); + } + + @Test + public void testSrcBeginIsGreaterThanSrcEnd() { + Assert.assertThrows(IndexOutOfBoundsException.class, + () -> CB.getChars(4, 0, new char[4], 0)); + } + + @Test + public void testSrcEndIsGreaterThanSequenceLength() { + Assert.assertThrows(IndexOutOfBoundsException.class, + () -> CB.getChars(0, 5, new char[4], 0)); + } + + @Test + public void testRequestedLengthIsGreaterThanDstLength() { + Assert.assertThrows(IndexOutOfBoundsException.class, + () -> CB.getChars(0, 4, new char[3], 0)); + } + + @Test + public void testDstIsNull() { + Assert.assertThrows(NullPointerException.class, + () -> CB.getChars(0, 4, null, 0)); + } + + private static final Random RAND = new Random(); + private static final int SIZE = 128 + RAND.nextInt(1024); + + /** + * Randomize the char buffer's position and limit. + */ + private static CharBuffer randomizeRange(CharBuffer cb) { + int mid = cb.capacity() >>> 1; + int start = RAND.nextInt(mid + 1); // from 0 to mid + int end = mid + RAND.nextInt(cb.capacity() - mid + 1); // from mid to capacity + cb.position(start); + cb.limit(end); + return cb; + } + + /** + * Randomize the char buffer's contents, position and limit. + */ + private static CharBuffer randomize(CharBuffer cb) { + while (cb.hasRemaining()) { + cb.put((char)RAND.nextInt()); + } + return randomizeRange(cb); + } + + /** + * Sums the remaining chars in the char buffer. + */ + private static int intSum(CharBuffer cb) { + int sum = 0; + cb.mark(); + while (cb.hasRemaining()) { + sum += cb.get(); + } + cb.reset(); + return sum; + } + + /** + * Sums the chars in the char array. + */ + private static int intSum(char[] ca) { + int sum = 0; + for (int i = 0; i < ca.length; i++) + sum += ca[i]; + return sum; + } + + /** + * Creates char buffers to test, adding them to the given list. + */ + private static void addCases(CharBuffer cb, List buffers) { + randomize(cb); + buffers.add(cb); + + buffers.add(cb.slice()); + buffers.add(cb.duplicate()); + buffers.add(cb.asReadOnlyBuffer()); + + buffers.add(randomizeRange(cb.slice())); + buffers.add(randomizeRange(cb.duplicate())); + buffers.add(randomizeRange(cb.asReadOnlyBuffer())); + } + + @DataProvider(name = "charbuffers") + public Object[][] createCharBuffers() { + List buffers = new ArrayList<>(); + + // heap + addCases(CharBuffer.allocate(SIZE), buffers); + addCases(CharBuffer.wrap(new char[SIZE]), buffers); + addCases(ByteBuffer.allocate(SIZE*2).order(ByteOrder.BIG_ENDIAN).asCharBuffer(), + buffers); + addCases(ByteBuffer.allocate(SIZE*2).order(ByteOrder.LITTLE_ENDIAN).asCharBuffer(), + buffers); + + // direct + addCases(ByteBuffer.allocateDirect(SIZE*2).order(ByteOrder.BIG_ENDIAN).asCharBuffer(), + buffers); + addCases(ByteBuffer.allocateDirect(SIZE*2).order(ByteOrder.LITTLE_ENDIAN).asCharBuffer(), + buffers); + + // read-only buffer backed by a CharSequence + buffers.add(CharBuffer.wrap(randomize(CharBuffer.allocate(SIZE)))); + + Object[][] params = new Object[buffers.size()][]; + for (int i = 0; i < buffers.size(); i++) { + CharBuffer cb = buffers.get(i); + params[i] = new Object[] { cb.getClass().getName(), cb }; + } + + return params; + } + + @Test(dataProvider = "charbuffers") + public void testGetChars(String type, CharBuffer cb) { + System.out.format("%s position=%d, limit=%d%n", type, cb.position(), cb.limit()); + int expected = intSum(cb); + var dst = new char[cb.remaining()]; + cb.getChars(cb.position(), cb.limit(), dst, 0); + int actual = intSum(dst); + assertEquals(actual, expected); + } +} diff --git a/test/jdk/java/nio/CharBuffer/GetChars.java b/test/jdk/java/nio/CharBuffer/GetChars.java deleted file mode 100644 index 8ddd8dd0207f8..0000000000000 --- a/test/jdk/java/nio/CharBuffer/GetChars.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -import java.nio.CharBuffer; -import org.testng.Assert; -import org.testng.annotations.Test; - -/** - * @test - * @bug 8343110 - * @summary Check for expected behavior of CharBuffer.getChars(). - * @run testng GetChars - */ -public class GetChars { - private static CharBuffer CB = CharBuffer.wrap("Test"); - - @Test - public void testExactCopy() { - var dst = new char[4]; - CB.getChars(0, 4, dst, 0); - Assert.assertEquals(dst, new char[] {'T', 'e', 's', 't'}); - } - - @Test - public void testPartialCopy() { - var dst = new char[2]; - CB.getChars(1, 3, dst, 0); - Assert.assertEquals(dst, new char[] {'e', 's'}); - } - - @Test - public void testPositionedCopy() { - var dst = new char[] {1, 2, 3, 4, 5, 6}; - CB.getChars(0, 4, dst, 1); - Assert.assertEquals(dst, new char[] {1, 'T', 'e', 's', 't', 6}); - } - - @Test - public void testSrcBeginIsNegative() { - Assert.assertThrows(IndexOutOfBoundsException.class, - () -> CB.getChars(-1, 3, new char[4], 0)); - } - - @Test - public void testDstBeginIsNegative() { - Assert.assertThrows(IndexOutOfBoundsException.class, - () -> CB.getChars(0, 4, new char[4], -1)); - } - - @Test - public void testSrcBeginIsGreaterThanSrcEnd() { - Assert.assertThrows(IndexOutOfBoundsException.class, - () -> CB.getChars(4, 0, new char[4], 0)); - } - - @Test - public void testSrcEndIsGreaterThanSequenceLength() { - Assert.assertThrows(IndexOutOfBoundsException.class, - () -> CB.getChars(0, 5, new char[4], 0)); - } - - @Test - public void testRequestedLengthIsGreaterThanDstLength() { - Assert.assertThrows(IndexOutOfBoundsException.class, - () -> CB.getChars(0, 4, new char[3], 0)); - } - - @Test - public void testDstIsNull() { - Assert.assertThrows(NullPointerException.class, - () -> CB.getChars(0, 4, null, 0)); - } - -} From 47fbca7e911a4329c94c11ed127a596e56c6a2d0 Mon Sep 17 00:00:00 2001 From: Markus KARG Date: Sat, 26 Apr 2025 17:03:26 +0000 Subject: [PATCH 12/15] Applied changes proposed in response to Joe's CSR comments: 'understood for CharBuffer; I was thinking more of String, StringBuffer, and StringBuilder where there looks to be more textual similarities.' --- .../java/lang/AbstractStringBuilder.java | 28 ----------------- .../share/classes/java/lang/String.java | 30 ------------------- .../share/classes/java/lang/StringBuffer.java | 5 +--- .../classes/java/lang/StringBuilder.java | 2 +- 4 files changed, 2 insertions(+), 63 deletions(-) diff --git a/src/java.base/share/classes/java/lang/AbstractStringBuilder.java b/src/java.base/share/classes/java/lang/AbstractStringBuilder.java index 1ac075540e2a2..02a32129e6c01 100644 --- a/src/java.base/share/classes/java/lang/AbstractStringBuilder.java +++ b/src/java.base/share/classes/java/lang/AbstractStringBuilder.java @@ -483,34 +483,6 @@ public int offsetByCodePoints(int index, int codePointOffset) { index, codePointOffset); } - /** - * Characters are copied from this sequence into the - * destination character array {@code dst}. The first character to - * be copied is at index {@code srcBegin}; the last character to - * be copied is at index {@code srcEnd-1}. The total number of - * characters to be copied is {@code srcEnd-srcBegin}. The - * characters are copied into the subarray of {@code dst} starting - * at index {@code dstBegin} and ending at index: - *

    {@code
    -     * dstbegin + (srcEnd-srcBegin) - 1
    -     * }
    - * - * @param srcBegin start copying at this offset. - * @param srcEnd stop copying at this offset. - * @param dst the array to copy the data into. - * @param dstBegin offset into {@code dst}. - * @throws IndexOutOfBoundsException if any of the following is true: - *
      - *
    • {@code srcBegin} is negative - *
    • {@code dstBegin} is negative - *
    • the {@code srcBegin} argument is greater than - * the {@code srcEnd} argument. - *
    • {@code srcEnd} is greater than - * {@code this.length()}. - *
    • {@code dstBegin+srcEnd-srcBegin} is greater than - * {@code dst.length} - *
    - */ @Override public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) { diff --git a/src/java.base/share/classes/java/lang/String.java b/src/java.base/share/classes/java/lang/String.java index fb7e829e454a8..ed84445dbe731 100644 --- a/src/java.base/share/classes/java/lang/String.java +++ b/src/java.base/share/classes/java/lang/String.java @@ -1735,36 +1735,6 @@ public int offsetByCodePoints(int index, int codePointOffset) { return Character.offsetByCodePoints(this, index, codePointOffset); } - /** - * Copies characters from this string into the destination character - * array. - *

    - * The first character to be copied is at index {@code srcBegin}; - * the last character to be copied is at index {@code srcEnd-1} - * (thus the total number of characters to be copied is - * {@code srcEnd-srcBegin}). The characters are copied into the - * subarray of {@code dst} starting at index {@code dstBegin} - * and ending at index: - *

    -     *     dstBegin + (srcEnd-srcBegin) - 1
    -     * 
    - * - * @param srcBegin index of the first character in the string - * to copy. - * @param srcEnd index after the last character in the string - * to copy. - * @param dst the destination array. - * @param dstBegin the start offset in the destination array. - * @throws IndexOutOfBoundsException If any of the following - * is true: - *
    • {@code srcBegin} is negative. - *
    • {@code srcBegin} is greater than {@code srcEnd} - *
    • {@code srcEnd} is greater than the length of this - * string - *
    • {@code dstBegin} is negative - *
    • {@code dstBegin+(srcEnd-srcBegin)} is larger than - * {@code dst.length}
    - */ @Override public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) { checkBoundsBeginEnd(srcBegin, srcEnd, length()); diff --git a/src/java.base/share/classes/java/lang/StringBuffer.java b/src/java.base/share/classes/java/lang/StringBuffer.java index 1aeceb9598553..2546a84f39cae 100644 --- a/src/java.base/share/classes/java/lang/StringBuffer.java +++ b/src/java.base/share/classes/java/lang/StringBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -279,9 +279,6 @@ public synchronized int offsetByCodePoints(int index, int codePointOffset) { return super.offsetByCodePoints(index, codePointOffset); } - /** - * @throws IndexOutOfBoundsException {@inheritDoc} - */ @Override public synchronized void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) diff --git a/src/java.base/share/classes/java/lang/StringBuilder.java b/src/java.base/share/classes/java/lang/StringBuilder.java index d7ff5ee35d706..5752f673b183f 100644 --- a/src/java.base/share/classes/java/lang/StringBuilder.java +++ b/src/java.base/share/classes/java/lang/StringBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it From 99fcefbdca5650bc8ba38ca621f1f9a083ed91fe Mon Sep 17 00:00:00 2001 From: Markus KARG Date: Wed, 30 Apr 2025 15:29:23 +0000 Subject: [PATCH 13/15] Applied changes proposed by Joe and Jaikiran: Using @inheritDoc to get JavaDocs without @since. --- .../share/classes/java/lang/AbstractStringBuilder.java | 3 +++ src/java.base/share/classes/java/lang/String.java | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/java.base/share/classes/java/lang/AbstractStringBuilder.java b/src/java.base/share/classes/java/lang/AbstractStringBuilder.java index 02a32129e6c01..1ae92b6df367e 100644 --- a/src/java.base/share/classes/java/lang/AbstractStringBuilder.java +++ b/src/java.base/share/classes/java/lang/AbstractStringBuilder.java @@ -483,6 +483,9 @@ public int offsetByCodePoints(int index, int codePointOffset) { index, codePointOffset); } + /** + * {@inheritDoc CharSequence} + */ @Override public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) { diff --git a/src/java.base/share/classes/java/lang/String.java b/src/java.base/share/classes/java/lang/String.java index ed84445dbe731..c6e2f4ca0bc93 100644 --- a/src/java.base/share/classes/java/lang/String.java +++ b/src/java.base/share/classes/java/lang/String.java @@ -1735,6 +1735,9 @@ public int offsetByCodePoints(int index, int codePointOffset) { return Character.offsetByCodePoints(this, index, codePointOffset); } + /** + * {@inheritDoc CharSequence} + */ @Override public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) { checkBoundsBeginEnd(srcBegin, srcEnd, length()); From 342bc84243f6d689b9eef040b0c4afff3e102bde Mon Sep 17 00:00:00 2001 From: Markus KARG Date: Thu, 1 May 2025 07:18:52 +0000 Subject: [PATCH 14/15] Applied workaround proposed by Joe: Using component @inheritDoc to enforce getChars section in JavaDocs --- src/java.base/share/classes/java/lang/String.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/java.base/share/classes/java/lang/String.java b/src/java.base/share/classes/java/lang/String.java index c6e2f4ca0bc93..40638c6cf9f33 100644 --- a/src/java.base/share/classes/java/lang/String.java +++ b/src/java.base/share/classes/java/lang/String.java @@ -1737,6 +1737,11 @@ public int offsetByCodePoints(int index, int codePointOffset) { /** * {@inheritDoc CharSequence} + * @param srcBegin {@inheritDoc CharSequence} + * @param srcEnd {@inheritDoc CharSequence} + * @param dst {@inheritDoc CharSequence} + * @param dstBegin {@inheritDoc CharSequence} + * @throws IndexOutOfBoundsException {@inheritDoc CharSequence} */ @Override public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) { From 62a6867b66c16f1388746d525356378ac8f09d9f Mon Sep 17 00:00:00 2001 From: Markus KARG Date: Thu, 1 May 2025 10:40:03 +0200 Subject: [PATCH 15/15] Applied proposal by Daniel: If there's no change to this file the copyright year update could be reverted? --- src/java.base/share/classes/java/lang/StringBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/java.base/share/classes/java/lang/StringBuilder.java b/src/java.base/share/classes/java/lang/StringBuilder.java index 5752f673b183f..d7ff5ee35d706 100644 --- a/src/java.base/share/classes/java/lang/StringBuilder.java +++ b/src/java.base/share/classes/java/lang/StringBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it