<br><br><div class="gmail_quote">On Tue, Oct 18, 2011 at 12:06 PM, Stuart Douglas <span dir="ltr">&lt;<a href="mailto:sdouglas@redhat.com">sdouglas@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
If the &#39;other&#39; instance is also a proxy, then both proxies will by definition be equal, as they will always resolve to the same underlying bean (as they are both being accessed by the same thread, that will have the same contexts active).<br>
</blockquote><div><br></div><div>They are not comparing two normal objects they are comparing an object and an instance. We are defining how proxies equals work, which is to get the underlying real object and compare it to the incoming real object or the real object from the proxy.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Anything we specify here is going to break the transitive behaviour of equals, consider we have a proxy A and normal class instantiated with new B.<br>
<br>
The normal class B has absolutely no knowledge of proxies, so will always compare the proxy instances fields directly, if we have the proxy forwarding the equals call to the underlying bean then you may end up with a situation where A.equals(B) is true, but B.equals(A) is false.<br>
</blockquote><div><br></div><div>Good point. So to not break this contract, we would only say that proxies can compare against other proxies. If they want to compare a proxy to a normal object they would have to use the utility methods I described earlier to unpack it. We could add an equals static method to this utility as well.</div>
<div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
HashCode has similar problems, if the proxy forwards it to the underlying bean, then the hash code will change as the underlying bean changes.<br></blockquote><div><br></div><div>But not within a Request scope or within a Session scope. I think this is ok actually. Much more so than the equals case. At least in the way people will actually use this in a web app. :)</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
I think we should specify that non-portable behaviour results, and tell people not to put proxies into a HashMap.<br>
<font color="#888888"><br>
Stuart<br></font></blockquote><div><br></div><div>Summary:</div><div><br></div><div><br></div><div>equals should only work with other client proxies, it should unpack and call equals on unpacked.</div><div><br></div><div>
hashCode should just work, it should unpack and call hashCode on underlying object (contextual instance in spec speak right?)</div><div><br></div><div><br></div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<font color="#888888">
</font><div><div></div><div class="h5"><br>
<br>
On 19/10/2011, at 4:17 AM, Mark Struberg wrote:<br>
<br>
&gt; Hi folks!<br>
&gt;<br>
&gt; There is a problem still in the chain which is a bit more trickier. It&#39;s about equals() on contextual references.<br>
&gt;<br>
&gt; If the &#39;other&#39; instance which gets compared with is a proxy as well, then we would first need to &#39;unpack&#39; it and pass the underlying contextual instance into the comparison implementation. Otherwise accessing private fields from the &#39;other&#39; will actually only hit the proxy, and not the &#39;real&#39; target.<br>

&gt;<br>
&gt; But otherwise it should work fine.<br>
&gt;<br>
&gt;<br>
&gt; Wdyt?<br>
&gt;<br>
&gt; 1.) Should we specify this?<br>
&gt;<br>
&gt; 2.) What is the expected behaviour?<br>
&gt;<br>
&gt; 3.) Do we like to specify equals() for beans at all?<br>
&gt; 4.) Is there some established behaviour in other frameworks which heavily uses proxies?<br>
&gt; 5.) Should we at least specify that &#39;non portable behaviour results&#39;?<br>
&gt;<br>
&gt;<br>
&gt; LieGrue,<br>
&gt; strub<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; ----- Original Message -----<br>
&gt;&gt; From: Pete Muir &lt;<a href="mailto:pmuir@redhat.com">pmuir@redhat.com</a>&gt;<br>
&gt;&gt; To: Mark Struberg &lt;<a href="mailto:struberg@yahoo.de">struberg@yahoo.de</a>&gt;<br>
&gt;&gt; Cc: <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a>; Stuart Douglas &lt;<a href="mailto:sdouglas@redhat.com">sdouglas@redhat.com</a>&gt;<br>
&gt;&gt; Sent: Monday, March 14, 2011 12:52 PM<br>
&gt;&gt; Subject: Re: [cdi-dev] calling &#39;equals&#39; on a proxy?<br>
&gt;&gt;<br>
&gt;&gt; Stuart, you had this one worked out right? I believe the spec says the behaviour<br>
&gt;&gt; is unspecified.<br>
&gt;&gt;<br>
&gt;&gt; On 7 Mar 2011, at 15:52, Mark Struberg wrote:<br>
&gt;&gt;<br>
&gt;&gt;&gt;   Hi Pete, others!<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;   Do you remember our discussion about what should happen if equals() gets<br>
&gt;&gt; called on a proxy?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;   Should it route to the equals method of the currently proxied instance?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;   LieGrue,<br>
&gt;&gt;&gt;   strub<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;   _______________________________________________<br>
&gt;&gt;&gt;   cdi-dev mailing list<br>
&gt;&gt;&gt;   <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
&gt;&gt;&gt;   <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; cdi-dev mailing list<br>
&gt; <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
&gt; <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>
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>
</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>