-
Bug
-
Resolution: Fixed
-
P2
-
16
-
b27
-
Verified
Integration of JDK-8254082 introduced regression. Running the following code
public class Test {
public static void main(String... args) {
new StringBuffer("abc").insert(0, "def", 1, 3);
}
}
now leads to
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: arraycopy: last source index 4 out of bounds for byte[3]
at java.base/java.lang.System.arraycopy(Native Method)
at java.base/java.lang.String.getBytes(String.java:3624)
at java.base/java.lang.AbstractStringBuilder.putStringAt(AbstractStringBuilder.java:1720)
at java.base/java.lang.AbstractStringBuilder.insert(AbstractStringBuilder.java:1301)
at java.base/java.lang.StringBuffer.insert(StringBuffer.java:588)
at Test.main(Test.java:3)
Please see the specification
https://docs.oracle.com/en/java/javase/15/docs/api/java.base/java/lang/StringBuffer.html#insert(int,java.lang.CharSequence,int,int)
to check input data validity
public class Test {
public static void main(String... args) {
new StringBuffer("abc").insert(0, "def", 1, 3);
}
}
now leads to
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: arraycopy: last source index 4 out of bounds for byte[3]
at java.base/java.lang.System.arraycopy(Native Method)
at java.base/java.lang.String.getBytes(String.java:3624)
at java.base/java.lang.AbstractStringBuilder.putStringAt(AbstractStringBuilder.java:1720)
at java.base/java.lang.AbstractStringBuilder.insert(AbstractStringBuilder.java:1301)
at java.base/java.lang.StringBuffer.insert(StringBuffer.java:588)
at Test.main(Test.java:3)
Please see the specification
https://docs.oracle.com/en/java/javase/15/docs/api/java.base/java/lang/StringBuffer.html#insert(int,java.lang.CharSequence,int,int)
to check input data validity
- relates to
-
JDK-8254082 AbstractStringBuilder.insert(int dstOffset, CharSequence s, int start, int end) is missing fast-path for String
- Resolved