APIdia Launch Partner
Top Description Inners Fields Constructors Methods
jdk.dynalink

pack-priv final Class BiClassValue<T>

extends Object
Class Inheritance
Type Parameters
<T>
the value to associate with pairs of types.
Imports
java.lang.invoke.MethodHandles, .VarHandle, java.util.Map, .Objects, java.util.function.BiFunction, .Function

Similar to ClassValue, but lazily associates a computed value with (potentially) every pair of types.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
BiClassValue.BiClassValues<
the type of the values
T
>

A type-specific map that stores the values specific to pairs of types which include its class in one of the positions of the pair.

private static class
private static enum

Field Summary

Modifier and TypeField and Description
private final BiFunction<Class<?>, Class<?>, T>
private final BiClassValue.BiClassValuesRoot<T>

Constructor Summary

AccessConstructor and Description
private
BiClassValue(final BiFunction<Class<?>, Class<?>, T> compute)

Method Summary

Modifier and TypeMethod and Description
pack-priv static <
the type of the values
T
>
BiClassValue<T>

Returns:

a new BiClassValue that computes the values using the passed function.
computing
(final BiFunction<Class<?>, Class<?>, T>
the binary function to compute the values. Ordinarily, it is invoked at most once for any pair of values. However, it is possible for it to be invoked concurrently. It can even be invoked concurrently multiple times for the same arguments under contention. In that case, it is undefined which of the computed values will be retained therefore returning semantically equivalent values is strongly recommended; the function should ideally be pure. Additionally, if the pair of types passed as parameters are from unrelated class loaders, the computed value is not cached at all and the function might be reinvoked with the same parameters in the future. Finally, a null return value is allowed, but not cached.
compute
)

Creates a new BiClassValue that uses the specified binary function to lazily compute the values.

pack-priv final T
get(final Class<?> c1, final Class<?> c2)

private static BiClassValue.RetentionDirection
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

computeback to summary
private final BiFunction<Class<?>, Class<?>, T> compute
rootback to summary
private final BiClassValue.BiClassValuesRoot<T> root

Constructor Detail

BiClassValueback to summary
private BiClassValue(final BiFunction<Class<?>, Class<?>, T> compute)

Method Detail

computingback to summary
pack-priv static <T> BiClassValue<T> computing(final BiFunction<Class<?>, Class<?>, T> compute)

Creates a new BiClassValue that uses the specified binary function to lazily compute the values.

Parameters
<T>
the type of the values
compute:BiFunction<Class<?>, Class<?>, T>

the binary function to compute the values. Ordinarily, it is invoked at most once for any pair of values. However, it is possible for it to be invoked concurrently. It can even be invoked concurrently multiple times for the same arguments under contention. In that case, it is undefined which of the computed values will be retained therefore returning semantically equivalent values is strongly recommended; the function should ideally be pure. Additionally, if the pair of types passed as parameters are from unrelated class loaders, the computed value is not cached at all and the function might be reinvoked with the same parameters in the future. Finally, a null return value is allowed, but not cached.

Returns:BiClassValue<T>

a new BiClassValue that computes the values using the passed function.

getback to summary
pack-priv final T get(final Class<?> c1, final Class<?> c2)
getRetentionDirectionback to summary
private static BiClassValue.RetentionDirection getRetentionDirection(Class<?> from, Class<?> to)
jdk.dynalink back to summary

private final Class BiClassValue.BiClassValues<T>

extends Object
Class Inheritance
Type Parameters
<T>
the type of the values

A type-specific map that stores the values specific to pairs of types which include its class in one of the positions of the pair. Internally, it uses at most two maps named "forward" and "reverse". A BiClassValues for class C1 can store values for (C1, Cy) in its forward map as well as values for (Cx, C1) in its reverse map. The reason for this scheme is to avoid creating unwanted strong references from a parent class loader to a child class loader. If for a pair of classes (C1, C2) either C1 and C2 are in the same class loader, or C2 is in parent of C1, or C2 is a system class, forward map of C1's BiClassValues is used for storing the computed value. If C1 is in parent of C2, or C1 is a system class, reverse map of C2's BiClassValues is used for storing. If the class loaders are unrelated, the computed value is not cached and will be recomputed on every evaluation. NOTE that while every instance of this class is type-specific, it does not store a reference to the type Class object itself. BiClassValuesRoot creates the association from a type Class object to its BiClassValues'.

