svn commit: r386056 [22/28] - in /jakarta/bcel/trunk: examples/ examples/Mini/ src/java/org/apache/bcel/ src/java/org/apache/bcel/classfile/ src/java/org/apache/bcel/generic/ src/java/org/apache/bcel/util/ src/java/org/apache/bcel/verifier/ src/java/or...

[email protected]
Newsgroups gmane.comp.jakarta.bcel.devel
Message-ID <[email protected]>
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/POP2.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/POP2.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/POP2.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/POP2.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License. 
  *
- */ 
+ */
 package org.apache.bcel.generic;
 
-
 /**
  * POP2 - Pop two top operand stack words
  *
@@ -26,23 +25,24 @@
  * @author  <A HREF="mailto:[email protected]">M. Dahm</A>
  */
 public class POP2 extends StackInstruction implements PopInstruction {
-  public POP2() {
-    super(org.apache.bcel.Constants.POP2);
-  }
+
+    public POP2() {
+        super(org.apache.bcel.Constants.POP2);
+    }
 
 
-  /**
-   * Call corresponding visitor method(s). The order is:
-   * Call visitor methods of implemented interfaces first, then
-   * call methods according to the class hierarchy in descending order,
-   * i.e., the most specific visitXXX() call comes last.
-   *
-   * @param v Visitor object
-   */
-  public void accept(Visitor v) {
-    v.visitStackConsumer(this);
-    v.visitPopInstruction(this);
-    v.visitStackInstruction(this);
-    v.visitPOP2(this);
-  }
+    /**
+     * Call corresponding visitor method(s). The order is:
+     * Call visitor methods of implemented interfaces first, then
+     * call methods according to the class hierarchy in descending order,
+     * i.e., the most specific visitXXX() call comes last.
+     *
+     * @param v Visitor object
+     */
+    public void accept( Visitor v ) {
+        v.visitStackConsumer(this);
+        v.visitPopInstruction(this);
+        v.visitStackInstruction(this);
+        v.visitPOP2(this);
+    }
 }

Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/PUSH.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/PUSH.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/PUSH.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/PUSH.java Wed Mar 15 03:31:56 2006
@@ -13,7 +13,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License. 
  *
- */ 
+ */
 package org.apache.bcel.generic;
 
 import org.apache.bcel.Constants;
@@ -25,137 +25,154 @@
  * @version $Id$
  * @author  <A HREF="mailto:[email protected]">M. Dahm</A>
  */
-public final class PUSH
-  implements CompoundInstruction, VariableLengthInstruction, InstructionConstants
-{
-  private Instruction instruction;
-
-  /**
-   * This constructor also applies for values of type short, char, byte 
-   *
-   * @param cp Constant pool
-   * @param value to be pushed 
-   */
-  public PUSH(ConstantPoolGen cp, int value) {
-    if((value >= -1) && (value <= 5)) // Use ICONST_n
-      instruction = INSTRUCTIONS[Constants.ICONST_0 + value];
-    else if((value >= -128) && (value <= 127)) // Use BIPUSH
-      instruction = new BIPUSH((byte)value);
-    else if((value >= -32768) && (value <= 32767)) // Use SIPUSH
-      instruction = new SIPUSH((short)value);
-    else // If everything fails create a Constant pool entry
-      instruction = new LDC(cp.addInteger(value));
-  }
-
-  /**
-   * @param cp Constant pool
-   * @param value to be pushed 
-   */
-  public PUSH(ConstantPoolGen cp, boolean value) {
-    instruction = INSTRUCTIONS[Constants.ICONST_0 + (value? 1 : 0)];
-  }
-
-  /**
-   * @param cp Constant pool
-   * @param value to be pushed 
-   */
-  public PUSH(ConstantPoolGen cp, float value) {
-    if(value == 0.0)
-      instruction = FCONST_0;
-    else if(value == 1.0)
-      instruction = FCONST_1;
-    else if(value == 2.0)
-      instruction = FCONST_2;
-    else // Create a Constant pool entry
-      instruction = new LDC(cp.addFloat(value));
-  }
-
-  /**
-   * @param cp Constant pool
-   * @param value to be pushed 
-   */
-  public PUSH(ConstantPoolGen cp, long value) {
-    if(value == 0)
-      instruction = LCONST_0;
-    else if(value == 1)
-      instruction = LCONST_1;
-    else // Create a Constant pool entry
-      instruction = new LDC2_W(cp.addLong(value));
-  }
-
-  /**
-   * @param cp Constant pool
-   * @param value to be pushed 
-   */
-  public PUSH(ConstantPoolGen cp, double value) {
-    if(value == 0.0)
-      instruction = DCONST_0;
-    else if(value == 1.0)
-      instruction = DCONST_1;
-    else // Create a Constant pool entry
-      instruction = new LDC2_W(cp.addDouble(value));
-  }
-
-  /**
-   * @param cp Constant pool
-   * @param value to be pushed 
-   */
-  public PUSH(ConstantPoolGen cp, String value) {
-    if(value == null)
-      instruction = ACONST_NULL;
-    else // Create a Constant pool entry
-      instruction = new LDC(cp.addString(value));
-  }
-
-  /**
-   * @param cp Constant pool
-   * @param value to be pushed 
-   */
-  public PUSH(ConstantPoolGen cp, Number value) {
-    if((value instanceof Integer) || (value instanceof Short) || (value instanceof Byte))
-      instruction = new PUSH(cp, value.intValue()).instruction;
-    else if(value instanceof Double)
-      instruction = new PUSH(cp, value.doubleValue()).instruction;
-    else if(value instanceof Float)
-      instruction = new PUSH(cp, value.floatValue()).instruction;
-    else if(value instanceof Long)
-      instruction = new PUSH(cp, value.longValue()).instruction;
-    else
-      throw new ClassGenException("What's this: " + value);
-  }
-
-  /**
-   * creates a push object from a Character value. Warning: Make sure not to attempt to allow
-   * autoboxing to create this value parameter, as an alternative constructor will be called
-   * 
-   * @param cp Constant pool
-   * @param value to be pushed 
-   */
-  public PUSH(ConstantPoolGen cp, Character value) {
-    this(cp, (int)value.charValue());
-  }
-
-  /**
-   * @param cp Constant pool
-   * @param value to be pushed 
-   */
-  public PUSH(ConstantPoolGen cp, Boolean value) {
-    this(cp, value.booleanValue());
-  }
-
-  public final InstructionList getInstructionList() {
-    return new InstructionList(instruction);
-  }
-
-  public final Instruction getInstruction() {
-    return instruction;
-  }
-
-  /**
-   * @return mnemonic for instruction
-   */
-  public String toString() {
-    return instruction.toString() + " (PUSH)";
-  }
-}
+public final class PUSH implements CompoundInstruction, VariableLengthInstruction,
+        InstructionConstants {
+
+    private Instruction instruction;
 
+
+    /**
+     * This constructor also applies for values of type short, char, byte 
+     *
+     * @param cp Constant pool
+     * @param value to be pushed 
+     */
+    public PUSH(ConstantPoolGen cp, int value) {
+        if ((value >= -1) && (value <= 5)) {
+            instruction = INSTRUCTIONS[Constants.ICONST_0 + value];
+        } else if ((value >= -128) && (value <= 127)) {
+            instruction = new BIPUSH((byte) value);
+        } else if ((value >= -32768) && (value <= 32767)) {
+            instruction = new SIPUSH((short) value);
+        } else {
+            instruction = new LDC(cp.addInteger(value));
+        }
+    }
+
+
+    /**
+     * @param cp Constant pool
+     * @param value to be pushed 
+     */
+    public PUSH(ConstantPoolGen cp, boolean value) {
+        instruction = INSTRUCTIONS[Constants.ICONST_0 + (value ? 1 : 0)];
+    }
+
+
+    /**
+     * @param cp Constant pool
+     * @param value to be pushed 
+     */
+    public PUSH(ConstantPoolGen cp, float value) {
+        if (value == 0.0) {
+            instruction = FCONST_0;
+        } else if (value == 1.0) {
+            instruction = FCONST_1;
+        } else if (value == 2.0) {
+            instruction = FCONST_2;
+        } else {
+            instruction = new LDC(cp.addFloat(value));
+        }
+    }
+
+
+    /**
+     * @param cp Constant pool
+     * @param value to be pushed 
+     */
+    public PUSH(ConstantPoolGen cp, long value) {
+        if (value == 0) {
+            instruction = LCONST_0;
+        } else if (value == 1) {
+            instruction = LCONST_1;
+        } else {
+            instruction = new LDC2_W(cp.addLong(value));
+        }
+    }
+
+
+    /**
+     * @param cp Constant pool
+     * @param value to be pushed 
+     */
+    public PUSH(ConstantPoolGen cp, double value) {
+        if (value == 0.0) {
+            instruction = DCONST_0;
+        } else if (value == 1.0) {
+            instruction = DCONST_1;
+        } else {
+            instruction = new LDC2_W(cp.addDouble(value));
+        }
+    }
+
+
+    /**
+     * @param cp Constant pool
+     * @param value to be pushed 
+     */
+    public PUSH(ConstantPoolGen cp, String value) {
+        if (value == null) {
+            instruction = ACONST_NULL;
+        } else {
+            instruction = new LDC(cp.addString(value));
+        }
+    }
+
+
+    /**
+     * @param cp Constant pool
+     * @param value to be pushed 
+     */
+    public PUSH(ConstantPoolGen cp, Number value) {
+        if ((value instanceof Integer) || (value instanceof Short) || (value instanceof Byte)) {
+            instruction = new PUSH(cp, value.intValue()).instruction;
+        } else if (value instanceof Double) {
+            instruction = new PUSH(cp, value.doubleValue()).instruction;
+        } else if (value instanceof Float) {
+            instruction = new PUSH(cp, value.floatValue()).instruction;
+        } else if (value instanceof Long) {
+            instruction = new PUSH(cp, value.longValue()).instruction;
+        } else {
+            throw new ClassGenException("What's this: " + value);
+        }
+    }
+
+
+    /**
+     * creates a push object from a Character value. Warning: Make sure not to attempt to allow
+     * autoboxing to create this value parameter, as an alternative constructor will be called
+     * 
+     * @param cp Constant pool
+     * @param value to be pushed 
+     */
+    public PUSH(ConstantPoolGen cp, Character value) {
+        this(cp, value.charValue());
+    }
+
+
+    /**
+     * @param cp Constant pool
+     * @param value to be pushed 
+     */
+    public PUSH(ConstantPoolGen cp, Boolean value) {
+        this(cp, value.booleanValue());
+    }
+
+
+    public final InstructionList getInstructionList() {
+        return new InstructionList(instruction);
+    }
+
+
+    public final Instruction getInstruction() {
+        return instruction;
+    }
+
+
+    /**
+     * @return mnemonic for instruction
+     */
+    public String toString() {
+        return instruction.toString() + " (PUSH)";
+    }
+}

Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/PUTFIELD.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/PUTFIELD.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/PUTFIELD.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/PUTFIELD.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License. 
  *
