JDK-8166840 : Synthetic bridge constructor in ArrayList$Itr blocks inlining
  • Type: Sub-task
  • Component: core-libs
  • Sub-Component: java.util:collections
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2016-09-28
  • Updated: 2021-03-03
  • Resolved: 2016-09-28
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 8 JDK 9
8u152Fixed 9 b139Fixed
Related Reports
Relates :  
Relates :  
Description
As discussed recently on hotspot-compiler-dev[1], having a private class with no default constructor can lead to C2 failing to inline, due to the synthetic bridge constructor using a dummy argument of an uninitialized class. This is really a problem in C2, as well as something which could ultimately be resolved by nestmates...

However, there is an easy workaround in adding an empty package-private constructor. In the most recently found case - a microbenchmark stressing MethodHandles.iteratedLoop - adding this to ArrayList$Itr lead to a 2.5-3x speedup. It thus makes sense to do this simple change in this particular case as a quick fix and solve the larger C2 issue separately.

[1] http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2016-September/024407.html
Comments
Claes and David: now that we have nestmates, it would be very good to have a tool to identify candidate methods to privatize or (for the case of package-private empty constructors) remove.
11-08-2018

It needs to be verified that nestmates works around the underlying C2 issue, but yes, I think so.
10-08-2018

I guess this workaround can be removed in jdk11+, since nestmates was integrated?
10-08-2018