[External] : Re: POC: JDK ClassModel -> ASM ClassReader

Adam Sotona adam.sotona at oracle.com
Thu Jul 14 09:15:04 UTC 2022



On 13.07.2022 22:10, "Rafael Winterhalter" <rafael.wth at gmail.com> wrote:

If you are exciting the tests of this repo (you'd need to use my "monad" branch to do so, but the error is not related to it), then OpenJDK would, for FrameWithMissingType - where the "Missing" class is not present - compute the following bytecode if it the instructions of "m" are copied to a new class:

  public m(Z)V
    ILOAD 1
    IFEQ 1
    NEW codes/rafael/asmjdkbridge/sample/FrameWithMissingType$Present
    DUP
    INVOKESPECIAL codes/rafael/asmjdkbridge/sample/FrameWithMissingType$Present.<init> ()V
    ASTORE 2
    GOTO 2
   LABEL 1
   FRAME SAME
    NEW codes/rafael/asmjdkbridge/sample/FrameWithMissingType$Missing
    DUP
    INVOKESPECIAL codes/rafael/asmjdkbridge/sample/FrameWithMissingType$Missing.<init> ()V
    ASTORE 2
   LABEL 2
   FRAME APPEND [java/lang/Object] // this will render slot 2 of type object, the next two lines yield the verification error
    ALOAD 2
    INVOKEINTERFACE codes/rafael/asmjdkbridge/sample/FrameWithMissingType$Iface.m ()V (itf)
    RETURN

When specifying the frames explicitly in ASM, this does not happen where the append frame with comment above is correctly:

   FRAME APPEND [codes/rafael/asmjdkbridge/sample/FrameWithMissingType$Iface]

Both FRAME APPEND [java/lang/Object] or FRAME APPEND [codes/rafael/asmjdkbridge/sample/FrameWithMissingType$Iface] are valid and both pass verification during class loading.
Common ancestor of FrameWithMissingType$Present and FrameWithMissingType$Missing is java/lang/Object and it is a valid entry in the stack map frame.
Declaration of common interface FrameWithMissingType$Iface  in stack map frame is irrelevant, as interfaces are not subject of hierarchical assignability verification.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/classfile-api-dev/attachments/20220714/a8f74dcb/attachment.htm>


More information about the classfile-api-dev mailing list