Browse Source

refactoring

tags/V1_6_6
aclement 14 years ago
parent
commit
a8aa0b1673

+ 1
- 0
bcel-builder/.isJava5 View File


+ 4
- 4
bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AnnotationDefaultAttributeTest.java View File

import org.aspectj.apache.bcel.classfile.AnnotationDefault; import org.aspectj.apache.bcel.classfile.AnnotationDefault;
import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.classfile.Method; 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 { public class AnnotationDefaultAttributeTest extends BcelTestCase {


Method m = getMethod(clazz,"fruit"); Method m = getMethod(clazz,"fruit");
AnnotationDefault a = (AnnotationDefault) findAttribute("AnnotationDefault",m.getAttributes()); 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(), 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(), assertTrue("Should have default of bananas but default is "+val.getValueString(),
val.getValueString().equals("bananas")); val.getValueString().equals("bananas"));
} }

+ 22
- 22
bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/AnnotationGenTest.java View File

import org.aspectj.apache.bcel.classfile.ConstantPool; import org.aspectj.apache.bcel.classfile.ConstantPool;
import org.aspectj.apache.bcel.classfile.Utility; import org.aspectj.apache.bcel.classfile.Utility;
import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; 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.RuntimeAnnotations;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisibleAnnotations;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleAnnotations;
import org.aspectj.apache.bcel.classfile.annotation.SimpleElementValueGen;
import org.aspectj.apache.bcel.classfile.annotation.NameValuePair;
import org.aspectj.apache.bcel.classfile.annotation.ElementValue;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeAnnos;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisAnnos;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisAnnos;
import org.aspectj.apache.bcel.classfile.annotation.SimpleElementValue;
import org.aspectj.apache.bcel.generic.ClassGen; import org.aspectj.apache.bcel.generic.ClassGen;
import org.aspectj.apache.bcel.generic.ObjectType; import org.aspectj.apache.bcel.generic.ObjectType;


ConstantPool cp = cg.getConstantPool(); ConstantPool cp = cg.getConstantPool();


// Create the simple primitive value '4' of type 'int' // Create the simple primitive value '4' of type 'int'
SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.PRIMITIVE_INT, cp, 4);
SimpleElementValue evg = new SimpleElementValue(ElementValue.PRIMITIVE_INT, cp, 4);


// Give it a name, call it 'id' // Give it a name, call it 'id'
ElementNameValuePairGen nvGen = new ElementNameValuePairGen("id", evg, cp);
NameValuePair nvGen = new NameValuePair("id", evg, cp);


// Check it looks right // Check it looks right
assertTrue("Should include string 'id=4' but says: " + nvGen.toString(), nvGen.toString().indexOf("id=4") != -1); assertTrue("Should include string 'id=4' but says: " + nvGen.toString(), nvGen.toString().indexOf("id=4") != -1);


ObjectType t = new ObjectType("SimpleAnnotation"); ObjectType t = new ObjectType("SimpleAnnotation");


List<ElementNameValuePairGen> elements = new ArrayList<ElementNameValuePairGen>();
List<NameValuePair> elements = new ArrayList<NameValuePair>();
elements.add(nvGen); elements.add(nvGen);


// Build an annotation of type 'SimpleAnnotation' with 'id=4' as the only value :) // Build an annotation of type 'SimpleAnnotation' with 'id=4' as the only value :)
ConstantPool cp = cg.getConstantPool(); ConstantPool cp = cg.getConstantPool();


// Create the simple primitive value '4' of type 'int' // Create the simple primitive value '4' of type 'int'
SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.PRIMITIVE_INT, cp, 4);
SimpleElementValue evg = new SimpleElementValue(ElementValue.PRIMITIVE_INT, cp, 4);


// Give it a name, call it 'id' // Give it a name, call it 'id'
ElementNameValuePairGen nvGen = new ElementNameValuePairGen("id", evg, cp);
NameValuePair nvGen = new NameValuePair("id", evg, cp);


// Check it looks right // Check it looks right
assertTrue("Should include string 'id=4' but says: " + nvGen.toString(), nvGen.toString().indexOf("id=4") != -1); assertTrue("Should include string 'id=4' but says: " + nvGen.toString(), nvGen.toString().indexOf("id=4") != -1);


ObjectType t = new ObjectType("SimpleAnnotation"); ObjectType t = new ObjectType("SimpleAnnotation");


List<ElementNameValuePairGen> elements = new ArrayList<ElementNameValuePairGen>();
List<NameValuePair> elements = new ArrayList<NameValuePair>();
elements.add(nvGen); elements.add(nvGen);


// Build a RV annotation of type 'SimpleAnnotation' with 'id=4' as the only value :) // Build a RV annotation of type 'SimpleAnnotation' with 'id=4' as the only value :)


