< prev index next >

src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/RET.java

Print this page

        

@@ -19,110 +19,133 @@
  * limitations under the License.
  */
 
 package com.sun.org.apache.bcel.internal.generic;
 
-import java.io.*;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
 import com.sun.org.apache.bcel.internal.util.ByteSequence;
 
 /**
  * RET - Return from subroutine
  *
- * <PRE>Stack: ..., -&gt; ..., address</PRE>
+ * <PRE>Stack: ... -&gt; ...</PRE>
  *
- * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
+ * @version $Id: RET.java 1747278 2016-06-07 17:28:43Z britter $
  */
 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() {}
+    RET() {
+    }
+
 
-  public RET(int index) {
-    super(com.sun.org.apache.bcel.internal.Constants.RET, (short)2);
+    public RET(final int index) {
+        super(com.sun.org.apache.bcel.internal.Const.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(com.sun.org.apache.bcel.internal.Constants.WIDE);
-
-    out.writeByte(opcode);
-
-    if(wide)
+    @Override
+    public void dump( final DataOutputStream out ) throws IOException {
+        if (wide) {
+            out.writeByte(com.sun.org.apache.bcel.internal.Const.WIDE);
+        }
+        out.writeByte(super.getOpcode());
+        if (wide) {
       out.writeShort(index);
-    else
+        } else {
       out.writeByte(index);
   }
+    }
+
 
-  private final void setWide() {
-    if(wide = index > com.sun.org.apache.bcel.internal.Constants.MAX_BYTE)
-      length = 4; // Including the wide byte
-    else
-      length = 2;
+    private void setWide() {
+        wide = index > com.sun.org.apache.bcel.internal.Const.MAX_BYTE;
+        if (wide) {
+            super.setLength(4); // Including the wide byte
+        } else {
+            super.setLength(2);
+        }
   }
 
+
   /**
    * Read needed data (e.g. index) from file.
    */
-  protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException
-  {
+    @Override
+    protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException {
     this.wide = wide;
-
-    if(wide) {
+        if (wide) {
       index  = bytes.readUnsignedShort();
-      length = 4;
+            super.setLength(4);
     } else {
       index = bytes.readUnsignedByte();
-      length = 2;
+            super.setLength(2);
     }
   }
 
+
   /**
    * @return index of local variable containg the return address
    */
-  public final int getIndex() { return index; }
+    @Override
+    public final int getIndex() {
+        return index;
+    }
+
 
   /**
    * Set index of local variable containg the return address
    */
-  public final void setIndex(int n) {
-    if(n < 0)
+    @Override
+    public final void setIndex( final int n ) {
+        if (n < 0) {
       throw new ClassGenException("Negative index value: " + n);
-
+        }
     index = n;
     setWide();
   }
 
+
   /**
    * @return mnemonic for instruction
    */
-  public String toString(boolean verbose) {
+    @Override
+    public String toString( final boolean verbose ) {
     return super.toString(verbose) + " " + index;
   }
 
+
   /** @return return address type
    */
-  public Type getType(ConstantPoolGen cp) {
+    @Override
+    public Type getType( final 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) {
+    @Override
+    public void accept( final Visitor v ) {
     v.visitRET(this);
   }
 }
< prev index next >