diff --git a/src/share/vm/classfile/verificationType.cpp b/src/share/vm/classfile/verificationType.cpp index 716a72d0d2aef2e76441ab6fce7226bc227e90e1..61715d92d5072cb536db287b943e99a50914756a 100644 --- a/src/share/vm/classfile/verificationType.cpp +++ b/src/share/vm/classfile/verificationType.cpp @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -63,6 +63,7 @@ bool VerificationType::is_reference_assignable_from( name(), Handle(THREAD, klass->class_loader()), Handle(THREAD, klass->protection_domain()), true, CHECK_false); KlassHandle this_class(THREAD, obj); + klass->class_loader_data()->record_dependency(obj, CHECK_false); if (this_class->is_interface() && (!from_field_is_protected || from.name() != vmSymbols::java_lang_Object())) { @@ -74,6 +75,7 @@ bool VerificationType::is_reference_assignable_from( Klass* from_class = SystemDictionary::resolve_or_fail( from.name(), Handle(THREAD, klass->class_loader()), 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()); if (result && DumpSharedSpaces) { if (klass()->is_subclass_of(from_class) && klass()->is_subclass_of(this_class())) { diff --git a/src/share/vm/classfile/verifier.cpp b/src/share/vm/classfile/verifier.cpp index b53b4aeda4d1b77194016f3a00848b4f851680a7..82509ff16b2514a46ff1854639153eefc3af1df4 100644 --- a/src/share/vm/classfile/verifier.cpp +++ b/src/share/vm/classfile/verifier.cpp @@ -1949,9 +1949,11 @@ Klass* ClassVerifier::load_class(Symbol* name, TRAPS) { oop loader = current_class()->class_loader(); 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), true, CHECK_NULL); + current_class()->class_loader_data()->record_dependency(kls, CHECK_NULL); + return kls; } bool ClassVerifier::is_protected_access(instanceKlassHandle this_class, diff --git a/src/share/vm/prims/jvm.cpp b/src/share/vm/prims/jvm.cpp index 7efc2775e5804903445da1188d4156ac8ef2dd83..17caabbee0cb3e9956a77eb1a336e375ee0514bf 100644 --- a/src/share/vm/prims/jvm.cpp +++ b/src/share/vm/prims/jvm.cpp @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "classfile/classLoader.hpp" +#include "classfile/classLoaderData.inline.hpp" #include "classfile/classLoaderExt.hpp" #include "classfile/javaAssertions.hpp" #include "classfile/javaClasses.hpp" @@ -952,6 +953,12 @@ JVM_ENTRY(jclass, JVM_FindClassFromClass(JNIEnv *env, const char *name, Handle h_prot (THREAD, protection_domain); jclass result = find_class_from_class_loader(env, h_name, init, h_loader, 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) { // this function is generally only used for class loading during verification.