Menu

#73 Class instances from classloader appear unique

open
nobody
None
3
2007-06-11
2007-06-10
dan
No

It appears that Object.class and obj.getClass() do not return the same Class instance. SuperWaba documentation does not make any guarentees about (nor mentions) these two aspects, however, due to these differences, hashing these values (in a waba.util.Hashtable) gives unexpected results (also hashing obj.getClass() gives unexpected results).

The following code reproduces this problem:

Object obj = new Object();
if (obj.getClass() == Object.class) {
Vm.debug("same!");
}
else {
Vm.debug("not same!");
}

if (obj.getClass() == obj.getClass()) {
Vm.debug("same here!");
}
else {
Vm.debug("not same here!");
}

When run in the JDK the results are (and waba.util.Hashtable works as expected):
same!
same here!

When run on Palm OS (Kyocera 7135) (and waba.util.Hashtable returns nulls for repeated get()s when the key in the hash is the Class instance):
not same!
not same here!

Thanks,
Dan

Discussion

  • Guilherme C. Hazan

    Logged In: YES
    user_id=180823
    Originator: NO

    Hi,

    I reproduced the bug. Unfortunately, it can't be fixed in SuperWaba. I'll fix it in TotalCross.

    thanks for pointing it out.

    guich

     
  • Guilherme C. Hazan

    • priority: 5 --> 3
     

Log in to post a comment.

Auth0 Logo