Background
I'm currently writing a JVM in C# for purely academic purposes (and maybe to build a mixed .NET and Java/Scala application in the future).
Context
I write the simple JAVA class:
public class test
{
public static String hello_world(int i)
{
return "Hello " + i + " World!";
}
}
And compile it into test.class
.
When I decompile it with my decompiler (which I have written as part of the JVM), I see the following instructions for this method:
iload_0
invokedynamic 2
areturn
When looking inside the constant pool for the constant at index 2
, I see an InvokeDynamic-Constant entry with the following data:
makeConcatWithConstants : (I)Ljava/lang/String;
Which makes sense, I guess (I am more a .NET-user than a JAVA-user).
When executing my method hello_world
with the parameter 1
, I have the following Stack before executing invokedynamic 2
:
----TOP---
0x00000001
--BOTTOM--
Question
My question is: How do I use invokedynamic
?
I cannot resolve the method makeConcatWithConstants
, as the InvokeDynamic-Constant does not give me any hint, where makeConcatWithConstants
might be located (see documentation).
Neither does the stack contain a reference to the heap, indicating which instance type the method makeConcatWithConstants
could be associated with.
I read through the invokedynamic
docs but I do not understand it (Maybe I'm to much "damaged" by the .NET-Framework).
Can somebody point me to some example about what is going on under the JVM's hood when executing these three instructions? (What the callee of invokedynamic
expects etc.)?
I already implemented invokestatic
in my JVM ... but I am currently unable to understand invokedynamic
.