Hi,
Thanks for your prompt reply. I must be missing something. To
demonstrate the cycle problem you described, I created a simple schema
with
<xsd:complexType name="Foo">
<xsd:sequence>
<xsd:element name="foo" type="Foo"/>
</xsd:sequence>
</xsd:complexType>
and generated the associated code. I then added an equals() method to
FooImpl as follows:
public boolean equals( Object o )
{
if( o == this )
return true;
if( !( o instanceof foo.Foo ) )
return false;
foo.Foo in = (foo.Foo)o;
return in.getFoo().equals( _Foo );
}
My test class then ran:
Foo f = ObjectFactory.createFoo();
f.setFoo( f );
f.equals( f );
The self-identity check in equals() is true in this case. What have I
missed? I am also not sure how ID/IDREF impacts this issue. Is there an
issue in global validation?
Thanks for your time,
Craig
> -----Original Message-----
> From: Discussion list for the Java Architecture for XML
> Binding [mailto:JAXB-INTEREST_at_JAVA.SUN.COM] On Behalf Of
> Kohsuke Kawaguchi
> Sent: 06 February 2003 07:36 PM
> To: JAXB-INTEREST_at_JAVA.SUN.COM
> Subject: Re: JAXB and equals
>
> Consider a generated interface like
>
> interface Foo {
> Foo getFoo();
> void setFoo(Foo v);
> }
>
> And suppose you did:
>
> Foo f = objectFactory.createFoo();
> f.setFoo(f);
>
> It's not good for "f.equals(f)" to throw a
> StackOverflowError. This example is rather artificial, but
> the same problem happens if you have ID/IDREFs.