You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2015/08/25 18:57:15 UTC
svn commit: r1697736 - in
/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic:
BranchInstruction.java LocalVariableInstruction.java Select.java
Author: sebb
Date: Tue Aug 25 16:57:15 2015
New Revision: 1697736
URL: http://svn.apache.org/r1697736
Log:
Replace direct use of external fields with getter/setter
Modified:
commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/BranchInstruction.java
commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LocalVariableInstruction.java
commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/Select.java
Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/BranchInstruction.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/BranchInstruction.java?rev=1697736&r1=1697735&r2=1697736&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/BranchInstruction.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/BranchInstruction.java Tue Aug 25 16:57:15 2015
@@ -75,7 +75,7 @@ public abstract class BranchInstruction
*/
@Override
public void dump( DataOutputStream out ) throws IOException {
- out.writeByte(opcode);
+ out.writeByte(super.getOpcode());
index = getTargetOffset();
if (!isValidShort(index)) {
throw new ClassGenException("Branch target offset too large for short: " + index);
@@ -176,7 +176,7 @@ public abstract class BranchInstruction
*/
@Override
protected void initFromFile( ByteSequence bytes, boolean wide ) throws IOException {
- length = 3;
+ super.setLength(3);
index = bytes.readShort();
}
Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LocalVariableInstruction.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LocalVariableInstruction.java?rev=1697736&r1=1697735&r2=1697736&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LocalVariableInstruction.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LocalVariableInstruction.java Tue Aug 25 16:57:15 2015
@@ -88,8 +88,8 @@ public abstract class LocalVariableInstr
if (wide()) {
out.writeByte(Constants.WIDE);
}
- out.writeByte(opcode);
- if (length > 1) { // Otherwise ILOAD_n, instruction, e.g.
+ out.writeByte(super.getOpcode());
+ if (super.getLength() > 1) { // Otherwise ILOAD_n, instruction, e.g.
if (wide()) {
out.writeShort(n);
} else {
@@ -110,8 +110,9 @@ public abstract class LocalVariableInstr
*/
@Override
public String toString( boolean verbose ) {
- if (((opcode >= Constants.ILOAD_0) && (opcode <= Constants.ALOAD_3))
- || ((opcode >= Constants.ISTORE_0) && (opcode <= Constants.ASTORE_3))) {
+ final short _opcode = super.getOpcode();
+ if (((_opcode >= Constants.ILOAD_0) && (_opcode <= Constants.ALOAD_3))
+ || ((_opcode >= Constants.ISTORE_0) && (_opcode <= Constants.ASTORE_3))) {
return super.toString(verbose);
}
return super.toString(verbose) + " " + n;
@@ -128,17 +129,20 @@ public abstract class LocalVariableInstr
protected void initFromFile( ByteSequence bytes, boolean wide ) throws IOException {
if (wide) {
n = bytes.readUnsignedShort();
- length = 4;
- } else if (((opcode >= Constants.ILOAD) && (opcode <= Constants.ALOAD))
- || ((opcode >= Constants.ISTORE) && (opcode <= Constants.ASTORE))) {
- n = bytes.readUnsignedByte();
- length = 2;
- } else if (opcode <= Constants.ALOAD_3) { // compact load instruction such as ILOAD_2
- n = (opcode - Constants.ILOAD_0) % 4;
- length = 1;
- } else { // Assert ISTORE_0 <= tag <= ASTORE_3
- n = (opcode - Constants.ISTORE_0) % 4;
- length = 1;
+ super.setLength(4);
+ } else {
+ final short _opcode = super.getOpcode();
+ if (((_opcode >= Constants.ILOAD) && (_opcode <= Constants.ALOAD))
+ || ((_opcode >= Constants.ISTORE) && (_opcode <= Constants.ASTORE))) {
+ n = bytes.readUnsignedByte();
+ super.setLength(2);
+ } else if (_opcode <= Constants.ALOAD_3) { // compact load instruction such as ILOAD_2
+ n = (_opcode - Constants.ILOAD_0) % 4;
+ super.setLength(1);
+ } else { // Assert ISTORE_0 <= tag <= ASTORE_3
+ n = (_opcode - Constants.ISTORE_0) % 4;
+ super.setLength(1);
+ }
}
}
@@ -166,14 +170,14 @@ public abstract class LocalVariableInstr
this.n = n;
// Cannot be < 0 as this is checked above
if (n <= 3) { // Use more compact instruction xLOAD_n
- opcode = (short) (c_tag + n);
- length = 1;
+ super.setOpcode((short) (c_tag + n));
+ super.setLength(1);
} else {
- opcode = canon_tag;
+ super.setOpcode(canon_tag);
if (wide()) {
- length = 4;
+ super.setLength(4);
} else {
- length = 2;
+ super.setLength(2);
}
}
}
Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/Select.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/Select.java?rev=1697736&r1=1697735&r2=1697736&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/Select.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/Select.java Tue Aug 25 16:57:15 2015
@@ -119,12 +119,12 @@ public abstract class Select extends Bra
@Override
protected int updatePosition( int offset, int max_offset ) {
setPosition(getPosition() + offset); // Additional offset caused by preceding SWITCHs, GOTOs, etc.
- short old_length = length;
+ short old_length = (short) super.getLength();
/* Alignment on 4-byte-boundary, + 1, because of tag byte.
*/
padding = (4 - ((getPosition() + 1) % 4)) % 4;
- length = (short) (fixed_length + padding); // Update length
- return length - old_length;
+ super.setLength((short) (fixed_length + padding)); // Update length
+ return super.getLength() - old_length;
}
@@ -134,7 +134,7 @@ public abstract class Select extends Bra
*/
@Override
public void dump( DataOutputStream out ) throws IOException {
- out.writeByte(opcode);
+ out.writeByte(super.getOpcode());
for (int i = 0; i < padding; i++) {
out.writeByte(0);
}