8166304: Skipping access check for classes generated by core reflection

Only allow boot and reflection class loader to load sub-types of jdk.internal.reflect

Reviewed-by: acorn, lfoltan, rehn
This commit is contained in:
Harold Seigel 2016-11-17 14:23:29 -05:00
parent 81f1e7056b
commit ccbb28f6a0
6 changed files with 161 additions and 9 deletions

View file

@ -3525,17 +3525,24 @@ bool java_lang_ClassLoader::is_trusted_loader(oop loader) {
return false;
}
oop java_lang_ClassLoader::non_reflection_class_loader(oop loader) {
// Return true if this is one of the class loaders associated with
// the generated bytecodes for reflection.
bool java_lang_ClassLoader::is_reflection_class_loader(oop loader) {
if (loader != NULL) {
// See whether this is one of the class loaders associated with
// the generated bytecodes for reflection, and if so, "magically"
// delegate to its parent to prevent class loading from occurring
// in places where applications using reflection didn't expect it.
Klass* delegating_cl_class = SystemDictionary::reflect_DelegatingClassLoader_klass();
// This might be null in non-1.4 JDKs
if (delegating_cl_class != NULL && loader->is_a(delegating_cl_class)) {
return parent(loader);
}
return (delegating_cl_class != NULL && loader->is_a(delegating_cl_class));
}
return false;
}
oop java_lang_ClassLoader::non_reflection_class_loader(oop loader) {
// See whether this is one of the class loaders associated with
// the generated bytecodes for reflection, and if so, "magically"
// delegate to its parent to prevent class loading from occurring
// in places where applications using reflection didn't expect it.
if (is_reflection_class_loader(loader)) {
return parent(loader);
}
return loader;
}