提交 2b04f898 编写于 作者: H hseigel

8189123: More consistent classloading

Reviewed-by: acorn, ahgross, rhalade
Contributed-by: harold.seigel@oracle.com
上级 4543f523
/* /*
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -63,6 +63,7 @@ bool VerificationType::is_reference_assignable_from( ...@@ -63,6 +63,7 @@ bool VerificationType::is_reference_assignable_from(
name(), Handle(THREAD, klass->class_loader()), name(), Handle(THREAD, klass->class_loader()),
Handle(THREAD, klass->protection_domain()), true, CHECK_false); Handle(THREAD, klass->protection_domain()), true, CHECK_false);
KlassHandle this_class(THREAD, obj); KlassHandle this_class(THREAD, obj);
klass->class_loader_data()->record_dependency(obj, CHECK_false);
if (this_class->is_interface() && (!from_field_is_protected || if (this_class->is_interface() && (!from_field_is_protected ||
from.name() != vmSymbols::java_lang_Object())) { from.name() != vmSymbols::java_lang_Object())) {
...@@ -74,6 +75,7 @@ bool VerificationType::is_reference_assignable_from( ...@@ -74,6 +75,7 @@ bool VerificationType::is_reference_assignable_from(
Klass* from_class = SystemDictionary::resolve_or_fail( Klass* from_class = SystemDictionary::resolve_or_fail(
from.name(), Handle(THREAD, klass->class_loader()), from.name(), Handle(THREAD, klass->class_loader()),
Handle(THREAD, klass->protection_domain()), true, CHECK_false); Handle(THREAD, klass->protection_domain()), true, CHECK_false);
klass->class_loader_data()->record_dependency(from_class, CHECK_false);
bool result = InstanceKlass::cast(from_class)->is_subclass_of(this_class()); bool result = InstanceKlass::cast(from_class)->is_subclass_of(this_class());
if (result && DumpSharedSpaces) { if (result && DumpSharedSpaces) {
if (klass()->is_subclass_of(from_class) && klass()->is_subclass_of(this_class())) { if (klass()->is_subclass_of(from_class) && klass()->is_subclass_of(this_class())) {
......
...@@ -1949,9 +1949,11 @@ Klass* ClassVerifier::load_class(Symbol* name, TRAPS) { ...@@ -1949,9 +1949,11 @@ Klass* ClassVerifier::load_class(Symbol* name, TRAPS) {
oop loader = current_class()->class_loader(); oop loader = current_class()->class_loader();
oop protection_domain = current_class()->protection_domain(); oop protection_domain = current_class()->protection_domain();
return SystemDictionary::resolve_or_fail( Klass* kls = SystemDictionary::resolve_or_fail(
name, Handle(THREAD, loader), Handle(THREAD, protection_domain), name, Handle(THREAD, loader), Handle(THREAD, protection_domain),
true, CHECK_NULL); true, CHECK_NULL);
current_class()->class_loader_data()->record_dependency(kls, CHECK_NULL);
return kls;
} }
bool ClassVerifier::is_protected_access(instanceKlassHandle this_class, bool ClassVerifier::is_protected_access(instanceKlassHandle this_class,
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "precompiled.hpp" #include "precompiled.hpp"
#include "classfile/classLoader.hpp" #include "classfile/classLoader.hpp"
#include "classfile/classLoaderData.inline.hpp"
#include "classfile/classLoaderExt.hpp" #include "classfile/classLoaderExt.hpp"
#include "classfile/javaAssertions.hpp" #include "classfile/javaAssertions.hpp"
#include "classfile/javaClasses.hpp" #include "classfile/javaClasses.hpp"
...@@ -952,6 +953,12 @@ JVM_ENTRY(jclass, JVM_FindClassFromClass(JNIEnv *env, const char *name, ...@@ -952,6 +953,12 @@ JVM_ENTRY(jclass, JVM_FindClassFromClass(JNIEnv *env, const char *name,
Handle h_prot (THREAD, protection_domain); Handle h_prot (THREAD, protection_domain);
jclass result = find_class_from_class_loader(env, h_name, init, h_loader, jclass result = find_class_from_class_loader(env, h_name, init, h_loader,
h_prot, true, thread); h_prot, true, thread);
if (result != NULL) {
oop mirror = JNIHandles::resolve_non_null(result);
Klass* to_class = java_lang_Class::as_Klass(mirror);
ClassLoaderData* cld = ClassLoaderData::class_loader_data(h_loader());
cld->record_dependency(to_class, CHECK_NULL);
}
if (TraceClassResolution && result != NULL) { if (TraceClassResolution && result != NULL) {
// this function is generally only used for class loading during verification. // this function is generally only used for class loading during verification.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册