< prev index next >

test/jdk/java/lang/StringBuffer/CompactStringBuffer.java

Print this page
rev 54318 : 8221430: StringBuffer(CharSequence) constructor truncates when -XX:-CompactStrings specified
Reviewed-by: igerasim, rriggs
Contributed-by: Andrew Leonard <andrew_m_leonard@uk.ibm.com>

*** 1,7 **** /* ! * Copyright (c) 2015, 2018, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2015, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 28,38 **** import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; /* * @test ! * @bug 8077559 * @summary Tests Compact String. This test is testing StringBuffer * behavior related to Compact String. * @run testng/othervm -XX:+CompactStrings CompactStringBuffer * @run testng/othervm -XX:-CompactStrings CompactStringBuffer */ --- 28,38 ---- import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; /* * @test ! * @bug 8077559 8221430 * @summary Tests Compact String. This test is testing StringBuffer * behavior related to Compact String. * @run testng/othervm -XX:+CompactStrings CompactStringBuffer * @run testng/othervm -XX:-CompactStrings CompactStringBuffer */
*** 438,447 **** --- 438,453 ---- //////////////////////////////////////////////////////////////////// check(new StringBuffer().append(ascii).append(1.23456).toString(), "abcdefgh1.23456"); check(new StringBuffer().append(bmp).append(1.23456).toString(), "\u4e00\u4e01\u4e02\u4e03\u4e04\u4e05\u4e06\u4e07\u4e081.23456"); + + //////////////////////////////////////////////////////////////////// + check(new StringBuffer((CharSequence)new StringBuffer(ascii)).toString(), + ascii); + check(new StringBuffer((CharSequence)new StringBuffer(asciiMixed)).toString(), + asciiMixed); } private void checkGetChars(StringBuffer sb, int srcBegin, int srcEnd, char expected[]) { char[] dst = new char[srcEnd - srcBegin];
< prev index next >