APIdia Launch Partner
Top Description Inners Fields Constructors Methods
jdk.internal.loader

public abstract Class AbstractClassLoaderValue<CLV extends AbstractClassLoaderValue<CLV, V>, V>

extends Object
Class Inheritance
Known Direct Subclasses
jdk.internal.loader.AbstractClassLoaderValue.Sub, jdk.internal.loader.ClassLoaderValue
Type Parameters
<CLV>
the type of concrete ClassLoaderValue (this type)
<V>
the type of values associated with ClassLoaderValue
Imports
jdk.internal.access.JavaLangAccess, .SharedSecrets, java.lang.reflect.UndeclaredThrowableException, java.util.Iterator, .Objects, java.util.concurrent.ConcurrentHashMap, java.util.function.BiFunction, .Supplier

AbstractClassLoaderValue is a superclass of root-ClassLoaderValue and sub-ClassLoaderValue.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
AbstractClassLoaderValue.Memoizer<CLV extends AbstractClassLoaderValue<CLV, V>, V>

A memoized supplier that invokes given mappingFunction just once and remembers the result or thrown exception for subsequent calls.

public class
AbstractClassLoaderValue.Sub<
the type of key() component contained in the sub-ClassLoaderValue.
K
>

sub-ClassLoaderValue is an inner class of AbstractClassLoaderValue and also a subclass of it.

Field Summary

Modifier and TypeField and Description
private static final JavaLangAccess

Constructor Summary

AccessConstructor and Description
pack-priv
AbstractClassLoaderValue()

Sole constructor.

Method Summary

Modifier and TypeMethod and Description
public V

Returns:

the value associated with this ClassLoaderValue and given ClassLoader.
computeIfAbsent
(ClassLoader
the ClassLoader for the associated value
cl
,
BiFunction<? super ClassLoader, ? super CLV, ? extends V>
the function to compute the value
mappingFunction
)

Returns the value associated with this ClassLoaderValue and given ClassLoader if there is one or computes the value by invoking given mappingFunction, associates it and returns it.

private V
extractValue(Object memoizerOrValue)

Returns: value extracted from the Memoizer if given memoizerOrValue parameter is a Memoizer or just return given parameter.

public V

Returns:

the value associated with this ClassLoaderValue and given ClassLoader or null if there is none.
get
(ClassLoader
the ClassLoader for the associated value
cl
)

Returns the value associated with this ClassLoaderValue and given ClassLoader or null if there is none.

public abstract boolean

Returns:

if this ClassLoaderValue is equal to given clv or its descendant
isEqualOrDescendantOf
(AbstractClassLoaderValue<?, V>
the ClassLoaderValue to test this against
clv
)

Returns true if this ClassLoaderValue is equal to given clv or if this ClassLoaderValue was derived from given clv by a chain of sub(Object) invocations.

public abstract Object

Returns:

the key component of this ClassLoaderValue.
key
()

Returns the key component of this ClassLoaderValue.

private static <CLV extends AbstractClassLoaderValue<CLV, ?>> ConcurrentHashMap<CLV, Object>
map(ClassLoader cl)

Returns: a ConcurrentHashMap for given ClassLoader

public V

Returns:

previously associated value or null if there was none
putIfAbsent
(ClassLoader
the ClassLoader for the associated value
cl
,
V
the value to associate
v
)

Associates given value v with this ClassLoaderValue and given ClassLoader and returns null if there was no previously associated value or does nothing and returns previously associated value if there was one.

public boolean

Returns:

true if the association was removed or false if not
remove
(ClassLoader
the ClassLoader for the associated value
cl
,
Object
the value to compare with currently associated value
v
)

Removes the value associated with this ClassLoaderValue and given ClassLoader if the associated value is equal to given value v and returns true or does nothing and returns false if there is no currently associated value or it is not equal to given value v.

public void
removeAll(ClassLoader
the associated ClassLoader of the values to be removed
cl
)

Removes all values associated with given ClassLoader cl and this or descendants of this ClassLoaderValue.

public <
the type of the key component.
K
>
AbstractClassLoaderValue<CLV, V>.Sub<K>

Returns:

a sub-ClassLoaderValue of this ClassLoaderValue for given key
sub
(K
the key component of the sub-ClassLoaderValue.
key
)

Constructs new sub-ClassLoaderValue of this ClassLoaderValue with given key component.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

JLAback to summary
private static final JavaLangAccess JLA

Constructor Detail

AbstractClassLoaderValueback to summary
pack-priv AbstractClassLoaderValue()

Sole constructor.

Method Detail

computeIfAbsentback to summary
public V computeIfAbsent(ClassLoader cl, BiFunction<? super ClassLoader, ? super CLV, ? extends V> mappingFunction) throws IllegalStateException

Returns the value associated with this ClassLoaderValue and given ClassLoader if there is one or computes the value by invoking given mappingFunction, associates it and returns it.

