Different behaviors of Ref_InvokeSpecial

Zeker Zhayard zekerzhayard at gmail.com
Mon Oct 4 13:42:39 UTC 2021

This is indeed an edge usage. This is an issue I accidentally discovered in
Minecraft modding. Sometimes we need to raise the access level to access
internal codes of Minecraft. There are some tools for modifying the access
level [1]. However, they only modified invokespecial to invokevirtual, but
did not modify ref_invokespecial to ref_invokevirtual, and then I found
such a different behavior.

Because in the previous jdk versions, calling base class methods all use
invokespecial, so it seems to be incorrect of the behavior of invokevirtual
after JDK 15 when class version is 52.0

Yours sincerely

[1] https://github.com/FabricMC/access-widener

- <liangchenblue at gmail.com> 于2021年10月4日周一 下午8:38写道:

> Hello,
> Bystander here. This comment in code [1] may be related information.
> The question here is more like how the access to methods should be
> changed. In prior versions, if you want to expose a private method to
> be overridable, you have to change all calls to it from invokespecial
> to invokevirtual, and it's no surprise if you need extra housekeeping
> around simple access changes. But let's take a step back, why are we
> changing the access of these methods at all, and how are they
> necessary?
> Sending this to jdk-dev as this is related to jdk itself than valhalla.
> Best regards
> [1]
> https://github.com/openjdk/jdk/blob/0828273b898cca5368344e75f1c3f4c3a29dde80/src/java.base/share/classes/java/lang/invoke/AbstractValidatingLambdaMetafactory.java#L157

More information about the jdk-dev mailing list