Vector<AnnotationGen> v = new Vector<AnnotationGen>(); Vector<AnnotationGen> v = new Vector<AnnotationGen>();
v.add(a); v.add(a);
Collection<RuntimeAnnotations> attributes = Utility.getAnnotationAttributes(cp, v);
Collection<RuntimeAnnos> attributes = Utility.getAnnotationAttributes(cp, v);
boolean foundRV = false; boolean foundRV = false;
for (Attribute attribute : attributes) { for (Attribute attribute : attributes) {
if (attribute instanceof RuntimeVisibleAnnotations) {
assertTrue(((RuntimeAnnotations) attribute).areVisible());
if (attribute instanceof RuntimeVisAnnos) {
assertTrue(((RuntimeAnnos) attribute).areVisible());
foundRV = true; foundRV = true;


} }


Vector<AnnotationGen> v2 = new Vector<AnnotationGen>(); Vector<AnnotationGen> v2 = new Vector<AnnotationGen>();
v2.add(a2); v2.add(a2);
Collection<RuntimeAnnotations> attributes2 = Utility.getAnnotationAttributes(cp, v2);
Collection<RuntimeAnnos> attributes2 = Utility.getAnnotationAttributes(cp, v2);
boolean foundRIV = false; boolean foundRIV = false;
for (Attribute attribute : attributes2) { for (Attribute attribute : attributes2) {
// for (int i = 0; i < attributes2.length; i++) { // for (int i = 0; i < attributes2.length; i++) {
// Attribute attribute = attributes2[i]; // Attribute attribute = attributes2[i];
if (attribute instanceof RuntimeInvisibleAnnotations) {
assertFalse(((RuntimeAnnotations) attribute).areVisible());
if (attribute instanceof RuntimeInvisAnnos) {
assertFalse(((RuntimeAnnos) attribute).areVisible());
foundRIV = true; foundRIV = true;
} }
} }
private void checkSerialize(AnnotationGen a, ConstantPool cpg) { private void checkSerialize(AnnotationGen a, ConstantPool cpg) {
try { try {
String beforeName = a.getTypeName(); String beforeName = a.getTypeName();
List<ElementNameValuePairGen> beforeValues = a.getValues();
List<NameValuePair> beforeValues = a.getValues();
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos); DataOutputStream dos = new DataOutputStream(baos);
a.dump(dos); a.dump(dos);
dis.close(); dis.close();


String afterName = annAfter.getTypeName(); String afterName = annAfter.getTypeName();
List<ElementNameValuePairGen> afterValues = annAfter.getValues();
List<NameValuePair> afterValues = annAfter.getValues();


if (!beforeName.equals(afterName)) { if (!beforeName.equals(afterName)) {
fail("Deserialization failed: before type='" + beforeName + "' after type='" + afterName + "'"); fail("Deserialization failed: before type='" + beforeName + "' after type='" + afterName + "'");
fail("Different numbers of element name value pairs?? " + a.getValues().size() + "!=" + annAfter.getValues().size()); fail("Different numbers of element name value pairs?? " + a.getValues().size() + "!=" + annAfter.getValues().size());
} }
for (int i = 0; i < a.getValues().size(); i++) { for (int i = 0; i < a.getValues().size(); i++) {
ElementNameValuePairGen beforeElement = a.getValues().get(i);
ElementNameValuePairGen afterElement = annAfter.getValues().get(i);
NameValuePair beforeElement = a.getValues().get(i);
NameValuePair afterElement = annAfter.getValues().get(i);
if (!beforeElement.getNameString().equals(afterElement.getNameString())) { if (!beforeElement.getNameString().equals(afterElement.getNameString())) {
fail("Different names?? " + beforeElement.getNameString() + "!=" + afterElement.getNameString()); fail("Different names?? " + beforeElement.getNameString() + "!=" + afterElement.getNameString());
} }

+ 6
- 6
bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/BcelTestCase.java View File

import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.classfile.Method; import org.aspectj.apache.bcel.classfile.Method;
import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; 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.NameValuePair;
import org.aspectj.apache.bcel.classfile.annotation.ElementValue;
import org.aspectj.apache.bcel.classfile.annotation.SimpleElementValue;
import org.aspectj.apache.bcel.generic.ObjectType; import org.aspectj.apache.bcel.generic.ObjectType;
import org.aspectj.apache.bcel.util.ClassPath; import org.aspectj.apache.bcel.util.ClassPath;
import org.aspectj.apache.bcel.util.SyntheticRepository; import org.aspectj.apache.bcel.util.SyntheticRepository;
} }


public AnnotationGen createFruitAnnotation(ConstantPool cp, String aFruit, boolean visibility) { public AnnotationGen createFruitAnnotation(ConstantPool cp, String aFruit, boolean visibility) {
SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.STRING, cp, aFruit);
ElementNameValuePairGen nvGen = new ElementNameValuePairGen("fruit", evg, cp);
SimpleElementValue evg = new SimpleElementValue(ElementValue.STRING, cp, aFruit);
NameValuePair nvGen = new NameValuePair("fruit", evg, cp);
ObjectType t = new ObjectType("SimpleStringAnnotation"); ObjectType t = new ObjectType("SimpleStringAnnotation");
List<ElementNameValuePairGen> elements = new ArrayList<ElementNameValuePairGen>();
List<NameValuePair> elements = new ArrayList<NameValuePair>();
elements.add(nvGen); elements.add(nvGen);
return new AnnotationGen(t, elements, visibility, cp); return new AnnotationGen(t, elements, visibility, cp);
} }

+ 17
- 17
bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ElementValueGenTest.java View File

import org.aspectj.apache.bcel.Constants; import org.aspectj.apache.bcel.Constants;
import org.aspectj.apache.bcel.generic.ClassGen; import org.aspectj.apache.bcel.generic.ClassGen;
import org.aspectj.apache.bcel.classfile.ConstantPool; 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.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;
import org.aspectj.apache.bcel.generic.ObjectType; import org.aspectj.apache.bcel.generic.ObjectType;


public class ElementValueGenTest extends BcelTestCase { public class ElementValueGenTest extends BcelTestCase {
ClassGen cg = createClassGen("HelloWorld"); ClassGen cg = createClassGen("HelloWorld");
ConstantPool cp = cg.getConstantPool(); ConstantPool cp = cg.getConstantPool();
SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.PRIMITIVE_INT,cp,555);
SimpleElementValue evg = new SimpleElementValue(ElementValue.PRIMITIVE_INT,cp,555);
// Creation of an element like that should leave a new entry in the cpool // Creation of an element like that should leave a new entry in the cpool
assertTrue("Should have the same index in the constantpool but "+evg.getIndex()+"!="+cp.lookupInteger(555), assertTrue("Should have the same index in the constantpool but "+evg.getIndex()+"!="+cp.lookupInteger(555),
evg.getIndex()==cp.lookupInteger(555)); evg.getIndex()==cp.lookupInteger(555));
ClassGen cg = createClassGen("HelloWorld"); ClassGen cg = createClassGen("HelloWorld");
ConstantPool cp = cg.getConstantPool(); ConstantPool cp = cg.getConstantPool();
SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.PRIMITIVE_FLOAT,cp,111.222f);
SimpleElementValue evg = new SimpleElementValue(ElementValue.PRIMITIVE_FLOAT,cp,111.222f);
// Creation of an element like that should leave a new entry in the cpool // Creation of an element like that should leave a new entry in the cpool
assertTrue("Should have the same index in the constantpool but "+evg.getIndex()+"!="+cp.lookupFloat(111.222f), assertTrue("Should have the same index in the constantpool but "+evg.getIndex()+"!="+cp.lookupFloat(111.222f),
evg.getIndex()==cp.lookupFloat(111.222f)); evg.getIndex()==cp.lookupFloat(111.222f));
ClassGen cg = createClassGen("HelloWorld"); ClassGen cg = createClassGen("HelloWorld");
ConstantPool cp = cg.getConstantPool(); ConstantPool cp = cg.getConstantPool();
SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.PRIMITIVE_DOUBLE,cp,333.44);
SimpleElementValue evg = new SimpleElementValue(ElementValue.PRIMITIVE_DOUBLE,cp,333.44);
// Creation of an element like that should leave a new entry in the cpool // Creation of an element like that should leave a new entry in the cpool
int idx = cp.lookupDouble(333.44); int idx = cp.lookupDouble(333.44);
assertTrue("Should have the same index in the constantpool but "+evg.getIndex()+"!="+idx, assertTrue("Should have the same index in the constantpool but "+evg.getIndex()+"!="+idx,
ClassGen cg = createClassGen("HelloWorld"); ClassGen cg = createClassGen("HelloWorld");
ConstantPool cp = cg.getConstantPool(); ConstantPool cp = cg.getConstantPool();
SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.PRIMITIVE_LONG,cp,3334455L);
SimpleElementValue evg = new SimpleElementValue(ElementValue.PRIMITIVE_LONG,cp,3334455L);
// Creation of an element like that should leave a new entry in the cpool // Creation of an element like that should leave a new entry in the cpool
int idx = cp.lookupLong(3334455L); int idx = cp.lookupLong(3334455L);
assertTrue("Should have the same index in the constantpool but "+evg.getIndex()+"!="+idx, assertTrue("Should have the same index in the constantpool but "+evg.getIndex()+"!="+idx,
ClassGen cg = createClassGen("HelloWorld"); ClassGen cg = createClassGen("HelloWorld");
ConstantPool cp = cg.getConstantPool(); ConstantPool cp = cg.getConstantPool();
SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.PRIMITIVE_CHAR,cp,(char)'t');
SimpleElementValue evg = new SimpleElementValue(ElementValue.PRIMITIVE_CHAR,cp,(char)'t');
// Creation of an element like that should leave a new entry in the cpool // Creation of an element like that should leave a new entry in the cpool
int idx = cp.lookupInteger((char)'t'); int idx = cp.lookupInteger((char)'t');
assertTrue("Should have the same index in the constantpool but "+evg.getIndex()+"!="+idx, assertTrue("Should have the same index in the constantpool but "+evg.getIndex()+"!="+idx,
ClassGen cg = createClassGen("HelloWorld"); ClassGen cg = createClassGen("HelloWorld");
ConstantPool cp = cg.getConstantPool(); ConstantPool cp = cg.getConstantPool();
SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.PRIMITIVE_CHAR,cp,(byte)'z');
SimpleElementValue evg = new SimpleElementValue(ElementValue.PRIMITIVE_CHAR,cp,(byte)'z');
// Creation of an element like that should leave a new entry in the cpool // Creation of an element like that should leave a new entry in the cpool
int idx = cp.lookupInteger((byte)'z'); int idx = cp.lookupInteger((byte)'z');
assertTrue("Should have the same index in the constantpool but "+evg.getIndex()+"!="+idx, assertTrue("Should have the same index in the constantpool but "+evg.getIndex()+"!="+idx,
ClassGen cg = createClassGen("HelloWorld"); ClassGen cg = createClassGen("HelloWorld");
ConstantPool cp = cg.getConstantPool(); ConstantPool cp = cg.getConstantPool();
SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.PRIMITIVE_BOOLEAN,cp,true);
SimpleElementValue evg = new SimpleElementValue(ElementValue.PRIMITIVE_BOOLEAN,cp,true);
// Creation of an element like that should leave a new entry in the cpool // Creation of an element like that should leave a new entry in the cpool
int idx = cp.lookupInteger(1); // 1 == true int idx = cp.lookupInteger(1); // 1 == true
assertTrue("Should have the same index in the constantpool but "+evg.getIndex()+"!="+idx, assertTrue("Should have the same index in the constantpool but "+evg.getIndex()+"!="+idx,
ClassGen cg = createClassGen("HelloWorld"); ClassGen cg = createClassGen("HelloWorld");
ConstantPool cp = cg.getConstantPool(); ConstantPool cp = cg.getConstantPool();
SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.PRIMITIVE_SHORT,cp,(short)42);
SimpleElementValue evg = new SimpleElementValue(ElementValue.PRIMITIVE_SHORT,cp,(short)42);
// Creation of an element like that should leave a new entry in the cpool // Creation of an element like that should leave a new entry in the cpool
int idx = cp.lookupInteger(42); int idx = cp.lookupInteger(42);
assertTrue("Should have the same index in the constantpool but "+evg.getIndex()+"!="+idx, assertTrue("Should have the same index in the constantpool but "+evg.getIndex()+"!="+idx,
ClassGen cg = createClassGen("HelloWorld"); ClassGen cg = createClassGen("HelloWorld");
ConstantPool cp = cg.getConstantPool(); ConstantPool cp = cg.getConstantPool();
SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.STRING,cp,"hello");
SimpleElementValue evg = new SimpleElementValue(ElementValue.STRING,cp,"hello");
// Creation of an element like that should leave a new entry in the cpool // Creation of an element like that should leave a new entry in the cpool
assertTrue("Should have the same index in the constantpool but "+evg.getIndex()+"!="+cp.lookupUtf8("hello"), assertTrue("Should have the same index in the constantpool but "+evg.getIndex()+"!="+cp.lookupUtf8("hello"),
evg.getIndex()==cp.lookupUtf8("hello")); evg.getIndex()==cp.lookupUtf8("hello"));


ObjectType enumType = new ObjectType("SimpleEnum"); // Supports rainbow :) ObjectType enumType = new ObjectType("SimpleEnum"); // Supports rainbow :)
EnumElementValueGen evg = new EnumElementValueGen(enumType,"Red",cp);
EnumElementValue evg = new EnumElementValue(enumType,"Red",cp);
// Creation of an element like that should leave a new entry in the cpool // Creation of an element like that should leave a new entry in the cpool
assertTrue("The new ElementValue value index should match the contents of the constantpool but "+ assertTrue("The new ElementValue value index should match the contents of the constantpool but "+
evg.getValueIndex()+"!="+cp.lookupUtf8("Red"), evg.getValueIndex()+"!="+cp.lookupUtf8("Red"),
ObjectType classType = new ObjectType("java.lang.Integer"); ObjectType classType = new ObjectType("java.lang.Integer");
ClassElementValueGen evg = new ClassElementValueGen(classType,cp);
ClassElementValue evg = new ClassElementValue(classType,cp);
assertTrue("Unexpected value for contained class: '"+evg.getClassString()+"'", assertTrue("Unexpected value for contained class: '"+evg.getClassString()+"'",
evg.getClassString().indexOf("Integer")!=-1); evg.getClassString().indexOf("Integer")!=-1);
//// ////
// Helper methods // Helper methods
private void checkSerialize(ElementValueGen evgBefore,ConstantPool cpg) {
private void checkSerialize(ElementValue evgBefore,ConstantPool cpg) {
try { try {
String beforeValue = evgBefore.stringifyValue(); String beforeValue = evgBefore.stringifyValue();
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
ByteArrayInputStream bais = new ByteArrayInputStream(bs); ByteArrayInputStream bais = new ByteArrayInputStream(bs);
DataInputStream dis = new DataInputStream(bais); DataInputStream dis = new DataInputStream(bais);
ElementValueGen evgAfter = ElementValueGen.readElementValue(dis,cpg);
ElementValue evgAfter = ElementValue.readElementValue(dis,cpg);
dis.close(); dis.close();
String afterValue = evgAfter.stringifyValue(); String afterValue = evgAfter.stringifyValue();

+ 4
- 4
bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/FieldAnnotationsTest.java View File

import org.aspectj.apache.bcel.classfile.Field; import org.aspectj.apache.bcel.classfile.Field;
import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen;
import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePairGen;
import org.aspectj.apache.bcel.classfile.annotation.NameValuePair;
import org.aspectj.apache.bcel.generic.ClassGen; import org.aspectj.apache.bcel.generic.ClassGen;
import org.aspectj.apache.bcel.generic.FieldGen; import org.aspectj.apache.bcel.generic.FieldGen;
import org.aspectj.apache.bcel.util.SyntheticRepository; import org.aspectj.apache.bcel.util.SyntheticRepository;
assertTrue("Expected annotation to have name "+name+" but it had name "+a.getTypeName(), assertTrue("Expected annotation to have name "+name+" but it had name "+a.getTypeName(),
a.getTypeName().equals(name)); a.getTypeName().equals(name));
assertTrue("Expected annotation to have one element but it had "+a.getValues().size(),a.getValues().size()==1); assertTrue("Expected annotation to have one element but it had "+a.getValues().size(),a.getValues().size()==1);
ElementNameValuePairGen envp = a.getValues().get(0);
NameValuePair envp = a.getValues().get(0);
assertTrue("Expected element name "+elementname+" but was "+envp.getNameString(), assertTrue("Expected element name "+elementname+" but was "+envp.getNameString(),
elementname.equals(envp.getNameString())); elementname.equals(envp.getNameString()));
assertTrue("Expected element value "+elementvalue+" but was "+envp.getValue().stringifyValue(), assertTrue("Expected element value "+elementvalue+" but was "+envp.getValue().stringifyValue(),
// helper methods // helper methods
public void checkValue(AnnotationGen a,String name,String tostring) { public void checkValue(AnnotationGen a,String name,String tostring) {
for (Iterator<ElementNameValuePairGen> i = a.getValues().iterator(); i.hasNext();) {
ElementNameValuePairGen element = i.next();
for (Iterator<NameValuePair> i = a.getValues().iterator(); i.hasNext();) {
NameValuePair element = i.next();
if (element.getNameString().equals(name)) { if (element.getNameString().equals(name)) {
if (!element.getValue().stringifyValue().equals(tostring)) { if (!element.getValue().stringifyValue().equals(tostring)) {
fail("Expected element "+name+" to have value "+tostring+" but it had value "+element.getValue().stringifyValue()); fail("Expected element "+name+" to have value "+tostring+" but it had value "+element.getValue().stringifyValue());

+ 33
- 33
bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/GeneratingAnnotatedClassesTest.java View File

import org.aspectj.apache.bcel.classfile.ConstantPool; import org.aspectj.apache.bcel.classfile.ConstantPool;
import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.classfile.Method; import org.aspectj.apache.bcel.classfile.Method;
import org.aspectj.apache.bcel.classfile.annotation.AnnotationElementValueGen;
import org.aspectj.apache.bcel.classfile.annotation.AnnotationElementValue;
import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; 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.classfile.annotation.ArrayElementValue;
import org.aspectj.apache.bcel.classfile.annotation.NameValuePair;
import org.aspectj.apache.bcel.classfile.annotation.ElementValue;
import org.aspectj.apache.bcel.classfile.annotation.SimpleElementValue;
import org.aspectj.apache.bcel.generic.ArrayType; import org.aspectj.apache.bcel.generic.ArrayType;
import org.aspectj.apache.bcel.generic.ClassGen; import org.aspectj.apache.bcel.generic.ClassGen;
import org.aspectj.apache.bcel.generic.InstructionBranch; import org.aspectj.apache.bcel.generic.InstructionBranch;
"SimpleAnnotation")); "SimpleAnnotation"));
assertTrue("Name of annotation 2 should be SimpleAnnotation but it is " + as[1].getTypeName(), as[1].getTypeName().equals( assertTrue("Name of annotation 2 should be SimpleAnnotation but it is " + as[1].getTypeName(), as[1].getTypeName().equals(
"SimpleAnnotation")); "SimpleAnnotation"));
List<ElementNameValuePairGen> vals = as[0].getValues();
ElementNameValuePairGen nvp = vals.get(0);
List<NameValuePair> vals = as[0].getValues();
NameValuePair nvp = vals.get(0);
assertTrue("Name of element in SimpleAnnotation should be 'id' but it is " + nvp.getNameString(), nvp.getNameString() assertTrue("Name of element in SimpleAnnotation should be 'id' but it is " + nvp.getNameString(), nvp.getNameString()
.equals("id")); .equals("id"));
ElementValueGen ev = nvp.getValue();
ElementValue ev = nvp.getValue();
assertTrue("Type of element value should be int but it is " + ev.getElementValueType(), 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("Value of element should be 4 but it is " + ev.stringifyValue(), ev.stringifyValue().equals("4"));
assertTrue(createTestdataFile("HelloWorld.class").delete()); assertTrue(createTestdataFile("HelloWorld.class").delete());
} }
assertTrue("Expected one annotation but found " + annotations.length, annotations.length == 1); assertTrue("Expected one annotation but found " + annotations.length, annotations.length == 1);
AnnotationGen a = annotations[0]; AnnotationGen a = annotations[0];
assertTrue("That annotation should only have one value but has " + a.getValues().size(), a.getValues().size() == 1); assertTrue("That annotation should only have one value but has " + a.getValues().size(), a.getValues().size() == 1);
ElementNameValuePairGen nvp = a.getValues().get(0);
ElementValueGen value = nvp.getValue();
assertTrue("Value should be ArrayElementValueGen but is " + value, value instanceof ArrayElementValueGen);
ArrayElementValueGen arrayValue = (ArrayElementValueGen) value;
NameValuePair nvp = a.getValues().get(0);
ElementValue value = nvp.getValue();
assertTrue("Value should be ArrayElementValueGen but is " + value, value instanceof ArrayElementValue);
ArrayElementValue arrayValue = (ArrayElementValue) value;
assertTrue("Array value should be size one but is " + arrayValue.getElementValuesArraySize(), arrayValue assertTrue("Array value should be size one but is " + arrayValue.getElementValuesArraySize(), arrayValue
.getElementValuesArraySize() == 1); .getElementValuesArraySize() == 1);
ElementValueGen innerValue = arrayValue.getElementValuesArray()[0];
ElementValue innerValue = arrayValue.getElementValuesArray()[0];
assertTrue("Value in the array should be AnnotationElementValueGen but is " + innerValue, assertTrue("Value in the array should be AnnotationElementValueGen but is " + innerValue,
innerValue instanceof AnnotationElementValueGen);
AnnotationElementValueGen innerAnnotationValue = (AnnotationElementValueGen) innerValue;
innerValue instanceof AnnotationElementValue);
AnnotationElementValue innerAnnotationValue = (AnnotationElementValue) innerValue;
assertTrue("Should be called LSimpleAnnotation; but is called: " + innerAnnotationValue.getAnnotation().getTypeName(), assertTrue("Should be called LSimpleAnnotation; but is called: " + innerAnnotationValue.getAnnotation().getTypeName(),
innerAnnotationValue.getAnnotation().getTypeSignature().equals("LSimpleAnnotation;")); innerAnnotationValue.getAnnotation().getTypeSignature().equals("LSimpleAnnotation;"));
} }
// Check annotations are correctly preserved // Check annotations are correctly preserved
AnnotationGen[] annotations = cgen.getAnnotations(); AnnotationGen[] annotations = cgen.getAnnotations();
assertTrue("Expected one annotation but found " + annotations.length, annotations.length == 1); assertTrue("Expected one annotation but found " + annotations.length, annotations.length == 1);
List<ElementNameValuePairGen> l = annotations[0].getValues();
List<NameValuePair> l = annotations[0].getValues();
boolean found = false; boolean found = false;
for (Iterator<ElementNameValuePairGen> iter = l.iterator(); iter.hasNext();) {
ElementNameValuePairGen element = iter.next();
for (Iterator<NameValuePair> iter = l.iterator(); iter.hasNext();) {
NameValuePair element = iter.next();
if (element.getNameString().equals("dval")) { if (element.getNameString().equals("dval")) {
if (((SimpleElementValueGen) element.getValue()).stringifyValue().equals("33.4"))
if (((SimpleElementValue) element.getValue()).stringifyValue().equals("33.4"))
found = true; found = true;
} }
} }
} }


public AnnotationGen createSimpleVisibleAnnotation(ConstantPool cp) { public AnnotationGen createSimpleVisibleAnnotation(ConstantPool cp) {
SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.PRIMITIVE_INT, cp, 4);
SimpleElementValue evg = new SimpleElementValue(ElementValue.PRIMITIVE_INT, cp, 4);


ElementNameValuePairGen nvGen = new ElementNameValuePairGen("id", evg, cp);
NameValuePair nvGen = new NameValuePair("id", evg, cp);


ObjectType t = new ObjectType("SimpleAnnotation"); ObjectType t = new ObjectType("SimpleAnnotation");


List<ElementNameValuePairGen> elements = new ArrayList<ElementNameValuePairGen>();
List<NameValuePair> elements = new ArrayList<NameValuePair>();
elements.add(nvGen); elements.add(nvGen);


AnnotationGen a = new AnnotationGen(t, elements, true, cp); AnnotationGen a = new AnnotationGen(t, elements, true, cp);
} }


public AnnotationGen createFruitAnnotation(ConstantPool cp, String aFruit) { public AnnotationGen createFruitAnnotation(ConstantPool cp, String aFruit) {
SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.STRING, cp, aFruit);
ElementNameValuePairGen nvGen = new ElementNameValuePairGen("fruit", evg, cp);
SimpleElementValue evg = new SimpleElementValue(ElementValue.STRING, cp, aFruit);
NameValuePair nvGen = new NameValuePair("fruit", evg, cp);
ObjectType t = new ObjectType("SimpleStringAnnotation"); ObjectType t = new ObjectType("SimpleStringAnnotation");
List<ElementNameValuePairGen> elements = new ArrayList<ElementNameValuePairGen>();
List<NameValuePair> elements = new ArrayList<NameValuePair>();
elements.add(nvGen); elements.add(nvGen);
return new AnnotationGen(t, elements, true, cp); return new AnnotationGen(t, elements, true, cp);
} }
public AnnotationGen createCombinedAnnotation(ConstantPool cp) { public AnnotationGen createCombinedAnnotation(ConstantPool cp) {
// Create an annotation instance // Create an annotation instance
AnnotationGen a = createSimpleVisibleAnnotation(cp); AnnotationGen a = createSimpleVisibleAnnotation(cp);
ArrayElementValueGen array = new ArrayElementValueGen(cp);
array.addElement(new AnnotationElementValueGen(a, cp));
ElementNameValuePairGen nvp = new ElementNameValuePairGen("value", array, cp);
List<ElementNameValuePairGen> elements = new ArrayList<ElementNameValuePairGen>();
ArrayElementValue array = new ArrayElementValue(cp);
array.addElement(new AnnotationElementValue(a, cp));
NameValuePair nvp = new NameValuePair("value", array, cp);
List<NameValuePair> elements = new ArrayList<NameValuePair>();
elements.add(nvp); elements.add(nvp);
return new AnnotationGen(new ObjectType("CombinedAnnotation"), elements, true, cp); return new AnnotationGen(new ObjectType("CombinedAnnotation"), elements, true, cp);
} }


public AnnotationGen createSimpleInvisibleAnnotation(ConstantPool cp) { public AnnotationGen createSimpleInvisibleAnnotation(ConstantPool cp) {
SimpleElementValueGen evg = new SimpleElementValueGen(ElementValueGen.PRIMITIVE_INT, cp, 4);
SimpleElementValue evg = new SimpleElementValue(ElementValue.PRIMITIVE_INT, cp, 4);


ElementNameValuePairGen nvGen = new ElementNameValuePairGen("id", evg, cp);
NameValuePair nvGen = new NameValuePair("id", evg, cp);


ObjectType t = new ObjectType("SimpleAnnotation"); ObjectType t = new ObjectType("SimpleAnnotation");


List<ElementNameValuePairGen> elements = new ArrayList<ElementNameValuePairGen>();
List<NameValuePair> elements = new ArrayList<NameValuePair>();
elements.add(nvGen); elements.add(nvGen);


AnnotationGen a = new AnnotationGen(t, elements, false, cp); AnnotationGen a = new AnnotationGen(t, elements, false, cp);

+ 4
- 4
bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/MethodAnnotationsTest.java View File

import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.classfile.Method; import org.aspectj.apache.bcel.classfile.Method;
import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen;
import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePairGen;
import org.aspectj.apache.bcel.classfile.annotation.NameValuePair;
import org.aspectj.apache.bcel.util.SyntheticRepository; import org.aspectj.apache.bcel.util.SyntheticRepository;




assertTrue("Expected annotation to have name "+name+" but it had name "+a.getTypeName(), assertTrue("Expected annotation to have name "+name+" but it had name "+a.getTypeName(),
a.getTypeName().equals(name)); a.getTypeName().equals(name));
assertTrue("Expected annotation to have one element but it had "+a.getValues().size(),a.getValues().size()==1); assertTrue("Expected annotation to have one element but it had "+a.getValues().size(),a.getValues().size()==1);
ElementNameValuePairGen envp = a.getValues().get(0);
NameValuePair envp = a.getValues().get(0);
assertTrue("Expected element name "+elementname+" but was "+envp.getNameString(), assertTrue("Expected element name "+elementname+" but was "+envp.getNameString(),
elementname.equals(envp.getNameString())); elementname.equals(envp.getNameString()));
assertTrue("Expected element value "+elementvalue+" but was "+envp.getValue().stringifyValue(), assertTrue("Expected element value "+elementvalue+" but was "+envp.getValue().stringifyValue(),
// helper methods // helper methods
public void checkValue(AnnotationGen a,String name,String tostring) { public void checkValue(AnnotationGen a,String name,String tostring) {
for (Iterator<ElementNameValuePairGen> i = a.getValues().iterator(); i.hasNext();) {
ElementNameValuePairGen element = i.next();
for (Iterator<NameValuePair> i = a.getValues().iterator(); i.hasNext();) {
NameValuePair element = i.next();
if (element.getNameString().equals(name)) { if (element.getNameString().equals(name)) {
if (!element.getValue().stringifyValue().equals(tostring)) { if (!element.getValue().stringifyValue().equals(tostring)) {
fail("Expected element "+name+" to have value "+tostring+" but it had value "+element.getValue().stringifyValue()); fail("Expected element "+name+" to have value "+tostring+" but it had value "+element.getValue().stringifyValue());

+ 17
- 17
bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/ParameterAnnotationsTest.java View File

import org.aspectj.apache.bcel.classfile.ConstantPool; import org.aspectj.apache.bcel.classfile.ConstantPool;
import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.classfile.Method; import org.aspectj.apache.bcel.classfile.Method;
import org.aspectj.apache.bcel.classfile.annotation.AnnotationElementValueGen;
import org.aspectj.apache.bcel.classfile.annotation.AnnotationElementValue;
import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; 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.classfile.annotation.ArrayElementValue;
import org.aspectj.apache.bcel.classfile.annotation.NameValuePair;
import org.aspectj.apache.bcel.classfile.annotation.ElementValue;
import org.aspectj.apache.bcel.classfile.annotation.SimpleElementValue;
import org.aspectj.apache.bcel.generic.ArrayType; import org.aspectj.apache.bcel.generic.ArrayType;
import org.aspectj.apache.bcel.generic.ClassGen; import org.aspectj.apache.bcel.generic.ClassGen;
import org.aspectj.apache.bcel.generic.InstructionBranch; import org.aspectj.apache.bcel.generic.InstructionBranch;


public AnnotationGen createSimpleVisibleAnnotation(ConstantPool cp) { public AnnotationGen createSimpleVisibleAnnotation(ConstantPool cp) {
SimpleElementValueGen evg = new SimpleElementValueGen(
ElementValueGen.PRIMITIVE_INT, cp, 4);
SimpleElementValue evg = new SimpleElementValue(
ElementValue.PRIMITIVE_INT, cp, 4);


ElementNameValuePairGen nvGen = new ElementNameValuePairGen("id", evg,cp);
NameValuePair nvGen = new NameValuePair("id", evg,cp);


ObjectType t = new ObjectType("SimpleAnnotation"); ObjectType t = new ObjectType("SimpleAnnotation");


List<ElementNameValuePairGen> elements = new ArrayList<ElementNameValuePairGen>();
List<NameValuePair> elements = new ArrayList<NameValuePair>();
elements.add(nvGen); elements.add(nvGen);


AnnotationGen a = new AnnotationGen(t, elements,true, cp); AnnotationGen a = new AnnotationGen(t, elements,true, cp);
public AnnotationGen createCombinedAnnotation(ConstantPool cp) { public AnnotationGen createCombinedAnnotation(ConstantPool cp) {
// Create an annotation instance // Create an annotation instance
AnnotationGen a = createSimpleVisibleAnnotation(cp); AnnotationGen a = createSimpleVisibleAnnotation(cp);
ArrayElementValueGen array = new ArrayElementValueGen(cp);
array.addElement(new AnnotationElementValueGen(a,cp));
ElementNameValuePairGen nvp = new ElementNameValuePairGen("value",array,cp);
List<ElementNameValuePairGen> elements = new ArrayList<ElementNameValuePairGen>();
ArrayElementValue array = new ArrayElementValue(cp);
array.addElement(new AnnotationElementValue(a,cp));
NameValuePair nvp = new NameValuePair("value",array,cp);
List<NameValuePair> elements = new ArrayList<NameValuePair>();
elements.add(nvp); elements.add(nvp);
return new AnnotationGen(new ObjectType("CombinedAnnotation"),elements,true,cp); return new AnnotationGen(new ObjectType("CombinedAnnotation"),elements,true,cp);
} }
public AnnotationGen createSimpleInvisibleAnnotation(ConstantPool cp) { public AnnotationGen createSimpleInvisibleAnnotation(ConstantPool cp) {
SimpleElementValueGen evg = new SimpleElementValueGen(
ElementValueGen.PRIMITIVE_INT, cp, 4);
SimpleElementValue evg = new SimpleElementValue(
ElementValue.PRIMITIVE_INT, cp, 4);


ElementNameValuePairGen nvGen = new ElementNameValuePairGen("id", evg,cp);
NameValuePair nvGen = new NameValuePair("id", evg,cp);


ObjectType t = new ObjectType("SimpleAnnotation"); ObjectType t = new ObjectType("SimpleAnnotation");


List<ElementNameValuePairGen> elements = new ArrayList<ElementNameValuePairGen>();
List<NameValuePair> elements = new ArrayList<NameValuePair>();
elements.add(nvGen); elements.add(nvGen);


AnnotationGen a = new AnnotationGen(t, elements,false, cp); AnnotationGen a = new AnnotationGen(t, elements,false, cp);

+ 41
- 41
bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleAnnotationAttributeTest.java View File

import org.aspectj.apache.bcel.classfile.ConstantPool; import org.aspectj.apache.bcel.classfile.ConstantPool;
import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.classfile.Utility; import org.aspectj.apache.bcel.classfile.Utility;
import org.aspectj.apache.bcel.classfile.annotation.AnnotationElementValueGen;
import org.aspectj.apache.bcel.classfile.annotation.AnnotationElementValue;
import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; 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.RuntimeVisibleAnnotations;
import org.aspectj.apache.bcel.classfile.annotation.SimpleElementValueGen;
import org.aspectj.apache.bcel.classfile.annotation.ArrayElementValue;
import org.aspectj.apache.bcel.classfile.annotation.ClassElementValue;
import org.aspectj.apache.bcel.classfile.annotation.NameValuePair;
import org.aspectj.apache.bcel.classfile.annotation.ElementValue;
import org.aspectj.apache.bcel.classfile.annotation.EnumElementValue;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisAnnos;
import org.aspectj.apache.bcel.classfile.annotation.SimpleElementValue;
import org.aspectj.apache.bcel.generic.ClassGen; import org.aspectj.apache.bcel.generic.ClassGen;
import org.aspectj.apache.bcel.util.SyntheticRepository; import org.aspectj.apache.bcel.util.SyntheticRepository;


JavaClass clazz = repos.loadClass("SimpleAnnotatedClass"); JavaClass clazz = repos.loadClass("SimpleAnnotatedClass");
ConstantPool pool = clazz.getConstantPool(); ConstantPool pool = clazz.getConstantPool();
Attribute[] rvaAttr = findAttribute("RuntimeVisibleAnnotations",clazz); Attribute[] rvaAttr = findAttribute("RuntimeVisibleAnnotations",clazz);
RuntimeVisibleAnnotations rva = (RuntimeVisibleAnnotations) rvaAttr[0];
RuntimeVisAnnos rva = (RuntimeVisAnnos) rvaAttr[0];
List<AnnotationGen> anns = rva.getAnnotations(); List<AnnotationGen> anns = rva.getAnnotations();
assertTrue("Should be one annotation but found "+anns.size(), assertTrue("Should be one annotation but found "+anns.size(),
anns.size()==1); anns.size()==1);
AnnotationGen ann = anns.get(0); AnnotationGen ann = anns.get(0);
assertTrue("Should be called 'SimpleAnnotation' but was called "+ann.getTypeName(), assertTrue("Should be called 'SimpleAnnotation' but was called "+ann.getTypeName(),
ann.getTypeName().equals("SimpleAnnotation")); ann.getTypeName().equals("SimpleAnnotation"));
List<ElementNameValuePairGen> l = ann.getValues();
List<NameValuePair> l = ann.getValues();
assertTrue("Should be one value for annotation 'SimpleAnnotation' but found "+l.size(), assertTrue("Should be one value for annotation 'SimpleAnnotation' but found "+l.size(),
l.size()==1); l.size()==1);
ElementNameValuePairGen envp = l.get(0);
NameValuePair envp = l.get(0);
assertTrue("Name of element in SimpleAnnotation should be 'id' but it is "+envp.getNameString(), assertTrue("Name of element in SimpleAnnotation should be 'id' but it is "+envp.getNameString(),
envp.getNameString().equals("id")); 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(), assertTrue("'id' should have value 4 but it is "+evalue.getValueInt(),
evalue.getValueInt()==4); evalue.getValueInt()==4);
} }
AnnotationGen ann = anns[0]; AnnotationGen ann = anns[0];
assertTrue("should be called 'AnnotationStringElement' but was called "+ann.getTypeName(), assertTrue("should be called 'AnnotationStringElement' but was called "+ann.getTypeName(),
ann.getTypeName().equals("AnnotationStringElement")); ann.getTypeName().equals("AnnotationStringElement"));
List<ElementNameValuePairGen> l = ann.getValues();
List<NameValuePair> l = ann.getValues();
assertTrue("Should be one value but there were "+l.size(),l.size()==1); assertTrue("Should be one value but there were "+l.size(),l.size()==1);
ElementNameValuePairGen nvp = l.get(0);
NameValuePair nvp = l.get(0);
assertTrue("Name of element should be 'stringval' but was "+nvp.getNameString(), assertTrue("Name of element should be 'stringval' but was "+nvp.getNameString(),
nvp.getNameString().equals("stringval")); nvp.getNameString().equals("stringval"));
SimpleElementValueGen ev = (SimpleElementValueGen)nvp.getValue();
SimpleElementValue ev = (SimpleElementValue)nvp.getValue();
assertTrue("String value should be 'hello' but was '"+ev.getValueString()+"'", assertTrue("String value should be 'hello' but was '"+ev.getValueString()+"'",
ev.getValueString().equals("hello")); ev.getValueString().equals("hello"));
} }
AnnotationGen ann = anns[0]; AnnotationGen ann = anns[0];
assertTrue("Should be called 'ComplexAnnotation' but was called "+ann.getTypeName(), assertTrue("Should be called 'ComplexAnnotation' but was called "+ann.getTypeName(),
ann.getTypeName().equals("ComplexAnnotation")); ann.getTypeName().equals("ComplexAnnotation"));
List<ElementNameValuePairGen> l = ann.getValues();
List<NameValuePair> l = ann.getValues();
assertTrue("Should be eight values for annotation 'ComplexAnnotation' but found "+l.size(), assertTrue("Should be eight values for annotation 'ComplexAnnotation' but found "+l.size(),
l.size()==8); l.size()==8);
List<String> names = RuntimeVisibleAnnotationAttributeTest.getListOfAnnotationNames(ann); List<String> names = RuntimeVisibleAnnotationAttributeTest.getListOfAnnotationNames(ann);
} }


private void checkValue(AnnotationGen a,String name,String tostring) { private void checkValue(AnnotationGen a,String name,String tostring) {
for (Iterator<ElementNameValuePairGen> i = a.getValues().iterator(); i.hasNext();) {
ElementNameValuePairGen element = i.next();
for (Iterator<NameValuePair> i = a.getValues().iterator(); i.hasNext();) {
NameValuePair element = i.next();
if (element.getNameString().equals(name)) { if (element.getNameString().equals(name)) {
if (!element.getValue().stringifyValue().equals(tostring)) { if (!element.getValue().stringifyValue().equals(tostring)) {
fail("Expected element "+name+" to have value "+tostring+" but it had value "+element.getValue().stringifyValue()); fail("Expected element "+name+" to have value "+tostring+" but it had value "+element.getValue().stringifyValue());
AnnotationGen ann = anns[0]; AnnotationGen ann = anns[0];
assertTrue("should be called 'AnnotationClassElement' but was called "+ann.getTypeName(), assertTrue("should be called 'AnnotationClassElement' but was called "+ann.getTypeName(),
ann.getTypeName().equals("AnnotationClassElement")); ann.getTypeName().equals("AnnotationClassElement"));
List<ElementNameValuePairGen> l = ann.getValues();
List<NameValuePair> l = ann.getValues();
assertTrue("Should be one value but there were "+l.size(),l.size()==1); assertTrue("Should be one value but there were "+l.size(),l.size()==1);
ElementNameValuePairGen nvp = l.get(0);
NameValuePair nvp = l.get(0);
assertTrue("Name of element should be 'clz' but was "+nvp.getNameString(), assertTrue("Name of element should be 'clz' but was "+nvp.getNameString(),
nvp.getNameString().equals("clz")); 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()+"'", assertTrue("String value should be 'Ljava/lang/Integer;' but was '"+ev.getClassString()+"'",
ev.getClassString().equals("Ljava/lang/Integer;")); ev.getClassString().equals("Ljava/lang/Integer;"));
AnnotationGen ann = anns[0]; AnnotationGen ann = anns[0];
assertTrue("should be called 'AnnotationEnumElement' but was called "+ann.getTypeName(), assertTrue("should be called 'AnnotationEnumElement' but was called "+ann.getTypeName(),
ann.getTypeName().equals("AnnotationEnumElement")); ann.getTypeName().equals("AnnotationEnumElement"));
List<ElementNameValuePairGen> l = ann.getValues();
List<NameValuePair> l = ann.getValues();
assertTrue("Should be one value but there were "+l.size(),l.size()==1); assertTrue("Should be one value but there were "+l.size(),l.size()==1);
ElementNameValuePairGen nvp = l.get(0);
NameValuePair nvp = l.get(0);
assertTrue("Name of element should be 'enumval' but was "+nvp.getNameString(), assertTrue("Name of element should be 'enumval' but was "+nvp.getNameString(),
nvp.getNameString().equals("enumval")); 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("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()+"'", assertTrue("String value should be 'Red' but was '"+eev.getEnumValueString()+"'",
eev.getEnumValueString().equals("Red")); eev.getEnumValueString().equals("Red"));
private void checkCombinedAnnotation(AnnotationGen ann) { private void checkCombinedAnnotation(AnnotationGen ann) {
assertTrue("should be called 'CombinedAnnotation' but was called "+ann.getTypeName(), assertTrue("should be called 'CombinedAnnotation' but was called "+ann.getTypeName(),
ann.getTypeName().equals("CombinedAnnotation")); ann.getTypeName().equals("CombinedAnnotation"));
List<ElementNameValuePairGen> l = ann.getValues();
List<NameValuePair> l = ann.getValues();
assertTrue("Should be one value but there were "+l.size(),l.size()==1); assertTrue("Should be one value but there were "+l.size(),l.size()==1);
ElementNameValuePairGen nvp = l.get(0);
NameValuePair nvp = l.get(0);
assertTrue("Name of element should be 'value' but was "+nvp.getNameString(), assertTrue("Name of element should be 'value' but was "+nvp.getNameString(),
nvp.getNameString().equals("value")); 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(), assertTrue("Array element value should be of size 1 but is "+aev.getElementValuesArraySize(),
aev.getElementValuesArraySize()==1); aev.getElementValuesArraySize()==1);
ElementValueGen[] evs = aev.getElementValuesArray();
ElementValue[] evs = aev.getElementValuesArray();
assertTrue("Entry in the array should be AnnotationElementValue but is "+evs[0], assertTrue("Entry in the array should be AnnotationElementValue but is "+evs[0],
evs[0] instanceof AnnotationElementValueGen);
AnnotationElementValueGen inner_ev = (AnnotationElementValueGen)evs[0];
evs[0] instanceof AnnotationElementValue);
AnnotationElementValue inner_ev = (AnnotationElementValue)evs[0];
AnnotationGen a = inner_ev.getAnnotation(); AnnotationGen a = inner_ev.getAnnotation();
assertTrue("Should be SimpleAnnotation but is "+a.getTypeName(),a.getTypeName().equals("SimpleAnnotation")); assertTrue("Should be SimpleAnnotation but is "+a.getTypeName(),a.getTypeName().equals("SimpleAnnotation"));
List<ElementNameValuePairGen> envps = a.getValues();
List<NameValuePair> envps = a.getValues();
assertTrue("Should be one name value pair but found "+envps.size(),envps.size()==1); assertTrue("Should be one name value pair but found "+envps.size(),envps.size()==1);
ElementNameValuePairGen envp = envps.get(0);
NameValuePair envp = envps.get(0);
assertTrue("Name should be 'id' but it is "+envp.getNameString(),envp.getNameString().equals("id")); 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(), assertTrue("Value of 'id' should be 4 but it is "+envp.getValue().stringifyValue(),
envp.getValue().stringifyValue().equals("4")); envp.getValue().stringifyValue().equals("4"));
} }


public static List<String> getListOfAnnotationNames(AnnotationGen a) { public static List<String> getListOfAnnotationNames(AnnotationGen a) {
List<ElementNameValuePairGen> l = a.getValues();
List<NameValuePair> l = a.getValues();
List<String> names = new ArrayList<String>(); List<String> names = new ArrayList<String>();
for (Iterator<ElementNameValuePairGen> i = l.iterator(); i.hasNext();) {
ElementNameValuePairGen element = i.next();
for (Iterator<NameValuePair> i = l.iterator(); i.hasNext();) {
NameValuePair element = i.next();
names.add(element.getNameString()); names.add(element.getNameString());
} }
return names; return names;

+ 9
- 9
bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/RuntimeVisibleParameterAnnotationAttributeTest.java View File

import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.classfile.Method; import org.aspectj.apache.bcel.classfile.Method;
import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen;
import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePairGen;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleParameterAnnotations;
import org.aspectj.apache.bcel.classfile.annotation.NameValuePair;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisParamAnnos;
import org.aspectj.apache.bcel.util.SyntheticRepository; import org.aspectj.apache.bcel.util.SyntheticRepository;




for (int i = 0; i < methods.length; i++) { for (int i = 0; i < methods.length; i++) {
Method m = methods[i]; Method m = methods[i];
if (m.getName().equals("foo")) { if (m.getName().equals("foo")) {
RuntimeVisibleParameterAnnotations paramAnns =
(RuntimeVisibleParameterAnnotations) findAttribute("RuntimeVisibleParameterAnnotations",m.getAttributes());
RuntimeVisParamAnnos paramAnns =
(RuntimeVisParamAnnos) findAttribute("RuntimeVisibleParameterAnnotations",m.getAttributes());
assertTrue("foo takes two parameters, not "+paramAnns.getParameterAnnotations().size(), assertTrue("foo takes two parameters, not "+paramAnns.getParameterAnnotations().size(),
paramAnns.getParameterAnnotations().size()==2); paramAnns.getParameterAnnotations().size()==2);


} }
if (m.getName().equals("main")) { if (m.getName().equals("main")) {
RuntimeVisibleParameterAnnotations paramAnns =
(RuntimeVisibleParameterAnnotations) findAttribute("RuntimeVisibleParameterAnnotations",m.getAttributes());
RuntimeVisParamAnnos paramAnns =
(RuntimeVisParamAnnos) findAttribute("RuntimeVisibleParameterAnnotations",m.getAttributes());
assertTrue("main takes one parameter, not "+paramAnns.getParameterAnnotations().size(), assertTrue("main takes one parameter, not "+paramAnns.getParameterAnnotations().size(),
paramAnns.getParameterAnnotations().size()==1); paramAnns.getParameterAnnotations().size()==1);


assertTrue("Expected annotation to have name "+name+" but it had name "+a.getTypeName(), assertTrue("Expected annotation to have name "+name+" but it had name "+a.getTypeName(),
a.getTypeName().equals(name)); a.getTypeName().equals(name));
assertTrue("Expected annotation to have one element but it had "+a.getValues().size(),a.getValues().size()==1); assertTrue("Expected annotation to have one element but it had "+a.getValues().size(),a.getValues().size()==1);
ElementNameValuePairGen envp = a.getValues().get(0);
NameValuePair envp = a.getValues().get(0);
assertTrue("Expected element name "+elementname+" but was "+envp.getNameString(), assertTrue("Expected element name "+elementname+" but was "+envp.getNameString(),
elementname.equals(envp.getNameString())); elementname.equals(envp.getNameString()));
assertTrue("Expected element value "+elementvalue+" but was "+envp.getValue().stringifyValue(), assertTrue("Expected element value "+elementvalue+" but was "+envp.getValue().stringifyValue(),
// helper methods // helper methods
public void checkValue(AnnotationGen a,String name,String tostring) { public void checkValue(AnnotationGen a,String name,String tostring) {
for (Iterator<ElementNameValuePairGen> i = a.getValues().iterator(); i.hasNext();) {
ElementNameValuePairGen element = i.next();
for (Iterator<NameValuePair> i = a.getValues().iterator(); i.hasNext();) {
NameValuePair element = i.next();
if (element.getNameString().equals(name)) { if (element.getNameString().equals(name)) {
if (!element.getValue().stringifyValue().equals(tostring)) { if (!element.getValue().stringifyValue().equals(tostring)) {
fail("Expected element "+name+" to have value "+tostring+" but it had value "+element.getValue().stringifyValue()); fail("Expected element "+name+" to have value "+tostring+" but it had value "+element.getValue().stringifyValue());

+ 3
- 3
bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/VarargsTest.java View File

import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.classfile.Method; import org.aspectj.apache.bcel.classfile.Method;
import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen;
import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePairGen;
import org.aspectj.apache.bcel.classfile.annotation.NameValuePair;
import org.aspectj.apache.bcel.util.SyntheticRepository; import org.aspectj.apache.bcel.util.SyntheticRepository;




// helper methods // helper methods
public void checkValue(AnnotationGen a,String name,String tostring) { public void checkValue(AnnotationGen a,String name,String tostring) {
for (Iterator<ElementNameValuePairGen> i = a.getValues().iterator(); i.hasNext();) {
ElementNameValuePairGen element = i.next();
for (Iterator<NameValuePair> i = a.getValues().iterator(); i.hasNext();) {
NameValuePair element = i.next();
if (element.getNameString().equals(name)) { if (element.getNameString().equals(name)) {
if (!element.getValue().stringifyValue().equals(tostring)) { if (!element.getValue().stringifyValue().equals(tostring)) {
fail("Expected element "+name+" to have value "+tostring+" but it had value "+element.getValue().stringifyValue()); fail("Expected element "+name+" to have value "+tostring+" but it had value "+element.getValue().stringifyValue());

+ 9
- 9
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/DescendingVisitor.java View File

import org.aspectj.apache.bcel.classfile.Synthetic; import org.aspectj.apache.bcel.classfile.Synthetic;
import org.aspectj.apache.bcel.classfile.Unknown; import org.aspectj.apache.bcel.classfile.Unknown;
import org.aspectj.apache.bcel.classfile.ClassVisitor; import org.aspectj.apache.bcel.classfile.ClassVisitor;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisibleAnnotations;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisibleParameterAnnotations;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleAnnotations;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleParameterAnnotations;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisAnnos;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisParamAnnos;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisAnnos;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisParamAnnos;


/** /**
* Traverses a JavaClass with another Visitor object 'piggy-backed' * Traverses a JavaClass with another Visitor object 'piggy-backed'
* class supplies the traversal strategy, other classes can make use * class supplies the traversal strategy, other classes can make use
* of it. * of it.
* *
* @version $Id: DescendingVisitor.java,v 1.3 2009/09/09 19:56:20 aclement Exp $
* @version $Id: DescendingVisitor.java,v 1.4 2009/09/15 19:40:22 aclement Exp $
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
*/ */
public class DescendingVisitor implements ClassVisitor { public class DescendingVisitor implements ClassVisitor {
stack.pop(); stack.pop();
} }
public void visitRuntimeVisibleAnnotations(RuntimeVisibleAnnotations attribute) {
public void visitRuntimeVisibleAnnotations(RuntimeVisAnnos attribute) {
stack.push(attribute); stack.push(attribute);
attribute.accept(visitor); attribute.accept(visitor);
stack.pop(); stack.pop();
} }
public void visitRuntimeInvisibleAnnotations(RuntimeInvisibleAnnotations attribute) {
public void visitRuntimeInvisibleAnnotations(RuntimeInvisAnnos attribute) {
stack.push(attribute); stack.push(attribute);
attribute.accept(visitor); attribute.accept(visitor);
stack.pop(); stack.pop();
} }
public void visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations attribute) {
public void visitRuntimeVisibleParameterAnnotations(RuntimeVisParamAnnos attribute) {
stack.push(attribute); stack.push(attribute);
attribute.accept(visitor); attribute.accept(visitor);
stack.pop(); stack.pop();
} }
public void visitRuntimeInvisibleParameterAnnotations(RuntimeInvisibleParameterAnnotations attribute) {
public void visitRuntimeInvisibleParameterAnnotations(RuntimeInvisParamAnnos attribute) {
stack.push(attribute); stack.push(attribute);
attribute.accept(visitor); attribute.accept(visitor);
stack.pop(); stack.pop();

+ 9
- 9
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/EmptyClassVisitor.java View File

import org.aspectj.apache.bcel.classfile.Synthetic; import org.aspectj.apache.bcel.classfile.Synthetic;
import org.aspectj.apache.bcel.classfile.Unknown; import org.aspectj.apache.bcel.classfile.Unknown;
import org.aspectj.apache.bcel.classfile.ClassVisitor; import org.aspectj.apache.bcel.classfile.ClassVisitor;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisibleAnnotations;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisibleParameterAnnotations;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleAnnotations;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleParameterAnnotations;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisAnnos;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisParamAnnos;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisAnnos;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisParamAnnos;


/** /**
* Visitor with empty method bodies, can be extended and used in conjunction with the * Visitor with empty method bodies, can be extended and used in conjunction with the
* By courtesy of David Spencer. * By courtesy of David Spencer.
* *
* @see DescendingVisitor * @see DescendingVisitor
* @version $Id: EmptyClassVisitor.java,v 1.2 2008/05/28 23:53:00 aclement Exp $
* @version $Id: EmptyClassVisitor.java,v 1.3 2009/09/15 19:40:22 aclement Exp $
* *
*/ */
public class EmptyClassVisitor implements ClassVisitor { public class EmptyClassVisitor implements ClassVisitor {
// J5SUPPORT: // J5SUPPORT:
public void visitEnclosingMethod(EnclosingMethod obj) {} public void visitEnclosingMethod(EnclosingMethod obj) {}
public void visitRuntimeVisibleAnnotations(RuntimeVisibleAnnotations attribute) {}
public void visitRuntimeInvisibleAnnotations(RuntimeInvisibleAnnotations attribute) {}
public void visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations attribute) {}
public void visitRuntimeInvisibleParameterAnnotations(RuntimeInvisibleParameterAnnotations attribute) {}
public void visitRuntimeVisibleAnnotations(RuntimeVisAnnos attribute) {}
public void visitRuntimeInvisibleAnnotations(RuntimeInvisAnnos attribute) {}
public void visitRuntimeVisibleParameterAnnotations(RuntimeVisParamAnnos attribute) {}
public void visitRuntimeInvisibleParameterAnnotations(RuntimeInvisParamAnnos attribute) {}
public void visitAnnotationDefault(AnnotationDefault attribute) {} public void visitAnnotationDefault(AnnotationDefault attribute) {}
public void visitLocalVariableTypeTable(LocalVariableTypeTable obj) {} public void visitLocalVariableTypeTable(LocalVariableTypeTable obj) {}

+ 9
- 9
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/StringRepresentation.java View File

import org.aspectj.apache.bcel.classfile.StackMap; import org.aspectj.apache.bcel.classfile.StackMap;
import org.aspectj.apache.bcel.classfile.Synthetic; import org.aspectj.apache.bcel.classfile.Synthetic;
import org.aspectj.apache.bcel.classfile.Unknown; import org.aspectj.apache.bcel.classfile.Unknown;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisibleAnnotations;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisibleParameterAnnotations;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleAnnotations;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleParameterAnnotations;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisAnnos;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisParamAnnos;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisAnnos;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisParamAnnos;
import org.aspectj.apache.bcel.verifier.exc.AssertionViolatedException; import org.aspectj.apache.bcel.verifier.exc.AssertionViolatedException;


/** /**
* Note that this class also serves as a placeholder for more sophisticated message * Note that this class also serves as a placeholder for more sophisticated message
* handling in future versions of JustIce. * handling in future versions of JustIce.
* *
* @version $Id: StringRepresentation.java,v 1.3 2008/08/28 00:02:14 aclement Exp $
* @version $Id: StringRepresentation.java,v 1.4 2009/09/15 19:40:22 aclement Exp $
* @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A> * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/ */
public class StringRepresentation extends org.aspectj.apache.bcel.verifier.EmptyClassVisitor{ public class StringRepresentation extends org.aspectj.apache.bcel.verifier.EmptyClassVisitor{
tostring = toString(obj); tostring = toString(obj);
} }


public void visitRuntimeVisibleAnnotations(RuntimeVisibleAnnotations obj) {tostring = toString(obj);}
public void visitRuntimeInvisibleAnnotations(RuntimeInvisibleAnnotations obj) {tostring = toString(obj);}
public void visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations obj) {tostring = toString(obj);}
public void visitRuntimeInvisibleParameterAnnotations(RuntimeInvisibleParameterAnnotations obj) {tostring = toString(obj);}
public void visitRuntimeVisibleAnnotations(RuntimeVisAnnos obj) {tostring = toString(obj);}
public void visitRuntimeInvisibleAnnotations(RuntimeInvisAnnos obj) {tostring = toString(obj);}
public void visitRuntimeVisibleParameterAnnotations(RuntimeVisParamAnnos obj) {tostring = toString(obj);}
public void visitRuntimeInvisibleParameterAnnotations(RuntimeInvisParamAnnos obj) {tostring = toString(obj);}
public void visitAnnotationDefault(AnnotationDefault obj) {tostring = toString(obj);} public void visitAnnotationDefault(AnnotationDefault obj) {tostring = toString(obj);}
public void visitLocalVariableTypeTable(LocalVariableTypeTable obj) {tostring = toString(obj);} public void visitLocalVariableTypeTable(LocalVariableTypeTable obj) {tostring = toString(obj);}

Loading…
Cancel
Save