[constables] RFR of constants API

John Rose john.r.rose at oracle.com
Mon Jun 4 23:00:11 UTC 2018


On Jun 4, 2018, at 2:54 PM, Brian Goetz <brian.goetz at oracle.com> wrote:
> 
> One of the inputs to a MHDesc is a Kind enum constant.  Currently, they map 1:1 with refKind, but it seems to me we need to differentiate between INTERFACE_VIRTUAL and INTERFACE_SPECIAL, where in the latter case, refKind=special but we use an InterfaceMethodRef?

Yes, I advise that.  Something like:

+    public enum Kind {
+        /** A method handle for a method invoked as with {@code invokestatic} */
+        STATIC(REF_invokeStatic),
+        /** A method handle for a method invoked as with {@code invokevirtual} */
+        VIRTUAL(REF_invokeVirtual),
+        /** A method handle for a method invoked as with {@code invokeinterface} */
+        INTERFACE_VIRTUAL(REF_invokeInterface, true),
+        /** A method handle for a class method invoked as with {@code invokespecial} */
+        SPECIAL(REF_invokeSpecial),
+        /** A method handle for an interface method invoked as with {@code invokespecial} */
+        INTERFACE_SPECIAL(REF_invokeSpecial, true),
+        /** A method handle for a constructor */
+        CONSTRUCTOR(REF_newInvokeSpecial),

…where the second constructor argument sets the "it's an interface"
bit, checked downstream when choosing CONSTANT_Methodref or
CONSTANT_InterfaceMethodref.

— John

P.S.  At one point I thought it might be useful if the ClassDesc carried
a tentative "opinion" about whether it will resolve to an interface or not.
The meaning of the bit could be "if true I know this will resolve to an
interface, else you can assume it's a class".  It could provide a default
setting for that boolean when the time comes to choose between a
CONSTANT_Methodref or a CONSTANT_InterfaceMethodref.
The interface bit would be set for ConstantDescs.CR_List and the like.

Also if there were a ClassDesc.classToRef function it could fill in this bit.
But there isn't, except in test code, for various reasons related to use case
analysis of intrinsics and side effects.

So it's hard to justify, since other places where ClassDescs are created
are from strings, where there is no meaningful way to check for an interface.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20180604/f267ff20/attachment.html>


More information about the amber-spec-experts mailing list