summaryrefslogtreecommitdiffstats
path: root/bcel-builder/testsrc/org/aspectj
diff options
context:
space:
mode:
authoraclement <aclement>2007-02-15 15:27:57 +0000
committeraclement <aclement>2007-02-15 15:27:57 +0000
commit41c8c1c3436b3ba20726f3e7d4d2e5c51108ed11 (patch)
tree8558585e8734ca48d148583402152b1bdf3afa9d /bcel-builder/testsrc/org/aspectj
parentb6ae145e2ae12dbe183a9a3b77fff51fc731711b (diff)
downloadaspectj-41c8c1c3436b3ba20726f3e7d4d2e5c51108ed11.tar.gz
aspectj-41c8c1c3436b3ba20726f3e7d4d2e5c51108ed11.zip
repairing HEAD
Diffstat (limited to 'bcel-builder/testsrc/org/aspectj')
-rw-r--r--bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AllTests.java3
-rw-r--r--bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AnnotationDefaultAttributeTest.java8
-rw-r--r--bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AnnotationGenTest.java16
-rw-r--r--bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/BcelTestCase.java24
-rw-r--r--bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ElementValueGenTest.java34
-rw-r--r--bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/FieldAnnotationsTest.java15
-rw-r--r--bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/GeneratingAnnotatedClassesTest.java96
-rw-r--r--bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/MethodAnnotationsTest.java14
-rw-r--r--bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ParameterAnnotationsTest.java85
-rw-r--r--bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleAnnotationAttributeTest.java97
-rw-r--r--bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleParameterAnnotationAttributeTest.java22
-rw-r--r--bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/TypeAnnotationsTest.java2
-rw-r--r--bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/VarargsTest.java8
13 files changed, 223 insertions, 201 deletions
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 cf270b5b0..da406e725 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
@@ -31,9 +31,8 @@ import org.aspectj.apache.bcel.classfile.tests.VarargsTest;
public class AllTests {
public static Test suite() {
- TestSuite suite = new TestSuite("Tests for BCEL");
+ TestSuite suite = new TestSuite("Tests for BCEL Java5 support");
//$JUnit-BEGIN$
- suite.addTestSuite(Fundamentals.class);
suite.addTestSuite(RuntimeVisibleParameterAnnotationAttributeTest.class);
suite.addTestSuite(AnnotationDefaultAttributeTest.class);
suite.addTestSuite(EnclosingMethodAttributeTest.class);
diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AnnotationDefaultAttributeTest.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AnnotationDefaultAttributeTest.java
index 2a57bbaac..ced29d489 100644
--- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AnnotationDefaultAttributeTest.java
+++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AnnotationDefaultAttributeTest.java
@@ -15,8 +15,8 @@ package org.aspectj.apache.bcel.classfile.tests;
import org.aspectj.apache.bcel.classfile.AnnotationDefault;
import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.classfile.Method;
-import org.aspectj.apache.bcel.classfile.annotation.ElementValueGen;
-import org.aspectj.apache.bcel.classfile.annotation.SimpleElementValueGen;
+import org.aspectj.apache.bcel.classfile.annotation.ElementValue;
+import org.aspectj.apache.bcel.classfile.annotation.SimpleElementValue;
public class AnnotationDefaultAttributeTest extends BcelTestCase {
@@ -35,9 +35,9 @@ public class AnnotationDefaultAttributeTest extends BcelTestCase {
Method m = getMethod(clazz,"fruit");
AnnotationDefault a = (AnnotationDefault) findAttribute("AnnotationDefault",m.getAttributes());
- SimpleElementValueGen val = (SimpleElementValueGen) a.getElementValue();
+ SimpleElementValue val = (SimpleElementValue) a.getElementValue();
assertTrue("Should be STRING but is "+val.getElementValueType(),
- val.getElementValueType()==ElementValueGen.STRING);
+ val.getElementValueType()==ElementValue.STRING);
assertTrue("Should have default of bananas but default is "+val.getValueString(),
val.getValueString().equals("bananas"));
}
diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AnnotationGenTest.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AnnotationGenTest.java
index 306a1a387..c863fda83 100644
--- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AnnotationGenTest.java
+++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AnnotationGenTest.java
@@ -21,16 +21,16 @@ import java.util.Vector;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.apache.bcel.classfile.Utility;
import org.aspectj.apache.bcel.classfile.Attribute;
-import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen;
-import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePairGen;
-import org.aspectj.apache.bcel.classfile.annotation.ElementValueGen;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleAnnotations;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisibleAnnotations;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeAnnotations;
-import org.aspectj.apache.bcel.classfile.annotation.SimpleElementValueGen;
import org.aspectj.apache.bcel.generic.ClassGen;
-import org.aspectj.apache.bcel.classfile.ConstantPool;
+import org.aspectj.apache.bcel.generic.ConstantPoolGen;
import org.aspectj.apache.bcel.generic.ObjectType;
+import org.aspectj.apache.bcel.generic.annotation.AnnotationGen;
+import org.aspectj.apache.bcel.generic.annotation.ElementNameValuePairGen;
+import org.aspectj.apache.bcel.generic.annotation.ElementValueGen;
+import org.aspectj.apache.bcel.generic.annotation.SimpleElementValueGen;
public class AnnotationGenTest extends BcelTestCase {
@@ -50,7 +50,7 @@ public class AnnotationGenTest extends BcelTestCase {
// Create the containing class
ClassGen cg = createClassGen("HelloWorld");
- ConstantPool cp = cg.getConstantPool();
+ ConstantPoolGen cp = cg.getConstantPool();
// Create the simple primitive value '4' of type 'int'
SimpleElementValueGen evg =
@@ -81,7 +81,7 @@ public class AnnotationGenTest extends BcelTestCase {
// Create the containing class
ClassGen cg = createClassGen("HelloWorld");
- ConstantPool cp = cg.getConstantPool();
+ ConstantPoolGen cp = cg.getConstantPool();
// Create the simple primitive value '4' of type 'int'
SimpleElementValueGen evg =
@@ -138,7 +138,7 @@ public class AnnotationGenTest extends BcelTestCase {
////
// Helper methods
- private void checkSerialize(AnnotationGen a,ConstantPool cpg) {
+ private void checkSerialize(AnnotationGen a,ConstantPoolGen cpg) {
try {
String beforeName = a.getTypeName();
List beforeValues = a.getValues();
diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/BcelTestCase.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/BcelTestCase.java
index b8a0b503f..db2d1c78c 100644
--- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/BcelTestCase.java
+++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/BcelTestCase.java
@@ -19,12 +19,13 @@ import java.util.List;
import org.aspectj.apache.bcel.classfile.Attribute;
import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.classfile.Method;
-import org.aspectj.apache.bcel.classfile.ConstantPool;
-import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen;
-import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePairGen;
-import org.aspectj.apache.bcel.classfile.annotation.ElementValueGen;
-import org.aspectj.apache.bcel.classfile.annotation.SimpleElementValueGen;
+import org.aspectj.apache.bcel.classfile.annotation.Annotation;
+import org.aspectj.apache.bcel.generic.ConstantPoolGen;
import org.aspectj.apache.bcel.generic.ObjectType;
+import org.aspectj.apache.bcel.generic.annotation.AnnotationGen;
+import org.aspectj.apache.bcel.generic.annotation.ElementNameValuePairGen;
+import org.aspectj.apache.bcel.generic.annotation.ElementValueGen;
+import org.aspectj.apache.bcel.generic.annotation.SimpleElementValueGen;
import org.aspectj.apache.bcel.util.ClassPath;
import org.aspectj.apache.bcel.util.SyntheticRepository;
@@ -99,6 +100,17 @@ public class BcelTestCase extends TestCase {
return (Attribute)chosenAttrsList.get(0);
}
+ protected String dumpAnnotations(Annotation[] as) {
+ StringBuffer result = new StringBuffer();
+ result.append("[");
+ for (int i = 0; i < as.length; i++) {
+ Annotation annotation = as[i];
+ result.append(annotation.toShortString());
+ if (i+1<as.length) result.append(",");
+ }
+ result.append("]");
+ return result.toString();
+ }
protected String dumpAnnotations(AnnotationGen[] as) {
StringBuffer result = new StringBuffer();
@@ -124,7 +136,7 @@ public class BcelTestCase extends TestCase {
return result.toString();
}
- public AnnotationGen createFruitAnnotation(ConstantPool cp, String aFruit, boolean visibility) {
+ public AnnotationGen createFruitAnnotation(ConstantPoolGen cp, String aFruit, boolean visibility) {
SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.STRING,cp,aFruit);
ElementNameValuePairGen nvGen = new ElementNameValuePairGen("fruit",evg,cp);
ObjectType t = new ObjectType("SimpleStringAnnotation");
diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ElementValueGenTest.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ElementValueGenTest.java
index 8fc5207bd..fa0f437e2 100644
--- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ElementValueGenTest.java
+++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ElementValueGenTest.java
@@ -17,12 +17,12 @@ import java.io.IOException;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.apache.bcel.generic.ClassGen;
-import org.aspectj.apache.bcel.classfile.ConstantPool;
-import org.aspectj.apache.bcel.classfile.annotation.ClassElementValueGen;
-import org.aspectj.apache.bcel.classfile.annotation.ElementValueGen;
-import org.aspectj.apache.bcel.classfile.annotation.EnumElementValueGen;
-import org.aspectj.apache.bcel.classfile.annotation.SimpleElementValueGen;
+import org.aspectj.apache.bcel.generic.ConstantPoolGen;
import org.aspectj.apache.bcel.generic.ObjectType;
+import org.aspectj.apache.bcel.generic.annotation.ClassElementValueGen;
+import org.aspectj.apache.bcel.generic.annotation.ElementValueGen;
+import org.aspectj.apache.bcel.generic.annotation.EnumElementValueGen;
+import org.aspectj.apache.bcel.generic.annotation.SimpleElementValueGen;
public class ElementValueGenTest extends BcelTestCase {
@@ -40,7 +40,7 @@ public class ElementValueGenTest extends BcelTestCase {
public void testCreateIntegerElementValue() {
ClassGen cg = createClassGen("HelloWorld");
- ConstantPool cp = cg.getConstantPool();
+ ConstantPoolGen cp = cg.getConstantPool();
SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.PRIMITIVE_INT,cp,555);
// Creation of an element like that should leave a new entry in the cpool
@@ -51,7 +51,7 @@ public class ElementValueGenTest extends BcelTestCase {
public void testCreateFloatElementValue() {
ClassGen cg = createClassGen("HelloWorld");
- ConstantPool cp = cg.getConstantPool();
+ ConstantPoolGen cp = cg.getConstantPool();
SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.PRIMITIVE_FLOAT,cp,111.222f);
// Creation of an element like that should leave a new entry in the cpool
@@ -62,7 +62,7 @@ public class ElementValueGenTest extends BcelTestCase {
public void testCreateDoubleElementValue() {
ClassGen cg = createClassGen("HelloWorld");
- ConstantPool cp = cg.getConstantPool();
+ ConstantPoolGen cp = cg.getConstantPool();
SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.PRIMITIVE_DOUBLE,cp,333.44);
// Creation of an element like that should leave a new entry in the cpool
@@ -74,7 +74,7 @@ public class ElementValueGenTest extends BcelTestCase {
public void testCreateLongElementValue() {
ClassGen cg = createClassGen("HelloWorld");
- ConstantPool cp = cg.getConstantPool();
+ ConstantPoolGen cp = cg.getConstantPool();
SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.PRIMITIVE_LONG,cp,3334455L);
// Creation of an element like that should leave a new entry in the cpool
@@ -86,7 +86,7 @@ public class ElementValueGenTest extends BcelTestCase {
public void testCreateCharElementValue() {
ClassGen cg = createClassGen("HelloWorld");
- ConstantPool cp = cg.getConstantPool();
+ ConstantPoolGen cp = cg.getConstantPool();
SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.PRIMITIVE_CHAR,cp,(char)'t');
// Creation of an element like that should leave a new entry in the cpool
@@ -98,7 +98,7 @@ public class ElementValueGenTest extends BcelTestCase {
public void testCreateByteElementValue() {
ClassGen cg = createClassGen("HelloWorld");
- ConstantPool cp = cg.getConstantPool();
+ ConstantPoolGen cp = cg.getConstantPool();
SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.PRIMITIVE_CHAR,cp,(byte)'z');
// Creation of an element like that should leave a new entry in the cpool
@@ -110,7 +110,7 @@ public class ElementValueGenTest extends BcelTestCase {
public void testCreateBooleanElementValue() {
ClassGen cg = createClassGen("HelloWorld");
- ConstantPool cp = cg.getConstantPool();
+ ConstantPoolGen cp = cg.getConstantPool();
SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.PRIMITIVE_BOOLEAN,cp,true);
// Creation of an element like that should leave a new entry in the cpool
@@ -122,7 +122,7 @@ public class ElementValueGenTest extends BcelTestCase {
public void testCreateShortElementValue() {
ClassGen cg = createClassGen("HelloWorld");
- ConstantPool cp = cg.getConstantPool();
+ ConstantPoolGen cp = cg.getConstantPool();
SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.PRIMITIVE_SHORT,cp,(short)42);
// Creation of an element like that should leave a new entry in the cpool
@@ -139,7 +139,7 @@ public class ElementValueGenTest extends BcelTestCase {
// Create HelloWorld
ClassGen cg = createClassGen("HelloWorld");
- ConstantPool cp = cg.getConstantPool();
+ ConstantPoolGen cp = cg.getConstantPool();
SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.STRING,cp,"hello");
// Creation of an element like that should leave a new entry in the cpool
@@ -153,7 +153,7 @@ public class ElementValueGenTest extends BcelTestCase {
public void testCreateEnumElementValue() {
ClassGen cg = createClassGen("HelloWorld");
- ConstantPool cp = cg.getConstantPool();
+ ConstantPoolGen cp = cg.getConstantPool();
ObjectType enumType = new ObjectType("SimpleEnum"); // Supports rainbow :)
@@ -176,7 +176,7 @@ public class ElementValueGenTest extends BcelTestCase {
public void testCreateClassElementValue() {
ClassGen cg = createClassGen("HelloWorld");
- ConstantPool cp = cg.getConstantPool();
+ ConstantPoolGen cp = cg.getConstantPool();
ObjectType classType = new ObjectType("java.lang.Integer");
@@ -192,7 +192,7 @@ public class ElementValueGenTest extends BcelTestCase {
////
// Helper methods
- private void checkSerialize(ElementValueGen evgBefore,ConstantPool cpg) {
+ private void checkSerialize(ElementValueGen evgBefore,ConstantPoolGen cpg) {
try {
String beforeValue = evgBefore.stringifyValue();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/FieldAnnotationsTest.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/FieldAnnotationsTest.java
index 0bcf1ac81..b62e5d88f 100644
--- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/FieldAnnotationsTest.java
+++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/FieldAnnotationsTest.java
@@ -18,10 +18,11 @@ import java.util.Iterator;
import org.aspectj.apache.bcel.classfile.Field;
import org.aspectj.apache.bcel.classfile.JavaClass;
-import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen;
-import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePairGen;
+import org.aspectj.apache.bcel.classfile.annotation.Annotation;
+import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePair;
import org.aspectj.apache.bcel.generic.ClassGen;
import org.aspectj.apache.bcel.generic.FieldGen;
+import org.aspectj.apache.bcel.generic.annotation.AnnotationGen;
import org.aspectj.apache.bcel.util.SyntheticRepository;
@@ -104,7 +105,7 @@ public class FieldAnnotationsTest extends BcelTestCase {
for (int i = 0; i < fields.length; i++) {
Field f = fields[i];
- AnnotationGen[] fieldAnnotations = f.getAnnotations();
+ Annotation[] fieldAnnotations = f.getAnnotations();
if (f.getName().equals(fieldname)) {
checkAnnotation(fieldAnnotations[0],annotationName,annotationElementName,annotationElementValue);
@@ -112,11 +113,11 @@ public class FieldAnnotationsTest extends BcelTestCase {
}
}
- private void checkAnnotation(AnnotationGen a,String name,String elementname,String elementvalue) {
+ private void checkAnnotation(Annotation a,String name,String elementname,String elementvalue) {
assertTrue("Expected annotation to have name "+name+" but it had name "+a.getTypeName(),
a.getTypeName().equals(name));
assertTrue("Expected annotation to have one element but it had "+a.getValues().size(),a.getValues().size()==1);
- ElementNameValuePairGen envp = (ElementNameValuePairGen)a.getValues().get(0);
+ ElementNameValuePair envp = (ElementNameValuePair)a.getValues().get(0);
assertTrue("Expected element name "+elementname+" but was "+envp.getNameString(),
elementname.equals(envp.getNameString()));
assertTrue("Expected element value "+elementvalue+" but was "+envp.getValue().stringifyValue(),
@@ -126,9 +127,9 @@ public class FieldAnnotationsTest extends BcelTestCase {
// helper methods
- public void checkValue(AnnotationGen a,String name,String tostring) {
+ public void checkValue(Annotation a,String name,String tostring) {
for (Iterator i = a.getValues().iterator(); i.hasNext();) {
- ElementNameValuePairGen element = (ElementNameValuePairGen) i.next();
+ ElementNameValuePair element = (ElementNameValuePair) i.next();
if (element.getNameString().equals(name)) {
if (!element.getValue().stringifyValue().equals(tostring)) {
fail("Expected element "+name+" to have value "+tostring+" but it had value "+element.getValue().stringifyValue());
diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/GeneratingAnnotatedClassesTest.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/GeneratingAnnotatedClassesTest.java
index 6306c3edc..6c0258beb 100644
--- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/GeneratingAnnotatedClassesTest.java
+++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/GeneratingAnnotatedClassesTest.java
@@ -17,16 +17,15 @@ import java.util.List;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.classfile.Method;
+import org.aspectj.apache.bcel.classfile.annotation.Annotation;
+import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePair;
+import org.aspectj.apache.bcel.classfile.annotation.ElementValue;
+import org.aspectj.apache.bcel.generic.ALOAD;
+import org.aspectj.apache.bcel.generic.ASTORE;
import org.aspectj.apache.bcel.generic.ArrayType;
import org.aspectj.apache.bcel.generic.ClassGen;
-import org.aspectj.apache.bcel.classfile.ConstantPool;
-import org.aspectj.apache.bcel.classfile.annotation.AnnotationElementValueGen;
-import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen;
-import org.aspectj.apache.bcel.classfile.annotation.ArrayElementValueGen;
-import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePairGen;
-import org.aspectj.apache.bcel.classfile.annotation.ElementValueGen;
-import org.aspectj.apache.bcel.classfile.annotation.SimpleElementValueGen;
-import org.aspectj.apache.bcel.generic.InstructionBranch;
+import org.aspectj.apache.bcel.generic.ConstantPoolGen;
+import org.aspectj.apache.bcel.generic.GOTO;
import org.aspectj.apache.bcel.generic.InstructionConstants;
import org.aspectj.apache.bcel.generic.InstructionFactory;
import org.aspectj.apache.bcel.generic.InstructionHandle;
@@ -34,7 +33,14 @@ import org.aspectj.apache.bcel.generic.InstructionList;
import org.aspectj.apache.bcel.generic.LocalVariableGen;
import org.aspectj.apache.bcel.generic.MethodGen;
import org.aspectj.apache.bcel.generic.ObjectType;
+import org.aspectj.apache.bcel.generic.PUSH;
import org.aspectj.apache.bcel.generic.Type;
+import org.aspectj.apache.bcel.generic.annotation.AnnotationElementValueGen;
+import org.aspectj.apache.bcel.generic.annotation.AnnotationGen;
+import org.aspectj.apache.bcel.generic.annotation.ArrayElementValueGen;
+import org.aspectj.apache.bcel.generic.annotation.ElementNameValuePairGen;
+import org.aspectj.apache.bcel.generic.annotation.ElementValueGen;
+import org.aspectj.apache.bcel.generic.annotation.SimpleElementValueGen;
import org.aspectj.apache.bcel.util.SyntheticRepository;
/**
@@ -70,7 +76,7 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase {
// Create HelloWorld
ClassGen cg = createClassGen("HelloWorld");
- ConstantPool cp = cg.getConstantPool();
+ ConstantPoolGen cp = cg.getConstantPool();
InstructionList il = new InstructionList();
cg.addAnnotation(createSimpleVisibleAnnotation(cp));
@@ -82,21 +88,21 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase {
JavaClass jc = getClassFrom(".","HelloWorld");
- AnnotationGen[] as = jc.getAnnotations();
+ Annotation[] as = jc.getAnnotations();
assertTrue("Should be two annotations but found "+as.length,as.length==2);
- AnnotationGen one = as[0];
- AnnotationGen two = as[1];
+ Annotation one = as[0];
+ Annotation two = as[1];
assertTrue("Name of annotation 1 should be SimpleAnnotation but it is "+as[0].getTypeName(),
as[0].getTypeName().equals("SimpleAnnotation"));
assertTrue("Name of annotation 2 should be SimpleAnnotation but it is "+as[1].getTypeName(),
as[1].getTypeName().equals("SimpleAnnotation"));
List vals = as[0].getValues();
- ElementNameValuePairGen nvp = (ElementNameValuePairGen) vals.get(0);
+ ElementNameValuePair nvp = (ElementNameValuePair) vals.get(0);
assertTrue("Name of element in SimpleAnnotation should be 'id' but it is "+
nvp.getNameString(),nvp.getNameString().equals("id"));
- ElementValueGen ev = nvp.getValue();
+ ElementValue ev = nvp.getValue();
assertTrue("Type of element value should be int but it is "+ev.getElementValueType(),
- ev.getElementValueType()==ElementValueGen.PRIMITIVE_INT);
+ ev.getElementValueType()==ElementValue.PRIMITIVE_INT);
assertTrue("Value of element should be 4 but it is "+ev.stringifyValue(),
ev.stringifyValue().equals("4"));
assertTrue(createTestdataFile("HelloWorld.class").delete());
@@ -111,7 +117,7 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase {
public void testGenerateMethodLevelAnnotations1() throws ClassNotFoundException {
// Create HelloWorld
ClassGen cg = createClassGen("HelloWorld");
- ConstantPool cp = cg.getConstantPool();
+ ConstantPoolGen cp = cg.getConstantPool();
InstructionList il = new InstructionList();
buildClassContentsWithAnnotatedMethods(cg, cp, il);
@@ -152,7 +158,7 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase {
public void testGenerateMethodLevelAnnotations2() throws ClassNotFoundException {
// Create HelloWorld
ClassGen cg = createClassGen("HelloWorld");
- ConstantPool cp = cg.getConstantPool();
+ ConstantPoolGen cp = cg.getConstantPool();
InstructionList il = new InstructionList();
buildClassContentsWithAnnotatedMethods(cg, cp, il);
@@ -241,9 +247,9 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase {
ElementValueGen value = (ElementValueGen)nvp.getValue();
assertTrue("Value should be ArrayElementValueGen but is "+value,value instanceof ArrayElementValueGen);
ArrayElementValueGen arrayValue = (ArrayElementValueGen)value;
- assertTrue("Array value should be size one but is "+arrayValue.getElementValuesArraySize(),
- arrayValue.getElementValuesArraySize()==1);
- ElementValueGen innerValue = (ElementValueGen)arrayValue.getElementValuesArray()[0];
+ assertTrue("Array value should be size one but is "+arrayValue.getElementValuesSize(),
+ arrayValue.getElementValuesSize()==1);
+ ElementValueGen innerValue = (ElementValueGen)arrayValue.getElementValues().get(0);
assertTrue("Value in the array should be AnnotationElementValueGen but is "+innerValue,
innerValue instanceof AnnotationElementValueGen);
AnnotationElementValueGen innerAnnotationValue = (AnnotationElementValueGen)innerValue;
@@ -281,7 +287,7 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase {
public void testModifyingClasses1() throws ClassNotFoundException {
JavaClass jc = getClassFrom("testcode.jar","SimpleAnnotatedClass");
ClassGen cgen = new ClassGen(jc);
- ConstantPool cp = cgen.getConstantPool();
+ ConstantPoolGen cp = cgen.getConstantPool();
cgen.addAnnotation(createFruitAnnotation(cp,"Pineapple"));
assertTrue("Should now have two annotations but has "+cgen.getAnnotations().length,
cgen.getAnnotations().length==2);
@@ -295,7 +301,7 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase {
public void testModifyingClasses2() throws ClassNotFoundException {
JavaClass jc = getClassFrom("testcode.jar","SimpleAnnotatedClass");
ClassGen cgen = new ClassGen(jc);
- ConstantPool cp = cgen.getConstantPool();
+ ConstantPoolGen cp = cgen.getConstantPool();
cgen.addAnnotation(createCombinedAnnotation(cp));
assertTrue("Should now have two annotations but has "+cgen.getAnnotations().length,
cgen.getAnnotations().length==2);
@@ -321,7 +327,7 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase {
dumpClass(cg,dir+File.separator+fname);
}
- private void buildClassContentsWithAnnotatedMethods(ClassGen cg, ConstantPool cp, InstructionList il) {
+ private void buildClassContentsWithAnnotatedMethods(ClassGen cg, ConstantPoolGen cp, InstructionList il) {
// Create method 'public static void main(String[]argv)'
MethodGen mg = createMethodGen("main",il,cp);
InstructionFactory factory = new InstructionFactory(cg);
@@ -350,14 +356,14 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase {
LocalVariableGen lg = mg.addLocalVariable("in", new ObjectType(
"java.io.BufferedReader"), null, null);
int in = lg.getIndex();
- lg.setStart(il.append(InstructionFactory.createASTORE(in))); // "in" valid from here
+ lg.setStart(il.append(new ASTORE(in))); // "in" valid from here
// Create local variable name and initialize it to null
lg = mg.addLocalVariable("name", Type.STRING, null, null);
int name = lg.getIndex();
il.append(InstructionConstants.ACONST_NULL);
- lg.setStart(il.append(InstructionFactory.createASTORE(name))); // "name" valid from here
+ lg.setStart(il.append(new ASTORE(name))); // "name" valid from here
// Create try-catch block: We remember the start of the block, read a
// line from the standard input and store it into the variable name .
@@ -372,13 +378,13 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase {
// il.append(new ALOAD(in));
// il.append(factory.createInvoke("java.io.BufferedReader", "readLine",
// Type.STRING, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
- InstructionHandle try_start = il.append(InstructionFactory.PUSH(cp,"Andy"));
- il.append(InstructionFactory.createASTORE(name));
+ InstructionHandle try_start = il.append(new PUSH(cp,"Andy"));
+ il.append(new ASTORE(name));
// Upon normal execution we jump behind exception handler, the target
// address is not known yet.
- InstructionBranch g = new InstructionBranch(Constants.GOTO);
+ GOTO g = new GOTO(null);
InstructionHandle try_end = il.append(g);
// We add the exception handler which simply returns from the method.
@@ -386,7 +392,7 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase {
LocalVariableGen var_ex = mg.addLocalVariable("ex",Type.getType("Ljava.io.IOException;"),null,null);
int var_ex_slot = var_ex.getIndex();
- InstructionHandle handler = il.append(InstructionFactory.createASTORE(var_ex_slot));
+ InstructionHandle handler = il.append(new ASTORE(var_ex_slot));
var_ex.setStart(handler);
var_ex.setEnd(il.append(InstructionConstants.RETURN));
@@ -405,12 +411,12 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase {
il.append(factory.createNew(Type.STRINGBUFFER));
il.append(InstructionConstants.DUP);
- il.append(InstructionFactory.PUSH(cp, "Hello, "));
+ il.append(new PUSH(cp, "Hello, "));
il
.append(factory.createInvoke("java.lang.StringBuffer",
"<init>", Type.VOID, new Type[] { Type.STRING },
Constants.INVOKESPECIAL));
- il.append(InstructionFactory.createALOAD(name));
+ il.append(new ALOAD(name));
il.append(factory.createInvoke("java.lang.StringBuffer", "append",
Type.STRINGBUFFER, new Type[] { Type.STRING },
Constants.INVOKEVIRTUAL));
@@ -433,7 +439,7 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase {
cg.addEmptyConstructor(Constants.ACC_PUBLIC);
}
- private void buildClassContents(ClassGen cg, ConstantPool cp, InstructionList il) {
+ private void buildClassContents(ClassGen cg, ConstantPoolGen cp, InstructionList il) {
// Create method 'public static void main(String[]argv)'
MethodGen mg = createMethodGen("main",il,cp);
InstructionFactory factory = new InstructionFactory(cg);
@@ -461,14 +467,14 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase {
LocalVariableGen lg = mg.addLocalVariable("in", new ObjectType(
"java.io.BufferedReader"), null, null);
int in = lg.getIndex();
- lg.setStart(il.append(InstructionFactory.createASTORE(in))); // "in" valid from here
+ lg.setStart(il.append(new ASTORE(in))); // "in" valid from here
// Create local variable name and initialize it to null
lg = mg.addLocalVariable("name", Type.STRING, null, null);
int name = lg.getIndex();
il.append(InstructionConstants.ACONST_NULL);
- lg.setStart(il.append(InstructionFactory.createASTORE(name))); // "name" valid from here
+ lg.setStart(il.append(new ASTORE(name))); // "name" valid from here
// Create try-catch block: We remember the start of the block, read a
// line from the standard input and store it into the variable name .
@@ -483,13 +489,13 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase {
// il.append(new ALOAD(in));
// il.append(factory.createInvoke("java.io.BufferedReader", "readLine",
// Type.STRING, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
- InstructionHandle try_start = il.append(InstructionFactory.PUSH(cp,"Andy"));
- il.append(InstructionFactory.createASTORE(name));
+ InstructionHandle try_start = il.append(new PUSH(cp,"Andy"));
+ il.append(new ASTORE(name));
// Upon normal execution we jump behind exception handler, the target
// address is not known yet.
- InstructionBranch g = new InstructionBranch(Constants.GOTO);
+ GOTO g = new GOTO(null);
InstructionHandle try_end = il.append(g);
// We add the exception handler which simply returns from the method.
@@ -497,7 +503,7 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase {
LocalVariableGen var_ex = mg.addLocalVariable("ex",Type.getType("Ljava.io.IOException;"),null,null);
int var_ex_slot = var_ex.getIndex();
- InstructionHandle handler = il.append(InstructionFactory.createASTORE(var_ex_slot));
+ InstructionHandle handler = il.append(new ASTORE(var_ex_slot));
var_ex.setStart(handler);
var_ex.setEnd(il.append(InstructionConstants.RETURN));
@@ -516,12 +522,12 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase {
il.append(factory.createNew(Type.STRINGBUFFER));
il.append(InstructionConstants.DUP);
- il.append(InstructionFactory.PUSH(cp, "Hello, "));
+ il.append(new PUSH(cp, "Hello, "));
il
.append(factory.createInvoke("java.lang.StringBuffer",
"<init>", Type.VOID, new Type[] { Type.STRING },
Constants.INVOKESPECIAL));
- il.append(InstructionFactory.createALOAD(name));
+ il.append(new ALOAD(name));
il.append(factory.createInvoke("java.lang.StringBuffer", "append",
Type.STRINGBUFFER, new Type[] { Type.STRING },
Constants.INVOKEVIRTUAL));
@@ -560,7 +566,7 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase {
"<generated>", Constants.ACC_PUBLIC | Constants.ACC_SUPER, null);
}
- private MethodGen createMethodGen(String methodname,InstructionList il,ConstantPool cp) {
+ private MethodGen createMethodGen(String methodname,InstructionList il,ConstantPoolGen cp) {
return new MethodGen(
Constants.ACC_STATIC | Constants.ACC_PUBLIC, // access flags
Type.VOID, // return type
@@ -571,7 +577,7 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase {
}
- public AnnotationGen createSimpleVisibleAnnotation(ConstantPool cp) {
+ public AnnotationGen createSimpleVisibleAnnotation(ConstantPoolGen cp) {
SimpleElementValueGen evg = new SimpleElementValueGen(
ElementValueGen.PRIMITIVE_INT, cp, 4);
@@ -586,7 +592,7 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase {
return a;
}
- public AnnotationGen createFruitAnnotation(ConstantPool cp,String aFruit) {
+ public AnnotationGen createFruitAnnotation(ConstantPoolGen cp,String aFruit) {
SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.STRING,cp,aFruit);
ElementNameValuePairGen nvGen = new ElementNameValuePairGen("fruit",evg,cp);
ObjectType t = new ObjectType("SimpleStringAnnotation");
@@ -595,7 +601,7 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase {
return new AnnotationGen(t,elements,true,cp);
}
- public AnnotationGen createCombinedAnnotation(ConstantPool cp) {
+ public AnnotationGen createCombinedAnnotation(ConstantPoolGen cp) {
// Create an annotation instance
AnnotationGen a = createSimpleVisibleAnnotation(cp);
ArrayElementValueGen array = new ArrayElementValueGen(cp);
@@ -606,7 +612,7 @@ public class GeneratingAnnotatedClassesTest extends BcelTestCase {
return new AnnotationGen(new ObjectType("CombinedAnnotation"),elements,true,cp);
}
- public AnnotationGen createSimpleInvisibleAnnotation(ConstantPool cp) {
+ public AnnotationGen createSimpleInvisibleAnnotation(ConstantPoolGen cp) {
SimpleElementValueGen evg = new SimpleElementValueGen(
ElementValueGen.PRIMITIVE_INT, cp, 4);
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 005eb3f69..5b4bbbaa9 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
@@ -18,8 +18,8 @@ import java.util.Iterator;
import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.classfile.Method;
-import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen;
-import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePairGen;
+import org.aspectj.apache.bcel.classfile.annotation.Annotation;
+import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePair;
import org.aspectj.apache.bcel.util.SyntheticRepository;
@@ -65,7 +65,7 @@ public class MethodAnnotationsTest extends BcelTestCase {
for (int i = 0; i < methods.length; i++) {
Method m = methods[i];
- AnnotationGen[] methodAnnotations = m.getAnnotations();
+ Annotation[] methodAnnotations = m.getAnnotations();
if (m.getName().equals(methodname)) {
checkAnnotation(methodAnnotations[0],annotationName,annotationElementName,annotationElementValue);
@@ -73,11 +73,11 @@ public class MethodAnnotationsTest extends BcelTestCase {
}
}
- private void checkAnnotation(AnnotationGen a,String name,String elementname,String elementvalue) {
+ private void checkAnnotation(Annotation a,String name,String elementname,String elementvalue) {
assertTrue("Expected annotation to have name "+name+" but it had name "+a.getTypeName(),
a.getTypeName().equals(name));
assertTrue("Expected annotation to have one element but it had "+a.getValues().size(),a.getValues().size()==1);
- ElementNameValuePairGen envp = (ElementNameValuePairGen)a.getValues().get(0);
+ ElementNameValuePair envp = (ElementNameValuePair)a.getValues().get(0);
assertTrue("Expected element name "+elementname+" but was "+envp.getNameString(),
elementname.equals(envp.getNameString()));
assertTrue("Expected element value "+elementvalue+" but was "+envp.getValue().stringifyValue(),
@@ -87,9 +87,9 @@ public class MethodAnnotationsTest extends BcelTestCase {
// helper methods
- public void checkValue(AnnotationGen a,String name,String tostring) {
+ public void checkValue(Annotation a,String name,String tostring) {
for (Iterator i = a.getValues().iterator(); i.hasNext();) {
- ElementNameValuePairGen element = (ElementNameValuePairGen) i.next();
+ ElementNameValuePair element = (ElementNameValuePair) i.next();
if (element.getNameString().equals(name)) {
if (!element.getValue().stringifyValue().equals(tostring)) {
fail("Expected element "+name+" to have value "+tostring+" but it had value "+element.getValue().stringifyValue());
diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ParameterAnnotationsTest.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ParameterAnnotationsTest.java
index 5df4ea173..d0afaef41 100644
--- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ParameterAnnotationsTest.java
+++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ParameterAnnotationsTest.java
@@ -17,25 +17,28 @@ import org.aspectj.apache.bcel.Constants;
import org.aspectj.apache.bcel.classfile.Attribute;
import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.classfile.Method;
+import org.aspectj.apache.bcel.classfile.annotation.Annotation;
+import org.aspectj.apache.bcel.generic.ALOAD;
+import org.aspectj.apache.bcel.generic.ASTORE;
import org.aspectj.apache.bcel.generic.ArrayType;
import org.aspectj.apache.bcel.generic.ClassGen;
-import org.aspectj.apache.bcel.classfile.ConstantPool;
-import org.aspectj.apache.bcel.classfile.annotation.AnnotationElementValueGen;
-import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen;
-import org.aspectj.apache.bcel.classfile.annotation.ArrayElementValueGen;
-import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePairGen;
-import org.aspectj.apache.bcel.classfile.annotation.ElementValueGen;
-import org.aspectj.apache.bcel.classfile.annotation.SimpleElementValueGen;
-import org.aspectj.apache.bcel.generic.InstructionBranch;
+import org.aspectj.apache.bcel.generic.ConstantPoolGen;
+import org.aspectj.apache.bcel.generic.GOTO;
import org.aspectj.apache.bcel.generic.InstructionConstants;
import org.aspectj.apache.bcel.generic.InstructionFactory;
import org.aspectj.apache.bcel.generic.InstructionHandle;
-import org.aspectj.apache.bcel.generic.InstructionLV;
import org.aspectj.apache.bcel.generic.InstructionList;
import org.aspectj.apache.bcel.generic.LocalVariableGen;
import org.aspectj.apache.bcel.generic.MethodGen;
import org.aspectj.apache.bcel.generic.ObjectType;
+import org.aspectj.apache.bcel.generic.PUSH;
import org.aspectj.apache.bcel.generic.Type;
+import org.aspectj.apache.bcel.generic.annotation.AnnotationElementValueGen;
+import org.aspectj.apache.bcel.generic.annotation.AnnotationGen;
+import org.aspectj.apache.bcel.generic.annotation.ArrayElementValueGen;
+import org.aspectj.apache.bcel.generic.annotation.ElementNameValuePairGen;
+import org.aspectj.apache.bcel.generic.annotation.ElementValueGen;
+import org.aspectj.apache.bcel.generic.annotation.SimpleElementValueGen;
import org.aspectj.apache.bcel.util.SyntheticRepository;
/**
@@ -63,7 +66,7 @@ public class ParameterAnnotationsTest extends BcelTestCase {
*/
public void testParameterAnnotations_builtOK() {
ClassGen clg = createClassGen("HelloWorld");
- ConstantPool cpg = clg.getConstantPool();
+ ConstantPoolGen cpg = clg.getConstantPool();
InstructionList il = new InstructionList();
buildClassContentsWithAnnotatedMethods(clg,cpg,il,true);
@@ -72,7 +75,7 @@ public class ParameterAnnotationsTest extends BcelTestCase {
assertTrue("Class should have 2 methods but has "+i,i==2);
Method mainMethod = clg.getMethods()[0];
- AnnotationGen[] annos = mainMethod.getAnnotationsOnParameter(0);
+ Annotation[] annos = mainMethod.getAnnotationsOnParameter(0);
assertTrue("Should be two annotation on the 'argv' parameter to main() but there are "+annos.length,annos.length==2);
assertTrue("This annotation should contain the string 'fruit=Apples' but it is "+annos[0].toString(),
annos[0].toString().indexOf("fruit=Apples")!=-1);
@@ -87,7 +90,7 @@ public class ParameterAnnotationsTest extends BcelTestCase {
*/
public void testParameterAnnotations_savedAndLoadedOK() throws ClassNotFoundException {
ClassGen clg = createClassGen("HelloWorld");
- ConstantPool cpg = clg.getConstantPool();
+ ConstantPoolGen cpg = clg.getConstantPool();
InstructionList il = new InstructionList();
buildClassContentsWithAnnotatedMethods(clg,cpg,il,true);
@@ -102,7 +105,7 @@ public class ParameterAnnotationsTest extends BcelTestCase {
assertTrue("Class should have 2 methods but has "+i,i==2);
Method mainMethod = clg.getMethods()[0];
- AnnotationGen[] annos = mainMethod.getAnnotationsOnParameter(0);
+ Annotation[] annos = mainMethod.getAnnotationsOnParameter(0);
assertTrue("Should be two annotation on the 'argv' parameter to main() but there are "+annos.length,annos.length==2);
assertTrue("This annotation should contain the string 'fruit=Apples' but it is "+annos[0].toString(),
annos[0].toString().indexOf("fruit=Apples")!=-1);
@@ -121,7 +124,7 @@ public class ParameterAnnotationsTest extends BcelTestCase {
JavaClass jc = getClassFrom("testcode.jar","AnnotatedParameters");
ClassGen clg = new ClassGen(jc);
- ConstantPool cpg = clg.getConstantPool();
+ ConstantPoolGen cpg = clg.getConstantPool();
//
// Foo method looks like this:
@@ -168,8 +171,8 @@ public class ParameterAnnotationsTest extends BcelTestCase {
JavaClass jc2 = getClassFrom("temp2","AnnotatedParameters");
m = jc2.getMethods()[2];
- AnnotationGen[] p1annotations = m.getAnnotationsOnParameter(0);
- AnnotationGen[] p2annotations = m.getAnnotationsOnParameter(1);
+ Annotation[] p1annotations = m.getAnnotationsOnParameter(0);
+ Annotation[] p2annotations = m.getAnnotationsOnParameter(1);
assertTrue("Expected two annotations on the first parameter but found "+p1annotations.length,p1annotations.length==2);
assertTrue("Expected two annotations on the second parameter but found "+p2annotations.length,p2annotations.length==2);
@@ -190,7 +193,7 @@ public class ParameterAnnotationsTest extends BcelTestCase {
public void testParameterAnnotations_loadedThenModifiedWithInvisibleAnnotationThenSavedAndLoadedOK() throws ClassNotFoundException {
JavaClass jc = getClassFrom("testcode.jar","AnnotatedParameters");
ClassGen clg = new ClassGen(jc);
- ConstantPool cpg = clg.getConstantPool();
+ ConstantPoolGen cpg = clg.getConstantPool();
//
// Foo method looks like this:
@@ -239,8 +242,8 @@ public class ParameterAnnotationsTest extends BcelTestCase {
JavaClass jc2 = getClassFrom("temp3","AnnotatedParameters");
m = jc2.getMethods()[2];
- AnnotationGen[] p1annotations = m.getAnnotationsOnParameter(0);
- AnnotationGen[] p2annotations = m.getAnnotationsOnParameter(1);
+ Annotation[] p1annotations = m.getAnnotationsOnParameter(0);
+ Annotation[] p2annotations = m.getAnnotationsOnParameter(1);
assertTrue("Expected two annotations on the first parameter but found "+p1annotations.length,p1annotations.length==2);
assertTrue("Expected two annotations on the second parameter but found "+p2annotations.length,p2annotations.length==2);
@@ -291,7 +294,7 @@ public class ParameterAnnotationsTest extends BcelTestCase {
dumpClass(cg,dir+File.separator+fname);
}
- private void buildClassContentsWithAnnotatedMethods(ClassGen cg, ConstantPool cp, InstructionList il,boolean addParameterAnnotations) {
+ private void buildClassContentsWithAnnotatedMethods(ClassGen cg, ConstantPoolGen cp, InstructionList il,boolean addParameterAnnotations) {
// Create method 'public static void main(String[]argv)'
MethodGen mg = createMethodGen("main",il,cp);
InstructionFactory factory = new InstructionFactory(cg);
@@ -320,14 +323,14 @@ public class ParameterAnnotationsTest extends BcelTestCase {
LocalVariableGen lg = mg.addLocalVariable("in", new ObjectType(
"java.io.BufferedReader"), null, null);
int in = lg.getIndex();
- lg.setStart(il.append(InstructionFactory.createASTORE(in))); // "in" valid from here
+ lg.setStart(il.append(new ASTORE(in))); // "in" valid from here
// Create local variable name and initialize it to null
lg = mg.addLocalVariable("name", Type.STRING, null, null);
int name = lg.getIndex();
il.append(InstructionConstants.ACONST_NULL);
- lg.setStart(il.append(InstructionFactory.createASTORE(name))); // "name" valid from here
+ lg.setStart(il.append(new ASTORE(name))); // "name" valid from here
// Create try-catch block: We remember the start of the block, read a
// line from the standard input and store it into the variable name .
@@ -342,13 +345,13 @@ public class ParameterAnnotationsTest extends BcelTestCase {
// il.append(new ALOAD(in));
// il.append(factory.createInvoke("java.io.BufferedReader", "readLine",
// Type.STRING, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
- InstructionHandle try_start = il.append(InstructionFactory.PUSH(cp,"Andy"));
- il.append(InstructionFactory.createASTORE(name));
+ InstructionHandle try_start = il.append(new PUSH(cp,"Andy"));
+ il.append(new ASTORE(name));
// Upon normal execution we jump behind exception handler, the target
// address is not known yet.
- InstructionBranch g = new InstructionBranch(Constants.GOTO);
+ GOTO g = new GOTO(null);
InstructionHandle try_end = il.append(g);
// We add the exception handler which simply returns from the method.
@@ -356,7 +359,7 @@ public class ParameterAnnotationsTest extends BcelTestCase {
LocalVariableGen var_ex = mg.addLocalVariable("ex",Type.getType("Ljava.io.IOException;"),null,null);
int var_ex_slot = var_ex.getIndex();
- InstructionHandle handler = il.append(InstructionFactory.createASTORE(var_ex_slot));
+ InstructionHandle handler = il.append(new ASTORE(var_ex_slot));
var_ex.setStart(handler);
var_ex.setEnd(il.append(InstructionConstants.RETURN));
@@ -375,12 +378,12 @@ public class ParameterAnnotationsTest extends BcelTestCase {
il.append(factory.createNew(Type.STRINGBUFFER));
il.append(InstructionConstants.DUP);
- il.append(InstructionFactory.PUSH(cp, "Hello, "));
+ il.append(new PUSH(cp, "Hello, "));
il
.append(factory.createInvoke("java.lang.StringBuffer",
"<init>", Type.VOID, new Type[] { Type.STRING },
Constants.INVOKESPECIAL));
- il.append(new InstructionLV(Constants.ALOAD,name));
+ il.append(new ALOAD(name));
il.append(factory.createInvoke("java.lang.StringBuffer", "append",
Type.STRINGBUFFER, new Type[] { Type.STRING },
Constants.INVOKEVIRTUAL));
@@ -405,7 +408,7 @@ public class ParameterAnnotationsTest extends BcelTestCase {
cg.addEmptyConstructor(Constants.ACC_PUBLIC);
}
- private void buildClassContents(ClassGen cg, ConstantPool cp, InstructionList il) {
+ private void buildClassContents(ClassGen cg, ConstantPoolGen cp, InstructionList il) {
// Create method 'public static void main(String[]argv)'
MethodGen mg = createMethodGen("main",il,cp);
InstructionFactory factory = new InstructionFactory(cg);
@@ -433,14 +436,14 @@ public class ParameterAnnotationsTest extends BcelTestCase {
LocalVariableGen lg = mg.addLocalVariable("in", new ObjectType(
"java.io.BufferedReader"), null, null);
int in = lg.getIndex();
- lg.setStart(il.append(InstructionFactory.createASTORE(in))); // "in" valid from here
+ lg.setStart(il.append(new ASTORE(in))); // "in" valid from here
// Create local variable name and initialize it to null
lg = mg.addLocalVariable("name", Type.STRING, null, null);
int name = lg.getIndex();
il.append(InstructionConstants.ACONST_NULL);
- lg.setStart(il.append(InstructionFactory.createASTORE(name))); // "name" valid from here
+ lg.setStart(il.append(new ASTORE(name))); // "name" valid from here
// Create try-catch block: We remember the start of the block, read a
// line from the standard input and store it into the variable name .
@@ -455,13 +458,13 @@ public class ParameterAnnotationsTest extends BcelTestCase {
// il.append(new ALOAD(in));
// il.append(factory.createInvoke("java.io.BufferedReader", "readLine",
// Type.STRING, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
- InstructionHandle try_start = il.append(InstructionFactory.PUSH(cp,"Andy"));
- il.append(InstructionFactory.createASTORE(name));
+ InstructionHandle try_start = il.append(new PUSH(cp,"Andy"));
+ il.append(new ASTORE(name));
// Upon normal execution we jump behind exception handler, the target
// address is not known yet.
- InstructionBranch g = new InstructionBranch(Constants.GOTO);
+ GOTO g = new GOTO(null);
InstructionHandle try_end = il.append(g);
// We add the exception handler which simply returns from the method.
@@ -469,7 +472,7 @@ public class ParameterAnnotationsTest extends BcelTestCase {
LocalVariableGen var_ex = mg.addLocalVariable("ex",Type.getType("Ljava.io.IOException;"),null,null);
int var_ex_slot = var_ex.getIndex();
- InstructionHandle handler = il.append(InstructionFactory.createASTORE(var_ex_slot));
+ InstructionHandle handler = il.append(new ASTORE(var_ex_slot));
var_ex.setStart(handler);
var_ex.setEnd(il.append(InstructionConstants.RETURN));
@@ -488,12 +491,12 @@ public class ParameterAnnotationsTest extends BcelTestCase {
il.append(factory.createNew(Type.STRINGBUFFER));
il.append(InstructionConstants.DUP);
- il.append(InstructionFactory.PUSH(cp, "Hello, "));
+ il.append(new PUSH(cp, "Hello, "));
il
.append(factory.createInvoke("java.lang.StringBuffer",
"<init>", Type.VOID, new Type[] { Type.STRING },
Constants.INVOKESPECIAL));
- il.append(InstructionFactory.createALOAD(name));
+ il.append(new ALOAD(name));
il.append(factory.createInvoke("java.lang.StringBuffer", "append",
Type.STRINGBUFFER, new Type[] { Type.STRING },
Constants.INVOKEVIRTUAL));
@@ -532,7 +535,7 @@ public class ParameterAnnotationsTest extends BcelTestCase {
"<generated>", Constants.ACC_PUBLIC | Constants.ACC_SUPER, null);
}
- private MethodGen createMethodGen(String methodname,InstructionList il,ConstantPool cp) {
+ private MethodGen createMethodGen(String methodname,InstructionList il,ConstantPoolGen cp) {
return new MethodGen(
Constants.ACC_STATIC | Constants.ACC_PUBLIC, // access flags
Type.VOID, // return type
@@ -543,7 +546,7 @@ public class ParameterAnnotationsTest extends BcelTestCase {
}
- public AnnotationGen createSimpleVisibleAnnotation(ConstantPool cp) {
+ public AnnotationGen createSimpleVisibleAnnotation(ConstantPoolGen cp) {
SimpleElementValueGen evg = new SimpleElementValueGen(
ElementValueGen.PRIMITIVE_INT, cp, 4);
@@ -558,7 +561,7 @@ public class ParameterAnnotationsTest extends BcelTestCase {
return a;
}
- public AnnotationGen createCombinedAnnotation(ConstantPool cp) {
+ public AnnotationGen createCombinedAnnotation(ConstantPoolGen cp) {
// Create an annotation instance
AnnotationGen a = createSimpleVisibleAnnotation(cp);
ArrayElementValueGen array = new ArrayElementValueGen(cp);
@@ -569,7 +572,7 @@ public class ParameterAnnotationsTest extends BcelTestCase {
return new AnnotationGen(new ObjectType("CombinedAnnotation"),elements,true,cp);
}
- public AnnotationGen createSimpleInvisibleAnnotation(ConstantPool cp) {
+ public AnnotationGen createSimpleInvisibleAnnotation(ConstantPoolGen cp) {
SimpleElementValueGen evg = new SimpleElementValueGen(
ElementValueGen.PRIMITIVE_INT, cp, 4);
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 1872aed0f..4c8c463cb 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
@@ -21,16 +21,17 @@ import org.aspectj.apache.bcel.classfile.Attribute;
import org.aspectj.apache.bcel.classfile.ConstantPool;
import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.classfile.Utility;
-import org.aspectj.apache.bcel.classfile.annotation.AnnotationElementValueGen;
-import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen;
-import org.aspectj.apache.bcel.classfile.annotation.ArrayElementValueGen;
-import org.aspectj.apache.bcel.classfile.annotation.ClassElementValueGen;
-import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePairGen;
-import org.aspectj.apache.bcel.classfile.annotation.ElementValueGen;
-import org.aspectj.apache.bcel.classfile.annotation.EnumElementValueGen;
+import org.aspectj.apache.bcel.classfile.annotation.Annotation;
+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.ElementNameValuePair;
+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.classfile.annotation.SimpleElementValueGen;
import org.aspectj.apache.bcel.generic.ClassGen;
+import org.aspectj.apache.bcel.generic.annotation.AnnotationGen;
import org.aspectj.apache.bcel.util.SyntheticRepository;
@@ -59,17 +60,17 @@ public class RuntimeVisibleAnnotationAttributeTest extends BcelTestCase {
List anns = rva.getAnnotations();
assertTrue("Should be one annotation but found "+anns.size(),
anns.size()==1);
- AnnotationGen ann = (AnnotationGen) anns.get(0);
+ Annotation ann = (Annotation) anns.get(0);
assertTrue("Should be called 'SimpleAnnotation' but was called "+ann.getTypeName(),
ann.getTypeName().equals("SimpleAnnotation"));
List l = ann.getValues();
assertTrue("Should be one value for annotation 'SimpleAnnotation' but found "+l.size(),
l.size()==1);
- ElementNameValuePairGen envp = (ElementNameValuePairGen)l.get(0);
+ ElementNameValuePair envp = (ElementNameValuePair)l.get(0);
assertTrue("Name of element in SimpleAnnotation should be 'id' but it is "+envp.getNameString(),
envp.getNameString().equals("id"));
- SimpleElementValueGen evalue = (SimpleElementValueGen)envp.getValue();
- assertTrue("'id' should be of type int, but it is "+evalue.getElementValueType(),evalue.getElementValueType()==SimpleElementValueGen.PRIMITIVE_INT);
+ SimpleElementValue evalue = (SimpleElementValue)envp.getValue();
+ assertTrue("'id' should be of type int, but it is "+evalue.getElementValueType(),evalue.getElementValueType()==SimpleElementValue.PRIMITIVE_INT);
assertTrue("'id' should have value 4 but it is "+evalue.getValueInt(),
evalue.getValueInt()==4);
}
@@ -78,7 +79,7 @@ public class RuntimeVisibleAnnotationAttributeTest extends BcelTestCase {
SyntheticRepository repos = createRepos("testcode.jar");
JavaClass clazz = repos.loadClass("SimpleAnnotatedClass");
ConstantPool pool = clazz.getConstantPool();
- AnnotationGen[] anns = clazz.getAnnotations();
+ Annotation[] anns = clazz.getAnnotations();
assertTrue("Expected one annotation on SimpleAnnotatedClass class but got "+anns.length,
anns.length==1);
}
@@ -87,7 +88,7 @@ public class RuntimeVisibleAnnotationAttributeTest extends BcelTestCase {
SyntheticRepository repos = createRepos("testcode.jar");
JavaClass clazz = repos.loadClass("SimpleAnnotatedClass");
ConstantPool pool = clazz.getConstantPool();
- AnnotationGen[] anns = clazz.getAnnotations();
+ Annotation[] anns = clazz.getAnnotations();
assertTrue("Expected one annotation on SimpleAnnotatedClass class but got "+anns.length,
anns.length==1);
@@ -98,7 +99,7 @@ public class RuntimeVisibleAnnotationAttributeTest extends BcelTestCase {
SyntheticRepository repos2 = createRepos(".");
JavaClass clazz2 = repos.loadClass("SimpleAnnotatedClass");
ConstantPool pool2 = clazz2.getConstantPool();
- AnnotationGen[] anns2 = clazz2.getAnnotations();
+ Annotation[] anns2 = clazz2.getAnnotations();
assertTrue("Expected one annotation on SimpleAnnotatedClass class but got "+anns2.length,
anns2.length==1);
@@ -134,17 +135,17 @@ public class RuntimeVisibleAnnotationAttributeTest extends BcelTestCase {
}
private void verifyAnnotationStringElement(JavaClass clazz) {
- AnnotationGen[] anns = clazz.getAnnotations();
+ Annotation[] anns = clazz.getAnnotations();
assertTrue("should be one annotation but found "+anns.length,anns.length==1);
- AnnotationGen ann = anns[0];
+ Annotation ann = anns[0];
assertTrue("should be called 'AnnotationStringElement' but was called "+ann.getTypeName(),
ann.getTypeName().equals("AnnotationStringElement"));
List l = ann.getValues();
assertTrue("Should be one value but there were "+l.size(),l.size()==1);
- ElementNameValuePairGen nvp = (ElementNameValuePairGen)l.get(0);
+ ElementNameValuePair nvp = (ElementNameValuePair)l.get(0);
assertTrue("Name of element should be 'stringval' but was "+nvp.getNameString(),
nvp.getNameString().equals("stringval"));
- SimpleElementValueGen ev = (SimpleElementValueGen)nvp.getValue();
+ SimpleElementValue ev = (SimpleElementValue)nvp.getValue();
assertTrue("String value should be 'hello' but was '"+ev.getValueString()+"'",
ev.getValueString().equals("hello"));
}
@@ -177,9 +178,9 @@ public class RuntimeVisibleAnnotationAttributeTest extends BcelTestCase {
}
private void verifyComplexAnnotation(JavaClass clazz) {
- AnnotationGen[] anns = clazz.getAnnotations();
+ Annotation[] anns = clazz.getAnnotations();
assertTrue("Should be one annotation but found "+anns.length,anns.length==1);
- AnnotationGen ann = anns[0];
+ Annotation ann = anns[0];
assertTrue("Should be called 'ComplexAnnotation' but was called "+ann.getTypeName(),
ann.getTypeName().equals("ComplexAnnotation"));
List l = ann.getValues();
@@ -206,9 +207,9 @@ public class RuntimeVisibleAnnotationAttributeTest extends BcelTestCase {
}
- private void checkValue(AnnotationGen a,String name,String tostring) {
+ private void checkValue(Annotation a,String name,String tostring) {
for (Iterator i = a.getValues().iterator(); i.hasNext();) {
- ElementNameValuePairGen element = (ElementNameValuePairGen) i.next();
+ ElementNameValuePair element = (ElementNameValuePair) i.next();
if (element.getNameString().equals(name)) {
if (!element.getValue().stringifyValue().equals(tostring)) {
fail("Expected element "+name+" to have value "+tostring+" but it had value "+element.getValue().stringifyValue());
@@ -231,7 +232,7 @@ public class RuntimeVisibleAnnotationAttributeTest extends BcelTestCase {
public void testAnnotationClassElementCopying() throws ClassNotFoundException {
SyntheticRepository repos = createRepos("testcode.jar");
JavaClass clazz = repos.loadClass("AnnotatedWithClassClass");
- AnnotationGen[] anns = clazz.getAnnotations();
+ Annotation[] anns = clazz.getAnnotations();
ClassGen cg = new ClassGen(clazz);
// Checks we can copy class values in an annotation
new AnnotationGen(anns[0],cg.getConstantPool(),true);
@@ -255,17 +256,17 @@ public class RuntimeVisibleAnnotationAttributeTest extends BcelTestCase {
}
private void verifyClassAnnotation(JavaClass clazz) {
- AnnotationGen[] anns = clazz.getAnnotations();
+ Annotation[] anns = clazz.getAnnotations();
assertTrue("should be one annotation but found "+anns.length,anns.length==1);
- AnnotationGen ann = anns[0];
+ Annotation ann = anns[0];
assertTrue("should be called 'AnnotationClassElement' but was called "+ann.getTypeName(),
ann.getTypeName().equals("AnnotationClassElement"));
List l = ann.getValues();
assertTrue("Should be one value but there were "+l.size(),l.size()==1);
- ElementNameValuePairGen nvp = (ElementNameValuePairGen)l.get(0);
+ ElementNameValuePair nvp = (ElementNameValuePair)l.get(0);
assertTrue("Name of element should be 'clz' but was "+nvp.getNameString(),
nvp.getNameString().equals("clz"));
- ClassElementValueGen ev = (ClassElementValueGen)nvp.getValue();
+ ClassElementValue ev = (ClassElementValue)nvp.getValue();
assertTrue("String value should be 'Ljava/lang/Integer;' but was '"+ev.getClassString()+"'",
ev.getClassString().equals("Ljava/lang/Integer;"));
@@ -297,20 +298,20 @@ public class RuntimeVisibleAnnotationAttributeTest extends BcelTestCase {
}
public void verifyAnnotationEnumElement(JavaClass clazz) {
- AnnotationGen[] anns = clazz.getAnnotations();
+ Annotation[] anns = clazz.getAnnotations();
assertTrue("should be one annotation but found "+anns.length,anns.length==1);
- AnnotationGen ann = anns[0];
+ Annotation ann = anns[0];
assertTrue("should be called 'AnnotationEnumElement' but was called "+ann.getTypeName(),
ann.getTypeName().equals("AnnotationEnumElement"));
List l = ann.getValues();
assertTrue("Should be one value but there were "+l.size(),l.size()==1);
- ElementNameValuePairGen nvp = (ElementNameValuePairGen)l.get(0);
+ ElementNameValuePair nvp = (ElementNameValuePair)l.get(0);
assertTrue("Name of element should be 'enumval' but was "+nvp.getNameString(),
nvp.getNameString().equals("enumval"));
- ElementValueGen ev = nvp.getValue();
- assertTrue("Should be of type EnumElementValue but is "+ev,ev instanceof EnumElementValueGen);
- EnumElementValueGen eev = (EnumElementValueGen)ev;
- assertTrue("Should be an enum type value but is "+eev.getElementValueType(),eev.getElementValueType()==SimpleElementValueGen.ENUM_CONSTANT);
+ ElementValue ev = nvp.getValue();
+ assertTrue("Should be of type EnumElementValue but is "+ev,ev instanceof EnumElementValue);
+ EnumElementValue eev = (EnumElementValue)ev;
+ assertTrue("Should be an enum type value but is "+eev.getElementValueType(),eev.getElementValueType()==SimpleElementValue.ENUM_CONSTANT);
assertTrue("Enum type for annotation should be 'SimpleEnum' but is "+Utility.signatureToString(eev.getEnumTypeString()),Utility.signatureToString(eev.getEnumTypeString()).equals("SimpleEnum"));
assertTrue("String value should be 'Red' but was '"+eev.getEnumValueString()+"'",
eev.getEnumValueString().equals("Red"));
@@ -322,7 +323,7 @@ public class RuntimeVisibleAnnotationAttributeTest extends BcelTestCase {
public void testAnnotationArraysOfAnnotations() throws ClassNotFoundException {
SyntheticRepository repos = createRepos("testcode.jar");
JavaClass clazz = repos.loadClass("AnnotatedWithCombinedAnnotation");
- AnnotationGen[] anns = clazz.getAnnotations();
+ Annotation[] anns = clazz.getAnnotations();
assertTrue("should be one annotation but found "+anns.length,anns.length==1);
checkCombinedAnnotation(anns[0]);
}
@@ -330,7 +331,7 @@ public class RuntimeVisibleAnnotationAttributeTest extends BcelTestCase {
public void testAnnotationArraysOfAnnotationsReadWrite() throws ClassNotFoundException, IOException {
SyntheticRepository repos = createRepos("testcode.jar");
JavaClass clazz = repos.loadClass("AnnotatedWithCombinedAnnotation");
- AnnotationGen[] anns = clazz.getAnnotations();
+ Annotation[] anns = clazz.getAnnotations();
assertTrue("should be one annotation but found "+anns.length,anns.length==1);
checkCombinedAnnotation(anns[0]);
@@ -340,7 +341,7 @@ public class RuntimeVisibleAnnotationAttributeTest extends BcelTestCase {
SyntheticRepository repos2 = createRepos(".");
JavaClass clazz2 = repos2.loadClass("AnnotatedWithCombinedAnnotation");
- AnnotationGen[] anns2 = clazz2.getAnnotations();
+ Annotation[] anns2 = clazz2.getAnnotations();
assertTrue("should be one annotation but found "+anns2.length,anns2.length==1);
checkCombinedAnnotation(anns2[0]);
@@ -348,29 +349,29 @@ public class RuntimeVisibleAnnotationAttributeTest extends BcelTestCase {
}
- private void checkCombinedAnnotation(AnnotationGen ann) {
+ private void checkCombinedAnnotation(Annotation ann) {
assertTrue("should be called 'CombinedAnnotation' but was called "+ann.getTypeName(),
ann.getTypeName().equals("CombinedAnnotation"));
List l = ann.getValues();
assertTrue("Should be one value but there were "+l.size(),l.size()==1);
- ElementNameValuePairGen nvp = (ElementNameValuePairGen)l.get(0);
+ ElementNameValuePair nvp = (ElementNameValuePair)l.get(0);
assertTrue("Name of element should be 'value' but was "+nvp.getNameString(),
nvp.getNameString().equals("value"));
- ElementValueGen ev = nvp.getValue();
- assertTrue("Should be of type ArrayElementValue but is "+ev,ev instanceof ArrayElementValueGen);
- ArrayElementValueGen aev = (ArrayElementValueGen)ev;
+ ElementValue ev = nvp.getValue();
+ assertTrue("Should be of type ArrayElementValue but is "+ev,ev instanceof ArrayElementValue);
+ ArrayElementValue aev = (ArrayElementValue)ev;
assertTrue("Array element value should be of size 1 but is "+aev.getElementValuesArraySize(),
aev.getElementValuesArraySize()==1);
- ElementValueGen[] evs = aev.getElementValuesArray();
+ ElementValue[] evs = aev.getElementValuesArray();
assertTrue("Entry in the array should be AnnotationElementValue but is "+evs[0],
- evs[0] instanceof AnnotationElementValueGen);
- AnnotationElementValueGen inner_ev = (AnnotationElementValueGen)evs[0];
- AnnotationGen a = inner_ev.getAnnotation();
+ evs[0] instanceof AnnotationElementValue);
+ AnnotationElementValue inner_ev = (AnnotationElementValue)evs[0];
+ Annotation a = inner_ev.getAnnotation();
assertTrue("Should be SimpleAnnotation but is "+a.getTypeName(),a.getTypeName().equals("SimpleAnnotation"));
List envps = a.getValues();
assertTrue("Should be one name value pair but found "+envps.size(),envps.size()==1);
- ElementNameValuePairGen envp = (ElementNameValuePairGen) envps.get(0);
+ ElementNameValuePair envp = (ElementNameValuePair) envps.get(0);
assertTrue("Name should be 'id' but it is "+envp.getNameString(),envp.getNameString().equals("id"));
assertTrue("Value of 'id' should be 4 but it is "+envp.getValue().stringifyValue(),
envp.getValue().stringifyValue().equals("4"));
diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleParameterAnnotationAttributeTest.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleParameterAnnotationAttributeTest.java
index 90cf709aa..fad1dad2c 100644
--- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleParameterAnnotationAttributeTest.java
+++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleParameterAnnotationAttributeTest.java
@@ -19,8 +19,8 @@ import java.util.Iterator;
import org.aspectj.apache.bcel.classfile.Attribute;
import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.classfile.Method;
-import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen;
-import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePairGen;
+import org.aspectj.apache.bcel.classfile.annotation.Annotation;
+import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePair;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleParameterAnnotations;
import org.aspectj.apache.bcel.util.SyntheticRepository;
@@ -46,10 +46,10 @@ public class RuntimeVisibleParameterAnnotationAttributeTest extends BcelTestCase
assertTrue("foo takes two parameters, not "+paramAnns.getParameterAnnotations().size(),
paramAnns.getParameterAnnotations().size()==2);
- AnnotationGen[] firstParamAnnotations = paramAnns.getAnnotationsOnParameter(0);
+ Annotation[] firstParamAnnotations = paramAnns.getAnnotationsOnParameter(0);
checkAnnotation(firstParamAnnotations[0],"SimpleAnnotation","id","2");
- AnnotationGen[] secondParamAnnotations = paramAnns.getAnnotationsOnParameter(1);
+ Annotation[] secondParamAnnotations = paramAnns.getAnnotationsOnParameter(1);
checkAnnotation(secondParamAnnotations[0],"SimpleAnnotation","id","3");
checkAnnotation(secondParamAnnotations[1],"AnnotationEnumElement","enumval","Red");
@@ -60,7 +60,7 @@ public class RuntimeVisibleParameterAnnotationAttributeTest extends BcelTestCase
assertTrue("main takes one parameter, not "+paramAnns.getParameterAnnotations().size(),
paramAnns.getParameterAnnotations().size()==1);
- AnnotationGen[] firstParamAnnotations = paramAnns.getAnnotationsOnParameter(0);
+ Annotation[] firstParamAnnotations = paramAnns.getAnnotationsOnParameter(0);
checkAnnotation(firstParamAnnotations[0],"SimpleAnnotation","id","1");
}
}
@@ -98,10 +98,10 @@ public class RuntimeVisibleParameterAnnotationAttributeTest extends BcelTestCase
Method m = methods[i];
if (m.getName().equals("foo")) {
- AnnotationGen[] firstParamAnnotations = m.getAnnotationsOnParameter(0);
+ Annotation[] firstParamAnnotations = m.getAnnotationsOnParameter(0);
checkAnnotation(firstParamAnnotations[0],"SimpleAnnotation","id","2");
- AnnotationGen[] secondParamAnnotations = m.getAnnotationsOnParameter(1);
+ Annotation[] secondParamAnnotations = m.getAnnotationsOnParameter(1);
checkAnnotation(secondParamAnnotations[0],"SimpleAnnotation","id","3");
checkAnnotation(secondParamAnnotations[1],"AnnotationEnumElement","enumval","Red");
@@ -109,11 +109,11 @@ public class RuntimeVisibleParameterAnnotationAttributeTest extends BcelTestCase
}
}
- private void checkAnnotation(AnnotationGen a,String name,String elementname,String elementvalue) {
+ private void checkAnnotation(Annotation a,String name,String elementname,String elementvalue) {
assertTrue("Expected annotation to have name "+name+" but it had name "+a.getTypeName(),
a.getTypeName().equals(name));
assertTrue("Expected annotation to have one element but it had "+a.getValues().size(),a.getValues().size()==1);
- ElementNameValuePairGen envp = (ElementNameValuePairGen)a.getValues().get(0);
+ ElementNameValuePair envp = (ElementNameValuePair)a.getValues().get(0);
assertTrue("Expected element name "+elementname+" but was "+envp.getNameString(),
elementname.equals(envp.getNameString()));
assertTrue("Expected element value "+elementvalue+" but was "+envp.getValue().stringifyValue(),
@@ -123,9 +123,9 @@ public class RuntimeVisibleParameterAnnotationAttributeTest extends BcelTestCase
// helper methods
- public void checkValue(AnnotationGen a,String name,String tostring) {
+ public void checkValue(Annotation a,String name,String tostring) {
for (Iterator i = a.getValues().iterator(); i.hasNext();) {
- ElementNameValuePairGen element = (ElementNameValuePairGen) i.next();
+ ElementNameValuePair element = (ElementNameValuePair) i.next();
if (element.getNameString().equals(name)) {
if (!element.getValue().stringifyValue().equals(tostring)) {
fail("Expected element "+name+" to have value "+tostring+" but it had value "+element.getValue().stringifyValue());
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
index dcb36432f..5b2e17af8 100644
--- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/TypeAnnotationsTest.java
+++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/TypeAnnotationsTest.java
@@ -13,8 +13,8 @@
package org.aspectj.apache.bcel.classfile.tests;
import org.aspectj.apache.bcel.classfile.JavaClass;
-import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen;
import org.aspectj.apache.bcel.generic.ClassGen;
+import org.aspectj.apache.bcel.generic.annotation.AnnotationGen;
public class TypeAnnotationsTest extends BcelTestCase {
diff --git a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/VarargsTest.java b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/VarargsTest.java
index a6f8e8021..52590bf71 100644
--- a/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/VarargsTest.java
+++ b/bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/VarargsTest.java
@@ -18,8 +18,8 @@ import java.util.Iterator;
import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.classfile.Method;
-import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen;
-import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePairGen;
+import org.aspectj.apache.bcel.classfile.annotation.Annotation;
+import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePair;
import org.aspectj.apache.bcel.util.SyntheticRepository;
@@ -77,9 +77,9 @@ public class VarargsTest extends BcelTestCase {
// helper methods
- public void checkValue(AnnotationGen a,String name,String tostring) {
+ public void checkValue(Annotation a,String name,String tostring) {
for (Iterator i = a.getValues().iterator(); i.hasNext();) {
- ElementNameValuePairGen element = (ElementNameValuePairGen) i.next();
+ ElementNameValuePair element = (ElementNameValuePair) i.next();
if (element.getNameString().equals(name)) {
if (!element.getValue().stringifyValue().equals(tostring)) {
fail("Expected element "+name+" to have value "+tostring+" but it had value "+element.getValue().stringifyValue());