commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1697749 - in /commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6: Constants.java classfile/ConstantPool.java classfile/Utility.java util/CodeHTML.java
Date Tue, 25 Aug 2015 17:58:57 GMT
Author: sebb
Date: Tue Aug 25 17:58:57 2015
New Revision: 1697749

URL: http://svn.apache.org/r1697749
Log:
Prepare for eventual privatisation of other array constants

Modified:
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/Constants.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/classfile/ConstantPool.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/classfile/Utility.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/util/CodeHTML.java

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/Constants.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/Constants.java?rev=1697749&r1=1697748&r2=1697749&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/Constants.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/Constants.java Tue Aug
25 17:58:57 2015
@@ -1528,7 +1528,10 @@ public final class Constants {
    * How the byte code operands are to be interpreted for each opcode.
    * Indexed by opcode.  TYPE_OF_OPERANDS[ILOAD] = an array of shorts
    * describing the data types for the instruction.
+   * @deprecated Do not use; will be made private.
+   * Use getOperandType(int, int) instead
    */
+  @Deprecated
   public static final short[][] TYPE_OF_OPERANDS = {
     {}/*nop*/, {}/*aconst_null*/, {}/*iconst_m1*/, {}/*iconst_0*/,
     {}/*iconst_1*/, {}/*iconst_2*/, {}/*iconst_3*/, {}/*iconst_4*/,
@@ -1594,6 +1597,20 @@ public final class Constants {
   };
 
   /**
+   * @since 6.0
+   */
+  public static short getOperandType(int opcode, int index) {
+      return TYPE_OF_OPERANDS[opcode][index];
+  }
+
+  /**
+   * @since 6.0
+   */
+  public static long getOperandTypeCount(int opcode) {
+      return TYPE_OF_OPERANDS[opcode].length;
+  }
+
+  /**
    * Names of opcodes.  Indexed by opcode.  OPCODE_NAMES[ALOAD] = "aload".
    * @deprecated Do not use; will be made private . Use getOpcodeName(int) instead
    */
@@ -1863,11 +1880,25 @@ public final class Constants {
   public static final byte REF_newInvokeSpecial = 8;
   public static final byte REF_invokeInterface  = 9;
   
-  /** The names of the referencd_kinds of a CONSTANT_MethodHandle_info. */
+  /**
+   * The names of the reference_kinds of a CONSTANT_MethodHandle_info.
+   * @deprecated Do not use; will be made private . Use getMethodHandleName(int) instead
+   */
+  @Deprecated
   public static final String[] METHODHANDLE_NAMES = {
       "", "getField", "getStatic", "putField", "putStatic", "invokeVirtual",
       "invokeStatic", "invokeSpecial", "newInvokeSpecial", "invokeInterface" };
 
+  /**
+   * 
+   * @param index
+   * @return
+   * @since 6.0
+   */
+  public static String getMethodHandleName(int index) {
+      return METHODHANDLE_NAMES[index];
+  }
+
   private Constants() { } // not instantiable
 
 }

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/classfile/ConstantPool.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/classfile/ConstantPool.java?rev=1697749&r1=1697748&r2=1697749&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/classfile/ConstantPool.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/classfile/ConstantPool.java
Tue Aug 25 17:58:57 2015
@@ -145,7 +145,7 @@ public class ConstantPool implements Clo
                 // Note that the ReferenceIndex may point to a Fieldref, Methodref or
                 // InterfaceMethodref - so we need to peek ahead to get the actual type.
                 ConstantMethodHandle cmh = (ConstantMethodHandle) c;
-                str = Constants.METHODHANDLE_NAMES[cmh.getReferenceKind()]
+                str = Constants.getMethodHandleName(cmh.getReferenceKind())
                         + " " + constantToString(cmh.getReferenceIndex(),
                         getConstant(cmh.getReferenceIndex()).getTag());
                 break;            

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/classfile/Utility.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/classfile/Utility.java?rev=1697749&r1=1697748&r2=1697749&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/classfile/Utility.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/classfile/Utility.java
Tue Aug 25 17:58:57 2015
@@ -429,9 +429,9 @@ public abstract class Utility {
                 break;
             default:
                 if (Constants.NO_OF_OPERANDS[opcode] > 0) {
-                    for (int i = 0; i < Constants.TYPE_OF_OPERANDS[opcode].length; i++)
{
+                    for (int i = 0; i < Constants.getOperandTypeCount(opcode); i++) {
                         buf.append("\t\t");
-                        switch (Constants.TYPE_OF_OPERANDS[opcode][i]) {
+                        switch (Constants.getOperandType(opcode, i)) {
                             case Constants.T_BYTE:
                                 buf.append(bytes.readByte());
                                 break;

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/util/CodeHTML.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/util/CodeHTML.java?rev=1697749&r1=1697748&r2=1697749&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/util/CodeHTML.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/util/CodeHTML.java Tue
Aug 25 17:58:57 2015
@@ -355,8 +355,8 @@ final class CodeHTML {
                 break;
             default:
                 if (Constants.NO_OF_OPERANDS[opcode] > 0) {
-                    for (int i = 0; i < Constants.TYPE_OF_OPERANDS[opcode].length; i++)
{
-                        switch (Constants.TYPE_OF_OPERANDS[opcode][i]) {
+                    for (int i = 0; i < Constants.getOperandTypeCount(opcode); i++) {
+                        switch (Constants.getOperandType(opcode, i)) {
                             case Constants.T_BYTE:
                                 buf.append(bytes.readUnsignedByte());
                                 break;
@@ -368,7 +368,7 @@ final class CodeHTML {
                                 break;
                             default: // Never reached
                                 throw new IllegalStateException(
-                                    "Unreachable default case reached! "+Constants.TYPE_OF_OPERANDS[opcode][i]);
+                                    "Unreachable default case reached! "+Constants.getOperandType(opcode,
i));
                         }
                         buf.append("&nbsp;");
                     }



Mime
View raw message