JDK-8280469 : C2: CHA support for interface calls when inlining through method handle linker
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 19
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-01-21
  • Updated: 2025-11-24
  • Resolved: 2025-11-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 26
26 b25Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
CHA can devirtualize interface calls by strength reducing them to virtual calls when there's only a single direct implementor class present at runtime. 

It relies on symbolic information present in bytecode and doesn't work when invocation goes through method handle linker (MethodHandle.linkToInterface()):

src/hotspot/share/opto/doCall.cpp:

    if (call_does_dispatch && bytecode == Bytecodes::_invokeinterface) {
      ciInstanceKlass* declared_interface =
          caller->get_declared_method_holder_at_bci(bci)->as_instance_klass();
      ciInstanceKlass* singleton = declared_interface->unique_implementor();

(Both C1 and C2 are affected.)
Comments
Changeset: 256a9bef Branch: master Author: Vladimir Ivanov <vlivanov@openjdk.org> Date: 2025-11-18 22:29:37 +0000 URL: https://git.openjdk.org/jdk/commit/256a9beffc106d6657a912a33f97e7f97acbb1e1
18-11-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/28094 Date: 2025-10-31 21:34:27 +0000
31-10-2025

cha_intf_mh_test.patch enhances test/hotspot/jtreg/compiler/cha/StrengthReduceInterfaceCall.java with method handle invocation mode.
21-01-2022

Method handle linkers rely on MemberName (passed as an appendix argument) to perform method selection. Resolved MemberName contains all necessary information needed, but CHA needs symbolic class information (REFC). Symbolic information is lost during MemberName resolution and receiver subtype check is performed in java.lang.invoke code instead before calling into MH linker. Until C2 trusts interface types, there's no way to reliably recover that type information and the only possible solution is to reify REFC in the MemberName instance during resolution to make it accessible to JIT-compilers during compilation.
21-01-2022