RFR: JDK-8235621: Replace use of Function<?,Integer> with ToIntFunction

Jonathan Gibbons jonathan.gibbons at oracle.com
Tue Dec 10 00:38:44 UTC 2019


Following Rémi's suggestion[1], please review a trivial change to javac 
to have it use ToIntFunction
instead of Function<..., Integer> in the recent patch for JDK-8234689 [2].

Patch inline below. No change to the original test is necessary.

JBS: https://bugs.openjdk.java.net/browse/JDK-8235621
[1] 
https://mail.openjdk.java.net/pipermail/compiler-dev/2019-December/014043.html
[2] https://hg.openjdk.java.net/jdk/jdk/rev/17b0f051280f

-- Jon

diff -r 2aaa8bcb90a9 -r 1e000f399f3a 
src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java

--- 
a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java 
Mon Dec 09 15:28:46 2019 +0100
+++ 
b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java 
Mon Dec 09 16:12:42 2019 -0800
@@ -30,7 +30,7 @@
  import java.util.Map;
  import java.util.Set;
  import java.util.LinkedHashSet;
-import java.util.function.Function;
+import java.util.function.ToIntFunction;

  import javax.tools.JavaFileManager;
  import javax.tools.FileObject;
@@ -114,7 +114,7 @@
       */
      public boolean multiModuleMode;

-    private List<Function<Symbol, Integer>> extraAttributeHooks = 
List.nil();
+    private List<ToIntFunction<Symbol>> extraAttributeHooks = List.nil();

      /** The initial sizes of the data and constant pool buffers.
       *  Sizes are increased when buffers get full.
@@ -191,7 +191,7 @@
          }
      }

-    public void addExtraAttributes(Function<Symbol, Integer> 
addExtraAttributes) {
+    public void addExtraAttributes(ToIntFunction<Symbol> 
addExtraAttributes) {
          extraAttributeHooks = 
extraAttributeHooks.prepend(addExtraAttributes);
      }

@@ -1669,7 +1669,7 @@
       */
      protected int writeExtraAttributes(Symbol sym) {
          int i = 0;
-        for (Function<Symbol, Integer> hook : extraAttributeHooks) {
+        for (ToIntFunction<Symbol> hook : extraAttributeHooks) {
              i += hook.apply(sym);
          }
          return i;



More information about the compiler-dev mailing list