JDK-8241548 : Convert StringConcatFactory to use hidden classes
  • Type: Sub-task
  • Component: core-libs
  • Sub-Component: java.lang.invoke
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2020-03-24
  • Updated: 2020-03-26
  • Resolved: 2020-03-24
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.
Other
repo-valhallaFixed
Description
StringConcatFactory spins bytecode dynamically to implement string concat that should migrate away from VM anonymous class and instead defines them as hidden classes. It should have the strong relationship with its defining class loader as it is the internal implementation as the class doing string concat.
Comments
The conversation we had on this must've been back in September, so I don't remember what I said exactly. :-) But yes, performance of BytecodeStringBuilderStrategy is not critical - it's a fallback strategy to use if all else fails. So dropping @ForceInline should be fine if that helps moving ahead with defineHiddenClass.
26-03-2020

The default translation strategy is to use MethodHandle inline sized exactly strategy (MH_INLINE_SIZED_EXACT). The strategy can be changed to specify -Djava.lang.invoke.stringConcat to other strategies. Claes has recommended to remove these non-default strategies as developers have no need to use them. BytecodeStringBuilderStrategy generates code to have the same StringBuilder chain javac would emit. It uses `@ForceInline` annotation which may probably be for performance. This could enable the use of VM annotations in this generated hidden class to access `@ForceInline`. Per the discussion with Claes, this strategy is not default and he advises to leave it as is with his wish to remove it some day. Hence StringConcatFactory uses the standard defineHiddenClass method rather than the internal flag to access VM annotations.
24-03-2020