8299326: LinkResolver::resolve_field resolved_klass cannot be null
Reviewed-by: iklam, fparain
This commit is contained in:
parent
e3035bad60
commit
ccbcea830d
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1997, 2023, 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
|
||||||
@ -814,7 +814,7 @@ static void trace_method_resolution(const char* prefix,
|
|||||||
st->print("%s%s, compile-time-class:%s, method:%s, method_holder:%s, access_flags: ",
|
st->print("%s%s, compile-time-class:%s, method:%s, method_holder:%s, access_flags: ",
|
||||||
prefix,
|
prefix,
|
||||||
(klass == NULL ? "<NULL>" : klass->internal_name()),
|
(klass == NULL ? "<NULL>" : klass->internal_name()),
|
||||||
(resolved_klass == NULL ? "<NULL>" : resolved_klass->internal_name()),
|
resolved_klass->internal_name(),
|
||||||
Method::name_and_sig_as_C_string(resolved_klass,
|
Method::name_and_sig_as_C_string(resolved_klass,
|
||||||
method->name(),
|
method->name(),
|
||||||
method->signature()),
|
method->signature()),
|
||||||
@ -970,11 +970,6 @@ void LinkResolver::resolve_field(fieldDescriptor& fd,
|
|||||||
Symbol* field = link_info.name();
|
Symbol* field = link_info.name();
|
||||||
Symbol* sig = link_info.signature();
|
Symbol* sig = link_info.signature();
|
||||||
|
|
||||||
if (resolved_klass == NULL) {
|
|
||||||
ResourceMark rm(THREAD);
|
|
||||||
THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resolve instance field
|
// Resolve instance field
|
||||||
Klass* sel_klass = resolved_klass->find_field(field, sig, &fd);
|
Klass* sel_klass = resolved_klass->find_field(field, sig, &fd);
|
||||||
// check if field exists; i.e., if a klass containing the field def has been selected
|
// check if field exists; i.e., if a klass containing the field def has been selected
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1997, 2023, 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
|
||||||
@ -155,25 +155,28 @@ class LinkInfo : public StackObj {
|
|||||||
LoaderConstraintCheck check_loader_constraints = LoaderConstraintCheck::required,
|
LoaderConstraintCheck check_loader_constraints = LoaderConstraintCheck::required,
|
||||||
constantTag tag = JVM_CONSTANT_Invalid) :
|
constantTag tag = JVM_CONSTANT_Invalid) :
|
||||||
_name(name),
|
_name(name),
|
||||||
_signature(signature), _resolved_klass(resolved_klass), _current_klass(current_klass), _current_method(methodHandle()),
|
_signature(signature),
|
||||||
|
_resolved_klass(resolved_klass),
|
||||||
|
_current_klass(current_klass),
|
||||||
|
_current_method(methodHandle()),
|
||||||
_check_access(check_access == AccessCheck::required),
|
_check_access(check_access == AccessCheck::required),
|
||||||
_check_loader_constraints(check_loader_constraints == LoaderConstraintCheck::required), _tag(tag) {}
|
_check_loader_constraints(check_loader_constraints == LoaderConstraintCheck::required),
|
||||||
|
_tag(tag) {
|
||||||
|
assert(_resolved_klass != nullptr, "must always have a resolved_klass");
|
||||||
|
}
|
||||||
|
|
||||||
LinkInfo(Klass* resolved_klass, Symbol* name, Symbol* signature, const methodHandle& current_method,
|
LinkInfo(Klass* resolved_klass, Symbol* name, Symbol* signature, const methodHandle& current_method,
|
||||||
AccessCheck check_access = AccessCheck::required,
|
AccessCheck check_access = AccessCheck::required,
|
||||||
LoaderConstraintCheck check_loader_constraints = LoaderConstraintCheck::required,
|
LoaderConstraintCheck check_loader_constraints = LoaderConstraintCheck::required,
|
||||||
constantTag tag = JVM_CONSTANT_Invalid) :
|
constantTag tag = JVM_CONSTANT_Invalid) :
|
||||||
_name(name),
|
LinkInfo(resolved_klass, name, signature, current_method->method_holder(), check_access, check_loader_constraints, tag) {
|
||||||
_signature(signature), _resolved_klass(resolved_klass), _current_klass(current_method->method_holder()), _current_method(current_method),
|
_current_method = current_method;
|
||||||
_check_access(check_access == AccessCheck::required),
|
}
|
||||||
_check_loader_constraints(check_loader_constraints == LoaderConstraintCheck::required), _tag(tag) {}
|
|
||||||
|
|
||||||
|
// Case where we just find the method and don't check access against the current class, used by JavaCalls
|
||||||
// Case where we just find the method and don't check access against the current class
|
|
||||||
LinkInfo(Klass* resolved_klass, Symbol*name, Symbol* signature) :
|
LinkInfo(Klass* resolved_klass, Symbol*name, Symbol* signature) :
|
||||||
_name(name),
|
LinkInfo(resolved_klass, name, signature, nullptr, AccessCheck::skip, LoaderConstraintCheck::skip,
|
||||||
_signature(signature), _resolved_klass(resolved_klass), _current_klass(NULL), _current_method(methodHandle()),
|
JVM_CONSTANT_Invalid) {}
|
||||||
_check_access(false), _check_loader_constraints(false), _tag(JVM_CONSTANT_Invalid) {}
|
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
Symbol* name() const { return _name; }
|
Symbol* name() const { return _name; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user