powered by Jive Software

Possible problem code

Hi thanks very much for the library having a lot of fun ! Whilst browsing the code I noticed the following and it struck a chord as I have made this same mistake in the past.

The following code is from PacketReader from the static inner class ListenerWrapper.

public boolean equals(Object object) {

if (object == null) {

return false;


if (object instanceof ListenerWrapper) {

return ((ListenerWrapper)object).packetListener.equals(this.packetListener);


else if (object instanceof PacketListener) {

return object.equals(this.packetListener);


return false;


The problem is that this implementation is not necessarily symmetric i.e. a.equals(b) does not imply b.equals(a), which is a requisite for equals().

Do you plan to write code to support the new multi user chat?


Just curious being a noob.

How would this not be symmetric? It looks to me like it boils down to object equivalence for PacketListener objects.

Take care,


Take any instance of PacketListener, call it B then if a ListenerWrapper called A contains a PacketListener C where B.equals©is true, then we certainly have A.equals(B) is true.

Now the other way round, is B.equals(A) true as it should be, probably not unless you specifically override the equals mtd, which you’'re almost certainly not going to do. Esp. in an anonymous adapter when you dont know anything about ListenerWrapper.

I think we should be ok since Object.equals will generally give us the behavior we’‘re looking for. I’'m open to suggestions for improvment, though!