Re: Small question on ldc and ldc_w
Rémi Forax <[email protected]>
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <[email protected]> |
Le 14/08/2010 07:08, Sai Zhang a écrit :
> Hi all:
>
> A small question on ldc and ldc_w instruction: it seems that asm does
> not distinguish these two instructions, right? I mean if i want to insert
> new LdcInsnNode(xxx).
>
> For example, I found the code like:
>
> new LdcInsnNode("String content");
>
> will sometimes produces ldc "string content", while some times
> produces Ldc_w "string content".
> and seems does related to the length of string?
>
> Does any one have idea on this point? Will this "unpredictability"
> produce some unexpected
> side-effect? or how asm decide to Ldc or Ldc_w?
>
> thanks
>
> -Sai
Hi,
It's not related to the size of the string.
All constants are stored in the constant pool and ldc use a constant
pool offset,
The different between ldc and ldc_w is the size of the offset,
for ldc the offset is encoded with 1 byte.
for ldc_w the offset is encoded with 2 bytes.
see
http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc8.html
Rémi
message-footer.txt
(text/plain, 238 B)
-- You receive this message as a subscriber of the [email protected] mailing list. To unsubscribe: mailto:[email protected] For general help: mailto:[email protected]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws