JDK-8191442 : Regression in LambdaFormBuffer.replaceFunctions
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang.invoke
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2017-11-16
  • Updated: 2017-11-22
  • Resolved: 2017-11-17
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 10
10 b33Fixed
Related Reports
Relates :  
Description
JDK-8184777 accidentally changed semantics of replaceFunctions from checking identity to equality, and in addition the use of List.indexOf methods caused a small startup regression on some sensitive benchmarks. 

diff -r 2ac93efc62ed src/java.base/share/classes/java/lang/invoke/LambdaFormBuffer.java
--- a/src/java.base/share/classes/java/lang/invoke/LambdaFormBuffer.java	Thu Nov 16 20:25:45 2017 +0000
+++ b/src/java.base/share/classes/java/lang/invoke/LambdaFormBuffer.java	Fri Nov 17 00:30:29 2017 +0100
@@ -115,9 +115,9 @@
         return true;
     }
 
-    private static int indexOf(NamedFunction fn, NamedFunction[] fns) {
-        for (int i = 0; i < fns.length; i++) {
-            if (fns[i] == fn)  return i;
+    private static int indexOf(NamedFunction fn, List<NamedFunction> fns) {
+        for (int i = 0; i < fns.size(); i++) {
+            if (fns.get(i) == fn)  return i;
         }
         return -1;
     }
@@ -333,7 +333,7 @@
         if (oldFns.isEmpty())  return this;
         for (int i = arity; i < length; i++) {
             Name n = names[i];
-            int nfi = oldFns.indexOf(n.function);
+            int nfi = indexOf(n.function, oldFns);
             if (nfi >= 0 && Arrays.equals(n.arguments, forArguments)) {
                 changeName(i, new Name(newFns.get(nfi), n.arguments));
             }