This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: crashing Kawa with a boolean field


Per Bothner wrote:
Wen-Chun Ni wrote:

When I cut-n-paste the above, I get
java.lang.NullPointerException
        at java.util.Hashtable.get(Hashtable.java:320)

That to me looks like a bug in java.util.Hashtable, not Kawa ...

Actually that NPE is a null key parameter to Hashtable.get.


The origin of that is probably gnu.bytecode.PrimType.emitCoerceToObject line 78 which is a case with this:

default: cname = null;

There also seems to be a mismatch in type naming between PrimType.emitCoerceToObject (which is using full java.lang class names) and Type.lookupType (which is using short Java source names for primitives).

A side note on the initialization of the mapNameToType static in Type. Using a static initializer would eliminate the null check and provide class loading synchronization for free.

Jim
--
"I love deadlines. I love the whooshing sound they make as they fly by." -- Douglas Adams
--- /Users/jim/Software/archives/kawa-1.7/gnu/bytecode/Type.java	Tue May 13 09:37:46 2003
+++ gnu/bytecode/Type.java	Wed Jun 18 01:09:46 2003
@@ -35,19 +35,6 @@
 
   public static Type lookupType (String name)
   {
-    if (mapNameToType == null)
-      {
-	mapNameToType = new java.util.Hashtable();
-	mapNameToType.put("byte",    byte_type);
-	mapNameToType.put("short",   short_type);
-	mapNameToType.put("int",     int_type);
-	mapNameToType.put("long",    long_type);
-	mapNameToType.put("float",   float_type);
-	mapNameToType.put("double",  double_type);
-	mapNameToType.put("boolean", boolean_type);
-	mapNameToType.put("char",    char_type);
-	mapNameToType.put("void",    void_type);
-      }
     return (Type) mapNameToType.get(name);
   }
 
@@ -416,6 +403,19 @@
     = new PrimType ("char", "C", 2, java.lang.Character.TYPE);
   public static final PrimType void_type
     = new PrimType ("void", "V", 0, java.lang.Void.TYPE);
+
+  static {
+	mapNameToType = new java.util.Hashtable();
+	mapNameToType.put("byte",    byte_type);
+	mapNameToType.put("short",   short_type);
+	mapNameToType.put("int",     int_type);
+	mapNameToType.put("long",    long_type);
+	mapNameToType.put("float",   float_type);
+	mapNameToType.put("double",  double_type);
+	mapNameToType.put("boolean", boolean_type);
+	mapNameToType.put("char",    char_type);
+	mapNameToType.put("void",    void_type);
+  }
 
   /** The "return type" of an expression that never returns, e.g. a throw. */
   public static final PrimType neverReturnsType = new PrimType (void_type);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]