-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
5.0
-
sparc
-
solaris_2.6
Name: auR10023 Date: 10/07/2003
Filed By : SPB JCK team (###@###.###)
JDK : java full version "1.5.0-beta-b22"
JCK : 1.5
Platform[s] : Solaris
switch/Mode :
JCK test owner : http://javaweb.eng/jct/sqe/JCK-tck/usr/owners.jto
Failing Test [s] :
api/java_nio/charset/Charset/index.html#Methods[Charset0048]
Specification excerpt:
======================
--------- J2SE API spec v.1.5 ---------
...
java.nio.charset
Class Charset
...
If a charset listed in the IANA Charset Registry is supported by an implementation of the Java platform then its canonical name must be the name listed in the registry. Many charsets are given more than one name in the registry, in which case the registry identifies one of the names as MIME-preferred. If a charset has more than one registry name then its canonical name must be the MIME-preferred name and the other names in the registry must be valid aliases. If a supported charset is not listed in the IANA registry then its canonical name must begin with one of the strings "X-" or "x-".
...
newEncoder
public abstract CharsetEncoder newEncoder()
Constructs a new encoder for this charset.
Returns:
A new encoder for this charset Throws:
UnsupportedOperationException - If this charset does not support encoding
...
name
public final String name()
Returns this charset's canonical name.
Returns:
The canonical name of this charset
availableCharsets
...
public static SortedMap availableCharsets()
Constructs a sorted map from canonical charset names to charset objects.
The map returned by this method will have one entry for each charset for which support is available in the current Java virtual machine. If two or more supported charsets have the same canonical name then the resulting map will contain just one of them; which one it will contain is not specified.
The invocation of this method, and the subsequent use of the resulting map, may cause time-consuming disk or network I/O operations to occur. This method is provided for applications that need to enumerate all of the available charsets, for example to allow user charset selection. This method is not used by the forName method, which instead employs an efficient incremental lookup algorithm.
This method may return different results at different times if new charset providers are dynamically made available to the current Java virtual machine. In the absence of such changes, the charsets returned by this method are exactly those that can be retrieved via the forName method.
Returns:
An immutable, case-insensitive map from canonical charset names to charset objects
...
...
---------- end-of-excerpt ---------------
Problem description
===================
ISO-2022-CN-CNS charset is not listed in IANA Charset Registry
(http://www.iana.org/assignments/character-sets), so it canonical name is x-ISO-2022-CN-CNS.But if we create charset with this name and call newDecoder().charset() then resulted charset's canonical name will be ISO-2022-CN.
Minimized test:
===============
------- Test.java -------
import java.nio.charset.*;
import java.util.*;
public class Test {
public static void main(String args[]) {
try {
Charset c1 = Charset.forName("x-ISO-2022-CN-CNS");
Charset c2 = c1.newDecoder().charset();
System.out.println( c1.name());
System.out.println( c2.name());
if (!c2.equals(c1)) {
System.out.println("newDecoder() returns invalid decoder ");
}
} catch(Exception e) {
}
}
}
------- end-of-Test.java -------
Minimized test output:
======================
x-ISO-2022-CN-CNS
ISO-2022-CN
newDecoder() returns invalid decoder
JCK test source location:
==========================
/java/re/jck/1.5/promoted/latest/JCK-runtime-15/tests
Test output:
=============
Executing command via oink,port=50135,localport=59165
Unexpected java.nio.charset.UnsupportedCharsetException: with charset ""
java.nio.charset.UnsupportedCharsetException:
at java.nio.charset.Charset.forName(Charset.java:430)
at javasoft.sqe.tests.api.java.nio.charset.Charset.MethodsTests.Charset0002(MethodsTests.java:265)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324) at javasoft.sqe.javatest.lib.MultiTest.invokeTestCase(MultiTest.java:399)
at javasoft.sqe.javatest.lib.MultiTest.run(MultiTest.java:195)
at com.sun.jck.lib.ExecJCKTestSameJVMCmd$Version2Test.execute(ExecJCKTestSameJVMCmd.java:372)
at com.sun.jck.lib.ExecJCKTestSameJVMCmd$StandardTest.run(ExecJCKTestSameJVMCmd.java:317)
at com.sun.jck.lib.ExecJCKTestSameJVMCmd.execute(ExecJCKTestSameJVMCmd.java:194)
at com.sun.jck.lib.ExecJCKTestSameJVMCmd.run(ExecJCKTestSameJVMCmd.java:125) at com.sun.javatest.agent.Agent$Task.executeCommand(Agent.java:818)
at com.sun.javatest.agent.Agent$Task.execute(Agent.java:749)
at com.sun.javatest.agent.Agent$Task.handleRequest(Agent.java:610)
at com.sun.javatest.agent.Agent.handleRequestsUntilClosed(Agent.java:379)
at com.sun.javatest.agent.Agent.access$000(Agent.java:43)
at com.sun.javatest.agent.Agent$1.run(Agent.java:255)
at java.lang.Thread.run(Thread.java:549)
IllegalCharsetNameException expected with charset ""
newDecoder() returns invalid decoder with x-ISO-2022-CN-CNS
...
Charset0046: Passed. OKAY
Charset0047: Passed. OKAY
Charset0048: Failed. newDecoder() returns invalid decoder
Charset0049: Passed. OKAY
Charset0050: Passed. OKAY
Charset0051: Passed. OKAY
Charset0052: Passed. OKAY
Charset0053: Passed. OKAY
result: Failed. test cases: 53; passed: 48; failed: 5; first test case failure: Charset0002
======================================================================
Filed By : SPB JCK team (###@###.###)
JDK : java full version "1.5.0-beta-b22"
JCK : 1.5
Platform[s] : Solaris
switch/Mode :
JCK test owner : http://javaweb.eng/jct/sqe/JCK-tck/usr/owners.jto
Failing Test [s] :
api/java_nio/charset/Charset/index.html#Methods[Charset0048]
Specification excerpt:
======================
--------- J2SE API spec v.1.5 ---------
...
java.nio.charset
Class Charset
...
If a charset listed in the IANA Charset Registry is supported by an implementation of the Java platform then its canonical name must be the name listed in the registry. Many charsets are given more than one name in the registry, in which case the registry identifies one of the names as MIME-preferred. If a charset has more than one registry name then its canonical name must be the MIME-preferred name and the other names in the registry must be valid aliases. If a supported charset is not listed in the IANA registry then its canonical name must begin with one of the strings "X-" or "x-".
...
newEncoder
public abstract CharsetEncoder newEncoder()
Constructs a new encoder for this charset.
Returns:
A new encoder for this charset Throws:
UnsupportedOperationException - If this charset does not support encoding
...
name
public final String name()
Returns this charset's canonical name.
Returns:
The canonical name of this charset
availableCharsets
...
public static SortedMap availableCharsets()
Constructs a sorted map from canonical charset names to charset objects.
The map returned by this method will have one entry for each charset for which support is available in the current Java virtual machine. If two or more supported charsets have the same canonical name then the resulting map will contain just one of them; which one it will contain is not specified.
The invocation of this method, and the subsequent use of the resulting map, may cause time-consuming disk or network I/O operations to occur. This method is provided for applications that need to enumerate all of the available charsets, for example to allow user charset selection. This method is not used by the forName method, which instead employs an efficient incremental lookup algorithm.
This method may return different results at different times if new charset providers are dynamically made available to the current Java virtual machine. In the absence of such changes, the charsets returned by this method are exactly those that can be retrieved via the forName method.
Returns:
An immutable, case-insensitive map from canonical charset names to charset objects
...
...
---------- end-of-excerpt ---------------
Problem description
===================
ISO-2022-CN-CNS charset is not listed in IANA Charset Registry
(http://www.iana.org/assignments/character-sets), so it canonical name is x-ISO-2022-CN-CNS.But if we create charset with this name and call newDecoder().charset() then resulted charset's canonical name will be ISO-2022-CN.
Minimized test:
===============
------- Test.java -------
import java.nio.charset.*;
import java.util.*;
public class Test {
public static void main(String args[]) {
try {
Charset c1 = Charset.forName("x-ISO-2022-CN-CNS");
Charset c2 = c1.newDecoder().charset();
System.out.println( c1.name());
System.out.println( c2.name());
if (!c2.equals(c1)) {
System.out.println("newDecoder() returns invalid decoder ");
}
} catch(Exception e) {
}
}
}
------- end-of-Test.java -------
Minimized test output:
======================
x-ISO-2022-CN-CNS
ISO-2022-CN
newDecoder() returns invalid decoder
JCK test source location:
==========================
/java/re/jck/1.5/promoted/latest/JCK-runtime-15/tests
Test output:
=============
Executing command via oink,port=50135,localport=59165
Unexpected java.nio.charset.UnsupportedCharsetException: with charset ""
java.nio.charset.UnsupportedCharsetException:
at java.nio.charset.Charset.forName(Charset.java:430)
at javasoft.sqe.tests.api.java.nio.charset.Charset.MethodsTests.Charset0002(MethodsTests.java:265)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324) at javasoft.sqe.javatest.lib.MultiTest.invokeTestCase(MultiTest.java:399)
at javasoft.sqe.javatest.lib.MultiTest.run(MultiTest.java:195)
at com.sun.jck.lib.ExecJCKTestSameJVMCmd$Version2Test.execute(ExecJCKTestSameJVMCmd.java:372)
at com.sun.jck.lib.ExecJCKTestSameJVMCmd$StandardTest.run(ExecJCKTestSameJVMCmd.java:317)
at com.sun.jck.lib.ExecJCKTestSameJVMCmd.execute(ExecJCKTestSameJVMCmd.java:194)
at com.sun.jck.lib.ExecJCKTestSameJVMCmd.run(ExecJCKTestSameJVMCmd.java:125) at com.sun.javatest.agent.Agent$Task.executeCommand(Agent.java:818)
at com.sun.javatest.agent.Agent$Task.execute(Agent.java:749)
at com.sun.javatest.agent.Agent$Task.handleRequest(Agent.java:610)
at com.sun.javatest.agent.Agent.handleRequestsUntilClosed(Agent.java:379)
at com.sun.javatest.agent.Agent.access$000(Agent.java:43)
at com.sun.javatest.agent.Agent$1.run(Agent.java:255)
at java.lang.Thread.run(Thread.java:549)
IllegalCharsetNameException expected with charset ""
newDecoder() returns invalid decoder with x-ISO-2022-CN-CNS
...
Charset0046: Passed. OKAY
Charset0047: Passed. OKAY
Charset0048: Failed. newDecoder() returns invalid decoder
Charset0049: Passed. OKAY
Charset0050: Passed. OKAY
Charset0051: Passed. OKAY
Charset0052: Passed. OKAY
Charset0053: Passed. OKAY
result: Failed. test cases: 53; passed: 48; failed: 5; first test case failure: Charset0002
======================================================================
- relates to
-
JDK-4949996 (cs spec) Charset{De,En}Coder.charset() spec should be relaxed
- Closed