Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8078641: MethodHandle.asTypeCache can retain classes from unloading #5246

Closed
wants to merge 6 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -873,9 +873,10 @@ private MethodHandle asTypeCached(MethodType newType) {
if (atc != null && newType == atc.type) {
return atc; // cache hit
}
if (asTypeSoftCache != null) {
atc = asTypeSoftCache.get();
if (newType == atc.type) {
SoftReference<MethodHandle> softCache = asTypeSoftCache;
if (softCache != null) {
atc = softCache.get();
if (atc != null && newType == atc.type) {
return atc; // soft cache hit
}
}
Expand Down Expand Up @@ -930,7 +931,7 @@ private static ClassLoader getApproximateCommonClassLoader(MethodType mt) {
return loader;
}

/* Returns true when {@code loader} keeps {@code mt} either directly or indirectly through the loader delegation chain. */
/* Returns true when {@code loader} keeps components of {@code mt} reachable either directly or indirectly through the loader delegation chain. */
private static boolean keepsAlive(MethodType mt, ClassLoader loader) {
for (Class<?> ptype : mt.ptypes()) {
if (!keepsAlive(ptype, loader)) {
Expand Down