Merge
This commit is contained in:
commit
0033b57269
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2015, 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
|
||||
@ -61,6 +61,10 @@ bool VerificationType::is_reference_assignable_from(
|
||||
Klass* obj = SystemDictionary::resolve_or_fail(
|
||||
name(), Handle(THREAD, klass->class_loader()),
|
||||
Handle(THREAD, klass->protection_domain()), true, CHECK_false);
|
||||
if (TraceClassResolution) {
|
||||
Verifier::trace_class_resolution(obj, klass());
|
||||
}
|
||||
|
||||
KlassHandle this_class(THREAD, obj);
|
||||
|
||||
if (this_class->is_interface() && (!from_field_is_protected ||
|
||||
@ -73,6 +77,9 @@ 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);
|
||||
if (TraceClassResolution) {
|
||||
Verifier::trace_class_resolution(from_class, klass());
|
||||
}
|
||||
return InstanceKlass::cast(from_class)->is_subclass_of(this_class());
|
||||
}
|
||||
} else if (is_array() && from.is_array()) {
|
||||
|
@ -94,6 +94,21 @@ bool Verifier::relax_verify_for(oop loader) {
|
||||
return !need_verify;
|
||||
}
|
||||
|
||||
void Verifier::trace_class_resolution(Klass* resolve_class, InstanceKlass* verify_class) {
|
||||
assert(verify_class != NULL, "Unexpected null verify_class");
|
||||
ResourceMark rm;
|
||||
Symbol* s = verify_class->source_file_name();
|
||||
const char* source_file = (s != NULL ? s->as_C_string() : NULL);
|
||||
const char* verify = verify_class->external_name();
|
||||
const char* resolve = resolve_class->external_name();
|
||||
// print in a single call to reduce interleaving between threads
|
||||
if (source_file != NULL) {
|
||||
tty->print("RESOLVE %s %s %s (verification)\n", verify, resolve, source_file);
|
||||
} else {
|
||||
tty->print("RESOLVE %s %s (verification)\n", verify, resolve);
|
||||
}
|
||||
}
|
||||
|
||||
bool Verifier::verify(instanceKlassHandle klass, Verifier::Mode mode, bool should_verify_class, TRAPS) {
|
||||
HandleMark hm;
|
||||
ResourceMark rm(THREAD);
|
||||
@ -172,6 +187,10 @@ bool Verifier::verify(instanceKlassHandle klass, Verifier::Mode mode, bool shoul
|
||||
ResourceMark rm(THREAD);
|
||||
instanceKlassHandle kls =
|
||||
SystemDictionary::resolve_or_fail(exception_name, true, CHECK_false);
|
||||
if (TraceClassResolution) {
|
||||
Verifier::trace_class_resolution(kls(), klass());
|
||||
}
|
||||
|
||||
while (!kls.is_null()) {
|
||||
if (kls == klass) {
|
||||
// If the class being verified is the exception we're creating
|
||||
@ -1947,9 +1966,15 @@ 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, THREAD);
|
||||
|
||||
if (TraceClassResolution) {
|
||||
instanceKlassHandle cur_class = current_class();
|
||||
Verifier::trace_class_resolution(kls, cur_class());
|
||||
}
|
||||
return kls;
|
||||
}
|
||||
|
||||
bool ClassVerifier::is_protected_access(instanceKlassHandle this_class,
|
||||
|
@ -60,6 +60,9 @@ class Verifier : AllStatic {
|
||||
// Relax certain verifier checks to enable some broken 1.1 apps to run on 1.2.
|
||||
static bool relax_verify_for(oop class_loader);
|
||||
|
||||
// Print output for -XX:+TraceClassResolution
|
||||
static void trace_class_resolution(Klass* resolve_class, InstanceKlass* verify_class);
|
||||
|
||||
private:
|
||||
static bool is_eligible_for_verification(instanceKlassHandle klass, bool should_verify_class);
|
||||
static Symbol* inference_verify(
|
||||
|
44
hotspot/test/runtime/verifier/TraceClassRes.java
Normal file
44
hotspot/test/runtime/verifier/TraceClassRes.java
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2015 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8076318
|
||||
* @summary split verifier needs to add TraceClassResolution
|
||||
* @library /testlibrary
|
||||
*/
|
||||
|
||||
import jdk.test.lib.*;
|
||||
|
||||
// Test that the verifier outputs the classes it loads if -XX:+TraceClassResolution is specified"
|
||||
public class TraceClassRes {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
|
||||
"-XX:+TraceClassResolution", "-verify", "-Xshare:off", "-version");
|
||||
|
||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||
output.shouldContain("RESOLVE java.lang.ClassLoader java.lang.Throwable ClassLoader.java (verification)");
|
||||
output.shouldHaveExitValue(0);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user