commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1697723 - in /commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic: INVOKEDYNAMIC.java INVOKEINTERFACE.java InvokeInstruction.java JSR.java JSR_W.java LCONST.java LDC.java LDC2_W.java LDC_W.java
Date Tue, 25 Aug 2015 16:28:58 GMT
Author: sebb
Date: Tue Aug 25 16:28:57 2015
New Revision: 1697723

URL: http://svn.apache.org/r1697723
Log:
Replace direct use of external fields with getter/setter

Modified:
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/INVOKEDYNAMIC.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/INVOKEINTERFACE.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/InvokeInstruction.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/JSR.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/JSR_W.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LCONST.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LDC.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LDC2_W.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LDC_W.java

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/INVOKEDYNAMIC.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/INVOKEDYNAMIC.java?rev=1697723&r1=1697722&r2=1697723&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/INVOKEDYNAMIC.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/INVOKEDYNAMIC.java
Tue Aug 25 16:28:57 2015
@@ -54,7 +54,7 @@ public class INVOKEDYNAMIC extends Invok
      */
     @Override
     public void dump( DataOutputStream out ) throws IOException {
-        out.writeByte(opcode);
+        out.writeByte(super.getOpcode());
         out.writeShort(super.getIndex());
         out.writeByte(0);
         out.writeByte(0);
@@ -67,7 +67,7 @@ public class INVOKEDYNAMIC extends Invok
     @Override
     protected void initFromFile( ByteSequence bytes, boolean wide ) throws IOException {
         super.initFromFile(bytes, wide);
-        length = 5;
+        super.setLength(5);
         bytes.readByte(); // Skip 0 byte
         bytes.readByte(); // Skip 0 byte
     }

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/INVOKEINTERFACE.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/INVOKEINTERFACE.java?rev=1697723&r1=1697722&r2=1697723&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/INVOKEINTERFACE.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/INVOKEINTERFACE.java
Tue Aug 25 16:28:57 2015
@@ -46,7 +46,7 @@ public final class INVOKEINTERFACE exten
 
     public INVOKEINTERFACE(int index, int nargs) {
         super(Constants.INVOKEINTERFACE, index);
-        length = 5;
+        super.setLength(5);
         if (nargs < 1) {
             throw new ClassGenException("Number of arguments must be > 0 " + nargs);
         }
@@ -60,7 +60,7 @@ public final class INVOKEINTERFACE exten
      */
     @Override
     public void dump( DataOutputStream out ) throws IOException {
-        out.writeByte(opcode);
+        out.writeByte(super.getOpcode());
         out.writeShort(super.getIndex());
         out.writeByte(nargs);
         out.writeByte(0);
@@ -82,7 +82,7 @@ public final class INVOKEINTERFACE exten
     @Override
     protected void initFromFile( ByteSequence bytes, boolean wide ) throws IOException {
         super.initFromFile(bytes, wide);
-        length = 5;
+        super.setLength(5);
         nargs = bytes.readUnsignedByte();
         bytes.readByte(); // Skip 0 byte
     }

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/InvokeInstruction.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/InvokeInstruction.java?rev=1697723&r1=1697722&r2=1697723&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/InvokeInstruction.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/InvokeInstruction.java
Tue Aug 25 16:28:57 2015
@@ -54,7 +54,7 @@ public abstract class InvokeInstruction
     public String toString( ConstantPool cp ) {
         Constant c = cp.getConstant(super.getIndex());
         StringTokenizer tok = new StringTokenizer(cp.constantToString(c));
-        return Constants.OPCODE_NAMES[opcode] + " " + tok.nextToken().replace('.', '/')
+        return Constants.OPCODE_NAMES[super.getOpcode()] + " " + tok.nextToken().replace('.',
'/')
                 + tok.nextToken();
     }
 
@@ -67,7 +67,7 @@ public abstract class InvokeInstruction
     @Override
     public int consumeStack( ConstantPoolGen cpg ) {
         int sum;
-        if ((opcode == Constants.INVOKESTATIC) || (opcode == Constants.INVOKEDYNAMIC)) {
+        if ((super.getOpcode() == Constants.INVOKESTATIC) || (super.getOpcode() == Constants.INVOKEDYNAMIC))
{
             sum = 0;
         } else {
             sum = 1; // this reference

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/JSR.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/JSR.java?rev=1697723&r1=1697722&r2=1697723&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/JSR.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/JSR.java Tue
Aug 25 16:28:57 2015
@@ -47,11 +47,11 @@ public class JSR extends JsrInstruction
     @Override
     public void dump( DataOutputStream out ) throws IOException {
         super.setIndex(getTargetOffset());
-        if (opcode == org.apache.commons.bcel6.Constants.JSR) {
+        if (super.getOpcode() == org.apache.commons.bcel6.Constants.JSR) {
             super.dump(out);
         } else { // JSR_W
             super.setIndex(getTargetOffset());
-            out.writeByte(opcode);
+            out.writeByte(super.getOpcode());
             out.writeInt(super.getIndex());
         }
     }
@@ -62,10 +62,10 @@ public class JSR extends JsrInstruction
         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)
-            opcode = org.apache.commons.bcel6.Constants.JSR_W;
-            short old_length = length;
-            length = 5;
-            return length - old_length;
+            super.setOpcode(org.apache.commons.bcel6.Constants.JSR_W);
+            short old_length = (short) super.getLength();
+            super.setLength(5);
+            return super.getLength() - old_length;
         }
         return 0;
     }

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/JSR_W.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/JSR_W.java?rev=1697723&r1=1697722&r2=1697723&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/JSR_W.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/JSR_W.java Tue
Aug 25 16:28:57 2015
@@ -39,7 +39,7 @@ public class JSR_W extends JsrInstructio
 
     public JSR_W(InstructionHandle target) {
         super(org.apache.commons.bcel6.Constants.JSR_W, target);
-        length = 5;
+        super.setLength(5);
     }
 
 
@@ -50,7 +50,7 @@ public class JSR_W extends JsrInstructio
     @Override
     public void dump( DataOutputStream out ) throws IOException {
         super.setIndex(getTargetOffset());
-        out.writeByte(opcode);
+        out.writeByte(super.getOpcode());
         out.writeInt(super.getIndex());
     }
 
@@ -61,7 +61,7 @@ public class JSR_W extends JsrInstructio
     @Override
     protected void initFromFile( ByteSequence bytes, boolean wide ) throws IOException {
         super.setIndex(bytes.readInt());
-        length = 5;
+        super.setLength(5);
     }
 
 

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LCONST.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LCONST.java?rev=1697723&r1=1697722&r2=1697723&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LCONST.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LCONST.java Tue
Aug 25 16:28:57 2015
@@ -40,9 +40,9 @@ public class LCONST extends Instruction
     public LCONST(long l) {
         super(org.apache.commons.bcel6.Constants.LCONST_0, (short) 1);
         if (l == 0) {
-            opcode = org.apache.commons.bcel6.Constants.LCONST_0;
+            super.setOpcode(org.apache.commons.bcel6.Constants.LCONST_0);
         } else if (l == 1) {
-            opcode = org.apache.commons.bcel6.Constants.LCONST_1;
+            super.setOpcode(org.apache.commons.bcel6.Constants.LCONST_1);
         } else {
             throw new ClassGenException("LCONST can be used only for 0 and 1: " + l);
         }

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LDC.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LDC.java?rev=1697723&r1=1697722&r2=1697723&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LDC.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LDC.java Tue
Aug 25 16:28:57 2015
@@ -50,10 +50,10 @@ public class LDC extends CPInstruction i
     protected final void setSize() {
         if (super.getIndex() <= org.apache.commons.bcel6.Constants.MAX_BYTE) { // Fits
in one byte?
             super.setOpcode(org.apache.commons.bcel6.Constants.LDC);
-            length = 2;
+            super.setLength(2);
         } else {
             super.setOpcode(org.apache.commons.bcel6.Constants.LDC_W);
-            length = 3;
+            super.setLength(3);
         }
     }
 
@@ -64,8 +64,8 @@ public class LDC extends CPInstruction i
      */
     @Override
     public void dump( DataOutputStream out ) throws IOException {
-        out.writeByte(opcode);
-        if (length == 2) {
+        out.writeByte(super.getOpcode());
+        if (super.getLength() == 2) { // TODO useless check?
             out.writeByte(super.getIndex());
         } else {
             out.writeShort(super.getIndex());
@@ -88,7 +88,7 @@ public class LDC extends CPInstruction i
      */
     @Override
     protected void initFromFile( ByteSequence bytes, boolean wide ) throws IOException {
-        length = 2;
+        super.setLength(2);
         super.setIndex(bytes.readUnsignedByte());
     }
 

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LDC2_W.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LDC2_W.java?rev=1697723&r1=1697722&r2=1697723&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LDC2_W.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LDC2_W.java Tue
Aug 25 16:28:57 2015
@@ -47,7 +47,7 @@ public class LDC2_W extends CPInstructio
             case org.apache.commons.bcel6.Constants.CONSTANT_Double:
                 return Type.DOUBLE;
             default: // Never reached
-                throw new RuntimeException("Unknown constant type " + opcode);
+                throw new RuntimeException("Unknown constant type " + super.getOpcode());
         }
     }
 

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LDC_W.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LDC_W.java?rev=1697723&r1=1697722&r2=1697723&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LDC_W.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LDC_W.java Tue
Aug 25 16:28:57 2015
@@ -50,7 +50,7 @@ public class LDC_W extends LDC {
     protected void initFromFile( ByteSequence bytes, boolean wide ) throws IOException {
         setIndex(bytes.readUnsignedShort());
         // Override just in case it has been changed
-        opcode = org.apache.commons.bcel6.Constants.LDC_W;
-        length = 3;
+        super.setOpcode(org.apache.commons.bcel6.Constants.LDC_W);
+        super.setLength(3);
     }
 }



Mime
View raw message