Question: What does line 14 means?
Use javap -v -c to disassembly the following code:
public class test {
static int i = 2;
public static void main(String[] args) {
test x = new test();
System.out.println("text + String: " + i);
}
}
in the main function we get the following:
14: invokedynamic #20, 0 // InvokeDynamic #0:makeConcatWithConstants:(I)Ljava/lang/String;
19: invokevirtual #24 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
...
BootstrapMethods:
0: #38 REF_invokeStatic java/lang/invoke/StringConcatFactory.makeConcatWithConstants:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/invoke/CallSite;
Method arguments:
#44 text + String: \u0001
So, for example, line 19 means that invokevirtual function from the #24 item in the runtime constant pool. The method invoked is println()
from the class java/io/PrintStream
, its input is from the class Ljava/lang/String
, its return value is Void.
As for line 14, #0 holds the reference to the BootstrapMethod and returns an Object whose class is CallSite
right?
Then:
- what is #20 pointing to?
- What does the comment
#0:makeConcatWithConstants:(I)Ljava/lang/String;
means?
Also, where could I find more about the Javap disassembly code's grammar? or what is the right keyword? Oracle's document about the JVM instruction set
does not seems to describe clearly about the meaning of the comment.