JDK-6907974 : (cs) Charset.availableCharsets throws NPE if "non-standard" charset is not present
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio.charsets
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: generic
  • CPU: generic
  • Submitted: 2009-12-07
  • Updated: 2012-10-22
  • Resolved: 2012-10-22
Related Reports
Relates :  
Description
Charset.availableCharsets throws NullPointerException if any of the charsets listed in StandardCharsets is not present (all "standard" charsets, as listed in java.nio.charset.Charsets, are persent)

/opt/my/usg169/space/export/xxx/build/tests/image/bin/java 
AvailableCharsetNames
Exception in thread "main" java.lang.NullPointerException
       at java.nio.charset.Charset.put(Charset.java:549)
       at java.nio.charset.Charset.access$300(Charset.java:272)
       at java.nio.charset.Charset$4.run(Charset.java:587)
       at java.nio.charset.Charset$4.run(Charset.java:582)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.nio.charset.Charset.availableCharsets(Charset.java:581)
       at AvailableCharsetNames.main(AvailableCharsetNames.java:17)

Should I be expecting at least "US-ASCII" as one of the entries in 
availableCharsets() ?

Comments
PUBLIC COMMENTS http://netbeans.org/bugzilla/show_bug.cgi?id=198827
2011-05-25

EVALUATION The issue is that sun.nio.cs.FastCharsetProvider#charsets returns an Iterator that doesn't handle missing charsets. If a charset is not present then the next method will return null.
2009-12-07