From owner-freebsd-java@FreeBSD.ORG Fri Feb 24 00:47:43 2006 Return-Path: X-Original-To: freebsd-java@freebsd.org Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 730BB16A420 for ; Fri, 24 Feb 2006 00:47:43 +0000 (GMT) (envelope-from serge@jetbrains.com) Received: from mail.intellij.net (mail.intellij.net [213.182.181.98]) by mx1.FreeBSD.org (Postfix) with ESMTP id A153543D45 for ; Fri, 24 Feb 2006 00:47:42 +0000 (GMT) (envelope-from serge@jetbrains.com) Received: (qmail 496 invoked by uid 89); 24 Feb 2006 00:47:40 -0000 Received: from unknown (HELO localhost) (192.168.1.15) by mail.intellij.net with SMTP; 24 Feb 2006 00:47:40 -0000 Date: Fri, 24 Feb 2006 03:47:40 +0300 From: Serge Baranov X-Mailer: The Bat! (v3.71.03) Professional Organization: JetBrains, Inc X-Priority: 3 (Normal) Message-ID: <1757973988.20060224034740@jetbrains.com> To: freebsd-java@freebsd.org. MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: Subject: NullPointerException in Charset.java:493 X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Serge Baranov List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Feb 2006 00:47:43 -0000 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!"