summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraclement <aclement>2004-12-09 15:19:39 +0000
committeraclement <aclement>2004-12-09 15:19:39 +0000
commit60b62539f1f1887f9c66caa995254e9e4ea89f2b (patch)
treeb2aade0e9a6dc89fb212b0e355cba7fff238b4f1
parentd474aa398cd671644f48fe8ffe55095109700a1e (diff)
downloadaspectj-60b62539f1f1887f9c66caa995254e9e4ea89f2b.tar.gz
aspectj-60b62539f1f1887f9c66caa995254e9e4ea89f2b.zip
Allows for MarkerAnnotations - doh! (i.e. ones with no values) and unpacks invis annotations on classgens correctly.
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/Annotation.java3
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/generic/ClassGen.java10
-rw-r--r--bcel-builder/testdata/MarkedType.java4
-rw-r--r--bcel-builder/testdata/MarkerAnnotation.java4
-rw-r--r--bcel-builder/testdata/MarkerAnnotationInvisible.java4
-rw-r--r--bcel-builder/testdata/testcode.jarbin14247 -> 15279 bytes
-rw-r--r--bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AllTests.java1
-rw-r--r--bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/MethodAnnotationsTest.java1
-rw-r--r--bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/TypeAnnotationsTest.java35
-rw-r--r--lib/bcel/bcel-src.zipbin867296 -> 862011 bytes
-rw-r--r--lib/bcel/bcel.jarbin579396 -> 574117 bytes
11 files changed, 58 insertions, 4 deletions
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/Annotation.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/Annotation.java
index f5c280018..ca7a8ec8d 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/Annotation.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/Annotation.java
@@ -30,7 +30,7 @@ import org.aspectj.apache.bcel.classfile.Utility;
*/
public class Annotation {
private int typeIndex;
- private List /* ElementNameValuePair */ evs;
+ private List /* ElementNameValuePair */ evs = new ArrayList();
private ConstantPool cpool;
private boolean isRuntimeVisible;
@@ -74,7 +74,6 @@ public class Annotation {
}
public void addElementNameValuePair(ElementNameValuePair evp) {
- if (evs == null) evs = new ArrayList();
evs.add(evp);
}
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/ClassGen.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/ClassGen.java
index 93e5ca8fb..a4fd19d13 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/generic/ClassGen.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/ClassGen.java
@@ -68,6 +68,7 @@ import org.aspectj.apache.bcel.classfile.Method;
import org.aspectj.apache.bcel.classfile.SourceFile;
import org.aspectj.apache.bcel.classfile.Utility;
import org.aspectj.apache.bcel.classfile.annotation.Annotation;
+import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisibleAnnotations;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleAnnotations;
import org.aspectj.apache.bcel.generic.annotation.AnnotationGen;
@@ -76,7 +77,7 @@ import org.aspectj.apache.bcel.generic.annotation.AnnotationGen;
* existing java class (file).
*
* @see JavaClass
- * @version $Id: ClassGen.java,v 1.3 2004/11/22 08:31:27 aclement Exp $
+ * @version $Id: ClassGen.java,v 1.4 2004/12/09 15:19:39 aclement Exp $
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
*/
public class ClassGen extends AccessFlags implements Cloneable {
@@ -200,6 +201,13 @@ public class ClassGen extends AccessFlags implements Cloneable {
Annotation a = (Annotation) iter.next();
annotationGenObjs.add(new AnnotationGen(a,getConstantPool()));
}
+ } else if (attr instanceof RuntimeInvisibleAnnotations) {
+ RuntimeInvisibleAnnotations ria = (RuntimeInvisibleAnnotations)attr;
+ List annos = ria.getAnnotations();
+ for (Iterator iter = annos.iterator(); iter.hasNext();) {
+ Annotation a = (Annotation) iter.next();
+ annotationGenObjs.add(new AnnotationGen(a,getConstantPool()));
+ }
}
}
return (AnnotationGen[])annotationGenObjs.toArray(new AnnotationGen[]{});
diff --git a/bcel-builder/testdata/MarkedType.java b/bcel-builder/testdata/MarkedType.java
new file mode 100644
index 000000000..2b0948438
--- /dev/null
+++ b/bcel-builder/testdata/MarkedType.java
@@ -0,0 +1,4 @@
+@MarkerAnnotationInvisible
+@MarkerAnnotation
+public class MarkedType {
+}
diff --git a/bcel-builder/testdata/MarkerAnnotation.java b/bcel-builder/testdata/MarkerAnnotation.java
new file mode 100644
index 000000000..f314a9432
--- /dev/null
+++ b/bcel-builder/testdata/MarkerAnnotation.java
@@ -0,0 +1,4 @@
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface MarkerAnnotation { }
diff --git a/bcel-builder/testdata/MarkerAnnotationInvisible.java b/bcel-builder/testdata/MarkerAnnotationInvisible.java
new file mode 100644
index 000000000..9b41a593a
--- /dev/null
+++ b/bcel-builder/testdata/MarkerAnnotationInvisible.java
@@ -0,0 +1,4 @@
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.CLASS)
+public @interface MarkerAnnotationInvisible { }
diff --git a/bcel-builder/testdata/testcode.jar b/bcel-builder/testdata/testcode.jar
index cbfaa1a2d..3324bf340 100644
--- a/bcel-builder/testdata/testcode.jar
+++ b/bcel-builder/testdata/testcode.jar
Binary files differ
diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AllTests.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AllTests.java
index 69d41d6b8..c2a087166 100644
--- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AllTests.java
+++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AllTests.java
@@ -48,6 +48,7 @@ public class AllTests {
suite.addTestSuite(AnnotationGenTest.class);
suite.addTestSuite(ParameterAnnotationsTest.class);
suite.addTestSuite(GeneratingAnnotatedClassesTest.class);
+ suite.addTestSuite(TypeAnnotationsTest.class);
//$JUnit-END$
return suite;
}
diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/MethodAnnotationsTest.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/MethodAnnotationsTest.java
index 5740add02..dab8e7cf3 100644
--- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/MethodAnnotationsTest.java
+++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/MethodAnnotationsTest.java
@@ -30,7 +30,6 @@ public class MethodAnnotationsTest extends BcelTestCase {
super.setUp();
}
-
public void testMethodAnnotations() throws ClassNotFoundException {
JavaClass clazz = getClassFromJar("AnnotatedMethods");
diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/TypeAnnotationsTest.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/TypeAnnotationsTest.java
new file mode 100644
index 000000000..88313faf3
--- /dev/null
+++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/TypeAnnotationsTest.java
@@ -0,0 +1,35 @@
+/* *******************************************************************
+ * Copyright (c) 2004 IBM
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Common Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * Andy Clement - initial implementation
+ * ******************************************************************/
+
+package org.aspectj.apache.bcel.classfile.tests;
+
+import org.aspectj.apache.bcel.classfile.JavaClass;
+import org.aspectj.apache.bcel.generic.ClassGen;
+import org.aspectj.apache.bcel.generic.annotation.AnnotationGen;
+
+
+public class TypeAnnotationsTest extends BcelTestCase {
+
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testMarkerAnnotationsOnTypes() throws ClassNotFoundException {
+ JavaClass clazz = getClassFromJar("MarkedType");
+ ClassGen cg = new ClassGen(clazz);
+ AnnotationGen[] annotations = cg.getAnnotations();
+ assertTrue("Should be a MarkerAnnotation and a MarkerAnnotationInvisible - but found: "+annotations.length,annotations.length==2);
+ }
+
+
+}
diff --git a/lib/bcel/bcel-src.zip b/lib/bcel/bcel-src.zip
index 75442a25a..14d4fd610 100644
--- a/lib/bcel/bcel-src.zip
+++ b/lib/bcel/bcel-src.zip
Binary files differ
diff --git a/lib/bcel/bcel.jar b/lib/bcel/bcel.jar
index 864a40e16..3d5db140e 100644
--- a/lib/bcel/bcel.jar
+++ b/lib/bcel/bcel.jar
Binary files differ