summaryrefslogtreecommitdiffstats
path: root/bcel-builder
diff options
context:
space:
mode:
authoraclement <aclement>2009-09-15 19:40:09 +0000
committeraclement <aclement>2009-09-15 19:40:09 +0000
commit7c89067090cc77b93ed9936919e9439b0aa336e2 (patch)
tree4b77457ff4249d09afcd3fdd9042836d82f3e61f /bcel-builder
parent23357ade788be1f2231b17a934e97a7b340ae697 (diff)
downloadaspectj-7c89067090cc77b93ed9936919e9439b0aa336e2.tar.gz
aspectj-7c89067090cc77b93ed9936919e9439b0aa336e2.zip
refactoring
Diffstat (limited to 'bcel-builder')
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/AnnotationDefault.java10
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/Attribute.java63
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/AttributeUtils.java11
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/ClassVisitor.java18
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/Code.java637
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantValue.java22
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/Deprecated.java218
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/ExceptionTable.java283
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/FieldOrMethod.java8
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/InnerClasses.java240
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/JavaClass.java8
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/LineNumberTable.java25
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/LocalVariableTable.java28
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/LocalVariableTypeTable.java179
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/Method.java18
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/Signature.java16
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/SourceFile.java12
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/StackMap.java253
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/Synthetic.java245
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/Unknown.java22
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/Utility.java36
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/AnnotationElementValue.java55
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/AnnotationElementValueGen.java61
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/AnnotationGen.java26
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ArrayElementValue.java84
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ArrayElementValueGen.java93
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ClassElementValue.java (renamed from bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ClassElementValueGen.java)12
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ElementValue.java135
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ElementValueGen.java140
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/EnumElementValue.java (renamed from bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/EnumElementValueGen.java)16
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/NameValuePair.java (renamed from bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ElementNameValuePairGen.java)14
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeAnnos.java (renamed from bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeAnnotations.java)48
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeInvisAnnos.java (renamed from bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeInvisibleAnnotations.java)8
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeInvisParamAnnos.java (renamed from bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeInvisibleParameterAnnotations.java)8
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeParamAnnos.java (renamed from bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeParameterAnnotations.java)6
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeVisAnnos.java (renamed from bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeVisibleAnnotations.java)8
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeVisParamAnnos.java (renamed from bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeVisibleParameterAnnotations.java)8
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/SimpleElementValue.java (renamed from bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/SimpleElementValueGen.java)67
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/generic/ClassGen.java14
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/generic/FieldGen.java8
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/generic/FieldGenOrMethodGen.java6
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/generic/MethodGen.java18
42 files changed, 1576 insertions, 1611 deletions
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/AnnotationDefault.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/AnnotationDefault.java
index 53cf1c33d..bd5a7251f 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/AnnotationDefault.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/AnnotationDefault.java
@@ -17,7 +17,7 @@ import java.io.DataOutputStream;
import java.io.IOException;
import org.aspectj.apache.bcel.Constants;
-import org.aspectj.apache.bcel.classfile.annotation.ElementValueGen;
+import org.aspectj.apache.bcel.classfile.annotation.ElementValue;
/**
* This attribute is attached to a method and indicates the default
@@ -25,13 +25,13 @@ import org.aspectj.apache.bcel.classfile.annotation.ElementValueGen;
*/
public class AnnotationDefault extends Attribute {
- private ElementValueGen value;
+ private ElementValue value;
public AnnotationDefault(int nameIndex, int len, DataInputStream dis, ConstantPool cpool) throws IOException {
- this(nameIndex, len, ElementValueGen.readElementValue(dis,cpool), cpool);
+ this(nameIndex, len, ElementValue.readElementValue(dis,cpool), cpool);
}
- private AnnotationDefault(int nameIndex, int len, ElementValueGen value, ConstantPool cpool) {
+ private AnnotationDefault(int nameIndex, int len, ElementValue value, ConstantPool cpool) {
super(Constants.ATTR_ANNOTATION_DEFAULT, nameIndex, len, cpool);
this.value = value;
}
@@ -42,7 +42,7 @@ public class AnnotationDefault extends Attribute {
// return (EnclosingMethod)clone();
}
- public final ElementValueGen getElementValue() { return value; }
+ public final ElementValue getElementValue() { return value; }
public final void dump(DataOutputStream dos) throws IOException {
super.dump(dos);
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Attribute.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Attribute.java
index 3f730f217..aefa0ed44 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Attribute.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Attribute.java
@@ -60,17 +60,17 @@ import java.io.IOException;
import java.io.Serializable;
import org.aspectj.apache.bcel.Constants;
-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;
/**
* Abstract super class for <em>Attribute</em> objects. Currently the <em>ConstantValue</em>, <em>SourceFile</em>, <em>Code</em>,
* <em>Exceptiontable</em>, <em>LineNumberTable</em>, <em>LocalVariableTable</em>, <em>InnerClasses</em> and <em>Synthetic</em>
* attributes are supported. The <em>Unknown</em> attribute stands for non-standard-attributes.
*
- * @version $Id: Attribute.java,v 1.6 2009/09/10 15:35:05 aclement Exp $
+ * @version $Id: Attribute.java,v 1.7 2009/09/15 19:40:12 aclement Exp $
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
* @see ConstantValue
* @see SourceFile
@@ -143,13 +143,13 @@ public abstract class Attribute implements Cloneable, Node, Serializable {
case Constants.ATTR_STACK_MAP:
return new StackMap(idx, len, file, cpool);
case Constants.ATTR_RUNTIME_VISIBLE_ANNOTATIONS:
- return new RuntimeVisibleAnnotations(idx, len, file, cpool);
+ return new RuntimeVisAnnos(idx, len, file, cpool);
case Constants.ATTR_RUNTIME_INVISIBLE_ANNOTATIONS:
- return new RuntimeInvisibleAnnotations(idx, len, file, cpool);
+ return new RuntimeInvisAnnos(idx, len, file, cpool);
case Constants.ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS:
- return new RuntimeVisibleParameterAnnotations(idx, len, file, cpool);
+ return new RuntimeVisParamAnnos(idx, len, file, cpool);
case Constants.ATTR_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS:
- return new RuntimeInvisibleParameterAnnotations(idx, len, file, cpool);
+ return new RuntimeInvisParamAnnos(idx, len, file, cpool);
case Constants.ATTR_ANNOTATION_DEFAULT:
return new AnnotationDefault(idx, len, file, cpool);
case Constants.ATTR_LOCAL_VARIABLE_TYPE_TABLE:
@@ -181,28 +181,29 @@ public abstract class Attribute implements Cloneable, Node, Serializable {
return cpool;
}
- /**
- * Use copy() if you want to have a deep copy(), ie. with all references copied correctly.
- *
- * @return shallow copy of this attribute
- */
- @Override
- public Object clone() {
- Object o = null;
-
- try {
- o = super.clone();
- } catch (CloneNotSupportedException e) {
- e.printStackTrace(); // Never occurs
- }
-
- return o;
- }
-
- /**
- * @return deep copy of this attribute
- */
- public abstract Attribute copy(ConstantPool constant_pool);
+ // /**
+ // * Use copy() if you want to have a deep copy(), ie. with all references copied correctly.
+ // *
+ // * @return shallow copy of this attribute
+ // */
+ // @Override
+ // public Object clone() {
+ // Object o = null;
+ //
+ // try {
+ // o = super.clone();
+ // } catch (CloneNotSupportedException e) {
+ // e.printStackTrace(); // Never occurs
+ // }
+ //
+ // return o;
+ // }
+
+ //
+ // /**
+ // * @return deep copy of this attribute
+ // */
+ // public abstract Attribute copy(ConstantPool constant_pool);
@Override
public String toString() {
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/AttributeUtils.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/AttributeUtils.java
index c2f7ed1c0..45d1597a7 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/AttributeUtils.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/AttributeUtils.java
@@ -36,17 +36,6 @@ public class AttributeUtils {
}
}
- public static Attribute[] copy(Attribute[] attributes, ConstantPool constant_pool) {
- if (attributes == null || attributes.length == 0) {
- return Attribute.NoAttributes;
- }
- Attribute[] attrs = new Attribute[attributes.length];
- for (int i = 0; i < attributes.length; i++) {
- attrs[i] = attributes[i].copy(constant_pool);
- }
- return attrs;
- }
-
public static Signature getSignatureAttribute(Attribute[] attributes) {
for (int i = 0; i < attributes.length; i++) {
if (attributes[i].tag == Constants.ATTR_SIGNATURE) {
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ClassVisitor.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ClassVisitor.java
index 9513e02f9..0957bfba8 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ClassVisitor.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ClassVisitor.java
@@ -1,9 +1,9 @@
package org.aspectj.apache.bcel.classfile;
-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;
/* ====================================================================
* The Apache Software License, Version 1.1
@@ -65,7 +65,7 @@ import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleParameterAnnot
*
* Implemented by wish of <A HREF="http://www.inf.fu-berlin.de/~bokowski">Boris Bokowski</A>.
*
- * @version $Id: ClassVisitor.java,v 1.3 2009/09/10 03:59:33 aclement Exp $
+ * @version $Id: ClassVisitor.java,v 1.4 2009/09/15 19:40:13 aclement Exp $
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
*/
public interface ClassVisitor {
@@ -135,13 +135,13 @@ public interface ClassVisitor {
public void visitEnclosingMethod(EnclosingMethod obj);
- public void visitRuntimeVisibleAnnotations(RuntimeVisibleAnnotations obj);
+ public void visitRuntimeVisibleAnnotations(RuntimeVisAnnos obj);
- public void visitRuntimeInvisibleAnnotations(RuntimeInvisibleAnnotations obj);
+ public void visitRuntimeInvisibleAnnotations(RuntimeInvisAnnos obj);
- public void visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations obj);
+ public void visitRuntimeVisibleParameterAnnotations(RuntimeVisParamAnnos obj);
- public void visitRuntimeInvisibleParameterAnnotations(RuntimeInvisibleParameterAnnotations obj);
+ public void visitRuntimeInvisibleParameterAnnotations(RuntimeInvisParamAnnos obj);
public void visitAnnotationDefault(AnnotationDefault obj);
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Code.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Code.java
index 237b80029..fb96fbe5f 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Code.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Code.java
@@ -54,325 +54,324 @@ package org.aspectj.apache.bcel.classfile;
* <http://www.apache.org/>.
*/
-import org.aspectj.apache.bcel.Constants;
-import java.io.*;
-
-/**
- * This class represents a chunk of Java byte code contained in a
- * method. It is instantiated by the
- * <em>Attribute.readAttribute()</em> method. A <em>Code</em>
- * attribute contains informations about operand stack, local
- * variables, byte code and the exceptions handled within this
- * method.
- *
- * This attribute has attributes itself, namely <em>LineNumberTable</em> which
- * is used for debugging purposes and <em>LocalVariableTable</em> which
- * contains information about the local variables.
- *
- * @version $Id: Code.java,v 1.7 2009/09/10 15:35:05 aclement Exp $
- * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
- * @see Attribute
- * @see CodeException
- * @see LineNumberTable
- * @see LocalVariableTable
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import org.aspectj.apache.bcel.Constants;
+
+/**
+ * This class represents a chunk of Java byte code contained in a method. It is instantiated by the
+ * <em>Attribute.readAttribute()</em> method. A <em>Code</em> attribute contains informations about operand stack, local variables,
+ * byte code and the exceptions handled within this method.
+ *
+ * This attribute has attributes itself, namely <em>LineNumberTable</em> which is used for debugging purposes and
+ * <em>LocalVariableTable</em> which contains information about the local variables.
+ *
+ * @version $Id: Code.java,v 1.8 2009/09/15 19:40:12 aclement Exp $
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Attribute
+ * @see CodeException
+ * @see LineNumberTable
+ * @see LocalVariableTable
*/
public final class Code extends Attribute {
- private int maxStack; // Maximum size of stack used by this method
- private int maxLocals; // Number of local variables
- private byte[] code; // Actual byte code
- private CodeException[] exceptionTable;
- private Attribute[] attributes;
- private static final CodeException[] NO_EXCEPTIONS = new CodeException[]{};
-
- /**
- * Initialize from another object. Note that both objects use the same
- * references (shallow copy). Use copy() for a physical copy.
- */
- public Code(Code c) {
- this(c.getNameIndex(), c.getLength(), c.getMaxStack(), c.getMaxLocals(),
- c.getCode(), c.getExceptionTable(), c.getAttributes(),
- c.getConstantPool());
- }
-
-
- Code(int name_index, int length, DataInputStream file, ConstantPool constant_pool) throws IOException {
- // Initialize with some default values which will be overwritten later
- this(name_index, length,
- file.readUnsignedShort(), file.readUnsignedShort(),
- (byte[])null, (CodeException[])null, (Attribute[])null,
- constant_pool);
-
- int len = file.readInt();
- code = new byte[len]; // Read byte code
- file.readFully(code);
-
- /* Read exception table that contains all regions where an exception
- * handler is active, i.e., a try { ... } catch() block.
- */
- len = file.readUnsignedShort();
- if (len==0) {
- exceptionTable = NO_EXCEPTIONS;
- } else {
- exceptionTable = new CodeException[len];
- for(int i=0; i < len; i++)
- exceptionTable[i] = new CodeException(file);
- }
-
- // Read all attributes, eg: LineNumberTable, LocalVariableTable
- attributes = AttributeUtils.readAttributes(file,constant_pool);
-
- /* Adjust length, because of setAttributes in this(), s.b. length
- * is incorrect, because it didn't take the internal attributes
- * into account yet! Very subtle bug, fixed in 3.1.1.
- */
- this.length = length;
- }
-
- /**
- * @param name_index Index pointing to the name <em>Code</em>
- * @param length Content length in bytes
- * @param max_stack Maximum size of stack
- * @param max_locals Number of local variables
- * @param code Actual byte code
- * @param exception_table Table of handled exceptions
- * @param attributes Attributes of code: LineNumber or LocalVariable
- * @param constant_pool Array of constants
- */
- public Code(int name_index, int length,
- int max_stack, int max_locals,
- byte[] code,
- CodeException[] exception_table,
- Attribute[] attributes,
- ConstantPool constant_pool)
- {
- super(Constants.ATTR_CODE, name_index, length, constant_pool);
-
- this.maxStack = max_stack;
- this.maxLocals = max_locals;
-
- setCode(code);
- setExceptionTable(exception_table);
- setAttributes(attributes); // Overwrites length!
- }
-
- /**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept(ClassVisitor v) {
- v.visitCode(this);
- }
-
- /**
- * Dump code attribute to file stream in binary format.
- *
- * @param file Output file stream
- * @throws IOException
- */
- public final void dump(DataOutputStream file) throws IOException
- {
- super.dump(file);
-
- file.writeShort(maxStack);
- file.writeShort(maxLocals);
- file.writeInt(code.length);
- file.write(code, 0, code.length);
-
- file.writeShort(exceptionTable.length);
- for(int i=0; i < exceptionTable.length; i++)
- exceptionTable[i].dump(file);
-
- file.writeShort(attributes.length);
- for(int i=0; i < attributes.length; i++)
- attributes[i].dump(file);
- }
-
- /**
- * @return Collection of code attributes.
- * @see Attribute
- */
- public final Attribute[] getAttributes() { return attributes; }
-
- /**
- * @return LineNumberTable of Code, if it has one
- */
- public LineNumberTable getLineNumberTable() {
- for (int i=0; i < attributes.length; i++)
- if (attributes[i].tag==Constants.ATTR_LINE_NUMBER_TABLE) return (LineNumberTable)attributes[i];
- return null;
- }
-
- /**
- * @return LocalVariableTable of Code, if it has one
- */
- public LocalVariableTable getLocalVariableTable() {
- for(int i=0; i < attributes.length; i++)
- if (attributes[i].tag==Constants.ATTR_LOCAL_VARIABLE_TABLE) return (LocalVariableTable)attributes[i];
- return null;
- }
-
- /**
- * @return Actual byte code of the method.
- */
- public final byte[] getCode() { return code; }
-
- /**
- * @return Table of handled exceptions.
- * @see CodeException
- */
- public final CodeException[] getExceptionTable() { return exceptionTable; }
-
- /**
- * @return Number of local variables.
- */
- public final int getMaxLocals() { return maxLocals; }
-
- /**
- * @return Maximum size of stack used by this method.
- */
-
- public final int getMaxStack() { return maxStack; }
-
- /**
- * @return the internal length of this code attribute (minus the first 6 bytes)
- * and excluding all its attributes
- */
- private final int getInternalLength() {
- return 2 /*max_stack*/ + 2 /*max_locals*/ + 4 /*code length*/
- + (code==null?0:code.length) /*byte-code*/
- + 2 /*exception-table length*/
- + 8 * (exceptionTable==null?0:exceptionTable.length) /* exception table */
- + 2 /* attributes count */;
- }
-
- /**
- * @return the full size of this code attribute, minus its first 6 bytes,
- * including the size of all its contained attributes
- */
- private final int calculateLength() {
- int len = 0;
- if (attributes!=null) {
- for(int i=0; i < attributes.length; i++)
- len += attributes[i].length + 6 /*attribute header size*/;
- }
- return len + getInternalLength();
- }
-
- /**
- * @param attributes.
- */
- public final void setAttributes(Attribute[] attributes) {
- this.attributes = attributes;
- length = calculateLength(); // Adjust length
- }
-
- /**
- * @param code byte code
- */
- public final void setCode(byte[] code) {
- this.code = code;
- }
-
- /**
- * @param exception_table exception table
- */
- public final void setExceptionTable(CodeException[] exception_table) {
- this.exceptionTable = exception_table;
- }
-
- /**
- * @param max_locals maximum number of local variables
- */
- public final void setMaxLocals(int max_locals) {
- this.maxLocals = max_locals;
- }
-
- /**
- * @param max_stack maximum stack size
- */
- public final void setMaxStack(int max_stack) {
- this.maxStack = max_stack;
- }
-
- /**
- * @return String representation of code chunk.
- */
- public final String toString(boolean verbose) {
- StringBuffer buf;
-
- buf = new StringBuffer("Code(max_stack = " + maxStack +
- ", max_locals = " + maxLocals +
- ", code_length = " + code.length + ")\n" +
- Utility.codeToString(code, cpool, 0, -1, verbose));
-
- if(exceptionTable.length > 0) {
- buf.append("\nException handler(s) = \n" + "From\tTo\tHandler\tType\n");
-
- for(int i=0; i < exceptionTable.length; i++)
- buf.append(exceptionTable[i].toString(cpool, verbose) + "\n");
- }
-
- if(attributes.length > 0) {
- buf.append("\nAttribute(s) = \n");
-
- for(int i=0; i < attributes.length; i++)
- buf.append(attributes[i].toString() + "\n");
- }
-
- return buf.toString();
- }
-
- /**
- * @return String representation of code chunk.
- */
- public final String toString() {
- return toString(true);
- }
-
- /**
- * @return deep copy of this attribute
- */
- public Attribute copy(ConstantPool constant_pool) {
- Code c = (Code)clone();
- c.code = (byte[])code.clone();
- c.cpool = constant_pool;
-
- c.exceptionTable = new CodeException[exceptionTable.length];
- for(int i=0; i < exceptionTable.length; i++)
- c.exceptionTable[i] = exceptionTable[i].copy();
-
- c.attributes = new Attribute[attributes.length];
- for(int i=0; i < attributes.length; i++)
- c.attributes[i] = attributes[i].copy(constant_pool);
-
- return c;
- }
-
- /**
- * Returns the same as toString(true) except that the attribute information
- * isn't included (line numbers).
- * Can be used to check whether two pieces of code are equivalent.
- */
- public String getCodeString() {
- StringBuffer codeString = new StringBuffer();
- codeString.append("Code(max_stack = ").append(maxStack);
- codeString.append(", max_locals = ").append(maxLocals);
- codeString.append(", code_length = ").append(code.length).append(")\n");
- codeString.append(Utility.codeToString(code, cpool, 0, -1,true));
- if (exceptionTable.length>0) {
- codeString.append("\n").append("Exception entries = ").append(exceptionTable.length).append("\n");
- for (int i = 0; i < exceptionTable.length; i++) {
- CodeException exc = exceptionTable[i];
- int type = exc.getCatchType();
- String name = "finally";
- if (type!=0) name = this.cpool.getConstantString(type,Constants.CONSTANT_Class);
- codeString.append(name).append("[");
- codeString.append(exc.getStartPC()).append(">").append(exc.getEndPC()).append("]\n");
- }
- }
- return codeString.toString();
- }
+ private int maxStack; // Maximum size of stack used by this method
+ private int maxLocals; // Number of local variables
+ private byte[] code; // Actual byte code
+ private CodeException[] exceptionTable;
+ private Attribute[] attributes;
+ private static final CodeException[] NO_EXCEPTIONS = new CodeException[] {};
+
+ /**
+ * Initialize from another object. Note that both objects use the same references (shallow copy). Use copy() for a physical
+ * copy.
+ */
+ public Code(Code c) {
+ this(c.getNameIndex(), c.getLength(), c.getMaxStack(), c.getMaxLocals(), c.getCode(), c.getExceptionTable(), c
+ .getAttributes(), c.getConstantPool());
+ }
+
+ Code(int name_index, int length, DataInputStream file, ConstantPool constant_pool) throws IOException {
+ // Initialize with some default values which will be overwritten later
+ this(name_index, length, file.readUnsignedShort(), file.readUnsignedShort(), (byte[]) null, (CodeException[]) null,
+ (Attribute[]) null, constant_pool);
+
+ int len = file.readInt();
+ code = new byte[len]; // Read byte code
+ file.readFully(code);
+
+ /*
+ * Read exception table that contains all regions where an exception handler is active, i.e., a try { ... } catch() block.
+ */
+ len = file.readUnsignedShort();
+ if (len == 0) {
+ exceptionTable = NO_EXCEPTIONS;
+ } else {
+ exceptionTable = new CodeException[len];
+ for (int i = 0; i < len; i++)
+ exceptionTable[i] = new CodeException(file);
+ }
+
+ // Read all attributes, eg: LineNumberTable, LocalVariableTable
+ attributes = AttributeUtils.readAttributes(file, constant_pool);
+
+ /*
+ * Adjust length, because of setAttributes in this(), s.b. length is incorrect, because it didn't take the internal
+ * attributes into account yet! Very subtle bug, fixed in 3.1.1.
+ */
+ this.length = length;
+ }
+
+ /**
+ * @param name_index Index pointing to the name <em>Code</em>
+ * @param length Content length in bytes
+ * @param max_stack Maximum size of stack
+ * @param max_locals Number of local variables
+ * @param code Actual byte code
+ * @param exception_table Table of handled exceptions
+ * @param attributes Attributes of code: LineNumber or LocalVariable
+ * @param constant_pool Array of constants
+ */
+ public Code(int name_index, int length, int max_stack, int max_locals, byte[] code, CodeException[] exception_table,
+ Attribute[] attributes, ConstantPool constant_pool) {
+ super(Constants.ATTR_CODE, name_index, length, constant_pool);
+
+ this.maxStack = max_stack;
+ this.maxLocals = max_locals;
+
+ setCode(code);
+ setExceptionTable(exception_table);
+ setAttributes(attributes); // Overwrites length!
+ }
+
+ /**
+ * Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class. I.e., the
+ * hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
+ *
+ * @param v Visitor object
+ */
+ @Override
+ public void accept(ClassVisitor v) {
+ v.visitCode(this);
+ }
+
+ /**
+ * Dump code attribute to file stream in binary format.
+ *
+ * @param file Output file stream
+ * @throws IOException
+ */
+ @Override
+ public final void dump(DataOutputStream file) throws IOException {
+ super.dump(file);
+
+ file.writeShort(maxStack);
+ file.writeShort(maxLocals);
+ file.writeInt(code.length);
+ file.write(code, 0, code.length);
+
+ file.writeShort(exceptionTable.length);
+ for (int i = 0; i < exceptionTable.length; i++)
+ exceptionTable[i].dump(file);
+
+ file.writeShort(attributes.length);
+ for (int i = 0; i < attributes.length; i++)
+ attributes[i].dump(file);
+ }
+
+ /**
+ * @return Collection of code attributes.
+ * @see Attribute
+ */
+ public final Attribute[] getAttributes() {
+ return attributes;
+ }
+
+ /**
+ * @return LineNumberTable of Code, if it has one
+ */
+ public LineNumberTable getLineNumberTable() {
+ for (int i = 0; i < attributes.length; i++)
+ if (attributes[i].tag == Constants.ATTR_LINE_NUMBER_TABLE)
+ return (LineNumberTable) attributes[i];
+ return null;
+ }
+
+ /**
+ * @return LocalVariableTable of Code, if it has one
+ */
+ public LocalVariableTable getLocalVariableTable() {
+ for (int i = 0; i < attributes.length; i++)
+ if (attributes[i].tag == Constants.ATTR_LOCAL_VARIABLE_TABLE)
+ return (LocalVariableTable) attributes[i];
+ return null;
+ }
+
+ /**
+ * @return Actual byte code of the method.
+ */
+ public final byte[] getCode() {
+ return code;
+ }
+
+ /**
+ * @return Table of handled exceptions.
+ * @see CodeException
+ */
+ public final CodeException[] getExceptionTable() {
+ return exceptionTable;
+ }
+
+ /**
+ * @return Number of local variables.
+ */
+ public final int getMaxLocals() {
+ return maxLocals;
+ }
+
+ /**
+ * @return Maximum size of stack used by this method.
+ */
+
+ public final int getMaxStack() {
+ return maxStack;
+ }
+
+ /**
+ * @return the internal length of this code attribute (minus the first 6 bytes) and excluding all its attributes
+ */
+ private final int getInternalLength() {
+ return 2 /* max_stack */+ 2 /* max_locals */+ 4 /* code length */
+ + (code == null ? 0 : code.length) /* byte-code */
+ + 2 /* exception-table length */
+ + 8 * (exceptionTable == null ? 0 : exceptionTable.length) /* exception table */
+ + 2 /* attributes count */;
+ }
+
+ /**
+ * @return the full size of this code attribute, minus its first 6 bytes, including the size of all its contained attributes
+ */
+ private final int calculateLength() {
+ int len = 0;
+ if (attributes != null) {
+ for (int i = 0; i < attributes.length; i++)
+ len += attributes[i].length + 6 /* attribute header size */;
+ }
+ return len + getInternalLength();
+ }
+
+ /**
+ * @param attributes.
+ */
+ public final void setAttributes(Attribute[] attributes) {
+ this.attributes = attributes;
+ length = calculateLength(); // Adjust length
+ }
+
+ /**
+ * @param code byte code
+ */
+ public final void setCode(byte[] code) {
+ this.code = code;
+ }
+
+ /**
+ * @param exception_table exception table
+ */
+ public final void setExceptionTable(CodeException[] exception_table) {
+ this.exceptionTable = exception_table;
+ }
+
+ /**
+ * @param max_locals maximum number of local variables
+ */
+ public final void setMaxLocals(int max_locals) {
+ this.maxLocals = max_locals;
+ }
+
+ /**
+ * @param max_stack maximum stack size
+ */
+ public final void setMaxStack(int max_stack) {
+ this.maxStack = max_stack;
+ }
+
+ /**
+ * @return String representation of code chunk.
+ */
+ public final String toString(boolean verbose) {
+ StringBuffer buf;
+
+ buf = new StringBuffer("Code(max_stack = " + maxStack + ", max_locals = " + maxLocals + ", code_length = " + code.length
+ + ")\n" + Utility.codeToString(code, cpool, 0, -1, verbose));
+
+ if (exceptionTable.length > 0) {
+ buf.append("\nException handler(s) = \n" + "From\tTo\tHandler\tType\n");
+
+ for (int i = 0; i < exceptionTable.length; i++)
+ buf.append(exceptionTable[i].toString(cpool, verbose) + "\n");
+ }
+
+ if (attributes.length > 0) {
+ buf.append("\nAttribute(s) = \n");
+
+ for (int i = 0; i < attributes.length; i++)
+ buf.append(attributes[i].toString() + "\n");
+ }
+
+ return buf.toString();
+ }
+
+ /**
+ * @return String representation of code chunk.
+ */
+ @Override
+ public final String toString() {
+ return toString(true);
+ }
+
+ // /**
+ // * @return deep copy of this attribute
+ // */
+ // public Attribute copy(ConstantPool constant_pool) {
+ // Code c = (Code)clone();
+ // c.code = (byte[])code.clone();
+ // c.cpool = constant_pool;
+ //
+ // c.exceptionTable = new CodeException[exceptionTable.length];
+ // for(int i=0; i < exceptionTable.length; i++)
+ // c.exceptionTable[i] = exceptionTable[i].copy();
+ //
+ // c.attributes = new Attribute[attributes.length];
+ // for(int i=0; i < attributes.length; i++)
+ // c.attributes[i] = attributes[i].copy(constant_pool);
+ //
+ // return c;
+ // }
+
+ /**
+ * Returns the same as toString(true) except that the attribute information isn't included (line numbers). Can be used to check
+ * whether two pieces of code are equivalent.
+ */
+ public String getCodeString() {
+ StringBuffer codeString = new StringBuffer();
+ codeString.append("Code(max_stack = ").append(maxStack);
+ codeString.append(", max_locals = ").append(maxLocals);
+ codeString.append(", code_length = ").append(code.length).append(")\n");
+ codeString.append(Utility.codeToString(code, cpool, 0, -1, true));
+ if (exceptionTable.length > 0) {
+ codeString.append("\n").append("Exception entries = ").append(exceptionTable.length).append("\n");
+ for (int i = 0; i < exceptionTable.length; i++) {
+ CodeException exc = exceptionTable[i];
+ int type = exc.getCatchType();
+ String name = "finally";
+ if (type != 0)
+ name = this.cpool.getConstantString(type, Constants.CONSTANT_Class);
+ codeString.append(name).append("[");
+ codeString.append(exc.getStartPC()).append(">").append(exc.getEndPC()).append("]\n");
+ }
+ }
+ return codeString.toString();
+ }
}
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantValue.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantValue.java
index c07ddcc62..67cc0851e 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantValue.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantValue.java
@@ -64,7 +64,7 @@ import org.aspectj.apache.bcel.Constants;
* This class is derived from <em>Attribute</em> and represents a constant value, i.e., a default value for initializing a class
* field. This class is instantiated by the <em>Attribute.readAttribute()</em> method.
*
- * @version $Id: ConstantValue.java,v 1.4 2009/09/10 15:35:04 aclement Exp $
+ * @version $Id: ConstantValue.java,v 1.5 2009/09/15 19:40:12 aclement Exp $
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
* @see Attribute
*/
@@ -176,14 +176,14 @@ public final class ConstantValue extends Attribute {
return buf;
}
-
- /**
- * @return deep copy of this attribute
- */
- @Override
- public Attribute copy(ConstantPool constant_pool) {
- ConstantValue c = (ConstantValue) clone();
- c.cpool = constant_pool;
- return c;
- }
+ //
+ // /**
+ // * @return deep copy of this attribute
+ // */
+ // @Override
+ // public Attribute copy(ConstantPool constant_pool) {
+ // ConstantValue c = (ConstantValue) clone();
+ // c.cpool = constant_pool;
+ // return c;
+ // }
}
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Deprecated.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Deprecated.java
index f3cc4e32c..21bbbcb46 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Deprecated.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Deprecated.java
@@ -54,116 +54,118 @@ package org.aspectj.apache.bcel.classfile;
* <http://www.apache.org/>.
*/
-import org.aspectj.apache.bcel.Constants;
-import java.io.*;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import org.aspectj.apache.bcel.Constants;
/**
- * This class is derived from <em>Attribute</em> and denotes that this is a
- * deprecated method.
- * It is instantiated from the <em>Attribute.readAttribute()</em> method.
- *
- * @version $Id: Deprecated.java,v 1.4 2009/09/10 15:35:04 aclement Exp $
- * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
- * @see Attribute
+ * This class is derived from <em>Attribute</em> and denotes that this is a deprecated method. It is instantiated from the
+ * <em>Attribute.readAttribute()</em> method.
+ *
+ * @version $Id: Deprecated.java,v 1.5 2009/09/15 19:40:12 aclement Exp $
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Attribute
*/
public final class Deprecated extends Attribute {
- private byte[] bytes;
-
- /**
- * Initialize from another object. Note that both objects use the same
- * references (shallow copy). Use clone() for a physical copy.
- */
- public Deprecated(Deprecated c) {
- this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool());
- }
-
- /**
- * @param name_index Index in constant pool to CONSTANT_Utf8
- * @param length Content length in bytes
- * @param bytes Attribute contents
- * @param constant_pool Array of constants
- */
- public Deprecated(int name_index, int length, byte[] bytes,
- ConstantPool constant_pool)
- {
- super(Constants.ATTR_DEPRECATED, name_index, length, constant_pool);
- this.bytes = bytes;
- }
-
- /**
- * Construct object from file stream.
- * @param name_index Index in constant pool to CONSTANT_Utf8
- * @param length Content length in bytes
- * @param file Input stream
- * @param constant_pool Array of constants
- * @throws IOException
- */
- Deprecated(int name_index, int length, DataInputStream file,
- ConstantPool constant_pool) throws IOException
- {
- this(name_index, length, (byte [])null, constant_pool);
-
- if(length > 0) {
- bytes = new byte[length];
- file.readFully(bytes);
- System.err.println("Deprecated attribute with length > 0");
- }
- }
-
- /**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept(ClassVisitor v) {
- v.visitDeprecated(this);
- }
-
- /**
- * Dump source file attribute to file stream in binary format.
- *
- * @param file Output file stream
- * @throws IOException
- */
- public final void dump(DataOutputStream file) throws IOException
- {
- super.dump(file);
-
- if(length > 0)
- file.write(bytes, 0, length);
- }
-
- /**
- * @return data bytes.
- */
- public final byte[] getBytes() { return bytes; }
-
- /**
- * @param bytes.
- */
- public final void setBytes(byte[] bytes) {
- this.bytes = bytes;
- }
-
- /**
- * @return attribute name
- */
- public final String toString() {
- return Constants.ATTRIBUTE_NAMES[Constants.ATTR_DEPRECATED];
- }
-
- /**
- * @return deep copy of this attribute
- */
- public Attribute copy(ConstantPool constant_pool) {
- Deprecated c = (Deprecated)clone();
-
- if(bytes != null)
- c.bytes = (byte[])bytes.clone();
-
- c.cpool = constant_pool;
- return c;
- }
+ private byte[] bytes;
+
+ /**
+ * Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a physical
+ * copy.
+ */
+ public Deprecated(Deprecated c) {
+ this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool());
+ }
+
+ /**
+ * @param name_index Index in constant pool to CONSTANT_Utf8
+ * @param length Content length in bytes
+ * @param bytes Attribute contents
+ * @param constant_pool Array of constants
+ */
+ public Deprecated(int name_index, int length, byte[] bytes, ConstantPool constant_pool) {
+ super(Constants.ATTR_DEPRECATED, name_index, length, constant_pool);
+ this.bytes = bytes;
+ }
+
+ /**
+ * Construct object from file stream.
+ *
+ * @param name_index Index in constant pool to CONSTANT_Utf8
+ * @param length Content length in bytes
+ * @param file Input stream
+ * @param constant_pool Array of constants
+ * @throws IOException
+ */
+ Deprecated(int name_index, int length, DataInputStream file, ConstantPool constant_pool) throws IOException {
+ this(name_index, length, (byte[]) null, constant_pool);
+
+ if (length > 0) {
+ bytes = new byte[length];
+ file.readFully(bytes);
+ System.err.println("Deprecated attribute with length > 0");
+ }
+ }
+
+ /**
+ * Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class. I.e., the
+ * hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
+ *
+ * @param v Visitor object
+ */
+ @Override
+ public void accept(ClassVisitor v) {
+ v.visitDeprecated(this);
+ }
+
+ /**
+ * Dump source file attribute to file stream in binary format.
+ *
+ * @param file Output file stream
+ * @throws IOException
+ */
+ @Override
+ public final void dump(DataOutputStream file) throws IOException {
+ super.dump(file);
+
+ if (length > 0)
+ file.write(bytes, 0, length);
+ }
+
+ /**
+ * @return data bytes.
+ */
+ public final byte[] getBytes() {
+ return bytes;
+ }
+
+ /**
+ * @param bytes.
+ */
+ public final void setBytes(byte[] bytes) {
+ this.bytes = bytes;
+ }
+
+ /**
+ * @return attribute name
+ */
+ @Override
+ public final String toString() {
+ return Constants.ATTRIBUTE_NAMES[Constants.ATTR_DEPRECATED];
+ }
+
+ // /**
+ // * @return deep copy of this attribute
+ // */
+ // public Attribute copy(ConstantPool constant_pool) {
+ // Deprecated c = (Deprecated)clone();
+ //
+ // if(bytes != null)
+ // c.bytes = (byte[])bytes.clone();
+ //
+ // c.cpool = constant_pool;
+ // return c;
+ // }
}
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ExceptionTable.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ExceptionTable.java
index a7a084cef..ad7d43f2e 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ExceptionTable.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ExceptionTable.java
@@ -54,149 +54,146 @@ package org.aspectj.apache.bcel.classfile;
* <http://www.apache.org/>.
*/
-import org.aspectj.apache.bcel.Constants;
-import java.io.*;
-
-/**
- * This class represents the table of exceptions that are thrown by a
- * method. This attribute may be used once per method. The name of
- * this class is <em>ExceptionTable</em> for historical reasons; The
- * Java Virtual Machine Specification, Second Edition defines this
- * attribute using the name <em>Exceptions</em> (which is inconsistent
- * with the other classes).
- *
- * @version $Id: ExceptionTable.java,v 1.4 2009/09/10 15:35:05 aclement Exp $
- * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
- * @see Code
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import org.aspectj.apache.bcel.Constants;
+
+/**
+ * This class represents the table of exceptions that are thrown by a method. This attribute may be used once per method. The name
+ * of this class is <em>ExceptionTable</em> for historical reasons; The Java Virtual Machine Specification, Second Edition defines
+ * this attribute using the name <em>Exceptions</em> (which is inconsistent with the other classes).
+ *
+ * @version $Id: ExceptionTable.java,v 1.5 2009/09/15 19:40:12 aclement Exp $
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Code
*/
public final class ExceptionTable extends Attribute {
- private int number_of_exceptions; // Table of indices into
- private int[] exception_index_table; // constant pool
-
- /**
- * Initialize from another object. Note that both objects use the same
- * references (shallow copy). Use copy() for a physical copy.
- */
- public ExceptionTable(ExceptionTable c) {
- this(c.getNameIndex(), c.getLength(), c.getExceptionIndexTable(),
- c.getConstantPool());
- }
-
- /**
- * @param name_index Index in constant pool
- * @param length Content length in bytes
- * @param exception_index_table Table of indices in constant pool
- * @param constant_pool Array of constants
- */
- public ExceptionTable(int name_index, int length,
- int[] exception_index_table,
- ConstantPool constant_pool)
- {
- super(Constants.ATTR_EXCEPTIONS, name_index, length, constant_pool);
- setExceptionIndexTable(exception_index_table);
- }
-
- /**
- * Construct object from file stream.
- * @param name_index Index in constant pool
- * @param length Content length in bytes
- * @param file Input stream
- * @param constant_pool Array of constants
- * @throws IOException
- */
- ExceptionTable(int name_index, int length, DataInputStream file,
- ConstantPool constant_pool) throws IOException
- {
- this(name_index, length, (int[])null, constant_pool);
-
- number_of_exceptions = file.readUnsignedShort();
- exception_index_table = new int[number_of_exceptions];
-
- for(int i=0; i < number_of_exceptions; i++)
- exception_index_table[i] = file.readUnsignedShort();
- }
-
- /**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept(ClassVisitor v) {
- v.visitExceptionTable(this);
- }
-
- /**
- * Dump exceptions attribute to file stream in binary format.
- *
- * @param file Output file stream
- * @throws IOException
- */
- public final void dump(DataOutputStream file) throws IOException
- {
- super.dump(file);
- file.writeShort(number_of_exceptions);
- for(int i=0; i < number_of_exceptions; i++)
- file.writeShort(exception_index_table[i]);
- }
-
- /**
- * @return Array of indices into constant pool of thrown exceptions.
- */
- public final int[] getExceptionIndexTable() {return exception_index_table;}
- /**
- * @return Length of exception table.
- */
- public final int getNumberOfExceptions() { return number_of_exceptions; }
-
- /**
- * @return class names of thrown exceptions
- */
- public final String[] getExceptionNames() {
- String[] names = new String[number_of_exceptions];
- for(int i=0; i < number_of_exceptions; i++)
- names[i] = cpool.getConstantString(exception_index_table[i],
- Constants.CONSTANT_Class).
- replace('/', '.');
- return names;
- }
-
- /**
- * @param exception_index_table.
- * Also redefines number_of_exceptions according to table length.
- */
- public final void setExceptionIndexTable(int[] exception_index_table) {
- this.exception_index_table = exception_index_table;
- number_of_exceptions = (exception_index_table == null)? 0 :
- exception_index_table.length;
- }
- /**
- * @return String representation, i.e., a list of thrown exceptions.
- */
- public final String toString() {
- StringBuffer buf = new StringBuffer("");
- String str;
-
- for(int i=0; i < number_of_exceptions; i++) {
- str = cpool.getConstantString(exception_index_table[i],
- Constants.CONSTANT_Class);
- buf.append(Utility.compactClassName(str, false));
-
- if(i < number_of_exceptions - 1)
- buf.append(", ");
- }
-
- return buf.toString();
- }
-
- /**
- * @return deep copy of this attribute
- */
- public Attribute copy(ConstantPool constant_pool) {
- ExceptionTable c = (ExceptionTable)clone();
- c.exception_index_table = (int[])exception_index_table.clone();
- c.cpool = constant_pool;
- return c;
- }
+ private int number_of_exceptions; // Table of indices into
+ private int[] exception_index_table; // constant pool
+
+ /**
+ * Initialize from another object. Note that both objects use the same references (shallow copy). Use copy() for a physical
+ * copy.
+ */
+ public ExceptionTable(ExceptionTable c) {
+ this(c.getNameIndex(), c.getLength(), c.getExceptionIndexTable(), c.getConstantPool());
+ }
+
+ /**
+ * @param name_index Index in constant pool
+ * @param length Content length in bytes
+ * @param exception_index_table Table of indices in constant pool
+ * @param constant_pool Array of constants
+ */
+ public ExceptionTable(int name_index, int length, int[] exception_index_table, ConstantPool constant_pool) {
+ super(Constants.ATTR_EXCEPTIONS, name_index, length, constant_pool);
+ setExceptionIndexTable(exception_index_table);
+ }
+
+ /**
+ * Construct object from file stream.
+ *
+ * @param name_index Index in constant pool
+ * @param length Content length in bytes
+ * @param file Input stream
+ * @param constant_pool Array of constants
+ * @throws IOException
+ */
+ ExceptionTable(int name_index, int length, DataInputStream file, ConstantPool constant_pool) throws IOException {
+ this(name_index, length, (int[]) null, constant_pool);
+
+ number_of_exceptions = file.readUnsignedShort();
+ exception_index_table = new int[number_of_exceptions];
+
+ for (int i = 0; i < number_of_exceptions; i++)
+ exception_index_table[i] = file.readUnsignedShort();
+ }
+
+ /**
+ * Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class. I.e., the
+ * hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
+ *
+ * @param v Visitor object
+ */
+ @Override
+ public void accept(ClassVisitor v) {
+ v.visitExceptionTable(this);
+ }
+
+ /**
+ * Dump exceptions attribute to file stream in binary format.
+ *
+ * @param file Output file stream
+ * @throws IOException
+ */
+ @Override
+ public final void dump(DataOutputStream file) throws IOException {
+ super.dump(file);
+ file.writeShort(number_of_exceptions);
+ for (int i = 0; i < number_of_exceptions; i++)
+ file.writeShort(exception_index_table[i]);
+ }
+
+ /**
+ * @return Array of indices into constant pool of thrown exceptions.
+ */
+ public final int[] getExceptionIndexTable() {
+ return exception_index_table;
+ }
+
+ /**
+ * @return Length of exception table.
+ */
+ public final int getNumberOfExceptions() {
+ return number_of_exceptions;
+ }
+
+ /**
+ * @return class names of thrown exceptions
+ */
+ public final String[] getExceptionNames() {
+ String[] names = new String[number_of_exceptions];
+ for (int i = 0; i < number_of_exceptions; i++)
+ names[i] = cpool.getConstantString(exception_index_table[i], Constants.CONSTANT_Class).replace('/', '.');
+ return names;
+ }
+
+ /**
+ * @param exception_index_table. Also redefines number_of_exceptions according to table length.
+ */
+ public final void setExceptionIndexTable(int[] exception_index_table) {
+ this.exception_index_table = exception_index_table;
+ number_of_exceptions = (exception_index_table == null) ? 0 : exception_index_table.length;
+ }
+
+ /**
+ * @return String representation, i.e., a list of thrown exceptions.
+ */
+ @Override
+ public final String toString() {
+ StringBuffer buf = new StringBuffer("");
+ String str;
+
+ for (int i = 0; i < number_of_exceptions; i++) {
+ str = cpool.getConstantString(exception_index_table[i], Constants.CONSTANT_Class);
+ buf.append(Utility.compactClassName(str, false));
+
+ if (i < number_of_exceptions - 1)
+ buf.append(", ");
+ }
+
+ return buf.toString();
+ }
+
+ // /**
+ // * @return deep copy of this attribute
+ // */
+ // public Attribute copy(ConstantPool constant_pool) {
+ // ExceptionTable c = (ExceptionTable)clone();
+ // c.exception_index_table = (int[])exception_index_table.clone();
+ // c.cpool = constant_pool;
+ // return c;
+ // }
}
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/FieldOrMethod.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/FieldOrMethod.java
index 1babd200a..a152b616f 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/FieldOrMethod.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/FieldOrMethod.java
@@ -61,12 +61,12 @@ import java.util.List;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen;
-import org.aspectj.apache.bcel.classfile.annotation.RuntimeAnnotations;
+import org.aspectj.apache.bcel.classfile.annotation.RuntimeAnnos;
/**
* Abstract super class for fields and methods.
*
- * @version $Id: FieldOrMethod.java,v 1.11 2009/09/15 03:33:52 aclement Exp $
+ * @version $Id: FieldOrMethod.java,v 1.12 2009/09/15 19:40:12 aclement Exp $
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
*/
public abstract class FieldOrMethod extends Modifiers implements Node {
@@ -170,8 +170,8 @@ public abstract class FieldOrMethod extends Modifiers implements Node {
List<AnnotationGen> accumulatedAnnotations = new ArrayList<AnnotationGen>();
for (int i = 0; i < attributes.length; i++) {
Attribute attribute = attributes[i];
- if (attribute instanceof RuntimeAnnotations) {
- RuntimeAnnotations runtimeAnnotations = (RuntimeAnnotations) attribute;
+ if (attribute instanceof RuntimeAnnos) {
+ RuntimeAnnos runtimeAnnotations = (RuntimeAnnos) attribute;
accumulatedAnnotations.addAll(runtimeAnnotations.getAnnotations());
}
}
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/InnerClasses.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/InnerClasses.java
index 493012bf9..0078156ed 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/InnerClasses.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/InnerClasses.java
@@ -54,128 +54,128 @@ package org.aspectj.apache.bcel.classfile;
* <http://www.apache.org/>.
*/
-import org.aspectj.apache.bcel.Constants;
-import java.io.*;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import org.aspectj.apache.bcel.Constants;
/**
- * This class is derived from <em>Attribute</em> and denotes that this class
- * is an Inner class of another.
- * to the source file of this class.
- * It is instantiated from the <em>Attribute.readAttribute()</em> method.
- *
- * @version $Id: InnerClasses.java,v 1.4 2009/09/10 15:35:05 aclement Exp $
- * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
- * @see Attribute
+ * This class is derived from <em>Attribute</em> and denotes that this class is an Inner class of another. to the source file of
+ * this class. It is instantiated from the <em>Attribute.readAttribute()</em> method.
+ *
+ * @version $Id: InnerClasses.java,v 1.5 2009/09/15 19:40:12 aclement Exp $
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Attribute
*/
public final class InnerClasses extends Attribute {
- private InnerClass[] inner_classes;
- private int number_of_classes;
-
- /**
- * Initialize from another object. Note that both objects use the same
- * references (shallow copy). Use clone() for a physical copy.
- */
- public InnerClasses(InnerClasses c) {
- this(c.getNameIndex(), c.getLength(), c.getInnerClasses(),
- c.getConstantPool());
- }
-
- /**
- * @param name_index Index in constant pool to CONSTANT_Utf8
- * @param length Content length in bytes
- * @param inner_classes array of inner classes attributes
- * @param constant_pool Array of constants
- * @param sourcefile_index Index in constant pool to CONSTANT_Utf8
- */
- public InnerClasses(int name_index, int length,
- InnerClass[] inner_classes,
- ConstantPool constant_pool)
- {
- super(Constants.ATTR_INNER_CLASSES, name_index, length, constant_pool);
- setInnerClasses(inner_classes);
- }
-
- /**
- * Construct object from file stream.
- *
- * @param name_index Index in constant pool to CONSTANT_Utf8
- * @param length Content length in bytes
- * @param file Input stream
- * @param constant_pool Array of constants
- * @throws IOException
- */
- InnerClasses(int name_index, int length, DataInputStream file,
- ConstantPool constant_pool) throws IOException
- {
- this(name_index, length, (InnerClass[])null, constant_pool);
-
- number_of_classes = file.readUnsignedShort();
- inner_classes = new InnerClass[number_of_classes];
-
- for(int i=0; i < number_of_classes; i++)
- inner_classes[i] = new InnerClass(file);
- }
- /**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept(ClassVisitor v) {
- v.visitInnerClasses(this);
- }
- /**
- * Dump source file attribute to file stream in binary format.
- *
- * @param file Output file stream
- * @throws IOException
- */
- public final void dump(DataOutputStream file) throws IOException
- {
- super.dump(file);
- file.writeShort(number_of_classes);
-
- for(int i=0; i < number_of_classes; i++)
- inner_classes[i].dump(file);
- }
-
- /**
- * @return array of inner class "records"
- */
- public final InnerClass[] getInnerClasses() { return inner_classes; }
-
- /**
- * @param inner_classes.
- */
- public final void setInnerClasses(InnerClass[] inner_classes) {
- this.inner_classes = inner_classes;
- number_of_classes = (inner_classes == null)? 0 : inner_classes.length;
- }
-
- /**
- * @return String representation.
- */
- public final String toString() {
- StringBuffer buf = new StringBuffer();
-
- for(int i=0; i < number_of_classes; i++)
- buf.append(inner_classes[i].toString(cpool) + "\n");
-
- return buf.toString();
- }
-
- /**
- * @return deep copy of this attribute
- */
- public Attribute copy(ConstantPool constant_pool) {
- InnerClasses c = (InnerClasses)clone();
-
- c.inner_classes = new InnerClass[number_of_classes];
- for(int i=0; i < number_of_classes; i++)
- c.inner_classes[i] = inner_classes[i].copy();
-
- c.cpool = constant_pool;
- return c;
- }
+ private InnerClass[] inner_classes;
+ private int number_of_classes;
+
+ /**
+ * Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a physical
+ * copy.
+ */
+ public InnerClasses(InnerClasses c) {
+ this(c.getNameIndex(), c.getLength(), c.getInnerClasses(), c.getConstantPool());
+ }
+
+ /**
+ * @param name_index Index in constant pool to CONSTANT_Utf8
+ * @param length Content length in bytes
+ * @param inner_classes array of inner classes attributes
+ * @param constant_pool Array of constants
+ * @param sourcefile_index Index in constant pool to CONSTANT_Utf8
+ */
+ public InnerClasses(int name_index, int length, InnerClass[] inner_classes, ConstantPool constant_pool) {
+ super(Constants.ATTR_INNER_CLASSES, name_index, length, constant_pool);
+ setInnerClasses(inner_classes);
+ }
+
+ /**
+ * Construct object from file stream.
+ *
+ * @param name_index Index in constant pool to CONSTANT_Utf8
+ * @param length Content length in bytes
+ * @param file Input stream
+ * @param constant_pool Array of constants
+ * @throws IOException
+ */
+ InnerClasses(int name_index, int length, DataInputStream file, ConstantPool constant_pool) throws IOException {
+ this(name_index, length, (InnerClass[]) null, constant_pool);
+
+ number_of_classes = file.readUnsignedShort();
+ inner_classes = new InnerClass[number_of_classes];
+
+ for (int i = 0; i < number_of_classes; i++)
+ inner_classes[i] = new InnerClass(file);
+ }
+
+ /**
+ * Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class. I.e., the
+ * hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
+ *
+ * @param v Visitor object
+ */
+ @Override
+ public void accept(ClassVisitor v) {
+ v.visitInnerClasses(this);
+ }
+
+ /**
+ * Dump source file attribute to file stream in binary format.
+ *
+ * @param file Output file stream
+ * @throws IOException
+ */
+ @Override
+ public final void dump(DataOutputStream file) throws IOException {
+ super.dump(file);
+ file.writeShort(number_of_classes);
+
+ for (int i = 0; i < number_of_classes; i++)
+ inner_classes[i].dump(file);
+ }
+
+ /**
+ * @return array of inner class "records"
+ */
+ public final InnerClass[] getInnerClasses() {
+ return inner_classes;
+ }
+
+ /**
+ * @param inner_classes.
+ */
+ public final void setInnerClasses(InnerClass[] inner_classes) {
+ this.inner_classes = inner_classes;
+ number_of_classes = (inner_classes == null) ? 0 : inner_classes.length;
+ }
+
+ /**
+ * @return String representation.
+ */
+ @Override
+ public final String toString() {
+ StringBuffer buf = new StringBuffer();
+
+ for (int i = 0; i < number_of_classes; i++)
+ buf.append(inner_classes[i].toString(cpool) + "\n");
+
+ return buf.toString();
+ }
+
+ // /**
+ // * @return deep copy of this attribute
+ // */
+ // public Attribute copy(ConstantPool constant_pool) {
+ // InnerClasses c = (InnerClasses)clone();
+ //
+ // c.inner_classes = new InnerClass[number_of_classes];
+ // for(int i=0; i < number_of_classes; i++)
+ // c.inner_classes[i] = inner_classes[i].copy();
+ //
+ // c.cpool = constant_pool;
+ // return c;
+ // }
}
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/JavaClass.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/JavaClass.java
index 27d2c241a..25c415295 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/JavaClass.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/JavaClass.java
@@ -69,7 +69,7 @@ import java.util.StringTokenizer;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen;
-import org.aspectj.apache.bcel.classfile.annotation.RuntimeAnnotations;
+import org.aspectj.apache.bcel.classfile.annotation.RuntimeAnnos;
import org.aspectj.apache.bcel.generic.Type;
import org.aspectj.apache.bcel.util.SyntheticRepository;
@@ -80,7 +80,7 @@ import org.aspectj.apache.bcel.util.SyntheticRepository;
* The intent of this class is to represent a parsed or otherwise existing class file. Those interested in programatically
* generating classes should see the <a href="../generic/ClassGen.html">ClassGen</a> class.
*
- * @version $Id: JavaClass.java,v 1.21 2009/09/15 16:39:56 aclement Exp $
+ * @version $Id: JavaClass.java,v 1.22 2009/09/15 19:40:14 aclement Exp $
* @see org.aspectj.apache.bcel.generic.ClassGen
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
*/
@@ -289,8 +289,8 @@ public class JavaClass extends Modifiers implements Cloneable, Node {
List<AnnotationGen> accumulatedAnnotations = new ArrayList<AnnotationGen>();
for (int i = 0; i < attributes.length; i++) {
Attribute attribute = attributes[i];
- if (attribute instanceof RuntimeAnnotations) {
- RuntimeAnnotations runtimeAnnotations = (RuntimeAnnotations) attribute;
+ if (attribute instanceof RuntimeAnnos) {
+ RuntimeAnnos runtimeAnnotations = (RuntimeAnnos) attribute;
accumulatedAnnotations.addAll(runtimeAnnotations.getAnnotations());
}
}
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/LineNumberTable.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/LineNumberTable.java
index e0ba7ebae..10d72fd3e 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/LineNumberTable.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/LineNumberTable.java
@@ -65,7 +65,7 @@ import org.aspectj.apache.bcel.Constants;
* This class represents a table of line numbers for debugging purposes. This attribute is used by the <em>Code</em> attribute. It
* contains pairs of PCs and line numbers.
*
- * @version $Id: LineNumberTable.java,v 1.7 2009/09/10 15:35:05 aclement Exp $
+ * @version $Id: LineNumberTable.java,v 1.8 2009/09/15 19:40:12 aclement Exp $
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
* @see Code changes: asc Feb06 Made unpacking lazy
*/
@@ -258,18 +258,17 @@ public final class LineNumberTable extends Attribute {
/**
* @return deep copy of this attribute
*/
- @Override
- public Attribute copy(ConstantPool constant_pool) {
- unpack();
- LineNumberTable newTable = (LineNumberTable) clone();
- newTable.table = new LineNumber[tableLength];
- for (int i = 0; i < tableLength; i++) {
- newTable.table[i] = table[i].copy();
- }
- newTable.cpool = constant_pool;
- return newTable;
- }
-
+ // @Override
+ // public Attribute copy(ConstantPool constant_pool) {
+ // unpack();
+ // LineNumberTable newTable = (LineNumberTable) clone();
+ // newTable.table = new LineNumber[tableLength];
+ // for (int i = 0; i < tableLength; i++) {
+ // newTable.table[i] = table[i].copy();
+ // }
+ // newTable.cpool = constant_pool;
+ // return newTable;
+ // }
public final int getTableLength() {
unpack();
return tableLength;
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/LocalVariableTable.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/LocalVariableTable.java
index 138269700..717bb5965 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/LocalVariableTable.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/LocalVariableTable.java
@@ -64,7 +64,7 @@ import org.aspectj.apache.bcel.Constants;
/**
* This class represents collection of local variables in a method. This attribute is contained in the <em>Code</em> attribute.
*
- * @version $Id: LocalVariableTable.java,v 1.7 2009/09/10 15:35:04 aclement Exp $
+ * @version $Id: LocalVariableTable.java,v 1.8 2009/09/15 19:40:12 aclement Exp $
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
* @see Code
* @see LocalVariable Updates: Andy 14Feb06 - Made unpacking of the data lazy, depending on someone actually asking for it.
@@ -120,6 +120,7 @@ public class LocalVariableTable extends Attribute {
*
* @param v Visitor object
*/
+ @Override
public void accept(ClassVisitor v) {
unpack();
v.visitLocalVariableTable(this);
@@ -131,6 +132,7 @@ public class LocalVariableTable extends Attribute {
* @param file Output file stream
* @throws IOException
*/
+ @Override
public final void dump(DataOutputStream file) throws IOException {
super.dump(file);
if (isInPackedState) {
@@ -173,6 +175,7 @@ public class LocalVariableTable extends Attribute {
/**
* @return String representation.
*/
+ @Override
public final String toString() {
StringBuffer buf = new StringBuffer("");
unpack();
@@ -189,18 +192,17 @@ public class LocalVariableTable extends Attribute {
/**
* @return deep copy of this attribute
*/
- public Attribute copy(ConstantPool constant_pool) {
- unpack();
- LocalVariableTable c = (LocalVariableTable) clone();
-
- c.localVariableTable = new LocalVariable[localVariableTableLength];
- for (int i = 0; i < localVariableTableLength; i++)
- c.localVariableTable[i] = localVariableTable[i].copy();
-
- c.cpool = constant_pool;
- return c;
- }
-
+ // public Attribute copy(ConstantPool constant_pool) {
+ // unpack();
+ // LocalVariableTable c = (LocalVariableTable) clone();
+ //
+ // c.localVariableTable = new LocalVariable[localVariableTableLength];
+ // for (int i = 0; i < localVariableTableLength; i++)
+ // c.localVariableTable[i] = localVariableTable[i].copy();
+ //
+ // c.cpool = constant_pool;
+ // return c;
+ // }
public final int getTableLength() {
unpack();
return localVariableTableLength;
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/LocalVariableTypeTable.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/LocalVariableTypeTable.java
index ea1f3badf..ecd7e4383 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/LocalVariableTypeTable.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/LocalVariableTypeTable.java
@@ -13,9 +13,11 @@
* ******************************************************************/
package org.aspectj.apache.bcel.classfile;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
-import org.aspectj.apache.bcel.Constants;
-import java.io.*;
+import org.aspectj.apache.bcel.Constants;
// The new table is used when generic types are about...
@@ -45,91 +47,90 @@ import java.io.*;
// }
// J5TODO: Needs some testing !
public class LocalVariableTypeTable extends Attribute {
- private int local_variable_type_table_length; // Table of local
- private LocalVariable[] local_variable_type_table; // variables
-
- public LocalVariableTypeTable(LocalVariableTypeTable c) {
- this(c.getNameIndex(), c.getLength(), c.getLocalVariableTypeTable(),
- c.getConstantPool());
- }
-
- public LocalVariableTypeTable(int name_index, int length,
- LocalVariable[] local_variable_table,
- ConstantPool constant_pool)
- {
- super(Constants.ATTR_LOCAL_VARIABLE_TYPE_TABLE, name_index, length, constant_pool);
- setLocalVariableTable(local_variable_table);
- }
-
- LocalVariableTypeTable(int nameIdx, int len, DataInputStream dis,ConstantPool cpool) throws IOException {
- this(nameIdx, len, (LocalVariable[])null, cpool);
-
- local_variable_type_table_length = (dis.readUnsignedShort());
- local_variable_type_table = new LocalVariable[local_variable_type_table_length];
-
- for(int i=0; i < local_variable_type_table_length; i++)
- local_variable_type_table[i] = new LocalVariable(dis, cpool);
- }
-
- public void accept(ClassVisitor v) {
- v.visitLocalVariableTypeTable(this);
- }
-
- public final void dump(DataOutputStream file) throws IOException
- {
- super.dump(file);
- file.writeShort(local_variable_type_table_length);
- for(int i=0; i < local_variable_type_table_length; i++)
- local_variable_type_table[i].dump(file);
- }
-
- public final LocalVariable[] getLocalVariableTypeTable() {
- return local_variable_type_table;
- }
-
- public final LocalVariable getLocalVariable(int index) {
- for(int i=0; i < local_variable_type_table_length; i++)
- if(local_variable_type_table[i].getIndex() == index)
- return local_variable_type_table[i];
-
- return null;
- }
-
- public final void setLocalVariableTable(LocalVariable[] local_variable_table)
- {
- this.local_variable_type_table = local_variable_table;
- local_variable_type_table_length = (local_variable_table == null)? 0 :
- local_variable_table.length;
- }
-
- /**
- * @return String representation.
- */
- public final String toString() {
- StringBuffer buf = new StringBuffer("");
-
- for(int i=0; i < local_variable_type_table_length; i++) {
- buf.append(local_variable_type_table[i].toString());
-
- if(i < local_variable_type_table_length - 1) buf.append('\n');
- }
-
- return buf.toString();
- }
-
- /**
- * @return deep copy of this attribute
- */
- public Attribute copy(ConstantPool constant_pool) {
- LocalVariableTypeTable c = (LocalVariableTypeTable)clone();
-
- c.local_variable_type_table = new LocalVariable[local_variable_type_table_length];
- for(int i=0; i < local_variable_type_table_length; i++)
- c.local_variable_type_table[i] = local_variable_type_table[i].copy();
-
- c.cpool = constant_pool;
- return c;
- }
-
- public final int getTableLength() { return local_variable_type_table_length; }
+ private int local_variable_type_table_length; // Table of local
+ private LocalVariable[] local_variable_type_table; // variables
+
+ public LocalVariableTypeTable(LocalVariableTypeTable c) {
+ this(c.getNameIndex(), c.getLength(), c.getLocalVariableTypeTable(), c.getConstantPool());
+ }
+
+ public LocalVariableTypeTable(int name_index, int length, LocalVariable[] local_variable_table, ConstantPool constant_pool) {
+ super(Constants.ATTR_LOCAL_VARIABLE_TYPE_TABLE, name_index, length, constant_pool);
+ setLocalVariableTable(local_variable_table);
+ }
+
+ LocalVariableTypeTable(int nameIdx, int len, DataInputStream dis, ConstantPool cpool) throws IOException {
+ this(nameIdx, len, (LocalVariable[]) null, cpool);
+
+ local_variable_type_table_length = (dis.readUnsignedShort());
+ local_variable_type_table = new LocalVariable[local_variable_type_table_length];
+
+ for (int i = 0; i < local_variable_type_table_length; i++)
+ local_variable_type_table[i] = new LocalVariable(dis, cpool);
+ }
+
+ @Override
+ public void accept(ClassVisitor v) {
+ v.visitLocalVariableTypeTable(this);
+ }
+
+ @Override
+ public final void dump(DataOutputStream file) throws IOException {
+ super.dump(file);
+ file.writeShort(local_variable_type_table_length);
+ for (int i = 0; i < local_variable_type_table_length; i++)
+ local_variable_type_table[i].dump(file);
+ }
+
+ public final LocalVariable[] getLocalVariableTypeTable() {
+ return local_variable_type_table;
+ }
+
+ public final LocalVariable getLocalVariable(int index) {
+ for (int i = 0; i < local_variable_type_table_length; i++)
+ if (local_variable_type_table[i].getIndex() == index)
+ return local_variable_type_table[i];
+
+ return null;
+ }
+
+ public final void setLocalVariableTable(LocalVariable[] local_variable_table) {
+ this.local_variable_type_table = local_variable_table;
+ local_variable_type_table_length = (local_variable_table == null) ? 0 : local_variable_table.length;
+ }
+
+ /**
+ * @return String representation.
+ */
+ @Override
+ public final String toString() {
+ StringBuffer buf = new StringBuffer("");
+
+ for (int i = 0; i < local_variable_type_table_length; i++) {
+ buf.append(local_variable_type_table[i].toString());
+
+ if (i < local_variable_type_table_length - 1)
+ buf.append('\n');
+ }
+
+ return buf.toString();
+ }
+
+ // /**
+ // * @return deep copy of this attribute
+ // */
+ // public Attribute copy(ConstantPool constant_pool) {
+ // LocalVariableTypeTable c = (LocalVariableTypeTable)clone();
+ //
+ // c.local_variable_type_table = new LocalVariable[local_variable_type_table_length];
+ // for(int i=0; i < local_variable_type_table_length; i++)
+ // c.local_variable_type_table[i] = local_variable_type_table[i].copy();
+ //
+ // c.cpool = constant_pool;
+ // return c;
+ // }
+
+ public final int getTableLength() {
+ return local_variable_type_table_length;
+ }
}
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Method.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Method.java
index cec26bd34..d354b7fe1 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Method.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Method.java
@@ -60,15 +60,15 @@ import java.util.List;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen;
-import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisibleParameterAnnotations;
-import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleParameterAnnotations;
+import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisParamAnnos;
+import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisParamAnnos;
import org.aspectj.apache.bcel.generic.Type;
/**
* This class represents the method info structure, i.e., the representation for a method in the class. See JVM specification for
* details. A method has access flags, a name, a signature and a number of attributes.
*
- * @version $Id: Method.java,v 1.10 2009/09/15 03:33:52 aclement Exp $
+ * @version $Id: Method.java,v 1.11 2009/09/15 19:40:12 aclement Exp $
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
*/
public final class Method extends FieldOrMethod {
@@ -206,18 +206,18 @@ public final class Method extends FieldOrMethod {
return;
}
- RuntimeVisibleParameterAnnotations parameterAnnotationsVis = null;
- RuntimeInvisibleParameterAnnotations parameterAnnotationsInvis = null;
+ RuntimeVisParamAnnos parameterAnnotationsVis = null;
+ RuntimeInvisParamAnnos parameterAnnotationsInvis = null;
// Find attributes that contain annotation data
Attribute[] attrs = getAttributes();
for (int i = 0; i < attrs.length; i++) {
Attribute attribute = attrs[i];
- if (attribute instanceof RuntimeVisibleParameterAnnotations) {
- parameterAnnotationsVis = (RuntimeVisibleParameterAnnotations) attribute;
- } else if (attribute instanceof RuntimeInvisibleParameterAnnotations) {
- parameterAnnotationsInvis = (RuntimeInvisibleParameterAnnotations) attribute;
+ if (attribute instanceof RuntimeVisParamAnnos) {
+ parameterAnnotationsVis = (RuntimeVisParamAnnos) attribute;
+ } else if (attribute instanceof RuntimeInvisParamAnnos) {
+ parameterAnnotationsInvis = (RuntimeInvisParamAnnos) attribute;
}
}
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Signature.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Signature.java
index b1991afef..b7488e9a4 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Signature.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Signature.java
@@ -68,7 +68,7 @@ import org.aspectj.apache.bcel.Constants;
* This class is derived from <em>Attribute</em> and represents a reference to a <href="http://wwwipd.ira.uka.de/~pizza/gj/">GJ</a>
* attribute.
*
- * @version $Id: Signature.java,v 1.10 2009/09/10 15:35:04 aclement Exp $
+ * @version $Id: Signature.java,v 1.11 2009/09/15 19:40:12 aclement Exp $
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
* @see Attribute
*/
@@ -299,12 +299,12 @@ public final class Signature extends Attribute {
return "Signature(" + s + ")";
}
- /**
- * @return deep copy of this attribute
- */
- @Override
- public Attribute copy(ConstantPool constant_pool) {
- return (Signature) clone();
- }
+ // /**
+ // * @return deep copy of this attribute
+ // */
+ // @Override
+ // public Attribute copy(ConstantPool constant_pool) {
+ // return (Signature) clone();
+ // }
}
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/SourceFile.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/SourceFile.java
index 6832f86cd..9fd840fc0 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/SourceFile.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/SourceFile.java
@@ -65,7 +65,7 @@ import org.aspectj.apache.bcel.Constants;
* attribute should appear per classfile. The intention of this class is that it is instantiated from the
* <em>Attribute.readAttribute()</em> method.
*
- * @version $Id: SourceFile.java,v 1.4 2009/09/10 15:35:04 aclement Exp $
+ * @version $Id: SourceFile.java,v 1.5 2009/09/15 19:40:12 aclement Exp $
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
* @see Attribute
*/
@@ -160,10 +160,10 @@ public final class SourceFile extends Attribute {
}
/**
- * @return deep copy of this attribute
+ * @return deep copy of this attribute //
*/
- @Override
- public Attribute copy(ConstantPool constant_pool) {
- return (SourceFile) clone();
- }
+ // @Override
+ // public Attribute copy(ConstantPool constant_pool) {
+ // return (SourceFile) clone();
+ // }
}
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/StackMap.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/StackMap.java
index 0ddf0e88f..80f943bbf 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/StackMap.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/StackMap.java
@@ -54,132 +54,137 @@ package org.aspectj.apache.bcel.classfile;
* <http://www.apache.org/>.
*/
-import org.aspectj.apache.bcel.Constants;
-import java.io.*;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import org.aspectj.apache.bcel.Constants;
/**
- * This class represents a stack map attribute used for
- * preverification of Java classes for the <a
- * href="http://java.sun.com/j2me/"> Java 2 Micro Edition</a>
- * (J2ME). This attribute is used by the <a
- * href="http://java.sun.com/products/cldc/">KVM</a> and contained
- * within the Code attribute of a method. See CLDC specification
- * §5.3.1.2
- *
- * @version $Id: StackMap.java,v 1.5 2009/09/10 15:35:04 aclement Exp $
- * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
- * @see Code
- * @see StackMapEntry
- * @see StackMapType
+ * This class represents a stack map attribute used for preverification of Java classes for the <a href="http://java.sun.com/j2me/">
+ * Java 2 Micro Edition</a> (J2ME). This attribute is used by the <a href="http://java.sun.com/products/cldc/">KVM</a> and contained
+ * within the Code attribute of a method. See CLDC specification §5.3.1.2
+ *
+ * @version $Id: StackMap.java,v 1.6 2009/09/15 19:40:12 aclement Exp $
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Code
+ * @see StackMapEntry
+ * @see StackMapType
*/
public final class StackMap extends Attribute {
- private int map_length;
- private StackMapEntry[] map; // Table of stack map entries
-
- /*
- * @param name_index Index of name
- * @param length Content length in bytes
- * @param map Table of stack map entries
- * @param constant_pool Array of constants
- */
- public StackMap(int name_index, int length, StackMapEntry[] map,
- ConstantPool constant_pool)
- {
- super(Constants.ATTR_STACK_MAP, name_index, length, constant_pool);
-
- setStackMap(map);
- }
-
- /**
- * Construct object from file stream.
- * @param name_index Index of name
- * @param length Content length in bytes
- * @param file Input stream
- * @throws IOException
- * @param constant_pool Array of constants
- */
- StackMap(int name_index, int length, DataInputStream file,
- ConstantPool constant_pool) throws IOException
- {
- this(name_index, length, (StackMapEntry[])null, constant_pool);
-
- map_length = file.readUnsignedShort();
- map = new StackMapEntry[map_length];
-
- for(int i=0; i < map_length; i++)
- map[i] = new StackMapEntry(file, constant_pool);
- }
-
- /**
- * Dump line number table attribute to file stream in binary format.
- *
- * @param file Output file stream
- * @throws IOException
- */
- public final void dump(DataOutputStream file) throws IOException
- {
- super.dump(file);
- file.writeShort(map_length);
- for(int i=0; i < map_length; i++)
- map[i].dump(file);
- }
-
- /**
- * @return Array of stack map entries
- */
- public final StackMapEntry[] getStackMap() { return map; }
-
- /**
- * @param map Array of stack map entries
- */
- public final void setStackMap(StackMapEntry[] map) {
- this.map = map;
-
- map_length = (map == null)? 0 : map.length;
- }
-
- /**
- * @return String representation.
- */
- public final String toString() {
- StringBuffer buf = new StringBuffer("StackMap(");
-
- for(int i=0; i < map_length; i++) {
- buf.append(map[i].toString());
-
- if(i < map_length - 1)
- buf.append(", ");
- }
-
- buf.append(')');
-
- return buf.toString();
- }
-
- /**
- * @return deep copy of this attribute
- */
- public Attribute copy(ConstantPool constant_pool) {
- StackMap c = (StackMap)clone();
-
- c.map = new StackMapEntry[map_length];
- for(int i=0; i < map_length; i++)
- c.map[i] = map[i].copy();
-
- c.cpool = constant_pool;
- return c;
- }
-
- /**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept(ClassVisitor v) {
- v.visitStackMap(this);
- }
-
- public final int getMapLength() { return map_length; }
+ private int map_length;
+ private StackMapEntry[] map; // Table of stack map entries
+
+ /*
+ * @param name_index Index of name
+ *
+ * @param length Content length in bytes
+ *
+ * @param map Table of stack map entries
+ *
+ * @param constant_pool Array of constants
+ */
+ public StackMap(int name_index, int length, StackMapEntry[] map, ConstantPool constant_pool) {
+ super(Constants.ATTR_STACK_MAP, name_index, length, constant_pool);
+
+ setStackMap(map);
+ }
+
+ /**
+ * Construct object from file stream.
+ *
+ * @param name_index Index of name
+ * @param length Content length in bytes
+ * @param file Input stream
+ * @throws IOException
+ * @param constant_pool Array of constants
+ */
+ StackMap(int name_index, int length, DataInputStream file, ConstantPool constant_pool) throws IOException {
+ this(name_index, length, (StackMapEntry[]) null, constant_pool);
+
+ map_length = file.readUnsignedShort();
+ map = new StackMapEntry[map_length];
+
+ for (int i = 0; i < map_length; i++)
+ map[i] = new StackMapEntry(file, constant_pool);
+ }
+
+ /**
+ * Dump line number table attribute to file stream in binary format.
+ *
+ * @param file Output file stream
+ * @throws IOException
+ */
+ @Override
+ public final void dump(DataOutputStream file) throws IOException {
+ super.dump(file);
+ file.writeShort(map_length);
+ for (int i = 0; i < map_length; i++)
+ map[i].dump(file);
+ }
+
+ /**
+ * @return Array of stack map entries
+ */
+ public final StackMapEntry[] getStackMap() {
+ return map;
+ }
+
+ /**
+ * @param map Array of stack map entries
+ */
+ public final void setStackMap(StackMapEntry[] map) {
+ this.map = map;
+
+ map_length = (map == null) ? 0 : map.length;
+ }
+
+ /**
+ * @return String representation.
+ */
+ @Override
+ public final String toString() {
+ StringBuffer buf = new StringBuffer("StackMap(");
+
+ for (int i = 0; i < map_length; i++) {
+ buf.append(map[i].toString());
+
+ if (i < map_length - 1)
+ buf.append(", ");
+ }
+
+ buf.append(')');
+
+ return buf.toString();
+ }
+
+ //
+ // /**
+ // * @return deep copy of this attribute
+ // */
+ // public Attribute copy(ConstantPool constant_pool) {
+ // StackMap c = (StackMap)clone();
+ //
+ // c.map = new StackMapEntry[map_length];
+ // for(int i=0; i < map_length; i++)
+ // c.map[i] = map[i].copy();
+ //
+ // c.cpool = constant_pool;
+ // return c;
+ // }
+
+ /**
+ * Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class. I.e., the
+ * hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
+ *
+ * @param v Visitor object
+ */
+ @Override
+ public void accept(ClassVisitor v) {
+ v.visitStackMap(this);
+ }
+
+ public final int getMapLength() {
+ return map_length;
+ }
}
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Synthetic.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Synthetic.java
index e3eebe36b..57fe97468 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Synthetic.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Synthetic.java
@@ -54,131 +54,132 @@ package org.aspectj.apache.bcel.classfile;
* <http://www.apache.org/>.
*/
-import org.aspectj.apache.bcel.Constants;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
-import java.io.*;
+import org.aspectj.apache.bcel.Constants;
/**
- * This class is derived from <em>Attribute</em> and declares this class as
- * `synthetic', i.e., it needs special handling. The JVM specification
- * states "A class member that does not appear in the source code must be
- * marked using a Synthetic attribute." It may appear in the ClassFile
- * attribute table, a field_info table or a method_info table. This class
- * is intended to be instantiated from the
- * <em>Attribute.readAttribute()</em> method.
- *
- * @version $Id: Synthetic.java,v 1.4 2009/09/10 15:35:04 aclement Exp $
- * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
- * @see Attribute
+ * This class is derived from <em>Attribute</em> and declares this class as `synthetic', i.e., it needs special handling. The JVM
+ * specification states "A class member that does not appear in the source code must be marked using a Synthetic attribute." It may
+ * appear in the ClassFile attribute table, a field_info table or a method_info table. This class is intended to be instantiated
+ * from the <em>Attribute.readAttribute()</em> method.
+ *
+ * @version $Id: Synthetic.java,v 1.5 2009/09/15 19:40:12 aclement Exp $
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Attribute
*/
public final class Synthetic extends Attribute {
- private byte[] bytes;
-
- /**
- * Initialize from another object. Note that both objects use the same
- * references (shallow copy). Use copy() for a physical copy.
- */
- public Synthetic(Synthetic c) {
- this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool());
- }
-//
-// public Synthetic(ConstantPoolGen cpool) {
-// super(Constants.ATTR_SYNTHETIC, cpool.addUtf8("Synthetic"), 0, cpool);
-// ConstantPoolGen cpg = myGen.getConstantPool();
-// int index = ;
-// Attribute synthetic = new Synthetic(index, 0, new byte[0], cpg.getConstantPool());
-// }
-
- /**
- * @param name_index Index in constant pool to CONSTANT_Utf8, which
- * should represent the string "Synthetic".
- * @param length Content length in bytes - should be zero.
- * @param bytes Attribute contents
- * @param constant_pool The constant pool this attribute is associated
- * with.
- */
- public Synthetic(int name_index, int length, byte[] bytes,
- ConstantPool constant_pool)
- {
- super(Constants.ATTR_SYNTHETIC, name_index, length, constant_pool);
- this.bytes = bytes;
- }
-
- /**
- * Construct object from file stream.
- * @param name_index Index in constant pool to CONSTANT_Utf8
- * @param length Content length in bytes
- * @param file Input stream
- * @param constant_pool Array of constants
- * @throws IOException
- */
- Synthetic(int name_index, int length, DataInputStream file,
- ConstantPool constant_pool) throws IOException
- {
- this(name_index, length, (byte [])null, constant_pool);
-
- if(length > 0) {
- bytes = new byte[length];
- file.readFully(bytes);
- System.err.println("Synthetic attribute with length > 0");
- }
- }
- /**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept(ClassVisitor v) {
- v.visitSynthetic(this);
- }
- /**
- * Dump source file attribute to file stream in binary format.
- *
- * @param file Output file stream
- * @throws IOException
- */
- public final void dump(DataOutputStream file) throws IOException
- {
- super.dump(file);
- if(length > 0)
- file.write(bytes, 0, length);
- }
- /**
- * @return data bytes.
- */
- public final byte[] getBytes() { return bytes; }
-
- /**
- * @param bytes.
- */
- public final void setBytes(byte[] bytes) {
- this.bytes = bytes;
- }
-
- /**
- * @return String representation.
- */
- public final String toString() {
- StringBuffer buf = new StringBuffer("Synthetic");
-
- if(length > 0)
- buf.append(" " + Utility.toHexString(bytes));
-
- return buf.toString();
- }
-
- /**
- * @return deep copy of this attribute
- */
- public Attribute copy(ConstantPool constant_pool) {
- Synthetic c = (Synthetic)clone();
-
- if(bytes != null)
- c.bytes = (byte[])bytes.clone();
-
- c.cpool = constant_pool;
- return c;
- }
+ private byte[] bytes;
+
+ /**
+ * Initialize from another object. Note that both objects use the same references (shallow copy). Use copy() for a physical
+ * copy.
+ */
+ public Synthetic(Synthetic c) {
+ this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool());
+ }
+
+ //
+ // public Synthetic(ConstantPoolGen cpool) {
+ // super(Constants.ATTR_SYNTHETIC, cpool.addUtf8("Synthetic"), 0, cpool);
+ // ConstantPoolGen cpg = myGen.getConstantPool();
+ // int index = ;
+ // Attribute synthetic = new Synthetic(index, 0, new byte[0], cpg.getConstantPool());
+ // }
+
+ /**
+ * @param name_index Index in constant pool to CONSTANT_Utf8, which should represent the string "Synthetic".
+ * @param length Content length in bytes - should be zero.
+ * @param bytes Attribute contents
+ * @param constant_pool The constant pool this attribute is associated with.
+ */
+ public Synthetic(int name_index, int length, byte[] bytes, ConstantPool constant_pool) {
+ super(Constants.ATTR_SYNTHETIC, name_index, length, constant_pool);
+ this.bytes = bytes;
+ }
+
+ /**
+ * Construct object from file stream.
+ *
+ * @param name_index Index in constant pool to CONSTANT_Utf8
+ * @param length Content length in bytes
+ * @param file Input stream
+ * @param constant_pool Array of constants
+ * @throws IOException
+ */
+ Synthetic(int name_index, int length, DataInputStream file, ConstantPool constant_pool) throws IOException {
+ this(name_index, length, (byte[]) null, constant_pool);
+
+ if (length > 0) {
+ bytes = new byte[length];
+ file.readFully(bytes);
+ System.err.println("Synthetic attribute with length > 0");
+ }
+ }
+
+ /**
+ * Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class. I.e., the
+ * hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
+ *
+ * @param v Visitor object
+ */
+ @Override
+ public void accept(ClassVisitor v) {
+ v.visitSynthetic(this);
+ }
+
+ /**
+ * Dump source file attribute to file stream in binary format.
+ *
+ * @param file Output file stream
+ * @throws IOException
+ */
+ @Override
+ public final void dump(DataOutputStream file) throws IOException {
+ super.dump(file);
+ if (length > 0)
+ file.write(bytes, 0, length);
+ }
+
+ /**
+ * @return data bytes.
+ */
+ public final byte[] getBytes() {
+ return bytes;
+ }
+
+ /**
+ * @param bytes.
+ */
+ public final void setBytes(byte[] bytes) {
+ this.bytes = bytes;
+ }
+
+ /**
+ * @return String representation.
+ */
+ @Override
+ public final String toString() {
+ StringBuffer buf = new StringBuffer("Synthetic");
+
+ if (length > 0)
+ buf.append(" " + Utility.toHexString(bytes));
+
+ return buf.toString();
+ }
+
+ // /**
+ // * @return deep copy of this attribute
+ // */
+ // public Attribute copy(ConstantPool constant_pool) {
+ // Synthetic c = (Synthetic)clone();
+ //
+ // if(bytes != null)
+ // c.bytes = (byte[])bytes.clone();
+ //
+ // c.cpool = constant_pool;
+ // return c;
+ // }
}
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Unknown.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Unknown.java
index c4f86441b..416d105b1 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Unknown.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Unknown.java
@@ -68,7 +68,7 @@ import org.aspectj.apache.bcel.Constants;
* org.aspectj.apache.bcel.classfile.AttributeReader)">Attribute.addAttributeReader</a>.
*
*
- * @version $Id: Unknown.java,v 1.5 2009/09/10 15:35:05 aclement Exp $
+ * @version $Id: Unknown.java,v 1.6 2009/09/15 19:40:12 aclement Exp $
* @see org.aspectj.apache.bcel.classfile.Attribute
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
*/
@@ -202,14 +202,14 @@ public final class Unknown extends Attribute {
/**
* @return deep copy of this attribute
*/
- @Override
- public Attribute copy(ConstantPool constant_pool) {
- Unknown c = (Unknown) clone();
-
- if (bytes != null)
- c.bytes = bytes.clone();
-
- c.cpool = constant_pool;
- return c;
- }
+ // @Override
+ // public Attribute copy(ConstantPool constant_pool) {
+ // Unknown c = (Unknown) clone();
+ //
+ // if (bytes != null)
+ // c.bytes = bytes.clone();
+ //
+ // c.cpool = constant_pool;
+ // return c;
+ // }
}
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Utility.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Utility.java
index df6b7f376..efcbf9fb5 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Utility.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Utility.java
@@ -63,19 +63,19 @@ import java.util.List;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen;
-import org.aspectj.apache.bcel.classfile.annotation.RuntimeAnnotations;
-import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisibleAnnotations;
-import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisibleParameterAnnotations;
-import org.aspectj.apache.bcel.classfile.annotation.RuntimeParameterAnnotations;
-import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleAnnotations;
-import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleParameterAnnotations;
+import org.aspectj.apache.bcel.classfile.annotation.RuntimeAnnos;
+import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisAnnos;
+import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisParamAnnos;
+import org.aspectj.apache.bcel.classfile.annotation.RuntimeParamAnnos;
+import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisAnnos;
+import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisParamAnnos;
import org.aspectj.apache.bcel.generic.Type;
import org.aspectj.apache.bcel.util.ByteSequence;
/**
* Utility functions that do not really belong to any class in particular.
*
- * @version $Id: Utility.java,v 1.11 2009/09/14 20:29:10 aclement Exp $
+ * @version $Id: Utility.java,v 1.12 2009/09/15 19:40:13 aclement Exp $
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
*
* modified: Andy Clement 2-mar-05 Removed unnecessary static and optimized
@@ -396,18 +396,16 @@ public abstract class Utility {
brackets = new StringBuffer(); // Accumulate []'s
// Count opening brackets and look for optional size argument
- for (n = 0; signature.charAt(n) == '['; n++)
+ for (n = 0; signature.charAt(n) == '['; n++) {
brackets.append("[]");
+ }
consumedChars = n;
- // The rest of the string denotes a `<field_type>'
+ // The rest of the string denotes a '<field_type>'
ResultHolder restOfIt = signatureToStringInternal(signature.substring(n), chopit);
- // type = signatureToString(signature.substring(n), chopit);
-
consumedChars += restOfIt.getConsumedChars();
return new ResultHolder(restOfIt.getResult() + brackets.toString(), consumedChars);
}
-
case 'V':
return ResultHolder.VOID;
@@ -545,7 +543,7 @@ public abstract class Utility {
* @param cp The constant pool gen where we can create the necessary name refs
* @param annotations A list of AnnotationGen objects
*/
- public static Collection<RuntimeAnnotations> getAnnotationAttributes(ConstantPool cp, List<AnnotationGen> annotations) {
+ public static Collection<RuntimeAnnos> getAnnotationAttributes(ConstantPool cp, List<AnnotationGen> annotations) {
if (annotations.size() == 0)
return null;
@@ -593,12 +591,12 @@ public abstract class Utility {
if (riaData.length > 2)
riaIndex = cp.addUtf8("RuntimeInvisibleAnnotations");
- List<RuntimeAnnotations> newAttributes = new ArrayList<RuntimeAnnotations>();
+ List<RuntimeAnnos> newAttributes = new ArrayList<RuntimeAnnos>();
if (rvaData.length > 2) {
- newAttributes.add(new RuntimeVisibleAnnotations(rvaIndex, rvaData.length, rvaData, cp));
+ newAttributes.add(new RuntimeVisAnnos(rvaIndex, rvaData.length, rvaData, cp));
}
if (riaData.length > 2) {
- newAttributes.add(new RuntimeInvisibleAnnotations(riaIndex, riaData.length, riaData, cp));
+ newAttributes.add(new RuntimeInvisAnnos(riaIndex, riaData.length, riaData, cp));
}
return newAttributes;
@@ -682,14 +680,14 @@ public abstract class Utility {
if (totalInvisCount > 0)
riaIndex = cp.addUtf8("RuntimeInvisibleParameterAnnotations");
- List<RuntimeParameterAnnotations> newAttributes = new ArrayList<RuntimeParameterAnnotations>();
+ List<RuntimeParamAnnos> newAttributes = new ArrayList<RuntimeParamAnnos>();
if (totalVisCount > 0) {
- newAttributes.add(new RuntimeVisibleParameterAnnotations(rvaIndex, rvaData.length, rvaData, cp));
+ newAttributes.add(new RuntimeVisParamAnnos(rvaIndex, rvaData.length, rvaData, cp));
}
if (totalInvisCount > 0) {
- newAttributes.add(new RuntimeInvisibleParameterAnnotations(riaIndex, riaData.length, riaData, cp));
+ newAttributes.add(new RuntimeInvisParamAnnos(riaIndex, riaData.length, riaData, cp));
}
return newAttributes.toArray(new Attribute[] {});
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/AnnotationElementValue.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/AnnotationElementValue.java
new file mode 100644
index 000000000..1b2d4023d
--- /dev/null
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/AnnotationElementValue.java
@@ -0,0 +1,55 @@
+/* *******************************************************************
+ * Copyright (c) 2004 IBM
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andy Clement - initial implementation {date}
+ * ******************************************************************/
+
+package org.aspectj.apache.bcel.classfile.annotation;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import org.aspectj.apache.bcel.classfile.ConstantPool;
+
+public class AnnotationElementValue extends ElementValue {
+
+ private AnnotationGen a;
+
+ public AnnotationElementValue(AnnotationGen a, ConstantPool cpool) {
+ super(ANNOTATION, cpool);
+ this.a = a;
+ }
+
+ public AnnotationElementValue(int type, AnnotationGen annotation, ConstantPool cpool) {
+ super(type, cpool);
+ assert type == ANNOTATION;
+ this.a = annotation;
+ }
+
+ public AnnotationElementValue(AnnotationElementValue value, ConstantPool cpool, boolean copyPoolEntries) {
+ super(ANNOTATION, cpool);
+ a = new AnnotationGen(value.getAnnotation(), cpool, copyPoolEntries);
+ }
+
+ @Override
+ public void dump(DataOutputStream dos) throws IOException {
+ dos.writeByte(type); // u1 type of value (ANNOTATION == '@')
+ a.dump(dos);
+ }
+
+ @Override
+ public String stringifyValue() {
+ throw new RuntimeException("Not implemented yet");
+ }
+
+ public AnnotationGen getAnnotation() {
+ return a;
+ }
+
+}
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/AnnotationElementValueGen.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/AnnotationElementValueGen.java
deleted file mode 100644
index e1b9f47d9..000000000
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/AnnotationElementValueGen.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2004 IBM
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andy Clement - initial implementation {date}
- * ******************************************************************/
-
-package org.aspectj.apache.bcel.classfile.annotation;
-
-import java.io.DataOutputStream;
-import java.io.IOException;
-
-import org.aspectj.apache.bcel.classfile.ConstantPool;
-
-
-public class AnnotationElementValueGen extends ElementValueGen {
-
- // For annotation element values, this is the annotation
- private AnnotationGen a;
-
- public AnnotationElementValueGen(AnnotationGen a,ConstantPool cpool) {
- super(ANNOTATION,cpool);
- this.a = a;
- }
-
- public AnnotationElementValueGen(int type, AnnotationGen annotation, ConstantPool cpool) {
- super(type,cpool);
- if (type != ANNOTATION)
- throw new RuntimeException("Only element values of type annotation can be built with this ctor");
- this.a = annotation;
- }
-
- public AnnotationElementValueGen(AnnotationElementValueGen value, ConstantPool cpool,boolean copyPoolEntries) {
- super(ANNOTATION,cpool);
- a = new AnnotationGen(value.getAnnotation(),cpool,copyPoolEntries);
- }
-
- public void dump(DataOutputStream dos) throws IOException {
- dos.writeByte(type); // u1 type of value (ANNOTATION == '@')
- a.dump(dos);
- }
-
- public String stringifyValue() {
- throw new RuntimeException("Not implemented yet");
- }
-
- /**
- * Return immutable variant of this AnnotationElementValueGen
- */
- public ElementValueGen getElementValue() {
- return new AnnotationElementValueGen(this.type,a,cpGen);
- }
-
- public AnnotationGen getAnnotation() { return a;}
-
-}
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/AnnotationGen.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/AnnotationGen.java
index e5d2566b7..af442522d 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/AnnotationGen.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/AnnotationGen.java
@@ -28,7 +28,7 @@ public class AnnotationGen {
public static final AnnotationGen[] NO_ANNOTATIONS = new AnnotationGen[0];
private int typeIndex;
- private List<ElementNameValuePairGen> pairs = Collections.emptyList();
+ private List<NameValuePair> pairs = Collections.emptyList();
private ConstantPool cpool;
private boolean isRuntimeVisible = false;
@@ -43,10 +43,10 @@ public class AnnotationGen {
pairs = copyValues(a.getValues(), cpool, copyPoolEntries);
}
- private List<ElementNameValuePairGen> copyValues(List<ElementNameValuePairGen> in, ConstantPool cpool, boolean copyPoolEntries) {
- List<ElementNameValuePairGen> out = new ArrayList<ElementNameValuePairGen>();
- for (ElementNameValuePairGen nvp : in) {
- out.add(new ElementNameValuePairGen(nvp, cpool, copyPoolEntries));
+ private List<NameValuePair> copyValues(List<NameValuePair> in, ConstantPool cpool, boolean copyPoolEntries) {
+ List<NameValuePair> out = new ArrayList<NameValuePair>();
+ for (NameValuePair nvp : in) {
+ out.add(new NameValuePair(nvp, cpool, copyPoolEntries));
}
return out;
}
@@ -58,7 +58,7 @@ public class AnnotationGen {
/**
* Retrieve an immutable version of this AnnotationGen
*/
- public AnnotationGen(ObjectType type, List<ElementNameValuePairGen> pairs, boolean runtimeVisible, ConstantPool cpool) {
+ public AnnotationGen(ObjectType type, List<NameValuePair> pairs, boolean runtimeVisible, ConstantPool cpool) {
this.cpool = cpool;
if (type != null) {
this.typeIndex = cpool.addUtf8(type.getSignature()); // Only null for funky *temporary* FakeAnnotation objects
@@ -73,7 +73,7 @@ public class AnnotationGen {
int elemValuePairCount = dis.readUnsignedShort();
for (int i = 0; i < elemValuePairCount; i++) {
int nidx = dis.readUnsignedShort();
- a.addElementNameValuePair(new ElementNameValuePairGen(nidx, ElementValueGen.readElementValue(dis, cpool), cpool));
+ a.addElementNameValuePair(new NameValuePair(nidx, ElementValue.readElementValue(dis, cpool), cpool));
}
a.isRuntimeVisible(b);
return a;
@@ -83,14 +83,14 @@ public class AnnotationGen {
dos.writeShort(typeIndex); // u2 index of type name in cpool
dos.writeShort(pairs.size()); // u2 element_value pair count
for (int i = 0; i < pairs.size(); i++) {
- ElementNameValuePairGen envp = pairs.get(i);
+ NameValuePair envp = pairs.get(i);
envp.dump(dos);
}
}
- public void addElementNameValuePair(ElementNameValuePairGen evp) {
+ public void addElementNameValuePair(NameValuePair evp) {
if (pairs == Collections.EMPTY_LIST) {
- pairs = new ArrayList<ElementNameValuePairGen>();
+ pairs = new ArrayList<NameValuePair>();
}
pairs.add(evp);
}
@@ -108,7 +108,7 @@ public class AnnotationGen {
return Utility.signatureToString(getTypeSignature());
}
- public List<ElementNameValuePairGen> getValues() {
+ public List<NameValuePair> getValues() {
return pairs;
}
@@ -149,7 +149,7 @@ public class AnnotationGen {
* @return true if the annotation has a value with the specified name and (toString'd) value
*/
public boolean hasNameValuePair(String name, String value) {
- for (ElementNameValuePairGen pair : pairs) {
+ for (NameValuePair pair : pairs) {
if (pair.getNameString().equals(name)) {
if (pair.getValue().stringifyValue().equals(value)) {
return true;
@@ -163,7 +163,7 @@ public class AnnotationGen {
* @return true if the annotation has a value with the specified name
*/
public boolean hasNamedValue(String name) {
- for (ElementNameValuePairGen pair : pairs) {
+ for (NameValuePair pair : pairs) {
if (pair.getNameString().equals(name)) {
return true;
}
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ArrayElementValue.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ArrayElementValue.java
new file mode 100644
index 000000000..3dd19af71
--- /dev/null
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ArrayElementValue.java
@@ -0,0 +1,84 @@
+/* *******************************************************************
+ * Copyright (c) 2004 IBM
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andy Clement - initial implementation {date}
+ * ******************************************************************/
+
+package org.aspectj.apache.bcel.classfile.annotation;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import org.aspectj.apache.bcel.classfile.ConstantPool;
+
+public class ArrayElementValue extends ElementValue {
+ private static final ElementValue[] NO_VALUES = new ElementValue[0];
+
+ // J5TODO: Should we make this an array or a list? A list would be easier to modify ...
+ private ElementValue[] evalues = NO_VALUES;
+
+ public ElementValue[] getElementValuesArray() {
+ return evalues;
+ }
+
+ public int getElementValuesArraySize() {
+ return evalues.length;
+ }
+
+ public ArrayElementValue(ConstantPool cp) {
+ super(ARRAY, cp);
+ }
+
+ public ArrayElementValue(int type, ElementValue[] datums, ConstantPool cpool) {
+ super(type, cpool);
+ if (type != ARRAY)
+ throw new RuntimeException("Only element values of type array can be built with this ctor");
+ this.evalues = datums;
+ }
+
+ public ArrayElementValue(ArrayElementValue value, ConstantPool cpool, boolean copyPoolEntries) {
+ super(ARRAY, cpool);
+ evalues = new ElementValue[value.getElementValuesArraySize()];
+ ElementValue[] in = value.getElementValuesArray();
+ for (int i = 0; i < in.length; i++) {
+ evalues[i] = ElementValue.copy(in[i], cpool, copyPoolEntries);
+ }
+ }
+
+ @Override
+ public void dump(DataOutputStream dos) throws IOException {
+ dos.writeByte(type); // u1 type of value (ARRAY == '[')
+ dos.writeShort(evalues.length);
+ for (int i = 0; i < evalues.length; i++) {
+ evalues[i].dump(dos);
+ }
+ }
+
+ @Override
+ public String stringifyValue() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("[");
+ for (int i = 0; i < evalues.length; i++) {
+ ElementValue element = evalues[i];
+ sb.append(element.stringifyValue());
+ if ((i + 1) < evalues.length)
+ sb.append(",");
+ }
+ sb.append("]");
+ return sb.toString();
+ }
+
+ public void addElement(ElementValue gen) {
+ ElementValue[] old = evalues;
+ evalues = new ElementValue[evalues.length + 1];
+ System.arraycopy(old, 0, evalues, 0, old.length);
+ evalues[old.length] = gen;
+ }
+
+}
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ArrayElementValueGen.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ArrayElementValueGen.java
deleted file mode 100644
index 10599225a..000000000
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ArrayElementValueGen.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2004 IBM
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andy Clement - initial implementation {date}
- * ******************************************************************/
-
-package org.aspectj.apache.bcel.classfile.annotation;
-
-import java.io.DataOutputStream;
-import java.io.IOException;
-
-import org.aspectj.apache.bcel.classfile.ConstantPool;
-
-
-public class ArrayElementValueGen extends ElementValueGen {
- private static final ElementValueGen[] NO_VALUES = new ElementValueGen[0];
-
- // J5TODO: Should we make this an array or a list? A list would be easier to modify ...
- private ElementValueGen[] evalues = NO_VALUES;
-
- public ElementValueGen[] getElementValuesArray() { return evalues;}
- public int getElementValuesArraySize() { return evalues.length;}
-
- public ArrayElementValueGen(ConstantPool cp) {
- super(ARRAY,cp);
- }
-
- public ArrayElementValueGen(int type, ElementValueGen[] datums, ConstantPool cpool) {
- super(type,cpool);
- if (type != ARRAY)
- throw new RuntimeException("Only element values of type array can be built with this ctor");
- this.evalues = datums;
- }
-
- /**
- * Return immutable variant of this ArrayElementValueGen
- */
- public ElementValueGen getElementValue() {
- ElementValueGen[] immutableData = new ElementValueGen[evalues.length];
- for (int i = 0; i<evalues.length;i++) {
- immutableData[i] = evalues[i];
- }
- return new ArrayElementValueGen(type,immutableData,cpGen);
- }
-
- /**
- * @param value
- * @param cpool
- */
- public ArrayElementValueGen(ArrayElementValueGen value, ConstantPool cpool,boolean copyPoolEntries) {
- super(ARRAY,cpool);
- evalues = new ElementValueGen[value.getElementValuesArraySize()];
- ElementValueGen[] in = value.getElementValuesArray();
- for (int i = 0; i < in.length; i++) {
- evalues[i]=ElementValueGen.copy(in[i],cpool,copyPoolEntries);
- }
- }
-
- public void dump(DataOutputStream dos) throws IOException {
- dos.writeByte(type); // u1 type of value (ARRAY == '[')
- dos.writeShort(evalues.length);
- for (int i =0;i<evalues.length;i++) {
- evalues[i].dump(dos);
- }
- }
-
- public String stringifyValue() {
- StringBuffer sb = new StringBuffer();
- sb.append("[");
- for (int i =0;i<evalues.length;i++) {
- ElementValueGen element = evalues[i];
- sb.append(element.stringifyValue());
- if ((i+1)<evalues.length) sb.append(",");
- }
- sb.append("]");
- return sb.toString();
- }
-
-
- public void addElement(ElementValueGen gen) {
- ElementValueGen[] old = evalues;
- evalues = new ElementValueGen[evalues.length+1];
- System.arraycopy(old,0,evalues,0,old.length);
- evalues[old.length]=gen;
- }
-
-}
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ClassElementValueGen.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ClassElementValue.java
index 82c1559b0..a4e18b6d4 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ClassElementValueGen.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ClassElementValue.java
@@ -19,19 +19,19 @@ import org.aspectj.apache.bcel.classfile.ConstantPool;
import org.aspectj.apache.bcel.classfile.ConstantUtf8;
import org.aspectj.apache.bcel.generic.ObjectType;
-public class ClassElementValueGen extends ElementValueGen {
+public class ClassElementValue extends ElementValue {
// For primitive types and string type, this points to the value entry in the cpool
// For 'class' this points to the class entry in the cpool
private int idx;
- protected ClassElementValueGen(int typeIdx, ConstantPool cpool) {
- super(ElementValueGen.CLASS, cpool);
+ protected ClassElementValue(int typeIdx, ConstantPool cpool) {
+ super(ElementValue.CLASS, cpool);
this.idx = typeIdx;
}
- public ClassElementValueGen(ObjectType t, ConstantPool cpool) {
- super(ElementValueGen.CLASS, cpool);
+ public ClassElementValue(ObjectType t, ConstantPool cpool) {
+ super(ElementValue.CLASS, cpool);
// this.idx = cpool.addClass(t);
idx = cpool.addUtf8(t.getSignature());
}
@@ -42,7 +42,7 @@ public class ClassElementValueGen extends ElementValueGen {
// public ElementValueGen getElementValue() {
// return new ClassElementValueGen(type,idx,cpGen);
// }
- public ClassElementValueGen(ClassElementValueGen value, ConstantPool cpool, boolean copyPoolEntries) {
+ public ClassElementValue(ClassElementValue value, ConstantPool cpool, boolean copyPoolEntries) {
super(CLASS, cpool);
if (copyPoolEntries) {
// idx = cpool.addClass(value.getClassString());
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ElementValue.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ElementValue.java
new file mode 100644
index 000000000..511afe2b1
--- /dev/null
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ElementValue.java
@@ -0,0 +1,135 @@
+/* *******************************************************************
+ * Copyright (c) 2004 IBM
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andy Clement - initial implementation {date}
+ * ******************************************************************/
+
+package org.aspectj.apache.bcel.classfile.annotation;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import org.aspectj.apache.bcel.classfile.ConstantPool;
+
+public abstract class ElementValue {
+
+ public static final int STRING = 's';
+ public static final int ENUM_CONSTANT = 'e';
+ public static final int CLASS = 'c';
+ public static final int ANNOTATION = '@';
+ public static final int ARRAY = '[';
+
+ public static final int PRIMITIVE_INT = 'I';
+ public static final int PRIMITIVE_BYTE = 'B';
+ public static final int PRIMITIVE_CHAR = 'C';
+ public static final int PRIMITIVE_DOUBLE = 'D';
+ public static final int PRIMITIVE_FLOAT = 'F';
+ public static final int PRIMITIVE_LONG = 'J';
+ public static final int PRIMITIVE_SHORT = 'S';
+ public static final int PRIMITIVE_BOOLEAN = 'Z';
+
+ protected int type;
+ protected ConstantPool cpool;
+
+ protected ElementValue(int type, ConstantPool cpool) {
+ this.type = type;
+ this.cpool = cpool;
+ }
+
+ public int getElementValueType() {
+ return type;
+ }
+
+ public abstract String stringifyValue();
+
+ public abstract void dump(DataOutputStream dos) throws IOException;
+
+ public static ElementValue readElementValue(DataInputStream dis, ConstantPool cpGen) throws IOException {
+ int type = dis.readUnsignedByte();
+ switch (type) {
+ case 'B': // byte
+ return new SimpleElementValue(PRIMITIVE_BYTE, dis.readUnsignedShort(), cpGen);
+ case 'C': // char
+ return new SimpleElementValue(PRIMITIVE_CHAR, dis.readUnsignedShort(), cpGen);
+ case 'D': // double
+ return new SimpleElementValue(PRIMITIVE_DOUBLE, dis.readUnsignedShort(), cpGen);
+ case 'F': // float
+ return new SimpleElementValue(PRIMITIVE_FLOAT, dis.readUnsignedShort(), cpGen);
+ case 'I': // int
+ return new SimpleElementValue(PRIMITIVE_INT, dis.readUnsignedShort(), cpGen);
+ case 'J': // long
+ return new SimpleElementValue(PRIMITIVE_LONG, dis.readUnsignedShort(), cpGen);
+ case 'S': // short
+ return new SimpleElementValue(PRIMITIVE_SHORT, dis.readUnsignedShort(), cpGen);
+ case 'Z': // boolean
+ return new SimpleElementValue(PRIMITIVE_BOOLEAN, dis.readUnsignedShort(), cpGen);
+ case 's': // String
+ return new SimpleElementValue(STRING, dis.readUnsignedShort(), cpGen);
+
+ case 'e': // Enum constant
+ return new EnumElementValue(dis.readUnsignedShort(), dis.readUnsignedShort(), cpGen);
+
+ case 'c': // Class
+ return new ClassElementValue(dis.readUnsignedShort(), cpGen);
+
+ // FIXME should this be true here? or should it be the value for the containing annotation?
+ case '@': // Annotation
+ return new AnnotationElementValue(ANNOTATION, AnnotationGen.read(dis, cpGen, true), cpGen);
+
+ case '[': // Array
+ int numArrayVals = dis.readUnsignedShort();
+ ElementValue[] evalues = new ElementValue[numArrayVals];
+ for (int j = 0; j < numArrayVals; j++) {
+ evalues[j] = ElementValue.readElementValue(dis, cpGen);
+ }
+ return new ArrayElementValue(ARRAY, evalues, cpGen);
+
+ default:
+ throw new RuntimeException("Unexpected element value kind in annotation: " + type);
+ }
+ }
+
+ protected ConstantPool getConstantPool() {
+ return cpool;
+ }
+
+ /**
+ * Creates an (modifiable) ElementValueGen copy of an (immutable) ElementValue - constant pool is assumed correct.
+ */
+ public static ElementValue copy(ElementValue value, ConstantPool cpool, boolean copyPoolEntries) {
+ switch (value.getElementValueType()) {
+ case 'B': // byte
+ case 'C': // char
+ case 'D': // double
+ case 'F': // float
+ case 'I': // int
+ case 'J': // long
+ case 'S': // short
+ case 'Z': // boolean
+ case 's': // String
+ return new SimpleElementValue((SimpleElementValue) value, cpool, copyPoolEntries);
+
+ case 'e': // Enum constant
+ return new EnumElementValue((EnumElementValue) value, cpool, copyPoolEntries);
+
+ case '@': // Annotation
+ return new AnnotationElementValue((AnnotationElementValue) value, cpool, copyPoolEntries);
+
+ case '[': // Array
+ return new ArrayElementValue((ArrayElementValue) value, cpool, copyPoolEntries);
+
+ case 'c': // Class
+ return new ClassElementValue((ClassElementValue) value, cpool, copyPoolEntries);
+
+ default:
+ throw new RuntimeException("Not implemented yet! (" + value.getElementValueType() + ")");
+ }
+ }
+}
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ElementValueGen.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ElementValueGen.java
deleted file mode 100644
index e575ff366..000000000
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ElementValueGen.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2004 IBM
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andy Clement - initial implementation {date}
- * ******************************************************************/
-
-package org.aspectj.apache.bcel.classfile.annotation;
-
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-
-import org.aspectj.apache.bcel.classfile.ConstantPool;
-
-public abstract class ElementValueGen {
-
- protected int type;
- protected ConstantPool cpGen;
-
-
- protected ElementValueGen(int type,ConstantPool cpGen) {
- this.type = type;
- this.cpGen = cpGen;
- }
-
-// /**
-// * Subtypes return an immutable variant of the ElementValueGen
-// */
-// public abstract ElementValueGen getElementValue();
-
- public int getElementValueType() {
- return type;
- }
-
- public abstract String stringifyValue();
- public abstract void dump(DataOutputStream dos) throws IOException;
-
- public static final int STRING = 's';
- public static final int ENUM_CONSTANT = 'e';
- public static final int CLASS = 'c';
- public static final int ANNOTATION = '@';
- public static final int ARRAY = '[';
-
- public static final int PRIMITIVE_INT = 'I';
- public static final int PRIMITIVE_BYTE = 'B';
- public static final int PRIMITIVE_CHAR = 'C';
- public static final int PRIMITIVE_DOUBLE = 'D';
- public static final int PRIMITIVE_FLOAT = 'F';
- public static final int PRIMITIVE_LONG = 'J';
- public static final int PRIMITIVE_SHORT = 'S';
- public static final int PRIMITIVE_BOOLEAN= 'Z';
-
- public static ElementValueGen readElementValue(DataInputStream dis,ConstantPool cpGen) throws IOException {
- int type= dis.readUnsignedByte();
- switch (type) {
- case 'B': // byte
- return new SimpleElementValueGen(PRIMITIVE_BYTE,dis.readUnsignedShort(),cpGen);
- case 'C': // char
- return new SimpleElementValueGen(PRIMITIVE_CHAR,dis.readUnsignedShort(),cpGen);
- case 'D': // double
- return new SimpleElementValueGen(PRIMITIVE_DOUBLE,dis.readUnsignedShort(),cpGen);
- case 'F': // float
- return new SimpleElementValueGen(PRIMITIVE_FLOAT,dis.readUnsignedShort(),cpGen);
- case 'I': // int
- return new SimpleElementValueGen(PRIMITIVE_INT,dis.readUnsignedShort(),cpGen);
- case 'J': // long
- return new SimpleElementValueGen(PRIMITIVE_LONG,dis.readUnsignedShort(),cpGen);
- case 'S': // short
- return new SimpleElementValueGen(PRIMITIVE_SHORT,dis.readUnsignedShort(),cpGen);
- case 'Z': // boolean
- return new SimpleElementValueGen(PRIMITIVE_BOOLEAN,dis.readUnsignedShort(),cpGen);
- case 's': // String
- return new SimpleElementValueGen(STRING,dis.readUnsignedShort(),cpGen);
-
- case 'e': // Enum constant
- return new EnumElementValueGen(dis.readUnsignedShort(),dis.readUnsignedShort(),cpGen);
-
- case 'c': // Class
- return new ClassElementValueGen(dis.readUnsignedShort(),cpGen);
-
- // FIXME should this be true here? or should it be the value for the containing annotation?
- case '@': // Annotation
- return new AnnotationElementValueGen(ANNOTATION,AnnotationGen.read(dis,cpGen,true),cpGen);
-
- case '[': // Array
- int numArrayVals = dis.readUnsignedShort();
- ElementValueGen[] evalues = new ElementValueGen[numArrayVals];
- for (int j=0;j<numArrayVals;j++) {
- evalues[j] = ElementValueGen.readElementValue(dis,cpGen);
- }
- return new ArrayElementValueGen(ARRAY,evalues,cpGen);
-
- default:
- throw new RuntimeException("Unexpected element value kind in annotation: "+type);
- }
- }
-
- protected ConstantPool getConstantPool() {
- return cpGen;
- }
-
- /**
- * Creates an (modifiable) ElementValueGen copy of an (immutable) ElementValue - constant pool is assumed correct.
- */
- public static ElementValueGen copy(ElementValueGen value,ConstantPool cpool,boolean copyPoolEntries) {
- switch (value.getElementValueType()) {
- case 'B': // byte
- case 'C': // char
- case 'D': // double
- case 'F': // float
- case 'I': // int
- case 'J': // long
- case 'S': // short
- case 'Z': // boolean
- case 's': // String
- return new SimpleElementValueGen((SimpleElementValueGen)value,cpool,copyPoolEntries);
-
- case 'e': // Enum constant
- return new EnumElementValueGen((EnumElementValueGen)value,cpool,copyPoolEntries);
-
- case '@': // Annotation
- return new AnnotationElementValueGen((AnnotationElementValueGen)value,cpool,copyPoolEntries);
-
- case '[': // Array
- return new ArrayElementValueGen((ArrayElementValueGen)value,cpool,copyPoolEntries);
-
- case 'c': // Class
- return new ClassElementValueGen((ClassElementValueGen)value,cpool,copyPoolEntries);
-
- default:
- throw new RuntimeException("Not implemented yet! ("+value.getElementValueType()+")");
- }
- }
-}
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/EnumElementValueGen.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/EnumElementValue.java
index c0198d240..b7adc1781 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/EnumElementValueGen.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/EnumElementValue.java
@@ -20,7 +20,7 @@ import org.aspectj.apache.bcel.classfile.ConstantPool;
import org.aspectj.apache.bcel.classfile.ConstantUtf8;
import org.aspectj.apache.bcel.generic.ObjectType;
-public class EnumElementValueGen extends ElementValueGen {
+public class EnumElementValue extends ElementValue {
// For enum types, these two indices point to the type and value
private int typeIdx;
@@ -30,8 +30,8 @@ public class EnumElementValueGen extends ElementValueGen {
* This ctor assumes the constant pool already contains the right type and value - as indicated by typeIdx and valueIdx. This
* ctor is used for deserialization
*/
- protected EnumElementValueGen(int typeIdx, int valueIdx, ConstantPool cpool) {
- super(ElementValueGen.ENUM_CONSTANT, cpool);
+ protected EnumElementValue(int typeIdx, int valueIdx, ConstantPool cpool) {
+ super(ElementValue.ENUM_CONSTANT, cpool);
if (type != ENUM_CONSTANT)
throw new RuntimeException("Only element values of type enum can be built with this ctor");
this.typeIdx = typeIdx;
@@ -46,13 +46,13 @@ public class EnumElementValueGen extends ElementValueGen {
// return new EnumElementValueGen(type,typeIdx,valueIdx,cpGen);
// }
- public EnumElementValueGen(ObjectType t, String value, ConstantPool cpool) {
- super(ElementValueGen.ENUM_CONSTANT, cpool);
+ public EnumElementValue(ObjectType t, String value, ConstantPool cpool) {
+ super(ElementValue.ENUM_CONSTANT, cpool);
typeIdx = cpool.addUtf8(t.getSignature());// was addClass(t);
valueIdx = cpool.addUtf8(value);// was addString(value);
}
- public EnumElementValueGen(EnumElementValueGen value, ConstantPool cpool, boolean copyPoolEntries) {
+ public EnumElementValue(EnumElementValue value, ConstantPool cpool, boolean copyPoolEntries) {
super(ENUM_CONSTANT, cpool);
if (copyPoolEntries) {
typeIdx = cpool.addUtf8(value.getEnumTypeString());// was addClass(value.getEnumTypeString());
@@ -76,9 +76,9 @@ public class EnumElementValueGen extends ElementValueGen {
@Override
public String stringifyValue() {
StringBuffer sb = new StringBuffer();
- ConstantUtf8 cu8 = (ConstantUtf8) cpGen.getConstant(typeIdx, Constants.CONSTANT_Utf8);
+ ConstantUtf8 cu8 = (ConstantUtf8) cpool.getConstant(typeIdx, Constants.CONSTANT_Utf8);
sb.append(cu8.getValue());
- cu8 = (ConstantUtf8) cpGen.getConstant(valueIdx, Constants.CONSTANT_Utf8);
+ cu8 = (ConstantUtf8) cpool.getConstant(valueIdx, Constants.CONSTANT_Utf8);
sb.append(cu8.getValue());
return sb.toString();
}
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ElementNameValuePairGen.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/NameValuePair.java
index c186fb277..99b4211ec 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ElementNameValuePairGen.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/NameValuePair.java
@@ -17,12 +17,12 @@ import java.io.IOException;
import org.aspectj.apache.bcel.classfile.ConstantPool;
-public class ElementNameValuePairGen {
+public class NameValuePair {
private int nameIdx;
- private ElementValueGen value;
+ private ElementValue value;
private ConstantPool cpool;
- public ElementNameValuePairGen(ElementNameValuePairGen pair, ConstantPool cpool, boolean copyPoolEntries) {
+ public NameValuePair(NameValuePair pair, ConstantPool cpool, boolean copyPoolEntries) {
this.cpool = cpool;
// J5ASSERT:
// Could assert nvp.getNameString() points to the same thing as cpool.getConstant(nvp.getNameIndex())
@@ -34,16 +34,16 @@ public class ElementNameValuePairGen {
} else {
nameIdx = pair.getNameIndex();
}
- value = ElementValueGen.copy(pair.getValue(), cpool, copyPoolEntries);
+ value = ElementValue.copy(pair.getValue(), cpool, copyPoolEntries);
}
- protected ElementNameValuePairGen(int idx, ElementValueGen value, ConstantPool cpool) {
+ protected NameValuePair(int idx, ElementValue value, ConstantPool cpool) {
this.nameIdx = idx;
this.value = value;
this.cpool = cpool;
}
- public ElementNameValuePairGen(String name, ElementValueGen value, ConstantPool cpool) {
+ public NameValuePair(String name, ElementValue value, ConstantPool cpool) {
this.nameIdx = cpool.addUtf8(name);
this.value = value;
this.cpool = cpool;
@@ -62,7 +62,7 @@ public class ElementNameValuePairGen {
return cpool.getConstantUtf8(nameIdx).getValue();
}
- public final ElementValueGen getValue() {
+ public final ElementValue getValue() {
return value;
}
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeAnnotations.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeAnnos.java
index 0530dca47..a6b6534df 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeAnnotations.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeAnnos.java
@@ -11,48 +11,46 @@ import java.util.List;
import org.aspectj.apache.bcel.classfile.Attribute;
import org.aspectj.apache.bcel.classfile.ConstantPool;
+public abstract class RuntimeAnnos extends Attribute {
-public abstract class RuntimeAnnotations extends Attribute {
-
- private List /*Annotation*/<AnnotationGen> annotations;
+ private List<AnnotationGen> annotations;
private boolean visible;
-
+
// Keep just a byte stream of the data until someone actually asks for it
private boolean inflated = false;
private byte[] annotation_data;
-
- public RuntimeAnnotations(byte attrid, boolean visible,
- int nameIdx, int len,
- ConstantPool cpool) {
- super(attrid,nameIdx,len,cpool);
- this.visible = visible;
+
+ public RuntimeAnnos(byte attrid, boolean visible, int nameIdx, int len, ConstantPool cpool) {
+ super(attrid, nameIdx, len, cpool);
+ this.visible = visible;
annotations = new ArrayList<AnnotationGen>();
}
-
- public RuntimeAnnotations(byte attrid,boolean visible,int nameIdx,int len,byte[] data,ConstantPool cpool) {
- super(attrid,nameIdx,len,cpool);
+
+ public RuntimeAnnos(byte attrid, boolean visible, int nameIdx, int len, byte[] data, ConstantPool cpool) {
+ super(attrid, nameIdx, len, cpool);
this.visible = visible;
annotations = new ArrayList<AnnotationGen>();
annotation_data = data;
}
-
+
public List<AnnotationGen> getAnnotations() {
- if (!inflated) inflate();
+ if (!inflated)
+ inflate();
return annotations;
}
-
+
public boolean areVisible() {
return visible;
}
- protected void readAnnotations(DataInputStream dis,ConstantPool cpool) throws IOException {
+ protected void readAnnotations(DataInputStream dis, ConstantPool cpool) throws IOException {
annotation_data = new byte[length];
- dis.read(annotation_data,0,length);
+ dis.read(annotation_data, 0, length);
}
-
+
protected void writeAnnotations(DataOutputStream dos) throws IOException {
if (!inflated) {
- dos.write(annotation_data,0,length);
+ dos.write(annotation_data, 0, length);
} else {
dos.writeShort(annotations.size());
for (Iterator<AnnotationGen> i = annotations.iterator(); i.hasNext();) {
@@ -65,9 +63,9 @@ public abstract class RuntimeAnnotations extends Attribute {
private void inflate() {
try {
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(annotation_data));
- int numberOfAnnotations = dis.readUnsignedShort();
- for (int i = 0 ;i<numberOfAnnotations;i++) {
- annotations.add(AnnotationGen.read(dis,getConstantPool(),visible));
+ int numberOfAnnotations = dis.readUnsignedShort();
+ for (int i = 0; i < numberOfAnnotations; i++) {
+ annotations.add(AnnotationGen.read(dis, getConstantPool(), visible));
}
dis.close();
inflated = true;
@@ -75,10 +73,10 @@ public abstract class RuntimeAnnotations extends Attribute {
throw new RuntimeException("Unabled to inflate annotation data, badly formed? ");
}
}
-
+
/** FOR TESTING ONLY: Tells you if the annotations have been inflated to an object graph */
public boolean isInflated() {
return inflated;
}
-
+
}
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeInvisibleAnnotations.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeInvisAnnos.java
index cb372b2c9..a2ab520d3 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeInvisibleAnnotations.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeInvisAnnos.java
@@ -9,19 +9,19 @@ import org.aspectj.apache.bcel.classfile.Attribute;
import org.aspectj.apache.bcel.classfile.ConstantPool;
import org.aspectj.apache.bcel.classfile.ClassVisitor;
-public class RuntimeInvisibleAnnotations extends RuntimeAnnotations {
+public class RuntimeInvisAnnos extends RuntimeAnnos {
- public RuntimeInvisibleAnnotations(int nameIdx, int len, ConstantPool cpool) {
+ public RuntimeInvisAnnos(int nameIdx, int len, ConstantPool cpool) {
super(Constants.ATTR_RUNTIME_INVISIBLE_ANNOTATIONS, false, nameIdx, len, cpool);
}
- public RuntimeInvisibleAnnotations(int nameIdx, int len,
+ public RuntimeInvisAnnos(int nameIdx, int len,
DataInputStream dis,ConstantPool cpool) throws IOException {
this(nameIdx, len, cpool);
readAnnotations(dis,cpool);
}
- public RuntimeInvisibleAnnotations(int nameIndex, int len, byte[] rvaData,ConstantPool cpool) {
+ public RuntimeInvisAnnos(int nameIndex, int len, byte[] rvaData,ConstantPool cpool) {
super(Constants.ATTR_RUNTIME_INVISIBLE_ANNOTATIONS,false,nameIndex,len,rvaData,cpool);
}
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeInvisibleParameterAnnotations.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeInvisParamAnnos.java
index 4fb4bb7bd..b5d7bb119 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeInvisibleParameterAnnotations.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeInvisParamAnnos.java
@@ -8,19 +8,19 @@ import org.aspectj.apache.bcel.classfile.Attribute;
import org.aspectj.apache.bcel.classfile.ConstantPool;
import org.aspectj.apache.bcel.classfile.ClassVisitor;
-public class RuntimeInvisibleParameterAnnotations extends RuntimeParameterAnnotations {
+public class RuntimeInvisParamAnnos extends RuntimeParamAnnos {
- public RuntimeInvisibleParameterAnnotations(int nameIdx, int len, ConstantPool cpool) {
+ public RuntimeInvisParamAnnos(int nameIdx, int len, ConstantPool cpool) {
super(Constants.ATTR_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS, false, nameIdx, len, cpool);
}
- public RuntimeInvisibleParameterAnnotations(int nameIdx, int len,
+ public RuntimeInvisParamAnnos(int nameIdx, int len,
DataInputStream dis,ConstantPool cpool) throws IOException {
this(nameIdx, len, cpool);
readParameterAnnotations(dis,cpool);
}
- public RuntimeInvisibleParameterAnnotations(int nameIndex, int len, byte[] rvaData,ConstantPool cpool) {
+ public RuntimeInvisParamAnnos(int nameIndex, int len, byte[] rvaData,ConstantPool cpool) {
super(Constants.ATTR_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS,false,nameIndex,len,rvaData,cpool);
}
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeParameterAnnotations.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeParamAnnos.java
index 7d57cb915..4bd8644c5 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeParameterAnnotations.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeParamAnnos.java
@@ -10,7 +10,7 @@ import java.util.List;
import org.aspectj.apache.bcel.classfile.Attribute;
import org.aspectj.apache.bcel.classfile.ConstantPool;
-public abstract class RuntimeParameterAnnotations extends Attribute {
+public abstract class RuntimeParamAnnos extends Attribute {
private List /*Annotation[]*/<AnnotationGen[]> parameterAnnotations;
private boolean visible;
@@ -21,14 +21,14 @@ public abstract class RuntimeParameterAnnotations extends Attribute {
private byte[] annotation_data;
- public RuntimeParameterAnnotations(byte attrid, boolean visible,
+ public RuntimeParamAnnos(byte attrid, boolean visible,
int nameIdx, int len, ConstantPool cpool) {
super(attrid,nameIdx,len,cpool);
this.visible = visible;
parameterAnnotations = new ArrayList<AnnotationGen[]>();
}
- public RuntimeParameterAnnotations(byte attrid,boolean visible,int nameIdx,int len,byte[] data,ConstantPool cpool) {
+ public RuntimeParamAnnos(byte attrid,boolean visible,int nameIdx,int len,byte[] data,ConstantPool cpool) {
super(attrid,nameIdx,len,cpool);
this.visible = visible;
parameterAnnotations = new ArrayList<AnnotationGen[]>();
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeVisibleAnnotations.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeVisAnnos.java
index 5d6e427d4..aa3f49eac 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeVisibleAnnotations.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeVisAnnos.java
@@ -9,19 +9,19 @@ import org.aspectj.apache.bcel.classfile.Attribute;
import org.aspectj.apache.bcel.classfile.ConstantPool;
import org.aspectj.apache.bcel.classfile.ClassVisitor;
-public class RuntimeVisibleAnnotations extends RuntimeAnnotations {
+public class RuntimeVisAnnos extends RuntimeAnnos {
- public RuntimeVisibleAnnotations(int nameIdx, int len, ConstantPool cpool) {
+ public RuntimeVisAnnos(int nameIdx, int len, ConstantPool cpool) {
super(Constants.ATTR_RUNTIME_VISIBLE_ANNOTATIONS, true, nameIdx, len, cpool);
}
- public RuntimeVisibleAnnotations(int nameIdx, int len,
+ public RuntimeVisAnnos(int nameIdx, int len,
DataInputStream dis,ConstantPool cpool) throws IOException {
this(nameIdx, len, cpool);
readAnnotations(dis,cpool);
}
- public RuntimeVisibleAnnotations(int nameIndex, int len, byte[] rvaData,ConstantPool cpool) {
+ public RuntimeVisAnnos(int nameIndex, int len, byte[] rvaData,ConstantPool cpool) {
super(Constants.ATTR_RUNTIME_VISIBLE_ANNOTATIONS,true,nameIndex,len,rvaData,cpool);
}
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeVisibleParameterAnnotations.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeVisParamAnnos.java
index b0eeea8bc..ccd1aa7d2 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeVisibleParameterAnnotations.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeVisParamAnnos.java
@@ -8,17 +8,17 @@ import org.aspectj.apache.bcel.classfile.Attribute;
import org.aspectj.apache.bcel.classfile.ConstantPool;
import org.aspectj.apache.bcel.classfile.ClassVisitor;
-public class RuntimeVisibleParameterAnnotations extends RuntimeParameterAnnotations {
+public class RuntimeVisParamAnnos extends RuntimeParamAnnos {
- public RuntimeVisibleParameterAnnotations(int nameIdx, int len, ConstantPool cpool) {
+ public RuntimeVisParamAnnos(int nameIdx, int len, ConstantPool cpool) {
super(Constants.ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS, true, nameIdx, len, cpool);
}
- public RuntimeVisibleParameterAnnotations(int nameIndex, int len, byte[] rvaData,ConstantPool cpool) {
+ public RuntimeVisParamAnnos(int nameIndex, int len, byte[] rvaData,ConstantPool cpool) {
super(Constants.ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS,true,nameIndex,len,rvaData,cpool);
}
- public RuntimeVisibleParameterAnnotations(int nameIdx, int len,
+ public RuntimeVisParamAnnos(int nameIdx, int len,
DataInputStream dis,ConstantPool cpool) throws IOException {
this(nameIdx, len, cpool);
readParameterAnnotations(dis,cpool);
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/SimpleElementValueGen.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/SimpleElementValue.java
index b1276bab3..b8b354c47 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/SimpleElementValueGen.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/SimpleElementValue.java
@@ -23,7 +23,7 @@ import org.aspectj.apache.bcel.classfile.ConstantLong;
import org.aspectj.apache.bcel.classfile.ConstantPool;
import org.aspectj.apache.bcel.classfile.ConstantUtf8;
-public class SimpleElementValueGen extends ElementValueGen {
+public class SimpleElementValue extends ElementValue {
// For primitive types and string type, this points to the value entry in the cpGen
// For 'class' this points to the class entry in the cpGen
@@ -36,47 +36,47 @@ public class SimpleElementValueGen extends ElementValueGen {
* Protected ctor used for deserialization, doesn't *put* an entry in the constant pool, assumes the one at the supplied index
* is correct.
*/
- protected SimpleElementValueGen(int type, int idx, ConstantPool cpGen) {
+ protected SimpleElementValue(int type, int idx, ConstantPool cpGen) {
super(type, cpGen);
this.idx = idx;
}
- public SimpleElementValueGen(int type, ConstantPool cpGen, int value) {
+ public SimpleElementValue(int type, ConstantPool cpGen, int value) {
super(type, cpGen);
idx = cpGen.addInteger(value);
}
- public SimpleElementValueGen(int type, ConstantPool cpGen, long value) {
+ public SimpleElementValue(int type, ConstantPool cpGen, long value) {
super(type, cpGen);
idx = cpGen.addLong(value);
}
- public SimpleElementValueGen(int type, ConstantPool cpGen, double value) {
+ public SimpleElementValue(int type, ConstantPool cpGen, double value) {
super(type, cpGen);
idx = cpGen.addDouble(value);
}
- public SimpleElementValueGen(int type, ConstantPool cpGen, float value) {
+ public SimpleElementValue(int type, ConstantPool cpGen, float value) {
super(type, cpGen);
idx = cpGen.addFloat(value);
}
- public SimpleElementValueGen(int type, ConstantPool cpGen, short value) {
+ public SimpleElementValue(int type, ConstantPool cpGen, short value) {
super(type, cpGen);
idx = cpGen.addInteger(value);
}
- public SimpleElementValueGen(int type, ConstantPool cpGen, byte value) {
+ public SimpleElementValue(int type, ConstantPool cpGen, byte value) {
super(type, cpGen);
idx = cpGen.addInteger(value);
}
- public SimpleElementValueGen(int type, ConstantPool cpGen, char value) {
+ public SimpleElementValue(int type, ConstantPool cpGen, char value) {
super(type, cpGen);
idx = cpGen.addInteger(value);
}
- public SimpleElementValueGen(int type, ConstantPool cpGen, boolean value) {
+ public SimpleElementValue(int type, ConstantPool cpGen, boolean value) {
super(type, cpGen);
if (value)
idx = cpGen.addInteger(1);
@@ -84,7 +84,7 @@ public class SimpleElementValueGen extends ElementValueGen {
idx = cpGen.addInteger(0);
}
- public SimpleElementValueGen(int type, ConstantPool cpGen, String value) {
+ public SimpleElementValue(int type, ConstantPool cpGen, String value) {
super(type, cpGen);
idx = cpGen.addUtf8(value);
}
@@ -92,49 +92,49 @@ public class SimpleElementValueGen extends ElementValueGen {
public byte getValueByte() {
if (type != PRIMITIVE_BYTE)
throw new RuntimeException("Dont call getValueByte() on a non BYTE ElementValue");
- ConstantInteger c = (ConstantInteger) cpGen.getConstant(idx, Constants.CONSTANT_Integer);
+ ConstantInteger c = (ConstantInteger) cpool.getConstant(idx, Constants.CONSTANT_Integer);
return (byte) c.getIntValue();
}
public char getValueChar() {
if (type != PRIMITIVE_CHAR)
throw new RuntimeException("Dont call getValueChar() on a non CHAR ElementValue");
- ConstantInteger c = (ConstantInteger) cpGen.getConstant(idx, Constants.CONSTANT_Integer);
+ ConstantInteger c = (ConstantInteger) cpool.getConstant(idx, Constants.CONSTANT_Integer);
return (char) c.getIntValue();
}
public long getValueLong() {
if (type != PRIMITIVE_LONG)
throw new RuntimeException("Dont call getValueLong() on a non LONG ElementValue");
- ConstantLong j = (ConstantLong) cpGen.getConstant(idx);
+ ConstantLong j = (ConstantLong) cpool.getConstant(idx);
return j.getValue();
}
public float getValueFloat() {
if (type != PRIMITIVE_FLOAT)
throw new RuntimeException("Dont call getValueFloat() on a non FLOAT ElementValue");
- ConstantFloat f = (ConstantFloat) cpGen.getConstant(idx);
+ ConstantFloat f = (ConstantFloat) cpool.getConstant(idx);
return f.getValue();
}
public double getValueDouble() {
if (type != PRIMITIVE_DOUBLE)
throw new RuntimeException("Dont call getValueDouble() on a non DOUBLE ElementValue");
- ConstantDouble d = (ConstantDouble) cpGen.getConstant(idx);
+ ConstantDouble d = (ConstantDouble) cpool.getConstant(idx);
return d.getValue();
}
public boolean getValueBoolean() {
if (type != PRIMITIVE_BOOLEAN)
throw new RuntimeException("Dont call getValueBoolean() on a non BOOLEAN ElementValue");
- ConstantInteger bo = (ConstantInteger) cpGen.getConstant(idx);
+ ConstantInteger bo = (ConstantInteger) cpool.getConstant(idx);
return (bo.getValue() != 0);
}
public short getValueShort() {
if (type != PRIMITIVE_SHORT)
throw new RuntimeException("Dont call getValueShort() on a non SHORT ElementValue");
- ConstantInteger s = (ConstantInteger) cpGen.getConstant(idx);
+ ConstantInteger s = (ConstantInteger) cpool.getConstant(idx);
return (short) s.getIntValue();
}
@@ -142,7 +142,7 @@ public class SimpleElementValueGen extends ElementValueGen {
* The boolean controls whether we copy info from the 'old' constant pool to the 'new'. You need to use this ctor if the
* annotation is being copied from one file to another.
*/
- public SimpleElementValueGen(SimpleElementValueGen value, ConstantPool cpool, boolean copyPoolEntries) {
+ public SimpleElementValue(SimpleElementValue value, ConstantPool cpool, boolean copyPoolEntries) {
super(value.getElementValueType(), cpool);
if (!copyPoolEntries) {
// J5ASSERT: Could assert value.stringifyValue() is the same as
@@ -187,13 +187,6 @@ public class SimpleElementValueGen extends ElementValueGen {
}
}
- /**
- * Return immutable variant
- */
- public ElementValueGen getElementValue() {
- return new SimpleElementValueGen(type, idx, cpGen);
- }
-
public int getIndex() {
return idx;
}
@@ -201,14 +194,14 @@ public class SimpleElementValueGen extends ElementValueGen {
public String getValueString() {
if (type != STRING)
throw new RuntimeException("Dont call getValueString() on a non STRING ElementValue");
- ConstantUtf8 c = (ConstantUtf8) cpGen.getConstant(idx);
+ ConstantUtf8 c = (ConstantUtf8) cpool.getConstant(idx);
return c.getValue();
}
public int getValueInt() {
if (type != PRIMITIVE_INT)
throw new RuntimeException("Dont call getValueString() on a non STRING ElementValue");
- ConstantInteger c = (ConstantInteger) cpGen.getConstant(idx);
+ ConstantInteger c = (ConstantInteger) cpool.getConstant(idx);
return c.getValue();
}
@@ -217,34 +210,34 @@ public class SimpleElementValueGen extends ElementValueGen {
public String stringifyValue() {
switch (type) {
case PRIMITIVE_INT:
- ConstantInteger c = (ConstantInteger) cpGen.getConstant(idx);
+ ConstantInteger c = (ConstantInteger) cpool.getConstant(idx);
return Integer.toString(c.getValue());
case PRIMITIVE_LONG:
- ConstantLong j = (ConstantLong) cpGen.getConstant(idx);
+ ConstantLong j = (ConstantLong) cpool.getConstant(idx);
return Long.toString(j.getValue());
case PRIMITIVE_DOUBLE:
- ConstantDouble d = (ConstantDouble) cpGen.getConstant(idx);
+ ConstantDouble d = (ConstantDouble) cpool.getConstant(idx);
return d.getValue().toString();
case PRIMITIVE_FLOAT:
- ConstantFloat f = (ConstantFloat) cpGen.getConstant(idx);
+ ConstantFloat f = (ConstantFloat) cpool.getConstant(idx);
return Float.toString(f.getValue());
case PRIMITIVE_SHORT:
- ConstantInteger s = (ConstantInteger) cpGen.getConstant(idx);
+ ConstantInteger s = (ConstantInteger) cpool.getConstant(idx);
return Integer.toString(s.getValue());
case PRIMITIVE_BYTE:
- ConstantInteger b = (ConstantInteger) cpGen.getConstant(idx);
+ ConstantInteger b = (ConstantInteger) cpool.getConstant(idx);
return Integer.toString(b.getValue());
case PRIMITIVE_CHAR:
- ConstantInteger ch = (ConstantInteger) cpGen.getConstant(idx);
+ ConstantInteger ch = (ConstantInteger) cpool.getConstant(idx);
return new Character((char) ch.getIntValue()).toString();
case PRIMITIVE_BOOLEAN:
- ConstantInteger bo = (ConstantInteger) cpGen.getConstant(idx);
+ ConstantInteger bo = (ConstantInteger) cpool.getConstant(idx);
if (bo.getValue() == 0)
return "false";
else
return "true";
case STRING:
- ConstantUtf8 cu8 = (ConstantUtf8) cpGen.getConstant(idx);
+ ConstantUtf8 cu8 = (ConstantUtf8) cpool.getConstant(idx);
return cu8.getValue();
default:
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/ClassGen.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/ClassGen.java
index bafc63359..f12bd4491 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/generic/ClassGen.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/ClassGen.java
@@ -75,14 +75,14 @@ import org.aspectj.apache.bcel.classfile.Modifiers;
import org.aspectj.apache.bcel.classfile.SourceFile;
import org.aspectj.apache.bcel.classfile.Utility;
import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen;
-import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisibleAnnotations;
-import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleAnnotations;
+import org.aspectj.apache.bcel.classfile.annotation.RuntimeInvisAnnos;
+import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisAnnos;
/**
* Template class for building up a java class. May be initialized with an existing java class.
*
* @see JavaClass
- * @version $Id: ClassGen.java,v 1.14 2009/09/10 03:59:34 aclement Exp $
+ * @version $Id: ClassGen.java,v 1.15 2009/09/15 19:40:14 aclement Exp $
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
*
* Upgraded, Andy Clement 9th Mar 06 - calculates SUID
@@ -148,14 +148,14 @@ public class ClassGen extends Modifiers implements Cloneable {
// OPTIMIZE Could make unpacking lazy, done on first reference
Attribute[] attributes = clazz.getAttributes();
for (Attribute attr : attributes) {
- if (attr instanceof RuntimeVisibleAnnotations) {
- RuntimeVisibleAnnotations rva = (RuntimeVisibleAnnotations) attr;
+ if (attr instanceof RuntimeVisAnnos) {
+ RuntimeVisAnnos rva = (RuntimeVisAnnos) attr;
List<AnnotationGen> annos = rva.getAnnotations();
for (AnnotationGen a : annos) {
annotationsList.add(new AnnotationGen(a, cpool, false));
}
- } else if (attr instanceof RuntimeInvisibleAnnotations) {
- RuntimeInvisibleAnnotations ria = (RuntimeInvisibleAnnotations) attr;
+ } else if (attr instanceof RuntimeInvisAnnos) {
+ RuntimeInvisAnnos ria = (RuntimeInvisAnnos) attr;
List<AnnotationGen> annos = ria.getAnnotations();
for (AnnotationGen anno : annos) {
annotationsList.add(new AnnotationGen(anno, cpool, false));
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/FieldGen.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/FieldGen.java
index 220844633..fdda9109a 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/generic/FieldGen.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/FieldGen.java
@@ -66,13 +66,13 @@ import org.aspectj.apache.bcel.classfile.ConstantValue;
import org.aspectj.apache.bcel.classfile.Field;
import org.aspectj.apache.bcel.classfile.Utility;
import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen;
-import org.aspectj.apache.bcel.classfile.annotation.RuntimeAnnotations;
+import org.aspectj.apache.bcel.classfile.annotation.RuntimeAnnos;
/**
* Template class for building up a field. The only extraordinary thing one can do is to add a constant value attribute to a field
* (which must of course be compatible with the declared type).
*
- * @version $Id: FieldGen.java,v 1.8 2009/09/14 20:29:10 aclement Exp $
+ * @version $Id: FieldGen.java,v 1.9 2009/09/15 19:40:14 aclement Exp $
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
* @see Field
*/
@@ -109,8 +109,8 @@ public class FieldGen extends FieldGenOrMethodGen {
for (int i = 0; i < attrs.length; i++) {
if (attrs[i] instanceof ConstantValue) {
setValue(((ConstantValue) attrs[i]).getConstantValueIndex());
- } else if (attrs[i] instanceof RuntimeAnnotations) {
- RuntimeAnnotations runtimeAnnotations = (RuntimeAnnotations) attrs[i];
+ } else if (attrs[i] instanceof RuntimeAnnos) {
+ RuntimeAnnos runtimeAnnotations = (RuntimeAnnos) attrs[i];
List<AnnotationGen> l = runtimeAnnotations.getAnnotations();
for (Iterator<AnnotationGen> it = l.iterator(); it.hasNext();) {
AnnotationGen element = it.next();
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/FieldGenOrMethodGen.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/FieldGenOrMethodGen.java
index 74ede06ec..ff8b6f42c 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/generic/FieldGenOrMethodGen.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/FieldGenOrMethodGen.java
@@ -63,12 +63,12 @@ import org.aspectj.apache.bcel.classfile.ConstantPool;
import org.aspectj.apache.bcel.classfile.Modifiers;
import org.aspectj.apache.bcel.classfile.Utility;
import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen;
-import org.aspectj.apache.bcel.classfile.annotation.RuntimeAnnotations;
+import org.aspectj.apache.bcel.classfile.annotation.RuntimeAnnos;
/**
* Super class for FieldGen and MethodGen objects, since they have some methods in common!
*
- * @version $Id: FieldGenOrMethodGen.java,v 1.7 2009/09/14 20:29:10 aclement Exp $
+ * @version $Id: FieldGenOrMethodGen.java,v 1.8 2009/09/15 19:40:14 aclement Exp $
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
*/
public abstract class FieldGenOrMethodGen extends Modifiers {
@@ -145,7 +145,7 @@ public abstract class FieldGenOrMethodGen extends Modifiers {
}
protected void addAnnotationsAsAttribute(ConstantPool cp) {
- Collection<RuntimeAnnotations> attrs = Utility.getAnnotationAttributes(cp, annotationList);
+ Collection<RuntimeAnnos> attrs = Utility.getAnnotationAttributes(cp, annotationList);
if (attrs != null) {
for (Attribute attr : attrs) {
addAttribute(attr);
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/MethodGen.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/MethodGen.java
index b85bf0165..15c9000e9 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/generic/MethodGen.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/MethodGen.java
@@ -73,8 +73,8 @@ import org.aspectj.apache.bcel.classfile.LocalVariableTable;
import org.aspectj.apache.bcel.classfile.Method;
import org.aspectj.apache.bcel.classfile.Utility;
import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen;
-import org.aspectj.apache.bcel.classfile.annotation.RuntimeAnnotations;
-import org.aspectj.apache.bcel.classfile.annotation.RuntimeParameterAnnotations;
+import org.aspectj.apache.bcel.classfile.annotation.RuntimeAnnos;
+import org.aspectj.apache.bcel.classfile.annotation.RuntimeParamAnnos;
/**
* Template class for building up a method. This is done by defining exception handlers, adding thrown exceptions, local variables
@@ -84,7 +84,7 @@ import org.aspectj.apache.bcel.classfile.annotation.RuntimeParameterAnnotations;
* While generating code it may be necessary to insert NOP operations. You can use the `removeNOPs' method to get rid off them. The
* resulting method object can be obtained via the `getMethod()' method.
*
- * @version $Id: MethodGen.java,v 1.14 2009/09/14 20:29:10 aclement Exp $
+ * @version $Id: MethodGen.java,v 1.15 2009/09/15 19:40:14 aclement Exp $
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
* @author <A HREF="http://www.vmeng.com/beard">Patrick C. Beard</A> [setMaxStack()]
* @see InstructionList
@@ -329,8 +329,8 @@ public class MethodGen extends FieldGenOrMethodGen {
String[] names = ((ExceptionTable) a).getExceptionNames();
for (int j = 0; j < names.length; j++)
addException(names[j]);
- } else if (a instanceof RuntimeAnnotations) {
- RuntimeAnnotations runtimeAnnotations = (RuntimeAnnotations) a;
+ } else if (a instanceof RuntimeAnnos) {
+ RuntimeAnnos runtimeAnnotations = (RuntimeAnnos) a;
List<AnnotationGen> l = runtimeAnnotations.getAnnotations();
annotationList.addAll(l);
// for (Iterator<AnnotationGen> it = l.iterator(); it.hasNext();) {
@@ -1040,11 +1040,11 @@ public class MethodGen extends FieldGenOrMethodGen {
}
// Find attributes that contain parameter annotation data
List<Attribute> attrs = getAttributes();
- RuntimeParameterAnnotations paramAnnVisAttr = null;
- RuntimeParameterAnnotations paramAnnInvisAttr = null;
+ RuntimeParamAnnos paramAnnVisAttr = null;
+ RuntimeParamAnnos paramAnnInvisAttr = null;
for (Attribute attribute : attrs) {
- if (attribute instanceof RuntimeParameterAnnotations) {
+ if (attribute instanceof RuntimeParamAnnos) {
if (!hasParameterAnnotations) {
param_annotations = new List[parameterTypes.length];
@@ -1054,7 +1054,7 @@ public class MethodGen extends FieldGenOrMethodGen {
}
hasParameterAnnotations = true;
- RuntimeParameterAnnotations rpa = (RuntimeParameterAnnotations) attribute;
+ RuntimeParamAnnos rpa = (RuntimeParamAnnos) attribute;
if (rpa.areVisible())
paramAnnVisAttr = rpa;
else