On Wednesday 28 November 2001 12:49, Dain Sundstrom wrote:
> I fixed this one.
>
> In the startup code I generate one bean the old way
> (Proxy.newProxyInstance), and then I steal the constructor from the
> generated object. Then when a new bean instance is requested, I just use
> the constructor.
>
> > >
> > > It appears that each instance of the Bean is created with a
> > > different Class
> > > instance using different instance of the ClassLoader. Is this
> > > on purpose?
> > > Wouldn't it be better to use the same Class?
> >
> > You would think so.
> >
> > My use of the proxy generator is obviously broken. I'll look
> > at it after
> > some sleep.
Good morning!
It might be that your use of the proxy generator is not broken at all but the
generator itself is. There's a method in the inner static class
org.jboss.proxy.Proxies.Impl that claims this:
// do the arrays have the same elements?
// (duplication and reordering are ignored)
static boolean sameTypes(Class tt1[], Class tt2[])
...but in fact some tests of this method reveal quite the opposite:
[Object, Serializable] == [Serializable, Object]: false
[Object, Serializable, Object] == [Object, Serializable, Object]: false
[Object] == [Object]: false
[Object] == [Object, Serializable]: true
[Object] == []: Exception in thread "main"
java.lang.ArrayIndexOutOfBoundsException
There are two bugs in this method. Can you spot them?
:
:... the answer is below...
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
... the first line of the method is:
if (tt1.length == 1 && tt2.length == 0)
... but should be:
if (tt1.length == 1 && tt2.length == 1)
... the last line of the method is:
return totalSeen2 != tt2.length;
... but should be:
return totalSeen2 == tt2.length;
With corrections applied, the tests return:
[Object, Serializable] == [Serializable, Object]: true
[Object, Serializable, Object] == [Object, Serializable, Object]: true
[Object] == [Object]: true
[Object] == [Object, Serializable]: false
[Object] == []: false
I think that some other parts of the JBoss would benefit from this patch :-)
Regards, Peter
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development