[jboss-cvs] JBossAS SVN: r105763 - in projects/aop/branches/Branch_2_2/aop: src/main/java/org/jboss/aop/instrument and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jun 7 11:18:56 EDT 2010


Author: kabir.khan at jboss.com
Date: 2010-06-07 11:18:55 -0400 (Mon, 07 Jun 2010)
New Revision: 105763

Added:
   projects/aop/branches/Branch_2_2/aop/src/resources/test/genericintroduction/
   projects/aop/branches/Branch_2_2/aop/src/resources/test/genericintroduction/jboss-aop.xml
   projects/aop/branches/Branch_2_2/aop/src/test/java/org/jboss/test/aop/genericintroduction/
   projects/aop/branches/Branch_2_2/aop/src/test/java/org/jboss/test/aop/genericintroduction/GenericIntroductionSignatureTestCase.java
   projects/aop/branches/Branch_2_2/aop/src/test/java/org/jboss/test/aop/genericintroduction/Interface1.java
   projects/aop/branches/Branch_2_2/aop/src/test/java/org/jboss/test/aop/genericintroduction/NoSuperclassNoInterfacesPOJO.java
   projects/aop/branches/Branch_2_2/aop/src/test/java/org/jboss/test/aop/genericintroduction/UncheckedNoSuperclassNoInterfacesPOJO.java
Modified:
   projects/aop/branches/Branch_2_2/aop/base-tests.xml
   projects/aop/branches/Branch_2_2/aop/src/main/java/org/jboss/aop/instrument/GeneratedAdvisorMethodExecutionTransformer.java
   projects/aop/branches/Branch_2_2/aop/src/main/java/org/jboss/aop/instrument/MethodExecutionTransformer.java
   projects/aop/branches/Branch_2_2/aop/src/main/java/org/jboss/aop/instrument/NonOptimizedMethodExecutionTransformer.java
   projects/aop/branches/Branch_2_2/aop/src/main/java/org/jboss/aop/instrument/OptimizedMethodExecutionTransformer.java
Log:
[JBAOP-795] Don't copy method signature attribute for introduced methods

Modified: projects/aop/branches/Branch_2_2/aop/base-tests.xml
===================================================================
--- projects/aop/branches/Branch_2_2/aop/base-tests.xml	2010-06-07 15:06:08 UTC (rev 105762)
+++ projects/aop/branches/Branch_2_2/aop/base-tests.xml	2010-06-07 15:18:55 UTC (rev 105763)
@@ -106,6 +106,9 @@
       <antcall target="${test-target}" inheritRefs="true">
          <param name="test" value="standalone"/>
       </antcall>
+      <antcall target="${test-target}" inheritRefs="true">
+         <param name="test" value="genericintroduction"/>
+      </antcall>
       
       <!-- Tests with special requirements for parameters -->
       <antcall target="${test-target}" inheritRefs="true">

Modified: projects/aop/branches/Branch_2_2/aop/src/main/java/org/jboss/aop/instrument/GeneratedAdvisorMethodExecutionTransformer.java
===================================================================
--- projects/aop/branches/Branch_2_2/aop/src/main/java/org/jboss/aop/instrument/GeneratedAdvisorMethodExecutionTransformer.java	2010-06-07 15:06:08 UTC (rev 105762)
+++ projects/aop/branches/Branch_2_2/aop/src/main/java/org/jboss/aop/instrument/GeneratedAdvisorMethodExecutionTransformer.java	2010-06-07 15:18:55 UTC (rev 105763)
@@ -127,14 +127,14 @@
             clazz);
       clazz.addMethod(original);
       long hash = JavassistMethodHashing.methodHash(original);
-      moveAnnotationsAndCopySignature(mixinMethod, original);
+      moveAnnotationsAndCopySignature(true, mixinMethod, original);
 
       String wrappedName = ClassAdvisor.notAdvisedMethodName(clazz.getName(), originalName);
       CtMethod wmethod = CtNewMethod.copy(original, clazz, null);
 
       wmethod.setName(wrappedName);
       clazz.addMethod(wmethod);