Computation and association of the computed value is performed atomically by the 1st thread that requests a particular association while holding a lock associated with this ClassLoaderValue and given ClassLoader. Nested calls from the mappingFunction to get, putIfAbsent or computeIfAbsent for the same association are not allowed and throw IllegalStateException. Nested call to remove for the same association is allowed but will always return false regardless of passed-in comparison value. Nested calls for other association(s) are allowed, but care should be taken to avoid deadlocks. When two threads perform nested computations of the overlapping set of associations they should always request them in the same order.

Parameters
cl:ClassLoader

the ClassLoader for the associated value

mappingFunction:BiFunction<? super ClassLoader, ? super CLV, ? extends V>

the function to compute the value

Returns:V

the value associated with this ClassLoaderValue and given ClassLoader.

Exceptions
IllegalStateException:
if a direct or indirect invocation from within given mappingFunction that computes the value of a particular association to get, putIfAbsent or computeIfAbsent for the same association is attempted.
extractValueback to summary
private V extractValue(Object memoizerOrValue)
Returns:V

value extracted from the Memoizer if given memoizerOrValue parameter is a Memoizer or just return given parameter.

Annotations
@SuppressWarnings:unchecked
getback to summary
public V get(ClassLoader cl)

Returns the value associated with this ClassLoaderValue and given ClassLoader or null if there is none.

Parameters
cl:ClassLoader

the ClassLoader for the associated value

Returns:V

the value associated with this ClassLoaderValue and given ClassLoader or null if there is none.

isEqualOrDescendantOfback to summary
public abstract boolean isEqualOrDescendantOf(AbstractClassLoaderValue<?, V> clv)

Returns true if this ClassLoaderValue is equal to given clv or if this ClassLoaderValue was derived from given clv by a chain of sub(Object) invocations.

Parameters
clv:AbstractClassLoaderValue<?, V>

the ClassLoaderValue to test this against

Returns:boolean

if this ClassLoaderValue is equal to given clv or its descendant

keyback to summary
public abstract Object key()

Returns the key component of this ClassLoaderValue. The key component of the root-ClassLoaderValue is the ClassLoaderValue itself, while the key component of a sub-ClassLoaderValue is what was given to construct it.

Returns:Object

the key component of this ClassLoaderValue.

mapback to summary
private static <CLV extends AbstractClassLoaderValue<CLV, ?>> ConcurrentHashMap<CLV, Object> map(ClassLoader cl)
Returns:ConcurrentHashMap<CLV, Object>

a ConcurrentHashMap for given ClassLoader

Annotations
@SuppressWarnings:unchecked
putIfAbsentback to summary
public V putIfAbsent(ClassLoader cl, V v)

Associates given value v with this ClassLoaderValue and given ClassLoader and returns null if there was no previously associated value or does nothing and returns previously associated value if there was one.

Parameters
cl:ClassLoader

the ClassLoader for the associated value

v:V

the value to associate

Returns:V

previously associated value or null if there was none

removeback to summary
public boolean remove(ClassLoader cl, Object v)

Removes the value associated with this ClassLoaderValue and given ClassLoader if the associated value is equal to given value v and returns true or does nothing and returns false if there is no currently associated value or it is not equal to given value v.

Parameters
cl:ClassLoader

the ClassLoader for the associated value

v:Object

the value to compare with currently associated value

Returns:boolean

true if the association was removed or false if not

removeAllback to summary
public void removeAll(ClassLoader cl)

Removes all values associated with given ClassLoader cl and this or descendants of this ClassLoaderValue. This is not an atomic operation. Other threads may see some associations be already removed and others still present while this method is executing.

The sole intention of this method is to cleanup after a unit test that tests ClassLoaderValue directly. It is not intended for use in actual algorithms.

Parameters
cl:ClassLoader

the associated ClassLoader of the values to be removed

subback to summary
public <K> AbstractClassLoaderValue<CLV, V>.Sub<K> sub(K key)

Constructs new sub-ClassLoaderValue of this ClassLoaderValue with given key component.

Parameters
<K>
the type of the key component.
key:K

the key component of the sub-ClassLoaderValue.

Returns:AbstractClassLoaderValue<CLV, V>.Sub<K>

a sub-ClassLoaderValue of this ClassLoaderValue for given key

jdk.internal.loader back to summary

private final Class AbstractClassLoaderValue.Memoizer<CLV extends AbstractClassLoaderValue<CLV, V>, V>

extends Object
implements Supplier<V>
Class Inheritance
All Implemented Interfaces
java.util.function.Supplier

A memoized supplier that invokes given mappingFunction just once and remembers the result or thrown exception for subsequent calls. If given mappingFunction returns null, it is converted to NullPointerException, thrown from the Memoizer's get() method and remembered. If the Memoizer is invoked recursively from the given mappingFunction, RecursiveInvocationException is thrown, but it is not remembered. The in-flight call to the get() can still complete successfully if such exception is handled by the mappingFunction.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
private final ClassLoader
private final CLV
private boolean
private final BiFunction<? super ClassLoader, ? super CLV, ? extends V>
private volatile Throwable
t

