]> source.dussan.org Git - aspectj.git/commitdiff
Fix 440983: RuntimeInvisTypeAnnotation unpacking
authorAndy Clement <aclement@gopivotal.com>
Wed, 6 Aug 2014 15:20:07 +0000 (08:20 -0700)
committerAndy Clement <aclement@gopivotal.com>
Wed, 6 Aug 2014 15:20:07 +0000 (08:20 -0700)
12 files changed:
bcel-builder/src/org/aspectj/apache/bcel/classfile/Attribute.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeInvisTypeAnnos.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeVisTypeAnnos.java
lib/bcel/bcel-src.zip
lib/bcel/bcel.jar
tests/bugs182/440983/Code.java [new file with mode: 0644]
tests/bugs182/440983/X.java [new file with mode: 0644]
tests/bugs182/440983/code.jar [new file with mode: 0644]
tests/src/org/aspectj/systemtest/AllTests18.java
tests/src/org/aspectj/systemtest/ajc182/Ajc182Tests.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc182/AllTestsAspectJ182.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc182/tests.xml [new file with mode: 0644]

index 817628295a759ad511dc6da5f19e6f02da8ba299..34ed08f5e9674c07b5c4753713fc3d8bc1f3ab44 100644 (file)
@@ -62,6 +62,7 @@ import java.io.Serializable;
 import org.aspectj.apache.bcel.Constants;
 import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisAnnos;
 import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisParamAnnos;
+import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisTypeAnnos;
 import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisAnnos;
 import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisParamAnnos;
 import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisTypeAnnos;
@@ -162,6 +163,8 @@ public abstract class Attribute implements Cloneable, Node, Serializable {
                        return new BootstrapMethods(idx,len,file,cpool);
                case Constants.ATTR_RUNTIME_VISIBLE_TYPE_ANNOTATIONS:
                        return new RuntimeVisTypeAnnos(idx, len, file, cpool);
+               case Constants.ATTR_RUNTIME_INVISIBLE_TYPE_ANNOTATIONS:
+                       return new RuntimeInvisTypeAnnos(idx, len, file, cpool);
                case Constants.ATTR_METHOD_PARAMETERS:
                        return new MethodParameters(idx, len, file, cpool);
                default:
index a635fdd5588eb01c8163f5610c44c7e527540afc..333ccbddd587d7653788f6b5459660fb6a97e098 100644 (file)
@@ -27,11 +27,10 @@ public class RuntimeInvisTypeAnnos extends RuntimeTypeAnnos {
        }
 
        public RuntimeInvisTypeAnnos(int nameIdx, int len, ConstantPool cpool) {
-               super(Constants.ATTR_RUNTIME_INVISIBLE_TYPE_ANNOTATIONS, true, nameIdx, len, cpool);
+               super(Constants.ATTR_RUNTIME_INVISIBLE_TYPE_ANNOTATIONS, false, nameIdx, len, cpool);
        }
 
        public void accept(ClassVisitor v) {
                v.visitRuntimeInvisibleTypeAnnotations(this);
        }
-       
 }
\ No newline at end of file
index dbb7d7aeb230f1eb01cfa92660a4e3ad29f9b1c8..59b77dabcb5ee26caae3934c4cf30aba0748e448 100644 (file)
@@ -15,7 +15,6 @@ import java.io.DataInputStream;
 import java.io.IOException;
 
 import org.aspectj.apache.bcel.Constants;
-import org.aspectj.apache.bcel.classfile.Attribute;
 import org.aspectj.apache.bcel.classfile.ConstantPool;
 import org.aspectj.apache.bcel.classfile.ClassVisitor;
 
@@ -30,15 +29,8 @@ public class RuntimeVisTypeAnnos extends RuntimeTypeAnnos {
            super(Constants.ATTR_RUNTIME_VISIBLE_TYPE_ANNOTATIONS, true, nameIdx, len, cpool);
          }
    
-//       public RuntimeVisTypeAnnos(int nameIndex, int len, byte[] rvaData,ConstantPool cpool) {
-//             super(Constants.ATTR_RUNTIME_VISIBLE_TYPE_ANNOTATIONS,true,nameIndex,len,rvaData,cpool);
-//       }
-
          public void accept(ClassVisitor v) {
                v.visitRuntimeVisibleTypeAnnotations(this);
          }
 
-//       public Attribute copy(ConstantPool constant_pool) {
-//             throw new RuntimeException("Not implemented yet!");
-//       }
 }
