Skip to main content

[jsr363-experts] Re: some things :)

  • From: Martin Desruisseaux < >
  • To:
  • Subject: [jsr363-experts] Re: some things :)
  • Date: Sun, 14 Dec 2014 12:36:49 +0900
  • Organization: Geomatys

<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    Le 14/12/14 00:44, Werner Keil a écrit :<br>
    <blockquote
cite="mid:CAAGawe3YTJtM=
      "
      type="cite">
      <div dir="ltr">Java and (Open)JDK have the most lousy equals()
        methods one can imagine.
        <div>See the Integer class:</div>
        <div>
          <div><font face="monospace">        if (obj instanceof
              Integer) {</font></div>
          <div><font face="monospace">            return value ==
              ((Integer)obj).intValue();</font></div>
          <div><font face="monospace">        }</font></div>
        </div>
        <div>Which is why BigInteger.ONE.equals(Integer.valueOf(1)) will
          always return false<img
            src="cid:part1.02090001.02000503@geomatys.fr" goomoji="362"
            style="margin: 0px 0.2ex; vertical-align: middle;"></div>
      </div>
    </blockquote>
    <p>I see this definition as strict, not lousy. And I think that the
      JDK is doing the right thing. If they were not so strict, it would
      be very difficult to enforce the <tt>equals(Object)</tt>
      invariants mentioned in my previous email.<br>
    </p>
    <p><br>
    </p>
    <blockquote
cite="mid:CAAGawe3YTJtM=
      "
      type="cite">
      <div dir="ltr">
        <div>Guess we can handle that better within an implementation
          like RI at least.<br>
        </div>
      </div>
    </blockquote>
    <p>Please read again my previous email about <tt>equals(Object)</tt>
      invariants (<i>e.g.</i> <tt>A.equals(B)</tt> must imply <tt>B.equals(A)</tt>,
      <i>etc.</i>). Wanting to handle "better" often results in much
      worst situation. If the JDK implementations perform strict
      comparisons, this is not because the developers were lazy.<br>
    </p>
    <p>    Martin<br>
      <br>
    </p>
  </body>
</html>

Attachment: gifp1qRG70Fl9.gif
Description: GIF image



[jsr363-experts] some things :)

Leonardo Lima 12/11/2014

[jsr363-experts] Re: some things :)

Martin Desruisseaux 12/13/2014

[jsr363-experts] Re: some things :)

Werner Keil 12/13/2014

[jsr363-experts] Re: some things :)

Martin Desruisseaux 12/14/2014

[jsr363-experts] Re: some things :)

Werner Keil 12/14/2014
 
 
Close
loading
Please Confirm
Close