]> source.dussan.org Git - aspectj.git/commitdiff
refactoring
authoraclement <aclement>
Thu, 10 Sep 2009 15:35:03 +0000 (15:35 +0000)
committeraclement <aclement>
Thu, 10 Sep 2009 15:35:03 +0000 (15:35 +0000)
45 files changed:
bcel-builder/src/org/aspectj/apache/bcel/classfile/Attribute.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/Code.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/Constant.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantCP.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantClass.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantDouble.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantFieldref.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantFloat.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantInteger.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantInterfaceMethodref.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantLong.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantMethodref.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantNameAndType.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantPool.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantString.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantUtf8.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantValue.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/Deprecated.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/EnclosingMethod.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/ExceptionTable.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/Field.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/FieldOrMethod.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/InnerClass.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/InnerClasses.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/LineNumberTable.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/LocalVariable.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/LocalVariableTable.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/LocalVariableTypeTable.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/Method.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/Signature.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/SimpleConstant.java [new file with mode: 0644]
bcel-builder/src/org/aspectj/apache/bcel/classfile/SourceFile.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/StackMap.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/Synthetic.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/Unknown.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/AnnotationGen.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ClassElementValueGen.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/ElementNameValuePairGen.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/EnumElementValueGen.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/SimpleElementValueGen.java
bcel-builder/src/org/aspectj/apache/bcel/generic/FieldOrMethod.java
bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionCP.java
bcel-builder/testsrc/org/aspectj/apache/bcel/classfile/tests/EnclosingMethodAttributeTest.java
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/Pass2Verifier.java
bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/Pass3aVerifier.java

index 2c385c964cc4bd94c28c11d8c7fafb4cefa4c9df..3f730f2174c2104542bd9544d9a9ab5a104e7e69 100644 (file)
@@ -70,7 +70,7 @@ import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleParameterAnnot
  * <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.5 2009/09/09 21:26:54 aclement Exp $
+ * @version $Id: Attribute.java,v 1.6 2009/09/10 15:35:05 aclement Exp $
  * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
  * @see ConstantValue
  * @see SourceFile
