commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1697699 - in /commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic: ArithmeticInstruction.java ArrayInstruction.java BIPUSH.java BranchHandle.java ConversionInstruction.java DCONST.java FCONST.java FieldGen.java
Date Tue, 25 Aug 2015 15:27:48 GMT
Author: sebb
Date: Tue Aug 25 15:27:48 2015
New Revision: 1697699

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

Modified:
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/ArithmeticInstruction.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/ArrayInstruction.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/BIPUSH.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/BranchHandle.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/ConversionInstruction.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/DCONST.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/FCONST.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/FieldGen.java

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/ArithmeticInstruction.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/ArithmeticInstruction.java?rev=1697699&r1=1697698&r2=1697699&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/ArithmeticInstruction.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/ArithmeticInstruction.java
Tue Aug 25 15:27:48 2015
@@ -47,7 +47,8 @@ public abstract class ArithmeticInstruct
      */
     @Override
     public Type getType( ConstantPoolGen cp ) {
-        switch (opcode) {
+        final short _opcode = super.getOpcode();
+        switch (_opcode) {
             case Constants.DADD:
             case Constants.DDIV:
             case Constants.DMUL:
@@ -89,7 +90,7 @@ public abstract class ArithmeticInstruct
             case Constants.LXOR:
                 return Type.LONG;
             default: // Never reached
-                throw new ClassGenException("Unknown type " + opcode);
+                throw new ClassGenException("Unknown type " + _opcode);
         }
     }
 }

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/ArrayInstruction.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/ArrayInstruction.java?rev=1697699&r1=1697698&r2=1697699&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/ArrayInstruction.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/ArrayInstruction.java
Tue Aug 25 15:27:48 2015
@@ -53,7 +53,8 @@ public abstract class ArrayInstruction e
      */
     @Override
     public Type getType( ConstantPoolGen cp ) {
-        switch (opcode) {
+        final short _opcode = super.getOpcode();
+        switch (_opcode) {
             case org.apache.commons.bcel6.Constants.IALOAD:
             case org.apache.commons.bcel6.Constants.IASTORE:
                 return Type.INT;
@@ -79,7 +80,7 @@ public abstract class ArrayInstruction e
             case org.apache.commons.bcel6.Constants.AASTORE:
                 return Type.OBJECT;
             default:
-                throw new ClassGenException("Oops: unknown case in switch" + opcode);
+                throw new ClassGenException("Oops: unknown case in switch" + _opcode);
         }
     }
 }

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/BIPUSH.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/BIPUSH.java?rev=1697699&r1=1697698&r2=1697699&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/BIPUSH.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/BIPUSH.java Tue
Aug 25 15:27:48 2015
@@ -74,7 +74,7 @@ public class BIPUSH extends Instruction
      */
     @Override
     protected void initFromFile( ByteSequence bytes, boolean wide ) throws IOException {
-        length = 2;
+        super.setLength(2);
         b = bytes.readByte();
     }
 

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/BranchHandle.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/BranchHandle.java?rev=1697699&r1=1697698&r2=1697699&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/BranchHandle.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/BranchHandle.java
Tue Aug 25 15:27:48 2015
@@ -44,7 +44,7 @@ public final class BranchHandle extends
             return new BranchHandle(i);
         }
         BranchHandle bh = bh_list;
-        bh_list = (BranchHandle) bh.next;
+        bh_list = (BranchHandle) bh.getNext();
         bh.setInstruction(i);
         return bh;
     }
@@ -54,7 +54,7 @@ public final class BranchHandle extends
      */
     @Override
     protected void addHandle() {
-        next = bh_list;
+        super.setNext(bh_list);
         bh_list = this;
     }
 
