mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8078641: MethodHandle.asTypeCache can retain classes from unloading
Co-authored-by: Peter Levart <plevart@openjdk.org> Co-authored-by: Vladimir Ivanov <vlivanov@openjdk.org> Reviewed-by: psandoz, mchung, plevart
This commit is contained in:
parent
185557423d
commit
21012f2bbe
2 changed files with 106 additions and 21 deletions
|
@ -493,12 +493,12 @@ abstract class MethodHandleImpl {
|
|||
if (newArity == collectArg+1 &&
|
||||
type.parameterType(collectArg).isAssignableFrom(newType.parameterType(collectArg))) {
|
||||
// if arity and trailing parameter are compatible, do normal thing
|
||||
return asTypeCache = asFixedArity().asType(newType);
|
||||
return asFixedArity().asType(newType);
|
||||
}
|
||||
// check cache
|
||||
MethodHandle acc = asCollectorCache;
|
||||
if (acc != null && acc.type().parameterCount() == newArity)
|
||||
return asTypeCache = acc.asType(newType);
|
||||
return acc.asType(newType);
|
||||
// build and cache a collector
|
||||
int arrayLength = newArity - collectArg;
|
||||
MethodHandle collector;
|
||||
|
@ -509,7 +509,7 @@ abstract class MethodHandleImpl {
|
|||
throw new WrongMethodTypeException("cannot build collector", ex);
|
||||
}
|
||||
asCollectorCache = collector;
|
||||
return asTypeCache = collector.asType(newType);
|
||||
return collector.asType(newType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -737,7 +737,7 @@ abstract class MethodHandleImpl {
|
|||
} else {
|
||||
wrapper = newTarget; // no need for a counting wrapper anymore
|
||||
}
|
||||
return (asTypeCache = wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
boolean countDown() {
|
||||
|
@ -1213,7 +1213,7 @@ abstract class MethodHandleImpl {
|
|||
public MethodHandle asTypeUncached(MethodType newType) {
|
||||
// This MH is an alias for target, except for the MemberName
|
||||
// Drop the MemberName if there is any conversion.
|
||||
return asTypeCache = target.asType(newType);
|
||||
return target.asType(newType);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1276,7 +1276,7 @@ abstract class MethodHandleImpl {
|
|||
public MethodHandle asTypeUncached(MethodType newType) {
|
||||
// This MH is an alias for target, except for the intrinsic name
|
||||
// Drop the name if there is any conversion.
|
||||
return asTypeCache = target.asType(newType);
|
||||
return target.asType(newType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue