asmtools `ldc Dynamic` syntax
Leonid Kuskov
leonid.kuskov at oracle.com
Thu Apr 22 05:07:05 UTC 2021
Correction: The issue for tracking purposes is https://bugs.openjdk.java.net/browse/CODETOOLS-7902888
On 4/21/21, 10:01 PM, "code-tools-dev on behalf of Leonid Kuskov" <code-tools-dev-retn at openjdk.java.net on behalf of leonid.kuskov at oracle.com> wrote:
Hello,
Your first question is about the JVMS 4.4.8. The CONSTANT_MethodHandle_info Structure
CONSTANT_MethodHandle_info {
u1 tag;
u1 reference_kind;
u2 reference_index;
}
The format of the ldc instruction is: ldc Dynamic reference_kind:reference_index {ClassName|InterfaceName}.MethodName ....
According to the assertion:
If the value of the reference_kind item is 6 (REF_invokeStatic) or 7 (REF_invokeSpecial), then if the class file version number is less than 52.0, the constant_pool entry at that index must be a CONSTANT_Methodref_info structure representing a class's method for which a method handle is to be created; if the class file version number is 52.0 or above, the constant_pool entry at that index must be either a CONSTANT_Methodref_info structure or a CONSTANT_InterfaceMethodref_info structure (§4.4.2) representing a class's or interface's method for which a method handle is to be created.
i.e. we might have the following pairs:
ldc Dynamic REF_invokeSpecial:Method ...... if reference_index is an index of a CONSTANT_Methodref_info structure in CP or
ldc Dynamic REF_invokeSpecial: InterfaceMethod... if reference_index points to CONSTANT_InterfaceMethodref_info
2nd issue is the defect, although it doesn't affect a code the bytecode footprint grows.
I will take care of the problem: https://bugs.openjdk.java.net/browse/JDK-8129547
> (it's even didn't assemble back).
I could not reproduce this. Please send your example.
On 4/21/21, 3:54 PM, "code-tools-dev on behalf of Maxim Degtyarev" <code-tools-dev-retn at openjdk.java.net on behalf of mdegtyarev at gmail.com> wrote:
Hello,
I have 2 questions regarding `ldc Dynamic` syntax:
1) Consider the following example:
ldc Dynamic
REF_newInvokeSpecial
:LdcConDyTwice."<init>"
:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;)V"
:LdcConDyTwice
:"LLdcConDyTwice;";
Being assembled with `asmtools jasm` and then disassembled with
`asmtools jdis` above instruction turns to:
ldc Dynamic
REF_newInvokeSpecial
:Method LdcConDyTwice."<init>"
:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;)V"
:LdcConDyTwice
:"LLdcConDyTwice;";
I assume "Method" in front of the constructor reference is a
disassembler bug (it's even didn't assemble back).
Could anyone confirm my assumption?
2) Is there a way to reference the same Dynamic constant more than
once with the current jasm syntax?
Right now two syntactically equal ldc Dynamic instructions create two
different entries in BootstrapMethods attribute.
More information about the code-tools-dev
mailing list