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 ConstantCallSitefindConstructorCallSite(MethodHandles.Lookup lookup, String ignoredMethodName, MethodType methodType, Class<?> targetClass) static final ConstantCallSitefindSetterCallSite(MethodHandles.Lookup lookup, String fieldName, MethodType methodType, Class<?> targetClass) static final ConstantCallSitefindStaticCallSiteAsSpreader(MethodHandles.Lookup lookup, String methodName, MethodType methodType, Class<?> targetClass) static final ConstantCallSitefindStaticSetterCallSite(MethodHandles.Lookup lookup, String fieldName, MethodType methodType, Class<?> targetClass) static final ConstantCallSitefindVirtualCallSite(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 aSortedSetrepresenting it that is immutable.static final <E> SortedSet<E>immutableSortedSetOf(Collection<? extends E> set, Comparator<? super E> comparator) Given aCollection, returns aSortedSetrepresenting 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 benullfieldName- the name of the static field to find; will not benullmethodType- aMethodType; will not benulltargetClass- theClasswhose static field will be sought; will not benull- Returns:
- a
ConstantCallSitebacked 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 aConstantCallSitebacked by a staticMethodHandleadapted to be an array-spreadingMethodHandle.- Parameters:
lookup- aMethodHandles.Lookup; will not benullmethodName- the name of the static field to find; will not benullmethodType- aMethodType; will not benulltargetClass- theClasswhose static method will be sought; will not benull- Returns:
- a
ConstantCallSitebacked by a staticMethodHandleadapted 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 benullfieldName- the name of the field to find; will not benullmethodType- aMethodType; will not benulltargetClass- theClasswhose instance field will be sought; will not benull- Returns:
- a
ConstantCallSitebacked 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 benullmethodName- the name of the method to find; will not benullmethodType- aMethodType; will not benulltargetClass- theClasswhose virtual method will be sought; will not benull- Returns:
- a
ConstantCallSitebacked 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 benullignoredMethodName- ignoredmethodType- aMethodType; will not benulltargetClass- theClasswhose constructor will be sought; will not benull- Returns:
- a
ConstantCallSitebacked 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- theComparatorto be returned by the returnedSortedMap'sSortedMap.comparator()method; may benull- Returns:
- an immutable, empty
SortedMap - Throws:
NullPointerException- ifmapisnull- 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.Entryinstances to represent; must not benull- Returns:
- an immutable
SortedMaprepresenting the supplied entries - Throws:
NullPointerException- ifentriesisnull- 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.Entryinstances to represent; must not benullcomparator- theComparatorto use to order the returnedSortedMap's elements; may benullto indicate natural order should be used in which case the supplied keys and values must implementComparable- Returns:
- an immutable
SortedMaprepresenting the supplied entries - Throws:
NullPointerException- ifentriesisnull- 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- theMapto represent; must not benull- Returns:
- an immutable
SortedMaprepresenting the suppliedMap - Throws:
NullPointerException- ifmapisnull- 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- theMapto represent; must not benullcomparator- theComparatorto use to order the suppliedMap's elements; may benullto indicate natural order should be used in which case the suppliedMap's elements must implementComparable- Returns:
- an immutable
SortedMaprepresenting the suppliedMap - Throws:
NullPointerException- ifmapisnull- 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- theComparatorto be returned by the returnedSortedSet'sSortedSet.comparator()method; may benull- Returns:
- an immutable, empty
SortedSet - Throws:
NullPointerException- ifsetisnull- 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 aSortedSetrepresenting it that is immutable.- Type Parameters:
E- the type borne by the suppliedCollection's elements- Parameters:
set- theCollectionto represent; must not benull- Returns:
- an immutable
SortedSetrepresenting the suppliedCollection - Throws:
NullPointerException- ifsetisnull- 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 aSortedSetrepresenting it that is immutable.- Type Parameters:
E- the type borne by the suppliedCollection's elements- Parameters:
set- theCollectionto represent; must not benullcomparator- theComparatorto use to order the suppliedCollection's elements; may benullto indicate natural order should be used in which case the suppliedCollection's elements must implementComparable- Returns:
- an immutable
SortedSetrepresenting the suppliedCollection - Throws:
NullPointerException- ifsetisnull- 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.
-