-
- All Known Subinterfaces:
-
BootstrapCallInfo<T>
- All Known Implementing Classes:
-
ConstantGroup.AbstractImpl
public interface ConstantGroup extends List<Object>
An ordered list of constants, some of which may not yet be linked. This type is used byBootstrapCallInfo
to represent the sequence of bootstrap arguments associated with a bootstrap method, without forcing their immediate resolution.In order to peek at a constant without necessarily resolving it, use the normal get method inherited from
List
. This method will never throw a resolution error but may return the emptyNOT_PRESENT
. If you need to resolve the constant, use theresolve(int)
method, but be prepared to catch anyLinkageError
arising from the resolution process, if the constant is not already resolved.To iterate through the constants, resolving as you go, use the view method
resolving()
.- Since:
- 1.10
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
ConstantGroup.AbstractImpl
Utility class for implementing ConstantGroup.
-
Field Summary
Fields Modifier and Type Field Description static Object
NOT_PRESENT
Sentinel value returned byget(int)
if a requested constant is not available, either because it has not yet been resolved, or because resolution was attempted but caused an error.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
copyOutArguments(int start, int end, Object[] buf, int pos, boolean resolve, Object ifNotPresent)
Copy a sequence of static arguments for this call into a given buffer.Object
get(int index)
Returns the selected constant, or a sentinel value if there is none available.default Object
get(int index, Object ifNotPresent)
Returns the selected constant, or the given sentinel value if there is none available.Object
resolve(int index)
Returns the selected constant, resolving it if necessary.default Iterable<Object>
resolving()
Iterate over this list forcing resolution at each step, as if by callingresolve(int)
instead ofget(int)
default ConstantGroup
subList(int start, int end)
Create a view on a sub-list of this list.-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream
-
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, equals, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, of, of, of, of, of, of, of, of, of, of, of, of, remove, remove, removeAll, replaceAll, retainAll, set, size, sort, spliterator, toArray, toArray
-
-
-
-
Method Detail
-
get
Object get(int index)
Returns the selected constant, or a sentinel value if there is none available. If the argument cannot be resolved, the sentinel will be returned. If the argument can (perhaps) be resolved, but has not yet been resolved, then the sentinel may be returned, at the implementation's discretion. To force resolution (and a possible exception), callresolve(int)
.- Specified by:
-
get
in interfaceList<Object>
- Parameters:
-
index
- the selected constant - Returns:
- the static argument, if available, else the sentinel value
NOT_PRESENT
.
-
get
default Object get(int index, Object ifNotPresent)
Returns the selected constant, or the given sentinel value if there is none available.- Parameters:
-
index
- which constant to select -
ifNotPresent
- the sentinel value to return if the constant is not present - Returns:
- the selected constant
-
resolve
Object resolve(int index) throws LinkageError
Returns the selected constant, resolving it if necessary.- Parameters:
-
index
- which constant to select - Returns:
- the selected constant
- Throws:
-
LinkageError
- if the static argument needs resolution and cannot be resolved
-
resolving
default Iterable<Object> resolving()
Iterate over this list forcing resolution at each step, as if by callingresolve(int)
instead ofget(int)
- Returns:
- an object ready to iterate over the list, resolving as it goes
-
subList
default ConstantGroup subList(int start, int end)
Create a view on a sub-list of this list.
-
copyOutArguments
default void copyOutArguments(int start, int end, Object[] buf, int pos, boolean resolve, Object ifNotPresent) throws LinkageError
Copy a sequence of static arguments for this call into a given buffer. This is equivalent toend-offset
separate calls toargument
, for each index in the range fromoffset
up to but not includingend
. If- Parameters:
-
start
- index of first argument to retrieve -
end
- limiting index of arguments to retrieve -
buf
- array to receive the requested arguments -
pos
- position in the array to offset storing the arguments -
resolve
- whether to force resolution -
ifNotPresent
- sentinel value to store ifresolve
is false and the argument is not available - Throws:
-
LinkageError
- ifresolve
is true and an argument cannot be resolved
-
-