- */ 
+ */
 package org.apache.bcel.generic;
 
-
 import org.apache.bcel.Constants;
 import org.apache.bcel.ExceptionConstants;
 
@@ -29,53 +28,53 @@
  * @version $Id$
  * @author  <A HREF="mailto:[email protected]">M. Dahm</A>
  */
-public class PUTFIELD 
-    extends FieldInstruction 
-    implements PopInstruction,ExceptionThrower{
-  /**
-   * Empty constructor needed for the Class.newInstance() statement in
-   * Instruction.readInstruction(). Not to be used otherwise.
-   */
-  PUTFIELD() {}
-
-  public PUTFIELD(int index) {
-    super(Constants.PUTFIELD, index);
-  }
-
-  public int consumeStack(ConstantPoolGen cpg) { return getFieldSize(cpg) + 1; }
-
-  public Class[] getExceptions() {
-    Class[] cs = new Class[2 + ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length];
-
-    System.arraycopy(ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION, 0,
-		     cs, 0, ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length);
-
-    cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length+1] =
-      ExceptionConstants.INCOMPATIBLE_CLASS_CHANGE_ERROR;
-    cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length] =
-      ExceptionConstants.NULL_POINTER_EXCEPTION;
-
-    return cs;
-  }
-
-
-  /**
-   * Call corresponding visitor method(s). The order is:
-   * Call visitor methods of implemented interfaces first, then
-   * call methods according to the class hierarchy in descending order,
-   * i.e., the most specific visitXXX() call comes last.
-   *
-   * @param v Visitor object
-   */
-  public void accept(Visitor v) {
-    v.visitExceptionThrower(this);
-    v.visitStackConsumer(this);
-    v.visitPopInstruction(this);
-    v.visitTypedInstruction(this);
-    v.visitLoadClass(this);
-    v.visitCPInstruction(this);
-    v.visitFieldOrMethod(this);
-    v.visitFieldInstruction(this);
-    v.visitPUTFIELD(this);
-  }
+public class PUTFIELD extends FieldInstruction implements PopInstruction, ExceptionThrower {
+
+    /**
+     * Empty constructor needed for the Class.newInstance() statement in
+     * Instruction.readInstruction(). Not to be used otherwise.
+     */
+    PUTFIELD() {
+    }
+
+
+    public PUTFIELD(int index) {
+        super(Constants.PUTFIELD, index);
+    }
+
+
+    public int consumeStack( ConstantPoolGen cpg ) {
+        return getFieldSize(cpg) + 1;
+    }
+
+
+    public Class[] getExceptions() {
+        Class[] cs = new Class[2 + ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length];
+        System.arraycopy(ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION, 0, cs, 0,
+                ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length);
+        cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length + 1] = ExceptionConstants.INCOMPATIBLE_CLASS_CHANGE_ERROR;
+        cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length] = ExceptionConstants.NULL_POINTER_EXCEPTION;
+        return cs;
+    }
+
+
+    /**
+     * Call corresponding visitor method(s). The order is:
+     * Call visitor methods of implemented interfaces first, then
+     * call methods according to the class hierarchy in descending order,
+     * i.e., the most specific visitXXX() call comes last.
+     *
+     * @param v Visitor object
+     */
+    public void accept( Visitor v ) {
+        v.visitExceptionThrower(this);
+        v.visitStackConsumer(this);
+        v.visitPopInstruction(this);
+        v.visitTypedInstruction(this);
+        v.visitLoadClass(this);
+        v.visitCPInstruction(this);
+        v.visitFieldOrMethod(this);
+        v.visitFieldInstruction(this);
+        v.visitPUTFIELD(this);
+    }
 }

Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/PUTSTATIC.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/PUTSTATIC.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/PUTSTATIC.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/PUTSTATIC.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License. 
  *
- */ 
+ */
 package org.apache.bcel.generic;
 
-
 import org.apache.bcel.Constants;
 import org.apache.bcel.ExceptionConstants;
 
@@ -29,49 +28,52 @@
  * @version $Id$
  * @author  <A HREF="mailto:[email protected]">M. Dahm</A>
  */
-public class PUTSTATIC extends FieldInstruction
-  implements ExceptionThrower, PopInstruction {
-  /**
-   * Empty constructor needed for the Class.newInstance() statement in
-   * Instruction.readInstruction(). Not to be used otherwise.
-   */
-  PUTSTATIC() {}
-
-  public PUTSTATIC(int index) {
-    super(Constants.PUTSTATIC, index);
-  }
-
-  public int consumeStack(ConstantPoolGen cpg) { return getFieldSize(cpg); }
-
-  public Class[] getExceptions() {
-    Class[] cs = new Class[1 + ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length];
-
-    System.arraycopy(ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION, 0,
-		     cs, 0, ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length);
-    cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length] = 
-      ExceptionConstants.INCOMPATIBLE_CLASS_CHANGE_ERROR;
-
-    return cs;
-  }
-
-
-  /**
-   * Call corresponding visitor method(s). The order is:
-   * Call visitor methods of implemented interfaces first, then
-   * call methods according to the class hierarchy in descending order,
-   * i.e., the most specific visitXXX() call comes last.
-   *
-   * @param v Visitor object
-   */
-  public void accept(Visitor v) {
-    v.visitExceptionThrower(this);
-    v.visitStackConsumer(this);
-    v.visitPopInstruction(this);
-    v.visitTypedInstruction(this);
-    v.visitLoadClass(this);
-    v.visitCPInstruction(this);
-    v.visitFieldOrMethod(this);
-    v.visitFieldInstruction(this);
-    v.visitPUTSTATIC(this);
-  }
+public class PUTSTATIC extends FieldInstruction implements ExceptionThrower, PopInstruction {
+
+    /**
+     * Empty constructor needed for the Class.newInstance() statement in
+     * Instruction.readInstruction(). Not to be used otherwise.
+     */
+    PUTSTATIC() {
+    }
+
+
+    public PUTSTATIC(int index) {
+        super(Constants.PUTSTATIC, index);
+    }
+
+
+    public int consumeStack( ConstantPoolGen cpg ) {
+        return getFieldSize(cpg);
+    }
+
+
+    public Class[] getExceptions() {
+        Class[] cs = new Class[1 + ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length];
+        System.arraycopy(ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION, 0, cs, 0,
+                ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length);
+        cs[ExceptionConstants.EXCS_FIELD_AND_METHOD_RESOLUTION.length] = ExceptionConstants.INCOMPATIBLE_CLASS_CHANGE_ERROR;
+        return cs;
+    }
+
+
+    /**
+     * Call corresponding visitor method(s). The order is:
+     * Call visitor methods of implemented interfaces first, then
+     * call methods according to the class hierarchy in descending order,
+     * i.e., the most specific visitXXX() call comes last.
+     *
+     * @param v Visitor object
+     */
+    public void accept( Visitor v ) {
+        v.visitExceptionThrower(this);
+        v.visitStackConsumer(this);
+        v.visitPopInstruction(this);
+        v.visitTypedInstruction(this);
+        v.visitLoadClass(this);
+        v.visitCPInstruction(this);
+        v.visitFieldOrMethod(this);
+        v.visitFieldInstruction(this);
+        v.visitPUTSTATIC(this);
+    }
 }

Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/PopInstruction.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/PopInstruction.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/PopInstruction.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/PopInstruction.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License. 
  *
- */ 
+ */
 package org.apache.bcel.generic;
 
-
 /**
  * Denotes an unparameterized instruction to pop a value on top from the stack,
  * such as ISTORE, POP, PUTSTATIC.
@@ -28,4 +27,3 @@
  */
 public interface PopInstruction extends StackConsumer {
 }
-

Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/PushInstruction.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/PushInstruction.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/PushInstruction.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/PushInstruction.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License. 
  *
- */ 
+ */
 package org.apache.bcel.generic;
 
-
 /**
  * Denotes an unparameterized instruction to produce a value on top of the stack,
  * such as ILOAD, LDC, SIPUSH, DUP, ICONST, etc.
@@ -33,4 +32,3 @@
  */
 public interface PushInstruction extends StackProducer {
 }