private volatile V
v

Constructor Summary

AccessConstructor and Description
pack-priv
Memoizer(ClassLoader cl, CLV clv, BiFunction<? super ClassLoader, ? super CLV, ? extends V> mappingFunction)

Method Summary

Modifier and TypeMethod and Description
public V
get()

Implements java.util.function.Supplier.get.

Gets a result.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

clback to summary
private final ClassLoader cl
clvback to summary
private final CLV clv
inCallback to summary
private boolean inCall
mappingFunctionback to summary
private final BiFunction<? super ClassLoader, ? super CLV, ? extends V> mappingFunction
tback to summary
private volatile Throwable t
vback to summary
private volatile V v

Constructor Detail

Memoizerback to summary
pack-priv Memoizer(ClassLoader cl, CLV clv, BiFunction<? super ClassLoader, ? super CLV, ? extends V> mappingFunction)

Method Detail

getback to summary
public V get() throws RecursiveInvocationException

Implements java.util.function.Supplier.get.

Doc from java.util.function.Supplier.get.

Gets a result.

Annotations
@Override
jdk.internal.loader back to summary

pack-priv Class AbstractClassLoaderValue.Memoizer.RecursiveInvocationException

extends IllegalStateException
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
pack-priv

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.lang.IllegalStateException.serialVersionUID.

Annotations
@Serial

Constructor Detail

RecursiveInvocationExceptionback to summary
pack-priv RecursiveInvocationException()
jdk.internal.loader back to summary

public final Class AbstractClassLoaderValue.Sub<K>

extends AbstractClassLoaderValue<AbstractClassLoaderValue<CLV extends AbstractClassLoaderValue<CLV, V>, V>.Sub<K>, V>
Class Inheritance
Type Parameters
<K>
the type of key() component contained in the sub-ClassLoaderValue.

sub-ClassLoaderValue is an inner class of AbstractClassLoaderValue and also a subclass of it. It can therefore be instantiated as an inner class of either an instance of root-ClassLoaderValue or another instance of itself. This enables composing type-safe compound keys of arbitrary length:
ClassLoaderValue<V> clv = new ClassLoaderValue<>();
ClassLoaderValue<V>.Sub<K1>.Sub<K2>.Sub<K3> clv_k123 =
    clv.sub(k1).sub(k2).sub(k3);
From which individual components are accessible in a type-safe way:
K1 k1 = clv_k123.parent().parent().key();
K2 k2 = clv_k123.parent().key();
K3 k3 = clv_k123.key();
This allows specifying non-capturing lambdas for the mapping function of computeIfAbsent(ClassLoader, BiFunction) operation that can access individual key components from passed-in sub-[sub-...]ClassLoaderValue instance in a type-safe way.

Field Summary

Modifier and TypeField and Description
private final K

Constructor Summary

AccessConstructor and Description
pack-priv
Sub(K key)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object o)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public boolean
isEqualOrDescendantOf(AbstractClassLoaderValue<?, V> clv)

Implements abstract jdk.internal.loader.AbstractClassLoaderValue.isEqualOrDescendantOf.

sub-ClassLoaderValue is a descendant of given clv if it is either equal to it or if its parent is a descendant of given clv.

public K

Returns:

the key component of this sub-ClassLoaderValue.
key
()

Implements abstract jdk.internal.loader.AbstractClassLoaderValue.key.

Returns the key component of this ClassLoaderValue.

public AbstractClassLoaderValue<CLV, V>
parent()

Returns: the parent ClassLoaderValue this sub-ClassLoaderValue has been derived from.

Inherited from jdk.internal.loader.AbstractClassLoaderValue:
computeIfAbsentgetputIfAbsentremoveremoveAllsub

Field Detail

keyback to summary
private final K key

Constructor Detail

Subback to summary
pack-priv Sub(K key)

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Annotations
@Override
isEqualOrDescendantOfback to summary
public boolean isEqualOrDescendantOf(AbstractClassLoaderValue<?, V> clv)

Implements abstract jdk.internal.loader.AbstractClassLoaderValue.isEqualOrDescendantOf.

sub-ClassLoaderValue is a descendant of given clv if it is either equal to it or if its parent is a descendant of given clv.

Annotations
@Override
keyback to summary
public K key()

Implements abstract jdk.internal.loader.AbstractClassLoaderValue.key.

Doc from jdk.internal.loader.AbstractClassLoaderValue.key.

Returns the key component of this ClassLoaderValue. The key component of the root-ClassLoaderValue is the ClassLoaderValue itself, while the key component of a sub-ClassLoaderValue is what was given to construct it.

Returns:K

the key component of this sub-ClassLoaderValue.

Annotations
@Override
parentback to summary
public AbstractClassLoaderValue<CLV, V> parent()
Returns:AbstractClassLoaderValue<CLV, V>

the parent ClassLoaderValue this sub-ClassLoaderValue has been derived from.