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:47:29 UTC

svn commit: r1697732 - in /commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic: LOOKUPSWITCH.java TABLESWITCH.java

Author: sebb
Date: Tue Aug 25 16:47:29 2015
New Revision: 1697732

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

Modified:
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LOOKUPSWITCH.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/TABLESWITCH.java

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LOOKUPSWITCH.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LOOKUPSWITCH.java?rev=1697732&r1=1697731&r2=1697732&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LOOKUPSWITCH.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LOOKUPSWITCH.java Tue Aug 25 16:47:29 2015
@@ -40,9 +40,10 @@ public class LOOKUPSWITCH extends Select
 
     public LOOKUPSWITCH(int[] match, InstructionHandle[] targets, InstructionHandle defaultTarget) {
         super(org.apache.commons.bcel6.Constants.LOOKUPSWITCH, match, targets, defaultTarget);
-        length = (short) (9 + match_length * 8); /* alignment remainder assumed
-         * 0 here, until dump time. */
-        fixed_length = length;
+        /* alignment remainder assumed 0 here, until dump time. */
+        final short _length = (short) (9 + getMatch_length() * 8);
+        super.setLength(_length);
+        setFixed_length(_length);
     }
 
 
@@ -53,10 +54,11 @@ public class LOOKUPSWITCH extends Select
     @Override
     public void dump( DataOutputStream out ) throws IOException {
         super.dump(out);
-        out.writeInt(match_length); // npairs
-        for (int i = 0; i < match_length; i++) {
-            out.writeInt(match[i]); // match-offset pairs
-            out.writeInt(indices[i] = getTargetOffset(targets[i]));
+        final int _match_length = getMatch_length();
+        out.writeInt(_match_length); // npairs
+        for (int i = 0; i < _match_length; i++) {
+            out.writeInt(super.getMatch(i)); // match-offset pairs
+            out.writeInt(setIndices(i, getTargetOffset(super.getTarget(i))));
         }
     }
 
@@ -67,15 +69,18 @@ public class LOOKUPSWITCH extends Select
     @Override
     protected void initFromFile( ByteSequence bytes, boolean wide ) throws IOException {
         super.initFromFile(bytes, wide); // reads padding
-        match_length = bytes.readInt();
-        fixed_length = (short) (9 + match_length * 8);
-        length = (short) (fixed_length + padding);
-        match = new int[match_length];
-        indices = new int[match_length];
-        targets = new InstructionHandle[match_length];
-        for (int i = 0; i < match_length; i++) {
-            match[i] = bytes.readInt();
-            indices[i] = bytes.readInt();
+        final int _match_length = bytes.readInt();
+        setMatch_length(_match_length);
+        final short _fixed_length = (short) (9 + _match_length * 8);
+        setFixed_length(_fixed_length);
+        final short _length = (short) (_match_length + super.getPadding());
+        super.setLength(_length);
+        super.setMatches(new int[_match_length]);
+        super.setIndices(new int[_match_length]);
+        super.setTargets(new InstructionHandle[_match_length]);
+        for (int i = 0; i < _match_length; i++) {
+            super.setMatch(i, bytes.readInt());
+            super.setIndices(i, bytes.readInt());
         }
     }
 

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/TABLESWITCH.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/TABLESWITCH.java?rev=1697732&r1=1697731&r2=1697732&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/TABLESWITCH.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/TABLESWITCH.java Tue Aug 25 16:47:29 2015
@@ -46,9 +46,10 @@ public class TABLESWITCH extends Select
      */
     public TABLESWITCH(int[] match, InstructionHandle[] targets, InstructionHandle defaultTarget) {
         super(org.apache.commons.bcel6.Constants.TABLESWITCH, match, targets, defaultTarget);
-        length = (short) (13 + match_length * 4); /* Alignment remainder assumed
-         * 0 here, until dump time */
-        fixed_length = length;
+        /* Alignment remainder assumed 0 here, until dump time */
+        final short _length = (short) (13 + getMatch_length() * 4);
+        super.setLength(_length);
+        setFixed_length(_length);
     }
 
 
@@ -59,12 +60,13 @@ public class TABLESWITCH extends Select
     @Override
     public void dump( DataOutputStream out ) throws IOException {
         super.dump(out);
-        int low = (match_length > 0) ? match[0] : 0;
+        final int _match_length = getMatch_length();
+        int low = (_match_length > 0) ? super.getMatch(0) : 0;
         out.writeInt(low);
-        int high = (match_length > 0) ? match[match_length - 1] : 0;
+        int high = (_match_length > 0) ? super.getMatch(_match_length - 1) : 0;
         out.writeInt(high);
-        for (int i = 0; i < match_length; i++) {
-            out.writeInt(indices[i] = getTargetOffset(targets[i]));
+        for (int i = 0; i < _match_length; i++) {
+            out.writeInt(setIndices(i, getTargetOffset(super.getTarget(i))));
         }
     }
 
@@ -77,15 +79,17 @@ public class TABLESWITCH extends Select
         super.initFromFile(bytes, wide);
         int low = bytes.readInt();
         int high = bytes.readInt();
-        match_length = high - low + 1;
-        fixed_length = (short) (13 + match_length * 4);
-        length = (short) (fixed_length + padding);
-        match = new int[match_length];
-        indices = new int[match_length];
-        targets = new InstructionHandle[match_length];
-        for (int i = 0; i < match_length; i++) {
-            match[i] = low + i;
-            indices[i] = bytes.readInt();
+        final int _match_length = high - low + 1;
+        setMatch_length(_match_length);
+        final short _fixed_length = (short) (13 + _match_length * 4);
+        setFixed_length(_fixed_length);
+        super.setLength((short) (_fixed_length + super.getPadding()));
+        super.setMatches(new int[_match_length]);
+        super.setIndices(new int[_match_length]);
+        super.setTargets(new InstructionHandle[_match_length]);
+        for (int i = 0; i < _match_length; i++) {
+            super.setMatch(i, low + i);
+            super.setIndices(i, bytes.readInt());
         }
     }