8244413: Avoid rebinds in MethodHandle.viewAsType

Reviewed-by: mchung, jrose
This commit is contained in:
Claes Redestad 2020-05-06 15:51:49 +02:00
parent 463e377053
commit 72704aaba1
4 changed files with 92 additions and 36 deletions

View file

@ -1640,12 +1640,9 @@ assertEquals("[three, thee, tee]", asListFix.invoke((Object)argv).toString());
/*non-public*/
MethodHandle viewAsType(MethodType newType, boolean strict) {
// No actual conversions, just a new view of the same method.
// Note that this operation must not produce a DirectMethodHandle,
// because retyped DMHs, like any transformed MHs,
// cannot be cracked into MethodHandleInfo.
assert viewAsTypeChecks(newType, strict);
BoundMethodHandle mh = rebind();
return mh.copyWith(newType, mh.form);
// Overridden in DMH, which has special rules
assert(viewAsTypeChecks(newType, strict));
return copyWith(newType, form);
}
/*non-public*/
@ -1693,7 +1690,7 @@ assertEquals("[three, thee, tee]", asListFix.invoke((Object)argv).toString());
} else {
// The following case is rare. Mask the internalMemberName by wrapping the MH in a BMH.
MethodHandle result = rebind();
assert (result.internalMemberName() == null);
assert(result.internalMemberName() == null);
return result;
}
}
@ -1703,6 +1700,11 @@ assertEquals("[three, thee, tee]", asListFix.invoke((Object)argv).toString());
return false; // DMH.Special returns true
}
/*non-public*/
boolean isCrackable() {
return false;
}
/*non-public*/
Object internalValues() {
return null;