java.lang.Object
org.microbean.invoke.BootstrapMethods
Useful constant bootstrap methods and methods that make sense to invoke from
ConstantBootstraps.invoke(Lookup, String, Class, MethodHandle, Object...)
.- Author:
- Laird Nelson
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic final ConstantCallSite
findConstructorCallSite
(MethodHandles.Lookup lookup, String ignoredMethodName, MethodType methodType, Class<?> targetClass) static final ConstantCallSite
findSetterCallSite
(MethodHandles.Lookup lookup, String fieldName, MethodType methodType, Class<?> targetClass) static final ConstantCallSite
findStaticCallSiteAsSpreader
(MethodHandles.Lookup lookup, String methodName, MethodType methodType, Class<?> targetClass) static final ConstantCallSite
findStaticSetterCallSite
(MethodHandles.Lookup lookup, String fieldName, MethodType methodType, Class<?> targetClass) static final ConstantCallSite
findVirtualCallSite
(MethodHandles.Lookup lookup, String methodName, MethodType methodType, Class<?> targetClass) static final <K,
V> SortedMap<K, V> immutableEmptySortedMap
(Comparator<? super K> comparator) Returns an empty, immutableSortedMap
.static final <E> SortedSet<E>
immutableEmptySortedSet
(Comparator<? super E> comparator) Returns an immutable, emptySortedSet
.static final <K,
V> SortedMap<K, V> immutableSortedMapOf
(Collection<? extends Map.Entry<K, V>> entries) static final <K,
V> SortedMap<K, V> immutableSortedMapOf
(Collection<? extends Map.Entry<K, V>> entries, Comparator<? super K> comparator) static final <K,
V> SortedMap<K, V> immutableSortedMapOf
(Map<? extends K, ? extends V> map) static final <K,
V> SortedMap<K, V> immutableSortedMapOf
(Map<? extends K, ? extends V> map, Comparator<? super K> comparator) static final <E> SortedSet<E>
immutableSortedSetOf
(Collection<? extends E> set) Given aCollection
, returns aSortedSet
representing it that is immutable.static final <E> SortedSet<E>
immutableSortedSetOf
(Collection<? extends E> set, Comparator<? super E> comparator) Given aCollection
, returns aSortedSet
representing it that is immutable.
-
Method Details
-
findStaticSetterCallSite
public static final ConstantCallSite findStaticSetterCallSite(MethodHandles.Lookup lookup, String fieldName, MethodType methodType, Class<?> targetClass) throws Throwable - Parameters:
lookup
- aMethodHandles.Lookup
; will not benull
fieldName
- the name of the static field to find; will not benull
methodType
- aMethodType
; will not benull
targetClass
- theClass
whose static field will be sought; will not benull
- Returns:
- a
ConstantCallSite
backed by a static setterMethodHandle
- Throws:
Throwable
- if an error occurs- See Also:
- Idempotency:
- This method is idempotent and deterministic.
- Nullability:
- This method never returns
null
. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
findStaticCallSiteAsSpreader
public static final ConstantCallSite findStaticCallSiteAsSpreader(MethodHandles.Lookup lookup, String methodName, MethodType methodType, Class<?> targetClass) throws Throwable Returns aConstantCallSite
backed by a staticMethodHandle
adapted to be an array-spreadingMethodHandle
.- Parameters:
lookup
- aMethodHandles.Lookup
; will not benull
methodName
- the name of the static field to find; will not benull
methodType
- aMethodType
; will not benull
targetClass
- theClass
whose static method will be sought; will not benull
- Returns:
- a
ConstantCallSite
backed by a staticMethodHandle
adapted to be an array-spreadingMethodHandle
- Throws:
Throwable
- if an error occurs- See Also:
- Idempotency:
- This method is idempotent and deterministic.
- Nullability:
- This method never returns
null
. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
findSetterCallSite
public static final ConstantCallSite findSetterCallSite(MethodHandles.Lookup lookup, String fieldName, MethodType methodType, Class<?> targetClass) throws Throwable - Parameters:
lookup
- aMethodHandles.Lookup
; will not benull
fieldName
- the name of the field to find; will not benull
methodType
- aMethodType
; will not benull
targetClass
- theClass
whose instance field will be sought; will not benull
- Returns:
- a
ConstantCallSite
backed by a setterMethodHandle
- Throws:
Throwable
- if an error occurs- See Also:
- Idempotency:
- This method is idempotent and deterministic.
- Nullability:
- This method never returns
null
. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
findVirtualCallSite
public static final ConstantCallSite findVirtualCallSite(MethodHandles.Lookup lookup, String methodName, MethodType methodType, Class<?> targetClass) throws Throwable - Parameters:
lookup
- aMethodHandles.Lookup
; will not benull
methodName
- the name of the method to find; will not benull
methodType
- aMethodType
; will not benull
targetClass
- theClass
whose virtual method will be sought; will not benull
- Returns:
- a
ConstantCallSite
backed by a virtualMethodHandle
- Throws:
Throwable
- if an error occurs- See Also:
- Idempotency:
- This method is idempotent and deterministic.
- Nullability:
- This method never returns
null
. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
findConstructorCallSite
public static final ConstantCallSite findConstructorCallSite(MethodHandles.Lookup lookup, String ignoredMethodName, MethodType methodType, Class<?> targetClass) throws Throwable - Parameters:
lookup
- aMethodHandles.Lookup
; will not benull
ignoredMethodName
- ignoredmethodType
- aMethodType
; will not benull
targetClass
- theClass
whose constructor will be sought; will not benull
- Returns:
- a
ConstantCallSite
backed by a constructorMethodHandle
- Throws:
Throwable
- if an error occurs- See Also:
- Idempotency:
- This method is idempotent and deterministic.
- Nullability:
- This method never returns
null
. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
immutableEmptySortedMap
Returns an empty, immutableSortedMap
.- Type Parameters:
K
- the type borne by the suppliedMap
's keysV
- the type borne by the suppliedMap
's values- Parameters:
comparator
- theComparator
to be returned by the returnedSortedMap
'sSortedMap.comparator()
method; may benull
- Returns:
- an immutable, empty
SortedMap
- Throws:
NullPointerException
- ifmap
isnull
- Idempotency:
- This method is idempotent and deterministic.
- Nullability:
- This method never returns
null
. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
immutableSortedMapOf
public static final <K,V> SortedMap<K,V> immutableSortedMapOf(Collection<? extends Map.Entry<K, V>> entries) - Type Parameters:
K
- the type borne by the supplied entries' keysV
- the type borne by the supplied entries' values- Parameters:
entries
- theMap.Entry
instances to represent; must not benull
- Returns:
- an immutable
SortedMap
representing the supplied entries - Throws:
NullPointerException
- ifentries
isnull
- See Also:
- Idempotency:
- This method is idempotent and deterministic.
- Nullability:
- This method never returns
null
. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
immutableSortedMapOf
public static final <K,V> SortedMap<K,V> immutableSortedMapOf(Collection<? extends Map.Entry<K, V>> entries, Comparator<? super K> comparator) - Type Parameters:
K
- the type borne by the supplied entries' keysV
- the type borne by the supplied entries' values- Parameters:
entries
- theMap.Entry
instances to represent; must not benull
comparator
- theComparator
to use to order the returnedSortedMap
's elements; may benull
to indicate natural order should be used in which case the supplied keys and values must implementComparable
- Returns:
- an immutable
SortedMap
representing the supplied entries - Throws:
NullPointerException
- ifentries
isnull
- Idempotency:
- This method is idempotent and deterministic.
- Nullability:
- This method never returns
null
. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
immutableSortedMapOf
- Type Parameters:
K
- the type borne by the suppliedMap
's keysV
- the type borne by the suppliedMap
's values- Parameters:
map
- theMap
to represent; must not benull
- Returns:
- an immutable
SortedMap
representing the suppliedMap
- Throws:
NullPointerException
- ifmap
isnull
- See Also:
- Idempotency:
- This method is idempotent and deterministic.
- Nullability:
- This method never returns
null
. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
immutableSortedMapOf
public static final <K,V> SortedMap<K,V> immutableSortedMapOf(Map<? extends K, ? extends V> map, Comparator<? super K> comparator) - Type Parameters:
K
- the type borne by the suppliedMap
's keysV
- the type borne by the suppliedMap
's values- Parameters:
map
- theMap
to represent; must not benull
comparator
- theComparator
to use to order the suppliedMap
's elements; may benull
to indicate natural order should be used in which case the suppliedMap
's elements must implementComparable
- Returns:
- an immutable
SortedMap
representing the suppliedMap
- Throws:
NullPointerException
- ifmap
isnull
- Idempotency:
- This method is idempotent and deterministic.
- Nullability:
- This method never returns
null
. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
immutableEmptySortedSet
Returns an immutable, emptySortedSet
.- Type Parameters:
E
- theSortedSet
's element type- Parameters:
comparator
- theComparator
to be returned by the returnedSortedSet
'sSortedSet.comparator()
method; may benull
- Returns:
- an immutable, empty
SortedSet
- Throws:
NullPointerException
- ifset
isnull
- See Also:
- Idempotency:
- This method is idempotent and deterministic.
- Nullability:
- This method never returns
null
. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
immutableSortedSetOf
Given aCollection
, returns aSortedSet
representing it that is immutable.- Type Parameters:
E
- the type borne by the suppliedCollection
's elements- Parameters:
set
- theCollection
to represent; must not benull
- Returns:
- an immutable
SortedSet
representing the suppliedCollection
- Throws:
NullPointerException
- ifset
isnull
- See Also:
- Idempotency:
- This method is idempotent and deterministic.
- Nullability:
- This method never returns
null
. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
immutableSortedSetOf
public static final <E> SortedSet<E> immutableSortedSetOf(Collection<? extends E> set, Comparator<? super E> comparator) Given aCollection
, returns aSortedSet
representing it that is immutable.- Type Parameters:
E
- the type borne by the suppliedCollection
's elements- Parameters:
set
- theCollection
to represent; must not benull
comparator
- theComparator
to use to order the suppliedCollection
's elements; may benull
to indicate natural order should be used in which case the suppliedCollection
's elements must implementComparable
- Returns:
- an immutable
SortedSet
representing the suppliedCollection
- Throws:
NullPointerException
- ifset
isnull
- Idempotency:
- This method is idempotent and deterministic.
- Nullability:
- This method never returns
null
. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-