-      moveAnnotationsAndCopySignature(original, wmethod);
+      moveAnnotationsAndCopySignature(true, original, wmethod);
 
       original.setName(wrappedName);
       Instrumentor.addSyntheticAttribute(original);
@@ -225,14 +225,14 @@
             clazz);
       clazz.addMethod(original);
       long hash = JavassistMethodHashing.methodHash(original);
-      moveAnnotationsAndCopySignature(mixinMethod, original);
+      moveAnnotationsAndCopySignature(true, mixinMethod, original);
 
       String wrappedName = ClassAdvisor.notAdvisedMethodName(clazz.getName(), originalName);
       CtMethod wmethod = CtNewMethod.copy(original, clazz, null);
 
       wmethod.setName(wrappedName);
       clazz.addMethod(wmethod);
-      moveAnnotationsAndCopySignature(original, wmethod);
+      moveAnnotationsAndCopySignature(true, original, wmethod);
 
       original.setName(wrappedName);
       Instrumentor.addSyntheticAttribute(original);
@@ -294,7 +294,7 @@
       String originalName = trans.getOriginalName();
       wmethod.setName(wrappedName);
       trans.getClazz().addMethod(wmethod);
-      moveAnnotationsAndCopySignature(trans.getMethod(), wmethod);
+      moveAnnotationsAndCopySignature(false, trans.getMethod(), wmethod);
       trans.getMethod().setName(wrappedName);
       Instrumentor.addSyntheticAttribute(trans.getMethod());
       wmethod.setName(originalName);

Modified: projects/aop/branches/Branch_2_2/aop/src/main/java/org/jboss/aop/instrument/MethodExecutionTransformer.java
===================================================================
--- projects/aop/branches/Branch_2_2/aop/src/main/java/org/jboss/aop/instrument/MethodExecutionTransformer.java	2010-06-07 15:06:08 UTC (rev 105762)
+++ projects/aop/branches/Branch_2_2/aop/src/main/java/org/jboss/aop/instrument/MethodExecutionTransformer.java	2010-06-07 15:18:55 UTC (rev 105763)
@@ -233,7 +233,7 @@
       }
    }
 
-   protected void moveAnnotationsAndCopySignature(CtMethod src, CtMethod dest) throws NotFoundException
+   protected void moveAnnotationsAndCopySignature(boolean copySignature, CtMethod src, CtMethod dest) throws NotFoundException
    {
       MethodInfo mi = src.getMethodInfo2();
       MethodInfo wmi = dest.getMethodInfo2();
@@ -243,7 +243,8 @@
       int numParams = src.getParameterTypes().length;
       moveParameterAnnotations(numParams, mi, wmi, ParameterAnnotationsAttribute.visibleTag);
       moveParameterAnnotations(numParams, mi, wmi, ParameterAnnotationsAttribute.invisibleTag);
-      copySignature(mi, wmi);
+      if (!copySignature)
+         copySignature(mi, wmi);
    }
 
    private void moveAnnotations(MethodInfo src, MethodInfo dest, String annotationTag)

Modified: projects/aop/branches/Branch_2_2/aop/src/main/java/org/jboss/aop/instrument/NonOptimizedMethodExecutionTransformer.java
===================================================================
--- projects/aop/branches/Branch_2_2/aop/src/main/java/org/jboss/aop/instrument/NonOptimizedMethodExecutionTransformer.java	2010-06-07 15:06:08 UTC (rev 105762)
+++ projects/aop/branches/Branch_2_2/aop/src/main/java/org/jboss/aop/instrument/NonOptimizedMethodExecutionTransformer.java	2010-06-07 15:18:55 UTC (rev 105763)
@@ -53,7 +53,7 @@
       String originalName = trans.getOriginalName();
       wmethod.setName(wrappedName);
       trans.getClazz().addMethod(wmethod);
-      moveAnnotationsAndCopySignature(trans.getMethod(), wmethod);
+      moveAnnotationsAndCopySignature(false, trans.getMethod(), wmethod);
       trans.getMethod().setName(wrappedName);
       Instrumentor.addSyntheticAttribute(trans.getMethod());
       wmethod.setName(originalName);

