comparison agent/src/share/classes/sun/jvm/hotspot/interpreter/BytecodeInvoke.java @ 1602:136b78722a08

6939203: JSR 292 needs method handle constants Summary: Add new CP types CONSTANT_MethodHandle, CONSTANT_MethodType; extend 'ldc' bytecode. Reviewed-by: twisti, never
author jrose
date Wed, 09 Jun 2010 18:50:45 -0700
parents c18cbe5936b8
children 0a8e0d4345b3
comparison
equal deleted inserted replaced
1585:49fac4acd688 1602:136b78722a08
52 } 52 }
53 53
54 // returns the name of the invoked method 54 // returns the name of the invoked method
55 public Symbol name() { 55 public Symbol name() {
56 ConstantPool cp = method().getConstants(); 56 ConstantPool cp = method().getConstants();
57 if (isInvokedynamic()) {
58 int[] nt = cp.getNameAndTypeAt(indexForFieldOrMethod());
59 return cp.getSymbolAt(nt[0]);
60 }
57 return cp.getNameRefAt(index()); 61 return cp.getNameRefAt(index());
58 } 62 }
59 63
60 // returns the signature of the invoked method 64 // returns the signature of the invoked method
61 public Symbol signature() { 65 public Symbol signature() {
62 ConstantPool cp = method().getConstants(); 66 ConstantPool cp = method().getConstants();
67 if (isInvokedynamic()) {
68 int[] nt = cp.getNameAndTypeAt(indexForFieldOrMethod());
69 return cp.getSymbolAt(nt[1]);
70 }
63 return cp.getSignatureRefAt(index()); 71 return cp.getSignatureRefAt(index());
72 }
73
74 public int getSecondaryIndex() {
75 if (isInvokedynamic()) {
76 // change byte-ordering of 4-byte integer
77 return VM.getVM().getBytes().swapInt(javaSignedWordAt(1));
78 }
79 return super.getSecondaryIndex(); // throw an error
64 } 80 }
65 81
66 public Method getInvokedMethod() { 82 public Method getInvokedMethod() {
67 return method().getConstants().getMethodRefAt(index()); 83 return method().getConstants().getMethodRefAt(index());
68 } 84 }
85 // Testers 101 // Testers
86 public boolean isInvokeinterface() { return adjustedInvokeCode() == Bytecodes._invokeinterface; } 102 public boolean isInvokeinterface() { return adjustedInvokeCode() == Bytecodes._invokeinterface; }
87 public boolean isInvokevirtual() { return adjustedInvokeCode() == Bytecodes._invokevirtual; } 103 public boolean isInvokevirtual() { return adjustedInvokeCode() == Bytecodes._invokevirtual; }
88 public boolean isInvokestatic() { return adjustedInvokeCode() == Bytecodes._invokestatic; } 104 public boolean isInvokestatic() { return adjustedInvokeCode() == Bytecodes._invokestatic; }
89 public boolean isInvokespecial() { return adjustedInvokeCode() == Bytecodes._invokespecial; } 105 public boolean isInvokespecial() { return adjustedInvokeCode() == Bytecodes._invokespecial; }
106 public boolean isInvokedynamic() { return adjustedInvokeCode() == Bytecodes._invokedynamic; }
90 107
91 public boolean isValid() { return isInvokeinterface() || 108 public boolean isValid() { return isInvokeinterface() ||
92 isInvokevirtual() || 109 isInvokevirtual() ||
93 isInvokestatic() || 110 isInvokestatic() ||
94 isInvokespecial(); } 111 isInvokespecial(); }
102 StringBuffer buf = new StringBuffer(); 119 StringBuffer buf = new StringBuffer();
103 buf.append(getJavaBytecodeName()); 120 buf.append(getJavaBytecodeName());
104 buf.append(spaces); 121 buf.append(spaces);
105 buf.append('#'); 122 buf.append('#');
106 buf.append(Integer.toString(indexForFieldOrMethod())); 123 buf.append(Integer.toString(indexForFieldOrMethod()));
124 if (isInvokedynamic()) {
125 buf.append('(');
126 buf.append(Integer.toString(getSecondaryIndex()));
127 buf.append(')');
128 }
107 buf.append(" [Method "); 129 buf.append(" [Method ");
108 StringBuffer sigBuf = new StringBuffer(); 130 StringBuffer sigBuf = new StringBuffer();
109 new SignatureConverter(signature(), sigBuf).iterateReturntype(); 131 new SignatureConverter(signature(), sigBuf).iterateReturntype();
110 buf.append(sigBuf.toString().replace('/', '.')); 132 buf.append(sigBuf.toString().replace('/', '.'));
111 buf.append(spaces); 133 buf.append(spaces);