mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8332547: Unloaded signature classes in DirectMethodHandles
Reviewed-by: jvernee, liach
This commit is contained in:
parent
c7d2a5c1c4
commit
29e10e4582
4 changed files with 83 additions and 15 deletions
|
@ -268,7 +268,7 @@ public class VerifyAccess {
|
|||
* @param type the supposed type of a member or symbolic reference of refc
|
||||
* @param refc the class attempting to make the reference
|
||||
*/
|
||||
public static boolean isTypeVisible(Class<?> type, Class<?> refc) {
|
||||
public static boolean ensureTypeVisible(Class<?> type, Class<?> refc) {
|
||||
if (type == refc) {
|
||||
return true; // easy check
|
||||
}
|
||||
|
@ -284,12 +284,14 @@ public class VerifyAccess {
|
|||
if (refcLoader == null && typeLoader != null) {
|
||||
return false;
|
||||
}
|
||||
if (typeLoader == null && type.getName().startsWith("java.")) {
|
||||
// Note: The API for actually loading classes, ClassLoader.defineClass,
|
||||
// guarantees that classes with names beginning "java." cannot be aliased,
|
||||
// because class loaders cannot load them directly.
|
||||
return true;
|
||||
}
|
||||
|
||||
// The API for actually loading classes, ClassLoader.defineClass,
|
||||
// guarantees that classes with names beginning "java." cannot be aliased,
|
||||
// because class loaders cannot load them directly. However, it is beneficial
|
||||
// for JIT-compilers to ensure all signature classes are loaded.
|
||||
// JVM doesn't install any loader contraints when performing MemberName resolution,
|
||||
// so eagerly resolving signature classes is a way to match what JVM achieves
|
||||
// with loader constraints during method resolution for invoke bytecodes.
|
||||
|
||||
// Do it the hard way: Look up the type name from the refc loader.
|
||||
//
|
||||
|
@ -338,12 +340,12 @@ public class VerifyAccess {
|
|||
* @param type the supposed type of a member or symbolic reference of refc
|
||||
* @param refc the class attempting to make the reference
|
||||
*/
|
||||
public static boolean isTypeVisible(java.lang.invoke.MethodType type, Class<?> refc) {
|
||||
if (!isTypeVisible(type.returnType(), refc)) {
|
||||
public static boolean ensureTypeVisible(java.lang.invoke.MethodType type, Class<?> refc) {
|
||||
if (!ensureTypeVisible(type.returnType(), refc)) {
|
||||
return false;
|
||||
}
|
||||
for (int n = 0, max = type.parameterCount(); n < max; n++) {
|
||||
if (!isTypeVisible(type.parameterType(n), refc)) {
|
||||
if (!ensureTypeVisible(type.parameterType(n), refc)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue