Bugs item #773087, was opened at 2003-07-17 18:05
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=773087&group_id=22866

Category: Aspects
Group: CVS HEAD
Status: Open
Resolution: None
Priority: 5
Submitted By: Laurent Etiemble (letiemble)
Assigned to: Bill Burke (patriot1burke)
Summary: Multiple mixins not supported

Initial Comment:
Hi,

I went through this bug while playing with mixin.
When multiple mixins are defined for a class, the
following exception is raised on mixin call :

Exception in thread "main"
java.lang.IllegalArgumentException: object is not an
instance of declaring class
        at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at
org.jboss.aop.ClassAdvisor$MethodTailInterceptor.invoke(Unknown
Source)
        at org.jboss.aop.Invocation.invokeNext(Unknown
Source)
        at
TracingInterceptor.invoke(TracingInterceptor.java:43)
        at org.jboss.aop.Invocation.invokeNext(Unknown
Source)
        at
org.jboss.aop.ClassAdvisor.invokeMethod(Unknown Source)
        at POJO._added_m$3(POJO.java)
        at POJO.disableLogging(POJO.java)
        at POJO.POJO$main$WithoutAdvisement(POJO.java:42)
        at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at
org.jboss.aop.ClassAdvisor$MethodTailInterceptor.invoke(Unknown
Source)
        at org.jboss.aop.Invocation.invokeNext(Unknown
Source)
        at
TracingInterceptor.invoke(TracingInterceptor.java:43)
        at org.jboss.aop.Invocation.invokeNext(Unknown
Source)
        at
org.jboss.aop.ClassAdvisor.invokeMethod(Unknown Source)
        at
org.jboss.aop.ClassAdvisor.invokeMethod(Unknown Source)
        at POJO._added_m$1(POJO.java)
        at POJO.main(POJO.java)


How to reproduce :
------------------
(Inspired from the example 3 of the O'Reilly article)
- Define a POJO class
- Define a TracingMixin class that implements Tracing
- Define a LoggingMixin class that implements Logging
- Apply the two mixins on the POJO class
- Make invocations on both mixin methods.

If the TracingMixin is first applied, the exception
occured on a Logging invocation.
If the LoggingMixin is first applied, the exception
occured on a Tracing invocation.


Analysis :
----------
When a mixin is added to a class, a mixin invocation
method is created to handle the mixin specific
invocations. This is done by the
"createMixinInvokeMethod" method in the
"org.jboss.aop.Instrumentor" class. But the name of the
created method is unique (or a least the generated one
by javassist) even for multiple mixin addition.


Workaround :
------------
The solution is to have a dedicated mixin invocation
method per mixin class. In the
"createMixinInvokeMethod" method in the
"org.jboss.aop.Instrumentor" class, the signature of
the created method has to be changed.

Replace :

"public java.lang.Object mixinInvoke(java.lang.Object[]
args, long i)" + ...

With :

"public java.lang.Object mixinInvoke" +
mixinFieldName(mixinClass) + "(java.lang.Object[] args,
long i)" + ...


Laurent.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=773087&group_id=22866


-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
_______________________________________________
JBoss-Development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to