-

Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/RET.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/RET.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/RET.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/RET.java Wed Mar 15 03:31:56 2006
@@ -13,7 +13,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License. 
  *
- */ 
+ */
 package org.apache.bcel.generic;
 
 import java.io.DataOutputStream;
@@ -29,99 +29,111 @@
  * @author  <A HREF="mailto:[email protected]">M. Dahm</A>
  */
 public class RET extends Instruction implements IndexedInstruction, TypedInstruction {
-  private boolean wide;
-  private int     index; // index to local variable containg the return address
 
-  /**
-   * Empty constructor needed for the Class.newInstance() statement in
-   * Instruction.readInstruction(). Not to be used otherwise.
-   */
-  RET() {}
-
-  public RET(int index) {
-    super(org.apache.bcel.Constants.RET, (short)2);
-    setIndex(index);   // May set wide as side effect
-  }
-
-  /**
-   * Dump instruction as byte code to stream out.
-   * @param out Output stream
-   */
-  public void dump(DataOutputStream out) throws IOException {
-    if(wide)
-      out.writeByte(org.apache.bcel.Constants.WIDE);
-
-    out.writeByte(opcode);
-
-    if(wide)
-      out.writeShort(index);
-    else
-      out.writeByte(index);
-  }
-
-  private final void setWide() {
-    wide = index > org.apache.bcel.Constants.MAX_BYTE;
-    if(wide) {
-      length = 4; // Including the wide byte  
-    } else {
-      length = 2;
-    }
-  }
-
-  /**
-   * Read needed data (e.g. index) from file.
-   */
-  protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException
-  {
-    this.wide = wide;
-
-    if(wide) {
-      index  = bytes.readUnsignedShort();
-      length = 4;
-    } else {
-      index = bytes.readUnsignedByte();
-      length = 2;
-    }
-  }
-
-  /**
-   * @return index of local variable containg the return address
-   */
-  public final int getIndex() { return index; }
-
-  /**
-   * Set index of local variable containg the return address
-   */
-  public final void setIndex(int n) { 
-    if(n < 0)
-      throw new ClassGenException("Negative index value: " + n);
-
-    index = n;
-    setWide();
-  }
-
-  /**
-   * @return mnemonic for instruction
-   */
-  public String toString(boolean verbose) {
-    return super.toString(verbose) + " " + index;
-  }  
-
-  /** @return return address type
-   */
-  public Type getType(ConstantPoolGen cp) {
-      return ReturnaddressType.NO_TARGET;
-  }
-
-  /**
-   * Call corresponding visitor method(s). The order is:
-   * Call visitor methods of implemented interfaces first, then
-   * call methods according to the class hierarchy in descending order,
-   * i.e., the most specific visitXXX() call comes last.
-   *
-   * @param v Visitor object
-   */
-  public void accept(Visitor v) {
-    v.visitRET(this);
-  }
+    private boolean wide;
+    private int index; // index to local variable containg the return address
+
+
+    /**
+     * Empty constructor needed for the Class.newInstance() statement in
+     * Instruction.readInstruction(). Not to be used otherwise.
+     */
+    RET() {
+    }
+
+
+    public RET(int index) {
+        super(org.apache.bcel.Constants.RET, (short) 2);
+        setIndex(index); // May set wide as side effect
+    }
+
+
+    /**
+     * Dump instruction as byte code to stream out.
+     * @param out Output stream
+     */
+    public void dump( DataOutputStream out ) throws IOException {
+        if (wide) {
+            out.writeByte(org.apache.bcel.Constants.WIDE);
+        }
+        out.writeByte(opcode);
+        if (wide) {
+            out.writeShort(index);
+        } else {
+            out.writeByte(index);
+        }
+    }
+
+
+    private final void setWide() {
+        wide = index > org.apache.bcel.Constants.MAX_BYTE;
+        if (wide) {
+            length = 4; // Including the wide byte  
+        } else {
+            length = 2;
+        }
+    }
+
+
+    /**
+     * Read needed data (e.g. index) from file.
+     */
+    protected void initFromFile( ByteSequence bytes, boolean wide ) throws IOException {
+        this.wide = wide;
+        if (wide) {
+            index = bytes.readUnsignedShort();
+            length = 4;
+        } else {
+            index = bytes.readUnsignedByte();
+            length = 2;
+        }
+    }
+
+
+    /**
+     * @return index of local variable containg the return address
+     */
+    public final int getIndex() {
+        return index;
+    }
+
+
+    /**
+     * Set index of local variable containg the return address
+     */
+    public final void setIndex( int n ) {
+        if (n < 0) {
+            throw new ClassGenException("Negative index value: " + n);
+        }
+        index = n;
+        setWide();
+    }
+
+
+    /**
+     * @return mnemonic for instruction
+     */
+    public String toString( boolean verbose ) {
+        return super.toString(verbose) + " " + index;
+    }
+
+
+    /** @return return address type
+     */
+    public Type getType( ConstantPoolGen cp ) {
+        return ReturnaddressType.NO_TARGET;
+    }
+
+
+    /**
+     * Call corresponding visitor method(s). The order is:
+     * Call visitor methods of implemented interfaces first, then
+     * call methods according to the class hierarchy in descending order,
+     * i.e., the most specific visitXXX() call comes last.
+     *
+     * @param v Visitor object
+     */
+    public void accept( Visitor v ) {
+        v.visitRET(this);
+    }
 }

Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/RETURN.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/RETURN.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/RETURN.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/RETURN.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License. 
  *
- */ 
+ */
 package org.apache.bcel.generic;
 
-
 /** 
  * RETURN -  Return from void method
  * <PRE>Stack: ... -&gt; &lt;empty&gt;</PRE>
@@ -25,24 +24,25 @@
  * @author  <A HREF="mailto:[email protected]">M. Dahm</A>
  */
 public class RETURN extends ReturnInstruction {
-  public RETURN() {
-    super(org.apache.bcel.Constants.RETURN);
-  }
+
+    public RETURN() {
+        super(org.apache.bcel.Constants.RETURN);
+    }
 
 
-  /**
-   * Call corresponding visitor method(s). The order is:
-   * Call visitor methods of implemented interfaces first, then
-   * call methods according to the class hierarchy in descending order,
-   * i.e., the most specific visitXXX() call comes last.
-   *
-   * @param v Visitor object
-   */
-  public void accept(Visitor v) {
-    v.visitExceptionThrower(this);
-    v.visitTypedInstruction(this);
-    v.visitStackConsumer(this);
-    v.visitReturnInstruction(this);
-    v.visitRETURN(this);
-  }
+    /**
+     * Call corresponding visitor method(s). The order is:
+     * Call visitor methods of implemented interfaces first, then
+     * call methods according to the class hierarchy in descending order,
+     * i.e., the most specific visitXXX() call comes last.
+     *
+     * @param v Visitor object
+     */
+    public void accept( Visitor v ) {
+        v.visitExceptionThrower(this);
+        v.visitTypedInstruction(this);
+        v.visitStackConsumer(this);
+        v.visitReturnInstruction(this);
+        v.visitRETURN(this);
+    }
 }

Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ReferenceType.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ReferenceType.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ReferenceType.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ReferenceType.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License. 
  *
- */ 
+ */
 package org.apache.bcel.generic;
 
-
 import org.apache.bcel.Constants;
 import org.apache.bcel.Repository;
 import org.apache.bcel.classfile.JavaClass;
