[jboss-cvs] JBossAS SVN: r58777 - in branches/Branch_AOP_1_5/aop: . src/main/org/jboss/aop/instrument src/resources/test/regression src/test/org/jboss/test/aop/regression src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Nov 30 11:59:49 EST 2006
Author: kabir.khan at jboss.com
Date: 2006-11-30 11:59:43 -0500 (Thu, 30 Nov 2006)
New Revision: 58777
Added:
branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/
branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/AnnotationsInWrapperMethodOnlyTestCase.java
branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/POJO.java
branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/TestAnnotation.java
Modified:
branches/Branch_AOP_1_5/aop/build.xml
branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorMethodExecutionTransformer.java
branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/MethodExecutionTransformer.java
branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/NonOptimizedMethodExecutionTransformer.java
branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/OptimizedMethodExecutionTransformer.java
branches/Branch_AOP_1_5/aop/src/resources/test/regression/jboss-aop.xml
Log:
[JBAOP-316] When intercepting method execution, only the wrapper method with the original name should have the annotations. The "internal" method containing the original method body should not have the annotations
Modified: branches/Branch_AOP_1_5/aop/build.xml
===================================================================
--- branches/Branch_AOP_1_5/aop/build.xml 2006-11-30 16:46:07 UTC (rev 58776)
+++ branches/Branch_AOP_1_5/aop/build.xml 2006-11-30 16:59:43 UTC (rev 58777)
@@ -704,6 +704,7 @@
<classpath path="${build.tests.classes}"/>
<src path="${source.tests.java}"/>
<include name="org/jboss/test/aop/annotatedcflow/*.java"/>
+ <include name="org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/*.java"/>
</annotationc>
<antcall target="_run-bootclasspath-test" inheritRefs="true">
@@ -914,6 +915,7 @@
<include name="org/jboss/test/aop/annotated/*.java"/>
<include name="org/jboss/test/aop/instanceofannotated/*.java"/>
<include name="org/jboss/test/aop/implementz/*.java"/>
+ <include name="org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/*.java"/>
</annotationc>
<antcall target="_run-precompiled-test" inheritRefs="true">
@@ -1630,6 +1632,7 @@
<classpath path="${build.tests.classes}"/>
<src path="${source.tests.java}"/>
<include name="org/jboss/test/aop/annotationc/*.java"/>
+ <include name="org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/*.java"/>
</annotationc>
<junit printsummary="yes" fork="yes" haltonfailure="no" jvm="${jrockit.home}/bin/java">
Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorMethodExecutionTransformer.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorMethodExecutionTransformer.java 2006-11-30 16:46:07 UTC (rev 58776)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorMethodExecutionTransformer.java 2006-11-30 16:59:43 UTC (rev 58777)
@@ -119,7 +119,7 @@
clazz);
clazz.addMethod(original);
long hash = JavassistMethodHashing.methodHash(original);
- copyAnnotations(mixinMethod, original);
+ moveAnnotations(mixinMethod, original);
String originalBody =
"{" +
" " + getReturnStr(original) + " " + Instrumentor.mixinFieldName(mixinClass) + "." + mixinMethod.getName() + "($$);" +
@@ -131,7 +131,7 @@
wmethod.setName(wrappedName);
clazz.addMethod(wmethod);
- copyAnnotations(original, wmethod);
+ moveAnnotations(original, wmethod);
original.setName(wrappedName);
wmethod.setName(originalName);
@@ -164,7 +164,7 @@
String originalName = trans.getOriginalName();
wmethod.setName(wrappedName);
trans.getClazz().addMethod(wmethod);
- copyAnnotations(trans.getMethod(), wmethod);
+ moveAnnotations(trans.getMethod(), wmethod);
trans.getMethod().setName(wrappedName);
wmethod.setName(originalName);
Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/MethodExecutionTransformer.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/MethodExecutionTransformer.java 2006-11-30 16:46:07 UTC (rev 58776)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/MethodExecutionTransformer.java 2006-11-30 16:59:43 UTC (rev 58777)
@@ -235,7 +235,7 @@
}
}
- protected void copyAnnotations(CtMethod src, CtMethod dest)
+ protected void moveAnnotations(CtMethod src, CtMethod dest)
{
MethodInfo mi = src.getMethodInfo2();
MethodInfo wmi = dest.getMethodInfo2();
@@ -249,6 +249,8 @@
{
wmi.addAttribute(visible.copy(wmi.getConstPool(), new HashMap()));
}
+ mi.addAttribute(new AnnotationsAttribute(mi.getConstPool(), AnnotationsAttribute.invisibleTag));
+ mi.addAttribute(new AnnotationsAttribute(mi.getConstPool(), AnnotationsAttribute.visibleTag));
}
protected static String getAopReturnStr(CtMethod method)throws NotFoundException
Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/NonOptimizedMethodExecutionTransformer.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/NonOptimizedMethodExecutionTransformer.java 2006-11-30 16:46:07 UTC (rev 58776)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/NonOptimizedMethodExecutionTransformer.java 2006-11-30 16:59:43 UTC (rev 58777)
@@ -53,7 +53,7 @@
String originalName = trans.getOriginalName();
wmethod.setName(wrappedName);
trans.getClazz().addMethod(wmethod);
- copyAnnotations(trans.getMethod(), wmethod);
+ moveAnnotations(trans.getMethod(), wmethod);
trans.getMethod().setName(wrappedName);
wmethod.setName(originalName);
Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/OptimizedMethodExecutionTransformer.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/OptimizedMethodExecutionTransformer.java 2006-11-30 16:46:07 UTC (rev 58776)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/OptimizedMethodExecutionTransformer.java 2006-11-30 16:59:43 UTC (rev 58777)
@@ -55,7 +55,7 @@
String originalName = trans.getOriginalName();
wmethod.setName(wrappedName);
trans.getClazz().addMethod(wmethod);
- copyAnnotations(trans.getMethod(), wmethod);
+ moveAnnotations(trans.getMethod(), wmethod);
String optimizedInvocation = OptimizedMethodInvocations.createOptimizedInvocationClass(trans.getInstrumentor(), trans.getClazz(), trans.getMethod());
trans.getMethod().setName(wrappedName);
wmethod.setName(originalName);
Modified: branches/Branch_AOP_1_5/aop/src/resources/test/regression/jboss-aop.xml
===================================================================
--- branches/Branch_AOP_1_5/aop/src/resources/test/regression/jboss-aop.xml 2006-11-30 16:46:07 UTC (rev 58776)
+++ branches/Branch_AOP_1_5/aop/src/resources/test/regression/jboss-aop.xml 2006-11-30 16:59:43 UTC (rev 58777)
@@ -125,4 +125,6 @@
<bind pointcut="execution(* org.jboss.test.aop.regression.jbaop279native.POJO->nativeMethod())">
<interceptor class="org.jboss.test.aop.regression.jbaop279native.ReturningInterceptor"/>
</bind>
+
+ <prepare expr="all(org.jboss.test.aop.regression.jbaop316annotationsinwrapperonly.POJO)"/>
</aop>
Added: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/AnnotationsInWrapperMethodOnlyTestCase.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/AnnotationsInWrapperMethodOnlyTestCase.java 2006-11-30 16:46:07 UTC (rev 58776)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/AnnotationsInWrapperMethodOnlyTestCase.java 2006-11-30 16:59:43 UTC (rev 58777)
@@ -0,0 +1,81 @@
+/*
+ * 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.aop.Advisor;
+
+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 AnnotationsInWrapperMethodOnlyTestCase extends junit.framework.TestCase
+{
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("AnnotationsInWrapperMethodOnlyTestCase");
+ suite.addTestSuite(AnnotationsInWrapperMethodOnlyTestCase.class);
+ return suite;
+ }
+
+ public AnnotationsInWrapperMethodOnlyTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testAnnotationNotInInternalCopy()throws Exception
+ {
+ POJO pojo = new POJO();
+ Method[] methods = POJO.class.getMethods();
+ Advisor advisor = ((Advised)pojo)._getAdvisor();
+
+ ArrayList hasAnnotation = new ArrayList();
+ for (int i = 0 ; i < methods.length ; i++)
+ {
+ Object ann = advisor.resolveAnnotation(methods[i], TestAnnotation.class);
+ if (ann != null)
+ {
+ 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));
+ }
+
+}
Added: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/POJO.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/POJO.java 2006-11-30 16:46:07 UTC (rev 58776)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/POJO.java 2006-11-30 16:59:43 UTC (rev 58777)
@@ -0,0 +1,38 @@
+/*
+* 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.regression.jbaop316annotationsinwrapperonly;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class POJO
+{
+ /**
+ * @@org.jboss.test.aop.regression.jbaop316annotationsinwrapperonly.TestAnnotation
+ */
+ public void method()
+ {
+
+ }
+}
Added: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/TestAnnotation.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/TestAnnotation.java 2006-11-30 16:46:07 UTC (rev 58776)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/TestAnnotation.java 2006-11-30 16:59:43 UTC (rev 58777)
@@ -0,0 +1,31 @@
+/*
+* 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.regression.jbaop316annotationsinwrapperonly;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public interface TestAnnotation {
+
+}
More information about the jboss-cvs-commits
mailing list