On Thu, 17 Apr 2025 09:24:13 GMT, Viktor Klang <vkl...@openjdk.org> wrote:
>> Per Minborg has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Address comments on original vs underlying > > src/java.base/share/classes/java/lang/StableValue.java line 204: > >> 202: * Set.of(1, 2, 4, 8, 16, 32); >> 203: * private static final UnaryOperator<Integer> UNDERLYING_LOG2 = >> 204: * i -> 31 - Integer.numberOfLeadingZeros(i); > > Would boxing be necessary—i.e. what would be needed to use > java.util.function.IntUnaryOperator? Boxing would be required in this example. It would have been possible to provide a lambda that invoked an underlying `IntUnaryOperator`. private static final IntUnaryOperator LOG2_ORIGINAL = i -> 31 - Integer.numberOfLeadingZeros(i); private static final Function<Integer, Integer> LOG2_CACHED = // @link substring="function" target="#function(Set,Function)" : StableValue.function(CACHED_KEYS, LOG2_ORIGINAL::applyAsInt); Writing a custom stable `IntUnaryOperator` is out of scope. At least in the first preview. I am planning on writing an article about that. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/23972#discussion_r2053750795