summaryrefslogtreecommitdiffstats
path: root/luni/src/main/java/java/lang/String.java
diff options
context:
space:
mode:
Diffstat (limited to 'luni/src/main/java/java/lang/String.java')
-rw-r--r--luni/src/main/java/java/lang/String.java22
1 files changed, 6 insertions, 16 deletions
diff --git a/luni/src/main/java/java/lang/String.java b/luni/src/main/java/java/lang/String.java
index efd4210..f3aeb64 100644
--- a/luni/src/main/java/java/lang/String.java
+++ b/luni/src/main/java/java/lang/String.java
@@ -168,17 +168,7 @@ public final class String implements Serializable, Comparable<String>, CharSeque
* if {@code byteCount < 0 || offset < 0 || offset + byteCount > data.length}.
*/
public String(byte[] data, int offset, int byteCount) {
- if ((offset | byteCount) < 0 || byteCount > data.length - offset) {
- throw failedBoundsCheck(data.length, offset, byteCount);
- }
- CharBuffer cb = Charset.defaultCharset().decode(ByteBuffer.wrap(data, offset, byteCount));
- this.count = cb.length();
- this.offset = 0;
- if (count > 0) {
- value = cb.array();
- } else {
- value = EmptyArray.CHAR;
- }
+ this(data, offset, byteCount, Charset.defaultCharset());
}
/**
@@ -524,7 +514,7 @@ outer:
*/
public String(int[] codePoints, int offset, int count) {
if (codePoints == null) {
- throw new NullPointerException();
+ throw new NullPointerException("codePoints == null");
}
if ((offset | count) < 0 || count > codePoints.length - offset) {
throw failedBoundsCheck(codePoints.length, offset, count);
@@ -1232,7 +1222,7 @@ outer:
*/
public boolean regionMatches(int thisStart, String string, int start, int length) {
if (string == null) {
- throw new NullPointerException();
+ throw new NullPointerException("string == null");
}
if (start < 0 || string.count - start < length) {
return false;
@@ -1729,7 +1719,7 @@ outer:
*/
public boolean contentEquals(CharSequence cs) {
if (cs == null) {
- throw new NullPointerException();
+ throw new NullPointerException("cs == null");
}
int len = cs.length();
@@ -1922,7 +1912,7 @@ outer:
*/
public boolean contains(CharSequence cs) {
if (cs == null) {
- throw new NullPointerException();
+ throw new NullPointerException("cs == null");
}
return indexOf(cs.toString()) >= 0;
}
@@ -1991,7 +1981,7 @@ outer:
*/
public static String format(Locale locale, String format, Object... args) {
if (format == null) {
- throw new NullPointerException("null format argument");
+ throw new NullPointerException("format == null");
}
int bufferSize = format.length() + (args == null ? 0 : args.length * 10);
Formatter f = new Formatter(new StringBuilder(bufferSize), locale);