dev@jaxb.java.net

Re: dev Digest 3 Jun 2009 20:17:01 -0000 Issue 143

From: Martin Grebac <Martin.Grebac_at_Sun.COM>
Date: Wed, 03 Jun 2009 14:05:57 -0700

Hi,
 there's a very good description of String interning here:

 http://weblogs.java.net/blog/enicholas/archive/2006/06/all_about_inter.html

  MartiNG

dev-digest-help_at_jaxb.dev.java.net wrote:
> Subject:
> why does jaxb compare strings with == instead of .equals
> From:
> jtmelton <jtmelton_at_gmail.com>
> Date:
> Wed, 03 Jun 2009 13:16:58 -0700 (PDT)
> To:
> dev_at_jaxb.dev.java.net
>
> To:
> dev_at_jaxb.dev.java.net
>
>
> I wanted to ask why JAXB compares strings with the equals operator
> (==) instead of the equals method. My understanding is that the equals
> method only works when comparing the same object or 2 strings that
> have both been initialized to the same value via the standard double
> quote initialization. In this case, it appears that an initialized
> string is being compared to a method parameter. Why would JAXB do it
> this way? As an example please look at the leaveElement method at this
> link.
> http://java.sun.com/developer/technicalArticles/WebServices/jaxb/CollectionTypeImpl.java
> Any help is greatly appreciated.
-- 
Martin Grebac, http://blogs.sun.com/mgrebac
Web Technologies & Standards
Sun Microsystems Czech
ICQ: 93478885