-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
P4
-
None
-
Affects Version/s: 8
-
Component/s: core-libs
-
None
The specification of MethodHandles.constant(Class<?> type, Object value) makes the following statement:
The returned method handle is equivalent to identity(type).bindTo(value).
However, this is wrong for "type" representing a primitive type, as MethodHandle#bindTo(...) throws (as specified) an IllegalArgumentException if the leading parameter type is not a reference type.
I see three ways to fix the specification here:
1. Remove the sentence mentioning bindTo.
2. Replace the sentence and mention MethodHandles.insertArguments(...) instead.
3. Change the sentence to mention that this equivalence is only true for reference types.
I would personally go with 2.
The returned method handle is equivalent to identity(type).bindTo(value).
However, this is wrong for "type" representing a primitive type, as MethodHandle#bindTo(...) throws (as specified) an IllegalArgumentException if the leading parameter type is not a reference type.
I see three ways to fix the specification here:
1. Remove the sentence mentioning bindTo.
2. Replace the sentence and mention MethodHandles.insertArguments(...) instead.
3. Change the sentence to mention that this equivalence is only true for reference types.
I would personally go with 2.