On Thu, 16 May 2024 07:19:54 GMT, Per Minborg <pminb...@openjdk.org> wrote:

>> src/java.base/share/classes/jdk/internal/lang/StableValue.java line 384:
>> 
>>> 382:      * @param <T>      the memoized type
>>> 383:      */
>>> 384:     static <T> Supplier<T> ofSupplier(Supplier<? extends T> original) {
>> 
>> `ofSupplier` sounds like this method returns a `StableValue` from a 
>> `Supplier`. I recommend another name, such as `stableSupplier`, 
>> `wrapSupplier`, or `memoize`, to better associate with the method's types.
>
> One alternative would be to expose the types `StableList` and `StableMap`. 
> This would allow detection of these types if declared. This would also allow 
> us to expose the methods `computeIfUnset` as instance methods and remove the 
> somewhat strange static counterparts. I agree strict finals are better in the 
> long run.

We had other names for the memoized factories before but some people did not 
like names like `asMemoized`. 

Maybe `ofSupplier` -> `memoizedSupplier` etc. ?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/18794#discussion_r1602754675

Reply via email to