]> source.dussan.org Git - aspectj.git/commitdiff
376351
authorAndy Clement <andrew.clement@gmail.com>
Mon, 9 Apr 2012 21:15:55 +0000 (14:15 -0700)
committerAndy Clement <andrew.clement@gmail.com>
Mon, 9 Apr 2012 21:15:55 +0000 (14:15 -0700)
tests/bugs170/pr376351/R.java [new file with mode: 0644]
tests/bugs170/pr376351/R1.java [new file with mode: 0644]
tests/bugs170/pr376351/RAj.java [new file with mode: 0644]
tests/bugs170/pr376351/aop.xml [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc170/Ajc170Tests.java
tests/src/org/aspectj/systemtest/ajc170/ajc170.xml
weaver/src/org/aspectj/weaver/bcel/asm/StackMapAdder.java

diff --git a/tests/bugs170/pr376351/R.java b/tests/bugs170/pr376351/R.java
new file mode 100644 (file)
index 0000000..80233db
--- /dev/null
@@ -0,0 +1,6 @@
+public class R{ 
+  public static void main(String[] args) {
+    R r = new R();
+    System.out.println(r.getClass().getName());
+  }
+}
diff --git a/tests/bugs170/pr376351/R1.java b/tests/bugs170/pr376351/R1.java
new file mode 100644 (file)
index 0000000..05a6029
--- /dev/null
@@ -0,0 +1 @@
+public class R1 extends R {}
diff --git a/tests/bugs170/pr376351/RAj.java b/tests/bugs170/pr376351/RAj.java
new file mode 100644 (file)
index 0000000..78c2122
--- /dev/null
@@ -0,0 +1,9 @@
+public aspect RAj
+{
+    pointcut createR() : call(R.new()) && !within(RAj);
+    Object around() : createR()
+    {
+        System.out.println("aspect running");
+        return new R1();
+    }
+}
diff --git a/tests/bugs170/pr376351/aop.xml b/tests/bugs170/pr376351/aop.xml
new file mode 100644 (file)
index 0000000..91026c7
--- /dev/null
@@ -0,0 +1,5 @@
+<aspectj>
+<aspects>
+<aspect name="RAj"/>
+</aspects>
+</aspectj>
index 643340944c1c8610b2d8bb3d409db6a4749f0ddd..b51ce51f3327caf2ed55f7bd6b0cce4923ccde6a 100644 (file)
@@ -31,6 +31,10 @@ import org.aspectj.weaver.tools.StandardPointcutParser;
  */ 
 public class Ajc170Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
 
+       public void testAttributeErrorJ7() {
+               runTest("attribute issue with J7");
+       }
+       
        public void testSwitchOnEnum() {
                runTest("switch on enum");
        }
index 5bf94415ce7c8a921739679b92d845d2ae6a4c5a..a9069d531e1d35a431fbf60933b56aad885e5ede 100644 (file)
@@ -2,6 +2,24 @@
 
 <suite>
 
+       <ajc-test dir="bugs170/pr376351" title="attribute issue with J7">
+     <compile files="R.java R1.java" outjar="code.jar" options="-1.5"/>
+     <compile files="RAj.java" options="-1.7 -Xlint:ignore" outjar="aspects.jar" classpath="code.jar"/>
+     <compile inpath="code.jar" aspectpath="aspects.jar" options="-showWeaveInfo">
+     <message kind="weave" text="Join point 'constructor-call(void R.&lt;init&gt;())'"/>
+     </compile>
+     <!-- 
+     if we had a 1.7 vm we could use this:
+     <compile files="RAj.java" options="-1.7 -Xlint:ignore"/>
+     <run class="R" ltw="aop.xml">
+     <stderr>
+     <line text="org.aspectj.weaver.tools.Jdk14Trace error"/>
+     <line text="Unsupported major.minor version 51.0"/>
+     <line text="java.lang.UnsupportedClassVersionError: RAj :"/>
+     </stderr>
+     </run>
+     -->
+   </ajc-test>
 
        <ajc-test dir="bugs170/pr376139" title="switch on enum">
      <compile files="Code.java" options="-1.5"/>
index 87b0f6b952a8e9d2a42ce2a49d3faa8015336421..07477d1a9bc753770e7ef9c512cc7211d4f590d1 100644 (file)
@@ -30,7 +30,7 @@ public class StackMapAdder {
        public static byte[] addStackMaps(World world, byte[] data) {
                try {
                        ClassReader cr = new ClassReader(data);
-                       ClassWriter cw = new AspectJConnectClassWriter(world);
+                       ClassWriter cw = new AspectJConnectClassWriter(cr, world);
                        cr.accept(cw, 0);
                        return cw.toByteArray();
                } catch (Throwable t) {
@@ -43,8 +43,8 @@ public class StackMapAdder {
        private static class AspectJConnectClassWriter extends ClassWriter {
                private final World world;
 
-               public AspectJConnectClassWriter(World w) {
-                       super(ClassWriter.COMPUTE_FRAMES);
+               public AspectJConnectClassWriter(ClassReader cr, World w) {
+                       super(cr, ClassWriter.COMPUTE_FRAMES); // passing in cr is necessary so cpool isnt modified (see 2.2.4 of asm doc)
                        this.world = w;
                }