problem with toString () --> com.sun.jdi.InvocationException occurred invok

hi all,

i have a problem with toString() method. i wrote an extending class for Hashtable, named OrderedHashtable. When i start the program toString method gives the following error message

com.sun.jdi.InvocationException occurred invoking method.

my extended class looks like this

public class OrderedHashtable extends Hashtable

{

...

...

..

public synchronized String toString()

{

return super.toString();

}

...

...

}

so, when i return back something else like return "test", it works fine ( but of course wrong for workflow) this toString method is the troublemaker. any idea, how to solve it?

thanks in advance

mogg

[748 byte] By [mogga] at [2007-11-27 0:26:07]
# 1
I'm not sure, but I would guess that it is cuz of the synchronized keyword. Do you really need it? If you do not need it, then you can simply remove the entire method. If you do need it, then try using "synchronized {" inside the method instead. Yours, Jiddo.
Jiddoa at 2007-7-11 22:24:24 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 2

hi Jiddo,

i redefined the toString method without using super keyword. it works fine, but, now i get the same error message by overwritten put method. i think, there something wrong with super keyword.

in put method, synchronized is inside the method, not in the definition, but it also produce the same error.

btw, i must use synchronized to make it thread safe, otherwise some problems will occur, because i have many threads that invoke these methods.

any other ideas?

mogg

mogga at 2007-7-11 22:24:24 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...