]> source.dussan.org Git - aspectj.git/commitdiff
This fix for 'c' values in annotations has been verified by Pepe. Committing source...
authoraclement <aclement>
Mon, 24 Jan 2005 08:49:15 +0000 (08:49 +0000)
committeraclement <aclement>
Mon, 24 Jan 2005 08:49:15 +0000 (08:49 +0000)
bcel-builder/src/org/aspectj/apache/bcel/generic/annotation/ClassElementValueGen.java
bcel-builder/src/org/aspectj/apache/bcel/generic/annotation/ElementValueGen.java
bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleAnnotationAttributeTest.java
lib/bcel/bcel-src.zip
lib/bcel/bcel.jar

index 4639e6b8bb2bb174d38de6ad0bf129971af634fc..051d2d8df406efbf5251810496ce7e11c41a4e87 100644 (file)
@@ -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;
     }
      
index b97afc8e38a66ce1419e0a0d65650b2856e98d58..054e1cbf80738c2d2b381eda54e660ced4d49519 100644 (file)
@@ -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()+")");
                }
index 129dbddbefbe5af4b0a2e587ab24771caf212d60..494bc1239be4a4c43d6e58055062a2dcbbc880da 100644 (file)
@@ -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");
index 12a8ef023a6d71a4c0660e1078e57123a9efbe40..06f9e8d071b61e61dcbe98fc2dee68def5d5a6f2 100644 (file)
Binary files a/lib/bcel/bcel-src.zip and b/lib/bcel/bcel-src.zip differ
index 658c0612b0e9cecaba1a11d4b87d1fc094ce0ce3..0b0dcbeb7ff40f3b57334cf7758c59edc70e4a39 100644 (file)
Binary files a/lib/bcel/bcel.jar and b/lib/bcel/bcel.jar differ