FileDocCategorySizeDatePackage
GOTO.javaAPI DocJava SE 5 API4785Fri Aug 26 14:55:20 BST 2005com.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.1.1 2001/10/29 20:00:13 jvanzyl 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;