Field Summary

Modifier and TypeField and Description
private static final VarHandle
private Map<Class<?>, T>
private static final VarHandle
private Map<Class<?>, T>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private T
compute(final VarHandle mapHandle, final Class<?> c, final Function<Class<?>, T> compute)

pack-priv T
computeForward(final Class<?> c, Function<Class<?>, T> compute)

pack-priv T
computeReverse(final Class<?> c, Function<Class<?>, T> compute)

pack-priv T
getForwardValue(final Class<?> c)

pack-priv T
getReverseValue(final Class<?> c)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

FORWARDback to summary
private static final VarHandle FORWARD
forwardback to summary
private Map<Class<?>, T> forward
REVERSEback to summary
private static final VarHandle REVERSE
reverseback to summary
private Map<Class<?>, T> reverse

Constructor Detail

BiClassValuesback to summary
private BiClassValues()

Method Detail

computeback to summary
private T compute(final VarHandle mapHandle, final Class<?> c, final Function<Class<?>, T> compute)
computeForwardback to summary
pack-priv T computeForward(final Class<?> c, Function<Class<?>, T> compute)
computeReverseback to summary
pack-priv T computeReverse(final Class<?> c, Function<Class<?>, T> compute)
getForwardValueback to summary
pack-priv T getForwardValue(final Class<?> c)
getReverseValueback to summary
pack-priv T getReverseValue(final Class<?> c)
jdk.dynalink back to summary

private final Class BiClassValue.BiClassValuesRoot<T>

extends ClassValue<BiClassValue.BiClassValues<T>>
Class Inheritance

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
protected BiClassValue.BiClassValues<T>
computeValue(Class<?> type)

Implements abstract java.lang.ClassValue.computeValue.

Computes the value to associate to the given Class.

Inherited from java.lang.ClassValue:
getremove

Constructor Detail

BiClassValuesRootback to summary
private BiClassValuesRoot()

Method Detail

computeValueback to summary
protected BiClassValue.BiClassValues<T> computeValue(Class<?> type)

Implements abstract java.lang.ClassValue.computeValue.

Doc from java.lang.ClassValue.computeValue.

Computes the value to associate to the given Class.

This method is invoked when the initial read-only access by get finds no associated value.

If this method throws an exception, the initiating get call will not attempt to associate a value, and may terminate by returning the associated value if it exists, or by propagating that exception otherwise.

Otherwise, the value is computed and returned. An attempt to associate the return value happens, with one of the following outcomes:

  • The associated value is present; it is returned and no association is done.
  • The most recent remove call, if it exists, does not happen-before (JLS 17.4.5) the finish of the computeValue that computed the value to associate. A new invocation to computeValue, which that remove call happens-before, will re-establish this happens-before relationship.
  • Otherwise, this value is successfully associated and returned.
Annotations
@Override
jdk.dynalink back to summary

private final Enum BiClassValue.RetentionDirection

extends Enum<BiClassValue.RetentionDirection>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final BiClassValue.RetentionDirection
public static final BiClassValue.RetentionDirection
public static final BiClassValue.RetentionDirection

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static BiClassValue.RetentionDirection
public static BiClassValue.RetentionDirection[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

FORWARDback to summary
public static final BiClassValue.RetentionDirection FORWARD
NEITHERback to summary
public static final BiClassValue.RetentionDirection NEITHER
REVERSEback to summary
public static final BiClassValue.RetentionDirection REVERSE

Constructor Detail

RetentionDirectionback to summary
private RetentionDirection()

Method Detail

valueOfback to summary
public static BiClassValue.RetentionDirection valueOf(String name)
valuesback to summary
public static BiClassValue.RetentionDirection[] values()