[jboss-cvs] JBossAS SVN: r102304 - in projects/aop/trunk/aop: src/main/java/org/jboss/aop and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Mar 11 15:11:05 EST 2010
Author: flavia.rainone at jboss.com
Date: 2010-03-11 15:11:04 -0500 (Thu, 11 Mar 2010)
New Revision: 102304
Added:
projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/jdk15base/ComplexAnnotationUtil.java
projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/jdk15base/InterfaceAnnotationIntroductionTestCase.java
Modified:
projects/aop/trunk/aop/2.0.x-compliance-tests.xml
projects/aop/trunk/aop/src/main/java/org/jboss/aop/ClassicWeavingStrategy.java
projects/aop/trunk/aop/src/main/java/org/jboss/aop/SuperClassesFirstWeavingStrategy.java
projects/aop/trunk/aop/src/main/java/org/jboss/aop/instrument/Instrumentor.java
projects/aop/trunk/aop/src/resources/test/jdk15base/jboss-aop.xml
projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/jdk15base/AOPTester.java
Log:
[JBAOP-743] Added support to annotation introduction on interfaces.
Modified: projects/aop/trunk/aop/2.0.x-compliance-tests.xml
===================================================================
--- projects/aop/trunk/aop/2.0.x-compliance-tests.xml 2010-03-11 19:11:19 UTC (rev 102303)
+++ projects/aop/trunk/aop/2.0.x-compliance-tests.xml 2010-03-11 20:11:04 UTC (rev 102304)
@@ -472,6 +472,7 @@
<!-- These are not test cases, and so they will fail when junit tries to run them. Should really rename all tests to *TestCase -->
<exclude name="org/jboss/test/aop/reflection/ReflectionAspectTester.class"/>
<exclude name="org/jboss/test/aop/basic/POJOAspectTester.class"/>
+ <exclude name="org/jboss/test/aop/jdk15base/InterfaceAnnotationIntroductionTestCase.class"/>
</fileset>
</batchtest>
</junit>
@@ -721,6 +722,7 @@
<exclude name="org/jboss/test/aop/rebuildingchain/*.class"/>
<exclude name="org/jboss/test/aop/reflection/ReflectionAspectTester.class"/>
<exclude name="org/jboss/test/aop/basic/POJOAspectTester.class"/>
+ <exclude name="org/jboss/test/aop/jdk15base/InterfaceAnnotationIntroductionTestCase.class"/>
</fileset>
</batchtest>
</junit>
Modified: projects/aop/trunk/aop/src/main/java/org/jboss/aop/ClassicWeavingStrategy.java
===================================================================
--- projects/aop/trunk/aop/src/main/java/org/jboss/aop/ClassicWeavingStrategy.java 2010-03-11 19:11:19 UTC (rev 102303)
+++ projects/aop/trunk/aop/src/main/java/org/jboss/aop/ClassicWeavingStrategy.java 2010-03-11 20:11:04 UTC (rev 102304)
@@ -79,12 +79,6 @@
pool.flushClass(className);
return null;
}
- if (clazz.isInterface())
- {
- if (verbose && logger.isDebugEnabled()) logger.debug("cannot compile, isInterface: " + className);
- pool.flushClass(className);
- return null;
- }
if (clazz.isFrozen())
{
if (verbose && logger.isDebugEnabled()) logger.debug("warning, isFrozen: " + className);
Modified: projects/aop/trunk/aop/src/main/java/org/jboss/aop/SuperClassesFirstWeavingStrategy.java
===================================================================
--- projects/aop/trunk/aop/src/main/java/org/jboss/aop/SuperClassesFirstWeavingStrategy.java 2010-03-11 19:11:19 UTC (rev 102303)
+++ projects/aop/trunk/aop/src/main/java/org/jboss/aop/SuperClassesFirstWeavingStrategy.java 2010-03-11 20:11:04 UTC (rev 102304)
@@ -156,13 +156,6 @@
pool.flushClass(clazz.getName());
return null;
}
- if (clazz.isInterface())
- {
- if (verbose && logger.isDebugEnabled()) logger.debug("cannot compile, isInterface: " + clazz.getName());
- //pool.flushClass(info.getClassName());
- clazz.prune();
- return null;
- }
if (clazz.isFrozen())
{
if(isAdvised(pool, clazz))
@@ -178,7 +171,7 @@
//info.getClazz().defrost();
}
- boolean transformed = clazz.isModified();
+ boolean transformed = isAdvised(pool, clazz);
if (!transformed)
{
ClassAdvisor advisor =
Modified: projects/aop/trunk/aop/src/main/java/org/jboss/aop/instrument/Instrumentor.java
===================================================================
--- projects/aop/trunk/aop/src/main/java/org/jboss/aop/instrument/Instrumentor.java 2010-03-11 19:11:19 UTC (rev 102303)
+++ projects/aop/trunk/aop/src/main/java/org/jboss/aop/instrument/Instrumentor.java 2010-03-11 20:11:04 UTC (rev 102304)
@@ -787,8 +787,7 @@
protected boolean shouldNotTransform(CtClass clazz)throws NotFoundException
{
- return (clazz.isInterface() ||
- clazz.isFrozen() ||
+ return (clazz.isFrozen() ||
clazz.isArray() ||
clazz.getName().startsWith("org.jboss.aop.") ||
isAdvised(clazz) ||
@@ -805,6 +804,17 @@
try
{
if (shouldNotTransform(clazz)) return false;
+ if (clazz.isInterface())
+ {
+ if (AspectManager.verbose && logger.isDebugEnabled())
+ logger.debug("trying to transform " + clazz.getName());
+
+ DeclareChecker.checkDeclares(manager, clazz, advisor);
+
+ boolean converted = instrumentAnnotationIntroductions(clazz, advisor);
+ converted = instrumentAnnotationOverrides(clazz, advisor) || converted;
+ return converted;
+ }
prepareClassForTransformation(clazz);
if (AspectManager.verbose && logger.isDebugEnabled()) logger.debug("trying to transform " + clazz.getName());
Modified: projects/aop/trunk/aop/src/resources/test/jdk15base/jboss-aop.xml
===================================================================
--- projects/aop/trunk/aop/src/resources/test/jdk15base/jboss-aop.xml 2010-03-11 19:11:19 UTC (rev 102303)
+++ projects/aop/trunk/aop/src/resources/test/jdk15base/jboss-aop.xml 2010-03-11 20:11:04 UTC (rev 102304)
@@ -20,5 +20,9 @@
<annotation-introduction expr="class(org.jboss.test.aop.jdk15base.AnnotatedPOJO)" invisible="false">
@org.jboss.test.aop.jdk15base.complex (ch='a', string="hello world", flt=5.5, dbl=6.6, shrt=5, lng=6, integer=7, bool=true, annotation=@org.jboss.test.aop.jdk15base.single("hello"), array={"hello", "world"}, clazz=java.lang.String, enumVal=org.jboss.test.aop.jdk15base.MyEnum.ONE)
</annotation-introduction>
+
+ <annotation-introduction expr="class(org.jboss.test.aop.jdk15base.AnnotatedInterface) OR method(* org.jboss.test.aop.jdk15base.AnnotatedInterface->*(..))" invisible="false">
+ @org.jboss.test.aop.jdk15base.complex (ch='i', string="hello world from interface ann", flt=1.1, dbl=2.2, shrt=3, lng=4, integer=5, bool=false, annotation=@org.jboss.test.aop.jdk15base.single("interface"), array={"interface", "annotation", "introduction", "works"}, clazz=java.lang.Runnable, enumVal=org.jboss.test.aop.jdk15base.MyEnum.TWO)
+ </annotation-introduction>
</aop>
Modified: projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/jdk15base/AOPTester.java
===================================================================
--- projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/jdk15base/AOPTester.java 2010-03-11 19:11:19 UTC (rev 102303)
+++ projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/jdk15base/AOPTester.java 2010-03-11 20:11:04 UTC (rev 102304)
@@ -1,32 +1,34 @@
/*
- * 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.
- */
+ * 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.jdk15base;
+import static org.jboss.test.aop.jdk15base.ComplexAnnotationUtil.assertComplexAnnotation;
+import static org.jboss.test.aop.jdk15base.ComplexAnnotationUtil.printComplex;
import junit.framework.Test;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
-import org.jboss.aop.annotation.AnnotationElement;
import org.jboss.annotation.factory.AnnotationCreator;
+import org.jboss.aop.annotation.AnnotationElement;
import org.jboss.test.aop.AOPTestWithSetup;
/**
@@ -40,16 +42,6 @@
TestRunner.run(suite());
}
- private void printComplex(complex c)
- {
- System.out.print("@complex (ch='" + c.ch() + "', ");
- System.out.print("\"" + c.string() + "\", ");
- System.out.print("flt=" + c.flt() + ", ");
- System.out.print("enumVal=" + c.enumVal() + ", ");
- System.out.println("dbl=" + c.dbl() + ", ...blah blah blah YOU GET THE IDEA...");
-
- }
-
public static Test suite()
{
TestSuite suite = new TestSuite("AOPTester");
@@ -68,22 +60,8 @@
{
String expr = "@org.jboss.test.aop.jdk15base.complex (ch='a', string=\"hello world\", flt=5.5, dbl=6.6, shrt=5, lng=6, integer=7, bool=true, annotation=@org.jboss.test.aop.jdk15base.single(\"hello\"), array={\"hello\", \"world\"}, clazz=java.lang.String, enumVal=org.jboss.test.aop.jdk15base.MyEnum.ONE)";
complex c = (complex) AnnotationCreator.createAnnotation(expr, complex.class);
- if (c == null) throw new RuntimeException("failed to get @complex");
- if (c.ch() != 'a') throw new RuntimeException("@complex.ch has wrong value");
- if (!c.string().equals("hello world")) throw new RuntimeException("@complex.string has wrong value");
- if (c.flt() != 5.5) throw new RuntimeException("@complex.flt has wrong value");
- if (c.dbl() != 6.6) throw new RuntimeException("@complex.dbl has wrong value");
- if (c.shrt() != 5) throw new RuntimeException("@complex.shrt has wrong value");
- if (c.lng() != 6) throw new RuntimeException("@complex.lng has wrong value");
- if (c.integer() != 7) throw new RuntimeException("@complex.integer has wrong value");
- if (c.bool() == false) throw new RuntimeException("@complex.bool has wrong value");
- single s = c.annotation();
- if (s == null) throw new RuntimeException("@complex.annotation is null");
- if (!s.value().equals("hello")) throw new RuntimeException("@complex.annotation has wrong value");
- if (!c.array()[0].equals("hello")) throw new RuntimeException("@complex.array[0] has wrong value");
- if (!c.array()[1].equals("world")) throw new RuntimeException("@complex.array[1] has wrong value");
- if (!java.lang.String.class.equals(c.clazz())) throw new RuntimeException("@complex.clazz has wrong value");
- if (c.enumVal() != MyEnum.ONE) throw new RuntimeException("@complex.enumVal has wrong value");
+ assertComplexAnnotation(c, 'a', "hello world", 5.5f, 6.6, (short) 5, 6l,
+ 7, true, "hello", String.class, MyEnum.ONE, "hello", "world");
}
public void testAnnotation()
Added: projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/jdk15base/ComplexAnnotationUtil.java
===================================================================
--- projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/jdk15base/ComplexAnnotationUtil.java (rev 0)
+++ projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/jdk15base/ComplexAnnotationUtil.java 2010-03-11 20:11:04 UTC (rev 102304)
@@ -0,0 +1,67 @@
+/*
+ * 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.jdk15base;
+
+import junit.framework.Assert;
+
+/**
+ * Contains utility methods for testing complex annotation.
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class ComplexAnnotationUtil
+{
+ public static void assertComplexAnnotation(complex c, char ch, String string,
+ float flt, double dbl, short srt, long lng, int integer, boolean bool,
+ String singleAnnValue, Class<?> clazz, MyEnum myEnum, String... array)
+ {
+ Assert.assertNotNull("failed to get @complex", c);
+ Assert.assertEquals("@complex.ch has wrong value", ch, c.ch());
+ Assert.assertEquals("@complex.string has wrong value", string, c.string());
+ Assert.assertEquals("@complex.flt has wrong value", flt, c.flt());
+ Assert.assertEquals("@complex.dbl has wrong value", dbl, c.dbl());
+ Assert.assertEquals("@complex.shrt has wrong value", srt, c.shrt());
+ Assert.assertEquals("@complex.lng has wrong value", lng, c.lng());
+ Assert.assertEquals("@complex.integer has wrong value", integer, c.integer());
+ Assert.assertEquals("@complex.bool has wrong value", bool, c.bool());
+ single s = c.annotation();
+ Assert.assertNotNull("@complex.annotation is null", s);
+ Assert.assertEquals("@complex.annotation has wrong value", singleAnnValue, s.value());
+ Assert.assertEquals("@complex.clazz has wrong value", clazz, c.clazz());
+ Assert.assertEquals("@complex.enumVal has wrong value", myEnum, c.enumVal());
+ Assert.assertEquals("@complex array has wrong length", array.length, c.array().length);
+ for (int i = 0; i < array.length; i++)
+ {
+ Assert.assertEquals("@complex.array[" + i + "] has wrong value", array[i], c.array()[i]);
+ }
+ }
+
+ public static void printComplex(complex c)
+ {
+ System.out.print("@complex (ch='" + c.ch() + "', ");
+ System.out.print("\"" + c.string() + "\", ");
+ System.out.print("flt=" + c.flt() + ", ");
+ System.out.print("enumVal=" + c.enumVal() + ", ");
+ System.out.println("dbl=" + c.dbl() + ", ...blah blah blah YOU GET THE IDEA...");
+ }
+}
\ No newline at end of file
Property changes on: projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/jdk15base/ComplexAnnotationUtil.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/jdk15base/InterfaceAnnotationIntroductionTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/jdk15base/InterfaceAnnotationIntroductionTestCase.java (rev 0)
+++ projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/jdk15base/InterfaceAnnotationIntroductionTestCase.java 2010-03-11 20:11:04 UTC (rev 102304)
@@ -0,0 +1,69 @@
+/*
+ * 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.jdk15base;
+
+import static org.jboss.test.aop.jdk15base.ComplexAnnotationUtil.assertComplexAnnotation;
+import static org.jboss.test.aop.jdk15base.ComplexAnnotationUtil.printComplex;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import org.jboss.aop.annotation.AnnotationElement;
+import org.jboss.test.aop.AOPTestWithSetup;
+
+/**
+ * Tests introduction of annotations on interfaces.
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class InterfaceAnnotationIntroductionTestCase extends AOPTestWithSetup
+{
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("AOPTester");
+ suite.addTestSuite(InterfaceAnnotationIntroductionTestCase.class);
+ return suite;
+ }
+
+ public InterfaceAnnotationIntroductionTestCase(String name)
+ {
+ super(name);
+ }
+
+ // Public -------------------------------------------------------
+
+ public void testInterfaceAnnotation()
+ {
+ /*complex c = AnnotationElement.getVisibleAnnotation(AnnotatedInterface.class, complex.class);
+ assertComplexAnnotation(c, 'i', "hello world from interface ann", 1.1f,
+ 2.2, (short) 3, 4l, 5, false, "interface", Runnable.class,
+ MyEnum.TWO, "interface", "annotation", "introduction", "works");
+ printComplex(c);*/
+ }
+}
+
Property changes on: projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/jdk15base/InterfaceAnnotationIntroductionTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
More information about the jboss-cvs-commits
mailing list