On Tue, 1 Apr 2025 13:27:34 GMT, Per Minborg <pminb...@openjdk.org> wrote:
>> Implement JEP 502. >> >> The PR passes tier1-tier3 tests. > > Per Minborg has updated the pull request incrementally with two additional > commits since the last revision: > > - Add lazy toSting for StableMap::values > - Make toString for reversed and sublist lazy src/java.base/share/classes/java/lang/StableValue.java line 169: > 167: * > 168: * {@snippet lang = java: > 169: * public final class SqrtUtil { Maybe this example can be improved? E.g. how about a general utility class which speeds up computation of common square roots, up to a certain number. Then you can have a method that takes a number and returns its square root (it will check if the number is less than the threshold and use the stable function cache in that case). E.g. this would be very nice with primitive type patterns: if (input instanceof int i && i < threshold) { return SQRT.apply(i); } else { return Math.sqrt(input); } (it's probably not great to refer to another preview here -- maybe we can keep this example for another time). But, if you use something like `pow`, that might be easier (as then you can only worry about int/long inputs) ? src/java.base/share/classes/java/lang/StableValue.java line 187: > 185: * uses it to compute a result (of type {@code R}) that is then cached > by the backing > 186: * stable value storage for that parameter value. A stable function is > created via the > 187: * {@linkplain StableValue#function(Set, Function) > StableValue.function()} factory. In general I'm not a big fan of using a `linkplain` in this way -- e.g. `@link` will already put the signature of the function -- here you are providing an alternate label with a simpler signature -- but that is less precise, and if there's overload it doesn't work great. I suggest to just use `@link` in these cases (here and elsewhere) -- unless you have a better english text to describe what's in the link -- e.g. this is ok: A stable function is created via a {@linkplain StableValue#function(Set, Function) factory}. (but not sure it's worth the trouble). ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/23972#discussion_r2024385407 PR Review Comment: https://git.openjdk.org/jdk/pull/23972#discussion_r2024390856