@@ -78,14 +78,14 @@ public final class BranchHandle extends
     void setPosition( int pos ) {
         // Original code: i_position = bi.position = pos;
         getBI().setPosition(pos);
-        i_position = pos;
+        super.setPosition(pos);
     }
 
 
     @Override
     protected int updatePosition( int offset, int max_offset ) {
         int x = getBI().updatePosition(offset, max_offset);
-        i_position = getBI().getPosition();
+        super.setPosition(getBI().getPosition());
         return x;
     }
 

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/ConversionInstruction.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/ConversionInstruction.java?rev=1697699&r1=1697698&r2=1697699&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/ConversionInstruction.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/ConversionInstruction.java
Tue Aug 25 15:27:48 2015
@@ -47,7 +47,8 @@ public abstract class ConversionInstruct
      */
     @Override
     public Type getType( ConstantPoolGen cp ) {
-        switch (opcode) {
+        final short _opcode = super.getOpcode();
+        switch (_opcode) {
             case Constants.D2I:
             case Constants.F2I:
             case Constants.L2I:
@@ -71,7 +72,7 @@ public abstract class ConversionInstruct
             case Constants.I2S:
                 return Type.SHORT;
             default: // Never reached
-                throw new ClassGenException("Unknown type " + opcode);
+                throw new ClassGenException("Unknown type " + _opcode);
         }
     }
 }

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/DCONST.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/DCONST.java?rev=1697699&r1=1697698&r2=1697699&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/DCONST.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/DCONST.java Tue
Aug 25 15:27:48 2015
@@ -40,9 +40,9 @@ public class DCONST extends Instruction
     public DCONST(double f) {
         super(org.apache.commons.bcel6.Constants.DCONST_0, (short) 1);
         if (f == 0.0) {
-            opcode = org.apache.commons.bcel6.Constants.DCONST_0;
+            super.setOpcode(org.apache.commons.bcel6.Constants.DCONST_0);
         } else if (f == 1.0) {
-            opcode = org.apache.commons.bcel6.Constants.DCONST_1;
+            super.setOpcode(org.apache.commons.bcel6.Constants.DCONST_1);
         } else {
             throw new ClassGenException("DCONST can be used only for 0.0 and 1.0: " + f);
         }

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/FCONST.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/FCONST.java?rev=1697699&r1=1697698&r2=1697699&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/FCONST.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/FCONST.java Tue
Aug 25 15:27:48 2015
@@ -40,11 +40,11 @@ public class FCONST extends Instruction
     public FCONST(float f) {
         super(org.apache.commons.bcel6.Constants.FCONST_0, (short) 1);
         if (f == 0.0) {
-            opcode = org.apache.commons.bcel6.Constants.FCONST_0;
+            super.setOpcode(org.apache.commons.bcel6.Constants.FCONST_0);
         } else if (f == 1.0) {
-            opcode = org.apache.commons.bcel6.Constants.FCONST_1;
+            super.setOpcode(org.apache.commons.bcel6.Constants.FCONST_1);
         } else if (f == 2.0) {
-            opcode = org.apache.commons.bcel6.Constants.FCONST_2;
+            super.setOpcode(org.apache.commons.bcel6.Constants.FCONST_2);
         } else {
             throw new ClassGenException("FCONST can be used only for 0.0, 1.0 and 2.0: "
+ f);
         }

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/FieldGen.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/FieldGen.java?rev=1697699&r1=1697698&r2=1697699&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/FieldGen.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/FieldGen.java
Tue Aug 25 15:27:48 2015
@@ -106,7 +106,7 @@ public class FieldGen extends FieldGenOr
 
 
     private void setValue( int index ) {
-        ConstantPool cp = this.cp.getConstantPool();
+        ConstantPool cp = super.getConstantPool().getConstantPool();
         Constant c = cp.getConstant(index);
         value = ((ConstantObject) c).getConstantValue(cp);
     }
@@ -196,14 +196,15 @@ public class FieldGen extends FieldGenOr
 
 
     private void checkType( Type atype ) {
-        if (type == null) {
+        final Type superType = super.getType();
+        if (superType == null) {
             throw new ClassGenException("You haven't defined the type of the field yet");
         }
         if (!isFinal()) {
             throw new ClassGenException("Only final fields may have an initial value!");
         }
-        if (!type.equals(atype)) {
-            throw new ClassGenException("Types are not compatible: " + type + " vs. " + atype);
+        if (!superType.equals(atype)) {
+            throw new ClassGenException("Types are not compatible: " + superType + " vs.
" + atype);
         }
     }
 
@@ -213,17 +214,17 @@ public class FieldGen extends FieldGenOr
      */
     public Field getField() {
         String signature = getSignature();
-        int name_index = cp.addUtf8(name);
-        int signature_index = cp.addUtf8(signature);
+        int name_index = super.getConstantPool().addUtf8(super.getName());
+        int signature_index = super.getConstantPool().addUtf8(signature);
         if (value != null) {
-            checkType(type);
+            checkType(super.getType());
             int index = addConstant();
-            addAttribute(new ConstantValue(cp.addUtf8("ConstantValue"), 2, index, cp
-                    .getConstantPool()));
+            addAttribute(new ConstantValue(super.getConstantPool().addUtf8("ConstantValue"),
2, index, 
+                    super.getConstantPool().getConstantPool())); // sic
         }
-        addAnnotationsAsAttribute(cp);
-        return new Field(super.getAccessFlags(), name_index, signature_index, getAttributes(),
cp
-                .getConstantPool());
+        addAnnotationsAsAttribute(super.getConstantPool());
+        return new Field(super.getAccessFlags(), name_index, signature_index, getAttributes(),

+                super.getConstantPool().getConstantPool()); // sic
     }
 
     private void addAnnotationsAsAttribute(ConstantPoolGen cp) {
@@ -235,30 +236,30 @@ public class FieldGen extends FieldGenOr
 
 
     private int addConstant() {
-        switch (type.getType()) {
+        switch (super.getType().getType()) { // sic
             case Constants.T_INT:
             case Constants.T_CHAR:
             case Constants.T_BYTE:
             case Constants.T_BOOLEAN:
             case Constants.T_SHORT:
-                return cp.addInteger(((Integer) value).intValue());
+                return super.getConstantPool().addInteger(((Integer) value).intValue());
             case Constants.T_FLOAT:
-                return cp.addFloat(((Float) value).floatValue());
+                return super.getConstantPool().addFloat(((Float) value).floatValue());
             case Constants.T_DOUBLE:
-                return cp.addDouble(((Double) value).doubleValue());
+                return super.getConstantPool().addDouble(((Double) value).doubleValue());
             case Constants.T_LONG:
-                return cp.addLong(((Long) value).longValue());
+                return super.getConstantPool().addLong(((Long) value).longValue());
             case Constants.T_REFERENCE:
-                return cp.addString((String) value);
+                return super.getConstantPool().addString((String) value);
             default:
-                throw new RuntimeException("Oops: Unhandled : " + type.getType());
+                throw new RuntimeException("Oops: Unhandled : " + super.getType().getType());
// sic
         }
     }
 
 
     @Override
     public String getSignature() {
-        return type.getSignature();
+        return super.getType().getSignature();
     }
 
     private List<FieldObserver> observers;
@@ -317,7 +318,7 @@ public class FieldGen extends FieldGenOr
         String access; // Short cuts to constant pool
         access = Utility.accessToString(super.getAccessFlags());
         access = access.equals("") ? "" : (access + " ");
-        signature = type.toString();
+        signature = super.getType().toString();
         name = getName();
         StringBuilder buf = new StringBuilder(32); // CHECKSTYLE IGNORE MagicNumber
         buf.append(access).append(signature).append(" ").append(name);



Mime
View raw message