/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4486841 7040220
* @summary Test UTF-8 charset
*/
public class TestUTF8 {
throws Exception {
if (testDirect) {
} else {
}
return cc;
}
throws Exception {
if (testDirect) {
} else {
}
}
if (len == 0)
return ca;
.reset();
try {
if (!cr.isUnderflow())
cr.throwException();
if (!cr.isUnderflow())
cr.throwException();
} catch (CharacterCodingException x) {
throw new Error(x);
}
}
throws Exception {
if (testDirect) {
} else {
}
return bb;
}
throws Exception {
if (testDirect) {
} else {
}
}
static char[] getUTFChars() {
(0x110000 - 0x10000) * 2]; //supp
int pos = 0;
int i = 0;
for (i = 0; i < 0xd800; i++)
for (i = 0xe000; i < 0x10000; i++)
for (i = 0x10000; i < 0x110000; i++) {
}
return cc;
}
return 3;
}
char[] cc = getUTFChars();
}
}
}
}
}
int bpos = 0;
int cpos = 0;
for (int i = 0x10000; i < 0x110000; i++) {
cpos += 2;
}
}
}
// new String(bb, csn).getBytes(csn) will not return
// the 6 bytes surrogates as in bb, so only test
// toCharArray() here.
}
}
char[] cc = getUTFChars();
}
}
}
// The first byte is the length of malformed bytes
static byte[][] malformed = {
// One-byte sequences:
{1, (byte)0xFF },
{1, (byte)0xC0 },
{1, (byte)0x80 },
{1, (byte)0xFF, (byte)0xFF}, // all ones
{1, (byte)0xA0, (byte)0x80}, // 101x first byte first nibble
// Two-byte sequences:
{1, (byte)0xC0, (byte)0x80}, // invalid first byte
{1, (byte)0xC1, (byte)0xBF}, // invalid first byte
{1, (byte)0xC2, (byte)0x00}, // invalid second byte
{1, (byte)0xC2, (byte)0xC0}, // invalid second byte
{1, (byte)0xD0, (byte)0x00}, // invalid second byte
{1, (byte)0xD0, (byte)0xC0}, // invalid second byte
{1, (byte)0xDF, (byte)0x00}, // invalid second byte
{1, (byte)0xDF, (byte)0xC0}, // invalid second byte
// Three-byte sequences
{1, (byte)0xE0, (byte)0x80, (byte)0x80}, // 111x first byte first nibble
{1, (byte)0xE0, (byte)0x80, (byte)0x80 }, // U+0000 zero-padded
{1, (byte)0xE0, (byte)0x81, (byte)0xBF }, // U+007F zero-padded
{1, (byte)0xE0, (byte)0x9F, (byte)0xBF }, // U+07FF zero-padded
{1, (byte)0xE0, (byte)0xC0, (byte)0xBF }, // invalid second byte
{2, (byte)0xE0, (byte)0xA0, (byte)0x7F }, // invalid third byte
{2, (byte)0xE0, (byte)0xA0, (byte)0xC0 }, // invalid third byte
{1, (byte)0xFF, (byte)0xFF, (byte)0xFF }, // all ones
{1, (byte)0xE0, (byte)0xC0, (byte)0x80 }, // invalid second byte
{1, (byte)0xE0, (byte)0x80, (byte)0xC0 }, // invalid first byte
// Four-byte sequences
{1, (byte)0xF0, (byte)0x80, (byte)0x80, (byte)0x80 }, // U+0000 zero-padded
{1, (byte)0xF0, (byte)0x80, (byte)0x81, (byte)0xBF }, // U+007F zero-padded
{1, (byte)0xF0, (byte)0x80, (byte)0x9F, (byte)0xBF }, // U+007F zero-padded
{1, (byte)0xF0, (byte)0x8F, (byte)0xBF, (byte)0xBF }, // U+07FF zero-padded
{1, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF }, // all ones
{1, (byte)0xF0, (byte)0x80, (byte)0x80, (byte)0x80}, // invalid second byte
{1, (byte)0xF0, (byte)0xC0, (byte)0x80, (byte)0x80 }, // invalid second byte
{2, (byte)0xF0, (byte)0x90, (byte)0xC0, (byte)0x80 }, // invalid third byte
{3, (byte)0xF0, (byte)0x90, (byte)0x80, (byte)0xC0 }, // invalid third byte
{1, (byte)0xF1, (byte)0xC0, (byte)0x80, (byte)0x80 }, // invalid second byte
{2, (byte)0xF1, (byte)0x80, (byte)0xC0, (byte)0x80 }, // invalid third byte
{3, (byte)0xF1, (byte)0x80, (byte)0x80, (byte)0xC0 }, // invalid forth byte
{1, (byte)0xF4, (byte)0x90, (byte)0x80, (byte)0xC0 }, // out-range 4-byte
{1, (byte)0xF4, (byte)0xC0, (byte)0x80, (byte)0xC0 }, // out-range 4-byte
{1, (byte)0xF5, (byte)0x80, (byte)0x80, (byte)0xC0 }, // out-range 4-byte
// Five-byte sequences
{5, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x80}, // invalid first byte
{5, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x80 }, // U+0000 zero-padded
{5, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x81, (byte)0xBF }, // U+007F zero-padded
{5, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x9F, (byte)0xBF }, // U+07FF zero-padded
{5, (byte)0xF8, (byte)0x80, (byte)0x8F, (byte)0xBF, (byte)0xBF }, // U+FFFF zero-padded
{1, (byte)0xF8, (byte)0xC0, (byte)0x80, (byte)0x80, (byte)0x80},
{2, (byte)0xF8, (byte)0x80, (byte)0xC0, (byte)0x80, (byte)0x80 },
{3, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0xC1, (byte)0xBF },
{4, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x9F, (byte)0xC0 },
// Six-byte sequences
{6, (byte)0xFC, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x80 }, // U+0000 zero-padded
{6, (byte)0xFC, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x81, (byte)0xBF }, // U+007F zero-padded
{6, (byte)0xFC, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x9F, (byte)0xBF }, // U+07FF zero-padded
{6, (byte)0xFC, (byte)0x80, (byte)0x80, (byte)0x8F, (byte)0xBF, (byte)0xBF }, // U+FFFF zero-padded
{1, (byte)0xF8, (byte)0xC0, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x80 },
{2, (byte)0xF8, (byte)0x80, (byte)0xC0, (byte)0x80, (byte)0x80, (byte)0x80 },
{3, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0xC1, (byte)0xBF, (byte)0x80 },
{4, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x9F, (byte)0xC0, (byte)0x80 },
{5, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x9F, (byte)0x80, (byte)0xC0 },
};
boolean failed = false;
for (boolean direct: new boolean[] {false, true}) {
}
if (!cr.isMalformed()) {
failed = true;
failed = true;
}
failed = true;
}
}
}
if (failed)
}
if (direct) {
} else {
}
return false;
}
return true;
}
boolean failed = false;
int[][] Flows = {
//inpos, inLen, outPos, outLen, inPosEP, outposEP, under(0)/over(1)
// underflow
};
for (boolean direct: new boolean[] {false, true}) {
failed = true;
}
}}}
if (failed)
}
checkRoundtrip("UTF-8");
check6ByteSurrs("UTF-8");
//compare("UTF-8", "UTF-8-OLD");
checkMalformed("UTF-8");
checkUnderOverflow("UTF-8");
}
}