You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by Martin Kalén <mk...@apache.org> on 2006/09/15 16:21:16 UTC

ProxyExamples#testReferenceProxyWithInheritance

Is the testcase ProxyExamples#testReferenceProxyWithInheritance
a known failure on the 1.0.x branch at the moment?

I'm currently looking into a fix for dynamic proxies when using
per-thread metadata profiles - a follow-up on a fix I did for
CollectionProxy-instances a long time ago, see:
http://mail-archives.apache.org/mod_mbox/db-ojb-dev/200410.mbox/%3c41615921.4000508@curalia.se%3e

I have not actually tried to rollback my changes and see if they
are responsible but the are so isolated to per-thread mode so
I am pretty sure they are not...

testReferenceProxyWithInheritance fails because the proxied unloaded
instances are only instanceof Ownable, not the specific instanceof
checked by the following asserts in the testcase:
325:assertTrue(owned1 instanceof Ownable2);
326:assertTrue(owned2 instanceof Ownable1);

There is a comment in the testcase:
323:// This should be true according the docs of class Proxy and because
324:// the concrete classes are Onwable2Impl/Onwable1Impl

However, are not the comments and asserts wrong? The proxies are
instanceof Ownable until they are materialized, when the instances
are indeed instanceof the more specific interfaces.

If I change the testcase lines 325-326 to this:
  assertTrue(owned1 instanceof Ownable);
  assertTrue(owned2 instanceof Ownable);
  assertTrue(ProxyHelper.getRealObject(owned1) instanceof Ownable2);
  assertTrue(ProxyHelper.getRealObject(owned2) instanceof Ownable1);
...it passes.

Any comments on this? I am thinking wrong and the old testcase code
correct? (In that case something in proxy generation code needs to
be fixed, since the test currently fails.)

Regards,
  Martin


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Re: ProxyExamples#testReferenceProxyWithInheritance

Posted by Martin Kalén <mk...@apache.org>.
Thomas Dudziak wrote:
>> Is the testcase ProxyExamples#testReferenceProxyWithInheritance
>> a known failure on the 1.0.x branch at the moment?
> 
> Yep, that's a known failure. I was using OJB at work and had this
> strange 'issue' that a testing a proxy via instanceof for an interface
> did always produce false. The problem is that for the creation of the
> proxy, we only use the declared interfaces, not all the concrete ones
> that the object actually implements.
> While this is logical (we don't know the concrete type and hence the
> interfaces at the point of creation of the interface), it is quite
> inconvenient.

OK, I just committed my change to make dynamic proxies work under the
same conditions as collection proxies with per-thread metadata profiles.

Regarding the proxy interface issue I cannot really tell how OJB
"should" behave. Any changes after concensus on that issue will
not be affected by my changes in AbstractIndirectionHandler.

Regards,
  Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Re: ProxyExamples#testReferenceProxyWithInheritance

Posted by Thomas Dudziak <to...@gmail.com>.
On 9/15/06, Martin Kalén <mk...@apache.org> wrote:
> Is the testcase ProxyExamples#testReferenceProxyWithInheritance
> a known failure on the 1.0.x branch at the moment?

Yep, that's a known failure. I was using OJB at work and had this
strange 'issue' that a testing a proxy via instanceof for an interface
did always produce false. The problem is that for the creation of the
proxy, we only use the declared interfaces, not all the concrete ones
that the object actually implements.
While this is logical (we don't know the concrete type and hence the
interfaces at the point of creation of the interface), it is quite
inconvenient.

Tom

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org