\ No newline at end of file
index 7b2259ed01c9ff734ed7bc0896a9217d05b201c4..5996c3ced1ef8bcc213b2f6953d57caa48174e60 100644 (file)
Binary files a/lib/bcel/bcel-src.zip and b/lib/bcel/bcel-src.zip differ
index f4b2cff655ccd9fd7cf6a4ed4778d60662e6811d..5da7b48426992124ad2567a55c8d98803f35120a 100644 (file)
Binary files a/lib/bcel/bcel.jar and b/lib/bcel/bcel.jar differ
diff --git a/tests/bugs182/440983/Code.java b/tests/bugs182/440983/Code.java
new file mode 100644 (file)
index 0000000..96411a3
--- /dev/null
@@ -0,0 +1,26 @@
+import java.util.*;
+import java.lang.annotation.*;
+
+@Target(ElementType.TYPE_USE)
+@Retention(RetentionPolicy.CLASS)
+@interface Anno {}
+
+public class Code {
+  public static void xxx(String []argv) {
+    List<@Anno String> ls = new ArrayList<String>();
+    System.out.println(ls);
+  }
+
+  public static void yyy(String []argv) {
+  }
+
+  public static void main(String []argv) {
+    Code c = new Code();
+    c.xxx(argv);
+    System.out.println("works");
+  }
+}
+
+//aspect X {
+//  before(): execution(* main(..)) {}
+//}
diff --git a/tests/bugs182/440983/X.java b/tests/bugs182/440983/X.java
new file mode 100644 (file)
index 0000000..822bbfe
--- /dev/null
@@ -0,0 +1,3 @@
+aspect X {
+  before(): execution(* xxx(..)) {}
+}
diff --git a/tests/bugs182/440983/code.jar b/tests/bugs182/440983/code.jar
new file mode 100644 (file)
index 0000000..1ed5f21
Binary files /dev/null and b/tests/bugs182/440983/code.jar differ
index c382ea5045fc0b5a6433c974436b16c878de7ef4..5001f9a37db92fe8788c4a870e92dc13ec457867 100644 (file)
@@ -15,12 +15,14 @@ import junit.framework.TestSuite;
 
 import org.aspectj.systemtest.ajc180.AllTestsAspectJ180;
 import org.aspectj.systemtest.ajc181.AllTestsAspectJ181;
+import org.aspectj.systemtest.ajc182.AllTestsAspectJ182; 
 
 public class AllTests18 {
 
        public static Test suite() {
                TestSuite suite = new TestSuite("AspectJ System Test Suite - 1.8");
                // $JUnit-BEGIN$ 
+               suite.addTest(AllTestsAspectJ182.suite()); 
                suite.addTest(AllTestsAspectJ181.suite()); 
                suite.addTest(AllTestsAspectJ180.suite()); 
                suite.addTest(AllTests17.suite());
diff --git a/tests/src/org/aspectj/systemtest/ajc182/Ajc182Tests.java b/tests/src/org/aspectj/systemtest/ajc182/Ajc182Tests.java
new file mode 100644 (file)
index 0000000..545def4
--- /dev/null
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Andy Clement - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.systemtest.ajc182;
+
+import java.io.File;
+
+import junit.framework.Test;
+
+import org.aspectj.apache.bcel.classfile.JavaClass;
+import org.aspectj.apache.bcel.classfile.Method;
+import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisTypeAnnos;
+import org.aspectj.testing.XMLBasedAjcTestCase;
+
+/**
+ * @author Andy Clement
+ */
+public class Ajc182Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
+
+       public void testInvisTypeAnnos_440983() throws ClassNotFoundException {
+               runTest("invis type annos");
+               JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "Code");
+               Method m = getMethodStartsWith(jc, "xxx");
+               RuntimeInvisTypeAnnos rita = (RuntimeInvisTypeAnnos)getAttributeStartsWith(m.getCode().getAttributes(),"RuntimeInvisibleTypeAnnotations");
+               assertEquals("AnnotationGen:[Anno #0 {}]",rita.getTypeAnnotations()[0].getAnnotation().toString());
+       }
+
+       public void testInvisTypeAnnos_440983_2() throws ClassNotFoundException {
+               runTest("invis type annos 2");
+       }
+
+       // ---
+
+       public static Test suite() {
+               return XMLBasedAjcTestCase.loadSuite(Ajc182Tests.class);
+       }
+
+       @Override
+       protected File getSpecFile() {
+        return getClassResource("tests.xml");
+       }
+
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc182/AllTestsAspectJ182.java b/tests/src/org/aspectj/systemtest/ajc182/AllTestsAspectJ182.java
new file mode 100644 (file)
index 0000000..4adbdfb
--- /dev/null
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Andy Clement - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.systemtest.ajc182;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.aspectj.systemtest.apt.AptTests;
+
+public class AllTestsAspectJ182 {
+
+       public static Test suite() {
+               TestSuite suite = new TestSuite("AspectJ 1.8.2 tests");
+               // $JUnit-BEGIN$
+               suite.addTest(Ajc182Tests.suite());
+               suite.addTest(AptTests.suite());
+               // $JUnit-END$
+               return suite;
+       }
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc182/tests.xml b/tests/src/org/aspectj/systemtest/ajc182/tests.xml
new file mode 100644 (file)
index 0000000..9b73838
--- /dev/null
@@ -0,0 +1,18 @@
+<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]>
+
+<suite>
+
+       <ajc-test dir="bugs182/440983" title="invis type annos">
+               <compile options="-1.8" files="Code.java"/>
+       </ajc-test>
+       
+       <ajc-test dir="bugs182/440983" title="invis type annos 2">
+               <compile options="-1.8" files="X.java" inpath="code.jar"/>
+               <run class="Code">
+               <stdout>
+                       <line text="works"/>
+               </stdout>
+               </run>
+       </ajc-test>
+
+</suite>