]> source.dussan.org Git - aspectj.git/commitdiff
generics and ITD inner class updates
authoraclement <aclement>
Tue, 8 Jun 2010 22:57:19 +0000 (22:57 +0000)
committeraclement <aclement>
Tue, 8 Jun 2010 22:57:19 +0000 (22:57 +0000)
tests/src/org/aspectj/systemtest/ajc154/CustomMungerExtensionTest.java
tests/src/org/aspectj/systemtest/ajc169/IntertypeTests.java
tests/src/org/aspectj/systemtest/ajc169/intertype.xml

index 909c100a31abd3d150277297a07e8621449082a1..7c0d26d4c96c079a7553e3e3864e2d6f5d3c29e3 100644 (file)
@@ -28,66 +28,70 @@ import org.aspectj.weaver.CustomMungerFactory;
 import org.aspectj.weaver.ResolvedType;
 import org.aspectj.weaver.ResolvedTypeMunger;
 import org.aspectj.weaver.Shadow;
+import org.aspectj.weaver.ShadowMunger;
 import org.aspectj.weaver.World;
 import org.aspectj.weaver.patterns.DeclareErrorOrWarning;
 import org.aspectj.weaver.patterns.IfPointcut;
 import org.aspectj.weaver.patterns.Pointcut;
 
 public class CustomMungerExtensionTest extends AjdeInteractionTestbed {
-       
-        File oldSandBoxDir;
-
-        protected void setUp() throws Exception {
-             super.setUp();
-             oldSandBoxDir = sandboxDir;
-             sandboxDir = new File("../tests");
-     }
-
-     protected void tearDown() throws Exception {
-             super.tearDown();
-             sandboxDir = oldSandBoxDir;
-     }
-       
+
+       File oldSandBoxDir;
+
+       protected void setUp() throws Exception {
+               super.setUp();
+               oldSandBoxDir = sandboxDir;
+               sandboxDir = new File("../tests");
+       }
+
+       protected void tearDown() throws Exception {
+               super.tearDown();
+               sandboxDir = oldSandBoxDir;
+       }
+
        public void testExtension() {
                String testFileDir = "bugs/pointcutdoctor-bug193065";
                AjCompiler compiler = getCompilerForProjectWithName(testFileDir);
                compiler.setCustomMungerFactory(new DumbCustomMungerFactory());
 
                doBuild(testFileDir);
-               
-               CustomMungerFactory factory = (CustomMungerFactory)compiler.getCustomMungerFactory();
-               assertTrue(factory.getAllCreatedCustomShadowMungers().size()>0);
-               for (Iterator i = factory.getAllCreatedCustomShadowMungers().iterator(); i.hasNext();)
-                       assertTrue(((DumbShadowMunger)i.next()).called);
-               
-               assertTrue(factory.getAllCreatedCustomTypeMungers().size()>0);
-               for (Iterator i = factory.getAllCreatedCustomTypeMungers().iterator(); i.hasNext();)
-                       assertTrue(((DumbTypeMunger)i.next()).called);
+
+               CustomMungerFactory factory = (CustomMungerFactory) compiler.getCustomMungerFactory();
+               assertTrue(factory.getAllCreatedCustomShadowMungers().size() > 0);
+               for (Iterator<ShadowMunger> i = factory.getAllCreatedCustomShadowMungers().iterator(); i.hasNext();) {
+                       assertTrue(((DumbShadowMunger) i.next()).called);
+               }
+
+               assertTrue(factory.getAllCreatedCustomTypeMungers().size() > 0);
+               for (Iterator<ConcreteTypeMunger> i = factory.getAllCreatedCustomTypeMungers().iterator(); i.hasNext();) {
+                       assertTrue(((DumbTypeMunger) i.next()).called);
+               }
        }
-       
+
        class DumbCustomMungerFactory implements CustomMungerFactory {
-               Collection allShadowMungers = new ArrayList();
-               Collection allTypeMungers = new ArrayList();
-               public Collection createCustomShadowMungers(ResolvedType aspectType) {
-                       List/* ShadowMunger */ mungers = new ArrayList/*ShadowMunger*/(); 
+               Collection<ShadowMunger> allShadowMungers = new ArrayList<ShadowMunger>();
+               Collection<ConcreteTypeMunger> allTypeMungers = new ArrayList<ConcreteTypeMunger>();
+
+               public Collection<ShadowMunger> createCustomShadowMungers(ResolvedType aspectType) {
+                       List<ShadowMunger> mungers = new ArrayList<ShadowMunger>();
                        Pointcut pointcut = new IfPointcut("abc");
                        mungers.add(new DumbShadowMunger(new DeclareErrorOrWarning(false, pointcut, "")));
                        allShadowMungers.addAll(mungers);
                        return mungers;
                }
 
-               public Collection createCustomTypeMungers(ResolvedType aspectType) {
-                       List/*ConcreteTypeMunger*/ mungers = new ArrayList/*ShadowMunger*/(); 
+               public Collection<ConcreteTypeMunger> createCustomTypeMungers(ResolvedType aspectType) {
+                       List<ConcreteTypeMunger> mungers = new ArrayList<ConcreteTypeMunger>();
                        mungers.add(new DumbTypeMunger(null, aspectType));
                        allTypeMungers.addAll(mungers);
                        return mungers;
                }
 
-               public Collection getAllCreatedCustomShadowMungers() {
+               public Collection<ShadowMunger> getAllCreatedCustomShadowMungers() {
                        return allShadowMungers;
                }
 
-               public Collection getAllCreatedCustomTypeMungers() {
+               public Collection<ConcreteTypeMunger> getAllCreatedCustomTypeMungers() {
                        return allTypeMungers;
                }
        }
@@ -119,14 +123,13 @@ public class CustomMungerExtensionTest extends AjdeInteractionTestbed {
                public ConcreteTypeMunger parameterizedFor(ResolvedType targetType) {
                        return null;
                }
-               
+
                public boolean matches(ResolvedType onType) {
                        called = true;
                        return false;
                }
 
-               public ConcreteTypeMunger parameterizeWith(Map parameterizationMap,
-                               World world) {
+               public ConcreteTypeMunger parameterizeWith(Map parameterizationMap, World world) {
                        // TODO Auto-generated method stub
                        return null;
                }
index 6a002a782a2f3c6479e2f8e81ad6806126337d3a..4772d4b2b585b205d932c1a2c7ba26c89cda0771 100644 (file)
@@ -7,13 +7,16 @@
  *******************************************************************************/
 package org.aspectj.systemtest.ajc169;
 
+import java.io.ByteArrayOutputStream;
 import java.io.File;
+import java.io.PrintWriter;
 
 import junit.framework.Test;
 
 import org.aspectj.apache.bcel.classfile.JavaClass;
 import org.aspectj.apache.bcel.util.ClassPath;
 import org.aspectj.apache.bcel.util.SyntheticRepository;
+import org.aspectj.asm.AsmManager;
 import org.aspectj.testing.XMLBasedAjcTestCase;
 
 /**
@@ -36,6 +39,33 @@ public class IntertypeTests extends org.aspectj.testing.XMLBasedAjcTestCase {
                runTest("choice");
        }
 
+       public void testRooScenario2() throws Exception {
+               runTest("choice2");
+       }
+
+       public void testRooScenarioWeaveInfo() throws Exception {
+               runTest("choice - weaveinfo");
+       }
+
+       public void testModel() throws Exception {
+               runTest("choice - model");
+               ByteArrayOutputStream baos = new ByteArrayOutputStream();
+               PrintWriter pw = new PrintWriter(baos);
+               AsmManager.dumptree(pw, AsmManager.lastActiveStructureModel.getHierarchy().getRoot(), 0);
+               pw.write(AsmManager.lastActiveStructureModel.getRelationshipMap().toString());
+               pw.flush();
+               String model = baos.toString();
+               assertTrue(model.indexOf("<{Choice.java[Choice=[aspect declarations], <{Choice.java}X[Keys=[declared on]") != -1);
+       }
+
+       public void testGenerics1() throws Exception {
+               runTest("choice - generics 1");
+       }
+
+       public void testGenerics2() throws Exception {
+               runTest("choice - generics 2");
+       }
+
        // compiler limitation tests
        public void testNotAllowedOnInterface() throws Exception {
                runTest("on interface");
index bac60086a52dfa4f69ced2de4a58ce4e264aafde..2cbb61190b4517769094305d61b79df805504ffd 100644 (file)
@@ -2,6 +2,16 @@
 
 <suite>
 
+   <ajc-test dir="features169/itdInnerTypes" title="choice - generics 1">
+     <compile files="ChoiceGenerics1.java" options="-1.5"/>
+   </ajc-test>
+
+   <ajc-test dir="features169/itdInnerTypes" title="choice - generics 2">
+     <compile files="ChoiceGenerics2.java" options="-1.5">
+       <message kind="error" text="Type mismatch: cannot convert from String to Integer"/>
+     </compile>
+   </ajc-test>
+   
    <ajc-test dir="features169/itdInnerTypes" title="choice">
      <compile files="Choice.java" options="-1.5"/>
      <run class="Choice">
        </stdout></run>
    </ajc-test>
    
+   <ajc-test dir="features169/itdInnerTypes" title="choice - weaveinfo">
+     <compile files="Choice.java" options="-1.5 -showWeaveInfo">
+       <message kind="weave" text="Type 'Choice' (Choice.java) has intertyped member class from 'X' (Choice.java)"/>
+     </compile>
+   </ajc-test>
+   
+   <ajc-test dir="features169/itdInnerTypes" title="choice - model">
+     <compile files="Choice.java" options="-1.5 -emacssym"/>
+   </ajc-test>
+   
+   <ajc-test dir="features169/itdInnerTypes" title="choice2">
+     <compile files="Choice2.java" options="-1.5"/>
+     <run class="Choice2">
+       <stdout>
+       <line text="null"/>
+       </stdout></run>
+   </ajc-test>
+   
    <ajc-test dir="features169/itdInnerTypes" title="field access">
      <compile files="FieldAccess.java" options="-1.5"/>
      <run class="FieldAccess">