Modified: projects/aop/branches/Branch_2_2/aop/src/main/java/org/jboss/aop/instrument/OptimizedMethodExecutionTransformer.java
===================================================================
--- projects/aop/branches/Branch_2_2/aop/src/main/java/org/jboss/aop/instrument/OptimizedMethodExecutionTransformer.java	2010-06-07 15:06:08 UTC (rev 105762)
+++ projects/aop/branches/Branch_2_2/aop/src/main/java/org/jboss/aop/instrument/OptimizedMethodExecutionTransformer.java	2010-06-07 15:18:55 UTC (rev 105763)
@@ -55,7 +55,7 @@
       String originalName = trans.getOriginalName();
       wmethod.setName(wrappedName);
       trans.getClazz().addMethod(wmethod);
-      moveAnnotationsAndCopySignature(trans.getMethod(), wmethod);
+      moveAnnotationsAndCopySignature(false, trans.getMethod(), wmethod);
       String optimizedInvocation = OptimizedMethodInvocations.createOptimizedInvocationClass(trans.getInstrumentor(), trans.getClazz(), trans.getMethod(), wmethod);
       trans.getMethod().setName(wrappedName);
       Instrumentor.addSyntheticAttribute(trans.getMethod());

Added: projects/aop/branches/Branch_2_2/aop/src/resources/test/genericintroduction/jboss-aop.xml
===================================================================
--- projects/aop/branches/Branch_2_2/aop/src/resources/test/genericintroduction/jboss-aop.xml	                        (rev 0)
+++ projects/aop/branches/Branch_2_2/aop/src/resources/test/genericintroduction/jboss-aop.xml	2010-06-07 15:18:55 UTC (rev 105763)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<aop>
+   <introduction class="org.jboss.test.aop.genericintroduction.NoSuperclassNoInterfacesPOJO">
+      <interfaces>
+         org.jboss.test.aop.genericintroduction.Interface1
+      </interfaces>
+   </introduction>
+</aop>
\ No newline at end of file

