src/share/classes/java/lang/invoke/MethodHandle.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File
*** old/src/share/classes/java/lang/invoke/MethodHandle.java Fri Jul 11 20:08:50 2014
--- new/src/share/classes/java/lang/invoke/MethodHandle.java Fri Jul 11 20:08:50 2014
*** 989,1000 ****
--- 989,1003 ----
target = convertArguments(type().changeParameterType(collectArgPos, arrayType));
MethodHandle collector = MethodHandleImpl.varargsArray(arrayType, arrayLength);
return MethodHandles.collectArguments(target, collectArgPos, collector);
}
// private API: return true if last param exactly matches arrayType
private boolean asCollectorChecks(Class<?> arrayType, int arrayLength) {
+ /**
+ * See if {@code asCollector} can be validly called with the given arguments.
+ * Return false if the last parameter is not an exact match to arrayType.
+ */
+ /*non-public*/ boolean asCollectorChecks(Class<?> arrayType, int arrayLength) {
spreadArrayChecks(arrayType, arrayLength);
int nargs = type().parameterCount();
if (nargs != 0) {
Class<?> lastParam = type().parameterType(nargs-1);
if (lastParam == arrayType) return true;
*** 1152,1162 ****
--- 1155,1165 ----
* @see #asCollector
* @see #isVarargsCollector
* @see #asFixedArity
*/
public MethodHandle asVarargsCollector(Class<?> arrayType) {
Class<?> arrayElement = arrayType.getComponentType();
+ arrayType.getClass(); // explicit NPE
boolean lastMatch = asCollectorChecks(arrayType, 0);
if (isVarargsCollector() && lastMatch)
return this;
return MethodHandleImpl.makeVarargsCollector(this, arrayType);
}
*** 1309,1318 ****
--- 1312,1322 ----
return MethodHandleImpl.makeVarargsCollector(this, arrayType);
}
}
throw member.makeAccessException("cannot make variable arity", null);
}
+
/*non-public*/
MethodHandle viewAsType(MethodType newType) {
// No actual conversions, just a new view of the same method.
return MethodHandleImpl.makePairwiseConvert(this, newType, 0);
}
*** 1467,1476 ****
--- 1471,1481 ----
* Use with discretion.
*/
/*non-public*/
void updateForm(LambdaForm newForm) {
if (form == newForm) return;
+ assert(this instanceof DirectMethodHandle && this.internalMemberName().isStatic());
// ISSUE: Should we have a memory fence here?
UNSAFE.putObject(this, FORM_OFFSET, newForm);
this.form.prepare(); // as in MethodHandle.<init>
}
src/share/classes/java/lang/invoke/MethodHandle.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File