* Lazily associate a computed value with (potentially) every class.
* Lazily associate a computed value with (potentially) every type.
* For example, if a dynamic language needs to construct a message dispatch
* table for each class encountered at a message send call site,
* it can use a {@code ClassValue} to cache information needed to
* perform the message send quickly, for each class encountered.
* @author John Rose, JSR 292 EG
* @author John Rose, JSR 292 EG
*/
*/
publicclassClassValue<T>{
publicabstractclassClassValue<T>{
/**
/**
* Compute the given class's derived value for this {@code ClassValue}.
* Compute the given class's derived value for this {@code ClassValue}.
* <p>
* <p>
...
@@ -45,61 +49,41 @@ public class ClassValue<T> {
...
@@ -45,61 +49,41 @@ public class ClassValue<T> {
* but it may be invoked again if there has been a call to
* but it may be invoked again if there has been a call to
* {@link #remove remove}.
* {@link #remove remove}.
* <p>
* <p>
* If there is no override from a subclass, this method returns
* If this method throws an exception, the corresponding call to {@code get}
* the result of applying the {@code ClassValue}'s {@code computeValue}
* will terminate abnormally with that exception, and no class value will be recorded.
* method handle, which was supplied at construction time.
*
*
* @param type the type whose class value must be computed
* @return the newly computed value associated with this {@code ClassValue}, for the given class or interface
* @return the newly computed value associated with this {@code ClassValue}, for the given class or interface
* @throws UndeclaredThrowableException if the {@code computeValue} method handle invocation throws something other than a {@code RuntimeException} or {@code Error}
* @see #get
* @throws UnsupportedOperationException if the {@code computeValue} method handle is null (subclasses must override)