Mercurial > hg > truffle
comparison agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ClassWriter.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 | 083fde3b838e |
comparison
equal
deleted
inserted
replaced
1585:49fac4acd688 | 1602:136b78722a08 |
---|---|
59 protected short _lineNumberTableIndex; | 59 protected short _lineNumberTableIndex; |
60 protected short _localVariableTableIndex; | 60 protected short _localVariableTableIndex; |
61 protected short _signatureIndex; | 61 protected short _signatureIndex; |
62 | 62 |
63 protected static int extractHighShortFromInt(int val) { | 63 protected static int extractHighShortFromInt(int val) { |
64 // must stay in sync with constantPoolOopDesc::name_and_type_at_put, method_at_put, etc. | |
64 return (val >> 16) & 0xFFFF; | 65 return (val >> 16) & 0xFFFF; |
65 } | 66 } |
66 | 67 |
67 protected static int extractLowShortFromInt(int val) { | 68 protected static int extractLowShortFromInt(int val) { |
69 // must stay in sync with constantPoolOopDesc::name_and_type_at_put, method_at_put, etc. | |
68 return val & 0xFFFF; | 70 return val & 0xFFFF; |
69 } | 71 } |
70 | 72 |
71 public ClassWriter(InstanceKlass kls, OutputStream os) { | 73 public ClassWriter(InstanceKlass kls, OutputStream os) { |
72 klass = kls; | 74 klass = kls; |
295 dos.writeShort(signatureIndex); | 297 dos.writeShort(signatureIndex); |
296 if (DEBUG) debugMessage("CP[" + ci + "] = N&T name = " + nameIndex | 298 if (DEBUG) debugMessage("CP[" + ci + "] = N&T name = " + nameIndex |
297 + ", type = " + signatureIndex); | 299 + ", type = " + signatureIndex); |
298 break; | 300 break; |
299 } | 301 } |
302 | |
303 case JVM_CONSTANT_MethodHandle: { | |
304 dos.writeByte(cpConstType); | |
305 int value = cpool.getIntAt(ci); | |
306 short refIndex = (short) extractHighShortFromInt(value); | |
307 byte refKind = (byte) extractLowShortFromInt(value); | |
308 dos.writeByte(refKind); | |
309 dos.writeShort(refIndex); | |
310 if (DEBUG) debugMessage("CP[" + ci + "] = MH index = " + refIndex | |
311 + ", kind = " + refKind); | |
312 break; | |
313 } | |
314 | |
315 case JVM_CONSTANT_MethodType: { | |
316 dos.writeByte(cpConstType); | |
317 int value = cpool.getIntAt(ci); | |
318 short refIndex = (short) value; | |
319 dos.writeShort(refIndex); | |
320 if (DEBUG) debugMessage("CP[" + ci + "] = MT index = " + refIndex); | |
321 break; | |
322 } | |
323 | |
300 default: | 324 default: |
301 throw new InternalError("Unknown tag: " + cpConstType); | 325 throw new InternalError("Unknown tag: " + cpConstType); |
302 } // switch | 326 } // switch |
303 } | 327 } |
304 } | 328 } |