Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4737614
Votes 0
Synopsis sun.nio.cs.ext.ISO2022_CN_CNS.newDecoder() returns null
Category java:char_encodings
Reported Against hopper
Release Fixed 1.4.2(mantis)
State 10-Fix Delivered, Verified, bug
Priority: 2-High
Related Bugs 4779029
Submit Date 27-AUG-2002
Description
Verified in Mantis Build 08.
 xxxxx@xxxxx  2002-11-22




sun.nio.cs.ext.ISO2022_CN_CNS.newDecoder() returns null to signal a desupported encoding which causes a NPE in java.lang.StringCoding$CharsetSD.CharsetSD(Charset cs, String rcn)
(the code is "this.cd = cs.newDecoder().onMalformedInput()...").
It believe it should throw UnsupportedEncodingException instead.

The exact version of the JDK is j2sdk-1_4_1-rc-src-b19-solwin-08_aug_2002


java.lang.NullPointerException
        at java.lang.StringCoding$CharsetSD.<init>(StringCoding.java:164)
        at java.lang.StringCoding$CharsetSD.<init>(StringCoding.java:155)
        at java.lang.StringCoding.decode(StringCoding.java:211)
        at java.lang.String.<init>(String.java:327)
        at java.lang.String.<init>(String.java:356)
        at oracle.ide.util.Encodings.searchForEncodings(Encodings.java:299)
        at oracle.ide.util.Encodings.initEncodingsListImpl(Encodings.java:268)
        at oracle.ide.util.Encodings.ensureInit(Encodings.java:243)
        at oracle.ide.util.Encodings.convertJdk2IanaEncoding(Encodings.java:114)
        at oracle.ide.util.Encodings.getDefaultIanaEncoding(Encodings.java:102)
        at oracle.ide.xml.XMLUtil.loadXSLT(XMLUtil.java:149)
        at oracle.ide.marshal.xml.Object2Dom.applyTransforms(Object2Dom.java:1218)
        at oracle.ide.marshal.xml.Object2Dom.open(Object2Dom.java:563)
...
(Review ID: 163561) 
======================================================================
Work Around




When invoking "new String( string, encoding )", the caller must catch both UnsupportedEncodingException and NullPointerExceptions
======================================================================
Evaluation
It's not clear to me why ISO2022_CN_CNS.newDecoder() is returning null, but we
should resolve this in Mantis.  --  xxxxx@xxxxx  2002/8/27

ISO2022_CN_CNS and ISO_2022_CN_GB provide encoder implementations only. In some respects this is not different to the situation for 1.3.1 and earlier.
See BugID 4140796. It turns out that historically the reason why these
named encodings don't provide ByteToChar converters is that the 
ISO2022_CN Byte->Char converter will decode a stream containing both
escape sequences (CN_CNS and CN_GB). 
The NIO implementation should probably throw an UnsupportedOperationException
for the moment but going forward an invokation of newDecoder() should 
probably instantiate a ISO2022_CN decoder instance and pass back a reference
to it. In 1.4.1 no NIO ISO2022_CN decoder was provided. This should be added
for 1.4.2 as part of the cleanup of the handling of the NIO ISO2022 coders.
 xxxxx@xxxxx  2002-08-28

Rather than provide an incomplete ISO-2022-CN NIO Charset solution it is 
proposed that the existing neutered encoder only implementations for 
ISO-2022-CN-CNS and ISO-2022-CN-GB be removed from the NIO charset
provider class, sun.nio.cs.ext.ExtendedCharsets. A full ISO-2022-CN-*
implementation will be tracked into J2SE 1.5.
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang