-
Bug
-
Resolution: Fixed
-
P4
-
8, 9, 17, 21, 22
-
b03
-
generic
-
generic
-
Verified
FULL PRODUCT VERSION :
java version "1.8.0_102"
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux, version 3.2.0-99-generic-pae
Mac OS X, version 10.8.5
A DESCRIPTION OF THE PROBLEM :
The following charsets returned by Charset.availableCharsets() does not contain itself
CESU-8
UTF-32
UTF-32BE
UTF-32LE
x-eucJP-Open
x-JISAutoDetect
X-UTF-32BE-BOM
X-UTF-32LE-BOM
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Charset(CESU-8).contains(Charset(CESU-8)) returns true
Charset(UTF-32).contains(Charset(UTF-32)) returns true
Charset(UTF-32BE).contains(Charset(UTF-32BE)) returns true
Charset(UTF-32LE).contains(Charset(UTF-32LE)) returns true
Charset(x-eucJP-Open).contains(Charset(x-eucJP-Open)) returns true
Charset(x-JISAutoDetect).contains(Charset(x-JISAutoDetect)) returns true
Charset(X-UTF-32BE-BOM).contains(Charset(X-UTF-32BE-BOM)) returns true
Charset(X-UTF-32LE-BOM).contains(Charset(X-UTF-32LE-BOM)) returns true
ACTUAL -
Charset(CESU-8).contains(Charset(CESU-8)) returns false
Charset(UTF-32).contains(Charset(UTF-32)) returns false
Charset(UTF-32BE).contains(Charset(UTF-32BE)) returns false
Charset(UTF-32LE).contains(Charset(UTF-32LE)) returns false
Charset(x-eucJP-Open).contains(Charset(x-eucJP-Open)) returns false
Charset(x-JISAutoDetect).contains(Charset(x-JISAutoDetect)) returns false
Charset(X-UTF-32BE-BOM).contains(Charset(X-UTF-32BE-BOM)) returns false
Charset(X-UTF-32LE-BOM).contains(Charset(X-UTF-32LE-BOM)) returns false
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.Map;
import java.nio.charset.Charset;
/**
* Each charset from all available charsets must contains itself.
*/
public class ContainsTest {
public int callSystemGC = 1;
public static void main(String[] args) {
boolean failed = false;
for (Map.Entry<String, Charset> entry : Charset.availableCharsets().entrySet()) {
String name = entry.getKey();
Charset charset = entry.getValue();
boolean contains = charset.contains(charset);
if (!contains) {
System.out.println("Charset(" + charset.name() + ").contains(Charset(" + charset.name()
+ ")) returns " + contains);
failed = true;
}
}
if (failed)
throw new RuntimeException("Charset.contains(itself) returns false for some charsets");
return;
}
}
---------- END SOURCE ----------
java version "1.8.0_102"
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux, version 3.2.0-99-generic-pae
Mac OS X, version 10.8.5
A DESCRIPTION OF THE PROBLEM :
The following charsets returned by Charset.availableCharsets() does not contain itself
CESU-8
UTF-32
UTF-32BE
UTF-32LE
x-eucJP-Open
x-JISAutoDetect
X-UTF-32BE-BOM
X-UTF-32LE-BOM
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Charset(CESU-8).contains(Charset(CESU-8)) returns true
Charset(UTF-32).contains(Charset(UTF-32)) returns true
Charset(UTF-32BE).contains(Charset(UTF-32BE)) returns true
Charset(UTF-32LE).contains(Charset(UTF-32LE)) returns true
Charset(x-eucJP-Open).contains(Charset(x-eucJP-Open)) returns true
Charset(x-JISAutoDetect).contains(Charset(x-JISAutoDetect)) returns true
Charset(X-UTF-32BE-BOM).contains(Charset(X-UTF-32BE-BOM)) returns true
Charset(X-UTF-32LE-BOM).contains(Charset(X-UTF-32LE-BOM)) returns true
ACTUAL -
Charset(CESU-8).contains(Charset(CESU-8)) returns false
Charset(UTF-32).contains(Charset(UTF-32)) returns false
Charset(UTF-32BE).contains(Charset(UTF-32BE)) returns false
Charset(UTF-32LE).contains(Charset(UTF-32LE)) returns false
Charset(x-eucJP-Open).contains(Charset(x-eucJP-Open)) returns false
Charset(x-JISAutoDetect).contains(Charset(x-JISAutoDetect)) returns false
Charset(X-UTF-32BE-BOM).contains(Charset(X-UTF-32BE-BOM)) returns false
Charset(X-UTF-32LE-BOM).contains(Charset(X-UTF-32LE-BOM)) returns false
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.Map;
import java.nio.charset.Charset;
/**
* Each charset from all available charsets must contains itself.
*/
public class ContainsTest {
public int callSystemGC = 1;
public static void main(String[] args) {
boolean failed = false;
for (Map.Entry<String, Charset> entry : Charset.availableCharsets().entrySet()) {
String name = entry.getKey();
Charset charset = entry.getValue();
boolean contains = charset.contains(charset);
if (!contains) {
System.out.println("Charset(" + charset.name() + ").contains(Charset(" + charset.name()
+ ")) returns " + contains);
failed = true;
}
}
if (failed)
throw new RuntimeException("Charset.contains(itself) returns false for some charsets");
return;
}
}
---------- END SOURCE ----------