Added: projects/aop/branches/Branch_2_2/aop/src/test/java/org/jboss/test/aop/genericintroduction/GenericIntroductionSignatureTestCase.java
===================================================================
--- projects/aop/branches/Branch_2_2/aop/src/test/java/org/jboss/test/aop/genericintroduction/GenericIntroductionSignatureTestCase.java	                        (rev 0)
+++ projects/aop/branches/Branch_2_2/aop/src/test/java/org/jboss/test/aop/genericintroduction/GenericIntroductionSignatureTestCase.java	2010-06-07 15:18:55 UTC (rev 105763)
@@ -0,0 +1,114 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.aop.genericintroduction;
+
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.test.aop.AOPTestWithSetup;
+
+/**
+ * Make sure that interface introductions don't break the method signatures
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class GenericIntroductionSignatureTestCase extends AOPTestWithSetup
+{
+   public GenericIntroductionSignatureTestCase(String arg0)
+   {
+      super(arg0);
+   }
+
+   public void testNoSuperclassNoInterfacesPOJO()
+   {
+      AspectManager.debugClasses = true;
+      
+      NoSuperclassNoInterfacesPOJO pojo = new NoSuperclassNoInterfacesPOJO();
+      UncheckedNoSuperclassNoInterfacesPOJO control = new UncheckedNoSuperclassNoInterfacesPOJO();
+      
+      Set<Class<?>> interfaces = createSet(pojo.getClass().getInterfaces());
+      assertTrue(interfaces.contains(Interface1.class));
+      
+      boolean found = false;
+      for (Method m : pojo.getClass().getDeclaredMethods())
+      {
+         if (m.getName().equals("introduced1"))
+         {
+            found = true;
+            
+            break;
+         }
+            
+      }
+      assertTrue(found);
+      testIntroducedMethods(pojo, control, Interface1.class);
+   }
+   
+   private void testIntroducedMethods(Object woven, Object control, Class<?> iface)
+   {
+      assertTrue(getInterfaces(woven).contains(iface));
+      assertTrue(getInterfaces(control).contains(iface));
+      
+      Method wovenMethod = getInterfaceMethod(woven, iface);
+      Method controlMethod = getInterfaceMethod(control, iface);
+      
+      assertEquals(controlMethod.getModifiers(), wovenMethod.getModifiers());
+      assertEquals(controlMethod.getParameterTypes(), wovenMethod.getParameterTypes());
+      assertEquals(controlMethod.getReturnType(), wovenMethod.getReturnType());
+      assertEquals(controlMethod.getExceptionTypes(), wovenMethod.getExceptionTypes());
+      
+      assertEquals(controlMethod.getGenericReturnType(), wovenMethod.getGenericReturnType());
+      assertEquals(controlMethod.getGenericParameterTypes(), wovenMethod.getGenericParameterTypes());
+      assertEquals(controlMethod.getGenericExceptionTypes(), wovenMethod.getGenericExceptionTypes());
+   }
+   
+   private Method getInterfaceMethod(Object o, Class<?> iface)
+   {
+      Method[] methods = iface.getDeclaredMethods();
+      assertTrue(methods.length == 1);
+      
+      for (Method m : o.getClass().getDeclaredMethods())
+      {
+         if (m.getName().equals(methods[0].getName()))
+            return m;
+      }
+      fail("Could not find method");
+      return null;
+   }
+   
+   private Set<Class<?>> getInterfaces(Object o)
+   {
+      return createSet(o.getClass().getInterfaces());
+   }
+   
+   private Set<Class<?>> createSet(Class<?>[] classes)
+   {
+      if (classes == null || classes.length == 0)
+         return Collections.<Class<?>>emptySet();
+      return new HashSet<Class<?>>(Arrays.asList(classes));
+   }
+}
\ No newline at end of file

Added: projects/aop/branches/Branch_2_2/aop/src/test/java/org/jboss/test/aop/genericintroduction/Interface1.java
===================================================================
--- projects/aop/branches/Branch_2_2/aop/src/test/java/org/jboss/test/aop/genericintroduction/Interface1.java	                        (rev 0)
+++ projects/aop/branches/Branch_2_2/aop/src/test/java/org/jboss/test/aop/genericintroduction/Interface1.java	2010-06-07 15:18:55 UTC (rev 105763)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.aop.genericintroduction;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public interface Interface1<T>
+{
+   T introduced1(T t);
+}

Added: projects/aop/branches/Branch_2_2/aop/src/test/java/org/jboss/test/aop/genericintroduction/NoSuperclassNoInterfacesPOJO.java
===================================================================
--- projects/aop/branches/Branch_2_2/aop/src/test/java/org/jboss/test/aop/genericintroduction/NoSuperclassNoInterfacesPOJO.java	                        (rev 0)
+++ projects/aop/branches/Branch_2_2/aop/src/test/java/org/jboss/test/aop/genericintroduction/NoSuperclassNoInterfacesPOJO.java	2010-06-07 15:18:55 UTC (rev 105763)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.aop.genericintroduction;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class NoSuperclassNoInterfacesPOJO
+{
+
+}

Added: projects/aop/branches/Branch_2_2/aop/src/test/java/org/jboss/test/aop/genericintroduction/UncheckedNoSuperclassNoInterfacesPOJO.java
===================================================================
--- projects/aop/branches/Branch_2_2/aop/src/test/java/org/jboss/test/aop/genericintroduction/UncheckedNoSuperclassNoInterfacesPOJO.java	                        (rev 0)
+++ projects/aop/branches/Branch_2_2/aop/src/test/java/org/jboss/test/aop/genericintroduction/UncheckedNoSuperclassNoInterfacesPOJO.java	2010-06-07 15:18:55 UTC (rev 105763)
@@ -0,0 +1,37 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.aop.genericintroduction;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at SuppressWarnings("unchecked")
+public class UncheckedNoSuperclassNoInterfacesPOJO implements Interface1
+{
+   public Object introduced1(Object t)
+   {
+      return null;
+   }
+
+}



More information about the jboss-cvs-commits mailing list