Hi,

If I use dynamic AOP and the "Design by Contract" @Dbc at the same time I get 
strange "duplicate method" error.  This only occur for class methods that are 
implementing an interface method but
the class method return type is overriding the method return type defined 
defined in the interface;

javassist.CannotCompileException: duplicate method: 
test$dynamicaop$MyClass$getObj$aop
 at javassist.bytecode.ClassFile.testExistingMethod(ClassFile.java:544)
 at javassist.bytecode.ClassFile.addMethod(ClassFile.java:528)
 at javassist.CtClassType.addMethod(CtClassType.java:1099)
 .........

I'm running it within eclipse using loadtime instrumentation.  JVM args;

-Djboss.aop.path=META-INF/jboss-aop.xml -javaagent:lib/jboss-aop-jdk50.jar 
-Djboss.aop.verbose=true


Setup was based on the dynamic aop tutorial but I've stripped out what is not 
relevant;


Driver.java
public class Driver {
  |    public static void main(String[] args) throws Exception {
  |       execute();
  |    }
  |    
  |    public static void execute() {
  |       MyClass obj = new MyClass();      
  |    }
  | }


MyObj.java
package test.dynamicaop;
  | 
  | import org.jboss.aspects.dbc.Dbc;
  | 
  | @Dbc
  | public class MyClass implements MyInterface {
  |  
  |  /*
  |   * Runs ok if method is - public Object getObj() {  return new MyObj();  }
  |   */
  |  public MyObj getObj() {  
  |   return new MyObj();
  |  }
  | }




MyInterface .java

  | package test.dynamicaop;
  | 
  | public interface MyInterface { 
  |  public Object getObj(); 
  | }


jboss-aop.xml 

  | <?xml version="1.0" encoding="UTF-8"?>
  | <aop>
  |    <prepare expr="all(test.dynamicaop.POJO)"/>
  | 
  |    <aspect class="org.jboss.aspects.dbc.DesignByContractAspect" 
scope="PER_JOINPOINT">
  |       <attribute name="verbose">true</attribute>
  |    </aspect>   
  |    
  |    <bind pointcut="execution(* [EMAIL PROTECTED]>*(..)) OR execution([EMAIL 
PROTECTED]>new(..))">
  |       <advice aspect="org.jboss.aspects.dbc.DesignByContractAspect" 
name="invoke"/>
  |    </bind> 
  | 
  | </aop>


Adjust the public MyObj getObj() method to public Object getObj() and its ok. 

regards

James




View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3945858#3945858

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3945858


-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to