I have this class, and I compile it.
package org.test;
import java.util.function.Supplier;
public class Test {
static String get() { return "!!"; }
public static void main(String[] args) {
Supplier<String> sup = Test::get;
System.out.println(sup.get());
}
}
Then, trying to look into it's bytecode, I get following beginning of public static void main
function:
public static void main(java.lang.String[]);
descriptor: ([Ljava/lang/String;)V
flags: ACC_PUBLIC, ACC_STATIC
Code:
stack=2, locals=2, args_size=1
0: invokedynamic #3, 0 // InvokeDynamic #0:get:()Ljava/util/function/Supplier;
5: astore_1
6: getstatic #4 // Field java/lang/System.out:Ljava/io/PrintStream;
Here we can see the invokedynamic call, which, if I understand correctly, creates anonymous instance of Supplier interface. Passed to invokedynamic are two arguments, one is #3. The second argument is 0. So, my first question is: what does 0 stand here for?
In constant pool #3 stands for #3 = InvokeDynamic #0:#27 // #0:get:()Ljava/util/function/Supplier;
. There is reference to #27 in constant pool, but no reference to #0.
My second question is: what does #0 stand for here?