[jboss-cvs] JBossAS SVN: r94217 - in branches/JBoss_AOP_1_5_5_GA_CP/aop: src/main/org/jboss/aop/proxy and 6 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Oct 1 10:07:21 EDT 2009
Author: stalep
Date: 2009-10-01 10:07:20 -0400 (Thu, 01 Oct 2009)
New Revision: 94217
Added:
branches/JBoss_AOP_1_5_5_GA_CP/aop/src/resources/test/bridgemethod/
branches/JBoss_AOP_1_5_5_GA_CP/aop/src/resources/test/bridgemethod/jboss-aop.xml
branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethod/
branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethod/BridgeMethodWeavingTestCase.java
branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethod/POJI.java
branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethod/POJO.java
branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethod/SimpleMethodInterceptor.java
branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethod/SubPOJO.java
branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethod/SubPOJO2.java
branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethod/SuperPOJO.java
branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethod/SuperPOJO2.java
branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethodnotwoven/
branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethodnotwoven/BridgeMethodTestCase.java
Modified:
branches/JBoss_AOP_1_5_5_GA_CP/aop/build.xml
branches/JBoss_AOP_1_5_5_GA_CP/aop/src/main/org/jboss/aop/proxy/ClassProxyFactory.java
branches/JBoss_AOP_1_5_5_GA_CP/aop/src/main/org/jboss/aop/util/JavassistMethodHashing.java
Log:
added support for bridgemethods
https://enterprise.redhat.com/issue-tracker/?module=issues&action=view&tid=333291&gid=1354
Modified: branches/JBoss_AOP_1_5_5_GA_CP/aop/build.xml
===================================================================
--- branches/JBoss_AOP_1_5_5_GA_CP/aop/build.xml 2009-10-01 13:58:34 UTC (rev 94216)
+++ branches/JBoss_AOP_1_5_5_GA_CP/aop/build.xml 2009-10-01 14:07:20 UTC (rev 94217)
@@ -244,8 +244,8 @@
<mkdir dir="${build.classes}"/>
<javac destdir="${build.classes}"
optimize="${javac.optimize}"
- target="1.4"
- source="1.4"
+ target="1.5"
+ source="1.5"
debug= "${javac.debug}"
depend="${javac.depend}"
verbose="${javac.verbose}"
@@ -266,8 +266,8 @@
<mkdir dir="${build.classes}"/>
<javac destdir="${build.classes}"
optimize="${javac.optimize}"
- target="1.4"
- source="1.4"
+ target="1.5"
+ source="1.5"
debug= "${javac.debug}"
depend="${javac.depend}"
verbose="${javac.verbose}"
@@ -613,8 +613,8 @@
<mkdir dir="${build.tests.classes}"/>
<javac destdir="${build.tests.classes}"
optimize="${javac.optimize}"
- target="1.4"
- source="1.4"
+ target="1.5"
+ source="1.5"
debug="${javac.debug}"
depend="${javac.depend}"
verbose="${javac.verbose}"
Modified: branches/JBoss_AOP_1_5_5_GA_CP/aop/src/main/org/jboss/aop/proxy/ClassProxyFactory.java
===================================================================
--- branches/JBoss_AOP_1_5_5_GA_CP/aop/src/main/org/jboss/aop/proxy/ClassProxyFactory.java 2009-10-01 13:58:34 UTC (rev 94216)
+++ branches/JBoss_AOP_1_5_5_GA_CP/aop/src/main/org/jboss/aop/proxy/ClassProxyFactory.java 2009-10-01 14:07:20 UTC (rev 94217)
@@ -24,10 +24,13 @@
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.WeakHashMap;
import org.jboss.aop.AspectManager;
import org.jboss.aop.ClassAdvisor;
@@ -314,30 +317,44 @@
return proxyClass;
}
- private static void populateMethodTables(HashMap advised, Class superclass)
+ private static void populateMethodTables(HashMap advised, List ignoredHash, Class superclass)
throws Exception
{
if (superclass == null) return;
if (superclass.getName().equals("java.lang.Object")) return;
- populateMethodTables(advised, superclass.getSuperclass());
-
Method[] declaredMethods = superclass.getDeclaredMethods();
for (int i = 0; i < declaredMethods.length; i++)
{
if (ClassAdvisor.isAdvisable(declaredMethods[i]))
{
- long hash = org.jboss.aop.util.MethodHashing.methodHash(declaredMethods[i]);
- advised.put(new Long(hash), new MethodPersistentReference(declaredMethods[i], PersistentReference.REFERENCE_SOFT));
- }
+ //if a method is marked as a "volatile/bridge" method, we need to
+ //ignore it and check that other implementations of that method
+ // (in superclasses) are not added either.
+ if(!java.lang.reflect.Modifier.isVolatile( declaredMethods[i].getModifiers()))
+ {
+ long hash = org.jboss.aop.util.MethodHashing.methodHash(declaredMethods[i]);
+ if(!ignoredHash.contains(new Long(hash)))
+ advised.put(new Long(hash), new MethodPersistentReference(declaredMethods[i], PersistentReference.REFERENCE_SOFT));
+ }
+ else
+ {
+ long hash = org.jboss.aop.util.MethodHashing.methodHash(declaredMethods[i]);
+ ignoredHash.add(new Long(hash));
+ }
+ }
}
+
+ populateMethodTables(advised, ignoredHash, superclass.getSuperclass());
+
}
public static HashMap methodMap(Class clazz)
throws Exception
{
HashMap methods = new HashMap();
- populateMethodTables(methods, clazz);
+ List ignoredHash = new ArrayList();
+ populateMethodTables(methods, ignoredHash, clazz);
return methods;
}
Modified: branches/JBoss_AOP_1_5_5_GA_CP/aop/src/main/org/jboss/aop/util/JavassistMethodHashing.java
===================================================================
--- branches/JBoss_AOP_1_5_5_GA_CP/aop/src/main/org/jboss/aop/util/JavassistMethodHashing.java 2009-10-01 13:58:34 UTC (rev 94216)
+++ branches/JBoss_AOP_1_5_5_GA_CP/aop/src/main/org/jboss/aop/util/JavassistMethodHashing.java 2009-10-01 14:07:20 UTC (rev 94217)
@@ -24,6 +24,7 @@
import javassist.CtClass;
import javassist.CtConstructor;
import javassist.CtMethod;
+import javassist.Modifier;
import javassist.NotFoundException;
import org.jboss.aop.instrument.Instrumentor;
@@ -34,7 +35,9 @@
import java.security.DigestOutputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
/**
* Create a unique hash for method. This is the same as
@@ -145,51 +148,55 @@
}
}
- private static void addDeclaredMethods(HashMap advised, CtClass superclass) throws Exception
+ private static void addDeclaredMethods(HashMap advised, List ignoredHash, CtClass superclass) throws Exception
{
CtMethod[] declaredMethods = superclass.getDeclaredMethods();
for (int i = 0; i < declaredMethods.length; i++)
{
if (superclass.isInterface() || Instrumentor.isAdvisable(declaredMethods[i]))
{
+ //if a method is marked as a "volatile/bridge" method, we need to
+ //ignore it and check that other implementations of that method
+ // (in superclasses) are not added either.
+ if(!Modifier.isVolatile(declaredMethods[i].getModifiers()))
+ {
long hash = methodHash(declaredMethods[i]);
- advised.put(new Long(hash), declaredMethods[i]);
+ if(!ignoredHash.contains(new Long(hash)))
+ advised.put(new Long(hash), declaredMethods[i]);
+ }
+ else
+ {
+ long hash = methodHash(declaredMethods[i]);
+ ignoredHash.add(new Long(hash));
+ }
}
}
}
- private static void populateMethodTables(HashMap advised, CtClass superclass)
- throws Exception
+ private static void populateMethodTables(HashMap advised, List ignoredHash, CtClass superclass)
+ throws Exception
{
if (superclass == null) return;
if (superclass.getName().equals("java.lang.Object")) return;
- if (superclass.isInterface())
- {
- CtClass[] ifs = superclass.getInterfaces();
- for (int i = 0 ; i < ifs.length ; i++)
- {
- populateMethodTables(advised, ifs[i]);
- }
- addDeclaredMethods(advised, superclass);
- }
- else
- {
- populateMethodTables(advised, superclass.getSuperclass());
- addDeclaredMethods(advised, superclass);
- }
+
+ addDeclaredMethods(advised, ignoredHash, superclass);
+ populateMethodTables(advised, ignoredHash, superclass.getSuperclass());
}
public static HashMap getMethodMap(CtClass clazz) throws Exception
{
HashMap map = new HashMap();
- populateMethodTables(map, clazz);
+ List ignoredHash = new ArrayList();
+ populateMethodTables(map, ignoredHash, clazz);
return map;
}
public static HashMap getDeclaredMethodMap(CtClass clazz) throws Exception
{
HashMap map = new HashMap();
- addDeclaredMethods(map, clazz);
+ List ignoredHash = new ArrayList();
+ addDeclaredMethods(map, ignoredHash, clazz);
return map;
}
}
+
Added: branches/JBoss_AOP_1_5_5_GA_CP/aop/src/resources/test/bridgemethod/jboss-aop.xml
===================================================================
--- branches/JBoss_AOP_1_5_5_GA_CP/aop/src/resources/test/bridgemethod/jboss-aop.xml (rev 0)
+++ branches/JBoss_AOP_1_5_5_GA_CP/aop/src/resources/test/bridgemethod/jboss-aop.xml 2009-10-01 14:07:20 UTC (rev 94217)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<aop>
+ <bind pointcut="execution(* org.jboss.test.aop.bridgemethod.POJO->getFoo())">
+ <interceptor class="org.jboss.test.aop.bridgemethod.SimpleMethodInterceptor"/>
+ </bind>
+ <bind pointcut="execution(* org.jboss.test.aop.bridgemethod.SubPOJO->setFoo(..))">
+ <interceptor class="org.jboss.test.aop.bridgemethod.SimpleMethodInterceptor"/>
+ </bind>
+ <bind pointcut="execution(* org.jboss.test.aop.bridgemethod.SubPOJO2->setFoo(..))">
+ <interceptor class="org.jboss.test.aop.bridgemethod.SimpleMethodInterceptor"/>
+ </bind>
+</aop>
\ No newline at end of file
Property changes on: branches/JBoss_AOP_1_5_5_GA_CP/aop/src/resources/test/bridgemethod/jboss-aop.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethod/BridgeMethodWeavingTestCase.java
===================================================================
--- branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethod/BridgeMethodWeavingTestCase.java (rev 0)
+++ branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethod/BridgeMethodWeavingTestCase.java 2009-10-01 14:07:20 UTC (rev 94217)
@@ -0,0 +1,93 @@
+/*
+ * 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.bridgemethod;
+
+import java.util.ArrayList;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ *
+ * @author <a href="mailto:stalep at conduct.no">Stale W. Pedersen</a>
+ * @version $Revision
+ */
+public class BridgeMethodWeavingTestCase extends TestCase
+{
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("BridgeMethodWeavingTestCase");
+ suite.addTestSuite(BridgeMethodWeavingTestCase.class);
+ return suite;
+ }
+
+ public BridgeMethodWeavingTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ public void testMethod()
+ {
+ POJO p = new POJO("bar");
+ p.getFoo();
+ assertTrue(SimpleMethodInterceptor.method);
+
+ }
+
+ public void testGenericMethod()
+ {
+ SimpleMethodInterceptor.method = false;
+ SubPOJO spojo = new SubPOJO();
+ spojo.setFoo(new ArrayList());
+ assertTrue(SimpleMethodInterceptor.method);
+ }
+
+ public void testMethodOverride()
+ {
+ SimpleMethodInterceptor.method = false;
+ SubPOJO2 spojo2 = new SubPOJO2();
+ spojo2.setFoo("bar");
+ assertTrue(SimpleMethodInterceptor.method);
+ }
+
+ public void testMethodOverrideNotWeaved()
+ {
+ SimpleMethodInterceptor.method = false;
+ SubPOJO2 spojo2 = new SubPOJO2();
+ spojo2.setFoo(new POJO());
+ assertFalse(SimpleMethodInterceptor.method);
+ }
+
+
+}
Added: branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethod/POJI.java
===================================================================
--- branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethod/POJI.java (rev 0)
+++ branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethod/POJI.java 2009-10-01 14:07:20 UTC (rev 94217)
@@ -0,0 +1,33 @@
+/*
+ * 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.bridgemethod;
+
+/**
+ *
+ * @author <a href="mailto:stalep at conduct.no">Stale W. Pedersen</a>
+ * @version $Revision
+ */
+public interface POJI
+{
+ public Object getFoo();
+
+}
Added: branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethod/POJO.java
===================================================================
--- branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethod/POJO.java (rev 0)
+++ branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethod/POJO.java 2009-10-01 14:07:20 UTC (rev 94217)
@@ -0,0 +1,45 @@
+/*
+ * 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.bridgemethod;
+
+/**
+ *
+ * @author <a href="mailto:stalep at conduct.no">Stale W. Pedersen</a>
+ * @version $Revision
+ */
+public class POJO implements POJI
+{
+ private String foo;
+
+ public POJO() { }
+
+ public POJO(String f)
+ {
+ foo = f;
+ }
+
+ public String getFoo()
+ {
+ return foo;
+ }
+
+}
Added: branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethod/SimpleMethodInterceptor.java
===================================================================
--- branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethod/SimpleMethodInterceptor.java (rev 0)
+++ branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethod/SimpleMethodInterceptor.java 2009-10-01 14:07:20 UTC (rev 94217)
@@ -0,0 +1,51 @@
+/*
+ * 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.bridgemethod;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodInvocation;
+
+/**
+ *
+ * @author <a href="mailto:stalep at conduct.no">Stale W. Pedersen</a>
+ * @version $Revision
+ */
+public class SimpleMethodInterceptor implements Interceptor
+{
+ public static boolean method;
+
+ public String getName()
+ {
+ return "SimpleMethodInterceptor";
+ }
+
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ if (invocation instanceof MethodInvocation)
+ {
+ method = true;
+ }
+ return invocation.invokeNext();
+ }
+
+}
Added: branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethod/SubPOJO.java
===================================================================
--- branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethod/SubPOJO.java (rev 0)
+++ branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethod/SubPOJO.java 2009-10-01 14:07:20 UTC (rev 94217)
@@ -0,0 +1,43 @@
+/*
+ * 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.bridgemethod;
+
+/**
+ *
+ * @author <a href="mailto:stalep at conduct.no">Stale W. Pedersen</a>
+ * @version $Revision
+ */
+public class SubPOJO extends SuperPOJO<java.util.ArrayList>
+{
+ private java.util.ArrayList bar;
+
+ public void setFoo(java.util.ArrayList a)
+ {
+ bar = a;
+ }
+
+ public java.util.ArrayList getFoo()
+ {
+ return bar;
+ }
+
+}
Added: branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethod/SubPOJO2.java
===================================================================
--- branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethod/SubPOJO2.java (rev 0)
+++ branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethod/SubPOJO2.java 2009-10-01 14:07:20 UTC (rev 94217)
@@ -0,0 +1,44 @@
+/*
+ * 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.bridgemethod;
+
+/**
+ *
+ * @author <a href="mailto:stalep at conduct.no">Stale W. Pedersen</a>
+ * @version $Revision
+ */
+public class SubPOJO2 extends SuperPOJO2
+{
+
+ private String bar;
+
+ public void setFoo(String s)
+ {
+ bar = s;
+ }
+
+ public String getFoo()
+ {
+ return bar;
+ }
+
+}
Added: branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethod/SuperPOJO.java
===================================================================
--- branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethod/SuperPOJO.java (rev 0)
+++ branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethod/SuperPOJO.java 2009-10-01 14:07:20 UTC (rev 94217)
@@ -0,0 +1,23 @@
+package org.jboss.test.aop.bridgemethod;
+
+/**
+ *
+ * @author <a href="mailto:stalep at conduct.no">Stale W. Pedersen</a>
+ * @version $Revision
+ */
+ at SuppressWarnings({"unchecked"})
+public class SuperPOJO<T extends java.util.AbstractList>
+{
+ private T fooObject;
+
+ public void setFoo(T arg)
+ {
+ fooObject = arg;
+ }
+
+ public T getFoo()
+ {
+ return fooObject;
+ }
+
+}
Added: branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethod/SuperPOJO2.java
===================================================================
--- branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethod/SuperPOJO2.java (rev 0)
+++ branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethod/SuperPOJO2.java 2009-10-01 14:07:20 UTC (rev 94217)
@@ -0,0 +1,42 @@
+/*
+ * 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.bridgemethod;
+
+/**
+ *
+ * @author <a href="mailto:stalep at conduct.no">Stale W. Pedersen</a>
+ * @version $Revision
+ */
+public class SuperPOJO2
+{
+ private Object foo;
+
+ public void setFoo(Object arg)
+ {
+ foo = arg;
+ }
+
+ public Object getFoo()
+ {
+ return foo;
+ }
+}
Added: branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethodnotwoven/BridgeMethodTestCase.java
===================================================================
--- branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethodnotwoven/BridgeMethodTestCase.java (rev 0)
+++ branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/bridgemethodnotwoven/BridgeMethodTestCase.java 2009-10-01 14:07:20 UTC (rev 94217)
@@ -0,0 +1,117 @@
+/*
+ * 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.bridgemethodnotwoven;
+
+import java.util.Properties;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import org.jboss.aop.proxy.ClassProxyFactory;
+import org.jboss.test.aop.bridgemethod.POJO;
+import org.jboss.test.aop.bridgemethod.SubPOJO;
+import org.jboss.test.aop.bridgemethod.SubPOJO2;
+import org.jboss.test.aop.bridgemethod.SuperPOJO;
+
+/**
+ * Test that we handle bridgemethods created by the java15 compiler correctly
+ * regarding reflection.
+ *
+ * @author <a href="mailto:stalep at conduct.no">Stale W. Pedersen</a>
+ * @version $Revision
+ */
+public class BridgeMethodTestCase extends TestCase
+{
+
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("BridgeMethodTestCase");
+ suite.addTestSuite(BridgeMethodTestCase.class);
+ return suite;
+ }
+
+ public BridgeMethodTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ public void testMethod()
+ {
+ try {
+ ClassProxyFactory.newInstance(POJO.class);
+ assertTrue("ClassProxy failed to instrument class", true);
+ }
+ catch(Exception e)
+ {
+ System.out.println("ERROR: "+e.getMessage());
+ e.printStackTrace();
+ assertTrue("ClassProxy failed to instrument class", false);
+
+ }
+
+ }
+
+ public void testGenericMethod()
+ {
+ //doesnt work with jbossretro atm...
+ //AOPTestDelegate delegate = (AOPTestDelegate)getDelegate();
+ //Properties properties = delegate.getSystemProperties();
+ try {
+ SuperPOJO superPojo = (SuperPOJO) ClassProxyFactory.newInstance(SubPOJO.class);
+ assertTrue("ClassProxy failed to instrument generic class", true);
+ }
+ catch(Exception e)
+ {
+ System.out.println("ERROR: "+e.getMessage());
+ e.printStackTrace();
+ assertTrue("ClassProxy failed to instrument generic class", false);
+
+ }
+ }
+
+ public void testMethodOverride()
+ {
+ try {
+ ClassProxyFactory.newInstance(SubPOJO2.class);
+ assertTrue("ClassProxy failed to instrument overrided class", true);
+ }
+ catch(Exception e)
+ {
+ System.out.println("ERROR: "+e.getMessage());
+ e.printStackTrace();
+ assertTrue("ClassProxy failed to instrument overrided class", false);
+ }
+ }
+
+}
More information about the jboss-cvs-commits
mailing list