[Jboss-cvs] JBossAS SVN: r54947 - in trunk/aop/src: main/org/jboss/aop/instrument resources/test/regression test/org/jboss/test/aop/regression test/org/jboss/test/aop/regression/jbaop279native
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jul 31 17:48:20 EDT 2006
Author: kabir.khan at jboss.com
Date: 2006-07-31 17:48:14 -0400 (Mon, 31 Jul 2006)
New Revision: 54947
Added:
trunk/aop/src/test/org/jboss/test/aop/regression/jbaop279native/
trunk/aop/src/test/org/jboss/test/aop/regression/jbaop279native/NativeMethodTestCase.java
trunk/aop/src/test/org/jboss/test/aop/regression/jbaop279native/POJO.java
trunk/aop/src/test/org/jboss/test/aop/regression/jbaop279native/ReturningInterceptor.java
Modified:
trunk/aop/src/main/org/jboss/aop/instrument/MethodExecutionTransformer.java
trunk/aop/src/resources/test/regression/jboss-aop.xml
Log:
Make sure that the wrapper method for native methods does not have the NATIVE modifier set
Modified: trunk/aop/src/main/org/jboss/aop/instrument/MethodExecutionTransformer.java
===================================================================
--- trunk/aop/src/main/org/jboss/aop/instrument/MethodExecutionTransformer.java 2006-07-31 21:32:23 UTC (rev 54946)
+++ trunk/aop/src/main/org/jboss/aop/instrument/MethodExecutionTransformer.java 2006-07-31 21:48:14 UTC (rev 54947)
@@ -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: trunk/aop/src/resources/test/regression/jboss-aop.xml
===================================================================
--- trunk/aop/src/resources/test/regression/jboss-aop.xml 2006-07-31 21:32:23 UTC (rev 54946)
+++ trunk/aop/src/resources/test/regression/jboss-aop.xml 2006-07-31 21:48:14 UTC (rev 54947)
@@ -149,5 +149,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: trunk/aop/src/test/org/jboss/test/aop/regression/jbaop279native/NativeMethodTestCase.java
===================================================================
--- trunk/aop/src/test/org/jboss/test/aop/regression/jbaop279native/NativeMethodTestCase.java 2006-07-31 21:32:23 UTC (rev 54946)
+++ trunk/aop/src/test/org/jboss/test/aop/regression/jbaop279native/NativeMethodTestCase.java 2006-07-31 21:48:14 UTC (rev 54947)
@@ -0,0 +1,60 @@
+/*
+ * 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.test.aop.AOPTestWithSetup;
+
+import junit.framework.Test;
+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 AOPTestWithSetup
+{
+ 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());
+ }
+}
Property changes on: trunk/aop/src/test/org/jboss/test/aop/regression/jbaop279native/NativeMethodTestCase.java
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/aop/src/test/org/jboss/test/aop/regression/jbaop279native/POJO.java
===================================================================
--- trunk/aop/src/test/org/jboss/test/aop/regression/jbaop279native/POJO.java 2006-07-31 21:32:23 UTC (rev 54946)
+++ trunk/aop/src/test/org/jboss/test/aop/regression/jbaop279native/POJO.java 2006-07-31 21:48:14 UTC (rev 54947)
@@ -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();
+}
Property changes on: trunk/aop/src/test/org/jboss/test/aop/regression/jbaop279native/POJO.java
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/aop/src/test/org/jboss/test/aop/regression/jbaop279native/ReturningInterceptor.java
===================================================================
--- trunk/aop/src/test/org/jboss/test/aop/regression/jbaop279native/ReturningInterceptor.java 2006-07-31 21:32:23 UTC (rev 54946)
+++ trunk/aop/src/test/org/jboss/test/aop/regression/jbaop279native/ReturningInterceptor.java 2006-07-31 21:48:14 UTC (rev 54947)
@@ -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);
+ }
+}
Property changes on: trunk/aop/src/test/org/jboss/test/aop/regression/jbaop279native/ReturningInterceptor.java
___________________________________________________________________
Name: svn:executable
+ *
More information about the jboss-cvs-commits
mailing list