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

Rafael Winterhalter rafael.wth at gmail.com
Thu Jul 14 09:38:45 UTC 2022


The frame is indeed valid. The verification fails after ALOAD 2 (now a
Object type is on the stack) and the subsequent method invocation
INVOKEINTERFACE
codes/rafael/asmjdkbridge/sample/FrameWithMissingType$Iface.m ()V. This
method is of course not declared on Object.

Adam Sotona <adam.sotona at oracle.com> schrieb am Do., 14. Juli 2022, 11:15:

>
>
>
>
> 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/b54c2ee8/attachment-0001.htm>


More information about the classfile-api-dev mailing list