From 61cd77beeb1135bc1a0ab9f456e3ff835651844e Mon Sep 17 00:00:00 2001 From: aclement Date: Mon, 24 Jan 2005 08:49:15 +0000 Subject: [PATCH] This fix for 'c' values in annotations has been verified by Pepe. Committing source changes and testcase. --- .../annotation/ClassElementValueGen.java | 8 +++++++- .../generic/annotation/ElementValueGen.java | 4 ++++ ...RuntimeVisibleAnnotationAttributeTest.java | 11 +++++++++++ lib/bcel/bcel-src.zip | Bin 867421 -> 867421 bytes lib/bcel/bcel.jar | Bin 579572 -> 579572 bytes 5 files changed, 22 insertions(+), 1 deletion(-) diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/annotation/ClassElementValueGen.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/annotation/ClassElementValueGen.java index 4639e6b8b..051d2d8df 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/annotation/ClassElementValueGen.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/annotation/ClassElementValueGen.java @@ -17,6 +17,7 @@ import java.io.IOException; import org.aspectj.apache.bcel.classfile.ConstantClass; import org.aspectj.apache.bcel.classfile.ConstantUtf8; +import org.aspectj.apache.bcel.classfile.annotation.ClassElementValue; import org.aspectj.apache.bcel.generic.ConstantPoolGen; import org.aspectj.apache.bcel.generic.ObjectType; @@ -37,7 +38,12 @@ public class ClassElementValueGen extends ElementValueGen { this.idx = cpool.addClass(t); } - public int getIndex() { + public ClassElementValueGen(ClassElementValue value, ConstantPoolGen cpool) { + super(CLASS,cpool); + idx = value.getIndex(); + } + + public int getIndex() { return idx; } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/annotation/ElementValueGen.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/annotation/ElementValueGen.java index b97afc8e3..054e1cbf8 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/annotation/ElementValueGen.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/annotation/ElementValueGen.java @@ -18,6 +18,7 @@ import java.io.IOException; import org.aspectj.apache.bcel.classfile.annotation.AnnotationElementValue; import org.aspectj.apache.bcel.classfile.annotation.ArrayElementValue; +import org.aspectj.apache.bcel.classfile.annotation.ClassElementValue; import org.aspectj.apache.bcel.classfile.annotation.ElementValue; import org.aspectj.apache.bcel.classfile.annotation.EnumElementValue; import org.aspectj.apache.bcel.classfile.annotation.SimpleElementValue; @@ -130,6 +131,9 @@ public abstract class ElementValueGen { case '[': // Array return new ArrayElementValueGen((ArrayElementValue)value,cpool); + case 'c': // Class + return new ClassElementValueGen((ClassElementValue)value,cpool); + default: throw new RuntimeException("Not implemented yet! ("+value.getElementValueType()+")"); } diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleAnnotationAttributeTest.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleAnnotationAttributeTest.java index 129dbddbe..494bc1239 100644 --- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleAnnotationAttributeTest.java +++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleAnnotationAttributeTest.java @@ -30,6 +30,8 @@ import org.aspectj.apache.bcel.classfile.annotation.ElementValue; import org.aspectj.apache.bcel.classfile.annotation.EnumElementValue; import org.aspectj.apache.bcel.classfile.annotation.SimpleElementValue; import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleAnnotations; +import org.aspectj.apache.bcel.generic.ClassGen; +import org.aspectj.apache.bcel.generic.annotation.AnnotationGen; import org.aspectj.apache.bcel.util.SyntheticRepository; @@ -227,6 +229,15 @@ public class RuntimeVisibleAnnotationAttributeTest extends BcelTestCase { verifyClassAnnotation(clazz); } + public void testAnnotationClassElementCopying() throws ClassNotFoundException { + SyntheticRepository repos = createRepos("testcode.jar"); + JavaClass clazz = repos.loadClass("AnnotatedWithClassClass"); + Annotation[] anns = clazz.getAnnotations(); + ClassGen cg = new ClassGen(clazz); + // Checks we can copy class values in an annotation + new AnnotationGen(anns[0],cg.getConstantPool()); + } + public void testAnnotationClassElementReadWrite() throws ClassNotFoundException,IOException { SyntheticRepository repos = createRepos("testcode.jar"); JavaClass clazz = repos.loadClass("AnnotatedWithClassClass"); diff --git a/lib/bcel/bcel-src.zip b/lib/bcel/bcel-src.zip index 12a8ef023a6d71a4c0660e1078e57123a9efbe40..06f9e8d071b61e61dcbe98fc2dee68def5d5a6f2 100644 GIT binary patch delta 101 zcmccn!{qJ{lZFF7M2#)7Pc1l7LF~PAENjQE6t6LJz!YF7M2#)7Pc1l7LF~PAENk*qs@(uJz!YF7M3ln-62ecmD_tmSZg?#ZdJ5%$Fc%38xXT^=Z@tl2>{AY RZ(Pgq94NUxYaK_ICICEu7-#?h delta 66 zcmeyeUir&<<%Sl<7N!>F7M3ln-62fH(c61NSZg?#&PKI!$Fc%38xXT^=Z@tl2>{AY RZ(Pgq94NUxYaK_ICIBv>7uo;- -- 2.39.5