-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
6
-
x86
-
windows_xp
FULL PRODUCT VERSION :
- The JDK version on which this problem can be reproduced.
All JDK 5 + 6 releases
A DESCRIPTION OF THE PROBLEM :
\uFFFE and \uFFFF should be valued as malformed. Here they are denoted as "Not a character": http://www.decodeunicode.org/de/u+fffe
So IMHO they should be valued as *malformed*, but the current JDK's encoders return *unmappable*.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
run the test class
EXPECTED VERSUS ACTUAL BEHAVIOR :
Expected: PASSED
Actual: FAILED
- Additional configuration information that may be relevant.
Executed by help of NetBeans IDE
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package sun.nio.cs;
import java.io.*;
import java.nio.*;
import java.nio.charset.*;
import java.util.*;
import org.junit.*;
import static org.junit.Assert.*;
import static org.junit.Assume.*;
import org.junit.runner.*;
import org.junit.runners.*;
import org.junit.runners.Parameterized.*;
/**
*
*/
@RunWith(Parameterized.class)
public class FFFETest {
// test parameters:
private static final Object[][] PARAMETERS = new Object[][]{
// standard charsets:
/* 0 */ {"IBM437"},
/* 1 */ {"IBM737"},
/* 2 */ {"IBM775"},
/* 3 */ {"IBM850"},
/* 4 */ {"IBM852"},
/* 5 */ {"IBM855"},
/* 6 */ {"IBM857"},
/* 7 */ {"IBM00858"},
/* 8 */ {"IBM862"},
/* 9 */ {"IBM866"},
/* 10 */ {"x-IBM874"},
/* 11 */ {"ISO-8859-1"},
/* 12 */ {"ISO-8859-13"},
/* 13 */ {"ISO-8859-15"},
/* 14 */ {"ISO-8859-2"},
/* 15 */ {"ISO-8859-4"},
/* 16 */ {"ISO-8859-5"},
/* 17 */ {"ISO-8859-7"},
/* 18 */ {"ISO-8859-9"},
/* 19 */ {"KOI8-R"},
/* 20 */ {"KOI8-U"},
/* 21 */ {"windows-1250"},
/* 22 */ {"windows-1251"},
/* 23 */ {"windows-1252"},
/* 24 */ {"windows-1253"},
/* 25 */ {"windows-1254"},
/* 26 */ {"windows-1257"},
/* 27 */ {"US-ASCII"},
// extended charsets:
/* 28 */ {"EUC-JP"},
/* 29 */ {"x-euc-jp-linux"},
/* 30 */ {"x-eucjp-open"},
/* 31 */ {"IBM037"},
/* 32 */ {"IBM1006"},
/* 33 */ {"IBM1025"},
/* 34 */ {"IBM1026"},
/* 35 */ {"IBM1046"},
/* 36 */ {"IBM1047"},
/* 37 */ {"IBM1097"},
/* 38 */ {"IBM1098"},
/* 39 */ {"IBM1112"},
/* 40 */ {"IBM1122"},
/* 41 */ {"IBM1123"},
/* 42 */ {"IBM1124"},
/* 43 */ {"IBM01140"},
/* 44 */ {"IBM01141"},
/* 45 */ {"IBM01142"},
/* 46 */ {"IBM01143"},
/* 47 */ {"IBM01144"},
/* 48 */ {"IBM01145"},
/* 49 */ {"IBM01146"},
/* 50 */ {"IBM01147"},
/* 51 */ {"IBM01148"},
/* 52 */ {"IBM01149"},
/* 53 */ {"IBM273"},
/* 54 */ {"IBM277"},
/* 55 */ {"IBM278"},
/* 56 */ {"IBM280"},
/* 57 */ {"IBM284"},
/* 58 */ {"IBM285"},
/* 59 */ {"IBM297"},
/* 60 */ {"IBM420"},
/* 61 */ {"IBM424"},
/* 62 */ {"IBM500"},
/* 63 */ {"IBM838"},
/* 64 */ {"IBM856"},
/* 65 */ {"IBM860"},
/* 66 */ {"IBM861"},
/* 67 */ {"IBM863"},
/* 68 */ {"IBM864"},
/* 69 */ {"IBM865"},
/* 70 */ {"IBM868"},
/* 71 */ {"IBM869"},
/* 72 */ {"IBM870"},
/* 73 */ {"IBM871"},
/* 74 */ {"IBM875"},
/* 75 */ {"IBM918"},
/* 76 */ {"IBM921"},
/* 77 */ {"IBM922"},
/* 78 */ {"ISO-8859-11"},
/* 79 */ {"ISO-8859-3"},
/* 80 */ {"ISO-8859-6"},
/* 81 */ {"ISO-8859-8"},
/* 82 */ {"JIS_X0201"},
/* 83 */ {"windows-1255"},
/* 84 */ {"windows-1256"},
/* 85 */ {"windows-1258"},
/* 86 */ {"windows-874"},
/* 87 */ {"windows-31j"},
/* 88 */ {"x-PCK"},
/* 89 */ {"Shift_JIS"},
/* 90 */ {"TIS-620"},
/* 91 */ {"ISO-2022-CN"},
/* 92 */ {"ISO-2022-JP"},
};
private static final int PROCESS_SINGLE = -1;
private static final int SAMPLES = 2;
private static final char[][] IN_CHARS = new char[SAMPLES][];
private static int parametersInTest = 0;
// parameters:
private static Charset cs;
// temp:
private CharsetEncoder encoder;
// results:
private CharBuffer[] inChars = new CharBuffer[SAMPLES];
private ByteBuffer[] outBytes = new ByteBuffer[SAMPLES];
public FFFETest(String charsetName) throws IOException {
cs = Charset.forName(charsetName);
System.out.println("\n>>> PARAMETERS["+(parametersInTest++)+"]");
}
@Parameters
public static Collection data() {
List parameters = new ArrayList(Arrays.asList(PROCESS_SINGLE < 0 ?
PARAMETERS : new Object[]{PARAMETERS[PROCESS_SINGLE]}));
try {
for (int idx = PROCESS_SINGLE; PARAMETERS[idx][0].equals(PARAMETERS[++idx][0]);)
parameters.add(PARAMETERS[idx]);
} catch (ArrayIndexOutOfBoundsException e) {}
return parameters;
}
@Before
public void setUp() throws Exception {
IN_CHARS[0] = new char[] {'\u0041', '\u0042', '\uFFFE', };
IN_CHARS[1] = new char[] {'\u0041', '\u0042', '\uFFFF', };
assumeTrue(cs.canEncode());
encoder = cs.newEncoder();
for (int i=0; i<SAMPLES; i++) {
inChars[i] = CharBuffer.wrap(IN_CHARS[i]);
outBytes[i] = ByteBuffer.allocate((int)(IN_CHARS[i].length*encoder.maxBytesPerChar()));
}
}
@Test(timeout=300)
public void testEncoder() throws CharacterCodingException {
assumeTrue(cs.canEncode());
System.out.println("NOW TEST > ["+cs+"] encoder");
for (int i=0; i<SAMPLES; i++) {
CoderResult result = null;
int position = 0;
while (inChars[i].hasRemaining()) {
position = inChars[i].position();
char c = inChars[i].get();
if (position < 2)
assertTrue("canEncode(char)", encoder.canEncode(c));
else
assertFalse("canEncode(char)", encoder.canEncode(c));
}
encoder.reset();
inChars[i].rewind();
result = encoder.encode((CharBuffer)inChars[i], outBytes[i], true);
position = inChars[i].position();
assertEquals("position", 2, position);
assertEquals("encode()", CoderResult.malformedForLength(1), result);
if (result.isOverflow())
result.throwException();
}
}
}
---------- END SOURCE ----------
- The JDK version on which this problem can be reproduced.
All JDK 5 + 6 releases
A DESCRIPTION OF THE PROBLEM :
\uFFFE and \uFFFF should be valued as malformed. Here they are denoted as "Not a character": http://www.decodeunicode.org/de/u+fffe
So IMHO they should be valued as *malformed*, but the current JDK's encoders return *unmappable*.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
run the test class
EXPECTED VERSUS ACTUAL BEHAVIOR :
Expected: PASSED
Actual: FAILED
- Additional configuration information that may be relevant.
Executed by help of NetBeans IDE
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package sun.nio.cs;
import java.io.*;
import java.nio.*;
import java.nio.charset.*;
import java.util.*;
import org.junit.*;
import static org.junit.Assert.*;
import static org.junit.Assume.*;
import org.junit.runner.*;
import org.junit.runners.*;
import org.junit.runners.Parameterized.*;
/**
*
*/
@RunWith(Parameterized.class)
public class FFFETest {
// test parameters:
private static final Object[][] PARAMETERS = new Object[][]{
// standard charsets:
/* 0 */ {"IBM437"},
/* 1 */ {"IBM737"},
/* 2 */ {"IBM775"},
/* 3 */ {"IBM850"},
/* 4 */ {"IBM852"},
/* 5 */ {"IBM855"},
/* 6 */ {"IBM857"},
/* 7 */ {"IBM00858"},
/* 8 */ {"IBM862"},
/* 9 */ {"IBM866"},
/* 10 */ {"x-IBM874"},
/* 11 */ {"ISO-8859-1"},
/* 12 */ {"ISO-8859-13"},
/* 13 */ {"ISO-8859-15"},
/* 14 */ {"ISO-8859-2"},
/* 15 */ {"ISO-8859-4"},
/* 16 */ {"ISO-8859-5"},
/* 17 */ {"ISO-8859-7"},
/* 18 */ {"ISO-8859-9"},
/* 19 */ {"KOI8-R"},
/* 20 */ {"KOI8-U"},
/* 21 */ {"windows-1250"},
/* 22 */ {"windows-1251"},
/* 23 */ {"windows-1252"},
/* 24 */ {"windows-1253"},
/* 25 */ {"windows-1254"},
/* 26 */ {"windows-1257"},
/* 27 */ {"US-ASCII"},
// extended charsets:
/* 28 */ {"EUC-JP"},
/* 29 */ {"x-euc-jp-linux"},
/* 30 */ {"x-eucjp-open"},
/* 31 */ {"IBM037"},
/* 32 */ {"IBM1006"},
/* 33 */ {"IBM1025"},
/* 34 */ {"IBM1026"},
/* 35 */ {"IBM1046"},
/* 36 */ {"IBM1047"},
/* 37 */ {"IBM1097"},
/* 38 */ {"IBM1098"},
/* 39 */ {"IBM1112"},
/* 40 */ {"IBM1122"},
/* 41 */ {"IBM1123"},
/* 42 */ {"IBM1124"},
/* 43 */ {"IBM01140"},
/* 44 */ {"IBM01141"},
/* 45 */ {"IBM01142"},
/* 46 */ {"IBM01143"},
/* 47 */ {"IBM01144"},
/* 48 */ {"IBM01145"},
/* 49 */ {"IBM01146"},
/* 50 */ {"IBM01147"},
/* 51 */ {"IBM01148"},
/* 52 */ {"IBM01149"},
/* 53 */ {"IBM273"},
/* 54 */ {"IBM277"},
/* 55 */ {"IBM278"},
/* 56 */ {"IBM280"},
/* 57 */ {"IBM284"},
/* 58 */ {"IBM285"},
/* 59 */ {"IBM297"},
/* 60 */ {"IBM420"},
/* 61 */ {"IBM424"},
/* 62 */ {"IBM500"},
/* 63 */ {"IBM838"},
/* 64 */ {"IBM856"},
/* 65 */ {"IBM860"},
/* 66 */ {"IBM861"},
/* 67 */ {"IBM863"},
/* 68 */ {"IBM864"},
/* 69 */ {"IBM865"},
/* 70 */ {"IBM868"},
/* 71 */ {"IBM869"},
/* 72 */ {"IBM870"},
/* 73 */ {"IBM871"},
/* 74 */ {"IBM875"},
/* 75 */ {"IBM918"},
/* 76 */ {"IBM921"},
/* 77 */ {"IBM922"},
/* 78 */ {"ISO-8859-11"},
/* 79 */ {"ISO-8859-3"},
/* 80 */ {"ISO-8859-6"},
/* 81 */ {"ISO-8859-8"},
/* 82 */ {"JIS_X0201"},
/* 83 */ {"windows-1255"},
/* 84 */ {"windows-1256"},
/* 85 */ {"windows-1258"},
/* 86 */ {"windows-874"},
/* 87 */ {"windows-31j"},
/* 88 */ {"x-PCK"},
/* 89 */ {"Shift_JIS"},
/* 90 */ {"TIS-620"},
/* 91 */ {"ISO-2022-CN"},
/* 92 */ {"ISO-2022-JP"},
};
private static final int PROCESS_SINGLE = -1;
private static final int SAMPLES = 2;
private static final char[][] IN_CHARS = new char[SAMPLES][];
private static int parametersInTest = 0;
// parameters:
private static Charset cs;
// temp:
private CharsetEncoder encoder;
// results:
private CharBuffer[] inChars = new CharBuffer[SAMPLES];
private ByteBuffer[] outBytes = new ByteBuffer[SAMPLES];
public FFFETest(String charsetName) throws IOException {
cs = Charset.forName(charsetName);
System.out.println("\n>>> PARAMETERS["+(parametersInTest++)+"]");
}
@Parameters
public static Collection data() {
List parameters = new ArrayList(Arrays.asList(PROCESS_SINGLE < 0 ?
PARAMETERS : new Object[]{PARAMETERS[PROCESS_SINGLE]}));
try {
for (int idx = PROCESS_SINGLE; PARAMETERS[idx][0].equals(PARAMETERS[++idx][0]);)
parameters.add(PARAMETERS[idx]);
} catch (ArrayIndexOutOfBoundsException e) {}
return parameters;
}
@Before
public void setUp() throws Exception {
IN_CHARS[0] = new char[] {'\u0041', '\u0042', '\uFFFE', };
IN_CHARS[1] = new char[] {'\u0041', '\u0042', '\uFFFF', };
assumeTrue(cs.canEncode());
encoder = cs.newEncoder();
for (int i=0; i<SAMPLES; i++) {
inChars[i] = CharBuffer.wrap(IN_CHARS[i]);
outBytes[i] = ByteBuffer.allocate((int)(IN_CHARS[i].length*encoder.maxBytesPerChar()));
}
}
@Test(timeout=300)
public void testEncoder() throws CharacterCodingException {
assumeTrue(cs.canEncode());
System.out.println("NOW TEST > ["+cs+"] encoder");
for (int i=0; i<SAMPLES; i++) {
CoderResult result = null;
int position = 0;
while (inChars[i].hasRemaining()) {
position = inChars[i].position();
char c = inChars[i].get();
if (position < 2)
assertTrue("canEncode(char)", encoder.canEncode(c));
else
assertFalse("canEncode(char)", encoder.canEncode(c));
}
encoder.reset();
inChars[i].rewind();
result = encoder.encode((CharBuffer)inChars[i], outBytes[i], true);
position = inChars[i].position();
assertEquals("position", 2, position);
assertEquals("encode()", CoderResult.malformedForLength(1), result);
if (result.isOverflow())
result.throwException();
}
}
}
---------- END SOURCE ----------