[cdi-dev] calling 'equals' on a proxy?

Rick Hightower richardhightower at gmail.com
Tue Oct 18 16:42:12 EDT 2011


Currently the docs say this.... 5.4.2.

•Behavior of all methods declared by java.lang.Object, except for
toString(), is undefined for a client proxy
•Portable applications should not invoke any method declared by
java.lang.Object, except for toString(), on a client proxy

I so don't agree with what is in the spec. now on this subject.
(Realizing that it is a work in progress...)

I think we should change this and call the underlying implementation for
these methods.

Also equals and hashCode should work by unpacking and comparing the
contextual instance.

Off topic....

It would be nice if there was a utility API that implementations had to
implement that had these methods


isProxy (lets you know if an object is a client proxy)
getUnproxiedVersion (gives you the underlying unproxied version of the
object)


(It may exist already.)


On Tue, Oct 18, 2011 at 10:17 AM, Mark Struberg <struberg at yahoo.de> wrote:

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



-- 
*Rick Hightower*
(415) 968-9037
Profile <http://www.google.com/profiles/RichardHightower>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/cdi-dev/attachments/20111018/9330b9d2/attachment.html 


More information about the cdi-dev mailing list