]> source.dussan.org Git - aspectj.git/commitdiff
testcode for 149305, 149096, 149305: fix for 149305
authoraclement <aclement>
Tue, 4 Jul 2006 16:57:09 +0000 (16:57 +0000)
committeraclement <aclement>
Tue, 4 Jul 2006 16:57:09 +0000 (16:57 +0000)
tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java
weaver/src/org/aspectj/weaver/CrosscuttingMembers.java

index 2fdfb4664921613a2fc86eb7b059d385d965d9ba..e6fc85777ce57f051fb16cb6a4dd232bf8f476d5 100644 (file)
@@ -14,14 +14,81 @@ import java.io.File;
 
 import junit.framework.Test;
 
+import org.aspectj.apache.bcel.Repository;
+import org.aspectj.apache.bcel.classfile.JavaClass;
+import org.aspectj.apache.bcel.classfile.Method;
+import org.aspectj.apache.bcel.util.ClassPath;
+import org.aspectj.apache.bcel.util.SyntheticRepository;
+import org.aspectj.apache.bcel.verifier.VerificationResult;
+import org.aspectj.apache.bcel.verifier.Verifier;
+import org.aspectj.apache.bcel.verifier.VerifierFactory;
 import org.aspectj.testing.XMLBasedAjcTestCase;
 
 public class Ajc153Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
 
   // public void testArgnamesAndJavac_pr148381() { runTest("argNames and javac");}
-
+  // public void testCFlowXMLAspectLTW_pr149096() { runTest("cflow xml concrete aspect"); }
   public void testIllegalStateException_pr148737() { runTest("illegalstateexception for non generic type");}
+  public void testAtajInheritance_pr149305_1() { runTest("ataj inheritance - 1");}
+  public void testAtajInheritance_pr149305_2() { runTest("ataj inheritance - 2");}
+  public void testAtajInheritance_pr149305_3() { runTest("ataj inheritance - 3");}
+
+
+  // work in progress
 
+//     public void testVerificationFailureForAspectOf_pr148693() throws ClassNotFoundException {
+//             runTest("verification problem");
+//             verifyClass("mypackage.MyAspect");
+//     }
+       
+
+       // TODO refactor into a util class
+       /**
+        * Performs verification of a class - the supplied class is expected to exist in the sandbox
+        * directory so typically this is called after a small compile step has been invoked to build it.
+        */
+       public void verifyClass(String clazzname) {
+               JavaClass jc = null;
+               try {
+                       jc = getClassFrom(ajc.getSandboxDirectory().getAbsolutePath(),clazzname);
+               } catch (ClassNotFoundException cnfe) {
+                       fail("Could not find "+clazzname+" in the sandbox: "+ajc.getSandboxDirectory());
+               }
+               assertTrue("Could not find class",jc!=null);
+               Repository.setRepository(jc.getRepository());
+               Verifier v = VerifierFactory.getVerifier("mypackage.MyAspect"); 
+               VerificationResult vr = v.doPass1();
+               System.err.println(vr);
+               
+               assertTrue("Verification: "+vr,vr.getStatus()==VerificationResult.VERIFIED_OK);
+               vr = v.doPass2();
+               System.err.println(vr);
+               assertTrue("Verification: "+vr,vr.getStatus()==VerificationResult.VERIFIED_OK);
+               Method[] ms = jc.getMethods();
+               for (int i = 0; i < ms.length; i++) {
+                       System.err.println("Pass3a for "+ms[i]);
+                       vr = v.doPass3a(i);
+                       System.err.println(vr);
+                       assertTrue("Verification: "+vr,vr.getStatus()==VerificationResult.VERIFIED_OK);
+                       System.err.println("Pass3b for "+ms[i]);
+                       vr = v.doPass3b(i);
+                       System.err.println(vr);
+                       assertTrue("Verification: "+vr,vr.getStatus()==VerificationResult.VERIFIED_OK);
+               }
+       }
+       
+       protected  JavaClass getClassFrom(String frompath,String clazzname) throws ClassNotFoundException {
+               SyntheticRepository repos = createRepos(frompath);
+               return repos.loadClass(clazzname);
+       }
+
+       public SyntheticRepository createRepos(String cpentry) {
+               ClassPath cp = new ClassPath(
+                               cpentry+File.pathSeparator+
+                               System.getProperty("java.class.path"));
+               return SyntheticRepository.getInstance(cp);
+       }       
+  
   /////////////////////////////////////////
   public static Test suite() {
     return XMLBasedAjcTestCase.loadSuite(Ajc153Tests.class);
index c280b0de1d494f51c4ea1533ff0373a73d9465bf..7ee94d92d8b1be92d0e95dd5606c2a1a63008fbb 100644 (file)
@@ -237,8 +237,11 @@ public class CrosscuttingMembers {
                        PointcutRewriter pr = new PointcutRewriter();
                        for (Iterator iter = otherShadowMungers.iterator(); iter.hasNext();) {
                                ShadowMunger munger = (ShadowMunger) iter.next();
-                               Pointcut p = munger.getPointcut();
-                               Pointcut newP = pr.rewrite(p);
+                               Pointcut p          = munger.getPointcut();
+                               Pointcut newP       = pr.rewrite(p);
+                               if (p.m_ignoreUnboundBindingForNames.length!=0) {// *sigh* dirty fix for dirty hacky implementation pr149305
+                                       newP.m_ignoreUnboundBindingForNames = p.m_ignoreUnboundBindingForNames;
+                               }
                                munger.setPointcut(newP);
                        }
                        if (!theseShadowMungers.equals(otherShadowMungers)) {