#502 compilation error for jfan

vladdu Fri 3 Apr 2009

Hi,

Trying to compile the jfan library gives an error in FanBool

public static boolean equals(boolean self, Object obj) {
  return self==obj;
}

as boolean and Object are incompatible.

Would it work with

public static boolean equals(boolean self, Object obj) {
  return (obj instanceof Boolean)
    && ((Boolean) obj).booleanValue() == self;
}

instead?

regards, Vlad

brian Fri 3 Apr 2009

Which compiler are you using?

vladdu Fri 3 Apr 2009

The Eclipse compiler (3.4).

brian Fri 3 Apr 2009

Interesting - must just be a difference from javac. I pushed a fix to hg.

alexlamsl Sat 4 Apr 2009

One would expect the Java compiler to box self before performing the comparison. The Eclipse compiler in this case failed to comply with the JLS, but then this is not the first time anyway.

Login or Signup to reply.