RFR 8186046 Minimal ConstantDynamic support
paul.sandoz at oracle.com
Tue Nov 7 22:47:16 UTC 2017
> On 7 Nov 2017, at 12:04, Karen Kinnear <karen.kinnear at oracle.com> wrote:
> Thank you for the explanations. Asking for your help in some test case construction at the end here:
>>> 3. java/lang/invoke/package-info.java 128-134
>>> Error handling could be clearer.
>>> My understanding is that if a LinkageError or subclass is thrown, this will be rethrown
>>> for all subsequent attempts. Other errors, e.g. VMError may retry resolution
> I was WRONG here - this does match the JVMS. Apologies for the confusion.
>>> 9. test/jdk/java/lang/invoke/common/test/java/lang/invoke/lib/InstructionHelper.java
>>> How would I write an ldc CONSTANT_Dynamic which referred to a bootstrap method that
>>> was not ACC_STATIC?
>> See the note under bootstrap_method_ref. The kind of method handle is constrained because of the arguments that are pushed on the stack before invocation. I believe it’s possible to have a constructor, but the declaring class would need to be a subtype of CallSite in the case of indy, and a subtype of the constant value type in the case of condy.
>>> Or was not ACC_PUBLIC?
>> That’s dependent on the accessibility between the lookup class the the BSM declaring class.
>>> Or was
>>> Or did I read the invoke dynamic method incorrectly?
>> By default, and for convenience, the InstructionHelper assumes the BSM is declared by the lookup class. I recently modified that to support the BSM being declared on another class, to test the minimal set of BSMs for condy (separate issue ). Note it’s always possible to use the bytecode API more directly.
>> So we can easily add more -ve tests for non-accessible or non-static BSMs.
I am wrong, i forgot i updated the API to remove the declaration of the BSM kind, and it only supports static BSMs.
> Thank you - that is what we were trying to do - test BSM declared in another class, test in-accessible
> BSM and test non static method.
The latter (access to a BSM in another class) is easy now using the high-level construct of InstructionHelper.ldcDynamicConstant (see patch for the condy BSMs, which is also in the amber repo in the condy branch).
> Could you help us figure out how to
> 1) invoke a constructor?
> 2) invoke a virtual method? How do you pass the receiver?
I think for these you will need to use ASM tools to massage the MH for the BSM e.g. develop for a class with a static BSM then adjust the constant pool entry for the associated MH.
More information about the core-libs-dev