I would argue (and probably lose) that something that worked in 99% of cases as expected would be better than something that never does.<div><div><br></div><div>I will reread Stuarts arguments, but it seems to me that we can specify how equals works with client proxies.<br>
<br><div class="gmail_quote">On Tue, Oct 18, 2011 at 1:56 PM, Pete Muir <span dir="ltr"><<a href="mailto:pmuir@redhat.com">pmuir@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im"><br>
On 18 Oct 2011, at 21:42, Rick Hightower wrote:<br>
<br>
> Currently the docs say this.... 5.4.2.<br>
><br>
> •Behavior of all methods declared by java.lang.Object, except for toString(), is undefined for a client proxy<br>
> •Portable applications should not invoke any method declared by java.lang.Object, except for toString(), on a client proxy<br>
><br>
> I so don't agree with what is in the spec. now on this subject.<br>
> (Realizing that it is a work in progress...)<br>
<br>
</div>Not really, this is unchanged since 1.0. We don't currently have plans to change this.<br>
<div class="im"><br>
><br>
> I think we should change this and call the underlying implementation for these methods.<br>
> Also equals and hashCode should work by unpacking and comparing the contextual instance.<br>
<br>
</div>Please take a look at Stuart's follow up to Mark's email, he has investigated the options thoroughly, and found there is no solution that can correctly obey the rules for equals. For this reason it's better to keep it unspecified, as it warns people not to rely on this behavior.<br>
<div class="im"><br>
><br>
> Off topic....<br>
><br>
> It would be nice if there was a utility API that implementations had to implement that had these methods<br>
><br>
><br>
> isProxy (lets you know if an object is a client proxy)<br>
> getUnproxiedVersion (gives you the underlying unproxied version of the object)<br>
><br>
><br>
> (It may exist already.)<br>
<br>
</div>I don't believe there is, so file a CDI issue and we can discuss / add it. It should be relatively trivial (require any client proxy to implement an interface e.g. ClientProxy and provide a method on getUnderlying() or similar).<br>
<div class="im"><br>
><br>
><br>
> On Tue, Oct 18, 2011 at 10:17 AM, Mark Struberg <<a href="mailto:struberg@yahoo.de">struberg@yahoo.de</a>> wrote:<br>
> Hi folks!<br>
><br>
> There is a problem still in the chain which is a bit more trickier. It's about equals() on contextual references.<br>
><br>
> If the 'other' instance which gets compared with is a proxy as well, then we would first need to 'unpack' it and pass the underlying contextual instance into the comparison implementation. Otherwise accessing private fields from the 'other' will actually only hit the proxy, and not the 'real' target.<br>
><br>
> But otherwise it should work fine.<br>
><br>
><br>
> Wdyt?<br>
><br>
> 1.) Should we specify this?<br>
<br>
</div>See Stuart's response, I would be very leery of requiring behavior which broke the fundamental contract of equals(). If we can't fully support the correct behavior, it's better to leave it unportable.<br>
<div class="im"><br>
><br>
> 2.) What is the expected behaviour?<br>
><br>
> 3.) Do we like to specify equals() for beans at all?<br>
> 4.) Is there some established behaviour in other frameworks which heavily uses proxies?<br>
<br>
</div>Not AFAIK. We played around for ages with this in Seam and Weld, and have something that gives you 99% correct behavior, but there are still edge cases.<br>
<div class="im"><br>
> 5.) Should we at least specify that 'non portable behaviour results'?<br>
<br>
</div>We do, see Rick's reference above.<br>
<div><div></div><div class="h5"><br>
><br>
><br>
> LieGrue,<br>
> strub<br>
><br>
><br>
><br>
> ----- Original Message -----<br>
> > From: Pete Muir <<a href="mailto:pmuir@redhat.com">pmuir@redhat.com</a>><br>
> > To: Mark Struberg <<a href="mailto:struberg@yahoo.de">struberg@yahoo.de</a>><br>
> > Cc: <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a>; Stuart Douglas <<a href="mailto:sdouglas@redhat.com">sdouglas@redhat.com</a>><br>
> > Sent: Monday, March 14, 2011 12:52 PM<br>
> > Subject: Re: [cdi-dev] calling 'equals' on a proxy?<br>
> ><br>
> > Stuart, you had this one worked out right? I believe the spec says the behaviour<br>
> > is unspecified.<br>
> ><br>
> > On 7 Mar 2011, at 15:52, Mark Struberg wrote:<br>
> ><br>
> >> Hi Pete, others!<br>
> >><br>
> >> Do you remember our discussion about what should happen if equals() gets<br>
> > called on a proxy?<br>
> >><br>
> >> Should it route to the equals method of the currently proxied instance?<br>
> >><br>
> >> LieGrue,<br>
> >> strub<br>
> >><br>
> >><br>
> >><br>
> >> _______________________________________________<br>
> >> cdi-dev mailing list<br>
> >> <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
> >> <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
> ><br>
><br>
><br>
> _______________________________________________<br>
> cdi-dev mailing list<br>
> <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
><br>
><br>
><br>
> --<br>
> Rick Hightower<br>
> <a href="tel:%28415%29%20968-9037" value="+14159689037">(415) 968-9037</a><br>
> Profile<br>
><br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><b>Rick Hightower</b><br>(415) 968-9037 <br><a href="http://www.google.com/profiles/RichardHightower" target="_blank">Profile</a> <br><br>
</div></div>