commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ebo...@apache.org
Subject svn commit: r1646789 - in /commons/proper/bcel/trunk/src/main/java/org/apache/bcel: Constants.java classfile/ConstantPool.java
Date Fri, 19 Dec 2014 16:20:06 GMT
Author: ebourg
Date: Fri Dec 19 16:20:06 2014
New Revision: 1646789

URL: http://svn.apache.org/r1646789
Log:
Implement constantToString for MethodHandle, MethodType and InvokeDynamic

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

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/Constants.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/Constants.java?rev=1646789&r1=1646788&r2=1646789&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/Constants.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/Constants.java Fri Dec 19 16:20:06
2014
@@ -1511,4 +1511,23 @@ public static final byte ATTR_RUNTIMEINV
   public static final int SAME_LOCALS_1_STACK_ITEM_FRAME_MAX = 127;
   public static final int CHOP_FRAME_MAX = 250;
   public static final int APPEND_FRAME_MAX = 254;
+
+
+  // Constants defining the behavior of the Method Handles (JVMS ยง5.4.3.5)
+  
+  public static final byte REF_getField         = 1;
+  public static final byte REF_getStatic        = 2;
+  public static final byte REF_putField         = 3;
+  public static final byte REF_putStatic        = 4;
+  public static final byte REF_invokeVirtual    = 5;
+  public static final byte REF_invokeStatic     = 6;
+  public static final byte REF_invokeSpecial    = 7;
+  public static final byte REF_newInvokeSpecial = 8;
+  public static final byte REF_invokeInterface  = 9;
+  
+  public static final String[] REF_NAMES = {
+          "getfield", "getstatic", "putfield", 
+          "putstatic", "invokevirtual", "invokestatic", 
+          "invokespecial", "new dup invokespecial", "invokeinterface"
+  };
 }

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/classfile/ConstantPool.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/classfile/ConstantPool.java?rev=1646789&r1=1646788&r2=1646789&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/classfile/ConstantPool.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/classfile/ConstantPool.java Fri
Dec 19 16:20:06 2014
@@ -143,6 +143,18 @@ public class ConstantPool implements Clo
                         + "." + constantToString(((ConstantCP) c).getNameAndTypeIndex(),
                         Constants.CONSTANT_NameAndType));
                 break;
+            case Constants.CONSTANT_MethodHandle:
+                ConstantMethodHandle cmh = (ConstantMethodHandle) c;
+                str = Constants.REF_NAMES[cmh.getReferenceKind()] + " " + constantToString(constant_pool[cmh.getReferenceIndex()]);
+                break;            
+            case Constants.CONSTANT_MethodType:
+                ConstantMethodType cmt = (ConstantMethodType) c;
+                str = constantToString(cmt.getDescriptorIndex(), Constants.CONSTANT_Utf8);
+                break;
+            case Constants.CONSTANT_InvokeDynamic:
+                ConstantInvokeDynamic cid = ((ConstantInvokeDynamic) c);
+                str = cid.getBootstrapMethodAttrIndex() + ": " + constantToString(cid.getNameAndTypeIndex(),
Constants.CONSTANT_NameAndType);
+                break;
             default: // Never reached
                 throw new RuntimeException("Unknown constant type " + tag);
         }



Mime
View raw message