Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8257511

JDK-8254082 brings regression to AbstractStringBuilder.insert(int dstOffset, CharSequence s, int start, int end)

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b27
    • Verification:
      Verified

      Description

      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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              redestad Claes Redestad
              Reporter:
              dbessono Dmitry Bessonov
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: