ldc_w :
push single-word constant onto stack (wide index) : index : visitLdcInsn()
- Description
- ldc_w pushes a one-word constant onto the operand stack.
ldc_w takes a single parameter, <value>, which is
the value to push. The following Java types can be pushed using
ldc_w:
int
float
String
Pushing a String causes a reference to a java.lang.String object to be
constructed and pushed onto the stack. Pusing an int or a float causes a
primitive value to be pushed onto the stack.
ldc_w is identical to ldc except that, in bytecode,
ldc_w uses a 16-bit index rather than an 8-bit index. - Exceptions
- OutOfMemoryError - not enough memory to allocate a reference to a
String
- Notes
- 1. Where possible, its more efficient to use one of bipush,
sipush, or one of the const instructions instead of ldc_w.
2. If the same string constant (i.e. a string with the same sequence of
characters) appears in several different class files, only one String instance
is built for that constant. The String.intern() method can be used to retrieve
the instance used for a given sequence of characters.
3. The Jasmin assembler automatically determines whether to use ldc or
ldc_w, so in Jasmin assembly files these two instructions are
synonymous. - See also
- bipush sipush ldc ldc2_w aconst_null iconst_m1 iconst_n lconst_l fconst_f dconst_d
- Stack
Before
|
After |
... |
<value> |
|
... |
- Bytecode
Type
|
Description |
u1
|
ldc_w
opcode = 0x13 (19)
|
u2
|
index |