--- old/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/JSR.java 2017-08-08 16:05:41.798830532 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/JSR.java 2017-08-08 16:05:41.718826526 -0700 @@ -21,66 +21,74 @@ package com.sun.org.apache.bcel.internal.generic; -import java.io.*; +import java.io.DataOutputStream; +import java.io.IOException; /** * JSR - Jump to subroutine * - * @author M. Dahm + * @version $Id: JSR.java 1749603 2016-06-21 20:50:19Z ggregory $ */ public class JSR extends JsrInstruction implements VariableLengthInstruction { - /** - * Empty constructor needed for the Class.newInstance() statement in - * Instruction.readInstruction(). Not to be used otherwise. - */ - JSR() {} - - public JSR(InstructionHandle target) { - super(com.sun.org.apache.bcel.internal.Constants.JSR, target); - } - - /** - * Dump instruction as byte code to stream out. - * @param out Output stream - */ - public void dump(DataOutputStream out) throws IOException { - index = getTargetOffset(); - if(opcode == com.sun.org.apache.bcel.internal.Constants.JSR) - super.dump(out); - else { // JSR_W - index = getTargetOffset(); - out.writeByte(opcode); - out.writeInt(index); + + /** + * Empty constructor needed for the Class.newInstance() statement in + * Instruction.readInstruction(). Not to be used otherwise. + */ + JSR() { } - } - protected int updatePosition(int offset, int max_offset) { - int i = getTargetOffset(); // Depending on old position value - position += offset; // Position may be shifted by preceding expansions + public JSR(final InstructionHandle target) { + super(com.sun.org.apache.bcel.internal.Const.JSR, target); + } + - if(Math.abs(i) >= (32767 - max_offset)) { // to large for short (estimate) - opcode = com.sun.org.apache.bcel.internal.Constants.JSR_W; - length = 5; - return 2; // 5 - 3 + /** + * Dump instruction as byte code to stream out. + * @param out Output stream + */ + @Override + public void dump( final DataOutputStream out ) throws IOException { + super.setIndex(getTargetOffset()); + if (super.getOpcode() == com.sun.org.apache.bcel.internal.Const.JSR) { + super.dump(out); + } else { // JSR_W + super.setIndex(getTargetOffset()); + out.writeByte(super.getOpcode()); + out.writeInt(super.getIndex()); + } } - return 0; - } - /** - * 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.visitVariableLengthInstruction(this); - v.visitBranchInstruction(this); - v.visitJsrInstruction(this); - v.visitJSR(this); - } + @Override + protected int updatePosition( final int offset, final int max_offset ) { + final int i = getTargetOffset(); // Depending on old position value + setPosition(getPosition() + offset); // Position may be shifted by preceding expansions + if (Math.abs(i) >= (Short.MAX_VALUE - max_offset)) { // to large for short (estimate) + super.setOpcode(com.sun.org.apache.bcel.internal.Const.JSR_W); + final short old_length = (short) super.getLength(); + super.setLength(5); + return super.getLength() - old_length; + } + return 0; + } + + + /** + * 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 + */ + @Override + public void accept( final Visitor v ) { + v.visitStackProducer(this); + v.visitVariableLengthInstruction(this); + v.visitBranchInstruction(this); + v.visitJsrInstruction(this); + v.visitJSR(this); + } }