@@ -28,301 +27,304 @@
  * @author  <A HREF="mailto:[email protected]">M. Dahm</A>
  */
 public abstract class ReferenceType extends Type {
-  protected ReferenceType(byte t, String s) {
-    super(t, s);
-  }
-
-  /** Class is non-abstract but not instantiable from the outside
-   */
-  ReferenceType() {
-    super(Constants.T_OBJECT, "<null object>");
-  }
-
-  /**
-   * Return true iff this type is castable to another type t as defined in
-   * the JVM specification.  The case where this is Type.NULL is not
-   * defined (see the CHECKCAST definition in the JVM specification).
-   * However, because e.g. CHECKCAST doesn't throw a
-   * ClassCastException when casting a null reference to any Object,
-   * true is returned in this case.
-   *
-   * @throws ClassNotFoundException if any classes or interfaces required
-   *  to determine assignment compatibility can't be found
-   */
-  public boolean isCastableTo(Type t) throws ClassNotFoundException {
-    if (this.equals(Type.NULL))
-      return true;		// If this is ever changed in isAssignmentCompatible()
-
-    return isAssignmentCompatibleWith(t);
-    /* Yes, it's true: It's the same definition.
-     * See vmspec2 AASTORE / CHECKCAST definitions.
-     */
-  }
 
-  /**
-   * Return true iff this is assignment compatible with another type t
-   * as defined in the JVM specification; see the AASTORE definition
-   * there.
-   * @throws ClassNotFoundException if any classes or interfaces required
-   *  to determine assignment compatibility can't be found
-   */
-  public boolean isAssignmentCompatibleWith(Type t)
-    throws ClassNotFoundException {
-
-    if (!(t instanceof ReferenceType))
-      return false;
-
-    ReferenceType T = (ReferenceType) t;
+    protected ReferenceType(byte t, String s) {
+        super(t, s);
+    }
 
-    if (this.equals(Type.NULL))
-      return true; // This is not explicitely stated, but clear. Isn't it?
 
-    /* If this is a class type then
+    /** Class is non-abstract but not instantiable from the outside
      */
-    if ((this instanceof ObjectType) && (((ObjectType) this).referencesClassExact())) {
-      /* If T is a class type, then this must be the same class as T,
-	 or this must be a subclass of T;
-      */
-      if ((T instanceof ObjectType) && (((ObjectType) T).referencesClassExact())) {
-	if (this.equals(T))
-	  return true;
-
-	if (Repository.instanceOf(((ObjectType) this).getClassName(),
-				  ((ObjectType) T).getClassName()))
-	  return true;
-      }
-
-      /* If T is an interface type, this must implement interface T.
-       */
-      if ((T instanceof ObjectType) && (((ObjectType) T).referencesInterfaceExact())) {
-	if (Repository.implementationOf(((ObjectType) this).getClassName(),
-					((ObjectType) T).getClassName()))
-	  return true;
-      }
+    ReferenceType() {
+        super(Constants.T_OBJECT, "<null object>");
     }
 
-    /* If this is an interface type, then:
-     */
-    if ((this instanceof ObjectType) && (((ObjectType) this).referencesInterfaceExact())) {
-      /* If T is a class type, then T must be Object (§2.4.7).
-       */
-      if ((T instanceof ObjectType) && (((ObjectType) T).referencesClassExact())) {
-	if (T.equals(Type.OBJECT)) return true;
-      }
-
-      /* If T is an interface type, then T must be the same interface
-       * as this or a superinterface of this (§2.13.2).
-       */
-       if ((T instanceof ObjectType) && (((ObjectType) T).referencesInterfaceExact())) {
-	if (this.equals(T)) return true;
-	if (Repository.implementationOf(((ObjectType) this).getClassName(),
-					((ObjectType) T).getClassName()))
-	  return true;
-      }
-    }
 
-    /* If this is an array type, namely, the type SC[], that is, an
-     * array of components of type SC, then:
+    /**
+     * Return true iff this type is castable to another type t as defined in
+     * the JVM specification.  The case where this is Type.NULL is not
+     * defined (see the CHECKCAST definition in the JVM specification).
+     * However, because e.g. CHECKCAST doesn't throw a
+     * ClassCastException when casting a null reference to any Object,
+     * true is returned in this case.
+     *
+     * @throws ClassNotFoundException if any classes or interfaces required
+     *  to determine assignment compatibility can't be found
      */
-    if (this instanceof ArrayType) {
-      /* If T is a class type, then T must be Object (§2.4.7).
-       */
-      if ((T instanceof ObjectType) && (((ObjectType) T).referencesClassExact())) {
-	if (T.equals(Type.OBJECT)) return true;
-      }
-
-      /* If T is an array type TC[], that is, an array of components
-       * of type TC, then one of the following must be true:
-       */
-      if (T instanceof ArrayType) {
-	/* TC and SC are the same primitive type (§2.4.1).
-	 */
-	Type sc = ((ArrayType) this).getElementType();
-	Type tc = ((ArrayType) T).getElementType();
-
-	if (sc instanceof BasicType && tc instanceof BasicType && sc.equals(tc))
-	  return true;
-
-	/* TC and SC are reference types (§2.4.6), and type SC is
-	 * assignable to TC by these runtime rules.
-	 */
-	if (tc instanceof ReferenceType && sc instanceof ReferenceType &&
-	    ((ReferenceType) sc).isAssignmentCompatibleWith((ReferenceType) tc))
-	  return true;
-      }
-
-      /* If T is an interface type, T must be one of the interfaces implemented by arrays (§2.15). */
-      // TODO: Check if this is still valid or find a way to dynamically find out which
-      // interfaces arrays implement. However, as of the JVM specification edition 2, there
-      // are at least two different pages where assignment compatibility is defined and
-      // on one of them "interfaces implemented by arrays" is exchanged with "'Cloneable' or
-      // 'java.io.Serializable'"
-      if ((T instanceof ObjectType) && (((ObjectType) T).referencesInterfaceExact())) {
-	for (int ii = 0; ii < Constants.INTERFACES_IMPLEMENTED_BY_ARRAYS.length; ii++) {
-	  if (T.equals(new ObjectType(Constants.INTERFACES_IMPLEMENTED_BY_ARRAYS[ii]))) return true;
-	}
-      }
+    public boolean isCastableTo( Type t ) throws ClassNotFoundException {
+        if (this.equals(Type.NULL)) {
+            return true; // If this is ever changed in isAssignmentCompatible()
+        }
+        return isAssignmentCompatibleWith(t);
+        /* Yes, it's true: It's the same definition.
+         * See vmspec2 AASTORE / CHECKCAST definitions.
+         */
     }
-    return false; // default.
-  }
-
-  /**
-   * This commutative operation returns the first common superclass (narrowest ReferenceType
-   * referencing a class, not an interface).
-   * If one of the types is a superclass of the other, the former is returned.
-   * If "this" is Type.NULL, then t is returned.
-   * If t is Type.NULL, then "this" is returned.
-   * If "this" equals t ['this.equals(t)'] "this" is returned.
-   * If "this" or t is an ArrayType, then Type.OBJECT is returned;
-   * unless their dimensions match. Then an ArrayType of the same
-   * number of dimensions is returned, with its basic type being the
-   * first common super class of the basic types of "this" and t.
-   * If "this" or t is a ReferenceType referencing an interface, then Type.OBJECT is returned.
-   * If not all of the two classes' superclasses cannot be found, "null" is returned.
-   * See the JVM specification edition 2, "§4.9.2 The Bytecode Verifier".
-   *
-   * @throws ClassNotFoundException on failure to find superclasses of this
-   *  type, or the type passed as a parameter
-   */
-  public ReferenceType getFirstCommonSuperclass(ReferenceType t)
-    throws ClassNotFoundException {
-
-    if (this.equals(Type.NULL)) return t;
-    if (t.equals(Type.NULL)) return this;
-    if (this.equals(t)) return this;
-    /*
-     * TODO: Above sounds a little arbitrary. On the other hand, there is
-     * no object referenced by Type.NULL so we can also say all the objects
-     * referenced by Type.NULL were derived from java.lang.Object.
-     * However, the Java Language's "instanceof" operator proves us wrong:
-     * "null" is not referring to an instance of java.lang.Object :)
-     */
 
-    /* This code is from a bug report by Konstantin Shagin <[email protected]> */
 
-    if ((this instanceof ArrayType) && (t instanceof ArrayType)) {
-      ArrayType arrType1 = (ArrayType) this;
-      ArrayType arrType2 = (ArrayType) t;
-      if (
-	  (arrType1.getDimensions() == arrType2.getDimensions()) &&
-	  arrType1.getBasicType() instanceof ObjectType &&
-	  arrType2.getBasicType() instanceof ObjectType) {
-	return new ArrayType(
-			     ((ObjectType) arrType1.getBasicType()).getFirstCommonSuperclass((ObjectType) arrType2.getBasicType()),
-			     arrType1.getDimensions()
-			     );
-
-      }
+    /**
+     * Return true iff this is assignment compatible with another type t
+     * as defined in the JVM specification; see the AASTORE definition
+     * there.
+     * @throws ClassNotFoundException if any classes or interfaces required
+     *  to determine assignment compatibility can't be found
+     */
+    public boolean isAssignmentCompatibleWith( Type t ) throws ClassNotFoundException {
+        if (!(t instanceof ReferenceType)) {
+            return false;
+        }
+        ReferenceType T = (ReferenceType) t;
+        if (this.equals(Type.NULL)) {
+            return true; // This is not explicitely stated, but clear. Isn't it?
+        }
+        /* If this is a class type then
+         */
+        if ((this instanceof ObjectType) && (((ObjectType) this).referencesClassExact())) {
+            /* If T is a class type, then this must be the same class as T,
+             or this must be a subclass of T;
+             */
+            if ((T instanceof ObjectType) && (((ObjectType) T).referencesClassExact())) {
+                if (this.equals(T)) {
+                    return true;
+                }
+                if (Repository.instanceOf(((ObjectType) this).getClassName(), ((ObjectType) T)
+                        .getClassName())) {
+                    return true;
+                }
+            }
+            /* If T is an interface type, this must implement interface T.
+             */
+            if ((T instanceof ObjectType) && (((ObjectType) T).referencesInterfaceExact())) {
+                if (Repository.implementationOf(((ObjectType) this).getClassName(),
+                        ((ObjectType) T).getClassName())) {
+                    return true;
+                }
+            }
+        }
+        /* If this is an interface type, then:
+         */
+        if ((this instanceof ObjectType) && (((ObjectType) this).referencesInterfaceExact())) {
+            /* If T is a class type, then T must be Object (§2.4.7).
+             */
+            if ((T instanceof ObjectType) && (((ObjectType) T).referencesClassExact())) {
+                if (T.equals(Type.OBJECT)) {
+                    return true;
+                }
+            }
+            /* If T is an interface type, then T must be the same interface
+             * as this or a superinterface of this (§2.13.2).
+             */
+            if ((T instanceof ObjectType) && (((ObjectType) T).referencesInterfaceExact())) {
+                if (this.equals(T)) {
+                    return true;
+                }
+                if (Repository.implementationOf(((ObjectType) this).getClassName(),
+                        ((ObjectType) T).getClassName())) {
+                    return true;
+                }
+            }
+        }
+        /* If this is an array type, namely, the type SC[], that is, an
+         * array of components of type SC, then:
+         */
+        if (this instanceof ArrayType) {
+            /* If T is a class type, then T must be Object (§2.4.7).
+             */
+            if ((T instanceof ObjectType) && (((ObjectType) T).referencesClassExact())) {
+                if (T.equals(Type.OBJECT)) {
+                    return true;
+                }
+            }
+            /* If T is an array type TC[], that is, an array of components
+             * of type TC, then one of the following must be true:
+             */
+            if (T instanceof ArrayType) {
+                /* TC and SC are the same primitive type (§2.4.1).
+                 */
+                Type sc = ((ArrayType) this).getElementType();
+                Type tc = ((ArrayType) T).getElementType();
+                if (sc instanceof BasicType && tc instanceof BasicType && sc.equals(tc)) {
+                    return true;
+                }
+                /* TC and SC are reference types (§2.4.6), and type SC is
+                 * assignable to TC by these runtime rules.
+                 */
+                if (tc instanceof ReferenceType && sc instanceof ReferenceType
+                        && ((ReferenceType) sc).isAssignmentCompatibleWith(tc)) {
+                    return true;
+                }
+            }
+            /* If T is an interface type, T must be one of the interfaces implemented by arrays (§2.15). */
+            // TODO: Check if this is still valid or find a way to dynamically find out which
+            // interfaces arrays implement. However, as of the JVM specification edition 2, there
+            // are at least two different pages where assignment compatibility is defined and
+            // on one of them "interfaces implemented by arrays" is exchanged with "'Cloneable' or
+            // 'java.io.Serializable'"
+            if ((T instanceof ObjectType) && (((ObjectType) T).referencesInterfaceExact())) {
+                for (int ii = 0; ii < Constants.INTERFACES_IMPLEMENTED_BY_ARRAYS.length; ii++) {
+                    if (T.equals(new ObjectType(Constants.INTERFACES_IMPLEMENTED_BY_ARRAYS[ii]))) {
+                        return true;
+                    }
+                }
+            }
+        }
+        return false; // default.
     }
 
-    if ((this instanceof ArrayType) || (t instanceof ArrayType))
-      return Type.OBJECT;
-    // TODO: Is there a proof of OBJECT being the direct ancestor of every ArrayType?
-
-    if (((this instanceof ObjectType) && ((ObjectType) this).referencesInterface()) ||
-	((t instanceof ObjectType) && ((ObjectType) t).referencesInterface()))
-      return Type.OBJECT;
-    // TODO: The above line is correct comparing to the vmspec2. But one could
-    // make class file verification a bit stronger here by using the notion of
-    // superinterfaces or even castability or assignment compatibility.
-
-
-    // this and t are ObjectTypes, see above.
-    ObjectType thiz = (ObjectType) this;
-    ObjectType other = (ObjectType) t;
-    JavaClass[] thiz_sups = Repository.getSuperClasses(thiz.getClassName());
-    JavaClass[] other_sups = Repository.getSuperClasses(other.getClassName());
 
-    if ((thiz_sups == null) || (other_sups == null)) {
-      return null;
+    /**
+     * This commutative operation returns the first common superclass (narrowest ReferenceType
+     * referencing a class, not an interface).
+     * If one of the types is a superclass of the other, the former is returned.
+     * If "this" is Type.NULL, then t is returned.
+     * If t is Type.NULL, then "this" is returned.
+     * If "this" equals t ['this.equals(t)'] "this" is returned.
+     * If "this" or t is an ArrayType, then Type.OBJECT is returned;
+     * unless their dimensions match. Then an ArrayType of the same
+     * number of dimensions is returned, with its basic type being the
+     * first common super class of the basic types of "this" and t.
+     * If "this" or t is a ReferenceType referencing an interface, then Type.OBJECT is returned.
+     * If not all of the two classes' superclasses cannot be found, "null" is returned.
+     * See the JVM specification edition 2, "§4.9.2 The Bytecode Verifier".
+     *
+     * @throws ClassNotFoundException on failure to find superclasses of this
+     *  type, or the type passed as a parameter
+     */
+    public ReferenceType getFirstCommonSuperclass( ReferenceType t ) throws ClassNotFoundException {
+        if (this.equals(Type.NULL)) {
+            return t;
+        }
+        if (t.equals(Type.NULL)) {
+            return this;
+        }
+        if (this.equals(t)) {
+            return this;
+            /*
+             * TODO: Above sounds a little arbitrary. On the other hand, there is
+             * no object referenced by Type.NULL so we can also say all the objects
+             * referenced by Type.NULL were derived from java.lang.Object.
+             * However, the Java Language's "instanceof" operator proves us wrong:
+             * "null" is not referring to an instance of java.lang.Object :)
+             */
+        }
+        /* This code is from a bug report by Konstantin Shagin <[email protected]> */
+        if ((this instanceof ArrayType) && (t instanceof ArrayType)) {
+            ArrayType arrType1 = (ArrayType) this;
+            ArrayType arrType2 = (ArrayType) t;
+            if ((arrType1.getDimensions() == arrType2.getDimensions())
+                    && arrType1.getBasicType() instanceof ObjectType
+                    && arrType2.getBasicType() instanceof ObjectType) {
+                return new ArrayType(((ObjectType) arrType1.getBasicType())
+                        .getFirstCommonSuperclass((ObjectType) arrType2.getBasicType()), arrType1
+                        .getDimensions());
+            }
+        }
+        if ((this instanceof ArrayType) || (t instanceof ArrayType)) {
+            return Type.OBJECT;
+            // TODO: Is there a proof of OBJECT being the direct ancestor of every ArrayType?
+        }
+        if (((this instanceof ObjectType) && ((ObjectType) this).referencesInterface())
+                || ((t instanceof ObjectType) && ((ObjectType) t).referencesInterface())) {
+            return Type.OBJECT;
+            // TODO: The above line is correct comparing to the vmspec2. But one could
+            // make class file verification a bit stronger here by using the notion of
+            // superinterfaces or even castability or assignment compatibility.
+        }
+        // this and t are ObjectTypes, see above.
+        ObjectType thiz = (ObjectType) this;
+        ObjectType other = (ObjectType) t;
+        JavaClass[] thiz_sups = Repository.getSuperClasses(thiz.getClassName());
+        JavaClass[] other_sups = Repository.getSuperClasses(other.getClassName());
+        if ((thiz_sups == null) || (other_sups == null)) {
+            return null;
+        }
+        // Waaahh...
+        JavaClass[] this_sups = new JavaClass[thiz_sups.length + 1];
+        JavaClass[] t_sups = new JavaClass[other_sups.length + 1];
+        System.arraycopy(thiz_sups, 0, this_sups, 1, thiz_sups.length);
+        System.arraycopy(other_sups, 0, t_sups, 1, other_sups.length);
+        this_sups[0] = Repository.lookupClass(thiz.getClassName());
+        t_sups[0] = Repository.lookupClass(other.getClassName());
+        for (int i = 0; i < t_sups.length; i++) {
+            for (int j = 0; j < this_sups.length; j++) {
+                if (this_sups[j].equals(t_sups[i])) {
+                    return new ObjectType(this_sups[j].getClassName());
+                }
+            }
+        }
+        // Huh? Did you ask for Type.OBJECT's superclass??
+        return null;
     }
 
-    // Waaahh...
-    JavaClass[] this_sups = new JavaClass[thiz_sups.length + 1];
-    JavaClass[] t_sups = new JavaClass[other_sups.length + 1];
-    System.arraycopy(thiz_sups, 0, this_sups, 1, thiz_sups.length);
-    System.arraycopy(other_sups, 0, t_sups, 1, other_sups.length);
-    this_sups[0] = Repository.lookupClass(thiz.getClassName());
-    t_sups[0] = Repository.lookupClass(other.getClassName());
-
-    for (int i = 0; i < t_sups.length; i++) {
-      for (int j = 0; j < this_sups.length; j++) {
-	if (this_sups[j].equals(t_sups[i])) return new ObjectType(this_sups[j].getClassName());
-      }
-    }
 
-    // Huh? Did you ask for Type.OBJECT's superclass??
-    return null;
-  }
-
-  /**
-   * This commutative operation returns the first common superclass (narrowest ReferenceType
-   * referencing a class, not an interface).
-   * If one of the types is a superclass of the other, the former is returned.
-   * If "this" is Type.NULL, then t is returned.
-   * If t is Type.NULL, then "this" is returned.
-   * If "this" equals t ['this.equals(t)'] "this" is returned.
-   * If "this" or t is an ArrayType, then Type.OBJECT is returned.
-   * If "this" or t is a ReferenceType referencing an interface, then Type.OBJECT is returned.
-   * If not all of the two classes' superclasses cannot be found, "null" is returned.
-   * See the JVM specification edition 2, "§4.9.2 The Bytecode Verifier".
-   *
-   * @deprecated use getFirstCommonSuperclass(ReferenceType t) which has
-   *             slightly changed semantics.
-   * @throws ClassNotFoundException on failure to find superclasses of this
-   *  type, or the type passed as a parameter
-   */
-  public ReferenceType firstCommonSuperclass(ReferenceType t)
-    throws ClassNotFoundException {
-
-    if (this.equals(Type.NULL)) return t;
-    if (t.equals(Type.NULL)) return this;
-    if (this.equals(t)) return this;
-    /*
-     * TODO: Above sounds a little arbitrary. On the other hand, there is
-     * no object referenced by Type.NULL so we can also say all the objects
-     * referenced by Type.NULL were derived from java.lang.Object.
-     * However, the Java Language's "instanceof" operator proves us wrong:
-     * "null" is not referring to an instance of java.lang.Object :)
+    /**
+     * This commutative operation returns the first common superclass (narrowest ReferenceType
+     * referencing a class, not an interface).
+     * If one of the types is a superclass of the other, the former is returned.
+     * If "this" is Type.NULL, then t is returned.
+     * If t is Type.NULL, then "this" is returned.
+     * If "this" equals t ['this.equals(t)'] "this" is returned.
+     * If "this" or t is an ArrayType, then Type.OBJECT is returned.
+     * If "this" or t is a ReferenceType referencing an interface, then Type.OBJECT is returned.
+     * If not all of the two classes' superclasses cannot be found, "null" is returned.
+     * See the JVM specification edition 2, "§4.9.2 The Bytecode Verifier".
+     *
+     * @deprecated use getFirstCommonSuperclass(ReferenceType t) which has
+     *             slightly changed semantics.
+     * @throws ClassNotFoundException on failure to find superclasses of this
+     *  type, or the type passed as a parameter
      */
-
-    if ((this instanceof ArrayType) || (t instanceof ArrayType))
-      return Type.OBJECT;
-    // TODO: Is there a proof of OBJECT being the direct ancestor of every ArrayType?
-
-    if (((this instanceof ObjectType) && ((ObjectType) this).referencesInterface()) ||
-	((t instanceof ObjectType) && ((ObjectType) t).referencesInterface()))
-      return Type.OBJECT;
-    // TODO: The above line is correct comparing to the vmspec2. But one could
-    // make class file verification a bit stronger here by using the notion of
-    // superinterfaces or even castability or assignment compatibility.
-
-
-    // this and t are ObjectTypes, see above.
-    ObjectType thiz = (ObjectType) this;
-    ObjectType other = (ObjectType) t;
-    JavaClass[] thiz_sups = Repository.getSuperClasses(thiz.getClassName());
-    JavaClass[] other_sups = Repository.getSuperClasses(other.getClassName());
-
-    if ((thiz_sups == null) || (other_sups == null)) {
-      return null;
-    }
-
-    // Waaahh...
-    JavaClass[] this_sups = new JavaClass[thiz_sups.length + 1];
-    JavaClass[] t_sups = new JavaClass[other_sups.length + 1];
-    System.arraycopy(thiz_sups, 0, this_sups, 1, thiz_sups.length);
-    System.arraycopy(other_sups, 0, t_sups, 1, other_sups.length);
-    this_sups[0] = Repository.lookupClass(thiz.getClassName());
-    t_sups[0] = Repository.lookupClass(other.getClassName());
-
-    for (int i = 0; i < t_sups.length; i++) {
-      for (int j = 0; j < this_sups.length; j++) {
-	if (this_sups[j].equals(t_sups[i])) return new ObjectType(this_sups[j].getClassName());
-      }
+    public ReferenceType firstCommonSuperclass( ReferenceType t ) throws ClassNotFoundException {
+        if (this.equals(Type.NULL)) {
+            return t;
+        }
+        if (t.equals(Type.NULL)) {
+            return this;
+        }
+        if (this.equals(t)) {
+            return this;
+            /*
+             * TODO: Above sounds a little arbitrary. On the other hand, there is
+             * no object referenced by Type.NULL so we can also say all the objects
+             * referenced by Type.NULL were derived from java.lang.Object.
+             * However, the Java Language's "instanceof" operator proves us wrong:
+             * "null" is not referring to an instance of java.lang.Object :)
+             */
+        }
+        if ((this instanceof ArrayType) || (t instanceof ArrayType)) {
+            return Type.OBJECT;
+            // TODO: Is there a proof of OBJECT being the direct ancestor of every ArrayType?
+        }
+        if (((this instanceof ObjectType) && ((ObjectType) this).referencesInterface())
+                || ((t instanceof ObjectType) && ((ObjectType) t).referencesInterface())) {
+            return Type.OBJECT;
+            // TODO: The above line is correct comparing to the vmspec2. But one could
+            // make class file verification a bit stronger here by using the notion of
+            // superinterfaces or even castability or assignment compatibility.
+        }
+        // this and t are ObjectTypes, see above.
+        ObjectType thiz = (ObjectType) this;
+        ObjectType other = (ObjectType) t;
+        JavaClass[] thiz_sups = Repository.getSuperClasses(thiz.getClassName());
+        JavaClass[] other_sups = Repository.getSuperClasses(other.getClassName());
+        if ((thiz_sups == null) || (other_sups == null)) {
+            return null;
+        }
+        // Waaahh...
+        JavaClass[] this_sups = new JavaClass[thiz_sups.length + 1];
+        JavaClass[] t_sups = new JavaClass[other_sups.length + 1];
+        System.arraycopy(thiz_sups, 0, this_sups, 1, thiz_sups.length);
+        System.arraycopy(other_sups, 0, t_sups, 1, other_sups.length);
+        this_sups[0] = Repository.lookupClass(thiz.getClassName());
+        t_sups[0] = Repository.lookupClass(other.getClassName());
+        for (int i = 0; i < t_sups.length; i++) {
+            for (int j = 0; j < this_sups.length; j++) {
+                if (this_sups[j].equals(t_sups[i])) {
+                    return new ObjectType(this_sups[j].getClassName());
+                }
+            }
+        }
+        // Huh? Did you ask for Type.OBJECT's superclass??
+        return null;
     }
-
-    // Huh? Did you ask for Type.OBJECT's superclass??
-    return null;
-  }
 }

Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ReturnInstruction.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ReturnInstruction.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ReturnInstruction.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ReturnInstruction.java Wed Mar 15 03:31:56 2006
@@ -13,7 +13,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License. 
  *
- */ 
+ */
 package org.apache.bcel.generic;
 
 import org.apache.bcel.Constants;
@@ -25,43 +25,55 @@
  * @version $Id$
  * @author  <A HREF="mailto:[email protected]">M. Dahm</A>
  */
-public abstract class ReturnInstruction extends Instruction
-  implements ExceptionThrower, TypedInstruction, StackConsumer {
-  /**
-   * Empty constructor needed for the Class.newInstance() statement in
-   * Instruction.readInstruction(). Not to be used otherwise.
-   */
-  ReturnInstruction() {}
-
-  /**
-   * @param opcode of instruction
-   */
-  protected ReturnInstruction(short opcode) {
-    super(opcode, (short)1);
-  }
-
-  public Type getType() {
-    switch(opcode) {
-      case Constants.IRETURN: return Type.INT;
-      case Constants.LRETURN: return Type.LONG;
-      case Constants.FRETURN: return Type.FLOAT;
-      case Constants.DRETURN: return Type.DOUBLE;
-      case Constants.ARETURN: return Type.OBJECT;
-      case Constants.RETURN:  return Type.VOID;
- 
-    default: // Never reached
-      throw new ClassGenException("Unknown type " + opcode);
+public abstract class ReturnInstruction extends Instruction implements ExceptionThrower,
+        TypedInstruction, StackConsumer {
+
+    /**
+     * Empty constructor needed for the Class.newInstance() statement in
+     * Instruction.readInstruction(). Not to be used otherwise.
+     */
+    ReturnInstruction() {
     }
-  }
 
-  public Class[] getExceptions() {
-    return new Class[] { ExceptionConstants.ILLEGAL_MONITOR_STATE };
-  }
-
-  /** @return type associated with the instruction
-   */
-  public Type getType(ConstantPoolGen cp) {
-    return getType();
-  }
-}
 
+    /**
+     * @param opcode of instruction
+     */
+    protected ReturnInstruction(short opcode) {
+        super(opcode, (short) 1);
+    }
+
+
+    public Type getType() {
+        switch (opcode) {
+            case Constants.IRETURN:
+                return Type.INT;
+            case Constants.LRETURN:
+                return Type.LONG;
+            case Constants.FRETURN:
+                return Type.FLOAT;
+            case Constants.DRETURN:
+                return Type.DOUBLE;
+            case Constants.ARETURN:
+                return Type.OBJECT;
+            case Constants.RETURN:
+                return Type.VOID;
+            default: // Never reached
+                throw new ClassGenException("Unknown type " + opcode);
+        }
+    }
+
+
+    public Class[] getExceptions() {
+        return new Class[] {
+            ExceptionConstants.ILLEGAL_MONITOR_STATE
+        };
+    }
+
+
+    /** @return type associated with the instruction
+     */
+    public Type getType( ConstantPoolGen cp ) {
+        return getType();
+    }
+}

Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ReturnaddressType.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ReturnaddressType.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ReturnaddressType.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/ReturnaddressType.java Wed Mar 15 03:31:56 2006
@@ -13,7 +13,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License. 
  *
- */ 
+ */
 package org.apache.bcel.generic;
 
 import org.apache.bcel.Constants;
@@ -27,51 +27,56 @@
  */
 public class ReturnaddressType extends Type {
 
-  public static final ReturnaddressType NO_TARGET = new ReturnaddressType();
-  private InstructionHandle returnTarget;
- 
-  /**
-   * A Returnaddress [that doesn't know where to return to].
-   */
-  private ReturnaddressType(){
-    super(Constants.T_ADDRESS, "<return address>");
-  }
- 	
-  /**
-   * Creates a ReturnaddressType object with a target.
-   */
-  public ReturnaddressType(InstructionHandle returnTarget) {
-    super(Constants.T_ADDRESS, "<return address targeting "+returnTarget+">");
-  	this.returnTarget = returnTarget;
-  }
-	
-  /** @return a hash code value for the object.
-   */
-  public int hashCode() { 
-    if (returnTarget == null)
-      return 0;
-  	return returnTarget.hashCode(); 
-  }
-
-  /**
-   * Returns if the two Returnaddresses refer to the same target.
-   */
-  public boolean equals(Object rat){
-    if(!(rat instanceof ReturnaddressType))
-      return false;
-
-		ReturnaddressType that = (ReturnaddressType)rat;
-		
-		if(this.returnTarget == null || that.returnTarget == null)
-			return that.returnTarget == this.returnTarget;
-		
-    return that.returnTarget.equals(this.returnTarget);
-  }	
-
-  /**
-   * @return the target of this ReturnaddressType
-   */
-  public InstructionHandle getTarget(){
-    return returnTarget;
-  }
+    public static final ReturnaddressType NO_TARGET = new ReturnaddressType();
+    private InstructionHandle returnTarget;
+
+
+    /**
+     * A Returnaddress [that doesn't know where to return to].
+     */
+    private ReturnaddressType() {
+        super(Constants.T_ADDRESS, "<return address>");
+    }
+
+
+    /**
+     * Creates a ReturnaddressType object with a target.
+     */
+    public ReturnaddressType(InstructionHandle returnTarget) {
+        super(Constants.T_ADDRESS, "<return address targeting " + returnTarget + ">");
+        this.returnTarget = returnTarget;
+    }
+
+
+    /** @return a hash code value for the object.
+     */
+    public int hashCode() {
+        if (returnTarget == null) {
+            return 0;
+        }
+        return returnTarget.hashCode();
+    }
+
+
+    /**
+     * Returns if the two Returnaddresses refer to the same target.
+     */
+    public boolean equals( Object rat ) {
+        if (!(rat instanceof ReturnaddressType)) {
+            return false;
+        }
+        ReturnaddressType that = (ReturnaddressType) rat;
+        if (this.returnTarget == null || that.returnTarget == null) {
+            return that.returnTarget == this.returnTarget;
+        }
+        return that.returnTarget.equals(this.returnTarget);
+    }
+
+
+    /**
+     * @return the target of this ReturnaddressType
+     */
+    public InstructionHandle getTarget() {
+        return returnTarget;
+    }
 }

Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/SALOAD.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/SALOAD.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/SALOAD.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/SALOAD.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License. 
  *
- */ 
+ */
 package org.apache.bcel.generic;
 
-
 /** 
  * SALOAD - Load short from array
  * <PRE>Stack: ..., arrayref, index -&gt; ..., value</PRE>
@@ -25,24 +24,25 @@
  * @author  <A HREF="mailto:[email protected]">M. Dahm</A>
  */
 public class SALOAD extends ArrayInstruction implements StackProducer {
-  public SALOAD() {
-    super(org.apache.bcel.Constants.SALOAD);
-  }
+
+    public SALOAD() {
+        super(org.apache.bcel.Constants.SALOAD);
+    }
 
 
-  /**
-   * Call corresponding visitor method(s). The order is:
-   * Call visitor methods of implemented interfaces first, then
-   * call methods according to the class hierarchy in descending order,
-   * i.e., the most specific visitXXX() call comes last.
-   *
-   * @param v Visitor object
-   */
-  public void accept(Visitor v) {
-    v.visitStackProducer(this);
-    v.visitExceptionThrower(this);
-    v.visitTypedInstruction(this);
-    v.visitArrayInstruction(this);
-    v.visitSALOAD(this);
-  }
+    /**
+     * Call corresponding visitor method(s). The order is:
+     * Call visitor methods of implemented interfaces first, then
+     * call methods according to the class hierarchy in descending order,
+     * i.e., the most specific visitXXX() call comes last.
+     *
+     * @param v Visitor object
+     */
+    public void accept( Visitor v ) {
+        v.visitStackProducer(this);
+        v.visitExceptionThrower(this);
+        v.visitTypedInstruction(this);
+        v.visitArrayInstruction(this);
+        v.visitSALOAD(this);
+    }
 }

Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/SASTORE.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/SASTORE.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/SASTORE.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/SASTORE.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License. 
  *
- */ 
+ */
 package org.apache.bcel.generic;
 
-
 /**
  * SASTORE - Store into short array
  * <PRE>Stack: ..., arrayref, index, value -&gt; ...</PRE>
@@ -25,24 +24,25 @@
  * @author  <A HREF="mailto:[email protected]">M. Dahm</A>
  */
 public class SASTORE extends ArrayInstruction implements StackConsumer {
-  public SASTORE() {
-    super(org.apache.bcel.Constants.SASTORE);
-  }
+
+    public SASTORE() {
+        super(org.apache.bcel.Constants.SASTORE);
+    }
 
 
-  /**
-   * Call corresponding visitor method(s). The order is:
-   * Call visitor methods of implemented interfaces first, then
-   * call methods according to the class hierarchy in descending order,
-   * i.e., the most specific visitXXX() call comes last.
-   *
-   * @param v Visitor object
-   */
-  public void accept(Visitor v) {
-    v.visitStackConsumer(this);
-    v.visitExceptionThrower(this);
-    v.visitTypedInstruction(this);
-    v.visitArrayInstruction(this);
-    v.visitSASTORE(this);
-  }
+    /**
+     * Call corresponding visitor method(s). The order is:
+     * Call visitor methods of implemented interfaces first, then
+     * call methods according to the class hierarchy in descending order,
+     * i.e., the most specific visitXXX() call comes last.
+     *
+     * @param v Visitor object
+     */
+    public void accept( Visitor v ) {
+        v.visitStackConsumer(this);
+        v.visitExceptionThrower(this);
+        v.visitTypedInstruction(this);
+        v.visitArrayInstruction(this);
+        v.visitSASTORE(this);
+    }
 }

Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/SIPUSH.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/SIPUSH.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/SIPUSH.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/SIPUSH.java Wed Mar 15 03:31:56 2006
@@ -13,7 +13,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License. 
  *
- */ 
+ */
 package org.apache.bcel.generic;
 
 import java.io.DataOutputStream;
@@ -29,64 +29,75 @@
  * @author  <A HREF="mailto:[email protected]">M. Dahm</A>
  */
 public class SIPUSH extends Instruction implements ConstantPushInstruction {
-  private short b;
 
-  /**
-   * Empty constructor needed for the Class.newInstance() statement in
-   * Instruction.readInstruction(). Not to be used otherwise.
-   */
-  SIPUSH() {}
-
-  public SIPUSH(short b) {
-    super(org.apache.bcel.Constants.SIPUSH, (short)3);
-    this.b = b;
-  }
-
-  /**
-   * Dump instruction as short code to stream out.
-   */
-  public void dump(DataOutputStream out) throws IOException {
-    super.dump(out);
-    out.writeShort(b);
-  }
-
-  /**
-   * @return mnemonic for instruction
-   */
-  public String toString(boolean verbose) {
-    return super.toString(verbose) + " " + b;
-  }
-
-  /**
-   * Read needed data (e.g. index) from file.
-   */
-  protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException
-  {
-    length = 3;
-    b      = bytes.readShort();
-  }
-
-  public Number getValue() { return new Integer(b); }
-
-  /** @return Type.SHORT
-   */
-  public Type getType(ConstantPoolGen cp) {
-    return Type.SHORT;
-  }
-
-  /**
-   * Call corresponding visitor method(s). The order is:
-   * Call visitor methods of implemented interfaces first, then
-   * call methods according to the class hierarchy in descending order,
-   * i.e., the most specific visitXXX() call comes last.
-   *
-   * @param v Visitor object
-   */
-  public void accept(Visitor v) {
-    v.visitPushInstruction(this);
-    v.visitStackProducer(this);
-    v.visitTypedInstruction(this);
-    v.visitConstantPushInstruction(this);
-    v.visitSIPUSH(this);
-  }
+    private short b;
+
+
+    /**
+     * Empty constructor needed for the Class.newInstance() statement in
+     * Instruction.readInstruction(). Not to be used otherwise.
+     */
+    SIPUSH() {
+    }
+
+
+    public SIPUSH(short b) {
+        super(org.apache.bcel.Constants.SIPUSH, (short) 3);
+        this.b = b;
+    }
+
+
+    /**
+     * Dump instruction as short code to stream out.
+     */
+    public void dump( DataOutputStream out ) throws IOException {
+        super.dump(out);
+        out.writeShort(b);
+    }
+
+
+    /**
+     * @return mnemonic for instruction
+     */
+    public String toString( boolean verbose ) {
+        return super.toString(verbose) + " " + b;
+    }
+
+
+    /**
+     * Read needed data (e.g. index) from file.
+     */
+    protected void initFromFile( ByteSequence bytes, boolean wide ) throws IOException {
+        length = 3;
+        b = bytes.readShort();
+    }
+
+
+    public Number getValue() {
+        return new Integer(b);
+    }
+
+
+    /** @return Type.SHORT
+     */
+    public Type getType( ConstantPoolGen cp ) {
+        return Type.SHORT;
+    }
+
+
+    /**
+     * Call corresponding visitor method(s). The order is:
+     * Call visitor methods of implemented interfaces first, then
+     * call methods according to the class hierarchy in descending order,
+     * i.e., the most specific visitXXX() call comes last.
+     *
+     * @param v Visitor object
+     */
+    public void accept( Visitor v ) {
+        v.visitPushInstruction(this);
+        v.visitStackProducer(this);
+        v.visitTypedInstruction(this);
+        v.visitConstantPushInstruction(this);
+        v.visitSIPUSH(this);
+    }
 }

Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/SWAP.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/SWAP.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/SWAP.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/SWAP.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License. 
  *
- */ 
+ */
 package org.apache.bcel.generic;
 
-
 /** 
  * SWAP - Swa top operand stack word
  * <PRE>Stack: ..., word2, word1 -&gt; ..., word1, word2</PRE>
@@ -25,23 +24,24 @@
  * @author  <A HREF="mailto:[email protected]">M. Dahm</A>
  */
 public class SWAP extends StackInstruction implements StackConsumer, StackProducer {
-  public SWAP() {
-    super(org.apache.bcel.Constants.SWAP);
-  }
+
+    public SWAP() {
+        super(org.apache.bcel.Constants.SWAP);
+    }
 
 
-  /**
-   * Call corresponding visitor method(s). The order is:
-   * Call visitor methods of implemented interfaces first, then
-   * call methods according to the class hierarchy in descending order,
-   * i.e., the most specific visitXXX() call comes last.
-   *
-   * @param v Visitor object
-   */
-  public void accept(Visitor v) {
-    v.visitStackConsumer(this);
-    v.visitStackProducer(this);
-    v.visitStackInstruction(this);
-    v.visitSWAP(this);
-  }
+    /**
+     * Call corresponding visitor method(s). The order is:
+     * Call visitor methods of implemented interfaces first, then
+     * call methods according to the class hierarchy in descending order,
+     * i.e., the most specific visitXXX() call comes last.
+     *
+     * @param v Visitor object
+     */
+    public void accept( Visitor v ) {
+        v.visitStackConsumer(this);
+        v.visitStackProducer(this);
+        v.visitStackInstruction(this);
+        v.visitSWAP(this);
+    }
 }

Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/generic/SWITCH.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/generic/SWITCH.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/generic/SWITCH.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/generic/SWITCH.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License. 
  *
- */ 
+ */
 package org.apache.bcel.generic;
 
-
 /** 
  * SWITCH - Branch depending on int value, generates either LOOKUPSWITCH or
  * TABLESWITCH instruction, depending on whether the match values (int[]) can be
@@ -26,121 +25,129 @@
  * @author  <A HREF="mailto:[email protected]">M. Dahm</A>
  */
 public final class SWITCH implements CompoundInstruction {
-  private int[]               match;
-  private InstructionHandle[] targets;
-  private Select              instruction;
-  private int                 match_length;
-
-  /**
-   * Template for switch() constructs. If the match array can be
-   * sorted in ascending order with gaps no larger than max_gap
-   * between the numbers, a TABLESWITCH instruction is generated, and
-   * a LOOKUPSWITCH otherwise. The former may be more efficient, but
-   * needs more space.
-   * 
-   * Note, that the key array always will be sorted, though we leave
-   * the original arrays unaltered.
-   *
-   * @param match array of match values (case 2: ... case 7: ..., etc.)
-   * @param targets the instructions to be branched to for each case
-   * @param target the default target
-   * @param max_gap maximum gap that may between case branches
-   */
-  public SWITCH(int[] match, InstructionHandle[] targets,
-		InstructionHandle target, int max_gap) {
-    this.match   = (int[])match.clone();
-    this.targets = (InstructionHandle[])targets.clone();
-
-    if((match_length = match.length) < 2) // (almost) empty switch, or just default
-      instruction = new TABLESWITCH(match, targets, target);
-    else {
-      sort(0, match_length - 1);
-      
-      if(matchIsOrdered(max_gap)) {
-	fillup(max_gap, target);
-
-	instruction = new TABLESWITCH(this.match, this.targets, target);
-      }
-      else
-	instruction = new LOOKUPSWITCH(this.match, this.targets, target);
-    }
-  }
-
-  public SWITCH(int[] match, InstructionHandle[] targets,
-		InstructionHandle target) {
-    this(match, targets, target, 1);
-  }
-  
-  private final void fillup(int max_gap, InstructionHandle target) {
-    int                 max_size = match_length + match_length * max_gap;
-    int[]               m_vec    = new int[max_size];
-    InstructionHandle[] t_vec    = new InstructionHandle[max_size];
-    int                 count    = 1;
-
-    m_vec[0] = match[0];
-    t_vec[0] = targets[0];
-
-    for(int i=1; i < match_length; i++) {
-      int prev = match[i-1];
-      int gap  = match[i] - prev; 
-
-      for(int j=1; j < gap; j++) {
-	m_vec[count] = prev + j;
-	t_vec[count] = target;
-	count++;
-      }
-
-      m_vec[count] = match[i];
-      t_vec[count] = targets[i];
-      count++;
-    }	
-
-    match   = new int[count];
-    targets = new InstructionHandle[count];
-
-    System.arraycopy(m_vec, 0, match, 0, count);
-    System.arraycopy(t_vec, 0, targets, 0, count);
-  }
-
-  /**
-   * Sort match and targets array with QuickSort.
-   */
-  private final void sort(int l, int r) {
-    int i = l, j = r;
-    int h, m = match[(l + r) / 2];
-    InstructionHandle h2;
-
-    do {
-      while(match[i] < m) i++;
-      while(m < match[j]) j--;
-
-      if(i <= j) {
-	h=match[i]; match[i]=match[j]; match[j]=h; // Swap elements
-	h2=targets[i]; targets[i]=targets[j]; targets[j]=h2; // Swap instructions, too
-	i++; j--;
-      }
-    } while(i <= j);
-
-    if(l < j) sort(l, j);
-    if(i < r) sort(i, r);
-  }
-
-  /**
-   * @return match is sorted in ascending order with no gap bigger than max_gap?
-   */
-  private final boolean matchIsOrdered(int max_gap) {
-    for(int i=1; i < match_length; i++)
-      if(match[i] - match[i-1] > max_gap)
-	return false;
-
-    return true;
-  }
-
-  public final InstructionList getInstructionList() {
-    return new InstructionList(instruction);
-  }
-
-  public final Instruction getInstruction() {
-    return instruction;
-  }
+
+    private int[] match;
+    private InstructionHandle[] targets;
+    private Select instruction;
+    private int match_length;
+
+
+    /**
+     * Template for switch() constructs. If the match array can be
+     * sorted in ascending order with gaps no larger than max_gap
+     * between the numbers, a TABLESWITCH instruction is generated, and
+     * a LOOKUPSWITCH otherwise. The former may be more efficient, but
+     * needs more space.
+     * 
+     * Note, that the key array always will be sorted, though we leave
+     * the original arrays unaltered.
+     *
+     * @param match array of match values (case 2: ... case 7: ..., etc.)
+     * @param targets the instructions to be branched to for each case
+     * @param target the default target
+     * @param max_gap maximum gap that may between case branches
+     */
+    public SWITCH(int[] match, InstructionHandle[] targets, InstructionHandle target, int max_gap) {
+        this.match = (int[]) match.clone();
+        this.targets = (InstructionHandle[]) targets.clone();
+        if ((match_length = match.length) < 2) {
+            instruction = new TABLESWITCH(match, targets, target);
+        } else {
+            sort(0, match_length - 1);
+            if (matchIsOrdered(max_gap)) {
+                fillup(max_gap, target);
+                instruction = new TABLESWITCH(this.match, this.targets, target);
+            } else {
+                instruction = new LOOKUPSWITCH(this.match, this.targets, target);
+            }
+        }
+    }
+
+
+    public SWITCH(int[] match, InstructionHandle[] targets, InstructionHandle target) {
+        this(match, targets, target, 1);
+    }
+
+
+    private final void fillup( int max_gap, InstructionHandle target ) {
+        int max_size = match_length + match_length * max_gap;
+        int[] m_vec = new int[max_size];
+        InstructionHandle[] t_vec = new InstructionHandle[max_size];
+        int count = 1;
+        m_vec[0] = match[0];
+        t_vec[0] = targets[0];
+        for (int i = 1; i < match_length; i++) {
+            int prev = match[i - 1];
+            int gap = match[i] - prev;
+            for (int j = 1; j < gap; j++) {
+                m_vec[count] = prev + j;
+                t_vec[count] = target;
+                count++;
+            }
+            m_vec[count] = match[i];
+            t_vec[count] = targets[i];
+            count++;
+        }
+        match = new int[count];
+        targets = new InstructionHandle[count];
+        System.arraycopy(m_vec, 0, match, 0, count);
+        System.arraycopy(t_vec, 0, targets, 0, count);
+    }
+
+
+    /**
+     * Sort match and targets array with QuickSort.
+     */
+    private final void sort( int l, int r ) {
+        int i = l, j = r;
+        int h, m = match[(l + r) / 2];
+        InstructionHandle h2;
+        do {
+            while (match[i] < m) {
+                i++;
+            }
+            while (m < match[j]) {
+                j--;
+            }
+            if (i <= j) {
+                h = match[i];
+                match[i] = match[j];
+                match[j] = h; // Swap elements
+                h2 = targets[i];
+                targets[i] = targets[j];
+                targets[j] = h2; // Swap instructions, too
+                i++;
+                j--;
+            }
+        } while (i <= j);
+        if (l < j) {
+            sort(l, j);
+        }
+        if (i < r) {
+            sort(i, r);
+        }
+    }
+
+
+    /**
+     * @return match is sorted in ascending order with no gap bigger than max_gap?
+     */
+    private final boolean matchIsOrdered( int max_gap ) {
+        for (int i = 1; i < match_length; i++) {
+            if (match[i] - match[i - 1] > max_gap) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+
+    public final InstructionList getInstructionList() {
+        return new InstructionList(instruction);
+    }
+
+
+    public final Instruction getInstruction() {
+        return instruction;
+    }
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.