@@ -88,27 +88,26 @@ public abstract class Attribute implements Cloneable, Node, Serializable {
        public final static Attribute[] NoAttributes = new Attribute[0];
 
        protected byte tag; // Tag to distinguish subclasses
-       protected int nameIndex; // Points to attribute name in constant pool
-       protected int length; // Content length of attribute field
-       protected ConstantPool constantPool;
+       protected int nameIndex;
+       protected int length;
+       protected ConstantPool cpool;
 
-       protected Attribute(byte tag, int nameIndex, int length, ConstantPool constantPool) {
+       protected Attribute(byte tag, int nameIndex, int length, ConstantPool cpool) {
                this.tag = tag;
                this.nameIndex = nameIndex;
                this.length = length;
-               this.constantPool = constantPool;
+               this.cpool = cpool;
        }
 
-       /** Dump attribute to file stream in binary format */
        public void dump(DataOutputStream file) throws IOException {
                file.writeShort(nameIndex);
                file.writeInt(length);
        }
 
        public static final Attribute readAttribute(DataInputStream file, ConstantPool cpool) throws IOException {
-               byte tag = Constants.ATTR_UNKNOWN; // Unknown attribute
+               byte tag = Constants.ATTR_UNKNOWN;
                int idx = file.readUnsignedShort();
-               String name = cpool.getConstantUtf8(idx).getBytes();
+               String name = cpool.getConstantUtf8(idx).getValue();
                int len = file.readInt();
 
                // Compare strings to find known attribute
@@ -163,7 +162,7 @@ public abstract class Attribute implements Cloneable, Node, Serializable {
        }
 
        public String getName() {
-               return constantPool.getConstantUtf8(nameIndex).getBytes();
+               return cpool.getConstantUtf8(nameIndex).getValue();
        }
 
        public final int getLength() {
@@ -179,7 +178,7 @@ public abstract class Attribute implements Cloneable, Node, Serializable {
        }
 
        public final ConstantPool getConstantPool() {
-               return constantPool;
+               return cpool;
        }
 
        /**
index 06f3b5b5891d38c766a2e75b93bd5a5d56f8711b..237b80029d147173f5340016233d73720eaa65a8 100644 (file)
@@ -69,7 +69,7 @@ import  java.io.*;
  * is used for debugging purposes and <em>LocalVariableTable</em> which 
  * contains information about the local variables.
  *
- * @version $Id: Code.java,v 1.6 2008/08/26 14:59:45 aclement Exp $
+ * @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
@@ -306,13 +306,13 @@ public final class Code extends Attribute {
     buf = new StringBuffer("Code(max_stack = " + maxStack +
                           ", max_locals = " + maxLocals +
                           ", code_length = " + code.length + ")\n" +
-                          Utility.codeToString(code, constantPool, 0, -1, verbose));
+                          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(constantPool, verbose) + "\n");
+       buf.append(exceptionTable[i].toString(cpool, verbose) + "\n");
     }
 
     if(attributes.length > 0) {
@@ -338,7 +338,7 @@ public final class Code extends Attribute {
   public Attribute copy(ConstantPool constant_pool) {
     Code c = (Code)clone();
     c.code          = (byte[])code.clone();
-    c.constantPool = constant_pool;
+    c.cpool = constant_pool;
   
     c.exceptionTable = new CodeException[exceptionTable.length];
     for(int i=0; i < exceptionTable.length; i++)
@@ -361,14 +361,14 @@ public final class Code extends Attribute {
          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, constantPool, 0, -1,true));
+         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.constantPool.getConstantString(type,Constants.CONSTANT_Class);
+                       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");
                  }
index 53a5c4c7f90613efacb2733149c9535f5c65c3f9..eedcc98f24f586c039709a5a15526edf82a8ebdd 100644 (file)
@@ -57,7 +57,6 @@ package org.aspectj.apache.bcel.classfile;
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
-import java.io.Serializable;
 
 import org.aspectj.apache.bcel.Constants;
 
@@ -65,10 +64,10 @@ import org.aspectj.apache.bcel.Constants;
  * Abstract superclass for classes to represent the different constant types in the constant pool of a class file. The classes keep
  * closely to the JVM specification.
  * 
- * @version $Id: Constant.java,v 1.4 2009/09/10 03:59:33 aclement Exp $
+ * @version $Id: Constant.java,v 1.5 2009/09/10 15:35:04 aclement Exp $
  * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
  */
-public abstract class Constant implements Cloneable, Node, Serializable {
+public abstract class Constant implements Cloneable, Node {
 
        protected byte tag;
 
@@ -76,16 +75,6 @@ public abstract class Constant implements Cloneable, Node, Serializable {
                this.tag = tag;
        }
 
-       /**
-        * Visitor pattern
-        */
-       public abstract void accept(ClassVisitor v);
-
-       /**
-        * Serialize the constant to an output stream
-        */
-       public abstract void dump(DataOutputStream dataOutputStream) throws IOException;
-
        public final byte getTag() {
                return tag;
        }
@@ -95,9 +84,12 @@ public abstract class Constant implements Cloneable, Node, Serializable {
                return Constants.CONSTANT_NAMES[tag] + "[" + tag + "]";
        }
 
-       /**
-        * @return deep copy of this constant
-        */
+       public abstract void accept(ClassVisitor v);
+
+       public abstract void dump(DataOutputStream dataOutputStream) throws IOException;
+
+       public abstract Object getValue();
+
        public Constant copy() {
                try {
                        return (Constant) super.clone();
@@ -112,33 +104,34 @@ public abstract class Constant implements Cloneable, Node, Serializable {
                return super.clone();
        }
 
-       static final Constant readConstant(DataInputStream file) throws IOException, ClassFormatException {
-               byte b = file.readByte();
+       static final Constant readConstant(DataInputStream dis) throws IOException, ClassFormatException {
+               byte b = dis.readByte();
                switch (b) {
                case Constants.CONSTANT_Class:
-                       return new ConstantClass(file);
+                       return new ConstantClass(dis);
                case Constants.CONSTANT_NameAndType:
-                       return new ConstantNameAndType(file);
+                       return new ConstantNameAndType(dis);
                case Constants.CONSTANT_Utf8:
-                       return new ConstantUtf8(file);
+                       return new ConstantUtf8(dis);
                case Constants.CONSTANT_Fieldref:
-                       return new ConstantFieldref(file);
+                       return new ConstantFieldref(dis);
                case Constants.CONSTANT_Methodref:
-                       return new ConstantMethodref(file);
+                       return new ConstantMethodref(dis);
                case Constants.CONSTANT_InterfaceMethodref:
-                       return new ConstantInterfaceMethodref(file);
+                       return new ConstantInterfaceMethodref(dis);
                case Constants.CONSTANT_String:
-                       return new ConstantString(file);
+                       return new ConstantString(dis);
                case Constants.CONSTANT_Integer:
-                       return new ConstantInteger(file);
+                       return new ConstantInteger(dis);
                case Constants.CONSTANT_Float:
-                       return new ConstantFloat(file);
+                       return new ConstantFloat(dis);
                case Constants.CONSTANT_Long:
-                       return new ConstantLong(file);
+                       return new ConstantLong(dis);
                case Constants.CONSTANT_Double:
-                       return new ConstantDouble(file);
+                       return new ConstantDouble(dis);
                default:
                        throw new ClassFormatException("Invalid byte tag in constant pool: " + b);
                }
        }
+
 }
index 4cc882e3d5261da3d753ad801d280d814bb90b84..a2811914e329a8604d63fbb7cbc9468eaafb5ee1 100644 (file)
@@ -53,102 +53,61 @@ package org.aspectj.apache.bcel.classfile;
  * information on the Apache Software Foundation, please see
  * <http://www.apache.org/>.
  */
-import java.io.*;
-import  org.aspectj.apache.bcel.Constants;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
 
-/** 
+import org.aspectj.apache.bcel.Constants;
+
+/**
  * Abstract super class for Fieldref and Methodref constants.
- *
- * @version $Id: ConstantCP.java,v 1.3 2008/05/28 23:53:02 aclement Exp $
- * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
- * @see     ConstantFieldref
- * @see     ConstantMethodref
- * @see     ConstantInterfaceMethodref
+ * 
+ * @version $Id: ConstantCP.java,v 1.4 2009/09/10 15:35:05 aclement Exp $
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see ConstantFieldref
+ * @see ConstantMethodref
+ * @see ConstantInterfaceMethodref
  */
 public abstract class ConstantCP extends Constant {
-  /** References to the constants containing the class and the field signature
-   */
-  protected int class_index, name_and_type_index; 
 
-  /**
-   * Initialize from another object.
-   */
-  public ConstantCP(ConstantCP c) {
-    this(c.getTag(), c.getClassIndex(), c.getNameAndTypeIndex());
-  }  
-  
-  /**
-   * Initialize instance from file data.
-   *
-   * @param tag  Constant type tag
-   * @param file Input stream
-   * @throws IOException
-   */
-  ConstantCP(byte tag, DataInputStream file) throws IOException
-  {
-    this(tag, file.readUnsignedShort(), file.readUnsignedShort());
-  }
+       protected int classIndex, nameAndTypeIndex;
+
+       public ConstantCP(ConstantCP c) {
+               this(c.getTag(), c.getClassIndex(), c.getNameAndTypeIndex());
+       }
 
-  /**
-   * @param class_index Reference to the class containing the field
-   * @param name_and_type_index and the field signature
-   */
-  protected ConstantCP(byte tag, int class_index, 
-                      int name_and_type_index) {
-    super(tag);
-    this.class_index         = class_index;
-    this.name_and_type_index = name_and_type_index;
-  }
+       ConstantCP(byte tag, DataInputStream file) throws IOException {
+               this(tag, file.readUnsignedShort(), file.readUnsignedShort());
+       }
 
-  /** 
-   * Dump constant field reference to file stream in binary format.
-   *
-   * @param file Output file stream
-   * @throws IOException
-   */ 
-  public final void dump(DataOutputStream file) throws IOException
-  {
-    file.writeByte(tag);
-    file.writeShort(class_index);
-    file.writeShort(name_and_type_index);
-  }    
+       protected ConstantCP(byte tag, int classIndex, int nameAndTypeIndex) {
+               super(tag);
+               this.classIndex = classIndex;
+               this.nameAndTypeIndex = nameAndTypeIndex;
+       }
 
-  /**
-   * @return Reference (index) to class this field or method belongs to.
-   */  
-  public final int getClassIndex()       { return class_index; }    
+       @Override
+       public final void dump(DataOutputStream file) throws IOException {
+               file.writeByte(tag);
+               file.writeShort(classIndex);
+               file.writeShort(nameAndTypeIndex);
+       }
 
-  /**
-   * @return Reference (index) to signature of the field.
-   */  
-  public final int getNameAndTypeIndex() { return name_and_type_index; }    
+       public final int getClassIndex() {
+               return classIndex;
+       }
 
-  /**
-   * @param class_index points to Constant_class 
-   */
-  public final void setClassIndex(int class_index) {
-    this.class_index = class_index;
-  }    
+       public final int getNameAndTypeIndex() {
+               return nameAndTypeIndex;
+       }
 
-  /**
-   * @return Class this field belongs to.
-   */  
-  public String getClass(ConstantPool cp) {
-    return cp.constantToString(class_index, Constants.CONSTANT_Class);
-  }
+       public String getClass(ConstantPool cp) {
+               return cp.constantToString(classIndex, Constants.CONSTANT_Class);
+       }
 
-  /**
-   * @param name_and_type_index points to Constant_NameAndType
-   */
-  public final void setNameAndTypeIndex(int name_and_type_index) {
-    this.name_and_type_index = name_and_type_index;
-  }
+       @Override
+       public final String toString() {
+               return super.toString() + "(classIndex = " + classIndex + ", nameAndTypeIndex = " + nameAndTypeIndex + ")";
+       }
 
-  /**
-   * @return String representation.
-   */
-  public final String toString() {
-    return super.toString() + "(class_index = " + class_index +
-      ", name_and_type_index = " + name_and_type_index + ")";
-  }    
 }
index da6326245e1210d588df5262ee391e9e3351aea4..ee6b0e403adc6d7426c9d35fd853eab66d8e515d 100644 (file)
@@ -64,11 +64,11 @@ import org.aspectj.apache.bcel.Constants;
  * This class is derived from the abstract <A HREF="org.aspectj.apache.bcel.classfile.Constant.html">Constant</A> class and
  * represents a reference to a (external) class.
  * 
- * @version $Id: ConstantClass.java,v 1.4 2009/09/10 03:59:33 aclement Exp $
+ * @version $Id: ConstantClass.java,v 1.5 2009/09/10 15:35:05 aclement Exp $
  * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
  * @author Andy Clement
  */
-public final class ConstantClass extends Constant implements ConstantObject {
+public final class ConstantClass extends Constant {
        private int nameIndex;
 
        public ConstantClass(ConstantClass c) {
@@ -100,14 +100,13 @@ public final class ConstantClass extends Constant implements ConstantObject {
                return nameIndex;
        }
 
-       public final void setNameIndex(int nameIndex) {
-               this.nameIndex = nameIndex;
+       @Override
+       public Integer getValue() {
+               return nameIndex;
        }
 
-       public String getConstantValue(ConstantPool cp) {
-               return cp.getConstantUtf8(nameIndex).getBytes();
-               // Constant c = cp.getConstant(nameIndex, Constants.CONSTANT_Utf8);
-               // return ((ConstantUtf8) c).getBytes();
+       public String getClassname(ConstantPool cpool) {
+               return cpool.getConstantUtf8(nameIndex).getValue();
        }
 
        @Override
index 34e5b3cfca0cd566a590d0021fc70cb991886d31..9f4f1628af6025ae08469cf78651dc162ee5e883 100644 (file)
@@ -64,11 +64,11 @@ import org.aspectj.apache.bcel.Constants;
  * This class is derived from the abstract <A HREF="org.aspectj.apache.bcel.classfile.Constant.html">Constant</A> class and
  * represents a reference to a Double object.
  * 
- * @version $Id: ConstantDouble.java,v 1.4 2009/09/10 03:59:33 aclement Exp $
+ * @version $Id: ConstantDouble.java,v 1.5 2009/09/10 15:35:04 aclement Exp $
  * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
  * @author Andy Clement
  */
-public final class ConstantDouble extends Constant implements ConstantObject {
+public final class ConstantDouble extends Constant implements SimpleConstant {
        private double value;
 
        public ConstantDouble(double value) {
@@ -77,7 +77,7 @@ public final class ConstantDouble extends Constant implements ConstantObject {
        }
 
        public ConstantDouble(ConstantDouble c) {
-               this(c.getBytes());
+               this(c.getValue());
        }
 
        ConstantDouble(DataInputStream file) throws IOException {
@@ -95,16 +95,17 @@ public final class ConstantDouble extends Constant implements ConstantObject {
                file.writeDouble(value);
        }
 
-       public final double getBytes() {
-               return value;
-       }
-
        @Override
        public final String toString() {
                return super.toString() + "(bytes = " + value + ")";
        }
 
-       public Double getConstantValue(ConstantPool cp) {
-               return new Double(value);
+       @Override
+       public Double getValue() {
+               return value;
+       }
+
+       public String getStringValue() {
+               return Double.toString(value);
        }
 }
index ee248ea302aae15ae012b881ed5d29af5830eeb8..babe174bc2f0575ef7b7451f2dd9b394114ea484 100644 (file)
@@ -54,51 +54,38 @@ package org.aspectj.apache.bcel.classfile;
  * <http://www.apache.org/>.
  */
 
+import java.io.DataInputStream;
+import java.io.IOException;
+
 import org.aspectj.apache.bcel.Constants;
-import java.io.*;
 
-/** 
+/**
  * This class represents a constant pool reference to a field.
- *
- * @version $Id: ConstantFieldref.java,v 1.3 2008/05/28 23:53:02 aclement Exp $
- * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * 
+ * @version $Id: ConstantFieldref.java,v 1.4 2009/09/10 15:35:04 aclement Exp $
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
  */
 public final class ConstantFieldref extends ConstantCP {
-  /**
-   * Initialize from another object.
-   */
-  public ConstantFieldref(ConstantFieldref c) {
-    super(Constants.CONSTANT_Fieldref, c.getClassIndex(), c.getNameAndTypeIndex());
-  }
 
-  /**
-   * Initialize instance from file data.
-   *
-   * @param file input stream
-   * @throws IOException
-   */
-  ConstantFieldref(DataInputStream file) throws IOException
-  {
-    super(Constants.CONSTANT_Fieldref, file);
-  }
+       public ConstantFieldref(ConstantFieldref c) {
+               super(Constants.CONSTANT_Fieldref, c.getClassIndex(), c.getNameAndTypeIndex());
+       }
+
+       ConstantFieldref(DataInputStream file) throws IOException {
+               super(Constants.CONSTANT_Fieldref, file);
+       }
+
+       public ConstantFieldref(int class_index, int name_and_type_index) {
+               super(Constants.CONSTANT_Fieldref, class_index, name_and_type_index);
+       }
 
-  /**
-   * @param class_index Reference to the class containing the Field
-   * @param name_and_type_index and the Field signature
-   */
-  public ConstantFieldref(int class_index, 
-                          int name_and_type_index) {
-    super(Constants.CONSTANT_Fieldref, class_index, name_and_type_index);
-  }    
+       @Override
+       public void accept(ClassVisitor v) {
+               v.visitConstantFieldref(this);
+       }
 
-  /**
-   * 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 Fields,
-   * fields, attributes, etc. spawns a tree of objects.
-   *
-   * @param v Visitor object
-   */
-  public void accept(ClassVisitor v) {
-    v.visitConstantFieldref(this);
-  }    
+       @Override
+       public String getValue() {
+               return toString();
+       }
 }
index 22f8ab91053bd9ab5c37c845309fe6a81a007841..7e016db81bdfcd273509384e818a3b851f3e6fe7 100644 (file)
@@ -54,88 +54,67 @@ package org.aspectj.apache.bcel.classfile;
  * <http://www.apache.org/>.
  */
 
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
 import org.aspectj.apache.bcel.Constants;
-import java.io.*;
 
-/** 
- * This class is derived from the abstract 
- * <A HREF="org.aspectj.apache.bcel.classfile.Constant.html">Constant</A> class 
- * and represents a reference to a float object.
- *
- * @version $Id: ConstantFloat.java,v 1.3 2008/05/28 23:53:02 aclement Exp $
- * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
- * @see     Constant
+/**
+ * This class is derived from the abstract <A HREF="org.aspectj.apache.bcel.classfile.Constant.html">Constant</A> class and
+ * represents a reference to a float object.
+ * 
+ * @version $Id: ConstantFloat.java,v 1.4 2009/09/10 15:35:05 aclement Exp $
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Constant
  */
-public final class ConstantFloat extends Constant implements ConstantObject {
-  private float bytes;
+public final class ConstantFloat extends Constant implements SimpleConstant {
+       private float floatValue;
+
+       public ConstantFloat(float floatValue) {
+               super(Constants.CONSTANT_Float);
+               this.floatValue = floatValue;
+       }
+
+       public ConstantFloat(ConstantFloat c) {
+               this(c.getValue());
+       }
+
+       ConstantFloat(DataInputStream file) throws IOException {
+               this(file.readFloat());
+       }
+
+       @Override
+       public void accept(ClassVisitor v) {
+               v.visitConstantFloat(this);
+       }
+
+       @Override
+       public final void dump(DataOutputStream file) throws IOException {
+               file.writeByte(tag);
+               file.writeFloat(floatValue);
+       }
+
+       @Override
+       public final Float getValue() {
+               return floatValue;
+       }
+
+       public final String getStringValue() {
+               return Float.toString(floatValue);
+       }
+
+       public final float getFloatValue() {
+               return floatValue;
+       }
 
-  /** 
-   * @param bytes Data
-   */
-  public ConstantFloat(float bytes)
-  {    
-    super(Constants.CONSTANT_Float);
-    this.bytes = bytes;
-  }    
-  /**
-   * Initialize from another object. Note that both objects use the same
-   * references (shallow copy). Use clone() for a physical copy.
-   */
-  public ConstantFloat(ConstantFloat c) {
-    this(c.getBytes());
-  }    
-  /** 
-   * Initialize instance from file data.
-   *
-   * @param file Input stream
-   * @throws IOException
-   */
-  ConstantFloat(DataInputStream file) throws IOException
-  {    
-    this(file.readFloat());
-  }    
-  /**
-   * 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.visitConstantFloat(this);
-  }    
-  /**
-   * Dump constant float to file stream in binary format.
-   *
-   * @param file Output file stream
-   * @throws IOException
-   */ 
-  public final void dump(DataOutputStream file) throws IOException
-  {
-    file.writeByte(tag);
-    file.writeFloat(bytes);
-  }    
-  /**
-   * @return data, i.e., 4 bytes.
-   */  
-  public final float getBytes() { return bytes; }    
-  /**
-   * @param bytes.
-   */
-  public final void setBytes(float bytes) {
-    this.bytes = bytes;
-  }
+       public final void setBytes(float bytes) {
+               this.floatValue = bytes;
+       }
 
-  /**
-   * @return String representation.
-   */
-  public final String toString() {
-    return super.toString() + "(bytes = " + bytes + ")";
-  }    
+       @Override
+       public final String toString() {
+               return super.toString() + "(bytes = " + floatValue + ")";
+       }
 
-  /** @return Float object
-   */
-  public Object getConstantValue(ConstantPool cp) {
-    return new Float(bytes);
-  }
 }
index 3a35d4334cd645e9ea26972c5743224d19e5fe87..503a230244b6a42cc6f9f198cf571ccfe3a14e2f 100644 (file)
@@ -1,4 +1,3 @@
-
 package org.aspectj.apache.bcel.classfile;
 
 /* ====================================================================
@@ -55,94 +54,66 @@ package org.aspectj.apache.bcel.classfile;
  * <http://www.apache.org/>.
  */
 
+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;
 
-/** 
- * This class is derived from the abstract 
- * <A HREF="org.aspectj.apache.bcel.classfile.Constant.html">Constant</A> class 
- * and represents a reference to an int object.
- *
- * @version $Id: ConstantInteger.java,v 1.3 2008/05/28 23:53:02 aclement Exp $
- * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
- * @see     Constant
+/**
+ * This class is derived from the abstract <A HREF="org.aspectj.apache.bcel.classfile.Constant.html">Constant</A> class and
+ * represents a reference to an int object.
+ * 
+ * @version $Id: ConstantInteger.java,v 1.4 2009/09/10 15:35:05 aclement Exp $
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Constant
  */
-public final class ConstantInteger extends Constant implements ConstantObject {
-  private int bytes;
+public final class ConstantInteger extends Constant implements SimpleConstant {
+       private int intValue;
+
+       public ConstantInteger(int intValue) {
+               super(Constants.CONSTANT_Integer);
+               this.intValue = intValue;
+       }
 
-  /** 
-   * @param bytes Data
-   */
-  public ConstantInteger(int bytes)
-  {    
-    super(Constants.CONSTANT_Integer);
-    this.bytes = bytes;
-  }
+       public ConstantInteger(ConstantInteger c) {
+               this(c.getValue());
+       }
 
-  /**
-   * Initialize from another object.
-   */
-  public ConstantInteger(ConstantInteger c) {
-    this(c.getBytes());
-  }
+       ConstantInteger(DataInputStream file) throws IOException {
+               this(file.readInt());
+       }
 
-  /** 
-   * Initialize instance from file data.
-   *
-   * @param file Input stream
-   * @throws IOException
-   */
-  ConstantInteger(DataInputStream file) throws IOException
-  {    
-    this(file.readInt());
-  }
+       @Override
+       public void accept(ClassVisitor v) {
+               v.visitConstantInteger(this);
+       }
 
-  /**
-   * 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.visitConstantInteger(this);
-  }
+       @Override
+       public final void dump(DataOutputStream file) throws IOException {
+               file.writeByte(tag);
+               file.writeInt(intValue);
+       }
 
-  /**
-   * Dump constant integer to file stream in binary format.
-   *
-   * @param file Output file stream
-   * @throws IOException
-   */ 
-  public final void dump(DataOutputStream file) throws IOException
-  {
-    file.writeByte(tag);
-    file.writeInt(bytes);
-  }
+       public final void setBytes(int bytes) {
+               this.intValue = bytes;
+       }
 
-  /**
-   * @return data, i.e., 4 bytes.
-   */  
-  public final int getBytes() { return bytes; }
+       @Override
+       public final String toString() {
+               return super.toString() + "(bytes = " + intValue + ")";
+       }
 
-  /**
-   * @param bytes.
-   */
-  public final void setBytes(int bytes) {
-    this.bytes = bytes;
-  }
+       @Override
+       public Integer getValue() {
+               return intValue;
+       }
 
-  /**
-   * @return String representation.
-   */
-  public final String toString() {
-    return super.toString() + "(bytes = " + bytes + ")";
-  }    
+       public int getIntValue() {
+               return intValue;
+       }
 
-  /** @return Integer object
-   */
-  public Object getConstantValue(ConstantPool cp) {
-    return new Integer(bytes);
-  }
+       public String getStringValue() {
+               return Integer.toString(intValue);
+       }
 }
index 1598ce24f58a725d480420bcf4f21cf9041914f2..f5101095004d91813b6ab6d1cbef0fb4a6ea4cea 100644 (file)
@@ -54,51 +54,39 @@ package org.aspectj.apache.bcel.classfile;
  * <http://www.apache.org/>.
  */
 
+import java.io.DataInputStream;
+import java.io.IOException;
+
 import org.aspectj.apache.bcel.Constants;
-import java.io.*;
 
-/** 
+/**
  * This class represents a constant pool reference to an interface method.
- *
- * @version $Id: ConstantInterfaceMethodref.java,v 1.3 2008/05/28 23:53:02 aclement Exp $
- * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * 
+ * @version $Id: ConstantInterfaceMethodref.java,v 1.4 2009/09/10 15:35:04 aclement Exp $
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
  */
 public final class ConstantInterfaceMethodref extends ConstantCP {
-  /**
-   * Initialize from another object.
-   */
-  public ConstantInterfaceMethodref(ConstantInterfaceMethodref c) {
-    super(Constants.CONSTANT_InterfaceMethodref, c.getClassIndex(), c.getNameAndTypeIndex());
-  }
 
-  /**
-   * Initialize instance from file data.
-   *
-   * @param file input stream
-   * @throws IOException
-   */
-  ConstantInterfaceMethodref(DataInputStream file) throws IOException
-  {
-    super(Constants.CONSTANT_InterfaceMethodref, file);
-  }
+       public ConstantInterfaceMethodref(ConstantInterfaceMethodref c) {
+               super(Constants.CONSTANT_InterfaceMethodref, c.getClassIndex(), c.getNameAndTypeIndex());
+       }
+
+       ConstantInterfaceMethodref(DataInputStream file) throws IOException {
+               super(Constants.CONSTANT_InterfaceMethodref, file);
+       }
+
+       public ConstantInterfaceMethodref(int classIndex, int nameAndTypeIndex) {
+               super(Constants.CONSTANT_InterfaceMethodref, classIndex, nameAndTypeIndex);
+       }
+
+       @Override
+       public void accept(ClassVisitor v) {
+               v.visitConstantInterfaceMethodref(this);
+       }
 
-  /**
-   * @param class_index Reference to the class containing the method
-   * @param name_and_type_index and the method signature
-   */
-  public ConstantInterfaceMethodref(int class_index, 
-                                   int name_and_type_index) {
-    super(Constants.CONSTANT_InterfaceMethodref, class_index, name_and_type_index);
-  }    
+       @Override
+       public String getValue() {
+               return toString();
+       }
 
-  /**
-   * 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.visitConstantInterfaceMethodref(this);
-  }    
 }
index a850d248ce616d4fab9f1b14601a58e12fe7b32a..b8fea1bcddd5842792a3e1cd58e44f2d394dff9a 100644 (file)
@@ -54,86 +54,59 @@ 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;
 
-/** 
- * This class is derived from the abstract 
- * <A HREF="org.aspectj.apache.bcel.classfile.Constant.html">Constant</A> class 
- * and represents a reference to a long object.
- *
- * @version $Id: ConstantLong.java,v 1.3 2008/05/28 23:53:02 aclement Exp $
- * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
- * @see     Constant
+import org.aspectj.apache.bcel.Constants;
+
+/**
+ * This class is derived from the abstract <A HREF="org.aspectj.apache.bcel.classfile.Constant.html">Constant</A> class and
+ * represents a reference to a long object.
+ * 
+ * @version $Id: ConstantLong.java,v 1.4 2009/09/10 15:35:05 aclement Exp $
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Constant
  */
-public final class ConstantLong extends Constant implements ConstantObject {
-  private long bytes;
+public final class ConstantLong extends Constant implements SimpleConstant {
+       private long longValue;
+
+       public ConstantLong(long longValue) {
+               super(Constants.CONSTANT_Long);
+               this.longValue = longValue;
+       }
+
+       public ConstantLong(ConstantLong c) {
+               this(c.getValue());
+       }
+
+       ConstantLong(DataInputStream file) throws IOException {
+               this(file.readLong());
+       }
+
+       @Override
+       public void accept(ClassVisitor v) {
+               v.visitConstantLong(this);
+       }
+
+       @Override
+       public final void dump(DataOutputStream file) throws IOException {
+               file.writeByte(tag);
+               file.writeLong(longValue);
+       }
+
+       @Override
+       public final Long getValue() {
+               return longValue;
+       }
+
+       public final String getStringValue() {
+               return Long.toString(longValue);
+       }
 
-  /** 
-   * @param bytes Data
-   */
-  public ConstantLong(long bytes)
-  {
-    super(Constants.CONSTANT_Long);
-    this.bytes = bytes;
-  }    
-  /**
-   * Initialize from another object.
-   */
-  public ConstantLong(ConstantLong c) {
-    this(c.getBytes());
-  }    
-  /** 
-   * Initialize instance from file data.
-   *
-   * @param file Input stream
-   * @throws IOException
-   */
-  ConstantLong(DataInputStream file) throws IOException
-  {    
-    this(file.readLong());
-  }    
-  /**
-   * 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.visitConstantLong(this);
-  }    
-  /**
-   * Dump constant long to file stream in binary format.
-   *
-   * @param file Output file stream
-   * @throws IOException
-   */ 
-  public final void dump(DataOutputStream file) throws IOException
-  {
-    file.writeByte(tag);
-    file.writeLong(bytes);
-  }    
-  /**
-   * @return data, i.e., 8 bytes.
-   */  
-  public final long getBytes() { return bytes; }    
-  /**
-   * @param bytes.
-   */
-  public final void setBytes(long bytes) {
-    this.bytes = bytes;
-  }    
-  /**
-   * @return String representation.
-   */
-  public final String toString() {
-    return super.toString() + "(bytes = " + bytes + ")";
-  }    
+       @Override
+       public final String toString() {
+               return super.toString() + "(longValue = " + longValue + ")";
+       }
 
-  /** @return Long object
-   */
-  public Object getConstantValue(ConstantPool cp) {
-    return new Long(bytes);
-  }
 }
index bd22ee0484fc9b43a229a44613312638c5511883..8697541cca080f47f99f941c054fd1e4c2aca9bd 100644 (file)
@@ -54,51 +54,56 @@ package org.aspectj.apache.bcel.classfile;
  * <http://www.apache.org/>.
  */
 
+import java.io.DataInputStream;
+import java.io.IOException;
+
 import org.aspectj.apache.bcel.Constants;
-import java.io.*;
 
-/** 
+/**
  * This class represents a constant pool reference to a method.
- *
- * @version $Id: ConstantMethodref.java,v 1.3 2008/05/28 23:53:02 aclement Exp $
- * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * 
+ * @version $Id: ConstantMethodref.java,v 1.4 2009/09/10 15:35:05 aclement Exp $
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
  */
 public final class ConstantMethodref extends ConstantCP {
-  /**
-   * Initialize from another object.
-   */
-  public ConstantMethodref(ConstantMethodref c) {
-    super(Constants.CONSTANT_Methodref, c.getClassIndex(), c.getNameAndTypeIndex());
-  }
+       /**
+        * Initialize from another object.
+        */
+       public ConstantMethodref(ConstantMethodref c) {
+               super(Constants.CONSTANT_Methodref, c.getClassIndex(), c.getNameAndTypeIndex());
+       }
+
+       /**
+        * Initialize instance from file data.
+        * 
+        * @param file input stream
+        * @throws IOException
+        */
+       ConstantMethodref(DataInputStream file) throws IOException {
+               super(Constants.CONSTANT_Methodref, file);
+       }
 
-  /**
-   * Initialize instance from file data.
-   *
-   * @param file input stream
-   * @throws IOException
-   */
-  ConstantMethodref(DataInputStream file) throws IOException
-  {
-    super(Constants.CONSTANT_Methodref, file);
-  }
+       /**
+        * @param class_index Reference to the class containing the method
+        * @param name_and_type_index and the method signature
+        */
+       public ConstantMethodref(int class_index, int name_and_type_index) {
+               super(Constants.CONSTANT_Methodref, class_index, name_and_type_index);
+       }
 
-  /**
-   * @param class_index Reference to the class containing the method
-   * @param name_and_type_index and the method signature
-   */
-  public ConstantMethodref(int class_index, 
-                          int name_and_type_index) {
-    super(Constants.CONSTANT_Methodref, class_index, name_and_type_index);
-  }    
+       /**
+        * 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.visitConstantMethodref(this);
+       }
 
-  /**
-   * 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.visitConstantMethodref(this);
-  }    
+       @Override
+       public String getValue() {
+               return toString();
+       }
 }
index 21a60153474fea2a020ec32ad9bb73cab915fe6f..1a2219ed49822a76eeb4e51388889c36376e0911 100644 (file)
@@ -54,118 +54,128 @@ package org.aspectj.apache.bcel.classfile;
  * <http://www.apache.org/>.
  */
 
-import  org.aspectj.apache.bcel.Constants;
-import  java.io.*;
-
-/** 
- * This class is derived from the abstract 
- * <A HREF="org.aspectj.apache.bcel.classfile.Constant.html">Constant</A> class 
- * and represents a reference to the name and signature
- * of a field or method.
- *
- * @version $Id: ConstantNameAndType.java,v 1.3 2008/05/28 23:53:02 aclement Exp $
- * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
- * @see     Constant
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import org.aspectj.apache.bcel.Constants;
+
+/**
+ * This class is derived from the abstract <A HREF="org.aspectj.apache.bcel.classfile.Constant.html">Constant</A> class and
+ * represents a reference to the name and signature of a field or method.
+ * 
+ * @version $Id: ConstantNameAndType.java,v 1.4 2009/09/10 15:35:05 aclement Exp $
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Constant
  */
 public final class ConstantNameAndType extends Constant {
-  private int name_index;      // Name of field/method
-  private int signature_index; // and its signature.
-
-  /**
-   * Initialize from another object.
-   */
-  public ConstantNameAndType(ConstantNameAndType c) {
-    this(c.getNameIndex(), c.getSignatureIndex());
-  }
-  /**
-   * Initialize instance from file data.
-   *
-   * @param file Input stream
-   * @throws IOException
-   */
-  ConstantNameAndType(DataInputStream file) throws IOException
-  {    
-    this(file.readUnsignedShort(), file.readUnsignedShort());
-  }
-
-  /**
-   * @param name_index Name of field/method
-   * @param signature_index and its signature
-   */
-  public ConstantNameAndType(int name_index,
-                            int signature_index)
-  {
-    super(Constants.CONSTANT_NameAndType);
-    this.name_index      = name_index;
-    this.signature_index = signature_index;
-  }
-
-  /**
-   * 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.visitConstantNameAndType(this);
-  }
-
-  /**
-   * Dump name and signature index to file stream in binary format.
-   *
-   * @param file Output file stream
-   * @throws IOException
-   */ 
-  public final void dump(DataOutputStream file) throws IOException
-  {
-    file.writeByte(tag);
-    file.writeShort(name_index);
-    file.writeShort(signature_index);
-  }
-
-  /**
-   * @return Name index in constant pool of field/method name.
-   */  
-  public final int getNameIndex()      { return name_index; }
-
-  /** @return name
-   */
-  public final String getName(ConstantPool cp) {
-    return cp.constantToString(getNameIndex(), Constants.CONSTANT_Utf8);
-  }
-
-  /**
-   * @return Index in constant pool of field/method signature.
-   */  
-  public final int getSignatureIndex() { return signature_index; }
-
-  /** @return signature
-   */
-  public final String getSignature(ConstantPool cp) {
-    return cp.constantToString(getSignatureIndex(), Constants.CONSTANT_Utf8);
-  }
-
-  /**
-   * @param name_index.
-   */
-  public final void setNameIndex(int name_index) {
-    this.name_index = name_index;
-  }
-
-  /**
-   * @param signature_index.
-   */
-  public final void setSignatureIndex(int signature_index) {
-    this.signature_index = signature_index;
-  }
-
-  /**
-   * @return String representation
-   */
-  public final String toString() {
-    return super.toString() + "(name_index = " + name_index + 
-      ", signature_index = " + signature_index + ")";
-  }    
+       private int name_index; // Name of field/method
+       private int signature_index; // and its signature.
+
+       /**
+        * Initialize from another object.
+        */
+       public ConstantNameAndType(ConstantNameAndType c) {
+               this(c.getNameIndex(), c.getSignatureIndex());
+       }
+
+       /**
+        * Initialize instance from file data.
+        * 
+        * @param file Input stream
+        * @throws IOException
+        */
+       ConstantNameAndType(DataInputStream file) throws IOException {
+               this(file.readUnsignedShort(), file.readUnsignedShort());
+       }
+
+       /**
+        * @param name_index Name of field/method
+        * @param signature_index and its signature
+        */
+       public ConstantNameAndType(int name_index, int signature_index) {
+               super(Constants.CONSTANT_NameAndType);
+               this.name_index = name_index;
+               this.signature_index = signature_index;
+       }
+
+       /**
+        * 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.visitConstantNameAndType(this);
+       }
+
+       /**
+        * Dump name and signature index to file stream in binary format.
+        * 
+        * @param file Output file stream
+        * @throws IOException
+        */
+       @Override
+       public final void dump(DataOutputStream file) throws IOException {
+               file.writeByte(tag);
+               file.writeShort(name_index);
+               file.writeShort(signature_index);
+       }
+
+       /**
+        * @return Name index in constant pool of field/method name.
+        */
+       public final int getNameIndex() {
+               return name_index;
+       }
+
+       /**
+        * @return name
+        */
+       public final String getName(ConstantPool cp) {
+               return cp.constantToString(getNameIndex(), Constants.CONSTANT_Utf8);
+       }
+
+       /**
+        * @return Index in constant pool of field/method signature.
+        */
+       public final int getSignatureIndex() {
+               return signature_index;
+       }
+
+       /**
+        * @return signature
+        */
+       public final String getSignature(ConstantPool cp) {
+               return cp.constantToString(getSignatureIndex(), Constants.CONSTANT_Utf8);
+       }
+
+       /**
+        * @param name_index.
+        */
+       public final void setNameIndex(int name_index) {
+               this.name_index = name_index;
+       }
+
+       /**
+        * @param signature_index.
+        */
+       public final void setSignatureIndex(int signature_index) {
+               this.signature_index = signature_index;
+       }
+
+       /**
+        * @return String representation
+        */
+       @Override
+       public final String toString() {
+               return super.toString() + "(name_index = " + name_index + ", signature_index = " + signature_index + ")";
+       }
+
+       @Override
+       public String getValue() {
+               return toString();
+       }
+
 }
index 20cd3d13de0a29366bc38eab3cbe73d14311f9a2..dece36ee42382967db5629a4d8020f8c2f108c9d 100644 (file)
@@ -60,9 +60,11 @@ public class ConstantPool implements Node {
        }
 
        public Constant getConstant(int index) {
-               if (index >= pool.length || index < 0)
-                       throw new ClassFormatException("Invalid constant pool reference: " + index + ". Constant pool size is: " + pool.length);
-               return pool[index];
+               try {
+                       return pool[index];
+               } catch (ArrayIndexOutOfBoundsException aioobe) {
+                       throw new ClassFormatException("Index " + index + " into constant pool (size:" + poolSize + ") is invalid");
+               }
        }
 
        /**
@@ -110,7 +112,7 @@ public class ConstantPool implements Node {
                }
                // Finally get the string from the constant pool
                c = getConstant(i, Constants.CONSTANT_Utf8);
-               return ((ConstantUtf8) c).getBytes();
+               return ((ConstantUtf8) c).getValue();
        }
 
        /**
@@ -124,29 +126,21 @@ public class ConstantPool implements Node {
                case Constants.CONSTANT_Class:
                        i = ((ConstantClass) c).getNameIndex();
                        c = getConstant(i, Constants.CONSTANT_Utf8);
-                       str = Utility.compactClassName(((ConstantUtf8) c).getBytes(), false);
+                       str = Utility.compactClassName(((ConstantUtf8) c).getValue(), false);
                        break;
 
                case Constants.CONSTANT_String:
                        i = ((ConstantString) c).getStringIndex();
                        c = getConstant(i, Constants.CONSTANT_Utf8);
-                       str = "\"" + escape(((ConstantUtf8) c).getBytes()) + "\"";
+                       str = "\"" + escape(((ConstantUtf8) c).getValue()) + "\"";
                        break;
 
                case Constants.CONSTANT_Utf8:
-                       str = ((ConstantUtf8) c).getBytes();
-                       break;
                case Constants.CONSTANT_Double:
-                       str = Double.toString(((ConstantDouble) c).getBytes());
-                       break;
                case Constants.CONSTANT_Float:
-                       str = Float.toString(((ConstantFloat) c).getBytes());
-                       break;
                case Constants.CONSTANT_Long:
-                       str = Long.toString(((ConstantLong) c).getBytes());
-                       break;
                case Constants.CONSTANT_Integer:
-                       str = Integer.toString(((ConstantInteger) c).getBytes());
+                       str = ((SimpleConstant) c).getStringValue();
                        break;
 
                case Constants.CONSTANT_NameAndType:
@@ -218,25 +212,17 @@ public class ConstantPool implements Node {
                                pool[i].dump(file);
        }
 
-       public ConstantUtf8 getConstantUtf8(int idx) {
-               try {
-                       Constant c = pool[idx];
-                       if (c == null) {
-                               throw new ClassFormatException("Constant pool at index " + idx + " is null.");
-                       }
-                       if (c.tag != Constants.CONSTANT_Utf8) {
-                               throw new ClassFormatException("Expected UTF8Constant " + " at index " + idx + " and got " + c);
-                       }
-                       return (ConstantUtf8) c;
-               } catch (ArrayIndexOutOfBoundsException aioobe) {
-                       throw new ClassFormatException("Index " + idx + " into constant pool (size:" + poolSize + ") is invalid");
-               }
+       public ConstantUtf8 getConstantUtf8(int index) {
+               Constant c = getConstant(index);
+               assert c != null;
+               assert c.tag == Constants.CONSTANT_Utf8;
+               return (ConstantUtf8) c;
        }
 
        public String getConstantString_CONSTANTClass(int index) {
                ConstantClass c = (ConstantClass) getConstant(index, Constants.CONSTANT_Class);
                index = c.getNameIndex();
-               return ((ConstantUtf8) getConstant(index, Constants.CONSTANT_Utf8)).getBytes();
+               return ((ConstantUtf8) getConstant(index, Constants.CONSTANT_Utf8)).getValue();
        }
 
        public int getLength() {
@@ -257,7 +243,7 @@ public class ConstantPool implements Node {
                for (int i = 1; i < poolSize; i++) {
                        if (pool[i] instanceof ConstantInteger) {
                                ConstantInteger c = (ConstantInteger) pool[i];
-                               if (c.getBytes() == n)
+                               if (c.getValue() == n)
                                        return i;
                        }
                }
@@ -272,7 +258,7 @@ public class ConstantPool implements Node {
                for (int i = 1; i < poolSize; i++) {
                        Constant c = pool[i];
                        if (c != null && c.tag == Constants.CONSTANT_Utf8) {
-                               if (((ConstantUtf8) c).getBytes().equals(string)) {
+                               if (((ConstantUtf8) c).getValue().equals(string)) {
                                        utf8Cache.put(string, i);
                                        return i;
                                }
@@ -286,7 +272,7 @@ public class ConstantPool implements Node {
                        Constant c = pool[i];
                        if (c != null && c.tag == Constants.CONSTANT_Class) {
                                int cIndex = ((ConstantClass) c).getNameIndex();
-                               String cName = ((ConstantUtf8) pool[cIndex]).getBytes();
+                               String cName = ((ConstantUtf8) pool[cIndex]).getValue();
                                if (cName.equals(classname))
                                        return i;
                        }
@@ -376,15 +362,15 @@ public class ConstantPool implements Node {
                                // check the class
                                int cIndex = cfr.getClassIndex();
                                ConstantClass cc = (ConstantClass) pool[cIndex];
-                               String cName = ((ConstantUtf8) pool[cc.getNameIndex()]).getBytes();
+                               String cName = ((ConstantUtf8) pool[cc.getNameIndex()]).getValue();
                                if (!cName.equals(searchClassname))
                                        continue;
 
                                // check the name and type
-                               String name = ((ConstantUtf8) pool[cnat.getNameIndex()]).getBytes();
+                               String name = ((ConstantUtf8) pool[cnat.getNameIndex()]).getValue();
                                if (!name.equals(searchFieldname))
                                        continue; // not this one
-                               String typeSignature = ((ConstantUtf8) pool[cnat.getSignatureIndex()]).getBytes();
+                               String typeSignature = ((ConstantUtf8) pool[cnat.getSignatureIndex()]).getValue();
                                if (!typeSignature.equals(searchSignature))
                                        continue;
                                fieldCache.put(k, new Integer(i));
@@ -411,10 +397,10 @@ public class ConstantPool implements Node {
                        Constant c = pool[i];
                        if (c != null && c.tag == Constants.CONSTANT_NameAndType) {
                                ConstantNameAndType cnat = (ConstantNameAndType) c;
-                               String name = ((ConstantUtf8) pool[cnat.getNameIndex()]).getBytes();
+                               String name = ((ConstantUtf8) pool[cnat.getNameIndex()]).getValue();
                                if (!name.equals(searchName))
                                        continue; // not this one
-                               String typeSignature = ((ConstantUtf8) pool[cnat.getSignatureIndex()]).getBytes();
+                               String typeSignature = ((ConstantUtf8) pool[cnat.getSignatureIndex()]).getValue();
                                if (!typeSignature.equals(searchTypeSignature))
                                        continue;
                                return i;
@@ -439,7 +425,7 @@ public class ConstantPool implements Node {
                        Constant c = pool[i];
                        if (c != null && c.tag == Constants.CONSTANT_Float) {
                                ConstantFloat cf = (ConstantFloat) c;
-                               if (Float.floatToIntBits(cf.getBytes()) == bits)
+                               if (Float.floatToIntBits(cf.getValue()) == bits)
                                        return i;
                        }
                }
@@ -463,7 +449,7 @@ public class ConstantPool implements Node {
                        Constant c = pool[i];
                        if (c != null && c.tag == Constants.CONSTANT_Double) {
                                ConstantDouble cf = (ConstantDouble) c;
-                               if (Double.doubleToLongBits(cf.getBytes()) == bits)
+                               if (Double.doubleToLongBits(cf.getValue()) == bits)
                                        return i;
                        }
                }
@@ -487,7 +473,7 @@ public class ConstantPool implements Node {
                        if (c != null && c.tag == Constants.CONSTANT_String) {
                                ConstantString cs = (ConstantString) c;
                                ConstantUtf8 cu8 = (ConstantUtf8) pool[cs.getStringIndex()];
-                               if (cu8.getBytes().equals(s))
+                               if (cu8.getValue().equals(s))
                                        return i;
                        }
                }
@@ -511,7 +497,7 @@ public class ConstantPool implements Node {
                        Constant c = pool[i];
                        if (c != null && c.tag == Constants.CONSTANT_Long) {
                                ConstantLong cf = (ConstantLong) c;
-                               if (cf.getBytes() == l)
+                               if (cf.getValue() == l)
                                        return i;
                        }
                }
@@ -526,14 +512,14 @@ public class ConstantPool implements Node {
                        ConstantString s = (ConstantString) c;
                        ConstantUtf8 u8 = (ConstantUtf8) constants[s.getStringIndex()];
 
-                       return addString(u8.getBytes());
+                       return addString(u8.getValue());
                }
 
                case Constants.CONSTANT_Class: {
                        ConstantClass s = (ConstantClass) c;
                        ConstantUtf8 u8 = (ConstantUtf8) constants[s.getNameIndex()];
 
-                       return addClass(u8.getBytes());
+                       return addClass(u8.getValue());
                }
 
                case Constants.CONSTANT_NameAndType: {
@@ -541,23 +527,23 @@ public class ConstantPool implements Node {
                        ConstantUtf8 u8 = (ConstantUtf8) constants[n.getNameIndex()];
                        ConstantUtf8 u8_2 = (ConstantUtf8) constants[n.getSignatureIndex()];
 
-                       return addNameAndType(u8.getBytes(), u8_2.getBytes());
+                       return addNameAndType(u8.getValue(), u8_2.getValue());
                }
 
                case Constants.CONSTANT_Utf8:
-                       return addUtf8(((ConstantUtf8) c).getBytes());
+                       return addUtf8(((ConstantUtf8) c).getValue());
 
                case Constants.CONSTANT_Double:
-                       return addDouble(((ConstantDouble) c).getBytes());
+                       return addDouble(((ConstantDouble) c).getValue());
 
                case Constants.CONSTANT_Float:
-                       return addFloat(((ConstantFloat) c).getBytes());
+                       return addFloat(((ConstantFloat) c).getValue());
 
                case Constants.CONSTANT_Long:
-                       return addLong(((ConstantLong) c).getBytes());
+                       return addLong(((ConstantLong) c).getValue());
 
                case Constants.CONSTANT_Integer:
-                       return addInteger(((ConstantInteger) c).getBytes());
+                       return addInteger(((ConstantInteger) c).getValue());
 
                case Constants.CONSTANT_InterfaceMethodref:
                case Constants.CONSTANT_Methodref:
@@ -566,13 +552,13 @@ public class ConstantPool implements Node {
                        ConstantClass clazz = (ConstantClass) constants[m.getClassIndex()];
                        ConstantNameAndType n = (ConstantNameAndType) constants[m.getNameAndTypeIndex()];
                        ConstantUtf8 u8 = (ConstantUtf8) constants[clazz.getNameIndex()];
-                       String class_name = u8.getBytes().replace('/', '.');
+                       String class_name = u8.getValue().replace('/', '.');
 
                        u8 = (ConstantUtf8) constants[n.getNameIndex()];
-                       String name = u8.getBytes();
+                       String name = u8.getValue();
 
                        u8 = (ConstantUtf8) constants[n.getSignatureIndex()];
-                       String signature = u8.getBytes();
+                       String signature = u8.getValue();
 
                        switch (c.getTag()) {
                        case Constants.CONSTANT_InterfaceMethodref:
@@ -632,16 +618,16 @@ public class ConstantPool implements Node {
                                ConstantInterfaceMethodref cfr = (ConstantInterfaceMethodref) c;
 
                                ConstantClass cc = (ConstantClass) pool[cfr.getClassIndex()];
-                               String cName = ((ConstantUtf8) pool[cc.getNameIndex()]).getBytes();
+                               String cName = ((ConstantUtf8) pool[cc.getNameIndex()]).getValue();
                                if (!cName.equals(searchClassname))
                                        continue;
 
                                // check the name and type
                                ConstantNameAndType cnat = (ConstantNameAndType) pool[cfr.getNameAndTypeIndex()];
-                               String name = ((ConstantUtf8) pool[cnat.getNameIndex()]).getBytes();
+                               String name = ((ConstantUtf8) pool[cnat.getNameIndex()]).getValue();
                                if (!name.equals(searchMethodName))
                                        continue; // not this one
-                               String typeSignature = ((ConstantUtf8) pool[cnat.getSignatureIndex()]).getBytes();
+                               String typeSignature = ((ConstantUtf8) pool[cnat.getSignatureIndex()]).getValue();
                                if (!typeSignature.equals(searchSignature))
                                        continue;
                                return i;
@@ -665,15 +651,15 @@ public class ConstantPool implements Node {
                                // check the class
                                int cIndex = cfr.getClassIndex();
                                ConstantClass cc = (ConstantClass) pool[cIndex];
-                               String cName = ((ConstantUtf8) pool[cc.getNameIndex()]).getBytes();
+                               String cName = ((ConstantUtf8) pool[cc.getNameIndex()]).getValue();
                                if (!cName.equals(searchClassname))
                                        continue;
 
                                // check the name and type
-                               String name = ((ConstantUtf8) pool[cnat.getNameIndex()]).getBytes();
+                               String name = ((ConstantUtf8) pool[cnat.getNameIndex()]).getValue();
                                if (!name.equals(searchMethodName))
                                        continue; // not this one
-                               String typeSignature = ((ConstantUtf8) pool[cnat.getSignatureIndex()]).getBytes();
+                               String typeSignature = ((ConstantUtf8) pool[cnat.getSignatureIndex()]).getValue();
                                if (!typeSignature.equals(searchSignature))
                                        continue;
                                methodCache.put(key, new Integer(i));
index bd0807f0097e5f3c4c4ab80d87c8f91d91c613e3..c29b8bba91a337e9552300772146351969c2b61f 100644 (file)
@@ -54,94 +54,70 @@ 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;
 
-/** 
- * This class is derived from the abstract 
- * <A HREF="org.aspectj.apache.bcel.classfile.Constant.html">Constant</A> class 
- * and represents a reference to a String object.
- *
- * @version $Id: ConstantString.java,v 1.3 2008/05/28 23:53:02 aclement Exp $
- * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
- * @see     Constant
+import org.aspectj.apache.bcel.Constants;
+
+/**
+ * This class is derived from the abstract <A HREF="org.aspectj.apache.bcel.classfile.Constant.html">Constant</A> class and
+ * represents a reference to a String object.
+ * 
+ * @version $Id: ConstantString.java,v 1.4 2009/09/10 15:35:04 aclement Exp $
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Constant
  */
-public final class ConstantString extends Constant implements ConstantObject {
-  private int string_index; // Identical to ConstantClass except for this name
+public final class ConstantString extends Constant {
+       private int stringIndex;
+
+       public ConstantString(ConstantString c) {
+               this(c.getStringIndex());
+       }
+
+       ConstantString(DataInputStream file) throws IOException {
+               this(file.readUnsignedShort());
+       }
+
+       public ConstantString(int stringIndex) {
+               super(Constants.CONSTANT_String);
+               this.stringIndex = stringIndex;
+       }
+
+       @Override
+       public void accept(ClassVisitor v) {
+               v.visitConstantString(this);
+       }
+
+       @Override
+       public final void dump(DataOutputStream file) throws IOException {
+               file.writeByte(tag);
+               file.writeShort(stringIndex);
+       }
+
+       // OPTIMIZE fix duplication in these next two methods
+       /**
+        * @return the index of the string in the constant pool
+        */
+       @Override
+       public Integer getValue() {
+               return stringIndex;
+       }
 
-  /**
-   * Initialize from another object.
-   */
-  public ConstantString(ConstantString c) {
-    this(c.getStringIndex());
-  }    
-  /** 
-   * Initialize instance from file data.
-   *
-   * @param file Input stream
-   * @throws IOException
-   */
-  ConstantString(DataInputStream file) throws IOException
-  {    
-    this(file.readUnsignedShort());
-  }    
-  /**
-   * @param string_index Index of Constant_Utf8 in constant pool
-   */
-  public ConstantString(int string_index)
-  {    
-    super(Constants.CONSTANT_String);
-    this.string_index = string_index;
-  }    
-  /**
-   * 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.visitConstantString(this);
-  }    
-  /**
-   * Dump constant field reference to file stream in binary format.
-   *
-   * @param file Output file stream
-   * @throws IOException
-   */ 
-  public final void dump(DataOutputStream file) throws IOException
-  {
-    file.writeByte(tag);
-    file.writeShort(string_index);
-  }    
-  /**
-   * @return Index in constant pool of the string (ConstantUtf8).
-   */  
-  public final int getStringIndex() { return string_index; }    
-  /**
-   * @param string_index.
-   */
-  public final void setStringIndex(int string_index) {
-    this.string_index = string_index;
-  }    
-  /**
-   * @return String representation.
-   */
-  public final String toString()
-  {
-    return super.toString() + "(string_index = " + string_index + ")";
-  }    
+       public final int getStringIndex() {
+               return stringIndex;
+       }
 
-  /** @return String object
-   */
-  public Object getConstantValue(ConstantPool cp) {
-    Constant c = cp.getConstant(string_index, Constants.CONSTANT_Utf8);
-    return ((ConstantUtf8)c).getBytes();
-  }
+       @Override
+       public final String toString() {
+               return super.toString() + "(string_index = " + stringIndex + ")";
+       }
 
-  /** @return dereferenced string
-   */
-  public String getBytes(ConstantPool cp) {
-    return (String)getConstantValue(cp);
-  }
+       /**
+        * @return the string, as dereferenced using the internal index into the supplied constant pool
+        */
+       public String getString(ConstantPool cpool) {
+               Constant c = cpool.getConstant(stringIndex, Constants.CONSTANT_Utf8);
+               return ((ConstantUtf8) c).getValue();
+       }
 }
index 603199efc03d9859aa6736d6e5df486852256e6c..b3f8f12b764904a2fb5e0e04941b2de166515235 100644 (file)
@@ -54,91 +54,64 @@ 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;
 
-/** 
- * This class is derived from the abstract 
- * <A HREF="org.aspectj.apache.bcel.classfile.Constant.html">Constant</A> class 
- * and represents a reference to a Utf8 encoded string.
- *
- * @version $Id: ConstantUtf8.java,v 1.3 2008/05/28 23:53:01 aclement Exp $
- * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
- * @see     Constant
+import org.aspectj.apache.bcel.Constants;
+
+/**
+ * This class is derived from the abstract <A HREF="org.aspectj.apache.bcel.classfile.Constant.html">Constant</A> class and
+ * represents a reference to a Utf8 encoded string.
+ * 
+ * @version $Id: ConstantUtf8.java,v 1.4 2009/09/10 15:35:05 aclement Exp $
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Constant
  */
-public final class ConstantUtf8 extends Constant {
-  private String bytes;
-  
-  /**
-   * Initialize from another object.
-   */
-  public ConstantUtf8(ConstantUtf8 c) {
-    this(c.getBytes());
-  }    
-  
-  /**
-   * Initialize instance from file data.
-   *
-   * @param file Input stream
-   * @throws IOException
-   */
-  ConstantUtf8(DataInputStream file) throws IOException
-  {    
-    super(Constants.CONSTANT_Utf8);
-    bytes=file.readUTF();
-  }    
+public final class ConstantUtf8 extends Constant implements SimpleConstant {
+       private String string;
+
+       public ConstantUtf8(ConstantUtf8 c) {
+               this(c.getValue());
+       }
+
+       ConstantUtf8(DataInputStream file) throws IOException {
+               super(Constants.CONSTANT_Utf8);
+               string = file.readUTF();
+       }
 
-  public ConstantUtf8(String bytes)
-  {
-    super(Constants.CONSTANT_Utf8);
+       public ConstantUtf8(String string) {
+               super(Constants.CONSTANT_Utf8);
+               assert string != null;
+               this.string = string;
+       }
 
-    if(bytes == null)
-      throw new IllegalArgumentException("bytes must not be null!");
-    this.bytes  = bytes;
-  }    
+       @Override
+       public void accept(ClassVisitor v) {
+               v.visitConstantUtf8(this);
+       }
 
-  /**
-   * 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.visitConstantUtf8(this);
-  }
+       @Override
+       public final void dump(DataOutputStream file) throws IOException {
+               file.writeByte(tag);
+               file.writeUTF(string);
+       }
 
-  /**
-   * Dump String in Utf8 format to file stream.
-   *
-   * @param file Output file stream
-   * @throws IOException
-   */ 
-  public final void dump(DataOutputStream file) throws IOException
-  {
-    file.writeByte(tag);
-    file.writeUTF(bytes);
-  }
+       public final void setBytes(String bytes) {
+               this.string = bytes;
+       }
 
-  /**
-   * @return Data converted to string.
-   */  
-  public final String getBytes() {
-         return bytes; 
-  }    
+       @Override
+       public final String toString() {
+               return super.toString() + "(\"" + Utility.replace(string, "\n", "\\n") + "\")";
+       }
 
-  /**
-   * @param bytes.
-   */
-  public final void setBytes(String bytes) {
-    this.bytes = bytes;
-  }    
+       @Override
+       public String getValue() {
+               return string;
+       }
 
-  /**
-   * @return String representation
-   */
-  public final String toString()
-  {
-    return super.toString() + "(\"" + Utility.replace(bytes, "\n", "\\n") + "\")";
-  }    
+       public String getStringValue() {
+               return string;
+       }
 }
index c6a979318bdd4661e46371124c3d8cd39ddb9a8e..c07ddcc6222e96277a470b83283cef2bd20813a0 100644 (file)
@@ -54,125 +54,136 @@ 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 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.3 2008/05/28 23:53:02 aclement Exp $
- * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
- * @see     Attribute
+ * 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 $
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Attribute
  */
 public final class ConstantValue extends Attribute {
-  private int constantvalue_index;
-
-  /**
-   * Initialize from another object. Note that both objects use the same
-   * references (shallow copy). Use clone() for a physical copy.
-   */
-  public ConstantValue(ConstantValue c) {
-    this(c.getNameIndex(), c.getLength(), c.getConstantValueIndex(),
-        c.getConstantPool());
-  }
-
-  /**
-   * Construct object from file stream.
-   * @param name_index Name index in constant pool
-   * @param length Content length in bytes
-   * @param file Input stream
-   * @param constant_pool Array of constants
-   * @throw IOException
-   */
-  ConstantValue(int name_index, int length, DataInputStream file,
-               ConstantPool constant_pool) throws IOException
-  {
-    this(name_index, length, file.readUnsignedShort(), constant_pool);
-  }    
-
-  /**
-   * @param name_index Name index in constant pool
-   * @param length Content length in bytes
-   * @param constantvalue_index Index in constant pool
-   * @param constant_pool Array of constants
-   */  
-  public ConstantValue(int name_index, int length, 
-                      int constantvalue_index,
-                      ConstantPool constant_pool)
-  {
-    super(Constants.ATTR_CONSTANT_VALUE, name_index, length, constant_pool);
-    this.constantvalue_index = constantvalue_index;
-  }    
-
-  /**
-   * 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.visitConstantValue(this);
-  }    
-  /**
-   * Dump constant value attribute to file stream on binary format.
-   *
-   * @param file Output file stream
-   * @throws IOException
-   */ 
-  public final void dump(DataOutputStream file) throws IOException
-  {
-    super.dump(file);
-    file.writeShort(constantvalue_index);
-  }    
-  /**
-   * @return Index in constant pool of constant value.
-   */  
-  public final int getConstantValueIndex() { return constantvalue_index; }    
-
-  /**
-   * @param constantvalue_index.
-   */
-  public final void setConstantValueIndex(int constantvalue_index) {
-    this.constantvalue_index = constantvalue_index;
-  }    
-
-  /**
-   * @return String representation of constant value.
-   */ 
-  public final String toString() {
-    Constant c = constantPool.getConstant(constantvalue_index);
-       
-    String   buf;
-    int    i;
-
-    // Print constant to string depending on its type
-    switch(c.getTag()) {
-    case Constants.CONSTANT_Long:    buf = "" + ((ConstantLong)c).getBytes();    break;
-    case Constants.CONSTANT_Float:   buf = "" + ((ConstantFloat)c).getBytes();   break;
-    case Constants.CONSTANT_Double:  buf = "" + ((ConstantDouble)c).getBytes();  break;
-    case Constants.CONSTANT_Integer: buf = "" + ((ConstantInteger)c).getBytes(); break;
-    case Constants.CONSTANT_String:  
-      i   = ((ConstantString)c).getStringIndex();
-      c   = constantPool.getConstant(i, Constants.CONSTANT_Utf8);
-      buf = "\"" + Utility.convertString(((ConstantUtf8)c).getBytes()) + "\"";
-      break;
-
-    default:
-      throw new IllegalStateException("Type of ConstValue invalid: " + c);
-    }
-
-    return buf;
-  }
-
-  /**
-   * @return deep copy of this attribute
-   */
-  public Attribute copy(ConstantPool constant_pool) {
-    ConstantValue c = (ConstantValue)clone();
-    c.constantPool = constant_pool;
-    return c;
-  }
+       private int constantvalue_index;
+
+       /**
+        * Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a physical
+        * copy.
+        */
+       public ConstantValue(ConstantValue c) {
+               this(c.getNameIndex(), c.getLength(), c.getConstantValueIndex(), c.getConstantPool());
+       }
+
+       /**
+        * Construct object from file stream.
+        * 
+        * @param name_index Name index in constant pool
+        * @param length Content length in bytes
+        * @param file Input stream
+        * @param constant_pool Array of constants
+        * @throw IOException
+        */
+       ConstantValue(int name_index, int length, DataInputStream file, ConstantPool constant_pool) throws IOException {
+               this(name_index, length, file.readUnsignedShort(), constant_pool);
+       }
+
+       /**
+        * @param name_index Name index in constant pool
+        * @param length Content length in bytes
+        * @param constantvalue_index Index in constant pool
+        * @param constant_pool Array of constants
+        */
+       public ConstantValue(int name_index, int length, int constantvalue_index, ConstantPool constant_pool) {
+               super(Constants.ATTR_CONSTANT_VALUE, name_index, length, constant_pool);
+               this.constantvalue_index = constantvalue_index;
+       }
+
+       /**
+        * 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.visitConstantValue(this);
+       }
+
+       /**
+        * Dump constant value attribute to file stream on binary format.
+        * 
+        * @param file Output file stream
+        * @throws IOException
+        */
+       @Override
+       public final void dump(DataOutputStream file) throws IOException {
+               super.dump(file);
+               file.writeShort(constantvalue_index);
+       }
+
+       /**
+        * @return Index in constant pool of constant value.
+        */
+       public final int getConstantValueIndex() {
+               return constantvalue_index;
+       }
+
+       /**
+        * @param constantvalue_index.
+        */
+       public final void setConstantValueIndex(int constantvalue_index) {
+               this.constantvalue_index = constantvalue_index;
+       }
+
+       /**
+        * @return String representation of constant value.
+        */
+       @Override
+       public final String toString() {
+               Constant c = cpool.getConstant(constantvalue_index);
+
+               String buf;
+               int i;
+
+               // Print constant to string depending on its type
+               switch (c.getTag()) {
+               case Constants.CONSTANT_Long:
+                       buf = "" + ((ConstantLong) c).getValue();
+                       break;
+               case Constants.CONSTANT_Float:
+                       buf = "" + ((ConstantFloat) c).getValue();
+                       break;
+               case Constants.CONSTANT_Double:
+                       buf = "" + ((ConstantDouble) c).getValue();
+                       break;
+               case Constants.CONSTANT_Integer:
+                       buf = "" + ((ConstantInteger) c).getValue();
+                       break;
+               case Constants.CONSTANT_String:
+                       i = ((ConstantString) c).getStringIndex();
+                       c = cpool.getConstant(i, Constants.CONSTANT_Utf8);
+                       buf = "\"" + Utility.convertString(((ConstantUtf8) c).getValue()) + "\"";
+                       break;
+
+               default:
+                       throw new IllegalStateException("Type of ConstValue invalid: " + c);
+               }
+
+               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;
+       }
 }
index 8df953096c48b8947fe97553f13b317e7aea2cc4..f3cc4e32c35215bb1c3446664f3760ec8cdcc98d 100644 (file)
@@ -62,7 +62,7 @@ import  java.io.*;
  * deprecated method.
  * It is instantiated from the <em>Attribute.readAttribute()</em> method.
  *
- * @version $Id: Deprecated.java,v 1.3 2008/05/28 23:53:01 aclement Exp $
+ * @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
  */
@@ -163,7 +163,7 @@ public final class Deprecated extends Attribute {
     if(bytes != null)
       c.bytes = (byte[])bytes.clone();
 
-    c.constantPool = constant_pool;
+    c.cpool = constant_pool;
     return c;
   }
 }
index 6b01d23e521579ff56fdef1968c9bb35f1dfca02..9e1554ec58e0148f5e6dac7c866e8339385f98eb 100644 (file)
@@ -68,14 +68,14 @@ public class EnclosingMethod extends Attribute {
 
        public final ConstantClass getEnclosingClass() {
                ConstantClass c = 
-                       (ConstantClass)constantPool.getConstant(classIndex,Constants.CONSTANT_Class);
+                       (ConstantClass)cpool.getConstant(classIndex,Constants.CONSTANT_Class);
                return c;
        }
        
        public final ConstantNameAndType getEnclosingMethod() {
                if (methodIndex == 0) return null;
                ConstantNameAndType nat = 
-                       (ConstantNameAndType)constantPool.getConstant(methodIndex,Constants.CONSTANT_NameAndType);
+                       (ConstantNameAndType)cpool.getConstant(methodIndex,Constants.CONSTANT_NameAndType);
                return nat;
        }
 
index 3219cbae7b63ba425ddf88f9ae2bd4f8d2052705..a7a084cefa6bfa4934e4d85d0dc45cf68be899ca 100644 (file)
@@ -65,7 +65,7 @@ import  java.io.*;
  * attribute using the name <em>Exceptions</em> (which is inconsistent
  * with the other classes).
  *
- * @version $Id: ExceptionTable.java,v 1.3 2008/05/28 23:53:02 aclement Exp $
+ * @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
  */
@@ -156,7 +156,7 @@ public final class ExceptionTable extends Attribute {
   public final String[] getExceptionNames() {
     String[] names = new String[number_of_exceptions];
     for(int i=0; i < number_of_exceptions; i++)
-      names[i] = constantPool.getConstantString(exception_index_table[i],
+      names[i] = cpool.getConstantString(exception_index_table[i],
                                                 Constants.CONSTANT_Class).
        replace('/', '.');
     return names;
@@ -179,7 +179,7 @@ public final class ExceptionTable extends Attribute {
     String       str;
 
     for(int i=0; i < number_of_exceptions; i++) {
-      str = constantPool.getConstantString(exception_index_table[i],
+      str = cpool.getConstantString(exception_index_table[i],
                                            Constants.CONSTANT_Class);
       buf.append(Utility.compactClassName(str, false));
 
@@ -196,7 +196,7 @@ public final class ExceptionTable extends Attribute {
   public Attribute copy(ConstantPool constant_pool) {
     ExceptionTable c = (ExceptionTable)clone();
     c.exception_index_table = (int[])exception_index_table.clone();
-    c.constantPool = constant_pool;
+    c.cpool = constant_pool;
     return c;
   }
 }
index 4465f3027ea4c625fde10dc9f4d451ba1074ac79..3453347a797e0ea74090188ff30a53c82655567b 100644 (file)
@@ -59,85 +59,83 @@ import java.io.IOException;
 import org.aspectj.apache.bcel.generic.Type;
 
 /**
- * This class represents the field info structure, i.e., the representation 
- * for a variable in the class. See JVM specification for details.
- *
- * @version $Id: Field.java,v 1.4 2008/06/03 05:28:59 aclement Exp $
- * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * This class represents the field info structure, i.e., the representation for a variable in the class. See JVM specification for
+ * details.
+ * 
+ * @version $Id: Field.java,v 1.5 2009/09/10 15:35:05 aclement Exp $
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
  */
 public final class Field extends FieldOrMethod {
-       
-  public static final Field[] NoFields = new Field[0];
-  
-  private Type fieldType = null; // lazily initialized
-
-  private Field() {}
-  
-  /**
-   * Initialize from another object. Note that both objects use the same
-   * references (shallow copy). Use clone() for a physical copy.
-   */
-  public Field(Field c) {
-    super(c);
-  }
-
-  Field(DataInputStream file, ConstantPool constant_pool) throws IOException {
-    super(file, constant_pool);
-  }
-
-  public Field(int accessflags, int nameIndex, int signatureIndex,Attribute[] attributes, ConstantPool constant_pool) {
-    super(accessflags, nameIndex, signatureIndex, attributes, constant_pool);
-  }
-
-  public void accept(ClassVisitor v) {
-    v.visitField(this);
-  }
-
-  /**
-   * @return constant value associated with this field (may be null)
-   */
-  public final ConstantValue getConstantValue() {
-         return AttributeUtils.getConstantValueAttribute(attributes);
-  }
-
-  /**
-   * Return string representation close to declaration format, eg:
-   * 'public static final short MAX = 100'
-   */
-  public final String toString() {
-    String name, signature, access; // Short cuts to constant pool
-
-    // Get names from constant pool
-    access    = Utility.accessToString(modifiers);
-    access    = access.equals("")? "" : (access + " ");
-    signature = Utility.signatureToString(getSignature());
-    name      = getName();
-
-    StringBuffer  buf = new StringBuffer(access);
-    buf.append(signature).append(" ").append(name);
-    ConstantValue cv  = getConstantValue();
-
-    if (cv != null) buf.append(" = ").append(cv);
-
-    // append all attributes that are *not* "ConstantValue"
-    for(int i=0; i < attributes.length; i++) {
-      Attribute a = attributes[i];
-      if(!(a instanceof ConstantValue)) buf.append(" [").append(a.toString()).append("]");
-    }
-
-    return buf.toString();
-  }
-
-  /** deep copy of this field */
-  public final Field copy(ConstantPool constant_pool) {
-    return (Field)copy_(constant_pool);
-  }
-
-  /** return the type of the field */
-  public Type getType() {
-       if (fieldType==null) {
-               fieldType = Type.getReturnType(getSignature());
+
+       public static final Field[] NoFields = new Field[0];
+
+       private Type fieldType = null; // lazily initialized
+
+       private Field() {
+       }
+
+       public Field(Field c) {
+               super(c);
+       }
+
+       Field(DataInputStream dis, ConstantPool cpool) throws IOException {
+               super(dis, cpool);
+       }
+
+       public Field(int modifiers, int nameIndex, int signatureIndex, Attribute[] attributes, ConstantPool cpool) {
+               super(modifiers, nameIndex, signatureIndex, attributes, cpool);
+       }
+
+       public void accept(ClassVisitor v) {
+               v.visitField(this);
+       }
+
+       /**
+        * @return constant value associated with this field (may be null)
+        */
+       public final ConstantValue getConstantValue() {
+               return AttributeUtils.getConstantValueAttribute(attributes);
+       }
+
+       /**
+        * Return string representation close to declaration format, eg: 'public static final short MAX = 100'
+        */
+       @Override
+       public final String toString() {
+               // Get names from constant pool
+               StringBuffer buf = new StringBuffer(Utility.accessToString(modifiers));
+               if (buf.length() > 0) {
+                       buf.append(" ");
+               }
+               String signature = Utility.signatureToString(getSignature());
+
+               buf.append(signature).append(" ").append(getName());
+
+               ConstantValue cv = getConstantValue();
+               if (cv != null) {
+                       buf.append(" = ").append(cv);
+               }
+
+               // append all attributes that are *not* "ConstantValue"
+               for (Attribute a : attributes) {
+                       if (!(a instanceof ConstantValue)) {
+                               buf.append(" [").append(a.toString()).append("]");
+                       }
+               }
+
+               return buf.toString();
+       }
+
+       /** deep copy of this field */
+       public final Field copy(ConstantPool constant_pool) {
+               return (Field) copy_(constant_pool);
+       }
+
+       /** return the type of the field */
+       public Type getType() {
+               if (fieldType == null) {
+                       fieldType = Type.getReturnType(getSignature());
+               }
+               return fieldType;
        }
-       return fieldType;
-  }
 }
index 4841b9b51bb024727705966e155955edeef8de93..ad15e4275fa9c05891e12f04beb4d6679220116e 100644 (file)
@@ -66,7 +66,7 @@ import org.aspectj.apache.bcel.classfile.annotation.RuntimeAnnotations;
 /**
  * Abstract super class for fields and methods.
  * 
- * @version $Id: FieldOrMethod.java,v 1.9 2009/09/09 21:26:54 aclement Exp $
+ * @version $Id: FieldOrMethod.java,v 1.10 2009/09/10 15:35:05 aclement Exp $
  * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
  */
 public abstract class FieldOrMethod extends Modifiers implements Cloneable, Node {
@@ -138,7 +138,7 @@ public abstract class FieldOrMethod extends Modifiers implements Cloneable, Node
        public final String getName() {
                if (name == null) {
                        ConstantUtf8 c = (ConstantUtf8) cpool.getConstant(nameIndex, Constants.CONSTANT_Utf8);
-                       name = c.getBytes();
+                       name = c.getValue();
                }
                return name;
        }
@@ -146,7 +146,7 @@ public abstract class FieldOrMethod extends Modifiers implements Cloneable, Node
        public final String getSignature() {
                if (signature == null) {
                        ConstantUtf8 c = (ConstantUtf8) cpool.getConstant(signatureIndex, Constants.CONSTANT_Utf8);
-                       signature = c.getBytes();
+                       signature = c.getValue();
                }
                return signature;
        }
index 8ccbeb93a3db38ef0c22ed91adcc1ed8be991b39..d3b1eb0a887b049cfc4f9c01365cff1a5dcd29ab 100644 (file)
@@ -54,168 +54,179 @@ 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;
 
-/** 
- * This class represents a inner class attribute, i.e., the class
- * indices of the inner and outer classes, the name and the attributes
- * of the inner class.
- *
- * @version $Id: InnerClass.java,v 1.3 2008/05/28 23:53:02 aclement Exp $
- * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+import org.aspectj.apache.bcel.Constants;
+
+/**
+ * This class represents a inner class attribute, i.e., the class indices of the inner and outer classes, the name and the
+ * attributes of the inner class.
+ * 
+ * @version $Id: InnerClass.java,v 1.4 2009/09/10 15:35:05 aclement Exp $
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
  * @see InnerClasses
  */
 public final class InnerClass implements Cloneable, Node {
-  private int inner_class_index;
-  private int outer_class_index;
-  private int inner_name_index;
-  private int inner_access_flags;
-
-  /**
-   * Initialize from another object.
-   */
-  public InnerClass(InnerClass c) {
-    this(c.getInnerClassIndex(), c.getOuterClassIndex(), c.getInnerNameIndex(),
-        c.getInnerAccessFlags());
-  }
-
-  /**
-   * Construct object from file stream.
-   * @param file Input stream
-   * @throws IOException
-   */  
-  InnerClass(DataInputStream file) throws IOException
-  {
-    this(file.readUnsignedShort(), file.readUnsignedShort(),
-        file.readUnsignedShort(), file.readUnsignedShort());
-  }
-
-  /**
-   * @param inner_class_index Class index in constant pool of inner class
-   * @param outer_class_index Class index in constant pool of outer class
-   * @param inner_name_index  Name index in constant pool of inner class
-   * @param inner_access_flags Access flags of inner class
-   */
-  public InnerClass(int inner_class_index, int outer_class_index,
-                   int inner_name_index, int inner_access_flags)
-  {
-    this.inner_class_index  = inner_class_index; 
-    this.outer_class_index  = outer_class_index;
-    this.inner_name_index   = inner_name_index; 
-    this.inner_access_flags = inner_access_flags;
-  }
-
-  /**
-   * 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.visitInnerClass(this);
-  }    
-  /**
-   * Dump inner class attribute to file stream in binary format.
-   *
-   * @param file Output file stream
-   * @throws IOException
-   */ 
-  public final void dump(DataOutputStream file) throws IOException
-  {
-    file.writeShort(inner_class_index);
-    file.writeShort(outer_class_index);
-    file.writeShort(inner_name_index);
-    file.writeShort(inner_access_flags);
-  }    
-  /**
-   * @return access flags of inner class.
-   */  
-  public final int getInnerAccessFlags() { return inner_access_flags; }    
-  /**
-   * @return class index of inner class.
-   */  
-  public final int getInnerClassIndex() { return inner_class_index; }    
-  /**
-   * @return name index of inner class.
-   */  
-  public final int getInnerNameIndex() { return inner_name_index; }    
-  /**
-   * @return class index of outer class.
-   */  
-  public final int getOuterClassIndex() { return outer_class_index; }    
-  /**
-   * @param inner_access_flags.
-   */
-  public final void setInnerAccessFlags(int inner_access_flags) {
-    this.inner_access_flags = inner_access_flags;
-  }    
-  /**
-   * @param inner_class_index.
-   */
-  public final void setInnerClassIndex(int inner_class_index) {
-    this.inner_class_index = inner_class_index;
-  }    
-  /**
-   * @param inner_name_index.
-   */
-  public final void setInnerNameIndex(int inner_name_index) {
-    this.inner_name_index = inner_name_index;
-  }    
-  /**
-   * @param outer_class_index.
-   */
-  public final void setOuterClassIndex(int outer_class_index) {
-    this.outer_class_index = outer_class_index;
-  }    
-  /**
-   * @return String representation.
-   */ 
-  public final String toString() {
-    return "InnerClass(" + inner_class_index + ", " + outer_class_index +
-      ", " + inner_name_index + ", " + inner_access_flags + ")";
-  }
-
-  /**
-   * @return Resolved string representation
-   */ 
-  public final String toString(ConstantPool constant_pool) { 
-    String inner_class_name, outer_class_name, inner_name, access;
-    inner_class_name = constant_pool.getConstantString(inner_class_index,
-                                                      Constants.CONSTANT_Class);
-    inner_class_name = Utility.compactClassName(inner_class_name);
-
-    if (outer_class_index != 0) {
-      outer_class_name = constant_pool.getConstantString(outer_class_index, 
-                                                         Constants.CONSTANT_Class);
-      outer_class_name = Utility.compactClassName(outer_class_name);
-    }
-    else
-      outer_class_name = "<not a member>";
-    
-    if(inner_name_index != 0)
-      inner_name = ((ConstantUtf8)constant_pool.
-                   getConstant(inner_name_index, Constants.CONSTANT_Utf8)).getBytes();
-    else
-      inner_name = "<anonymous>";
-
-    access = Utility.accessToString(inner_access_flags, true);
-    access = access.equals("")? "" : (access + " ");
-
-    return "InnerClass:" + access + inner_class_name + 
-      "(\"" + outer_class_name + "\", \"" + inner_name + "\")";
-  }   
-
-  /**
-   * @return deep copy of this object
-   */
-  public InnerClass copy() {
-    try {
-      return (InnerClass)clone();
-    } catch(CloneNotSupportedException e) {}
-
-    return null;
-  }
+       private int inner_class_index;
+       private int outer_class_index;
+       private int inner_name_index;
+       private int inner_access_flags;
+
+       /**
+        * Initialize from another object.
+        */
+       public InnerClass(InnerClass c) {
+               this(c.getInnerClassIndex(), c.getOuterClassIndex(), c.getInnerNameIndex(), c.getInnerAccessFlags());
+       }
+
+       /**
+        * Construct object from file stream.
+        * 
+        * @param file Input stream
+        * @throws IOException
+        */
+       InnerClass(DataInputStream file) throws IOException {
+               this(file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort());
+       }
+
+       /**
+        * @param inner_class_index Class index in constant pool of inner class
+        * @param outer_class_index Class index in constant pool of outer class
+        * @param inner_name_index Name index in constant pool of inner class
+        * @param inner_access_flags Access flags of inner class
+        */
+       public InnerClass(int inner_class_index, int outer_class_index, int inner_name_index, int inner_access_flags) {
+               this.inner_class_index = inner_class_index;
+               this.outer_class_index = outer_class_index;
+               this.inner_name_index = inner_name_index;
+               this.inner_access_flags = inner_access_flags;
+       }
+
+       /**
+        * 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.visitInnerClass(this);
+       }
+
+       /**
+        * Dump inner class attribute to file stream in binary format.
+        * 
+        * @param file Output file stream
+        * @throws IOException
+        */
+       public final void dump(DataOutputStream file) throws IOException {
+               file.writeShort(inner_class_index);
+               file.writeShort(outer_class_index);
+               file.writeShort(inner_name_index);
+               file.writeShort(inner_access_flags);
+       }
+
+       /**
+        * @return access flags of inner class.
+        */
+       public final int getInnerAccessFlags() {
+               return inner_access_flags;
+       }
+
+       /**
+        * @return class index of inner class.
+        */
+       public final int getInnerClassIndex() {
+               return inner_class_index;
+       }
+
+       /**
+        * @return name index of inner class.
+        */
+       public final int getInnerNameIndex() {
+               return inner_name_index;
+       }
+
+       /**
+        * @return class index of outer class.
+        */
+       public final int getOuterClassIndex() {
+               return outer_class_index;
+       }
+
+       /**
+        * @param inner_access_flags.
+        */
+       public final void setInnerAccessFlags(int inner_access_flags) {
+               this.inner_access_flags = inner_access_flags;
+       }
+
+       /**
+        * @param inner_class_index.
+        */
+       public final void setInnerClassIndex(int inner_class_index) {
+               this.inner_class_index = inner_class_index;
+       }
+
+       /**
+        * @param inner_name_index.
+        */
+       public final void setInnerNameIndex(int inner_name_index) {
+               this.inner_name_index = inner_name_index;
+       }
+
+       /**
+        * @param outer_class_index.
+        */
+       public final void setOuterClassIndex(int outer_class_index) {
+               this.outer_class_index = outer_class_index;
+       }
+
+       /**
+        * @return String representation.
+        */
+       @Override
+       public final String toString() {
+               return "InnerClass(" + inner_class_index + ", " + outer_class_index + ", " + inner_name_index + ", " + inner_access_flags
+                               + ")";
+       }
+
+       /**
+        * @return Resolved string representation
+        */
+       public final String toString(ConstantPool constant_pool) {
+               String inner_class_name, outer_class_name, inner_name, access;
+
+               inner_class_name = constant_pool.getConstantString(inner_class_index, Constants.CONSTANT_Class);
+               inner_class_name = Utility.compactClassName(inner_class_name);
+
+               if (outer_class_index != 0) {
+                       outer_class_name = constant_pool.getConstantString(outer_class_index, Constants.CONSTANT_Class);
+                       outer_class_name = Utility.compactClassName(outer_class_name);
+               } else
+                       outer_class_name = "<not a member>";
+
+               if (inner_name_index != 0)
+                       inner_name = ((ConstantUtf8) constant_pool.getConstant(inner_name_index, Constants.CONSTANT_Utf8)).getValue();
+               else
+                       inner_name = "<anonymous>";
+
+               access = Utility.accessToString(inner_access_flags, true);
+               access = access.equals("") ? "" : (access + " ");
+
+               return "InnerClass:" + access + inner_class_name + "(\"" + outer_class_name + "\", \"" + inner_name + "\")";
+       }
+
+       /**
+        * @return deep copy of this object
+        */
+       public InnerClass copy() {
+               try {
+                       return (InnerClass) clone();
+               } catch (CloneNotSupportedException e) {
+               }
+
+               return null;
+       }
 }
index 7bc5b6e1c030611929f4453a73eb9e4635aed8e6..493012bf941582962bcc8a90051d1f7bb84bbee9 100644 (file)
@@ -63,7 +63,7 @@ import  java.io.*;
  * to the source file of this class.
  * It is instantiated from the <em>Attribute.readAttribute()</em> method.
  *
- * @version $Id: InnerClasses.java,v 1.3 2008/05/28 23:53:02 aclement Exp $
+ * @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
  */
@@ -160,7 +160,7 @@ public final class InnerClasses extends Attribute {
     StringBuffer buf = new StringBuffer();
 
     for(int i=0; i < number_of_classes; i++)
-      buf.append(inner_classes[i].toString(constantPool) + "\n");
+      buf.append(inner_classes[i].toString(cpool) + "\n");
 
     return buf.toString();
   }
@@ -175,7 +175,7 @@ public final class InnerClasses extends Attribute {
     for(int i=0; i < number_of_classes; i++)
       c.inner_classes[i] = inner_classes[i].copy();
 
-    c.constantPool = constant_pool;
+    c.cpool = constant_pool;
     return c;
   }
 }
index 83a9f7110e3ed4d049103d7b6382e04141e3e1de..e0ba7ebae34c58aac2cdf22809463cac9e5f98ce 100644 (file)
@@ -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.6 2009/09/09 21:26:54 aclement Exp $
+ * @version $Id: LineNumberTable.java,v 1.7 2009/09/10 15:35:05 aclement Exp $
  * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
  * @see Code changes: asc Feb06 Made unpacking lazy
  */
@@ -266,7 +266,7 @@ public final class LineNumberTable extends Attribute {
                for (int i = 0; i < tableLength; i++) {
                        newTable.table[i] = table[i].copy();
                }
-               newTable.constantPool = constant_pool;
+               newTable.cpool = constant_pool;
                return newTable;
        }
 
index 8fc7a504dea6e56e269610012deb9ee4b03bfd69..c8d5cd87f6c855705003ae4546fa8709015cf226 100644 (file)
@@ -54,205 +54,214 @@ 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 local variable within a method. It contains its
- * scope, name, signature and index on the method's frame.
- *
- * @version $Id: LocalVariable.java,v 1.4 2008/08/26 15:00:49 aclement Exp $
- * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
- * @see     LocalVariableTable
+ * This class represents a local variable within a method. It contains its scope, name, signature and index on the method's frame.
+ * 
+ * @version $Id: LocalVariable.java,v 1.5 2009/09/10 15:35:05 aclement Exp $
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see LocalVariableTable
  */
 public final class LocalVariable implements Constants, Cloneable, Node {
 
-  private int start_pc;        // Range in which the variable is valid
-  private int length;
-  private int name_index;      // Index in constant pool of variable name
-  private int signature_index; // Index of variable signature
-  private int index;            /* Variable is `index'th local variable on
-                               * this method's frame.
-                               */
+       private int start_pc; // Range in which the variable is valid
+       private int length;
+       private int name_index; // Index in constant pool of variable name
+       private int signature_index; // Index of variable signature
+       private int index; /*
+                                                * Variable is `index'th local variable on this method's frame.
+                                                */
 
-  private ConstantPool constant_pool;
+       private ConstantPool constant_pool;
 
-  /**
-   * Initialize from another object. Note that both objects use the same
-   * references (shallow copy). Use copy() for a physical copy.
-   */
-  public LocalVariable(LocalVariable c) {
-    this(c.getStartPC(), c.getLength(), c.getNameIndex(),
-        c.getSignatureIndex(), c.getIndex(), c.getConstantPool());
-  }
+       /**
+        * Initialize from another object. Note that both objects use the same references (shallow copy). Use copy() for a physical
+        * copy.
+        */
+       public LocalVariable(LocalVariable c) {
+               this(c.getStartPC(), c.getLength(), c.getNameIndex(), c.getSignatureIndex(), c.getIndex(), c.getConstantPool());
+       }
 
-  /**
-   * Construct object from file stream.
-   * @param file Input stream
-   * @throws IOException
-   */
-  LocalVariable(DataInputStream file, ConstantPool constant_pool)
-       throws IOException
-  {
-    this(file.readUnsignedShort(), file.readUnsignedShort(), 
-        file.readUnsignedShort(), file.readUnsignedShort(), 
-        file.readUnsignedShort(), constant_pool);
-  }
+       /**
+        * Construct object from file stream.
+        * 
+        * @param file Input stream
+        * @throws IOException
+        */
+       LocalVariable(DataInputStream file, ConstantPool constant_pool) throws IOException {
+               this(file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), file
+                               .readUnsignedShort(), constant_pool);
+       }
 
-  /**
-   * @param start_pc Range in which the variable
-   * @param length ... is valid
-   * @param name_index Index in constant pool of variable name
-   * @param signature_index Index of variable's signature
-   * @param index Variable is `index'th local variable on the method's frame
-   * @param constant_pool Array of constants
-   */
-  public LocalVariable(int start_pc, int length, int name_index,
-                      int signature_index, int index,
-                      ConstantPool constant_pool)
-  {
-    this.start_pc        = start_pc;
-    this.length          = length;
-    this.name_index      = name_index;
-    this.signature_index = signature_index;
-    this.index           = index;
-    this.constant_pool   = constant_pool;
-  }
+       /**
+        * @param start_pc Range in which the variable
+        * @param length ... is valid
+        * @param name_index Index in constant pool of variable name
+        * @param signature_index Index of variable's signature
+        * @param index Variable is `index'th local variable on the method's frame
+        * @param constant_pool Array of constants
+        */
+       public LocalVariable(int start_pc, int length, int name_index, int signature_index, int index, ConstantPool constant_pool) {
+               this.start_pc = start_pc;
+               this.length = length;
+               this.name_index = name_index;
+               this.signature_index = signature_index;
+               this.index = index;
+               this.constant_pool = constant_pool;
+       }
 
-  /**
-   * 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.visitLocalVariable(this);
-  }
+       /**
+        * 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.visitLocalVariable(this);
+       }
 
-  /**
-   * Dump local variable to file stream in binary format.
-   *
-   * @param file Output file stream
-   * @throws IOException
-   */ 
-  public final void dump(DataOutputStream file) throws IOException
-  {
-    file.writeShort(start_pc);
-    file.writeShort(length);
-    file.writeShort(name_index);
-    file.writeShort(signature_index);
-    file.writeShort(index);
-  }
+       /**
+        * Dump local variable to file stream in binary format.
+        * 
+        * @param file Output file stream
+        * @throws IOException
+        */
+       public final void dump(DataOutputStream file) throws IOException {
+               file.writeShort(start_pc);
+               file.writeShort(length);
+               file.writeShort(name_index);
+               file.writeShort(signature_index);
+               file.writeShort(index);
+       }
 
-  /**
-   * @return Constant pool used by this object.
-   */   
-  public final ConstantPool getConstantPool() { return constant_pool; }
+       /**
+        * @return Constant pool used by this object.
+        */
+       public final ConstantPool getConstantPool() {
+               return constant_pool;
+       }
 
-  /**
-   * @return Variable is valid within getStartPC() .. getStartPC()+getLength()
-   */  
-  public final int getLength()         { return length; }
+       /**
+        * @return Variable is valid within getStartPC() .. getStartPC()+getLength()
+        */
+       public final int getLength() {
+               return length;
+       }
 
-  /**
-   * @return Variable name.
-   */   
-  public final String getName() {
-    ConstantUtf8  c;
+       /**
+        * @return Variable name.
+        */
+       public final String getName() {
+               ConstantUtf8 c;
 
-    c = (ConstantUtf8)constant_pool.getConstant(name_index, CONSTANT_Utf8);
-    return c.getBytes();
-  }
+               c = (ConstantUtf8) constant_pool.getConstant(name_index, CONSTANT_Utf8);
+               return c.getValue();
+       }
 
-  /**
-   * @return Index in constant pool of variable name.
-   */   
-  public final int getNameIndex()      { return name_index; }
+       /**
+        * @return Index in constant pool of variable name.
+        */
+       public final int getNameIndex() {
+               return name_index;
+       }
 
-  /**
-   * @return Signature.
-   */   
-  public final String getSignature() {
-    ConstantUtf8  c;
-    c = (ConstantUtf8)constant_pool.getConstant(signature_index, 
-                                               CONSTANT_Utf8);
-    return c.getBytes();
-  }
+       /**
+        * @return Signature.
+        */
+       public final String getSignature() {
+               ConstantUtf8 c;
+               c = (ConstantUtf8) constant_pool.getConstant(signature_index, CONSTANT_Utf8);
+               return c.getValue();
+       }
 
-  /**
-   * @return Index in constant pool of variable signature.
-   */   
-  public final int getSignatureIndex() { return signature_index; }    
+       /**
+        * @return Index in constant pool of variable signature.
+        */
+       public final int getSignatureIndex() {
+               return signature_index;
+       }
 
-  /**
-   * @return index of register where variable is stored
-   */   
-  public final int getIndex()           { return index; }
+       /**
+        * @return index of register where variable is stored
+        */
+       public final int getIndex() {
+               return index;
+       }
 
-  /**
-   * @return Start of range where he variable is valid
-   */
-  public final int getStartPC()        { return start_pc; }
+       /**
+        * @return Start of range where he variable is valid
+        */
+       public final int getStartPC() {
+               return start_pc;
+       }
 
-  /**
-   * @param constant_pool Constant pool to be used for this object.
-   */   
-  public final void setConstantPool(ConstantPool constant_pool) {
-    this.constant_pool = constant_pool;
-  }
+       /**
+        * @param constant_pool Constant pool to be used for this object.
+        */
+       public final void setConstantPool(ConstantPool constant_pool) {
+               this.constant_pool = constant_pool;
+       }
 
-  /**
-   * @param length.
-   */
-  public final void setLength(int length) {
-    this.length = length;
-  }
+       /**
+        * @param length.
+        */
+       public final void setLength(int length) {
+               this.length = length;
+       }
 
-  /**
-   * @param name_index.
-   */
-  public final void setNameIndex(int name_index) {
-    this.name_index = name_index;
-  }    
+       /**
+        * @param name_index.
+        */
+       public final void setNameIndex(int name_index) {
+               this.name_index = name_index;
+       }
 
-  /**
-   * @param signature_index.
-   */
-  public final void setSignatureIndex(int signature_index) {
-    this.signature_index = signature_index;
-  }    
+       /**
+        * @param signature_index.
+        */
+       public final void setSignatureIndex(int signature_index) {
+               this.signature_index = signature_index;
+       }
 
-  /**
-   * @param index.
-   */
-  public final void setIndex(int index) { this.index = index; }
+       /**
+        * @param index.
+        */
+       public final void setIndex(int index) {
+               this.index = index;
+       }
 
-  /**
-   * @param start_pc Specify range where the local variable is valid.
-   */
-  public final void setStartPC(int start_pc) {
-    this.start_pc = start_pc;
-  }
+       /**
+        * @param start_pc Specify range where the local variable is valid.
+        */
+       public final void setStartPC(int start_pc) {
+               this.start_pc = start_pc;
+       }
 
-  /**
-   * @return string representation.
-   */
-  public final String toString() {
-    String name = getName(), signature = Utility.signatureToString(getSignature());
+       /**
+        * @return string representation.
+        */
+       @Override
+       public final String toString() {
+               String name = getName(), signature = Utility.signatureToString(getSignature());
 
-    return "LocalVariable(start_pc = " + start_pc + ", length = " + length +
-      ", index = " + index + ":" + signature + " " + name + ")";
-  }    
+               return "LocalVariable(start_pc = " + start_pc + ", length = " + length + ", index = " + index + ":" + signature + " "
+                               + name + ")";
+       }
 
-  /**
-   * @return deep copy of this object
-   */
-  public LocalVariable copy() {
-    try {
-      return (LocalVariable)clone();
-    } catch(CloneNotSupportedException e) {}
+       /**
+        * @return deep copy of this object
+        */
+       public LocalVariable copy() {
+               try {
+                       return (LocalVariable) clone();
+               } catch (CloneNotSupportedException e) {
+               }
 
-    return null;
-  }
+               return null;
+       }
 }
index 4fc728534e41f5050b28ee13fe2f074c7dcdf7de..138269700f2b988731266aab0d54cb3371ce1d34 100644 (file)
@@ -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.6 2009/03/17 01:16:25 aclement Exp $
+ * @version $Id: LocalVariableTable.java,v 1.7 2009/09/10 15:35:04 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.
@@ -197,7 +197,7 @@ public class LocalVariableTable extends Attribute {
                for (int i = 0; i < localVariableTableLength; i++)
                        c.localVariableTable[i] = localVariableTable[i].copy();
 
-               c.constantPool = constant_pool;
+               c.cpool = constant_pool;
                return c;
        }
 
@@ -217,7 +217,7 @@ public class LocalVariableTable extends Attribute {
                        localVariableTableLength = (dis.readUnsignedShort());
                        localVariableTable = new LocalVariable[localVariableTableLength];
                        for (int i = 0; i < localVariableTableLength; i++)
-                               localVariableTable[i] = new LocalVariable(dis, constantPool);
+                               localVariableTable[i] = new LocalVariable(dis, cpool);
                        dis.close();
                        data = null; // throw it away now
                } catch (IOException e) {
index 81af0cc3a5eb7b546b1f90ed9f4be4699a516617..ea1f3badf2ad77fea7ca37ba61f53eb688fb3a6a 100644 (file)
@@ -127,7 +127,7 @@ public class LocalVariableTypeTable extends Attribute {
     for(int i=0; i < local_variable_type_table_length; i++)
       c.local_variable_type_table[i] = local_variable_type_table[i].copy();
 
-    c.constantPool = constant_pool;
+    c.cpool = constant_pool;
     return c;
   }
 
index 59fe05a85e2142e7b9c43634a7524aa48c1da5e7..e3d1f78ac2a207655f216beee1d0164aa4d4d2ee 100644 (file)
@@ -65,215 +65,216 @@ import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleParameterAnnot
 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.8 2009/09/09 19:56:20 aclement Exp $
- * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * 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.9 2009/09/10 15:35:05 aclement Exp $
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
  */
 public final class Method extends FieldOrMethod {
-  
-  public static final AnnotationGen[][] NO_PARAMETER_ANNOTATIONS = new AnnotationGen[][]{};
-  public static final AnnotationGen[] NO_ANNOTATIONS = new AnnotationGen[]{};
-       
-  public static final Method[] NoMethods = new Method[0];
-  
-  private boolean parameterAnnotationsOutOfDate = true;
-  private AnnotationGen[][] unpackedParameterAnnotations;
-
-  private Method() {   
-    parameterAnnotationsOutOfDate = true;
-  }
-
-  /**
-   * Initialize from another object. Note that both objects use the same
-   * references (shallow copy). Use clone() for a physical copy.
-   */
-  public Method(Method c) {
-    super(c);
-    parameterAnnotationsOutOfDate = true;
-  }
-
-  Method(DataInputStream file, ConstantPool constant_pool) throws IOException {
-    super(file, constant_pool);
-  }
-
-  public Method(int access_flags, int name_index, int signature_index, Attribute[] attributes, ConstantPool constant_pool) {
-    super(access_flags, name_index, signature_index, attributes, constant_pool);
-    parameterAnnotationsOutOfDate = true;
-  }
-
-  public void accept(ClassVisitor v) {
-    v.visitMethod(this);
-  }
-  
-  // CUSTARD mutable or not?
-  public void setAttributes(Attribute[] attributes) { 
-    parameterAnnotationsOutOfDate = true;
-    super.setAttributes(attributes);
-  }
-
-  /**
-   * @return Code attribute of method, if any
-   */   
-  public final Code getCode() {
-       return AttributeUtils.getCodeAttribute(attributes);
-  }
-
-  public final ExceptionTable getExceptionTable() {
-    return AttributeUtils.getExceptionTableAttribute(attributes);
-  }
-
-  /** 
-   * Return LocalVariableTable of code attribute if any (the call is forwarded
-   * to the Code attribute)
-   */
-  public final LocalVariableTable getLocalVariableTable() {
-    Code code = getCode();
-    if (code != null) return code.getLocalVariableTable();
-    return null;
-  }
-
-  /** 
-   * Return LineNumberTable of code attribute if any (the call is forwarded
-   * to the Code attribute)
-   */
-  public final LineNumberTable getLineNumberTable() {
-    Code code = getCode();
-    if (code != null) return code.getLineNumberTable();
-    return null;
-  }
-
-  /**
-   * Return string representation close to declaration format, eg:
-   * 'public static void main(String[] args) throws IOException'
-   */
-  public final String toString() {
-    ConstantUtf8  c;
-    String        name, signature, access; // Short cuts to constant pool
-    StringBuffer  buf;
-
-    access = Utility.accessToString(modifiers);
-
-    // Get name and signature from constant pool
-    c = (ConstantUtf8)cpool.getConstant(signatureIndex, 
-                                               Constants.CONSTANT_Utf8);
-    signature = c.getBytes();
-
-    c = (ConstantUtf8)cpool.getConstant(nameIndex, Constants.CONSTANT_Utf8);
-    name = c.getBytes();
-
-    signature = Utility.methodSignatureToString(signature, name, access, true,
-                                               getLocalVariableTable());
-    buf = new StringBuffer(signature);
-
-    for(int i=0; i < attributes.length; i++) {
-      Attribute a = attributes[i];
-      if(!((a instanceof Code) || (a instanceof ExceptionTable))) buf.append(" [" + a.toString() + "]");
-    }
-
-    ExceptionTable e = getExceptionTable();
-    if(e != null) {
-      String str = e.toString();
-      if(!str.equals(""))
-       buf.append("\n\t\tthrows " + str);
-    }
-    return buf.toString();
-  }
-
-  /**
-   * Return a deep copy of this method
-   */
-  public final Method copy(ConstantPool constant_pool) {
-    return (Method)copy_(constant_pool);
-  }
-
-  /**
-   * @return return type of method
-   */
-  public Type getReturnType() {
-    return Type.getReturnType(getSignature());
-  }
-
-  /**
-   * @return array of method argument types
-   */
-  public Type[] getArgumentTypes() {
-    return Type.getArgumentTypes(getSignature());
-  }
-  
-  private void ensureParameterAnnotationsUnpacked() {
-       if (!parameterAnnotationsOutOfDate) return;
-       parameterAnnotationsOutOfDate = false;
-
-       int parameterCount = getArgumentTypes().length;
-       if (parameterCount == 0) {
-               unpackedParameterAnnotations = NO_PARAMETER_ANNOTATIONS;
-               return;
+
+       public static final AnnotationGen[][] NO_PARAMETER_ANNOTATIONS = new AnnotationGen[][] {};
+       public static final AnnotationGen[] NO_ANNOTATIONS = new AnnotationGen[] {};
+
+       public static final Method[] NoMethods = new Method[0];
+
+       private boolean parameterAnnotationsOutOfDate = true;
+       private AnnotationGen[][] unpackedParameterAnnotations;
+
+       private Method() {
+               parameterAnnotationsOutOfDate = true;
        }
 
-       RuntimeVisibleParameterAnnotations parameterAnnotationsVis = null;
-    RuntimeInvisibleParameterAnnotations 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;
-                       }
+       /**
+        * Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a physical
+        * copy.
+        */
+       public Method(Method c) {
+               super(c);
+               parameterAnnotationsOutOfDate = true;
+       }
+
+       Method(DataInputStream file, ConstantPool constant_pool) throws IOException {
+               super(file, constant_pool);
+       }
+
+       public Method(int access_flags, int name_index, int signature_index, Attribute[] attributes, ConstantPool constant_pool) {
+               super(access_flags, name_index, signature_index, attributes, constant_pool);
+               parameterAnnotationsOutOfDate = true;
+       }
+
+       public void accept(ClassVisitor v) {
+               v.visitMethod(this);
+       }
+
+       // CUSTARD mutable or not?
+       @Override
+       public void setAttributes(Attribute[] attributes) {
+               parameterAnnotationsOutOfDate = true;
+               super.setAttributes(attributes);
+       }
+
+       /**
+        * @return Code attribute of method, if any
+        */
+       public final Code getCode() {
+               return AttributeUtils.getCodeAttribute(attributes);
+       }
+
+       public final ExceptionTable getExceptionTable() {
+               return AttributeUtils.getExceptionTableAttribute(attributes);
+       }
+
+       /**
+        * Return LocalVariableTable of code attribute if any (the call is forwarded to the Code attribute)
+        */
+       public final LocalVariableTable getLocalVariableTable() {
+               Code code = getCode();
+               if (code != null)
+                       return code.getLocalVariableTable();
+               return null;
+       }
+
+       /**
+        * Return LineNumberTable of code attribute if any (the call is forwarded to the Code attribute)
+        */
+       public final LineNumberTable getLineNumberTable() {
+               Code code = getCode();
+               if (code != null)
+                       return code.getLineNumberTable();
+               return null;
+       }
+
+       /**
+        * Return string representation close to declaration format, eg: 'public static void main(String[] args) throws IOException'
+        */
+       @Override
+       public final String toString() {
+               ConstantUtf8 c;
+               String name, signature, access; // Short cuts to constant pool
+               StringBuffer buf;
+
+               access = Utility.accessToString(modifiers);
+
+               // Get name and signature from constant pool
+               c = (ConstantUtf8) cpool.getConstant(signatureIndex, Constants.CONSTANT_Utf8);
+               signature = c.getValue();
+
+               c = (ConstantUtf8) cpool.getConstant(nameIndex, Constants.CONSTANT_Utf8);
+               name = c.getValue();
+
+               signature = Utility.methodSignatureToString(signature, name, access, true, getLocalVariableTable());
+               buf = new StringBuffer(signature);
+
+               for (int i = 0; i < attributes.length; i++) {
+                       Attribute a = attributes[i];
+                       if (!((a instanceof Code) || (a instanceof ExceptionTable)))
+                               buf.append(" [" + a.toString() + "]");
                }
-       
-       boolean foundSome = false;
-       // Build a list of annotation arrays, one per argument
-       if (parameterAnnotationsInvis!=null || parameterAnnotationsVis!=null) {
-               List<AnnotationGen[]> annotationsForEachParameter = new ArrayList<AnnotationGen[]>();
-               AnnotationGen[] visibleOnes = null;
-               AnnotationGen[] invisibleOnes = null;
-               for (int i=0; i<parameterCount; i++) {
-                       int count = 0;
-                       visibleOnes = new AnnotationGen[0];
-                       invisibleOnes = new AnnotationGen[0];
-                       if (parameterAnnotationsVis!=null) {
-                               visibleOnes = parameterAnnotationsVis.getAnnotationsOnParameter(i);
-                               count+=visibleOnes.length;
-                       }
-                       if (parameterAnnotationsInvis!=null){
-                               invisibleOnes = parameterAnnotationsInvis.getAnnotationsOnParameter(i);
-                               count+=invisibleOnes.length;
-                       }
-       
-                       AnnotationGen[] complete = NO_ANNOTATIONS;
-                       if (count!=0) {
-                               complete = new AnnotationGen[visibleOnes.length+invisibleOnes.length];
-                               System.arraycopy(visibleOnes,0,complete,0,visibleOnes.length);
-                               System.arraycopy(invisibleOnes,0,complete,visibleOnes.length,invisibleOnes.length);
-                               foundSome = true;
-                       }
-                       annotationsForEachParameter.add(complete);
+
+               ExceptionTable e = getExceptionTable();
+               if (e != null) {
+                       String str = e.toString();
+                       if (!str.equals(""))
+                               buf.append("\n\t\tthrows " + str);
                }
-               if (foundSome) {
-                       unpackedParameterAnnotations = annotationsForEachParameter.toArray(new AnnotationGen[][]{});
+
+               return buf.toString();
+       }
+
+       /**
+        * Return a deep copy of this method
+        */
+       public final Method copy(ConstantPool constant_pool) {
+               return (Method) copy_(constant_pool);
+       }
+
+       /**
+        * @return return type of method
+        */
+       public Type getReturnType() {
+               return Type.getReturnType(getSignature());
+       }
+
+       /**
+        * @return array of method argument types
+        */
+       public Type[] getArgumentTypes() {
+               return Type.getArgumentTypes(getSignature());
+       }
+
+       private void ensureParameterAnnotationsUnpacked() {
+               if (!parameterAnnotationsOutOfDate)
+                       return;
+               parameterAnnotationsOutOfDate = false;
+
+               int parameterCount = getArgumentTypes().length;
+               if (parameterCount == 0) {
+                       unpackedParameterAnnotations = NO_PARAMETER_ANNOTATIONS;
                        return;
                }
+
+               RuntimeVisibleParameterAnnotations parameterAnnotationsVis = null;
+               RuntimeInvisibleParameterAnnotations 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;
+                       }
+               }
+
+               boolean foundSome = false;
+               // Build a list of annotation arrays, one per argument
+               if (parameterAnnotationsInvis != null || parameterAnnotationsVis != null) {
+                       List<AnnotationGen[]> annotationsForEachParameter = new ArrayList<AnnotationGen[]>();
+                       AnnotationGen[] visibleOnes = null;
+                       AnnotationGen[] invisibleOnes = null;
+                       for (int i = 0; i < parameterCount; i++) {
+                               int count = 0;
+                               visibleOnes = new AnnotationGen[0];
+                               invisibleOnes = new AnnotationGen[0];
+                               if (parameterAnnotationsVis != null) {
+                                       visibleOnes = parameterAnnotationsVis.getAnnotationsOnParameter(i);
+                                       count += visibleOnes.length;
+                               }
+                               if (parameterAnnotationsInvis != null) {
+                                       invisibleOnes = parameterAnnotationsInvis.getAnnotationsOnParameter(i);
+                                       count += invisibleOnes.length;
+                               }
+
+                               AnnotationGen[] complete = NO_ANNOTATIONS;
+                               if (count != 0) {
+                                       complete = new AnnotationGen[visibleOnes.length + invisibleOnes.length];
+                                       System.arraycopy(visibleOnes, 0, complete, 0, visibleOnes.length);
+                                       System.arraycopy(invisibleOnes, 0, complete, visibleOnes.length, invisibleOnes.length);
+                                       foundSome = true;
+                               }
+                               annotationsForEachParameter.add(complete);
+                       }
+                       if (foundSome) {
+                               unpackedParameterAnnotations = annotationsForEachParameter.toArray(new AnnotationGen[][] {});
+                               return;
+                       }
+               }
+               unpackedParameterAnnotations = NO_PARAMETER_ANNOTATIONS;
+       }
+
+       public AnnotationGen[] getAnnotationsOnParameter(int i) {
+               ensureParameterAnnotationsUnpacked();
+               if (unpackedParameterAnnotations == NO_PARAMETER_ANNOTATIONS)
+                       return NO_ANNOTATIONS;
+               return unpackedParameterAnnotations[i];
        }
-       unpackedParameterAnnotations=NO_PARAMETER_ANNOTATIONS;
-  }
-  
-  public AnnotationGen[] getAnnotationsOnParameter(int i) {
-         ensureParameterAnnotationsUnpacked();
-         if (unpackedParameterAnnotations==NO_PARAMETER_ANNOTATIONS) return NO_ANNOTATIONS;
-         return unpackedParameterAnnotations[i];
-  }
-    
-  public AnnotationGen[][] getParameterAnnotations() {
-         ensureParameterAnnotationsUnpacked();
-         return unpackedParameterAnnotations;
-  }
-    
+
+       public AnnotationGen[][] getParameterAnnotations() {
+               ensureParameterAnnotationsUnpacked();
+               return unpackedParameterAnnotations;
+       }
+
 }
index b627822c36d002fe237ff5ece3bb67ea03c93afa..b1991afef263b283cb6b6ba0596e811ceeb87c8d 100644 (file)
@@ -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.9 2008/10/20 18:31:01 aclement Exp $
+ * @version $Id: Signature.java,v 1.10 2009/09/10 15:35:04 aclement Exp $
  * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
  * @see Attribute
  */
@@ -113,6 +113,7 @@ public final class Signature extends Attribute {
         * 
         * @param v Visitor object
         */
+       @Override
        public void accept(ClassVisitor v) {
                System.err.println("Visiting non-standard Signature object");
                v.visitSignature(this);
@@ -124,6 +125,7 @@ public final class Signature extends Attribute {
         * @param file Output file stream
         * @throws IOException
         */
+       @Override
        public final void dump(DataOutputStream file) throws IOException {
                super.dump(file);
                file.writeShort(signature_index);
@@ -147,8 +149,8 @@ public final class Signature extends Attribute {
         * @return GJ signature.
         */
        public final String getSignature() {
-               ConstantUtf8 c = (ConstantUtf8) constantPool.getConstant(signature_index, Constants.CONSTANT_Utf8);
-               return c.getBytes();
+               ConstantUtf8 c = (ConstantUtf8) cpool.getConstant(signature_index, Constants.CONSTANT_Utf8);
+               return c.getValue();
        }
 
        /**
@@ -290,6 +292,7 @@ public final class Signature extends Attribute {
        /**
         * @return String representation
         */
+       @Override
        public final String toString() {
                String s = getSignature();
 
@@ -299,6 +302,7 @@ public final class Signature extends Attribute {
        /**
         * @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/SimpleConstant.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/SimpleConstant.java
new file mode 100644 (file)
index 0000000..84ff40c
--- /dev/null
@@ -0,0 +1,58 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation.  All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ *    "Apache BCEL" must not be used to endorse or promote products
+ *    derived from this software without prior written permission. For
+ *    written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    "Apache BCEL", nor may "Apache" appear in their name, without
+ *    prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+package org.aspectj.apache.bcel.classfile;
+
+public interface SimpleConstant {
+       public String getStringValue();
+}
index 9858be71dbc236671425e110f878c79aa3156c8c..6832f86cd87b566aff1e76db4f87582c6e6ef887 100644 (file)
@@ -54,120 +54,116 @@ 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 represents a reference
- * to the source file of this class.  At most one SourceFile 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.3 2008/05/28 23:53:01 aclement Exp $
- * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
- * @see     Attribute
+ * This class is derived from <em>Attribute</em> and represents a reference to the source file of this class. At most one SourceFile
+ * 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 $
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @see Attribute
  */
 public final class SourceFile extends Attribute {
-  private int sourcefile_index;
+       private int sourcefile_index;
 
-  /**
-   * Initialize from another object. Note that both objects use the same
-   * references (shallow copy). Use clone() for a physical copy.
-   */
-  public SourceFile(SourceFile c) {
-    this(c.getNameIndex(), c.getLength(), c.getSourceFileIndex(),
-        c.getConstantPool());
-  }
+       /**
+        * Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a physical
+        * copy.
+        */
+       public SourceFile(SourceFile c) {
+               this(c.getNameIndex(), c.getLength(), c.getSourceFileIndex(), c.getConstantPool());
+       }
 
-  /**
-   * 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
-   */
-  SourceFile(int name_index, int length, DataInputStream file,
-            ConstantPool constant_pool) throws IOException
-  {
-    this(name_index, length, file.readUnsignedShort(), constant_pool);
-  }
+       /**
+        * 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
+        */
+       SourceFile(int name_index, int length, DataInputStream file, ConstantPool constant_pool) throws IOException {
+               this(name_index, length, file.readUnsignedShort(), constant_pool);
+       }
 
-  /**
-   * @param name_index Index in constant pool to CONSTANT_Utf8, which
-   * should represent the string "SourceFile".
-   * @param length Content length in bytes, the value should be 2.
-   * @param constant_pool The constant pool that this attribute is
-   * associated with.
-   * @param sourcefile_index Index in constant pool to CONSTANT_Utf8.  This
-   * string will be interpreted as the name of the file from which this
-   * class was compiled.  It will not be interpreted as indicating the name
-   * of the directory contqining the file or an absolute path; this
-   * information has to be supplied the consumer of this attribute - in
-   * many cases, the JVM.
-   */
-  public SourceFile(int name_index, int length, int sourcefile_index,
-                   ConstantPool constant_pool)
-  {
-    super(Constants.ATTR_SOURCE_FILE, name_index, length, constant_pool);
-    this.sourcefile_index = sourcefile_index;
-  }
+       /**
+        * @param name_index Index in constant pool to CONSTANT_Utf8, which should represent the string "SourceFile".
+        * @param length Content length in bytes, the value should be 2.
+        * @param constant_pool The constant pool that this attribute is associated with.
+        * @param sourcefile_index Index in constant pool to CONSTANT_Utf8. This string will be interpreted as the name of the file from
+        *        which this class was compiled. It will not be interpreted as indicating the name of the directory contqining the file
+        *        or an absolute path; this information has to be supplied the consumer of this attribute - in many cases, the JVM.
+        */
+       public SourceFile(int name_index, int length, int sourcefile_index, ConstantPool constant_pool) {
+               super(Constants.ATTR_SOURCE_FILE, name_index, length, constant_pool);
+               this.sourcefile_index = sourcefile_index;
+       }
 
-  /**
-   * 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.visitSourceFile(this);
-  }
+       /**
+        * 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.visitSourceFile(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(sourcefile_index);
-  }    
+       /**
+        * 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(sourcefile_index);
+       }
 
-  /**
-   * @return Index in constant pool of source file name.
-   */  
-  public final int getSourceFileIndex() { return sourcefile_index; }    
+       /**
+        * @return Index in constant pool of source file name.
+        */
+       public final int getSourceFileIndex() {
+               return sourcefile_index;
+       }
 
-  /**
-   * @param sourcefile_index.
-   */
-  public final void setSourceFileIndex(int sourcefile_index) {
-    this.sourcefile_index = sourcefile_index;
-  }    
+       /**
+        * @param sourcefile_index.
+        */
+       public final void setSourceFileIndex(int sourcefile_index) {
+               this.sourcefile_index = sourcefile_index;
+       }
 
-  /**
-   * @return Source file name.
-   */ 
-  public final String getSourceFileName() {
-    ConstantUtf8 c = (ConstantUtf8)constantPool.getConstant(sourcefile_index, 
-                                                            Constants.CONSTANT_Utf8);
-    return c.getBytes();
-  }
+       /**
+        * @return Source file name.
+        */
+       public final String getSourceFileName() {
+               ConstantUtf8 c = (ConstantUtf8) cpool.getConstant(sourcefile_index, Constants.CONSTANT_Utf8);
+               return c.getValue();
+       }
 
-  /**
-   * @return String representation
-   */ 
-  public final String toString() {
-    return "SourceFile(" + getSourceFileName() + ")";
-  }    
+       /**
+        * @return String representation
+        */
+       @Override
+       public final String toString() {
+               return "SourceFile(" + getSourceFileName() + ")";
+       }
 
-  /**
-   * @return deep copy of this attribute
-   */
-  public Attribute copy(ConstantPool constant_pool) {
-    return (SourceFile)clone();
-  }
+       /**
+        * @return deep copy of this attribute
+        */
+       @Override
+       public Attribute copy(ConstantPool constant_pool) {
+               return (SourceFile) clone();
+       }
 }
index 88caa3d558eac0abb67c353a29d181ca76e14e67..0ddf0e88f585eca30f90907be4cd1d5259d2c893 100644 (file)
@@ -66,7 +66,7 @@ import  java.io.*;
  * within the Code attribute of a method. See CLDC specification
  * §5.3.1.2
  *
- * @version $Id: StackMap.java,v 1.4 2008/08/26 15:01:37 aclement Exp $
+ * @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
@@ -166,7 +166,7 @@ public final class StackMap extends Attribute {
     for(int i=0; i < map_length; i++)
       c.map[i] = map[i].copy();
 
-    c.constantPool = constant_pool;
+    c.cpool = constant_pool;
     return c;
   }
 
index 91f53b40d523529cf858aeec6988e117900c3b5f..e3eebe36b22de2587f21164c3778e6ba984ac287 100644 (file)
@@ -67,7 +67,7 @@ import  java.io.*;
  * is intended to be instantiated from the
  * <em>Attribute.readAttribute()</em> method.
  *
- * @version $Id: Synthetic.java,v 1.3 2008/05/28 23:53:02 aclement Exp $
+ * @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
  */
@@ -178,7 +178,7 @@ public final class Synthetic extends Attribute {
     if(bytes != null)
       c.bytes = (byte[])bytes.clone();
 
-    c.constantPool = constant_pool;
+    c.cpool = constant_pool;
     return c;
   }
 }
index 279b1511df881571acfaccb5e6fac9b1c0f70c98..c4f86441b95f29ff190eface04c6a3358fbd7fe4 100644 (file)
@@ -54,159 +54,162 @@ package org.aspectj.apache.bcel.classfile;
  * <http://www.apache.org/>.
  */
 
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
 import org.aspectj.apache.bcel.Constants;
-import java.io.*;
 
 /**
- * This class represents a reference to an unknown (i.e.,
- * application-specific) attribute of a class.  It is instantiated from the
- * <em>Attribute.readAttribute()</em> method.  Applications that need to
- * read in application-specific attributes should create an <a
- * href="./AttributeReader.html">AttributeReader</a> implementation and
- * attach it via <a
+ * This class represents a reference to an unknown (i.e., application-specific) attribute of a class. It is instantiated from the
+ * <em>Attribute.readAttribute()</em> method. Applications that need to read in application-specific attributes should create an <a
+ * href="./AttributeReader.html">AttributeReader</a> implementation and attach it via <a
  * href="./Attribute.html#addAttributeReader(java.lang.String,
  * org.aspectj.apache.bcel.classfile.AttributeReader)">Attribute.addAttributeReader</a>.
-
- *
- * @version $Id: Unknown.java,v 1.4 2008/05/28 23:53:01 aclement Exp $
+ * 
+ * 
+ * @version $Id: Unknown.java,v 1.5 2009/09/10 15:35:05 aclement Exp $
  * @see org.aspectj.apache.bcel.classfile.Attribute
- * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
  */
 public final class Unknown extends Attribute {
-  private byte[] bytes;
-  private String name;
-
-  // evil static - removed by Andy C - no apparent users (4 Mar 06)
-//  private static HashMap unknown_attributes = new HashMap();
-
-  /** @return array of unknown attributes, but just one for each kind.
-   */
-//  static Unknown[] getUnknownAttributes() {
-//    Unknown[] unknowns = new Unknown[unknown_attributes.size()];
-//    Iterator  entries  = unknown_attributes.values().iterator();
-//
-//    for(int i=0; entries.hasNext(); i++)
-//      unknowns[i] = (Unknown)entries.next();
-//
-//    unknown_attributes.clear();
-//    return unknowns;
-//  }
-
-  /**
-   * Initialize from another object. Note that both objects use the same
-   * references (shallow copy). Use clone() for a physical copy.
-   */
-  public Unknown(Unknown c) {
-    this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool());
-  }
-
-  /**
-   * Create a non-standard attribute.
-   *
-   * @param name_index Index in constant pool
-   * @param length Content length in bytes
-   * @param bytes Attribute contents
-   * @param constant_pool Array of constants
-   */
-  public Unknown(int name_index, int length, byte[] bytes,
-                ConstantPool constant_pool)
-  {
-    super(Constants.ATTR_UNKNOWN, name_index, length, constant_pool);
-    this.bytes = bytes;
-
-    name = ((ConstantUtf8)constant_pool.getConstant(name_index,
-                                                   Constants.CONSTANT_Utf8)).getBytes();
-//    unknown_attributes.put(name, this);
-  }
-
-  /**
-   * 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
-   */
-  Unknown(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);
-    }
-  }    
-
-  /**
-   * 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.visitUnknown(this);
-  }    
-  /**
-   * Dump unknown bytes to file stream.
-   *
-   * @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; }    
-
-  /**
-   * @return name of attribute.
-   */  
-  public String getName() { return name; }    
-
-  /**
-   * @param bytes.
-   */
-  public final void setBytes(byte[] bytes) {
-    this.bytes = bytes;
-  }
-
-  /**
-   * @return String representation.
-   */ 
-  public final String toString() {
-    if(length == 0 || bytes == null)
-      return "(Unknown attribute " + name + ")";
-
-    String hex;
-    if(length > 10) {
-      byte[] tmp = new byte[10];
-      System.arraycopy(bytes, 0, tmp, 0, 10);
-      hex = Utility.toHexString(tmp) + "... (truncated)";
-    }
-    else
-      hex = Utility.toHexString(bytes);
-
-    return "(Unknown attribute " + name + ": " + hex + ")";
-  }
-
-  /**
-   * @return deep copy of this attribute
-   */
-  public Attribute copy(ConstantPool constant_pool) {
-    Unknown c = (Unknown)clone();
-
-    if(bytes != null)
-      c.bytes = (byte[])bytes.clone();
-
-    c.constantPool = constant_pool;
-    return c;
-  }
+       private byte[] bytes;
+       private String name;
+
+       // evil static - removed by Andy C - no apparent users (4 Mar 06)
+       // private static HashMap unknown_attributes = new HashMap();
+
+       /**
+        * @return array of unknown attributes, but just one for each kind.
+        */
+       // static Unknown[] getUnknownAttributes() {
+       // Unknown[] unknowns = new Unknown[unknown_attributes.size()];
+       // Iterator entries = unknown_attributes.values().iterator();
+       //
+       // for(int i=0; entries.hasNext(); i++)
+       // unknowns[i] = (Unknown)entries.next();
+       //
+       // unknown_attributes.clear();
+       // return unknowns;
+       // }
+       /**
+        * Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a physical
+        * copy.
+        */
+       public Unknown(Unknown c) {
+               this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool());
+       }
+
+       /**
+        * Create a non-standard attribute.
+        * 
+        * @param name_index Index in constant pool
+        * @param length Content length in bytes
+        * @param bytes Attribute contents
+        * @param constant_pool Array of constants
+        */
+       public Unknown(int name_index, int length, byte[] bytes, ConstantPool constant_pool) {
+               super(Constants.ATTR_UNKNOWN, name_index, length, constant_pool);
+               this.bytes = bytes;
+
+               name = ((ConstantUtf8) constant_pool.getConstant(name_index, Constants.CONSTANT_Utf8)).getValue();
+               // unknown_attributes.put(name, this);
+       }
+
+       /**
+        * 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
+        */
+       Unknown(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);
+               }
+       }
+
+       /**
+        * 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.visitUnknown(this);
+       }
+
+       /**
+        * Dump unknown bytes to file stream.
+        * 
+        * @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;
+       }
+
+       /**
+        * @return name of attribute.
+        */
+       @Override
+       public String getName() {
+               return name;
+       }
+
+       /**
+        * @param bytes.
+        */
+       public final void setBytes(byte[] bytes) {
+               this.bytes = bytes;
+       }
+
+       /**
+        * @return String representation.
+        */
+       @Override
+       public final String toString() {
+               if (length == 0 || bytes == null)
+                       return "(Unknown attribute " + name + ")";
+
+               String hex;
+               if (length > 10) {
+                       byte[] tmp = new byte[10];
+                       System.arraycopy(bytes, 0, tmp, 0, 10);
+                       hex = Utility.toHexString(tmp) + "... (truncated)";
+               } else
+                       hex = Utility.toHexString(bytes);
+
+               return "(Unknown attribute " + name + ": " + hex + ")";
+       }
+
+       /**
+        * @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;
+       }
 }
index 4f0a00d544ce3d28bf81ac443614617182b7368d..9efdeb7b934879d3682a7e21a9867da501dee352 100644 (file)
@@ -107,7 +107,7 @@ public class AnnotationGen {
 
        public String getTypeSignature() {
                ConstantUtf8 utf8 = (ConstantUtf8) cpool.getConstant(typeIndex);
-               return utf8.getBytes();
+               return utf8.getValue();
        }
 
        public String getTypeName() {
index 333030ad7f77d20d152f3192313c92b8f6e888a8..82c1559b0c5f0be50d7b14ec32746e0332a71603 100644 (file)
@@ -15,65 +15,65 @@ package org.aspectj.apache.bcel.classfile.annotation;
 import java.io.DataOutputStream;
 import java.io.IOException;
 
-import org.aspectj.apache.bcel.classfile.ConstantUtf8;
 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 ClassElementValueGen extends ElementValueGen {    
-       
        // 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);
-       this.idx = typeIdx;
-    }
-    
-    public ClassElementValueGen(ObjectType t,ConstantPool cpool) {
-       super(ElementValueGen.CLASS,cpool);
-       //this.idx = cpool.addClass(t);
-       idx = cpool.addUtf8(t.getSignature());
-    }
-       
+
+       protected ClassElementValueGen(int typeIdx, ConstantPool cpool) {
+               super(ElementValueGen.CLASS, cpool);
+               this.idx = typeIdx;
+       }
+
+       public ClassElementValueGen(ObjectType t, ConstantPool cpool) {
+               super(ElementValueGen.CLASS, cpool);
+               // this.idx = cpool.addClass(t);
+               idx = cpool.addUtf8(t.getSignature());
+       }
+
        /**
         * Return immutable variant of this ClassElementValueGen
         */
-//     public ElementValueGen getElementValue() {
-//             return new ClassElementValueGen(type,idx,cpGen);
-//     }
-    
-       public ClassElementValueGen(ClassElementValueGen value, ConstantPool cpool,boolean copyPoolEntries) {
-               super(CLASS,cpool);
+       // public ElementValueGen getElementValue() {
+       // return new ClassElementValueGen(type,idx,cpGen);
+       // }
+       public ClassElementValueGen(ClassElementValueGen value, ConstantPool cpool, boolean copyPoolEntries) {
+               super(CLASS, cpool);
                if (copyPoolEntries) {
-                       //idx = cpool.addClass(value.getClassString());
+                       // idx = cpool.addClass(value.getClassString());
                        idx = cpool.addUtf8(value.getClassString());
-               } else {        
+               } else {
                        idx = value.getIndex();
-                       
+
                }
        }
 
        public int getIndex() {
-       return idx;
-    }
-     
-    public String getClassString() {
-       ConstantUtf8 cu8 = (ConstantUtf8)getConstantPool().getConstant(idx);
-       return cu8.getBytes();
-//             ConstantClass c = (ConstantClass)getConstantPool().getConstant(idx);
-//             ConstantUtf8 utf8 = (ConstantUtf8)getConstantPool().getConstant(c.getNameIndex());
-//             return utf8.getBytes();
-    }
-    
-    public String stringifyValue() {
-       return getClassString();
-    }
-    
-    public void dump(DataOutputStream dos) throws IOException {
-       dos.writeByte(type); // u1 kind of value
-       dos.writeShort(idx);
-    }
+               return idx;
+       }
+
+       public String getClassString() {
+               ConstantUtf8 cu8 = (ConstantUtf8) getConstantPool().getConstant(idx);
+               return cu8.getValue();
+               // ConstantClass c = (ConstantClass)getConstantPool().getConstant(idx);
+               // ConstantUtf8 utf8 = (ConstantUtf8)getConstantPool().getConstant(c.getNameIndex());
+               // return utf8.getBytes();
+       }
+
+       @Override
+       public String stringifyValue() {
+               return getClassString();
+       }
+
+       @Override
+       public void dump(DataOutputStream dos) throws IOException {
+               dos.writeByte(type); // u1 kind of value
+               dos.writeShort(idx);
+       }
+
 }
index 4996051d7cc6ae6506ee338df02bbc6b50f4ff0b..c186fb277154ffb4dbf8b1e6df0952709bc6bf10 100644 (file)
@@ -59,7 +59,7 @@ public class ElementNameValuePairGen {
        }
 
        public final String getNameString() {
-               return cpool.getConstantUtf8(nameIdx).getBytes();
+               return cpool.getConstantUtf8(nameIdx).getValue();
        }
 
        public final ElementValueGen getValue() {
index 1f3e796df960afede7adad1bf1f7735ed5d18b29..c0198d240f063fac0debbbd3ce38f3cf05b65e64 100644 (file)
@@ -16,91 +16,94 @@ import java.io.DataOutputStream;
 import java.io.IOException;
 
 import org.aspectj.apache.bcel.Constants;
-import org.aspectj.apache.bcel.classfile.ConstantUtf8;
 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 {
-       
+
        // For enum types, these two indices point to the type and value
        private int typeIdx;
        private int valueIdx;
-       
+
        /**
-        * 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
+        * 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);
-       if (type != ENUM_CONSTANT) 
-               throw new RuntimeException("Only element values of type enum can be built with this ctor");
-       this.typeIdx = typeIdx;
-       this.valueIdx= valueIdx;
-    }
-       
-//     /**
-//     * Return immutable variant of this EnumElementValue
-//     */
-//     public ElementValueGen getElementValue() {
-//             System.err.println("Duplicating value: "+getEnumTypeString()+":"+getEnumValueString());
-//             return new EnumElementValueGen(type,typeIdx,valueIdx,cpGen);
-//     }
-    
-    public EnumElementValueGen(ObjectType t,String value,ConstantPool cpool) {
-       super(ElementValueGen.ENUM_CONSTANT,cpool);
-       typeIdx = cpool.addUtf8(t.getSignature());// was addClass(t);
-       valueIdx= cpool.addUtf8(value);// was addString(value);
-    }
+       protected EnumElementValueGen(int typeIdx, int valueIdx, ConstantPool cpool) {
+               super(ElementValueGen.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;
+               this.valueIdx = valueIdx;
+       }
+
+       // /**
+       // * Return immutable variant of this EnumElementValue
+       // */
+       // public ElementValueGen getElementValue() {
+       // System.err.println("Duplicating value: "+getEnumTypeString()+":"+getEnumValueString());
+       // return new EnumElementValueGen(type,typeIdx,valueIdx,cpGen);
+       // }
+
+       public EnumElementValueGen(ObjectType t, String value, ConstantPool cpool) {
+               super(ElementValueGen.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) {
-               super(ENUM_CONSTANT,cpool);
+               super(ENUM_CONSTANT, cpool);
                if (copyPoolEntries) {
                        typeIdx = cpool.addUtf8(value.getEnumTypeString());// was addClass(value.getEnumTypeString());
                        valueIdx = cpool.addUtf8(value.getEnumValueString()); // was addString(value.getEnumValueString());
                } else {
-                       typeIdx  = value.getTypeIndex();
+                       typeIdx = value.getTypeIndex();
                        valueIdx = value.getValueIndex();
                }
        }
 
+       @Override
        public void dump(DataOutputStream dos) throws IOException {
-       dos.writeByte(type);      // u1 type of value (ENUM_CONSTANT == 'e')
-               dos.writeShort(typeIdx);  // u2
+               dos.writeByte(type); // u1 type of value (ENUM_CONSTANT == 'e')
+               dos.writeShort(typeIdx); // u2
                dos.writeShort(valueIdx); // u2
-    }
-    
-    /**
-     * return signature and value, something like Lp/Color;RED
-     */
-    public String stringifyValue() {
-       StringBuffer sb = new StringBuffer();
-       ConstantUtf8 cu8 = (ConstantUtf8)cpGen.getConstant(typeIdx,Constants.CONSTANT_Utf8);
-       sb.append(cu8.getBytes());
-       cu8 = (ConstantUtf8)cpGen.getConstant(valueIdx,Constants.CONSTANT_Utf8);
-       sb.append(cu8.getBytes());
-       return sb.toString();
-    }
-
-    
-    
-    // BCELBUG: Should we need to call utility.signatureToString() on the output here?
-    public String getEnumTypeString() {
-//             Constant cc = getConstantPool().getConstant(typeIdx);
-//     ConstantClass cu8 = (ConstantClass)getConstantPool().getConstant(typeIdx);              
-//     return ((ConstantUtf8)getConstantPool().getConstant(cu8.getNameIndex())).getBytes();
-               return ((ConstantUtf8)getConstantPool().getConstant(typeIdx)).getBytes();
+       }
+
+       /**
+        * return signature and value, something like Lp/Color;RED
+        */
+       @Override
+       public String stringifyValue() {
+               StringBuffer sb = new StringBuffer();
+               ConstantUtf8 cu8 = (ConstantUtf8) cpGen.getConstant(typeIdx, Constants.CONSTANT_Utf8);
+               sb.append(cu8.getValue());
+               cu8 = (ConstantUtf8) cpGen.getConstant(valueIdx, Constants.CONSTANT_Utf8);
+               sb.append(cu8.getValue());
+               return sb.toString();
+       }
+
+       // BCELBUG: Should we need to call utility.signatureToString() on the output here?
+       public String getEnumTypeString() {
+               // Constant cc = getConstantPool().getConstant(typeIdx);
+               // ConstantClass cu8 = (ConstantClass)getConstantPool().getConstant(typeIdx);
+               // return ((ConstantUtf8)getConstantPool().getConstant(cu8.getNameIndex())).getBytes();
+               return ((ConstantUtf8) getConstantPool().getConstant(typeIdx)).getValue();
                // return Utility.signatureToString(cu8.getBytes());
-    }
-    
+       }
+
        public String getEnumValueString() {
-               return ((ConstantUtf8)getConstantPool().getConstant(valueIdx)).getBytes();
-//             ConstantString cu8 = (ConstantString)getConstantPool().getConstant(valueIdx);
-//     return ((ConstantUtf8)getConstantPool().getConstant(cu8.getStringIndex())).getBytes();
+               return ((ConstantUtf8) getConstantPool().getConstant(valueIdx)).getValue();
+               // ConstantString cu8 = (ConstantString)getConstantPool().getConstant(valueIdx);
+               // return ((ConstantUtf8)getConstantPool().getConstant(cu8.getStringIndex())).getBytes();
+       }
+
+       public int getValueIndex() {
+               return valueIdx;
+       }
+
+       public int getTypeIndex() {
+               return typeIdx;
        }
-    
-    public int getValueIndex() { return valueIdx;}
-    public int getTypeIndex()  { return typeIdx; }
 
-   
 }
index 927e6d026706942287af4628e3134154d2a5ddea..b1276bab3b5db08d6b8f5f2601f44cca90d31bd0 100644 (file)
@@ -93,49 +93,49 @@ public class SimpleElementValueGen extends ElementValueGen {
                if (type != PRIMITIVE_BYTE)
                        throw new RuntimeException("Dont call getValueByte() on a non BYTE ElementValue");
                ConstantInteger c = (ConstantInteger) cpGen.getConstant(idx, Constants.CONSTANT_Integer);
-               return (byte) c.getBytes();
+               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);
-               return (char) c.getBytes();
+               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);
-               return j.getBytes();
+               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);
-               return f.getBytes();
+               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);
-               return d.getBytes();
+               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);
-               return (bo.getBytes() != 0);
+               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);
-               return (short) s.getBytes();
+               return (short) s.getIntValue();
        }
 
        /**
@@ -202,14 +202,14 @@ public class SimpleElementValueGen extends ElementValueGen {
                if (type != STRING)
                        throw new RuntimeException("Dont call getValueString() on a non STRING ElementValue");
                ConstantUtf8 c = (ConstantUtf8) cpGen.getConstant(idx);
-               return c.getBytes();
+               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);
-               return c.getBytes();
+               return c.getValue();
        }
 
        // Whatever kind of value it is, return it as a string
@@ -218,34 +218,34 @@ public class SimpleElementValueGen extends ElementValueGen {
                switch (type) {
                case PRIMITIVE_INT:
                        ConstantInteger c = (ConstantInteger) cpGen.getConstant(idx);
-                       return Integer.toString(c.getBytes());
+                       return Integer.toString(c.getValue());
                case PRIMITIVE_LONG:
                        ConstantLong j = (ConstantLong) cpGen.getConstant(idx);
-                       return Long.toString(j.getBytes());
+                       return Long.toString(j.getValue());
                case PRIMITIVE_DOUBLE:
                        ConstantDouble d = (ConstantDouble) cpGen.getConstant(idx);
-                       return Double.toString(d.getBytes());
+                       return d.getValue().toString();
                case PRIMITIVE_FLOAT:
                        ConstantFloat f = (ConstantFloat) cpGen.getConstant(idx);
-                       return Float.toString(f.getBytes());
+                       return Float.toString(f.getValue());
                case PRIMITIVE_SHORT:
                        ConstantInteger s = (ConstantInteger) cpGen.getConstant(idx);
-                       return Integer.toString(s.getBytes());
+                       return Integer.toString(s.getValue());
                case PRIMITIVE_BYTE:
                        ConstantInteger b = (ConstantInteger) cpGen.getConstant(idx);
-                       return Integer.toString(b.getBytes());
+                       return Integer.toString(b.getValue());
                case PRIMITIVE_CHAR:
                        ConstantInteger ch = (ConstantInteger) cpGen.getConstant(idx);
-                       return new Character((char) ch.getBytes()).toString();
+                       return new Character((char) ch.getIntValue()).toString();
                case PRIMITIVE_BOOLEAN:
                        ConstantInteger bo = (ConstantInteger) cpGen.getConstant(idx);
-                       if (bo.getBytes() == 0)
+                       if (bo.getValue() == 0)
                                return "false";
                        else
                                return "true";
                case STRING:
                        ConstantUtf8 cu8 = (ConstantUtf8) cpGen.getConstant(idx);
-                       return cu8.getBytes();
+                       return cu8.getValue();
 
                default:
                        throw new RuntimeException("SimpleElementValueGen class does not know how to stringify type " + type);
index 434ca757b3cc2aed575e0c26fd9c8563b99321e6..71f8157cd77d049249becc77c1037c69076a5f93 100644 (file)
@@ -59,76 +59,84 @@ import org.aspectj.apache.bcel.classfile.ConstantPool;
 import org.aspectj.apache.bcel.classfile.ConstantUtf8;
 
 /**
- * Super class for InvokeInstruction and FieldInstruction, since they have
- * some methods in common!
- *
- * @version $Id: FieldOrMethod.java,v 1.6 2008/05/28 23:52:57 aclement Exp $
- * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * Super class for InvokeInstruction and FieldInstruction, since they have some methods in common!
+ * 
+ * @version $Id: FieldOrMethod.java,v 1.7 2009/09/10 15:35:06 aclement Exp $
+ * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
  */
 public abstract class FieldOrMethod extends InstructionCP {
 
-//  private boolean dontKnowSignature=true;
-  private String signature;
-  
-//  private boolean dontKnowName =true;
-  private String name;
-  
-//  private boolean dontKnowClassname =true;
-  private String classname;
-  
-  /**
-   * @param index to constant pool
-   */
-  protected FieldOrMethod(short opcode, int index) {
-    super(opcode, index);
-  }
+       // private boolean dontKnowSignature=true;
+       private String signature;
+
+       // private boolean dontKnowName =true;
+       private String name;
+
+       // private boolean dontKnowClassname =true;
+       private String classname;
 
-  /** @return signature of referenced method/field.
-   */
-  public String getSignature(ConstantPool cp) {
-       if (signature==null) {
-           ConstantCP          cmr  = (ConstantCP)cp.getConstant(index);
-           ConstantNameAndType cnat = (ConstantNameAndType)cp.getConstant(cmr.getNameAndTypeIndex());
-       
-           signature = ((ConstantUtf8)cp.getConstant(cnat.getSignatureIndex())).getBytes();
-//         dontKnowSignature=false;
+       /**
+        * @param index to constant pool
+        */
+       protected FieldOrMethod(short opcode, int index) {
+               super(opcode, index);
        }
-       return signature;
-  }
 
-  /** @return name of referenced method/field.
-   */
-  public String getName(ConstantPool cp) {
-         if (name==null) {
-           ConstantCP          cmr  = (ConstantCP)cp.getConstant(index);
-           ConstantNameAndType cnat = (ConstantNameAndType)cp.getConstant(cmr.getNameAndTypeIndex());
-           name = ((ConstantUtf8)cp.getConstant(cnat.getNameIndex())).getBytes();
-//             dontKnowName = false;
-         }
-         return name;
-  }
+       /**
+        * @return signature of referenced method/field.
+        */
+       public String getSignature(ConstantPool cp) {
+               if (signature == null) {
+                       ConstantCP cmr = (ConstantCP) cp.getConstant(index);
+                       ConstantNameAndType cnat = (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex());
 
-  /** @return name of the referenced class/interface
-   */
-  public String getClassName(ConstantPool cp) {
-       if (classname==null) {
-           ConstantCP   cmr = (ConstantCP)cp.getConstant(index);
-           String str       = cp.getConstantString(cmr.getClassIndex(), CONSTANT_Class);
-           if (str.charAt(0)=='[') classname= str; else classname= str.replace('/', '.');
-//         dontKnowClassname = false;
+                       signature = ((ConstantUtf8) cp.getConstant(cnat.getSignatureIndex())).getValue();
+                       // dontKnowSignature=false;
+               }
+               return signature;
        }
-       return classname;
-  }
 
-  /** @return type of the referenced class/interface
-   */
-  public ObjectType getClassType(ConstantPool cpg) {
-    return new ObjectType(getClassName(cpg));
-  }
+       /**
+        * @return name of referenced method/field.
+        */
+       public String getName(ConstantPool cp) {
+               if (name == null) {
+                       ConstantCP cmr = (ConstantCP) cp.getConstant(index);
+                       ConstantNameAndType cnat = (ConstantNameAndType) cp.getConstant(cmr.getNameAndTypeIndex());
+                       name = ((ConstantUtf8) cp.getConstant(cnat.getNameIndex())).getValue();
+                       // dontKnowName = false;
+               }
+               return name;
+       }
 
-  /** @return type of the referenced class/interface
-   */
-  public ObjectType getLoadClassType(ConstantPool cpg) {
-    return getClassType(cpg);
-  }
+       /**
+        * @return name of the referenced class/interface
+        */
+       public String getClassName(ConstantPool cp) {
+               if (classname == null) {
+                       ConstantCP cmr = (ConstantCP) cp.getConstant(index);
+                       String str = cp.getConstantString(cmr.getClassIndex(), CONSTANT_Class);
+                       if (str.charAt(0) == '[')
+                               classname = str;
+                       else
+                               classname = str.replace('/', '.');
+                       // dontKnowClassname = false;
+               }
+               return classname;
+       }
+
+       /**
+        * @return type of the referenced class/interface
+        */
+       public ObjectType getClassType(ConstantPool cpg) {
+               return new ObjectType(getClassName(cpg));
+       }
+
+       /**
+        * @return type of the referenced class/interface
+        */
+       @Override
+       public ObjectType getLoadClassType(ConstantPool cpg) {
+               return getClassType(cpg);
+       }
 }
index 8c007142dd16d9415c57248ef285dde24bd4e4dc..d84f5246ad01af29299dd96adf3496d2aa5fa005 100644 (file)
@@ -73,7 +73,7 @@ import com.sun.org.apache.bcel.internal.generic.LDC;
  * @see LDC
  * @see INVOKEVIRTUAL
  * 
- * @version $Id: InstructionCP.java,v 1.3 2008/08/28 00:05:49 aclement Exp $
+ * @version $Id: InstructionCP.java,v 1.4 2009/09/10 15:35:06 aclement Exp $
  * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
  */
 public class InstructionCP extends Instruction {
@@ -84,6 +84,7 @@ public class InstructionCP extends Instruction {
                this.index = index;
        }
 
+       @Override
        public void dump(DataOutputStream out) throws IOException {
                if (opcode == LDC_W && index < 256) {
                        out.writeByte(LDC);
@@ -101,6 +102,7 @@ public class InstructionCP extends Instruction {
                }
        }
 
+       @Override
        public int getLength() {
                if (opcode == LDC_W && index < 256) {
                        return 2;
@@ -118,6 +120,7 @@ public class InstructionCP extends Instruction {
         * @param verbose long/short format switch
         * @return mnemonic for instruction
         */
+       @Override
        public String toString(boolean verbose) {
                return super.toString(verbose) + " " + index;
        }
@@ -139,10 +142,12 @@ public class InstructionCP extends Instruction {
        /**
         * @return index in constant pool referred by this instruction.
         */
+       @Override
        public final int getIndex() {
                return index;
        }
 
+       @Override
        public void setIndex(int index) {
                this.index = index;
                if (this.index > 255 && opcode == LDC) {
@@ -151,6 +156,7 @@ public class InstructionCP extends Instruction {
                }
        }
 
+       @Override
        public Type getType(ConstantPool cpg) {
                switch (cpg.getConstant(index).getTag()) {
                case CONSTANT_String:
@@ -179,6 +185,7 @@ public class InstructionCP extends Instruction {
                }
        }
 
+       @Override
        public Object getValue(ConstantPool cpg) {
                org.aspectj.apache.bcel.classfile.Constant c = cpg.getConstant(index);
 
@@ -186,25 +193,26 @@ public class InstructionCP extends Instruction {
                case org.aspectj.apache.bcel.Constants.CONSTANT_String:
                        int i = ((org.aspectj.apache.bcel.classfile.ConstantString) c).getStringIndex();
                        c = cpg.getConstant(i);
-                       return ((org.aspectj.apache.bcel.classfile.ConstantUtf8) c).getBytes();
+                       return ((org.aspectj.apache.bcel.classfile.ConstantUtf8) c).getValue();
 
                case org.aspectj.apache.bcel.Constants.CONSTANT_Float:
-                       return new Float(((org.aspectj.apache.bcel.classfile.ConstantFloat) c).getBytes());
+                       return new Float(((org.aspectj.apache.bcel.classfile.ConstantFloat) c).getValue());
 
                case org.aspectj.apache.bcel.Constants.CONSTANT_Integer:
-                       return new Integer(((org.aspectj.apache.bcel.classfile.ConstantInteger) c).getBytes());
+                       return new Integer(((org.aspectj.apache.bcel.classfile.ConstantInteger) c).getValue());
 
                        // from ldc2_w:
                case org.aspectj.apache.bcel.Constants.CONSTANT_Long:
-                       return new Long(((org.aspectj.apache.bcel.classfile.ConstantLong) c).getBytes());
+                       return new Long(((org.aspectj.apache.bcel.classfile.ConstantLong) c).getValue());
 
                case org.aspectj.apache.bcel.Constants.CONSTANT_Double:
-                       return new Double(((org.aspectj.apache.bcel.classfile.ConstantDouble) c).getBytes());
+                       return new Double(((org.aspectj.apache.bcel.classfile.ConstantDouble) c).getValue());
                default: // Never reached
                        throw new RuntimeException("Unknown or invalid constant type at " + index);
                }
        }
 
+       @Override
        public Class[] getExceptions() {
                return org.aspectj.apache.bcel.ExceptionConstants.EXCS_STRING_RESOLUTION;
        }
index bcf4403bbaac158a97fe79e01ac6ace327a8e1f3..a03c9b386cc3b84c73edeb84cb7cf9ec46914faa 100644 (file)
@@ -38,7 +38,7 @@ public class EnclosingMethodAttributeTest extends BcelTestCase {
                Attribute[] encMethodAttrs = findAttribute("EnclosingMethod", clazz);
                assertTrue("Expected 1 EnclosingMethod attribute but found " + encMethodAttrs.length, encMethodAttrs.length == 1);
                EnclosingMethod em = (EnclosingMethod) encMethodAttrs[0];
-               String enclosingClassName = em.getEnclosingClass().getConstantValue(pool);
+               String enclosingClassName = em.getEnclosingClass().getClassname(pool);
                String enclosingMethodName = em.getEnclosingMethod().getName(pool);
                assertTrue("Expected class name to be 'AttributeTestClassEM01' but was " + enclosingClassName, enclosingClassName
                                .equals("AttributeTestClassEM01"));
@@ -56,7 +56,7 @@ public class EnclosingMethodAttributeTest extends BcelTestCase {
                Attribute[] encMethodAttrs = findAttribute("EnclosingMethod", clazz);
                assertTrue("Expected 1 EnclosingMethod attribute but found " + encMethodAttrs.length, encMethodAttrs.length == 1);
                EnclosingMethod em = (EnclosingMethod) encMethodAttrs[0];
-               String enclosingClassName = em.getEnclosingClass().getConstantValue(pool);
+               String enclosingClassName = em.getEnclosingClass().getClassname(pool);
                assertTrue("The class is not within a method, so method_index should be null, but it is " + em.getEnclosingMethodIndex(),
                                em.getEnclosingMethodIndex() == 0);
                assertTrue("Expected class name to be 'AttributeTestClassEM02' but was " + enclosingClassName, enclosingClassName
@@ -82,7 +82,7 @@ public class EnclosingMethodAttributeTest extends BcelTestCase {
                SyntheticRepository repos2 = createRepos(".");
                JavaClass clazz2 = repos2.loadClass("AttributeTestClassEM02$1");
                EnclosingMethod em = (EnclosingMethod) encMethodAttrs[0];
-               String enclosingClassName = em.getEnclosingClass().getConstantValue(pool);
+               String enclosingClassName = em.getEnclosingClass().getClassname(pool);
                assertTrue("The class is not within a method, so method_index should be null, but it is " + em.getEnclosingMethodIndex(),
                                em.getEnclosingMethodIndex() == 0);
                assertTrue("Expected class name to be 'AttributeTestClassEM02' but was " + enclosingClassName, enclosingClassName
index f6b15dbb1b6dd83450ce63d6e8573619be2197b1..b02c351281d4487bce7eb8e6f18f1ab26820f85c 100644 (file)
@@ -105,199 +105,176 @@ import org.aspectj.apache.bcel.verifier.exc.ClassConstraintException;
 import org.aspectj.apache.bcel.verifier.exc.LocalVariableInfoInconsistentException;
 
 /**
- * This PassVerifier verifies a class file according to
- * pass 2 as described in The Java Virtual Machine
- * Specification, 2nd edition.
- * More detailed information is to be found at the do_verify()
- * method's documentation.
- *
- * @version $Id: Pass2Verifier.java,v 1.4 2009/09/09 19:56:20 aclement Exp $
+ * This PassVerifier verifies a class file according to pass 2 as described in The Java Virtual Machine Specification, 2nd edition.
+ * More detailed information is to be found at the do_verify() method's documentation.
+ * 
+ * @version $Id: Pass2Verifier.java,v 1.5 2009/09/10 15:35:05 aclement Exp $
  * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
  * @see #do_verify()
  */
-public final class Pass2Verifier extends PassVerifier implements Constants{
+public final class Pass2Verifier extends PassVerifier implements Constants {
 
        /**
-        * The LocalVariableInfo instances used by Pass3bVerifier.
-        * localVariablesInfos[i] denotes the information for the
-        * local variables of method number i in the
-        * JavaClass this verifier operates on.
+        * The LocalVariableInfo instances used by Pass3bVerifier. localVariablesInfos[i] denotes the information for the local
+        * variables of method number i in the JavaClass this verifier operates on.
         */
        private LocalVariablesInfo[] localVariablesInfos;
-       
+
        /** The Verifier that created this. */
        private Verifier myOwner;
 
        /**
         * Should only be instantiated by a Verifier.
-        *
+        * 
         * @see Verifier
         */
-       public Pass2Verifier(Verifier owner){
+       public Pass2Verifier(Verifier owner) {
                myOwner = owner;
        }
 
        /**
-        * Returns a LocalVariablesInfo object containing information
-        * about the usage of the local variables in the Code attribute
-        * of the said method or <B>null</B> if the class file this
-        * Pass2Verifier operates on could not be pass-2-verified correctly.
-        * The method number method_nr is the method you get using
-        * <B>Repository.lookupClass(myOwner.getClassname()).getMethods()[method_nr];</B>.
-        * You should not add own information. Leave that to JustIce.
+        * Returns a LocalVariablesInfo object containing information about the usage of the local variables in the Code attribute of
+        * the said method or <B>null</B> if the class file this Pass2Verifier operates on could not be pass-2-verified correctly. The
+        * method number method_nr is the method you get using
+        * <B>Repository.lookupClass(myOwner.getClassname()).getMethods()[method_nr];</B>. You should not add own information. Leave
+        * that to JustIce.
         */
-       public LocalVariablesInfo getLocalVariablesInfo(int method_nr){
-               if (this.verify() != VerificationResult.VR_OK) return null; // It's cached, don't worry.
-               if (method_nr < 0 || method_nr >= localVariablesInfos.length){
+       public LocalVariablesInfo getLocalVariablesInfo(int method_nr) {
+               if (this.verify() != VerificationResult.VR_OK)
+                       return null; // It's cached, don't worry.
+               if (method_nr < 0 || method_nr >= localVariablesInfos.length) {
                        throw new AssertionViolatedException("Method number out of range.");
                }
                return localVariablesInfos[method_nr];
        }
-       
+
        /**
-        * Pass 2 is the pass where static properties of the
-        * class file are checked without looking into "Code"
-        * arrays of methods.
-        * This verification pass is usually invoked when
-        * a class is resolved; and it may be possible that
-        * this verification pass has to load in other classes
-        * such as superclasses or implemented interfaces.
-        * Therefore, Pass 1 is run on them.<BR>
-        * Note that most referenced classes are <B>not</B> loaded
-        * in for verification or for an existance check by this
-        * pass; only the syntactical correctness of their names
-        * and descriptors (a.k.a. signatures) is checked.<BR>
-        * Very few checks that conceptually belong here
-        * are delayed until pass 3a in JustIce. JustIce does
-        * not only check for syntactical correctness but also
-        * for semantical sanity - therefore it needs access to
-        * the "Code" array of methods in a few cases. Please
-        * see the pass 3a documentation, too.
-        *
+        * Pass 2 is the pass where static properties of the class file are checked without looking into "Code" arrays of methods. This
+        * verification pass is usually invoked when a class is resolved; and it may be possible that this verification pass has to load
+        * in other classes such as superclasses or implemented interfaces. Therefore, Pass 1 is run on them.<BR>
+        * Note that most referenced classes are <B>not</B> loaded in for verification or for an existance check by this pass; only the
+        * syntactical correctness of their names and descriptors (a.k.a. signatures) is checked.<BR>
+        * Very few checks that conceptually belong here are delayed until pass 3a in JustIce. JustIce does not only check for
+        * syntactical correctness but also for semantical sanity - therefore it needs access to the "Code" array of methods in a few
+        * cases. Please see the pass 3a documentation, too.
+        * 
         * @see org.aspectj.apache.bcel.verifier.statics.Pass3aVerifier
         */
-       public VerificationResult do_verify(){
+       @Override
+       public VerificationResult do_verify() {
                VerificationResult vr1 = myOwner.doPass1();
-               if (vr1.equals(VerificationResult.VR_OK)){
-                       
+               if (vr1.equals(VerificationResult.VR_OK)) {
+
                        // For every method, we could have information about the local variables out of LocalVariableTable attributes of
                        // the Code attributes.
                        localVariablesInfos = new LocalVariablesInfo[Repository.lookupClass(myOwner.getClassName()).getMethods().length];
 
                        VerificationResult vr = VerificationResult.VR_OK; // default.
-                       try{
+                       try {
                                constant_pool_entries_satisfy_static_constraints();
                                field_and_method_refs_are_valid();
                                every_class_has_an_accessible_superclass();
                                final_methods_are_not_overridden();
-                       }
-                       catch (ClassConstraintException cce){
+                       } catch (ClassConstraintException cce) {
                                vr = new VerificationResult(VerificationResult.VERIFIED_REJECTED, cce.getMessage());
                        }
                        return vr;
-               }
-               else
+               } else
                        return VerificationResult.VR_NOTYET;
        }
 
        /**
-        * Ensures that every class has a super class and that
-        * <B>final</B> classes are not subclassed.
-        * This means, the class this Pass2Verifier operates
-        * on has proper super classes (transitively) up to
-        * java.lang.Object.
-        * The reason for really loading (and Pass1-verifying)
-        * all of those classes here is that we need them in
-        * Pass2 anyway to verify no final methods are overridden
+        * Ensures that every class has a super class and that <B>final</B> classes are not subclassed. This means, the class this
+        * Pass2Verifier operates on has proper super classes (transitively) up to java.lang.Object. The reason for really loading (and
+        * Pass1-verifying) all of those classes here is that we need them in Pass2 anyway to verify no final methods are overridden
         * (that could be declared anywhere in the ancestor hierarchy).
-        *
+        * 
         * @throws ClassConstraintException otherwise.
         */
-       private void every_class_has_an_accessible_superclass(){
+       private void every_class_has_an_accessible_superclass() {
                HashSet<String> hs = new HashSet<String>(); // save class names to detect circular inheritance
                JavaClass jc = Repository.lookupClass(myOwner.getClassName());
                int supidx = -1;
 
-               while (supidx != 0){
+               while (supidx != 0) {
                        supidx = jc.getSuperclassNameIndex();
-               
-                       if (supidx == 0){
-                               if (jc != Repository.lookupClass(Type.OBJECT.getClassName())){
-                                       throw new ClassConstraintException("Superclass of '"+jc.getClassName()+"' missing but not "+Type.OBJECT.getClassName()+" itself!");
+
+                       if (supidx == 0) {
+                               if (jc != Repository.lookupClass(Type.OBJECT.getClassName())) {
+                                       throw new ClassConstraintException("Superclass of '" + jc.getClassName() + "' missing but not "
+                                                       + Type.OBJECT.getClassName() + " itself!");
                                }
-                       }
-                       else{
+                       } else {
                                String supername = jc.getSuperclassName();
-                               if (! hs.add(supername)){       // If supername already is in the list
+                               if (!hs.add(supername)) { // If supername already is in the list
                                        throw new ClassConstraintException("Circular superclass hierarchy detected.");
                                }
                                Verifier v = VerifierFactory.getVerifier(supername);
                                VerificationResult vr = v.doPass1();
 
-                               if (vr != VerificationResult.VR_OK){
-                                       throw new ClassConstraintException("Could not load in ancestor class '"+supername+"'.");
+                               if (vr != VerificationResult.VR_OK) {
+                                       throw new ClassConstraintException("Could not load in ancestor class '" + supername + "'.");
                                }
                                jc = Repository.lookupClass(supername);
 
-                               if (jc.isFinal()){
-                                       throw new ClassConstraintException("Ancestor class '"+supername+"' has the FINAL access modifier and must therefore not be subclassed.");
+                               if (jc.isFinal()) {
+                                       throw new ClassConstraintException("Ancestor class '" + supername
+                                                       + "' has the FINAL access modifier and must therefore not be subclassed.");
                                }
                        }
                }
        }
 
        /**
-        * Ensures that <B>final</B> methods are not overridden.
-        * <B>Precondition to run this method:
-        * constant_pool_entries_satisfy_static_constraints() and
-        * every_class_has_an_accessible_superclass() have to be invoked before
+        * Ensures that <B>final</B> methods are not overridden. <B>Precondition to run this method:
+        * constant_pool_entries_satisfy_static_constraints() and every_class_has_an_accessible_superclass() have to be invoked before
         * (in that order).</B>
-        *
+        * 
         * @throws ClassConstraintException otherwise.
         * @see #constant_pool_entries_satisfy_static_constraints()
         * @see #every_class_has_an_accessible_superclass()
         */
-       private void final_methods_are_not_overridden(){
+       private void final_methods_are_not_overridden() {
                HashMap<String, String> hashmap = new HashMap<String, String>();
                JavaClass jc = Repository.lookupClass(myOwner.getClassName());
-               
+
                int supidx = -1;
-               while (supidx != 0){
+               while (supidx != 0) {
                        supidx = jc.getSuperclassNameIndex();
 
                        Method[] methods = jc.getMethods();
-                       for (int i=0; i<methods.length; i++){
-                               String name_and_sig = (methods[i].getName()+methods[i].getSignature());
-
-                               if (hashmap.containsKey(name_and_sig)){
-                                       if (methods[i].isFinal()){
-                                               throw new ClassConstraintException("Method '"+name_and_sig+"' in class '"+hashmap.get(name_and_sig)+"' overrides the final (not-overridable) definition in class '"+jc.getClassName()+"'.");
-                                       }
-                                       else{
-                                               if (!methods[i].isStatic()){ // static methods don't inherit
+                       for (int i = 0; i < methods.length; i++) {
+                               String name_and_sig = (methods[i].getName() + methods[i].getSignature());
+
+                               if (hashmap.containsKey(name_and_sig)) {
+                                       if (methods[i].isFinal()) {
+                                               throw new ClassConstraintException("Method '" + name_and_sig + "' in class '" + hashmap.get(name_and_sig)
+                                                               + "' overrides the final (not-overridable) definition in class '" + jc.getClassName() + "'.");
+                                       } else {
+                                               if (!methods[i].isStatic()) { // static methods don't inherit
                                                        hashmap.put(name_and_sig, jc.getClassName());
                                                }
                                        }
-                               }
-                               else{
-                                       if (!methods[i].isStatic()){ // static methods don't inherit
+                               } else {
+                                       if (!methods[i].isStatic()) { // static methods don't inherit
                                                hashmap.put(name_and_sig, jc.getClassName());
                                        }
                                }
                        }
-               
-                       jc = Repository.lookupClass(jc.getSuperclassName());    // Well, for OBJECT this returns OBJECT so it works (could return anything but must not throw an Exception).
+
+                       jc = Repository.lookupClass(jc.getSuperclassName()); // Well, for OBJECT this returns OBJECT so it works (could return
+                       // anything but must not throw an Exception).
                }
 
        }
 
        /**
-        * Ensures that the constant pool entries satisfy the static constraints
-        * as described in The Java Virtual Machine Specification, 2nd Edition.
-        *
+        * Ensures that the constant pool entries satisfy the static constraints as described in The Java Virtual Machine Specification,
+        * 2nd Edition.
+        * 
         * @throws ClassConstraintException otherwise.
         */
-       private void constant_pool_entries_satisfy_static_constraints(){
+       private void constant_pool_entries_satisfy_static_constraints() {
                // Most of the consistency is handled internally by BCEL; here
                // we only have to verify if the indices of the constants point
                // to constants of the appropriate type and such.
@@ -306,19 +283,16 @@ public final class Pass2Verifier extends PassVerifier implements Constants{
        }
 
        /**
-        * A Visitor class that ensures the constant pool satisfies the static
-        * constraints.
-   * The visitXXX() methods throw ClassConstraintException instances otherwise.
-   *
-   * @see #constant_pool_entries_satisfy_static_constraints()
+        * A Visitor class that ensures the constant pool satisfies the static constraints. The visitXXX() methods throw
+        * ClassConstraintException instances otherwise.
+        * 
+        * @see #constant_pool_entries_satisfy_static_constraints()
         */
-       private class CPESSC_Visitor extends org.aspectj.apache.bcel.verifier.EmptyClassVisitor{
+       private class CPESSC_Visitor extends org.aspectj.apache.bcel.verifier.EmptyClassVisitor {
                private Class CONST_Class;
                /*
-        private Class CONST_Fieldref;
-               private Class CONST_Methodref;
-               private Class CONST_InterfaceMethodref;
-        */
+                * private Class CONST_Fieldref; private Class CONST_Methodref; private Class CONST_InterfaceMethodref;
+                */
                private Class<ConstantString> CONST_String;
                private Class<ConstantInteger> CONST_Integer;
                private Class<ConstantFloat> CONST_Float;
@@ -336,17 +310,17 @@ public final class Pass2Verifier extends PassVerifier implements Constants{
                private HashSet<String> field_names_and_desc = new HashSet<String>();
                private HashSet<String> method_names_and_desc = new HashSet<String>();
 
-               private CPESSC_Visitor(JavaClass _jc){
+               private CPESSC_Visitor(JavaClass _jc) {
                        jc = _jc;
                        cp = _jc.getConstantPool();
                        cplen = cp.getLength();
 
                        CONST_Class = org.aspectj.apache.bcel.classfile.ConstantClass.class;
                        /*
-            CONST_Fieldref = org.aspectj.apache.bcel.classfile.ConstantFieldref.class;
-                       CONST_Methodref = org.aspectj.apache.bcel.classfile.ConstantMethodref.class;
-                       CONST_InterfaceMethodref = org.aspectj.apache.bcel.classfile.ConstantInterfaceMethodref.class;
-            */
+                        * CONST_Fieldref = org.aspectj.apache.bcel.classfile.ConstantFieldref.class; CONST_Methodref =
+                        * org.aspectj.apache.bcel.classfile.ConstantMethodref.class; CONST_InterfaceMethodref =
+                        * org.aspectj.apache.bcel.classfile.ConstantInterfaceMethodref.class;
+                        */
                        CONST_String = org.aspectj.apache.bcel.classfile.ConstantString.class;
                        CONST_Integer = org.aspectj.apache.bcel.classfile.ConstantInteger.class;
                        CONST_Float = org.aspectj.apache.bcel.classfile.ConstantFloat.class;
@@ -359,20 +333,23 @@ public final class Pass2Verifier extends PassVerifier implements Constants{
                        carrier.visit();
                }
 
-               private void checkIndex(Node referrer, int index, Class shouldbe){
-                       if ((index < 0) || (index >= cplen)){
-                               throw new ClassConstraintException("Invalid index '"+index+"' used by '"+tostring(referrer)+"'.");
+               private void checkIndex(Node referrer, int index, Class shouldbe) {
+                       if ((index < 0) || (index >= cplen)) {
+                               throw new ClassConstraintException("Invalid index '" + index + "' used by '" + tostring(referrer) + "'.");
                        }
                        Constant c = cp.getConstant(index);
-                       if (! shouldbe.isInstance(c)){
+                       if (!shouldbe.isInstance(c)) {
                                /* String isnot = shouldbe.toString().substring(shouldbe.toString().lastIndexOf(".")+1); //Cut all before last "." */
-                               throw new ClassCastException("Illegal constant '"+tostring(c)+"' at index '"+index+"'. '"+tostring(referrer)+"' expects a '"+shouldbe+"'.");
+                               throw new ClassCastException("Illegal constant '" + tostring(c) + "' at index '" + index + "'. '"
+                                               + tostring(referrer) + "' expects a '" + shouldbe + "'.");
                        }
                }
-               ///////////////////////////////////////
+
+               // /////////////////////////////////////
                // ClassFile structure (vmspec2 4.1) //
-               ///////////////////////////////////////
-               public void visitJavaClass(JavaClass obj){
+               // /////////////////////////////////////
+               @Override
+               public void visitJavaClass(JavaClass obj) {
                        Attribute[] atts = obj.getAttributes();
                        boolean foundSourceFile = false;
                        boolean foundInnerClasses = false;
@@ -381,521 +358,631 @@ public final class Pass2Verifier extends PassVerifier implements Constants{
                        // This is a costly check; existing verifiers don't do it!
                        boolean hasInnerClass = new InnerClassDetector(jc).innerClassReferenced();
 
-                       for (int i=0; i<atts.length; i++){
-                               if ((! (atts[i] instanceof SourceFile)) &&
-                                   (! (atts[i] instanceof Deprecated))     &&
-                                   (! (atts[i] instanceof InnerClasses)) &&
-                                   (! (atts[i] instanceof Synthetic))){
-                                       addMessage("Attribute '"+tostring(atts[i])+"' as an attribute of the ClassFile structure '"+tostring(obj)+"' is unknown and will therefore be ignored.");
+                       for (int i = 0; i < atts.length; i++) {
+                               if ((!(atts[i] instanceof SourceFile)) && (!(atts[i] instanceof Deprecated))
+                                               && (!(atts[i] instanceof InnerClasses)) && (!(atts[i] instanceof Synthetic))) {
+                                       addMessage("Attribute '" + tostring(atts[i]) + "' as an attribute of the ClassFile structure '" + tostring(obj)
+                                                       + "' is unknown and will therefore be ignored.");
                                }
 
-                               if (atts[i] instanceof SourceFile){
-                                       if (foundSourceFile == false) foundSourceFile = true;
-                                       else throw new ClassConstraintException("A ClassFile structure (like '"+tostring(obj)+"') may have no more than one SourceFile attribute."); //vmspec2 4.7.7
+                               if (atts[i] instanceof SourceFile) {
+                                       if (foundSourceFile == false)
+                                               foundSourceFile = true;
+                                       else
+                                               throw new ClassConstraintException("A ClassFile structure (like '" + tostring(obj)
+                                                               + "') may have no more than one SourceFile attribute."); // vmspec2 4.7.7
                                }
 
-                               if (atts[i] instanceof InnerClasses){
-                                       if (foundInnerClasses == false) foundInnerClasses = true;
-                                       else{
-                                               if (hasInnerClass){
-                                                       throw new ClassConstraintException("A Classfile structure (like '"+tostring(obj)+"') must have exactly one InnerClasses attribute if at least one Inner Class is referenced (which is the case). More than one InnerClasses attribute was found.");
+                               if (atts[i] instanceof InnerClasses) {
+                                       if (foundInnerClasses == false)
+                                               foundInnerClasses = true;
+                                       else {
+                                               if (hasInnerClass) {
+                                                       throw new ClassConstraintException(
+                                                                       "A Classfile structure (like '"
+                                                                                       + tostring(obj)
+                                                                                       + "') must have exactly one InnerClasses attribute if at least one Inner Class is referenced (which is the case). More than one InnerClasses attribute was found.");
                                                }
                                        }
-                                       if (!hasInnerClass){
-                                               addMessage("No referenced Inner Class found, but InnerClasses attribute '"+tostring(atts[i])+"' found. Strongly suggest removal of that attribute.");
+                                       if (!hasInnerClass) {
+                                               addMessage("No referenced Inner Class found, but InnerClasses attribute '" + tostring(atts[i])
+                                                               + "' found. Strongly suggest removal of that attribute.");
                                        }
                                }
 
                        }
-                       if (hasInnerClass && !foundInnerClasses){
-                               //throw new ClassConstraintException("A Classfile structure (like '"+tostring(obj)+"') must have exactly one InnerClasses attribute if at least one Inner Class is referenced (which is the case). No InnerClasses attribute was found.");
-                               //vmspec2, page 125 says it would be a constraint: but existing verifiers
-                               //don't check it and javac doesn't satisfy it when it comes to anonymous
-                               //inner classes
-                               addMessage("A Classfile structure (like '"+tostring(obj)+"') must have exactly one InnerClasses attribute if at least one Inner Class is referenced (which is the case). No InnerClasses attribute was found.");
+                       if (hasInnerClass && !foundInnerClasses) {
+                               // throw new
+                               // ClassConstraintException("A Classfile structure (like '"+tostring(obj)+"') must have exactly one InnerClasses attribute if at least one Inner Class is referenced (which is the case). No InnerClasses attribute was found.");
+                               // vmspec2, page 125 says it would be a constraint: but existing verifiers
+                               // don't check it and javac doesn't satisfy it when it comes to anonymous
+                               // inner classes
+                               addMessage("A Classfile structure (like '"
+                                               + tostring(obj)
+                                               + "') must have exactly one InnerClasses attribute if at least one Inner Class is referenced (which is the case). No InnerClasses attribute was found.");
                        }
                }
-               /////////////////////////////
+
+               // ///////////////////////////
                // CONSTANTS (vmspec2 4.4) //
-               /////////////////////////////
-               public void visitConstantClass(ConstantClass obj){
-                       if (obj.getTag() != Constants.CONSTANT_Class){
-                               throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'.");
+               // ///////////////////////////
+               @Override
+               public void visitConstantClass(ConstantClass obj) {
+                       if (obj.getTag() != Constants.CONSTANT_Class) {
+                               throw new ClassConstraintException("Wrong constant tag in '" + tostring(obj) + "'.");
                        }
                        checkIndex(obj, obj.getNameIndex(), CONST_Utf8);
 
                }
-               public void visitConstantFieldref(ConstantFieldref obj){
-                       if (obj.getTag() != Constants.CONSTANT_Fieldref){
-                               throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'.");
+
+               @Override
+               public void visitConstantFieldref(ConstantFieldref obj) {
+                       if (obj.getTag() != Constants.CONSTANT_Fieldref) {
+                               throw new ClassConstraintException("Wrong constant tag in '" + tostring(obj) + "'.");
                        }
                        checkIndex(obj, obj.getClassIndex(), CONST_Class);
                        checkIndex(obj, obj.getNameAndTypeIndex(), CONST_NameAndType);
                }
-               public void visitConstantMethodref(ConstantMethodref obj){
-                       if (obj.getTag() != Constants.CONSTANT_Methodref){
-                               throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'.");
+
+               @Override
+               public void visitConstantMethodref(ConstantMethodref obj) {
+                       if (obj.getTag() != Constants.CONSTANT_Methodref) {
+                               throw new ClassConstraintException("Wrong constant tag in '" + tostring(obj) + "'.");
                        }
                        checkIndex(obj, obj.getClassIndex(), CONST_Class);
                        checkIndex(obj, obj.getNameAndTypeIndex(), CONST_NameAndType);
                }
-               public void visitConstantInterfaceMethodref(ConstantInterfaceMethodref obj){
-                       if (obj.getTag() != Constants.CONSTANT_InterfaceMethodref){
-                               throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'.");
+
+               @Override
+               public void visitConstantInterfaceMethodref(ConstantInterfaceMethodref obj) {
+                       if (obj.getTag() != Constants.CONSTANT_InterfaceMethodref) {
+                               throw new ClassConstraintException("Wrong constant tag in '" + tostring(obj) + "'.");
                        }
                        checkIndex(obj, obj.getClassIndex(), CONST_Class);
                        checkIndex(obj, obj.getNameAndTypeIndex(), CONST_NameAndType);
                }
-               public void visitConstantString(ConstantString obj){
-                       if (obj.getTag() != Constants.CONSTANT_String){
-                               throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'.");
+
+               @Override
+               public void visitConstantString(ConstantString obj) {
+                       if (obj.getTag() != Constants.CONSTANT_String) {
+                               throw new ClassConstraintException("Wrong constant tag in '" + tostring(obj) + "'.");
                        }
                        checkIndex(obj, obj.getStringIndex(), CONST_Utf8);
                }
-               public void visitConstantInteger(ConstantInteger obj){
-                       if (obj.getTag() != Constants.CONSTANT_Integer){
-                               throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'.");
+
+               @Override
+               public void visitConstantInteger(ConstantInteger obj) {
+                       if (obj.getTag() != Constants.CONSTANT_Integer) {
+                               throw new ClassConstraintException("Wrong constant tag in '" + tostring(obj) + "'.");
                        }
                        // no indices to check
                }
-               public void visitConstantFloat(ConstantFloat obj){
-                       if (obj.getTag() != Constants.CONSTANT_Float){
-                               throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'.");
+
+               @Override
+               public void visitConstantFloat(ConstantFloat obj) {
+                       if (obj.getTag() != Constants.CONSTANT_Float) {
+                               throw new ClassConstraintException("Wrong constant tag in '" + tostring(obj) + "'.");
                        }
-                       //no indices to check
+                       // no indices to check
                }
-               public void visitConstantLong(ConstantLong obj){
-                       if (obj.getTag() != Constants.CONSTANT_Long){
-                               throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'.");
+
+               @Override
+               public void visitConstantLong(ConstantLong obj) {
+                       if (obj.getTag() != Constants.CONSTANT_Long) {
+                               throw new ClassConstraintException("Wrong constant tag in '" + tostring(obj) + "'.");
                        }
-                       //no indices to check
+                       // no indices to check
                }
-               public void visitConstantDouble(ConstantDouble obj){
-                       if (obj.getTag() != Constants.CONSTANT_Double){
-                               throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'.");
+
+               @Override
+               public void visitConstantDouble(ConstantDouble obj) {
+                       if (obj.getTag() != Constants.CONSTANT_Double) {
+                               throw new ClassConstraintException("Wrong constant tag in '" + tostring(obj) + "'.");
                        }
-                       //no indices to check
+                       // no indices to check
                }
-               public void visitConstantNameAndType(ConstantNameAndType obj){
-                       if (obj.getTag() != Constants.CONSTANT_NameAndType){
-                               throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'.");
+
+               @Override
+               public void visitConstantNameAndType(ConstantNameAndType obj) {
+                       if (obj.getTag() != Constants.CONSTANT_NameAndType) {
+                               throw new ClassConstraintException("Wrong constant tag in '" + tostring(obj) + "'.");
                        }
                        checkIndex(obj, obj.getNameIndex(), CONST_Utf8);
-                       //checkIndex(obj, obj.getDescriptorIndex(), CONST_Utf8); //inconsistently named in BCEL, see below.
+                       // checkIndex(obj, obj.getDescriptorIndex(), CONST_Utf8); //inconsistently named in BCEL, see below.
                        checkIndex(obj, obj.getSignatureIndex(), CONST_Utf8);
                }
-               public void visitConstantUtf8(ConstantUtf8 obj){
-                       if (obj.getTag() != Constants.CONSTANT_Utf8){
-                               throw new ClassConstraintException("Wrong constant tag in '"+tostring(obj)+"'.");
+
+               @Override
+               public void visitConstantUtf8(ConstantUtf8 obj) {
+                       if (obj.getTag() != Constants.CONSTANT_Utf8) {
+                               throw new ClassConstraintException("Wrong constant tag in '" + tostring(obj) + "'.");
                        }
-                       //no indices to check
+                       // no indices to check
                }
-               //////////////////////////
+
+               // ////////////////////////
                // FIELDS (vmspec2 4.5) //
-               //////////////////////////
-               public void visitField(Field obj){
-
-                       if (jc.isClass()){
-                               int maxone=0;
-                               if (obj.isPrivate()) maxone++;
-                               if (obj.isProtected()) maxone++;
-                               if (obj.isPublic()) maxone++;
-                               if (maxone > 1){
-                                       throw new ClassConstraintException("Field '"+tostring(obj)+"' must only have at most one of its ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC modifiers set.");
+               // ////////////////////////
+               @Override
+               public void visitField(Field obj) {
+
+                       if (jc.isClass()) {
+                               int maxone = 0;
+                               if (obj.isPrivate())
+                                       maxone++;
+                               if (obj.isProtected())
+                                       maxone++;
+                               if (obj.isPublic())
+                                       maxone++;
+                               if (maxone > 1) {
+                                       throw new ClassConstraintException("Field '" + tostring(obj)
+                                                       + "' must only have at most one of its ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC modifiers set.");
                                }
 
-                               if (obj.isFinal() && obj.isVolatile()){
-                                       throw new ClassConstraintException("Field '"+tostring(obj)+"' must only have at most one of its ACC_FINAL, ACC_VOLATILE modifiers set.");
+                               if (obj.isFinal() && obj.isVolatile()) {
+                                       throw new ClassConstraintException("Field '" + tostring(obj)
+                                                       + "' must only have at most one of its ACC_FINAL, ACC_VOLATILE modifiers set.");
                                }
-                       }
-                       else{ // isInterface!
-                               if (!obj.isPublic()){
-                                       throw new ClassConstraintException("Interface field '"+tostring(obj)+"' must have the ACC_PUBLIC modifier set but hasn't!");
+                       } else { // isInterface!
+                               if (!obj.isPublic()) {
+                                       throw new ClassConstraintException("Interface field '" + tostring(obj)
+                                                       + "' must have the ACC_PUBLIC modifier set but hasn't!");
                                }
-                               if (!obj.isStatic()){
-                                       throw new ClassConstraintException("Interface field '"+tostring(obj)+"' must have the ACC_STATIC modifier set but hasn't!");
+                               if (!obj.isStatic()) {
+                                       throw new ClassConstraintException("Interface field '" + tostring(obj)
+                                                       + "' must have the ACC_STATIC modifier set but hasn't!");
                                }
-                               if (!obj.isFinal()){
-                                       throw new ClassConstraintException("Interface field '"+tostring(obj)+"' must have the ACC_FINAL modifier set but hasn't!");
+                               if (!obj.isFinal()) {
+                                       throw new ClassConstraintException("Interface field '" + tostring(obj)
+                                                       + "' must have the ACC_FINAL modifier set but hasn't!");
                                }
                        }
 
-                       if ((obj.getModifiers() & ~(ACC_PUBLIC|ACC_PRIVATE|ACC_PROTECTED|ACC_STATIC|ACC_FINAL|ACC_VOLATILE|ACC_TRANSIENT)) > 0){
-                               addMessage("Field '"+tostring(obj)+"' has access flag(s) other than ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL, ACC_VOLATILE, ACC_TRANSIENT set (ignored).");
+                       if ((obj.getModifiers() & ~(ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED | ACC_STATIC | ACC_FINAL | ACC_VOLATILE | ACC_TRANSIENT)) > 0) {
+                               addMessage("Field '"
+                                               + tostring(obj)
+                                               + "' has access flag(s) other than ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL, ACC_VOLATILE, ACC_TRANSIENT set (ignored).");
                        }
 
                        checkIndex(obj, obj.getNameIndex(), CONST_Utf8);
 
                        String name = obj.getName();
-                       if (! validFieldName(name)){
-                               throw new ClassConstraintException("Field '"+tostring(obj)+"' has illegal name '"+obj.getName()+"'.");
+                       if (!validFieldName(name)) {
+                               throw new ClassConstraintException("Field '" + tostring(obj) + "' has illegal name '" + obj.getName() + "'.");
                        }
 
                        // A descriptor is often named signature in BCEL
                        checkIndex(obj, obj.getSignatureIndex(), CONST_Utf8);
 
-                       String sig  = ((ConstantUtf8) (cp.getConstant(obj.getSignatureIndex()))).getBytes(); // Field or Method signature(=descriptor)
+                       String sig = ((ConstantUtf8) (cp.getConstant(obj.getSignatureIndex()))).getValue(); // Field or Method
+                       // signature(=descriptor)
 
-                       try{
-                               Type.getType(sig);  /* Don't need the return value */
-                       }
-                       catch (ClassFormatError cfe){ // sometimes BCEL is a little harsh describing exceptional situations.
-                               throw new ClassConstraintException("Illegal descriptor (==signature) '"+sig+"' used by '"+tostring(obj)+"'.");
+                       try {
+                               Type.getType(sig); /* Don't need the return value */
+                       } catch (ClassFormatError cfe) { // sometimes BCEL is a little harsh describing exceptional situations.
+                               throw new ClassConstraintException("Illegal descriptor (==signature) '" + sig + "' used by '" + tostring(obj)
+                                               + "'.");
                        }
 
-                       String nameanddesc = (name+sig);
-                       if (field_names_and_desc.contains(nameanddesc)){
-                               throw new ClassConstraintException("No two fields (like '"+tostring(obj)+"') are allowed have same names and descriptors!");
+                       String nameanddesc = (name + sig);
+                       if (field_names_and_desc.contains(nameanddesc)) {
+                               throw new ClassConstraintException("No two fields (like '" + tostring(obj)
+                                               + "') are allowed have same names and descriptors!");
                        }
-                       if (field_names.contains(name)){
-                               addMessage("More than one field of name '"+name+"' detected (but with different type descriptors). This is very unusual.");
+                       if (field_names.contains(name)) {
+                               addMessage("More than one field of name '" + name
+                                               + "' detected (but with different type descriptors). This is very unusual.");
                        }
                        field_names_and_desc.add(nameanddesc);
                        field_names.add(name);
 
                        Attribute[] atts = obj.getAttributes();
-                       for (int i=0; i<atts.length; i++){
-                               if ((! (atts[i] instanceof ConstantValue)) &&
-                                   (! (atts[i] instanceof Synthetic))     &&
-                                   (! (atts[i] instanceof Deprecated))){
-                                       addMessage("Attribute '"+tostring(atts[i])+"' as an attribute of Field '"+tostring(obj)+"' is unknown and will therefore be ignored.");
+                       for (int i = 0; i < atts.length; i++) {
+                               if ((!(atts[i] instanceof ConstantValue)) && (!(atts[i] instanceof Synthetic))
+                                               && (!(atts[i] instanceof Deprecated))) {
+                                       addMessage("Attribute '" + tostring(atts[i]) + "' as an attribute of Field '" + tostring(obj)
+                                                       + "' is unknown and will therefore be ignored.");
                                }
-                               if  (! (atts[i] instanceof ConstantValue)){
-                                       addMessage("Attribute '"+tostring(atts[i])+"' as an attribute of Field '"+tostring(obj)+"' is not a ConstantValue and is therefore only of use for debuggers and such.");
+                               if (!(atts[i] instanceof ConstantValue)) {
+                                       addMessage("Attribute '" + tostring(atts[i]) + "' as an attribute of Field '" + tostring(obj)
+                                                       + "' is not a ConstantValue and is therefore only of use for debuggers and such.");
                                }
                        }
                }
-               ///////////////////////////
+
+               // /////////////////////////
                // METHODS (vmspec2 4.6) //
-               ///////////////////////////
-               public void visitMethod(Method obj){
+               // /////////////////////////
+               @Override
+               public void visitMethod(Method obj) {
 
                        checkIndex(obj, obj.getNameIndex(), CONST_Utf8);
 
                        String name = obj.getName();
-                       if (! validMethodName(name, true)){
-                               throw new ClassConstraintException("Method '"+tostring(obj)+"' has illegal name '"+name+"'.");
+                       if (!validMethodName(name, true)) {
+                               throw new ClassConstraintException("Method '" + tostring(obj) + "' has illegal name '" + name + "'.");
                        }
 
                        // A descriptor is often named signature in BCEL
                        checkIndex(obj, obj.getSignatureIndex(), CONST_Utf8);
 
-                       String sig  = ((ConstantUtf8) (cp.getConstant(obj.getSignatureIndex()))).getBytes(); // Method's signature(=descriptor)
+                       String sig = ((ConstantUtf8) (cp.getConstant(obj.getSignatureIndex()))).getValue(); // Method's signature(=descriptor)
 
                        Type t;
                        Type[] ts; // needed below the try block.
-                       try{
-                               t  = Type.getReturnType(sig);
+                       try {
+                               t = Type.getReturnType(sig);
                                ts = Type.getArgumentTypes(sig);
-                       }
-                       catch (ClassFormatError cfe){
+                       } catch (ClassFormatError cfe) {
                                // Well, BCEL sometimes is a little harsh describing exceptional situations.
-                               throw new ClassConstraintException("Illegal descriptor (==signature) '"+sig+"' used by Method '"+tostring(obj)+"'.");
+                               throw new ClassConstraintException("Illegal descriptor (==signature) '" + sig + "' used by Method '"
+                                               + tostring(obj) + "'.");
                        }
 
                        // Check if referenced objects exist.
                        Type act = t;
-                       if (act instanceof ArrayType) act = ((ArrayType) act).getBasicType();
-                       if (act instanceof ObjectType){
-                               Verifier v = VerifierFactory.getVerifier( ((ObjectType) act).getClassName() );
+                       if (act instanceof ArrayType)
+                               act = ((ArrayType) act).getBasicType();
+                       if (act instanceof ObjectType) {
+                               Verifier v = VerifierFactory.getVerifier(((ObjectType) act).getClassName());
                                VerificationResult vr = v.doPass1();
                                if (vr != VerificationResult.VR_OK) {
-                                       throw new ClassConstraintException("Method '"+tostring(obj)+"' has a return type that does not pass verification pass 1: '"+vr+"'.");
+                                       throw new ClassConstraintException("Method '" + tostring(obj)
+                                                       + "' has a return type that does not pass verification pass 1: '" + vr + "'.");
                                }
                        }
 
-                       for (int i=0; i<ts.length; i++){
+                       for (int i = 0; i < ts.length; i++) {
                                act = ts[i];
-                               if (act instanceof ArrayType) act = ((ArrayType) act).getBasicType();
-                               if (act instanceof ObjectType){
-                                       Verifier v = VerifierFactory.getVerifier( ((ObjectType) act).getClassName() );
+                               if (act instanceof ArrayType)
+                                       act = ((ArrayType) act).getBasicType();
+                               if (act instanceof ObjectType) {
+                                       Verifier v = VerifierFactory.getVerifier(((ObjectType) act).getClassName());
                                        VerificationResult vr = v.doPass1();
                                        if (vr != VerificationResult.VR_OK) {
-                                               throw new ClassConstraintException("Method '"+tostring(obj)+"' has an argument type that does not pass verification pass 1: '"+vr+"'.");
+                                               throw new ClassConstraintException("Method '" + tostring(obj)
+                                                               + "' has an argument type that does not pass verification pass 1: '" + vr + "'.");
                                        }
                                }
                        }
 
-                       // Nearly forgot this! Funny return values are allowed, but a non-empty arguments list makes a different method out of it!
-                       if (name.equals(STATIC_INITIALIZER_NAME) && (ts.length != 0)){
-                               throw new ClassConstraintException("Method '"+tostring(obj)+"' has illegal name '"+name+"'. It's name resembles the class or interface initialization method which it isn't because of its arguments (==descriptor).");
-                       }
-
-                       if (jc.isClass()){
-                               int maxone=0;
-                               if (obj.isPrivate()) maxone++;
-                               if (obj.isProtected()) maxone++;
-                               if (obj.isPublic()) maxone++;
-                               if (maxone > 1){
-                                       throw new ClassConstraintException("Method '"+tostring(obj)+"' must only have at most one of its ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC modifiers set.");
+                       // Nearly forgot this! Funny return values are allowed, but a non-empty arguments list makes a different method out of
+                       // it!
+                       if (name.equals(STATIC_INITIALIZER_NAME) && (ts.length != 0)) {
+                               throw new ClassConstraintException(
+                                               "Method '"
+                                                               + tostring(obj)
+                                                               + "' has illegal name '"
+                                                               + name
+                                                               + "'. It's name resembles the class or interface initialization method which it isn't because of its arguments (==descriptor).");
+                       }
+
+                       if (jc.isClass()) {
+                               int maxone = 0;
+                               if (obj.isPrivate())
+                                       maxone++;
+                               if (obj.isProtected())
+                                       maxone++;
+                               if (obj.isPublic())
+                                       maxone++;
+                               if (maxone > 1) {
+                                       throw new ClassConstraintException("Method '" + tostring(obj)
+                                                       + "' must only have at most one of its ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC modifiers set.");
                                }
 
-                               if (obj.isAbstract()){
-                                       if (obj.isFinal()) throw new ClassConstraintException("Abstract method '"+tostring(obj)+"' must not have the ACC_FINAL modifier set.");
-                                       if (obj.isNative()) throw new ClassConstraintException("Abstract method '"+tostring(obj)+"' must not have the ACC_NATIVE modifier set.");
-                                       if (obj.isPrivate()) throw new ClassConstraintException("Abstract method '"+tostring(obj)+"' must not have the ACC_PRIVATE modifier set.");
-                                       if (obj.isStatic()) throw new ClassConstraintException("Abstract method '"+tostring(obj)+"' must not have the ACC_STATIC modifier set.");
-                                       if (obj.isStrictfp()) throw new ClassConstraintException("Abstract method '"+tostring(obj)+"' must not have the ACC_STRICT modifier set.");
-                                       if (obj.isSynchronized()) throw new ClassConstraintException("Abstract method '"+tostring(obj)+"' must not have the ACC_SYNCHRONIZED modifier set.");
+                               if (obj.isAbstract()) {
+                                       if (obj.isFinal())
+                                               throw new ClassConstraintException("Abstract method '" + tostring(obj)
+                                                               + "' must not have the ACC_FINAL modifier set.");
+                                       if (obj.isNative())
+                                               throw new ClassConstraintException("Abstract method '" + tostring(obj)
+                                                               + "' must not have the ACC_NATIVE modifier set.");
+                                       if (obj.isPrivate())
+                                               throw new ClassConstraintException("Abstract method '" + tostring(obj)
+                                                               + "' must not have the ACC_PRIVATE modifier set.");
+                                       if (obj.isStatic())
+                                               throw new ClassConstraintException("Abstract method '" + tostring(obj)
+                                                               + "' must not have the ACC_STATIC modifier set.");
+                                       if (obj.isStrictfp())
+                                               throw new ClassConstraintException("Abstract method '" + tostring(obj)
+                                                               + "' must not have the ACC_STRICT modifier set.");
+                                       if (obj.isSynchronized())
+                                               throw new ClassConstraintException("Abstract method '" + tostring(obj)
+                                                               + "' must not have the ACC_SYNCHRONIZED modifier set.");
                                }
-                       }
-                       else{ // isInterface!
-                               if (!name.equals(STATIC_INITIALIZER_NAME)){//vmspec2, p.116, 2nd paragraph
-                                       if (!obj.isPublic()){
-                                               throw new ClassConstraintException("Interface method '"+tostring(obj)+"' must have the ACC_PUBLIC modifier set but hasn't!");
+                       } else { // isInterface!
+                               if (!name.equals(STATIC_INITIALIZER_NAME)) {// vmspec2, p.116, 2nd paragraph
+                                       if (!obj.isPublic()) {
+                                               throw new ClassConstraintException("Interface method '" + tostring(obj)
+                                                               + "' must have the ACC_PUBLIC modifier set but hasn't!");
                                        }
-                                       if (!obj.isAbstract()){
-                                               throw new ClassConstraintException("Interface method '"+tostring(obj)+"' must have the ACC_STATIC modifier set but hasn't!");
+                                       if (!obj.isAbstract()) {
+                                               throw new ClassConstraintException("Interface method '" + tostring(obj)
+                                                               + "' must have the ACC_STATIC modifier set but hasn't!");
                                        }
-                                       if (    obj.isPrivate() ||
-                                                               obj.isProtected() ||
-                                                               obj.isStatic() ||
-                                                               obj.isFinal() ||
-                                                               obj.isSynchronized() ||
-                                                               obj.isNative() ||
-                                                               obj.isStrictfp() ){
-                                               throw new ClassConstraintException("Interface method '"+tostring(obj)+"' must not have any of the ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL, ACC_SYNCHRONIZED, ACC_NATIVE, ACC_ABSTRACT, ACC_STRICT modifiers set.");
+                                       if (obj.isPrivate() || obj.isProtected() || obj.isStatic() || obj.isFinal() || obj.isSynchronized()
+                                                       || obj.isNative() || obj.isStrictfp()) {
+                                               throw new ClassConstraintException(
+                                                               "Interface method '"
+                                                                               + tostring(obj)
+                                                                               + "' must not have any of the ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL, ACC_SYNCHRONIZED, ACC_NATIVE, ACC_ABSTRACT, ACC_STRICT modifiers set.");
                                        }
                                }
                        }
 
                        // A specific instance initialization method... (vmspec2,Page 116).
-                       if (name.equals(CONSTRUCTOR_NAME)){
-                               //..may have at most one of ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC set: is checked above.
-                               //..may also have ACC_STRICT set, but none of the other flags in table 4.5 (vmspec2, page 115)
-                               if (    obj.isStatic() ||
-                                                       obj.isFinal() ||
-                                                       obj.isSynchronized() ||
-                                                       obj.isNative() ||
-                                                       obj.isAbstract() ){
-                                       throw new ClassConstraintException("Instance initialization method '"+tostring(obj)+"' must not have any of the ACC_STATIC, ACC_FINAL, ACC_SYNCHRONIZED, ACC_NATIVE, ACC_ABSTRACT modifiers set.");
+                       if (name.equals(CONSTRUCTOR_NAME)) {
+                               // ..may have at most one of ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC set: is checked above.
+                               // ..may also have ACC_STRICT set, but none of the other flags in table 4.5 (vmspec2, page 115)
+                               if (obj.isStatic() || obj.isFinal() || obj.isSynchronized() || obj.isNative() || obj.isAbstract()) {
+                                       throw new ClassConstraintException(
+                                                       "Instance initialization method '"
+                                                                       + tostring(obj)
+                                                                       + "' must not have any of the ACC_STATIC, ACC_FINAL, ACC_SYNCHRONIZED, ACC_NATIVE, ACC_ABSTRACT modifiers set.");
                                }
                        }
 
                        // Class and interface initialization methods...
-                       if (name.equals(STATIC_INITIALIZER_NAME)){
-                               if ((obj.getModifiers() & (~ACC_STRICT)) > 0){
-                                       addMessage("Class or interface initialization method '"+tostring(obj)+"' has superfluous access modifier(s) set: everything but ACC_STRICT is ignored.");
+                       if (name.equals(STATIC_INITIALIZER_NAME)) {
+                               if ((obj.getModifiers() & (~ACC_STRICT)) > 0) {
+                                       addMessage("Class or interface initialization method '" + tostring(obj)
+                                                       + "' has superfluous access modifier(s) set: everything but ACC_STRICT is ignored.");
                                }
-                               if (obj.isAbstract()){
-                                       throw new ClassConstraintException("Class or interface initialization method '"+tostring(obj)+"' must not be abstract. This contradicts the Java Language Specification, Second Edition (which omits this constraint) but is common practice of existing verifiers.");
+                               if (obj.isAbstract()) {
+                                       throw new ClassConstraintException(
+                                                       "Class or interface initialization method '"
+                                                                       + tostring(obj)
+                                                                       + "' must not be abstract. This contradicts the Java Language Specification, Second Edition (which omits this constraint) but is common practice of existing verifiers.");
                                }
                        }
 
-                       if ((obj.getModifiers() & ~(ACC_PUBLIC|ACC_PRIVATE|ACC_PROTECTED|ACC_STATIC|ACC_FINAL|ACC_SYNCHRONIZED|ACC_NATIVE|ACC_ABSTRACT|ACC_STRICT)) > 0){
-                               addMessage("Method '"+tostring(obj)+"' has access flag(s) other than ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL, ACC_SYNCHRONIZED, ACC_NATIVE, ACC_ABSTRACT, ACC_STRICT set (ignored).");
+                       if ((obj.getModifiers() & ~(ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED | ACC_STATIC | ACC_FINAL | ACC_SYNCHRONIZED
+                                       | ACC_NATIVE | ACC_ABSTRACT | ACC_STRICT)) > 0) {
+                               addMessage("Method '"
+                                               + tostring(obj)
+                                               + "' has access flag(s) other than ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL, ACC_SYNCHRONIZED, ACC_NATIVE, ACC_ABSTRACT, ACC_STRICT set (ignored).");
                        }
 
-                       String nameanddesc = (name+sig);
-                       if (method_names_and_desc.contains(nameanddesc)){
-                               throw new ClassConstraintException("No two methods (like '"+tostring(obj)+"') are allowed have same names and desciptors!");
+                       String nameanddesc = (name + sig);
+                       if (method_names_and_desc.contains(nameanddesc)) {
+                               throw new ClassConstraintException("No two methods (like '" + tostring(obj)
+                                               + "') are allowed have same names and desciptors!");
                        }
                        method_names_and_desc.add(nameanddesc);
 
                        Attribute[] atts = obj.getAttributes();
                        int num_code_atts = 0;
-                       for (int i=0; i<atts.length; i++){
-                               if ((! (atts[i] instanceof Code)) &&
-                                   (! (atts[i] instanceof ExceptionTable))     &&
-                                   (! (atts[i] instanceof Synthetic)) &&
-                                   (! (atts[i] instanceof Deprecated))){
-                                       addMessage("Attribute '"+tostring(atts[i])+"' as an attribute of Method '"+tostring(obj)+"' is unknown and will therefore be ignored.");
+                       for (int i = 0; i < atts.length; i++) {
+                               if ((!(atts[i] instanceof Code)) && (!(atts[i] instanceof ExceptionTable)) && (!(atts[i] instanceof Synthetic))
+                                               && (!(atts[i] instanceof Deprecated))) {
+                                       addMessage("Attribute '" + tostring(atts[i]) + "' as an attribute of Method '" + tostring(obj)
+                                                       + "' is unknown and will therefore be ignored.");
                                }
-                               if ((! (atts[i] instanceof Code)) &&
-                                               (! (atts[i] instanceof ExceptionTable))){
-                                       addMessage("Attribute '"+tostring(atts[i])+"' as an attribute of Method '"+tostring(obj)+"' is neither Code nor Exceptions and is therefore only of use for debuggers and such.");
+                               if ((!(atts[i] instanceof Code)) && (!(atts[i] instanceof ExceptionTable))) {
+                                       addMessage("Attribute '" + tostring(atts[i]) + "' as an attribute of Method '" + tostring(obj)
+                                                       + "' is neither Code nor Exceptions and is therefore only of use for debuggers and such.");
                                }
-                               if ((atts[i] instanceof Code) && (obj.isNative() || obj.isAbstract())){
-                                       throw new ClassConstraintException("Native or abstract methods like '"+tostring(obj)+"' must not have a Code attribute like '"+tostring(atts[i])+"'."); //vmspec2 page120, 4.7.3
+                               if ((atts[i] instanceof Code) && (obj.isNative() || obj.isAbstract())) {
+                                       throw new ClassConstraintException("Native or abstract methods like '" + tostring(obj)
+                                                       + "' must not have a Code attribute like '" + tostring(atts[i]) + "'."); // vmspec2 page120, 4.7.3
                                }
-                               if (atts[i] instanceof Code) num_code_atts++;
+                               if (atts[i] instanceof Code)
+                                       num_code_atts++;
                        }
-                       if ( !obj.isNative() && !obj.isAbstract() && num_code_atts != 1){
-                               throw new ClassConstraintException("Non-native, non-abstract methods like '"+tostring(obj)+"' must have exactly one Code attribute (found: "+num_code_atts+").");
+                       if (!obj.isNative() && !obj.isAbstract() && num_code_atts != 1) {
+                               throw new ClassConstraintException("Non-native, non-abstract methods like '" + tostring(obj)
+                                               + "' must have exactly one Code attribute (found: " + num_code_atts + ").");
                        }
                }
-               ///////////////////////////////////////////////////////
+
+               // /////////////////////////////////////////////////////
                // ClassFile-structure-ATTRIBUTES (vmspec2 4.1, 4.7) //
-               ///////////////////////////////////////////////////////
-               public void visitSourceFile(SourceFile obj){//vmspec2 4.7.7
+               // /////////////////////////////////////////////////////
+               public void visitSourceFile(SourceFile obj) {// vmspec2 4.7.7
 
                        // zero or one SourceFile attr per ClassFile: see visitJavaClass()
 
                        checkIndex(obj, obj.getNameIndex(), CONST_Utf8);
 
-                       String name = ((ConstantUtf8) cp.getConstant(obj.getNameIndex())).getBytes();
-                       if (! name.equals("SourceFile")){
-                               throw new ClassConstraintException("The SourceFile attribute '"+tostring(obj)+"' is not correctly named 'SourceFile' but '"+name+"'.");
+                       String name = ((ConstantUtf8) cp.getConstant(obj.getNameIndex())).getValue();
+                       if (!name.equals("SourceFile")) {
+                               throw new ClassConstraintException("The SourceFile attribute '" + tostring(obj)
+                                               + "' is not correctly named 'SourceFile' but '" + name + "'.");
                        }
 
                        checkIndex(obj, obj.getSourceFileIndex(), CONST_Utf8);
 
-                       String sourcefilename = ((ConstantUtf8) cp.getConstant(obj.getSourceFileIndex())).getBytes(); //==obj.getSourceFileName() ?
+                       String sourcefilename = ((ConstantUtf8) cp.getConstant(obj.getSourceFileIndex())).getValue(); // ==obj.getSourceFileName()
+                       // ?
                        String sourcefilenamelc = sourcefilename.toLowerCase();
 
-                       if (    (sourcefilename.indexOf('/') != -1) ||
-                                               (sourcefilename.indexOf('\\') != -1) ||
-                                               (sourcefilename.indexOf(':') != -1) ||
-                                               (sourcefilenamelc.lastIndexOf(".java") == -1)   ){
-                               addMessage("SourceFile attribute '"+tostring(obj)+"' has a funny name: remember not to confuse certain parsers working on javap's output. Also, this name ('"+sourcefilename+"') is considered an unqualified (simple) file name only.");
+                       if ((sourcefilename.indexOf('/') != -1) || (sourcefilename.indexOf('\\') != -1) || (sourcefilename.indexOf(':') != -1)
+                                       || (sourcefilenamelc.lastIndexOf(".java") == -1)) {
+                               addMessage("SourceFile attribute '"
+                                               + tostring(obj)
+                                               + "' has a funny name: remember not to confuse certain parsers working on javap's output. Also, this name ('"
+                                               + sourcefilename + "') is considered an unqualified (simple) file name only.");
                        }
                }
-               public void visitDeprecated(Deprecated obj){//vmspec2 4.7.10
+
+               public void visitDeprecated(Deprecated obj) {// vmspec2 4.7.10
                        checkIndex(obj, obj.getNameIndex(), CONST_Utf8);
 
-                       String name = ((ConstantUtf8) cp.getConstant(obj.getNameIndex())).getBytes();
-                       if (! name.equals("Deprecated")){
-                               throw new ClassConstraintException("The Deprecated attribute '"+tostring(obj)+"' is not correctly named 'Deprecated' but '"+name+"'.");
+                       String name = ((ConstantUtf8) cp.getConstant(obj.getNameIndex())).getValue();
+                       if (!name.equals("Deprecated")) {
+                               throw new ClassConstraintException("The Deprecated attribute '" + tostring(obj)
+                                               + "' is not correctly named 'Deprecated' but '" + name + "'.");
                        }
                }
-               public void visitSynthetic(Synthetic obj){//vmspec2 4.7.6
+
+               public void visitSynthetic(Synthetic obj) {// vmspec2 4.7.6
                        checkIndex(obj, obj.getNameIndex(), CONST_Utf8);
-                       String name = ((ConstantUtf8) cp.getConstant(obj.getNameIndex())).getBytes();
-                       if (! name.equals("Synthetic")){
-                               throw new ClassConstraintException("The Synthetic attribute '"+tostring(obj)+"' is not correctly named 'Synthetic' but '"+name+"'.");
+                       String name = ((ConstantUtf8) cp.getConstant(obj.getNameIndex())).getValue();
+                       if (!name.equals("Synthetic")) {
+                               throw new ClassConstraintException("The Synthetic attribute '" + tostring(obj)
+                                               + "' is not correctly named 'Synthetic' but '" + name + "'.");
                        }
                }
-               public void visitInnerClasses(InnerClasses obj){//vmspec2 4.7.5
+
+               public void visitInnerClasses(InnerClasses obj) {// vmspec2 4.7.5
 
                        // exactly one InnerClasses attr per ClassFile if some inner class is refernced: see visitJavaClass()
 
                        checkIndex(obj, obj.getNameIndex(), CONST_Utf8);
 
-                       String name = ((ConstantUtf8) cp.getConstant(obj.getNameIndex())).getBytes();
-                       if (! name.equals("InnerClasses")){
-                               throw new ClassConstraintException("The InnerClasses attribute '"+tostring(obj)+"' is not correctly named 'InnerClasses' but '"+name+"'.");
+                       String name = ((ConstantUtf8) cp.getConstant(obj.getNameIndex())).getValue();
+                       if (!name.equals("InnerClasses")) {
+                               throw new ClassConstraintException("The InnerClasses attribute '" + tostring(obj)
+                                               + "' is not correctly named 'InnerClasses' but '" + name + "'.");
                        }
 
                        InnerClass[] ics = obj.getInnerClasses();
 
-                       for (int i=0; i<ics.length; i++){
+                       for (int i = 0; i < ics.length; i++) {
                                checkIndex(obj, ics[i].getInnerClassIndex(), CONST_Class);
                                int outer_idx = ics[i].getOuterClassIndex();
-                               if (outer_idx != 0){
+                               if (outer_idx != 0) {
                                        checkIndex(obj, outer_idx, CONST_Class);
                                }
                                int innername_idx = ics[i].getInnerNameIndex();
-                               if (innername_idx != 0){
+                               if (innername_idx != 0) {
                                        checkIndex(obj, innername_idx, CONST_Utf8);
                                }
                                int acc = ics[i].getInnerAccessFlags();
-                               acc = acc & (~ (ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED | ACC_STATIC | ACC_FINAL | ACC_INTERFACE | ACC_ABSTRACT));
-                               if (acc != 0){
-                                       addMessage("Unknown access flag for inner class '"+tostring(ics[i])+"' set (InnerClasses attribute '"+tostring(obj)+"').");
+                               acc = acc & (~(ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED | ACC_STATIC | ACC_FINAL | ACC_INTERFACE | ACC_ABSTRACT));
+                               if (acc != 0) {
+                                       addMessage("Unknown access flag for inner class '" + tostring(ics[i]) + "' set (InnerClasses attribute '"
+                                                       + tostring(obj) + "').");
                                }
                        }
                        // Semantical consistency is not yet checked by Sun, see vmspec2 4.7.5.
                        // [marked TODO in JustIce]
                }
-               ////////////////////////////////////////////////////////
+
+               // //////////////////////////////////////////////////////
                // field_info-structure-ATTRIBUTES (vmspec2 4.5, 4.7) //
-               ////////////////////////////////////////////////////////
-               public void visitConstantValue(ConstantValue obj){//vmspec2 4.7.2
+               // //////////////////////////////////////////////////////
+               public void visitConstantValue(ConstantValue obj) {// vmspec2 4.7.2
                        // Despite its name, this really is an Attribute,
                        // not a constant!
                        checkIndex(obj, obj.getNameIndex(), CONST_Utf8);
 
-                       String name = ((ConstantUtf8) cp.getConstant(obj.getNameIndex())).getBytes();
-                       if (! name.equals("ConstantValue")){
-                               throw new ClassConstraintException("The ConstantValue attribute '"+tostring(obj)+"' is not correctly named 'ConstantValue' but '"+name+"'.");
+                       String name = ((ConstantUtf8) cp.getConstant(obj.getNameIndex())).getValue();
+                       if (!name.equals("ConstantValue")) {
+                               throw new ClassConstraintException("The ConstantValue attribute '" + tostring(obj)
+                                               + "' is not correctly named 'ConstantValue' but '" + name + "'.");
                        }
 
                        Object pred = carrier.predecessor();
-                       if (pred instanceof Field){ //ConstantValue attributes are quite senseless if the predecessor is not a field.
+                       if (pred instanceof Field) { // ConstantValue attributes are quite senseless if the predecessor is not a field.
                                Field f = (Field) pred;
                                // Field constraints have been checked before -- so we are safe using their type information.
-                               Type field_type = Type.getType(((ConstantUtf8) (cp.getConstant(f.getSignatureIndex()))).getBytes());
+                               Type field_type = Type.getType(((ConstantUtf8) (cp.getConstant(f.getSignatureIndex()))).getValue());
 
                                int index = obj.getConstantValueIndex();
-                               if ((index < 0) || (index >= cplen)){
-                                       throw new ClassConstraintException("Invalid index '"+index+"' used by '"+tostring(obj)+"'.");
+                               if ((index < 0) || (index >= cplen)) {
+                                       throw new ClassConstraintException("Invalid index '" + index + "' used by '" + tostring(obj) + "'.");
                                }
                                Constant c = cp.getConstant(index);
 
-                               if (CONST_Long.isInstance(c) && field_type.equals(Type.LONG)){
+                               if (CONST_Long.isInstance(c) && field_type.equals(Type.LONG)) {
                                        return;
                                }
-                               if (CONST_Float.isInstance(c) && field_type.equals(Type.FLOAT)){
+                               if (CONST_Float.isInstance(c) && field_type.equals(Type.FLOAT)) {
                                        return;
                                }
-                               if (CONST_Double.isInstance(c) && field_type.equals(Type.DOUBLE)){
+                               if (CONST_Double.isInstance(c) && field_type.equals(Type.DOUBLE)) {
                                        return;
                                }
-                               if (CONST_Integer.isInstance(c) && (field_type.equals(Type.INT) || field_type.equals(Type.SHORT) || field_type.equals(Type.CHAR) || field_type.equals(Type.BYTE) || field_type.equals(Type.BOOLEAN))){
+                               if (CONST_Integer.isInstance(c)
+                                               && (field_type.equals(Type.INT) || field_type.equals(Type.SHORT) || field_type.equals(Type.CHAR)
+                                                               || field_type.equals(Type.BYTE) || field_type.equals(Type.BOOLEAN))) {
                                        return;
                                }
-                               if (CONST_String.isInstance(c) && field_type.equals(Type.STRING)){
+                               if (CONST_String.isInstance(c) && field_type.equals(Type.STRING)) {
                                        return;
                                }
 
-                               throw new ClassConstraintException("Illegal type of ConstantValue '"+obj+"' embedding Constant '"+c+"'. It is referenced by field '"+tostring(f)+"' expecting a different type: '"+field_type+"'.");
+                               throw new ClassConstraintException("Illegal type of ConstantValue '" + obj + "' embedding Constant '" + c
+                                               + "'. It is referenced by field '" + tostring(f) + "' expecting a different type: '" + field_type + "'.");
                        }
                }
+
                // SYNTHETIC: see above
                // DEPRECATED: see above
-               /////////////////////////////////////////////////////////
+               // ///////////////////////////////////////////////////////
                // method_info-structure-ATTRIBUTES (vmspec2 4.6, 4.7) //
-               /////////////////////////////////////////////////////////
-               public void visitCode(Code obj){//vmspec2 4.7.3
+               // ///////////////////////////////////////////////////////
+               public void visitCode(Code obj) {// vmspec2 4.7.3
                        // No code attribute allowed for native or abstract methods: see visitMethod(Method).
                        // Code array constraints are checked in Pass3 (3a and 3b).
 
                        checkIndex(obj, obj.getNameIndex(), CONST_Utf8);
 
-                       String name = ((ConstantUtf8) cp.getConstant(obj.getNameIndex())).getBytes();
-                       if (! name.equals("Code")){
-                               throw new ClassConstraintException("The Code attribute '"+tostring(obj)+"' is not correctly named 'Code' but '"+name+"'.");
+                       String name = ((ConstantUtf8) cp.getConstant(obj.getNameIndex())).getValue();
+                       if (!name.equals("Code")) {
+                               throw new ClassConstraintException("The Code attribute '" + tostring(obj) + "' is not correctly named 'Code' but '"
+                                               + name + "'.");
                        }
 
                        Method m = null; // satisfy compiler
-                       if (!(carrier.predecessor() instanceof Method)){
-                               addMessage("Code attribute '"+tostring(obj)+"' is not declared in a method_info structure but in '"+carrier.predecessor()+"'. Ignored.");
+                       if (!(carrier.predecessor() instanceof Method)) {
+                               addMessage("Code attribute '" + tostring(obj) + "' is not declared in a method_info structure but in '"
+                                               + carrier.predecessor() + "'. Ignored.");
                                return;
-                       }
-                       else{
-                               m = (Method) carrier.predecessor();     // we can assume this method was visited before;
-                                                                                                                                                                               // i.e. the data consistency was verified.
+                       } else {
+                               m = (Method) carrier.predecessor(); // we can assume this method was visited before;
+                               // i.e. the data consistency was verified.
                        }
 
-                       if (obj.getCode().length == 0){
-                               throw new ClassConstraintException("Code array of Code attribute '"+tostring(obj)+"' (method '"+m+"') must not be empty.");
+                       if (obj.getCode().length == 0) {
+                               throw new ClassConstraintException("Code array of Code attribute '" + tostring(obj) + "' (method '" + m
+                                               + "') must not be empty.");
                        }
 
-                       //In JustIce, the check for correct offsets into the code array is delayed to Pass 3a.
+                       // In JustIce, the check for correct offsets into the code array is delayed to Pass 3a.
                        CodeException[] exc_table = obj.getExceptionTable();
-                       for (int i=0; i<exc_table.length; i++){
+                       for (int i = 0; i < exc_table.length; i++) {
                                int exc_index = exc_table[i].getCatchType();
-                               if (exc_index != 0){ // if 0, it catches all Throwables
+                               if (exc_index != 0) { // if 0, it catches all Throwables
                                        checkIndex(obj, exc_index, CONST_Class);
                                        ConstantClass cc = (ConstantClass) (cp.getConstant(exc_index));
-                                       checkIndex(cc, cc.getNameIndex(), CONST_Utf8); // cannot be sure this ConstantClass has already been visited (checked)!
-                                       String cname = ((ConstantUtf8) cp.getConstant(cc.getNameIndex())).getBytes().replace('/','.');
+                                       checkIndex(cc, cc.getNameIndex(), CONST_Utf8); // cannot be sure this ConstantClass has already been visited
+                                       // (checked)!
+                                       String cname = ((ConstantUtf8) cp.getConstant(cc.getNameIndex())).getValue().replace('/', '.');
 
                                        Verifier v = VerifierFactory.getVerifier(cname);
                                        VerificationResult vr = v.doPass1();
 
-                                       if (vr != VerificationResult.VR_OK){
-                                               throw new ClassConstraintException("Code attribute '"+tostring(obj)+"' (method '"+m+"') has an exception_table entry '"+tostring(exc_table[i])+"' that references '"+cname+"' as an Exception but it does not pass verification pass 1: "+vr);
-                                       }
-                                       else{
+                                       if (vr != VerificationResult.VR_OK) {
+                                               throw new ClassConstraintException("Code attribute '" + tostring(obj) + "' (method '" + m
+                                                               + "') has an exception_table entry '" + tostring(exc_table[i]) + "' that references '" + cname
+                                                               + "' as an Exception but it does not pass verification pass 1: " + vr);
+                                       } else {
                                                // We cannot safely trust any other "instanceof" mechanism. We need to transitively verify
                                                // the ancestor hierarchy.
                                                JavaClass e = Repository.lookupClass(cname);
                                                JavaClass t = Repository.lookupClass(Type.THROWABLE.getClassName());
                                                JavaClass o = Repository.lookupClass(Type.OBJECT.getClassName());
-                                               while (e != o){
-                                                       if (e == t) break; // It's a subclass of Throwable, OKAY, leave.
+                                               while (e != o) {
+                                                       if (e == t)
+                                                               break; // It's a subclass of Throwable, OKAY, leave.
 
                                                        v = VerifierFactory.getVerifier(e.getSuperclassName());
                                                        vr = v.doPass1();
-                                                       if (vr != VerificationResult.VR_OK){
-                                                               throw new ClassConstraintException("Code attribute '"+tostring(obj)+"' (method '"+m+"') has an exception_table entry '"+tostring(exc_table[i])+"' that references '"+cname+"' as an Exception but '"+e.getSuperclassName()+"' in the ancestor hierachy does not pass verification pass 1: "+vr);
-                                                       }
-                                                       else{
+                                                       if (vr != VerificationResult.VR_OK) {
+                                                               throw new ClassConstraintException("Code attribute '" + tostring(obj) + "' (method '" + m
+                                                                               + "') has an exception_table entry '" + tostring(exc_table[i]) + "' that references '"
+                                                                               + cname + "' as an Exception but '" + e.getSuperclassName()
+                                                                               + "' in the ancestor hierachy does not pass verification pass 1: " + vr);
+                                                       } else {
                                                                e = Repository.lookupClass(e.getSuperclassName());
                                                        }
                                                }
-                                               if (e != t) throw new ClassConstraintException("Code attribute '"+tostring(obj)+"' (method '"+m+"') has an exception_table entry '"+tostring(exc_table[i])+"' that references '"+cname+"' as an Exception but it is not a subclass of '"+t.getClassName()+"'.");
+                                               if (e != t)
+                                                       throw new ClassConstraintException("Code attribute '" + tostring(obj) + "' (method '" + m
+                                                                       + "') has an exception_table entry '" + tostring(exc_table[i]) + "' that references '" + cname
+                                                                       + "' as an Exception but it is not a subclass of '" + t.getClassName() + "'.");
                                        }
                                }
                        }
@@ -905,190 +992,226 @@ public final class Pass2Verifier extends PassVerifier implements Constants{
                        // TODO: rework it.
                        int method_number = -1;
                        Method[] ms = Repository.lookupClass(myOwner.getClassName()).getMethods();
-                       for (int mn=0; mn<ms.length; mn++){
-                               if (m == ms[mn]){
+                       for (int mn = 0; mn < ms.length; mn++) {
+                               if (m == ms[mn]) {
                                        method_number = mn;
                                        break;
                                }
                        }
-                       if (method_number < 0){ // Mmmmh. Can we be sure BCEL does not sometimes instantiate new objects?
-                               throw new AssertionViolatedException("Could not find a known BCEL Method object in the corresponding BCEL JavaClass object.");
+                       if (method_number < 0) { // Mmmmh. Can we be sure BCEL does not sometimes instantiate new objects?
+                               throw new AssertionViolatedException(
+                                               "Could not find a known BCEL Method object in the corresponding BCEL JavaClass object.");
                        }
                        localVariablesInfos[method_number] = new LocalVariablesInfo(obj.getMaxLocals());
 
                        int num_of_lvt_attribs = 0;
                        // Now iterate through the attributes the Code attribute has.
                        Attribute[] atts = obj.getAttributes();
-                       for (int a=0; a<atts.length; a++){
-                               if ((! (atts[a] instanceof LineNumberTable)) &&
-                                   (! (atts[a] instanceof LocalVariableTable))){
-                                       addMessage("Attribute '"+tostring(atts[a])+"' as an attribute of Code attribute '"+tostring(obj)+"' (method '"+m+"') is unknown and will therefore be ignored.");
-                               }
-                               else{// LineNumberTable or LocalVariableTable
-                                       addMessage("Attribute '"+tostring(atts[a])+"' as an attribute of Code attribute '"+tostring(obj)+"' (method '"+m+"') will effectively be ignored and is only useful for debuggers and such.");
+                       for (int a = 0; a < atts.length; a++) {
+                               if ((!(atts[a] instanceof LineNumberTable)) && (!(atts[a] instanceof LocalVariableTable))) {
+                                       addMessage("Attribute '" + tostring(atts[a]) + "' as an attribute of Code attribute '" + tostring(obj)
+                                                       + "' (method '" + m + "') is unknown and will therefore be ignored.");
+                               } else {// LineNumberTable or LocalVariableTable
+                                       addMessage("Attribute '" + tostring(atts[a]) + "' as an attribute of Code attribute '" + tostring(obj)
+                                                       + "' (method '" + m + "') will effectively be ignored and is only useful for debuggers and such.");
                                }
 
-                               //LocalVariableTable check (partially delayed to Pass3a).
-                               //Here because its easier to collect the information of the
-                               //(possibly more than one) LocalVariableTables belonging to
-                               //one certain Code attribute.
-                               if (atts[a] instanceof LocalVariableTable){ // checks conforming to vmspec2 4.7.9
+                               // LocalVariableTable check (partially delayed to Pass3a).
+                               // Here because its easier to collect the information of the
+                               // (possibly more than one) LocalVariableTables belonging to
+                               // one certain Code attribute.
+                               if (atts[a] instanceof LocalVariableTable) { // checks conforming to vmspec2 4.7.9
 
                                        LocalVariableTable lvt = (LocalVariableTable) atts[a];
 
                                        checkIndex(lvt, lvt.getNameIndex(), CONST_Utf8);
 
-                                       String lvtname = ((ConstantUtf8) cp.getConstant(lvt.getNameIndex())).getBytes();
-                                       if (! lvtname.equals("LocalVariableTable")){
-                                               throw new ClassConstraintException("The LocalVariableTable attribute '"+tostring(lvt)+"' is not correctly named 'LocalVariableTable' but '"+lvtname+"'.");
+                                       String lvtname = ((ConstantUtf8) cp.getConstant(lvt.getNameIndex())).getValue();
+                                       if (!lvtname.equals("LocalVariableTable")) {
+                                               throw new ClassConstraintException("The LocalVariableTable attribute '" + tostring(lvt)
+                                                               + "' is not correctly named 'LocalVariableTable' but '" + lvtname + "'.");
                                        }
 
                                        Code code = obj;
 
-                                       //In JustIce, the check for correct offsets into the code array is delayed to Pass 3a.
+                                       // In JustIce, the check for correct offsets into the code array is delayed to Pass 3a.
                                        LocalVariable[] localvariables = lvt.getLocalVariableTable();
 
-                                       for (int i=0; i<localvariables.length; i++){
+                                       for (int i = 0; i < localvariables.length; i++) {
                                                checkIndex(lvt, localvariables[i].getNameIndex(), CONST_Utf8);
-                                               String localname = ((ConstantUtf8) cp.getConstant(localvariables[i].getNameIndex())).getBytes();
-                                               if (!validJavaIdentifier(localname)){
-                                                       throw new ClassConstraintException("LocalVariableTable '"+tostring(lvt)+"' references a local variable by the name '"+localname+"' which is not a legal Java simple name.");
+                                               String localname = ((ConstantUtf8) cp.getConstant(localvariables[i].getNameIndex())).getValue();
+                                               if (!validJavaIdentifier(localname)) {
+                                                       throw new ClassConstraintException("LocalVariableTable '" + tostring(lvt)
+                                                                       + "' references a local variable by the name '" + localname
+                                                                       + "' which is not a legal Java simple name.");
                                                }
 
                                                checkIndex(lvt, localvariables[i].getSignatureIndex(), CONST_Utf8);
-                                               String localsig  = ((ConstantUtf8) (cp.getConstant(localvariables[i].getSignatureIndex()))).getBytes(); // Local signature(=descriptor)
+                                               String localsig = ((ConstantUtf8) (cp.getConstant(localvariables[i].getSignatureIndex()))).getValue(); // Local
+                                               // signature(=descriptor)
                                                Type t;
-                                               try{
+                                               try {
                                                        t = Type.getType(localsig);
-                                               }
-                                               catch (ClassFormatError cfe){ // sometimes BCEL is a little harsh describing exceptional situations.
-                                                       throw new ClassConstraintException("Illegal descriptor (==signature) '"+localsig+"' used by LocalVariable '"+tostring(localvariables[i])+"' referenced by '"+tostring(lvt)+"'.");
+                                               } catch (ClassFormatError cfe) { // sometimes BCEL is a little harsh describing exceptional situations.
+                                                       throw new ClassConstraintException("Illegal descriptor (==signature) '" + localsig
+                                                                       + "' used by LocalVariable '" + tostring(localvariables[i]) + "' referenced by '"
+                                                                       + tostring(lvt) + "'.");
                                                }
                                                int localindex = localvariables[i].getIndex();
-                                               if ( ( (t==Type.LONG || t==Type.DOUBLE)? localindex+1:localindex) >= code.getMaxLocals()){
-                                                       throw new ClassConstraintException("LocalVariableTable attribute '"+tostring(lvt)+"' references a LocalVariable '"+tostring(localvariables[i])+"' with an index that exceeds the surrounding Code attribute's max_locals value of '"+code.getMaxLocals()+"'.");
+                                               if (((t == Type.LONG || t == Type.DOUBLE) ? localindex + 1 : localindex) >= code.getMaxLocals()) {
+                                                       throw new ClassConstraintException("LocalVariableTable attribute '" + tostring(lvt)
+                                                                       + "' references a LocalVariable '" + tostring(localvariables[i])
+                                                                       + "' with an index that exceeds the surrounding Code attribute's max_locals value of '"
+                                                                       + code.getMaxLocals() + "'.");
                                                }
 
-                                               try{
-                                                       localVariablesInfos[method_number].add(localindex, localname, localvariables[i].getStartPC(), localvariables[i].getLength(), t);
-                                               }
-                                               catch(LocalVariableInfoInconsistentException lviie){
-                                                       throw new ClassConstraintException("Conflicting information in LocalVariableTable '"+tostring(lvt)+"' found in Code attribute '"+tostring(obj)+"' (method '"+tostring(m)+"'). "+lviie.getMessage());
+                                               try {
+                                                       localVariablesInfos[method_number].add(localindex, localname, localvariables[i].getStartPC(),
+                                                                       localvariables[i].getLength(), t);
+                                               } catch (LocalVariableInfoInconsistentException lviie) {
+                                                       throw new ClassConstraintException("Conflicting information in LocalVariableTable '" + tostring(lvt)
+                                                                       + "' found in Code attribute '" + tostring(obj) + "' (method '" + tostring(m) + "'). "
+                                                                       + lviie.getMessage());
                                                }
                                        }// for all local variables localvariables[i] in the LocalVariableTable attribute atts[a] END
 
                                        num_of_lvt_attribs++;
-                                       if (num_of_lvt_attribs > obj.getMaxLocals()){
-                                               throw new ClassConstraintException("Number of LocalVariableTable attributes of Code attribute '"+tostring(obj)+"' (method '"+tostring(m)+"') exceeds number of local variable slots '"+obj.getMaxLocals()+"' ('There may be no more than one LocalVariableTable attribute per local variable in the Code attribute.').");
+                                       if (num_of_lvt_attribs > obj.getMaxLocals()) {
+                                               throw new ClassConstraintException(
+                                                               "Number of LocalVariableTable attributes of Code attribute '"
+                                                                               + tostring(obj)
+                                                                               + "' (method '"
+                                                                               + tostring(m)
+                                                                               + "') exceeds number of local variable slots '"
+                                                                               + obj.getMaxLocals()
+                                                                               + "' ('There may be no more than one LocalVariableTable attribute per local variable in the Code attribute.').");
                                        }
                                }// if atts[a] instanceof LocalVariableTable END
                        }// for all attributes atts[a] END
                }// visitCode(Code) END
 
-               public void visitExceptionTable(ExceptionTable obj){//vmspec2 4.7.4
+               public void visitExceptionTable(ExceptionTable obj) {// vmspec2 4.7.4
                        // incorrectly named, it's the Exceptions attribute (vmspec2 4.7.4)
                        checkIndex(obj, obj.getNameIndex(), CONST_Utf8);
 
-                       String name = ((ConstantUtf8) cp.getConstant(obj.getNameIndex())).getBytes();
-                       if (! name.equals("Exceptions")){
-                               throw new ClassConstraintException("The Exceptions attribute '"+tostring(obj)+"' is not correctly named 'Exceptions' but '"+name+"'.");
+                       String name = ((ConstantUtf8) cp.getConstant(obj.getNameIndex())).getValue();
+                       if (!name.equals("Exceptions")) {
+                               throw new ClassConstraintException("The Exceptions attribute '" + tostring(obj)
+                                               + "' is not correctly named 'Exceptions' but '" + name + "'.");
                        }
 
                        int[] exc_indices = obj.getExceptionIndexTable();
 
-                       for (int i=0; i<exc_indices.length; i++){
+                       for (int i = 0; i < exc_indices.length; i++) {
                                checkIndex(obj, exc_indices[i], CONST_Class);
 
                                ConstantClass cc = (ConstantClass) (cp.getConstant(exc_indices[i]));
-                               checkIndex(cc, cc.getNameIndex(), CONST_Utf8); // cannot be sure this ConstantClass has already been visited (checked)!
-                               String cname = ((ConstantUtf8) cp.getConstant(cc.getNameIndex())).getBytes().replace('/','.'); //convert internal notation on-the-fly to external notation
+                               checkIndex(cc, cc.getNameIndex(), CONST_Utf8); // cannot be sure this ConstantClass has already been visited
+                               // (checked)!
+                               String cname = ((ConstantUtf8) cp.getConstant(cc.getNameIndex())).getValue().replace('/', '.'); // convert internal
+                               // notation
+                               // on-the-fly to
+                               // external notation
 
                                Verifier v = VerifierFactory.getVerifier(cname);
                                VerificationResult vr = v.doPass1();
 
-                               if (vr != VerificationResult.VR_OK){
-                                       throw new ClassConstraintException("Exceptions attribute '"+tostring(obj)+"' references '"+cname+"' as an Exception but it does not pass verification pass 1: "+vr);
-                               }
-                               else{
+                               if (vr != VerificationResult.VR_OK) {
+                                       throw new ClassConstraintException("Exceptions attribute '" + tostring(obj) + "' references '" + cname
+                                                       + "' as an Exception but it does not pass verification pass 1: " + vr);
+                               } else {
                                        // We cannot safely trust any other "instanceof" mechanism. We need to transitively verify
                                        // the ancestor hierarchy.
                                        JavaClass e = Repository.lookupClass(cname);
                                        JavaClass t = Repository.lookupClass(Type.THROWABLE.getClassName());
                                        JavaClass o = Repository.lookupClass(Type.OBJECT.getClassName());
-                                       while (e != o){
-                                               if (e == t) break; // It's a subclass of Throwable, OKAY, leave.
+                                       while (e != o) {
+                                               if (e == t)
+                                                       break; // It's a subclass of Throwable, OKAY, leave.
 
                                                v = VerifierFactory.getVerifier(e.getSuperclassName());
                                                vr = v.doPass1();
-                                               if (vr != VerificationResult.VR_OK){
-                                                       throw new ClassConstraintException("Exceptions attribute '"+tostring(obj)+"' references '"+cname+"' as an Exception but '"+e.getSuperclassName()+"' in the ancestor hierachy does not pass verification pass 1: "+vr);
-                                               }
-                                               else{
+                                               if (vr != VerificationResult.VR_OK) {
+                                                       throw new ClassConstraintException("Exceptions attribute '" + tostring(obj) + "' references '" + cname
+                                                                       + "' as an Exception but '" + e.getSuperclassName()
+                                                                       + "' in the ancestor hierachy does not pass verification pass 1: " + vr);
+                                               } else {
                                                        e = Repository.lookupClass(e.getSuperclassName());
                                                }
                                        }
-                                       if (e != t) throw new ClassConstraintException("Exceptions attribute '"+tostring(obj)+"' references '"+cname+"' as an Exception but it is not a subclass of '"+t.getClassName()+"'.");
+                                       if (e != t)
+                                               throw new ClassConstraintException("Exceptions attribute '" + tostring(obj) + "' references '" + cname
+                                                               + "' as an Exception but it is not a subclass of '" + t.getClassName() + "'.");
                                }
                        }
                }
+
                // SYNTHETIC: see above
                // DEPRECATED: see above
-               //////////////////////////////////////////////////////////////
+               // ////////////////////////////////////////////////////////////
                // code_attribute-structure-ATTRIBUTES (vmspec2 4.7.3, 4.7) //
-               //////////////////////////////////////////////////////////////
-               public void visitLineNumberTable(LineNumberTable obj){//vmspec2 4.7.8
+               // ////////////////////////////////////////////////////////////
+               public void visitLineNumberTable(LineNumberTable obj) {// vmspec2 4.7.8
                        checkIndex(obj, obj.getNameIndex(), CONST_Utf8);
 
-                       String name = ((ConstantUtf8) cp.getConstant(obj.getNameIndex())).getBytes();
-                       if (! name.equals("LineNumberTable")){
-                               throw new ClassConstraintException("The LineNumberTable attribute '"+tostring(obj)+"' is not correctly named 'LineNumberTable' but '"+name+"'.");
+                       String name = ((ConstantUtf8) cp.getConstant(obj.getNameIndex())).getValue();
+                       if (!name.equals("LineNumberTable")) {
+                               throw new ClassConstraintException("The LineNumberTable attribute '" + tostring(obj)
+                                               + "' is not correctly named 'LineNumberTable' but '" + name + "'.");
                        }
 
-                       //In JustIce,this check is delayed to Pass 3a.
-                       //LineNumber[] linenumbers = obj.getLineNumberTable();
+                       // In JustIce,this check is delayed to Pass 3a.
+                       // LineNumber[] linenumbers = obj.getLineNumberTable();
                        // ...validity check...
 
                }
-               public void visitLocalVariableTable(LocalVariableTable obj){//vmspec2 4.7.9
-                       //In JustIce,this check is partially delayed to Pass 3a.
-                       //The other part can be found in the visitCode(Code) method.
+
+               public void visitLocalVariableTable(LocalVariableTable obj) {// vmspec2 4.7.9
+                       // In JustIce,this check is partially delayed to Pass 3a.
+                       // The other part can be found in the visitCode(Code) method.
                }
-               ////////////////////////////////////////////////////
+
+               // //////////////////////////////////////////////////
                // MISC-structure-ATTRIBUTES (vmspec2 4.7.1, 4.7) //
-               ////////////////////////////////////////////////////
-               public void visitUnknown(Unknown obj){//vmspec2 4.7.1
+               // //////////////////////////////////////////////////
+               public void visitUnknown(Unknown obj) {// vmspec2 4.7.1
                        // Represents an unknown attribute.
                        checkIndex(obj, obj.getNameIndex(), CONST_Utf8);
 
                        // Maybe only misnamed? Give a (warning) message.
-                       addMessage("Unknown attribute '"+tostring(obj)+"'. This attribute is not known in any context!");
+                       addMessage("Unknown attribute '" + tostring(obj) + "'. This attribute is not known in any context!");
                }
-               //////////
+
+               // ////////
                // BCEL //
-               //////////
-               public void visitLocalVariable(LocalVariable obj){
+               // ////////
+               public void visitLocalVariable(LocalVariable obj) {
                        // This does not represent an Attribute but is only
                        // related to internal BCEL data representation.
 
                        // see visitLocalVariableTable(LocalVariableTable)
                }
-               public void visitCodeException(CodeException obj){
+
+               public void visitCodeException(CodeException obj) {
                        // Code constraints are checked in Pass3 (3a and 3b).
                        // This does not represent an Attribute but is only
                        // related to internal BCEL data representation.
 
                        // see visitCode(Code)
                }
-               public void visitConstantPool(ConstantPool obj){
+
+               public void visitConstantPool(ConstantPool obj) {
                        // No need to. We're piggybacked by the DescendingVisitor.
                        // This does not represent an Attribute but is only
                        // related to internal BCEL data representation.
                }
-               public void visitInnerClass(InnerClass obj){
+
+               public void visitInnerClass(InnerClass obj) {
                        // This does not represent an Attribute but is only
                        // related to internal BCEL data representation.
                }
-               public void visitLineNumber(LineNumber obj){
+
+               public void visitLineNumber(LineNumber obj) {
                        // This does not represent an Attribute but is only
                        // related to internal BCEL data representation.
 
@@ -1097,277 +1220,271 @@ public final class Pass2Verifier extends PassVerifier implements Constants{
        }
 
        /**
-        * Ensures that the ConstantCP-subclassed entries of the constant
-        * pool are valid. According to "Yellin: Low Level Security in Java",
-        * this method does not verify the existence of referenced entities
-        * (such as classes) but only the formal correctness (such as well-formed
-        * signatures).
-   * The visitXXX() methods throw ClassConstraintException instances otherwise.
-        * <B>Precondition: index-style cross referencing in the constant
-        * pool must be valid. Simply invoke constant_pool_entries_satisfy_static_constraints()
-        * before.</B>
-        *
+        * Ensures that the ConstantCP-subclassed entries of the constant pool are valid. According to
+        * "Yellin: Low Level Security in Java", this method does not verify the existence of referenced entities (such as classes) but
+        * only the formal correctness (such as well-formed signatures). The visitXXX() methods throw ClassConstraintException instances
+        * otherwise. <B>Precondition: index-style cross referencing in the constant pool must be valid. Simply invoke
+        * constant_pool_entries_satisfy_static_constraints() before.</B>
+        * 
         * @throws ClassConstraintException otherwise.
         * @see #constant_pool_entries_satisfy_static_constraints()
         */
-       private void field_and_method_refs_are_valid(){
+       private void field_and_method_refs_are_valid() {
                JavaClass jc = Repository.lookupClass(myOwner.getClassName());
                DescendingVisitor v = new DescendingVisitor(jc, new FAMRAV_Visitor(jc));
                v.visit();
        }
 
        /**
-        * A Visitor class that ensures the ConstantCP-subclassed entries
-        * of the constant pool are valid.
-   * <B>Precondition: index-style cross referencing in the constant
-   * pool must be valid.</B>
-        *
-   * @see #constant_pool_entries_satisfy_static_constraints()
+        * A Visitor class that ensures the ConstantCP-subclassed entries of the constant pool are valid. <B>Precondition: index-style
+        * cross referencing in the constant pool must be valid.</B>
+        * 
+        * @see #constant_pool_entries_satisfy_static_constraints()
         * @see org.aspectj.apache.bcel.classfile.ConstantCP
         */
-       private class FAMRAV_Visitor extends EmptyClassVisitor{
+       private class FAMRAV_Visitor extends EmptyClassVisitor {
                private final ConstantPool cp; // ==jc.getConstantPool() -- only here to save typing work.
-               private FAMRAV_Visitor(JavaClass _jc){
+
+               private FAMRAV_Visitor(JavaClass _jc) {
                        cp = _jc.getConstantPool();
                }
-               
-               public void visitConstantFieldref(ConstantFieldref obj){
-                       if (obj.getTag() != Constants.CONSTANT_Fieldref){
-                               throw new ClassConstraintException("ConstantFieldref '"+tostring(obj)+"' has wrong tag!");
+
+               public void visitConstantFieldref(ConstantFieldref obj) {
+                       if (obj.getTag() != Constants.CONSTANT_Fieldref) {
+                               throw new ClassConstraintException("ConstantFieldref '" + tostring(obj) + "' has wrong tag!");
                        }
                        int name_and_type_index = obj.getNameAndTypeIndex();
                        ConstantNameAndType cnat = (ConstantNameAndType) (cp.getConstant(name_and_type_index));
-                       String name = ((ConstantUtf8) (cp.getConstant(cnat.getNameIndex()))).getBytes(); // Field or Method name
-                       if (!validFieldName(name)){
-                               throw new ClassConstraintException("Invalid field name '"+name+"' referenced by '"+tostring(obj)+"'.");
+                       String name = ((ConstantUtf8) (cp.getConstant(cnat.getNameIndex()))).getValue(); // Field or Method name
+                       if (!validFieldName(name)) {
+                               throw new ClassConstraintException("Invalid field name '" + name + "' referenced by '" + tostring(obj) + "'.");
                        }
-                       
+
                        int class_index = obj.getClassIndex();
                        ConstantClass cc = (ConstantClass) (cp.getConstant(class_index));
-                       String className = ((ConstantUtf8) (cp.getConstant(cc.getNameIndex()))).getBytes(); // Class Name in internal form
-                       if (! validClassName(className)){
-                               throw new ClassConstraintException("Illegal class name '"+className+"' used by '"+tostring(obj)+"'.");
+                       String className = ((ConstantUtf8) (cp.getConstant(cc.getNameIndex()))).getValue(); // Class Name in internal form
+                       if (!validClassName(className)) {
+                               throw new ClassConstraintException("Illegal class name '" + className + "' used by '" + tostring(obj) + "'.");
                        }
 
-                       String sig  = ((ConstantUtf8) (cp.getConstant(cnat.getSignatureIndex()))).getBytes(); // Field or Method signature(=descriptor)
-                                               
-                       try{
+                       String sig = ((ConstantUtf8) (cp.getConstant(cnat.getSignatureIndex()))).getValue(); // Field or Method
+                       // signature(=descriptor)
+
+                       try {
                                Type.getType(sig); /* Don't need the return value */
-                       }
-                       catch (ClassFormatError cfe){
+                       } catch (ClassFormatError cfe) {
                                // Well, BCEL sometimes is a little harsh describing exceptional situations.
-                               throw new ClassConstraintException("Illegal descriptor (==signature) '"+sig+"' used by '"+tostring(obj)+"'.");
+                               throw new ClassConstraintException("Illegal descriptor (==signature) '" + sig + "' used by '" + tostring(obj)
+                                               + "'.");
                        }
                }
 
-               public void visitConstantMethodref(ConstantMethodref obj){
-                       if (obj.getTag() != Constants.CONSTANT_Methodref){
-                               throw new ClassConstraintException("ConstantMethodref '"+tostring(obj)+"' has wrong tag!");
+               public void visitConstantMethodref(ConstantMethodref obj) {
+                       if (obj.getTag() != Constants.CONSTANT_Methodref) {
+                               throw new ClassConstraintException("ConstantMethodref '" + tostring(obj) + "' has wrong tag!");
                        }
                        int name_and_type_index = obj.getNameAndTypeIndex();
                        ConstantNameAndType cnat = (ConstantNameAndType) (cp.getConstant(name_and_type_index));
-                       String name = ((ConstantUtf8) (cp.getConstant(cnat.getNameIndex()))).getBytes(); // Field or Method name
-                       if (!validClassMethodName(name)){
-                               throw new ClassConstraintException("Invalid (non-interface) method name '"+name+"' referenced by '"+tostring(obj)+"'.");
+                       String name = ((ConstantUtf8) (cp.getConstant(cnat.getNameIndex()))).getValue(); // Field or Method name
+                       if (!validClassMethodName(name)) {
+                               throw new ClassConstraintException("Invalid (non-interface) method name '" + name + "' referenced by '"
+                                               + tostring(obj) + "'.");
                        }
 
                        int class_index = obj.getClassIndex();
                        ConstantClass cc = (ConstantClass) (cp.getConstant(class_index));
-                       String className = ((ConstantUtf8) (cp.getConstant(cc.getNameIndex()))).getBytes(); // Class Name in internal form
-                       if (! validClassName(className)){
-                               throw new ClassConstraintException("Illegal class name '"+className+"' used by '"+tostring(obj)+"'.");
+                       String className = ((ConstantUtf8) (cp.getConstant(cc.getNameIndex()))).getValue(); // Class Name in internal form
+                       if (!validClassName(className)) {
+                               throw new ClassConstraintException("Illegal class name '" + className + "' used by '" + tostring(obj) + "'.");
                        }
 
-                       String sig  = ((ConstantUtf8) (cp.getConstant(cnat.getSignatureIndex()))).getBytes(); // Field or Method signature(=descriptor)
-                                               
-                       try{
-                               Type   t  = Type.getReturnType(sig);
-                               if ( name.equals(CONSTRUCTOR_NAME) && (t != Type.VOID) ){
+                       String sig = ((ConstantUtf8) (cp.getConstant(cnat.getSignatureIndex()))).getValue(); // Field or Method
+                       // signature(=descriptor)
+
+                       try {
+                               Type t = Type.getReturnType(sig);
+                               if (name.equals(CONSTRUCTOR_NAME) && (t != Type.VOID)) {
                                        throw new ClassConstraintException("Instance initialization method must have VOID return type.");
                                }
-                       }
-                       catch (ClassFormatError cfe){
+                       } catch (ClassFormatError cfe) {
                                // Well, BCEL sometimes is a little harsh describing exceptional situations.
-                               throw new ClassConstraintException("Illegal descriptor (==signature) '"+sig+"' used by '"+tostring(obj)+"'.");
+                               throw new ClassConstraintException("Illegal descriptor (==signature) '" + sig + "' used by '" + tostring(obj)
+                                               + "'.");
                        }
                }
 
-               public void visitConstantInterfaceMethodref(ConstantInterfaceMethodref obj){
-                       if (obj.getTag() != Constants.CONSTANT_InterfaceMethodref){
-                               throw new ClassConstraintException("ConstantInterfaceMethodref '"+tostring(obj)+"' has wrong tag!");
+               public void visitConstantInterfaceMethodref(ConstantInterfaceMethodref obj) {
+                       if (obj.getTag() != Constants.CONSTANT_InterfaceMethodref) {
+                               throw new ClassConstraintException("ConstantInterfaceMethodref '" + tostring(obj) + "' has wrong tag!");
                        }
                        int name_and_type_index = obj.getNameAndTypeIndex();
                        ConstantNameAndType cnat = (ConstantNameAndType) (cp.getConstant(name_and_type_index));
-                       String name = ((ConstantUtf8) (cp.getConstant(cnat.getNameIndex()))).getBytes(); // Field or Method name
-                       if (!validInterfaceMethodName(name)){
-                               throw new ClassConstraintException("Invalid (interface) method name '"+name+"' referenced by '"+tostring(obj)+"'.");
+                       String name = ((ConstantUtf8) (cp.getConstant(cnat.getNameIndex()))).getValue(); // Field or Method name
+                       if (!validInterfaceMethodName(name)) {
+                               throw new ClassConstraintException("Invalid (interface) method name '" + name + "' referenced by '" + tostring(obj)
+                                               + "'.");
                        }
 
                        int class_index = obj.getClassIndex();
                        ConstantClass cc = (ConstantClass) (cp.getConstant(class_index));
-                       String className = ((ConstantUtf8) (cp.getConstant(cc.getNameIndex()))).getBytes(); // Class Name in internal form
-                       if (! validClassName(className)){
-                               throw new ClassConstraintException("Illegal class name '"+className+"' used by '"+tostring(obj)+"'.");
+                       String className = ((ConstantUtf8) (cp.getConstant(cc.getNameIndex()))).getValue(); // Class Name in internal form
+                       if (!validClassName(className)) {
+                               throw new ClassConstraintException("Illegal class name '" + className + "' used by '" + tostring(obj) + "'.");
                        }
 
-                       String sig  = ((ConstantUtf8) (cp.getConstant(cnat.getSignatureIndex()))).getBytes(); // Field or Method signature(=descriptor)
-                                               
-                       try{
-                               Type   t  = Type.getReturnType(sig);
-                               if ( name.equals(STATIC_INITIALIZER_NAME) && (t != Type.VOID) ){
-                                       addMessage("Class or interface initialization method '"+STATIC_INITIALIZER_NAME+"' usually has VOID return type instead of '"+t+"'. Note this is really not a requirement of The Java Virtual Machine Specification, Second Edition.");
+                       String sig = ((ConstantUtf8) (cp.getConstant(cnat.getSignatureIndex()))).getValue(); // Field or Method
+                       // signature(=descriptor)
+
+                       try {
+                               Type t = Type.getReturnType(sig);
+                               if (name.equals(STATIC_INITIALIZER_NAME) && (t != Type.VOID)) {
+                                       addMessage("Class or interface initialization method '" + STATIC_INITIALIZER_NAME
+                                                       + "' usually has VOID return type instead of '" + t
+                                                       + "'. Note this is really not a requirement of The Java Virtual Machine Specification, Second Edition.");
                                }
-                       }
-                       catch (ClassFormatError cfe){
+                       } catch (ClassFormatError cfe) {
                                // Well, BCEL sometimes is a little harsh describing exceptional situations.
-                               throw new ClassConstraintException("Illegal descriptor (==signature) '"+sig+"' used by '"+tostring(obj)+"'.");
+                               throw new ClassConstraintException("Illegal descriptor (==signature) '" + sig + "' used by '" + tostring(obj)
+                                               + "'.");
                        }
 
                }
-               
+
        }
 
        /**
-        * This method returns true if and only if the supplied String
-        * represents a valid Java class name.
+        * This method returns true if and only if the supplied String represents a valid Java class name.
         */
-       private static final boolean validClassName(String name){
-        /*
-         * TODO: implement.
-                * Are there any restrictions?
-         */
+       private static final boolean validClassName(String name) {
+               /*
+                * TODO: implement. Are there any restrictions?
+                */
                return true;
        }
+
        /**
-        * This method returns true if and only if the supplied String
-        * represents a valid method name.
-        * This is basically the same as a valid identifier name in the
-        * Java programming language, but the special name for
-        * the instance initialization method is allowed and the special name
-        * for the class/interface initialization method may be allowed.
+        * This method returns true if and only if the supplied String represents a valid method name. This is basically the same as a
+        * valid identifier name in the Java programming language, but the special name for the instance initialization method is
+        * allowed and the special name for the class/interface initialization method may be allowed.
         */
-       private static boolean validMethodName(String name, boolean allowStaticInit){
-               if (validJavaLangMethodName(name)) return true;
-               
-               if (allowStaticInit){
+       private static boolean validMethodName(String name, boolean allowStaticInit) {
+               if (validJavaLangMethodName(name))
+                       return true;
+
+               if (allowStaticInit) {
                        return (name.equals(CONSTRUCTOR_NAME) || name.equals(STATIC_INITIALIZER_NAME));
-               }
-               else{
+               } else {
                        return name.equals(CONSTRUCTOR_NAME);
                }
        }
 
        /**
-        * This method returns true if and only if the supplied String
-        * represents a valid method name that may be referenced by
+        * This method returns true if and only if the supplied String represents a valid method name that may be referenced by
         * ConstantMethodref objects.
         */
-       private static boolean validClassMethodName(String name){
+       private static boolean validClassMethodName(String name) {
                return validMethodName(name, false);
        }
 
        /**
-        * This method returns true if and only if the supplied String
-        * represents a valid Java programming language method name stored as a simple
-        * (non-qualified) name.
-        * Conforming to: The Java Virtual Machine Specification, Second Edition, §2.7, §2.7.1, §2.2.
+        * This method returns true if and only if the supplied String represents a valid Java programming language method name stored
+        * as a simple (non-qualified) name. Conforming to: The Java Virtual Machine Specification, Second Edition, §2.7, §2.7.1, §2.2.
         */
-       private static boolean validJavaLangMethodName(String name){
-               if (!Character.isJavaIdentifierStart(name.charAt(0))) return false;
-               
-               for (int i=1; i<name.length(); i++){
-                       if (!Character.isJavaIdentifierPart(name.charAt(i))) return false;
+       private static boolean validJavaLangMethodName(String name) {
+               if (!Character.isJavaIdentifierStart(name.charAt(0)))
+                       return false;
+
+               for (int i = 1; i < name.length(); i++) {
+                       if (!Character.isJavaIdentifierPart(name.charAt(i)))
+                               return false;
                }
                return true;
        }
 
        /**
-        * This method returns true if and only if the supplied String
-        * represents a valid Java interface method name that may be
+        * This method returns true if and only if the supplied String represents a valid Java interface method name that may be
         * referenced by ConstantInterfaceMethodref objects.
         */
-       private static boolean validInterfaceMethodName(String name){
+       private static boolean validInterfaceMethodName(String name) {
                // I guess we should assume special names forbidden here.
-               if (name.startsWith("<")) return false;
+               if (name.startsWith("<"))
+                       return false;
                return validJavaLangMethodName(name);
        }
 
        /**
-        * This method returns true if and only if the supplied String
-        * represents a valid Java identifier (so-called simple name).
+        * This method returns true if and only if the supplied String represents a valid Java identifier (so-called simple name).
         */
-       private static boolean validJavaIdentifier(String name){
+       private static boolean validJavaIdentifier(String name) {
                // vmspec2 2.7, vmspec2 2.2
-               if (!Character.isJavaIdentifierStart(name.charAt(0))) return false;
-               
-               for (int i=1; i<name.length(); i++){
-                       if (!Character.isJavaIdentifierPart(name.charAt(i))) return false;
+               if (!Character.isJavaIdentifierStart(name.charAt(0)))
+                       return false;
+
+               for (int i = 1; i < name.length(); i++) {
+                       if (!Character.isJavaIdentifierPart(name.charAt(i)))
+                               return false;
                }
                return true;
        }
 
        /**
-        * This method returns true if and only if the supplied String
-        * represents a valid Java field name.
+        * This method returns true if and only if the supplied String represents a valid Java field name.
         */
-       private static boolean validFieldName(String name){
+       private static boolean validFieldName(String name) {
                // vmspec2 2.7, vmspec2 2.2
                return validJavaIdentifier(name);
        }
 
        /**
-        * This class serves for finding out if a given JavaClass' ConstantPool
-        * references an Inner Class.
-        * The Java Virtual Machine Specification, Second Edition is not very precise
-        * about when an "InnerClasses" attribute has to appear. However, it states that
-        * there has to be exactly one InnerClasses attribute in the ClassFile structure
-        * if the constant pool of a class or interface refers to any class or interface
-        * "that is not a member of a package". Sun does not mean "member of the default
-        * package". In "Inner Classes Specification" they point out how a "bytecode name"
-        * is derived so one has to deduce what a class name of a class "that is not a
-        * member of a package" looks like: there is at least one character in the byte-
-        * code name that cannot be part of a legal Java Language Class name (and not equal
-        * to '/'). This assumption is wrong as the delimiter is '$' for which
-        * Character.isJavaIdentifierPart() == true.
-        * Hence, you really run into trouble if you have a toplevel class called
-        * "A$XXX" and another toplevel class called "A" with in inner class called "XXX".
-        * JustIce cannot repair this; please note that existing verifiers at this
-        * time even fail to detect missing InnerClasses attributes in pass 2.
+        * This class serves for finding out if a given JavaClass' ConstantPool references an Inner Class. The Java Virtual Machine
+        * Specification, Second Edition is not very precise about when an "InnerClasses" attribute has to appear. However, it states
+        * that there has to be exactly one InnerClasses attribute in the ClassFile structure if the constant pool of a class or
+        * interface refers to any class or interface "that is not a member of a package". Sun does not mean "member of the default
+        * package". In "Inner Classes Specification" they point out how a "bytecode name" is derived so one has to deduce what a class
+        * name of a class "that is not a member of a package" looks like: there is at least one character in the byte- code name that
+        * cannot be part of a legal Java Language Class name (and not equal to '/'). This assumption is wrong as the delimiter is '$'
+        * for which Character.isJavaIdentifierPart() == true. Hence, you really run into trouble if you have a toplevel class called
+        * "A$XXX" and another toplevel class called "A" with in inner class called "XXX". JustIce cannot repair this; please note that
+        * existing verifiers at this time even fail to detect missing InnerClasses attributes in pass 2.
         */
-       private class InnerClassDetector extends EmptyClassVisitor{
+       private class InnerClassDetector extends EmptyClassVisitor {
                private boolean hasInnerClass = false;
                private JavaClass jc;
                private ConstantPool cp;
-               private InnerClassDetector(){} // Don't use.
+
+               private InnerClassDetector() {
+               } // Don't use.
+
                /** Constructs an InnerClassDetector working on the JavaClass _jc. */
-               public InnerClassDetector(JavaClass _jc){
+               public InnerClassDetector(JavaClass _jc) {
                        jc = _jc;
                        cp = jc.getConstantPool();
                        (new DescendingVisitor(jc, this)).visit();
                }
+
                /**
-                * Returns if the JavaClass this InnerClassDetector is working on
-                * has an Inner Class reference in its constant pool.
+                * Returns if the JavaClass this InnerClassDetector is working on has an Inner Class reference in its constant pool.
                 */
-               public boolean innerClassReferenced(){
+               public boolean innerClassReferenced() {
                        return hasInnerClass;
                }
+
                /** This method casually visits ConstantClass references. */
-               public void visitConstantClass(ConstantClass obj){
+               public void visitConstantClass(ConstantClass obj) {
                        Constant c = cp.getConstant(obj.getNameIndex());
-                       if (c instanceof ConstantUtf8){ //Ignore the case where it's not a ConstantUtf8 here, we'll find out later.
-                               String classname = ((ConstantUtf8) c).getBytes();
-                               if (classname.startsWith(jc.getClassName().replace('.','/')+"$")){
+                       if (c instanceof ConstantUtf8) { // Ignore the case where it's not a ConstantUtf8 here, we'll find out later.
+                               String classname = ((ConstantUtf8) c).getValue();
+                               if (classname.startsWith(jc.getClassName().replace('.', '/') + "$")) {
                                        hasInnerClass = true;
                                }
                        }
                }
        }
-       
+
        /**
         * This method is here to save typing work and improve code readability.
         */
-       private static String tostring(Node n){
+       private static String tostring(Node n) {
                return new StringRepresentation(n).toString();
        }
 }
index b6ae90b20489078c88d79c68815fa1c65c4924d7..8afbdb5eaf1dc435012677efa69d5bb8ba6017a1 100644 (file)
@@ -111,7 +111,7 @@ import org.aspectj.apache.bcel.verifier.exc.StaticCodeInstructionOperandConstrai
  * This PassVerifier verifies a class file according to pass 3, static part as described in The Java Virtual Machine Specification,
  * 2nd edition. More detailed information is to be found at the do_verify() method's documentation.
  * 
- * @version $Id: Pass3aVerifier.java,v 1.4 2008/08/28 00:02:13 aclement Exp $
+ * @version $Id: Pass3aVerifier.java,v 1.5 2009/09/10 15:35:06 aclement Exp $
  * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
  * @see #do_verify()
  */
@@ -151,6 +151,7 @@ public final class Pass3aVerifier extends PassVerifier {
         * 
         * @throws InvalidMethodException if the method to verify does not exist.
         */
+       @Override
        public VerificationResult do_verify() {
                if (myOwner.doPass2().equals(VerificationResult.VR_OK)) {
                        // Okay, class file was loaded correctly by Pass 1
@@ -482,6 +483,7 @@ public final class Pass3aVerifier extends PassVerifier {
                /**
                 * Assures the generic preconditions of a LoadClass instance. The referenced class is loaded and pass2-verified.
                 */
+               @Override
                public void visitLoadClass(Instruction o) {
                        ObjectType t = o.getLoadClassType(cpg);
                        if (t != null) {// null means "no class is loaded"
@@ -503,6 +505,7 @@ public final class Pass3aVerifier extends PassVerifier {
 
                /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
                // LDC and LDC_W (LDC_W is a subclass of LDC in BCEL's model)
+               @Override
                public void visitLDC(Instruction o) {
                        indexValid(o, o.getIndex());
                        Constant c = cpg.getConstant(o.getIndex());
@@ -515,6 +518,7 @@ public final class Pass3aVerifier extends PassVerifier {
 
                /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
                // LDC2_W
+               @Override
                public void visitLDC2_W(Instruction o) {
                        indexValid(o, o.getIndex());
                        Constant c = cpg.getConstant(o.getIndex());
@@ -571,6 +575,7 @@ public final class Pass3aVerifier extends PassVerifier {
                }
 
                /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
+               @Override
                public void visitInvokeInstruction(InvokeInstruction o) {
                        indexValid(o, o.getIndex());
                        if (o.getOpcode() == Constants.INVOKEVIRTUAL || o.getOpcode() == Constants.INVOKESPECIAL
@@ -582,10 +587,10 @@ public final class Pass3aVerifier extends PassVerifier {
                                        // Constants are okay due to pass2.
                                        ConstantNameAndType cnat = (ConstantNameAndType) cpg.getConstant(((ConstantMethodref) c).getNameAndTypeIndex());
                                        ConstantUtf8 cutf8 = (ConstantUtf8) cpg.getConstant(cnat.getNameIndex());
-                                       if (cutf8.getBytes().equals(Constants.CONSTRUCTOR_NAME) && !(o.getOpcode() == Constants.INVOKESPECIAL)) {
+                                       if (cutf8.getValue().equals(Constants.CONSTRUCTOR_NAME) && !(o.getOpcode() == Constants.INVOKESPECIAL)) {
                                                constraintViolated(o, "Only INVOKESPECIAL is allowed to invoke instance initialization methods.");
                                        }
-                                       if (!cutf8.getBytes().equals(Constants.CONSTRUCTOR_NAME) && cutf8.getBytes().startsWith("<")) {
+                                       if (!cutf8.getValue().equals(Constants.CONSTRUCTOR_NAME) && cutf8.getValue().startsWith("<")) {
                                                constraintViolated(
                                                                o,
                                                                "No method with a name beginning with '<' other than the instance initialization methods may be called by the method invocation instructions.");
@@ -604,7 +609,7 @@ public final class Pass3aVerifier extends PassVerifier {
                                // Invoked method must not be <init> or <clinit>
                                ConstantNameAndType cnat = (ConstantNameAndType) cpg.getConstant(((ConstantInterfaceMethodref) c)
                                                .getNameAndTypeIndex());
-                               String name = ((ConstantUtf8) cpg.getConstant(cnat.getNameIndex())).getBytes();
+                               String name = ((ConstantUtf8) cpg.getConstant(cnat.getNameIndex())).getValue();
                                if (name.equals(Constants.CONSTRUCTOR_NAME)) {
                                        constraintViolated(o, "Method to invoke must not be '" + Constants.CONSTRUCTOR_NAME + "'.");
                                }
@@ -647,6 +652,7 @@ public final class Pass3aVerifier extends PassVerifier {
                }
 
                /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
+               @Override
                public void visitINSTANCEOF(Instruction o) {
                        indexValid(o, o.getIndex());
                        Constant c = cpg.getConstant(o.getIndex());
@@ -656,6 +662,7 @@ public final class Pass3aVerifier extends PassVerifier {
                }
 
                /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
+               @Override
                public void visitCHECKCAST(Instruction o) {
                        indexValid(o, o.getIndex());
                        Constant c = cpg.getConstant(o.getIndex());
@@ -665,6 +672,7 @@ public final class Pass3aVerifier extends PassVerifier {
                }
 
                /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
+               @Override
                public void visitNEW(Instruction o) {
                        indexValid(o, o.getIndex());
                        Constant c = cpg.getConstant(o.getIndex());
@@ -672,7 +680,7 @@ public final class Pass3aVerifier extends PassVerifier {
                                constraintViolated(o, "Expecting a CONSTANT_Class operand, but found a '" + c + "'.");
                        } else {
                                ConstantUtf8 cutf8 = (ConstantUtf8) cpg.getConstant(((ConstantClass) c).getNameIndex());
-                               Type t = Type.getType("L" + cutf8.getBytes() + ";");
+                               Type t = Type.getType("L" + cutf8.getValue() + ";");
                                if (t instanceof ArrayType) {
                                        constraintViolated(o, "NEW must not be used to create an array.");
                                }