(This is an omnibus RFE to capture possible improvements to ClassValue.)
There should be a factory method for ClassValue<T> that takes a Function<Class<?>,T>. (Named "ofRemovable", see below.)
There should be an option for a non-resettable ClassValue, i.e., one which rejects CV::remove calls. Suggested factory name is "of", not "ofNonResettable". This is a better default, given the binary option choice.
There should NOT be an "enum Option" mechanism. Calling the right factory is the way to select the right option.
The long-standing RFE JDK-8238260 may be easier to address if restricted only to non-resettable CVs.
There might also be an option for a CV which requests precomputation of (some) bindings at "Premain" time. (This is a case of Leyden shifted computation.) The API for this is unclear at present, however. It might be as simple as an imperative void static method "precomputeWhenPossible(CV)". More research is needed.
As the stable/constant value API develops, there may be opportunities to align ClassValue with that other API. For example, add an imperative ClassValue::set operation, that aligns in its behavior with a (hypothetical) stable/constant value associated with each <CV,Class> pair.
If a CV is non-removable, it clearly must also be non-settable. Again, CV should follow any lead provided by stable/constant value. FTR a recent draft of that API is:
https://cr.openjdk.org/~pminborg/computed-constant/api/java.base/java/lang/ComputedConstant.html
There should be a factory method for ClassValue<T> that takes a Function<Class<?>,T>. (Named "ofRemovable", see below.)
There should be an option for a non-resettable ClassValue, i.e., one which rejects CV::remove calls. Suggested factory name is "of", not "ofNonResettable". This is a better default, given the binary option choice.
There should NOT be an "enum Option" mechanism. Calling the right factory is the way to select the right option.
The long-standing RFE JDK-8238260 may be easier to address if restricted only to non-resettable CVs.
There might also be an option for a CV which requests precomputation of (some) bindings at "Premain" time. (This is a case of Leyden shifted computation.) The API for this is unclear at present, however. It might be as simple as an imperative void static method "precomputeWhenPossible(CV)". More research is needed.
As the stable/constant value API develops, there may be opportunities to align ClassValue with that other API. For example, add an imperative ClassValue::set operation, that aligns in its behavior with a (hypothetical) stable/constant value associated with each <CV,Class> pair.
If a CV is non-removable, it clearly must also be non-settable. Again, CV should follow any lead provided by stable/constant value. FTR a recent draft of that API is:
https://cr.openjdk.org/~pminborg/computed-constant/api/java.base/java/lang/ComputedConstant.html
- relates to
-
JDK-8238260 ClassValue.get should be optimized like MutableCallSite.getTarget
-
- Open
-