[kaffe] Hashtable.get() bug

Dalibor Topic robilad at yahoo.com
Thu Jun 6 09:32:12 PDT 2002


Hi alexander,

--- Alexander Popov <s_popov at prosyst.bg> wrote:
> Hashtable.get() constantly throws NPE. I use current
> CVS (trunk, not the 
> 1.0.7 brunch)... The platform is linux/x86.
> 
> Here is an example code thet demonstrates that:
> 
> 
> import java.util.Hashtable;
> import java.lang.System;
> 
> public class hashGet {
> 
>    public static Hashtable props;
>    public static Object SIZE = new String("404444");
> 
>    public static void get(){
> 
>      System.out.println("Get 1 : " + SIZE );
>      Object b = props.get(SIZE);
>      System.out.println("Get 2");
>    }
> 
>    public static void main(String[] args) {
> 
>      System.out.println("Main 1");
>      try {
>        get();
>      }catch (Exception e){
>        System.out.println("Hashtable.get throws : "
> + e);
>        e.printStackTrace();
>      }
>      System.out.println("Main 2");
> 
>    }
> 
> }

Actually, you don't even call Hashtable.get in this
example since props is not initialized. Since it is
not initialized, it defaults to null, and you get a
null pointer exception when you try to call get() on
it.

problem solved ;)

cheers,

dalibor topic

__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com




More information about the kaffe mailing list