--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/Select.java Tue Jun 25 18:46:51 2019 -0700
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/Select.java Wed Jun 26 05:49:59 2019 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -27,13 +27,13 @@
/**
* Select - Abstract super class for LOOKUPSWITCH and TABLESWITCH instructions.
*
- * <p>
- * We use our super's <code>target</code> property as the default target.
+ * <p>We use our super's <code>target</code> property as the default target.
*
- * @version $Id: Select.java 1749603 2016-06-21 20:50:19Z ggregory $
+ * @version $Id$
* @see LOOKUPSWITCH
* @see TABLESWITCH
* @see InstructionList
+ * @LastModified: Jun 2019
*/
public abstract class Select extends BranchInstruction implements VariableLengthInstruction,
StackConsumer /* @since 6.0 */, StackProducer {
@@ -52,9 +52,10 @@
Select() {
}
+
/**
- * (Match, target) pairs for switch. `Match' and `targets' must have the
- * same length of course.
+ * (Match, target) pairs for switch.
+ * `Match' and `targets' must have the same length of course.
*
* @param match array of matching values
* @param targets instruction targets
@@ -71,31 +72,28 @@
notifyTarget(null, target2, this);
}
if ((match_length = match.length) != targets.length) {
- throw new ClassGenException("Match and target array have not the same length: Match length: "
- + match.length + " Target length: " + targets.length);
+ throw new ClassGenException("Match and target array have not the same length: Match length: " +
+ match.length + " Target length: " + targets.length);
}
indices = new int[match_length];
}
+
/**
* Since this is a variable length instruction, it may shift the following
* instructions which then need to update their position.
*
- * Called by InstructionList.setPositions when setting the position for
- * every instruction. In the presence of variable length instructions
- * `setPositions' performs multiple passes over the instruction list to
- * calculate the correct (byte) positions and offsets by calling this
- * function.
+ * Called by InstructionList.setPositions when setting the position for every
+ * instruction. In the presence of variable length instructions `setPositions'
+ * performs multiple passes over the instruction list to calculate the
+ * correct (byte) positions and offsets by calling this function.
*
- * @param offset additional offset caused by preceding (variable length)
- * instructions
- * @param max_offset the maximum offset that may be caused by these
- * instructions
- * @return additional offset caused by possible change of this instruction's
- * length
+ * @param offset additional offset caused by preceding (variable length) instructions
+ * @param max_offset the maximum offset that may be caused by these instructions
+ * @return additional offset caused by possible change of this instruction's length
*/
@Override
- protected int updatePosition(final int offset, final int max_offset) {
+ protected int updatePosition( final int offset, final int max_offset ) {
setPosition(getPosition() + offset); // Additional offset caused by preceding SWITCHs, GOTOs, etc.
final short old_length = (short) super.getLength();
/* Alignment on 4-byte-boundary, + 1, because of tag byte.
@@ -105,13 +103,13 @@
return super.getLength() - old_length;
}
+
/**
* Dump instruction as byte code to stream out.
- *
* @param out Output stream
*/
@Override
- public void dump(final DataOutputStream out) throws IOException {
+ public void dump( final DataOutputStream out ) throws IOException {
out.writeByte(super.getOpcode());
for (int i = 0; i < padding; i++) {
out.writeByte(0);
@@ -120,11 +118,12 @@
out.writeInt(super.getIndex());
}
+
/**
* Read needed data (e.g. index) from file.
*/
@Override
- protected void initFromFile(final ByteSequence bytes, final boolean wide) throws IOException {
+ protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException {
padding = (4 - (bytes.getIndex() % 4)) % 4; // Compute number of pad bytes
for (int i = 0; i < padding; i++) {
bytes.readByte();
@@ -133,11 +132,12 @@
super.setIndex(bytes.readInt());
}
+
/**
* @return mnemonic for instruction
*/
@Override
- public String toString(final boolean verbose) {
+ public String toString( final boolean verbose ) {
final StringBuilder buf = new StringBuilder(super.toString(verbose));
if (verbose) {
for (int i = 0; i < match_length; i++) {
@@ -154,20 +154,22 @@
return buf.toString();
}
+
/**
* Set branch target for `i'th case
*/
- public void setTarget(final int i, final InstructionHandle target) { // TODO could be package-protected?
+ public void setTarget( final int i, final InstructionHandle target ) { // TODO could be package-protected?
notifyTarget(targets[i], target, this);
targets[i] = target;
}
+
/**
* @param old_ih old target
* @param new_ih new target
*/
@Override
- public void updateTarget(final InstructionHandle old_ih, final InstructionHandle new_ih) {
+ public void updateTarget( final InstructionHandle old_ih, final InstructionHandle new_ih ) {
boolean targeted = false;
if (super.getTarget() == old_ih) {
targeted = true;
@@ -184,11 +186,12 @@
}
}
+
/**
* @return true, if ih is target of this instruction
*/
@Override
- public boolean containsTarget(final InstructionHandle ih) {
+ public boolean containsTarget( final InstructionHandle ih ) {
if (super.getTarget() == ih) {
return true;
}
@@ -200,6 +203,7 @@
return false;
}
+
@Override
protected Object clone() throws CloneNotSupportedException {
final Select copy = (Select) super.clone();
@@ -209,6 +213,7 @@
return copy;
}
+
/**
* Inform targets that they're not targeted anymore.
*/
@@ -220,6 +225,7 @@
}
}
+
/**
* @return array of match indices
*/
@@ -227,6 +233,7 @@
return match;
}
+
/**
* @return array of match target offsets
*/
@@ -234,6 +241,7 @@
return indices;
}
+
/**
* @return array of match targets
*/
@@ -249,6 +257,7 @@
return match[index];
}
+
/**
* @return index entry from indices
* @since 6.0
@@ -265,6 +274,7 @@
return targets[index];
}
+
/**
* @return the fixed_length
* @since 6.0
@@ -273,6 +283,7 @@
return fixed_length;
}
+
/**
* @param fixed_length the fixed_length to set
* @since 6.0
@@ -281,6 +292,7 @@
this.fixed_length = fixed_length;
}
+
/**
* @return the match_length
* @since 6.0
@@ -289,6 +301,7 @@
return match_length;
}
+
/**
* @param match_length the match_length to set
* @since 6.0
@@ -344,9 +357,8 @@
return padding;
}
- /**
- * @since 6.0
- */
+
+ /** @since 6.0 */
final int setIndices(final int i, final int value) {
indices[i] = value;
return value; // Allow use in nested calls