test/sun/nio/cs/TestStringCoding.java
Print this page
@@ -22,11 +22,11 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
- @bug 6636323 6636319
+ @bug 6636323 6636319 7040220
@summary Test if StringCoding and NIO result have the same de/encoding result
* @run main/othervm/timeout=2000 TestStringCoding
*/
import java.util.*;
@@ -109,10 +109,12 @@
throw new RuntimeException("new String(cs) failed -> " + cs.name());
//encode unmappable surrogates
if (enc instanceof sun.nio.cs.ArrayEncoder &&
cs.contains(Charset.forName("ASCII"))) {
+ if (cs.name().equals("UTF-8")) // utf8 handles surrogates
+ return;
enc.replaceWith(new byte[] { (byte)'A'});
sun.nio.cs.ArrayEncoder cae = (sun.nio.cs.ArrayEncoder)enc;
String str = "ab\uD800\uDC00\uD800\uDC00cd";
byte[] ba = new byte[str.length() - 2];