[PATCH] unnecessary null check inside of java.lang.Boolean.valueOf(String)

Vitaly Davidovich vitalyd at gmail.com
Mon Mar 19 19:58:06 UTC 2018


It's surprising that both variants don't perform the same when JIT compiled.

On Mon, Mar 19, 2018 at 3:32 PM, Martin Buchholz <martinrb at google.com>
wrote:

> >
> >       */
> >      public boolean equals(Object obj) {
> >          if (obj instanceof Boolean) {
> > - return value == ((Boolean)obj).booleanValue();
> > + return value == (Boolean) obj;
> >          }
> >
> >
> This is not correct, since we might have multiple Boolean objects that are
> equals, but not ==.
> Do we have a test that would catch this?
>


More information about the core-libs-dev mailing list