src/java.base/share/classes/java/lang/AbstractStringBuilder.java
changeset 53653 868611f0adc3
parent 52156 1801fada294a
child 53977 723f665d0596
--- a/src/java.base/share/classes/java/lang/AbstractStringBuilder.java	Wed Feb 06 00:20:37 2019 +0100
+++ b/src/java.base/share/classes/java/lang/AbstractStringBuilder.java	Tue Feb 05 17:05:40 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, 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
@@ -92,6 +92,19 @@
     }
 
     /**
+     * Creates an AbstractStringBuilder with the specified coder and with
+     * the initial capacity equal to the smaller of (capacity + addition)
+     * and Integer.MAX_VALUE.
+     */
+    AbstractStringBuilder(byte coder, int capacity, int addition) {
+        this.coder = coder;
+        capacity = (capacity < Integer.MAX_VALUE - addition)
+                ? capacity + addition : Integer.MAX_VALUE;
+        value = (coder == LATIN1)
+                ? new byte[capacity] : StringUTF16.newBytesFor(capacity);
+    }
+
+    /**
      * Compares the objects of two AbstractStringBuilder implementations lexicographically.
      *
      * @since 11