8030221: Checking for anonymous class should check for NULL as well as potential nesting

Store the first non-anonymous class as the host when defining the anonymous class so don't need look for it later.

Reviewed-by: dholmes, lfoltan
This commit is contained in:
Harold Seigel 2016-08-16 09:56:18 -04:00
parent e3c3a54f7a
commit 2a74c06b8d
3 changed files with 104 additions and 5 deletions

View file

@ -861,6 +861,13 @@ Unsafe_DefineAnonymousClass_impl(JNIEnv *env,
}
const Klass* host_klass = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(host_class));
// Make sure it's the real host class, not another anonymous class.
while (host_klass != NULL && host_klass->is_instance_klass() &&
InstanceKlass::cast(host_klass)->is_anonymous()) {
host_klass = InstanceKlass::cast(host_klass)->host_klass();
}
// Primitive types have NULL Klass* fields in their java.lang.Class instances.
if (host_klass == NULL) {
THROW_0(vmSymbols::java_lang_IllegalArgumentException());