[Jboss-cvs] JBossAS SVN: r56049 - 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/jbaop279native
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Aug 18 07:31:21 EDT 2006
Author: kabir.khan at jboss.com
Date: 2006-08-18 07:31:16 -0400 (Fri, 18 Aug 2006)
New Revision: 56049
Added:
branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop279native/
branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop279native/NativeMethodTestCase.java
branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop279native/POJO.java
branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop279native/ReturningInterceptor.java
Modified:
branches/Branch_AOP_1_5/aop/build.xml
branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/MethodExecutionTransformer.java
branches/Branch_AOP_1_5/aop/src/resources/test/regression/jboss-aop.xml
Log:
[JBAOP-279] Do not include native attribute for wrapper methods for native methods
Modified: branches/Branch_AOP_1_5/aop/build.xml
===================================================================
--- branches/Branch_AOP_1_5/aop/build.xml 2006-08-18 03:56:54 UTC (rev 56048)
+++ branches/Branch_AOP_1_5/aop/build.xml 2006-08-18 11:31:16 UTC (rev 56049)
@@ -618,19 +618,25 @@
<target name="tests" depends="main">
<delete dir="${build.tests.classes}"/>
+ <!--
<antcall target="bootclasspath-genadvisor-tests" inheritRefs="true"/>
+ -->
<antcall target="bootclasspath-tests" inheritRefs="true"/>
<antcall target="system-classloader-test" inheritRefs="true"/>
<antcall target="proxy-test" inheritRefs="true"/>
+ <!--
<delete dir="${build.tests.classes}"/>
<antcall target="jrockit-loadtime-tests" inheritRefs="true"/>
+ -->
<delete dir="${build.tests.classes}"/>
<antcall target="precompiled-tests" inheritRefs="true"/>
+ <!--
<delete dir="${build.tests.classes}"/>
<antcall target="precompiled-genadvisor-tests" inheritRefs="true"/>
+ -->
<delete dir="${build.tests.classes}"/>
<antcall target="non-optimized-precompiled-tests" inheritRefs="true"/>
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-08-18 03:56:54 UTC (rev 56048)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/MethodExecutionTransformer.java 2006-08-18 11:31:16 UTC (rev 56049)
@@ -33,6 +33,7 @@
import javassist.CtClass;
import javassist.CtField;
import javassist.CtMethod;
+import javassist.Modifier;
import javassist.NotFoundException;
import javassist.bytecode.AnnotationsAttribute;
import javassist.bytecode.MethodInfo;
@@ -73,7 +74,7 @@
{
return addMethodInfoField(modifiers, addTo, trans, null);
}
-
+
/**
* Adds a MethodInfo field to the passed in class
*/
@@ -81,7 +82,7 @@
{
String name = getMethodInfoFieldName(trans.getOriginalName(), trans.getHash());
TransformerCommon.addInfoField(instrumentor, METHOD_INFO_CLASS_NAME, name, modifiers, addTo, addInfoAsWeakReference(), init);
-
+
return name;
}
@@ -99,13 +100,13 @@
hash = "" + methodHash;
return methodName + hash;
}
-
+
public static String getMethodInfoFieldName(String methodName, long methodHash)
{
String name = "aop$MethodInfo_" + getMethodNameHash(methodName, methodHash);
return name;
}
-
+
protected static String methodInfoFromWeakReference(String localName, String methodInfoName)
{
return TransformerCommon.infoFromWeakReference(METHOD_INFO_CLASS_NAME, localName, methodInfoName);
@@ -143,6 +144,13 @@
MethodTransformation trans = new MethodTransformation(instrumentor, clazz, methods[i]);
boolean wrap = (classification[i].equals(JoinpointClassification.WRAPPED));
transformMethod(trans, wrap);
+
+ int modifier = trans.getWMethod().getModifiers();
+ if (Modifier.isNative(modifier))
+ {
+ modifier &=~Modifier.NATIVE;
+ trans.getWMethod().setModifiers(modifier);
+ }
}
}
@@ -170,7 +178,7 @@
{
continue;
}
-
+
String wrappedName = ClassAdvisor.notAdvisedMethodName(clazz.getName(), method.getName());
CtMethod wmethod = clazz.getDeclaredMethod(method.getName(), javassistParameterTypes);
if (wrapper.isNotPrepared(wmethod, WrapperTransformer.SINGLE_TRANSFORMATION_INDEX))
@@ -247,12 +255,12 @@
{
return getAopReturnStr(method.getReturnType().equals(CtClass.voidType));
}
-
+
protected static String getAopReturnStr(boolean isVoid)throws NotFoundException
{
return isVoid ? "" : "return ($r)";
}
-
+
protected static String getReturnStr(CtMethod method)throws NotFoundException
{
return getReturnStr(method.getReturnType().equals(CtClass.voidType));
@@ -265,7 +273,7 @@
protected abstract void transformMethod(MethodTransformation trans, boolean wrap) throws CannotCompileException, NotFoundException;
protected abstract void doWrap(MethodTransformation trans, String methodInfoFieldName)throws NotFoundException, Exception;
-
+
protected class MethodTransformation
{
Instrumentor instrumentor;
@@ -275,7 +283,7 @@
CtMethod wmethod;
String wrappedName;
long hash;
-
+
public MethodTransformation(Instrumentor instrumentor, CtClass clazz, CtMethod method)
{
this.instrumentor = instrumentor;
@@ -284,10 +292,10 @@
this.originalName = method.getName();
hash = JavassistMethodHashing.methodHash(method);
}
-
- public MethodTransformation(Instrumentor instrumentor,
- CtClass clazz,
- CtMethod method,
+
+ public MethodTransformation(Instrumentor instrumentor,
+ CtClass clazz,
+ CtMethod method,
String originalName,
CtMethod wmethod,
String wrappedName)
@@ -300,10 +308,10 @@
this.wrappedName = wrappedName;
hash = JavassistMethodHashing.methodHash(wmethod);
}
-
- public MethodTransformation(Instrumentor instrumentor,
- CtClass clazz,
- CtMethod method,
+
+ public MethodTransformation(Instrumentor instrumentor,
+ CtClass clazz,
+ CtMethod method,
String originalName,
CtMethod wmethod,
String wrappedName,
@@ -317,29 +325,29 @@
this.wrappedName = wrappedName;
this.hash = hash;
}
-
-
+
+
public void setWMethod(CtMethod wmethod, String wrappedName)
{
this.wmethod = wmethod;
this.wrappedName = wrappedName;
}
-
+
public void setWMethodBody(String code)throws CannotCompileException
{
wmethod.setBody(code);
}
-
+
public String getOriginalName()
{
return originalName;
}
-
+
public String getWrappedName()
{
return wrappedName;
}
-
+
public CtClass getClazz()
{
return clazz;
@@ -349,22 +357,22 @@
{
return clazz.getName();
}
-
+
public CtMethod getMethod()
{
return method;
}
-
+
public CtMethod getWMethod()
{
return wmethod;
}
-
+
public long getHash()
{
return hash;
}
-
+
public Instrumentor getInstrumentor()
{
return instrumentor;
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-08-18 03:56:54 UTC (rev 56048)
+++ branches/Branch_AOP_1_5/aop/src/resources/test/regression/jboss-aop.xml 2006-08-18 11:31:16 UTC (rev 56049)
@@ -13,7 +13,7 @@
<bind pointcut="execution(* org.jboss.test.aop.regression.jbaop194_undeploy.POJO->method())">
<interceptor class="org.jboss.test.aop.regression.jbaop194_undeploy.TestInterceptor"/>
</bind>
-
+
<bind pointcut="execution(org.jboss.test.aop.regression.jbaop197.Singleton->new())">
<interceptor class="org.jboss.test.aop.regression.jbaop197.TestInterceptor"/>
</bind>
@@ -44,7 +44,7 @@
</bind>
<bind pointcut="execution(* org.jboss.test.aop.regression.arraymethodparam.POJO->someMethod(..))">
- <interceptor class="org.jboss.test.aop.regression.arraymethodparam.MyInterceptor"/>
+ <interceptor class="org.jboss.test.aop.regression.arraymethodparam.MyInterceptor"/>
</bind>
<metadata tag="TEST" class="org.jboss.test.aop.regression.arraymethodparam.POJO">
<method expr="java.lang.String[] someMethod(java.lang.String[])">
@@ -53,16 +53,16 @@
</metadata>
<bind pointcut="field(* org.jboss.test.aop.regression.inheritedfield.SubPOJO->x)">
- <interceptor class="org.jboss.test.aop.regression.inheritedfield.TestInterceptor"/>
+ <interceptor class="org.jboss.test.aop.regression.inheritedfield.TestInterceptor"/>
</bind>
<bind pointcut="all(org.jboss.test.aop.regression.ejbthree315.POJO)">
- <interceptor class="org.jboss.test.aop.regression.ejbthree315.MyInterceptor"/>
+ <interceptor class="org.jboss.test.aop.regression.ejbthree315.MyInterceptor"/>
</bind>
<prepare expr="field(* $instanceof{org.jboss.test.aop.regression.jbaop137.Base}->*)"/>
<prepare expr="execution(* $instanceof{org.jboss.test.aop.regression.jbaop137.Base}->*et*(..))"/>
-
+
<aspect class="org.jboss.test.aop.regression.jbaop110.TestAspect"/>
<bind pointcut="execution(org.jboss.test.aop.regression.jbaop110.POJO->new(org.jboss.test.aop.regression.jbaop110.Type$NormalType, org.jboss.test.aop.regression.jbaop110.Type$StaticType))">
<advice aspect="org.jboss.test.aop.regression.jbaop110.TestAspect" name="invoke"/>
@@ -111,7 +111,7 @@
<bind pointcut="get(org.jboss.test.aop.regression.jbaop110.Type$StaticType org.jboss.test.aop.regression.jbaop110.POJO$NormalClass->*)">
<advice aspect="org.jboss.test.aop.regression.jbaop110.TestAspect" name="invoke"/>
</bind>
-
+
<typedef name="POJO" expr="class(org.jboss.test.aop.regression.jbaop217typedefredeploy.POJO)"/>
<bind pointcut="execution(* $typedef{POJO}->method())">
<interceptor class="org.jboss.test.aop.regression.jbaop217typedefredeploy.TestInterceptor"/>
@@ -121,4 +121,8 @@
<bind pointcut="field(long org.jboss.test.aop.regression.jbaop264underscorefieldname.POJO->*)">
<advice aspect="org.jboss.test.aop.regression.jbaop264underscorefieldname.TestAspect" name="intercept"/>
</bind>
+
+ <bind pointcut="execution(* org.jboss.test.aop.regression.jbaop279native.POJO->nativeMethod())">
+ <interceptor class="org.jboss.test.aop.regression.jbaop279native.ReturningInterceptor"/>
+ </bind>
</aop>
Added: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop279native/NativeMethodTestCase.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop279native/NativeMethodTestCase.java 2006-08-18 03:56:54 UTC (rev 56048)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop279native/NativeMethodTestCase.java 2006-08-18 11:31:16 UTC (rev 56049)
@@ -0,0 +1,59 @@
+/*
+ * 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.jbaop279native;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+
+/**
+ *
+ * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @version $Revision: 46062 $
+ */
+public class NativeMethodTestCase extends TestCase
+{
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("NativeMethodTestCase");
+ suite.addTestSuite(NativeMethodTestCase.class);
+ return suite;
+ }
+
+ public NativeMethodTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testNativeMethod()throws Exception
+ {
+ POJO pojo = new POJO();
+ assertEquals(5, pojo.nativeMethod());
+ }
+}
Added: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop279native/POJO.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop279native/POJO.java 2006-08-18 03:56:54 UTC (rev 56048)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop279native/POJO.java 2006-08-18 11:31:16 UTC (rev 56049)
@@ -0,0 +1,32 @@
+/*
+* 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.jbaop279native;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class POJO
+{
+ public native int nativeMethod();
+}
Added: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop279native/ReturningInterceptor.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop279native/ReturningInterceptor.java 2006-08-18 03:56:54 UTC (rev 56048)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop279native/ReturningInterceptor.java 2006-08-18 11:31:16 UTC (rev 56049)
@@ -0,0 +1,41 @@
+/*
+* 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.jbaop279native;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ReturningInterceptor implements Interceptor
+{
+ public String getName() {
+ return this.getClass().getName();
+ }
+
+ public Object invoke(Invocation invocation) throws Throwable {
+ return new Integer(5);
+ }
+}
More information about the jboss-cvs-commits
mailing list