Index: trunk/modules/luni/src/main/java/java/lang/String.java =================================================================== --- trunk/modules/luni/src/main/java/java/lang/String.java (revision 438425) +++ trunk/modules/luni/src/main/java/java/lang/String.java (working copy) @@ -358,8 +358,14 @@ Charset charset = getCharset(encoding); int result; - CharBuffer cb = charset - .decode(ByteBuffer.wrap(data, start, length)); + CharBuffer cb; + try { + cb = charset.decode(ByteBuffer.wrap(data, start, length)); + } catch (Exception e) { + // do nothing. according to spec: + // behavior is unspecified for invalid array + cb = CharBuffer.wrap("\u003f".toCharArray()); + } if ((result = cb.length()) > 0) { value = cb.array(); count = result;