FileDocCategorySizeDatePackage
GOTO.javaAPI DocJava SE 6 API4788Tue Jun 10 00:22:20 BST 2008com.sun.org.apache.bcel.internal.generic

GOTO

public class GOTO extends GotoInstruction implements VariableLengthInstruction
GOTO - Branch always (to relative offset, not absolute address)
version
$Id: GOTO.java,v 1.1.2.1 2005/07/31 23:46:01 jeffsuttor Exp $
author
M. Dahm

Fields Summary
Constructors Summary
GOTO()
Empty constructor needed for the Class.newInstance() statement in Instruction.readInstruction(). Not to be used otherwise.

public GOTO(InstructionHandle target)

    super(com.sun.org.apache.bcel.internal.Constants.GOTO, target);
  
Methods Summary
public voidaccept(com.sun.org.apache.bcel.internal.generic.Visitor v)
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

    v.visitVariableLengthInstruction(this);
    v.visitUnconditionalBranch(this);
    v.visitBranchInstruction(this);
    v.visitGotoInstruction(this);
    v.visitGOTO(this);
  
public voiddump(java.io.DataOutputStream out)
Dump instruction as byte code to stream out.

param
out Output stream

    index = getTargetOffset();
    if(opcode == com.sun.org.apache.bcel.internal.Constants.GOTO)
      super.dump(out);
    else { // GOTO_W
      index = getTargetOffset();
      out.writeByte(opcode);
      out.writeInt(index);
    }
  
protected intupdatePosition(int offset, int max_offset)
Called in pass 2 of InstructionList.setPositions() in order to update the branch target, that may shift due to variable length instructions.

    int i = getTargetOffset(); // Depending on old position value

    position += offset; // Position may be shifted by preceding expansions

    if(Math.abs(i) >= (32767 - max_offset)) { // to large for short (estimate)
      opcode = com.sun.org.apache.bcel.internal.Constants.GOTO_W;
      length = 5;
      return 2; // 5 - 3
    }

    return 0;