Date: Fri, 24 Feb 2006 03:47:40 +0300 From: Serge Baranov <serge@jetbrains.com> To: freebsd-java@freebsd.org. Subject: NullPointerException in Charset.java:493 Message-ID: <1757973988.20060224034740@jetbrains.com>
next in thread | raw e-mail | index | archive | help
Hello All, The following exception is thrown when calling: Charset.availableCharsets() JDK method. Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at java.nio.charset.Charset.put(Charset.java:493) at java.nio.charset.Charset.access$300(Charset.java:240) at java.nio.charset.Charset$4.run(Charset.java:529) at java.security.AccessController.doPrivileged(Native Method) at java.nio.charset.Charset.availableCharsets(Charset.java:525) It has been already discussed: http://lists.freebsd.org/mailman/htdig/freebsd-java/2005-September/004339.html but the problem still exists. Here is the test case that will reproduce the problem: import java.nio.charset.Charset; import java.util.Iterator; import java.util.Set; public class TestCase { public static void main(String[] args) { Set set = Charset.availableCharsets().keySet(); for (Iterator iterator = set.iterator(); iterator.hasNext();) { String s = (String) iterator.next(); System.out.println(s); } } } Save into TestCase.java Compile: javac TestCase.java Run: java TestCase Expected result: list of available charsets printed. Actual result: NPE is thrown at java.nio.charset.Charset.put(Charset.java:493) For some reason there is null charset returned at this point: Charset cs = (Charset)i.next(); Suggested fix: either add a null check as per Dan Cojocar reply or investigate why null appears there and fix it on the earlier stage. Fixing this bug is very important, since it breaks functionality of almost any Java application that operates charsets (like IntelliJ IDEA). System information: $ java -version java version "1.5.0-p2" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-p2-root_23_feb_2006_08_02) Java HotSpot(TM) Client VM (build 1.5.0-p2-root_23_feb_2006_08_02, mixed mode) 6.1-PRERELEASE i386 P.S. I'm not subscribed to this list, put my address in CC field when replying. Serge Baranov JetBrains, Inc http://www.jetbrains.com "Develop with pleasure!"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1757973988.20060224034740>