[jboss-cvs] JBossAS SVN: r59070 - in projects/aop/trunk/aop/src: main/org/jboss/aop/instrument test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Dec 18 05:54:27 EST 2006


Author: kabir.khan at jboss.com
Date: 2006-12-18 05:54:24 -0500 (Mon, 18 Dec 2006)
New Revision: 59070

Removed:
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/AnnotationsInWrapperMethodOnly.java
Modified:
   projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/MethodExecutionTransformer.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/POJO.java
Log:
[JBAOP-329] Parameter annotations should exist in wrapper method and not the internal method

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/MethodExecutionTransformer.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/MethodExecutionTransformer.java	2006-12-18 08:06:42 UTC (rev 59069)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/MethodExecutionTransformer.java	2006-12-18 10:54:24 UTC (rev 59070)
@@ -37,6 +37,8 @@
 import javassist.NotFoundException;
 import javassist.bytecode.AnnotationsAttribute;
 import javassist.bytecode.MethodInfo;
+import javassist.bytecode.ParameterAnnotationsAttribute;
+import javassist.bytecode.annotation.Annotation;
 
 /**
  * Comment
@@ -235,24 +237,44 @@
       }
    }
 
-   protected void moveAnnotations(CtMethod src, CtMethod dest)
+   protected void moveAnnotations(CtMethod src, CtMethod dest) throws NotFoundException
    {
       MethodInfo mi = src.getMethodInfo2();
       MethodInfo wmi = dest.getMethodInfo2();
-      AnnotationsAttribute invisible = (AnnotationsAttribute) mi.getAttribute(AnnotationsAttribute.invisibleTag);
-      if (invisible != null)
+
+      moveAnnotations(mi, wmi, AnnotationsAttribute.invisibleTag);
+      moveAnnotations(mi, wmi, AnnotationsAttribute.visibleTag);
+      int numParams = src.getParameterTypes().length;
+      moveParameterAnnotations(numParams, mi, wmi, ParameterAnnotationsAttribute.visibleTag);
+      moveParameterAnnotations(numParams, mi, wmi, ParameterAnnotationsAttribute.invisibleTag);
+   }
+
+   private void moveAnnotations(MethodInfo src, MethodInfo dest, String annotationTag)
+   {
+      AnnotationsAttribute attribute = (AnnotationsAttribute) src.getAttribute(annotationTag);
+      if (attribute != null)
       {
-         wmi.addAttribute(invisible.copy(wmi.getConstPool(), new HashMap()));
+         dest.addAttribute(attribute.copy(dest.getConstPool(), new HashMap()));
+         src.addAttribute(new AnnotationsAttribute(src.getConstPool(), annotationTag));
       }
-      AnnotationsAttribute visible = (AnnotationsAttribute) mi.getAttribute(AnnotationsAttribute.visibleTag);
-      if (visible != null)
+   }
+   
+   private void moveParameterAnnotations(int numParams, MethodInfo src, MethodInfo dest, String paramsTag)
+   {
+      ParameterAnnotationsAttribute params = (ParameterAnnotationsAttribute)src.getAttribute(paramsTag);
+      if (params != null)
       {
-         wmi.addAttribute(visible.copy(wmi.getConstPool(), new HashMap()));
+         dest.addAttribute(params.copy(dest.getConstPool(), new HashMap()));
+         ParameterAnnotationsAttribute srcParams = new ParameterAnnotationsAttribute(src.getConstPool(), paramsTag);
+         Annotation[][] emptyParamAnnotations = new Annotation[numParams][];
+         for (int i = 0 ; i < numParams ; i++)
+         {
+            emptyParamAnnotations[i] = new Annotation[0];
+         }
+         srcParams.setAnnotations(emptyParamAnnotations);
+         src.addAttribute(srcParams);
       }
-      mi.addAttribute(new AnnotationsAttribute(mi.getConstPool(), AnnotationsAttribute.invisibleTag));
-      mi.addAttribute(new AnnotationsAttribute(mi.getConstPool(), AnnotationsAttribute.visibleTag));
    }
-   
 
    protected static String getAopReturnStr(CtMethod method)throws NotFoundException
    {

Deleted: projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/AnnotationsInWrapperMethodOnly.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/AnnotationsInWrapperMethodOnly.java	2006-12-18 08:06:42 UTC (rev 59069)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/AnnotationsInWrapperMethodOnly.java	2006-12-18 10:54:24 UTC (rev 59070)
@@ -1,79 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt 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.regression.jbaop316annotationsinwrapperonly;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-
-import org.jboss.aop.Advised;
-import org.jboss.test.aop.AOPTestWithSetup;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-
-
-/**
- * http://jira.jboss.com/jira/browse/JBAOP-316
- * 
- * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
- * @version $Revision: 45977 $
- */
-public class AnnotationsInWrapperMethodOnly extends AOPTestWithSetup
-{
-   public static void main(String[] args)
-   {
-      TestRunner.run(suite());
-   }
-
-   public static Test suite()
-   {
-      TestSuite suite = new TestSuite("AnnotationsInWrapperMethodOnly");
-      suite.addTestSuite(AnnotationsInWrapperMethodOnly.class);
-      return suite;
-   }
-
-   public AnnotationsInWrapperMethodOnly(String name)
-   {
-      super(name);
-   }
-
-   public void testAnnotationNotInInternalCopy()throws Exception
-   {
-      Method[] methods = POJO.class.getMethods();
-      
-      ArrayList hasAnnotation = new ArrayList();
-      for (int i = 0 ; i < methods.length ; i++)
-      {
-         if (methods[i].isAnnotationPresent(TestAnnotation.class))
-         {
-            hasAnnotation.add(methods[i].getName());
-         }
-      }
-      
-      assertFalse("Expected to find annotation for 'method'", hasAnnotation.size() == 0);
-      assertTrue("Expected to find annotation for 'method' only, it was found for " + hasAnnotation, hasAnnotation.size() == 1);
-      assertEquals("method", hasAnnotation.get(0));
-      assertTrue("Class was not woven", Advised.class.isAssignableFrom(POJO.class));
-   }
-
-}

Modified: projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/POJO.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/POJO.java	2006-12-18 08:06:42 UTC (rev 59069)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/POJO.java	2006-12-18 10:54:24 UTC (rev 59070)
@@ -29,7 +29,7 @@
 public class POJO
 {
    @TestAnnotation
-   public void method()
+   public void method(int i, @TestAnnotation String s)
    {
       
    }




More information about the jboss-cvs-commits mailing list