Skip to content
Permalink
Browse files
Automatic merge of jdk:master into master
  • Loading branch information
duke committed Mar 24, 2021
2 parents b89c68c + bc91596 commit d090adb13e51cad2a2e428592f826d6d892e99ca
Showing 16 changed files with 35 additions and 52 deletions.
@@ -5422,7 +5422,7 @@ void ClassFileParser::fill_instance_klass(InstanceKlass* ik,

// can only set dynamic nest-host after static nest information is set
if (cl_inst_info.dynamic_nest_host() != NULL) {
ik->set_nest_host(cl_inst_info.dynamic_nest_host(), THREAD);
ik->set_nest_host(cl_inst_info.dynamic_nest_host());
}

// note that is not safe to use the fields in the parser from this point on
@@ -1027,7 +1027,7 @@ void java_lang_Class::create_mirror(Klass* k, Handle class_loader,
// to support Class.getModifiers(). Instance classes recalculate
// the cached flags after the class file is parsed, but before the
// class is put into the system dictionary.
int computed_modifiers = k->compute_modifier_flags(CHECK);
int computed_modifiers = k->compute_modifier_flags();
k->set_modifier_flags(computed_modifiers);
// Class_klass has to be loaded because it is used to allocate
// the mirror.
@@ -1209,7 +1209,7 @@ InstanceKlass* SystemDictionary::load_shared_lambda_proxy_class(InstanceKlass* i
// as verified in SystemDictionaryShared::add_lambda_proxy_class()
assert(shared_nest_host->class_loader() == class_loader(), "mismatched class loader");
assert(shared_nest_host->class_loader_data() == ClassLoaderData::class_loader_data(class_loader()), "mismatched class loader data");
ik->set_nest_host(shared_nest_host, THREAD);
ik->set_nest_host(shared_nest_host);

InstanceKlass* loaded_ik = load_shared_class(ik, class_loader, protection_domain, NULL, pkg_entry, CHECK_NULL);

@@ -382,7 +382,7 @@ Method* LinkResolver::lookup_method_in_klasses(const LinkInfo& link_info,
Method* LinkResolver::lookup_instance_method_in_klasses(Klass* klass,
Symbol* name,
Symbol* signature,
Klass::PrivateLookupMode private_mode, TRAPS) {
Klass::PrivateLookupMode private_mode) {
Method* result = klass->uncached_lookup_method(name, signature, Klass::OverpassLookupMode::find, private_mode);

while (result != NULL && result->is_static() && result->method_holder()->super() != NULL) {
@@ -543,13 +543,13 @@ Method* LinkResolver::lookup_polymorphic_method(const LinkInfo& link_info,
return NULL;
}

static void print_nest_host_error_on(stringStream* ss, Klass* ref_klass, Klass* sel_klass, TRAPS) {
static void print_nest_host_error_on(stringStream* ss, Klass* ref_klass, Klass* sel_klass) {
assert(ref_klass->is_instance_klass(), "must be");
assert(sel_klass->is_instance_klass(), "must be");
InstanceKlass* ref_ik = InstanceKlass::cast(ref_klass);
InstanceKlass* sel_ik = InstanceKlass::cast(sel_klass);
const char* nest_host_error_1 = ref_ik->nest_host_error(THREAD);
const char* nest_host_error_2 = sel_ik->nest_host_error(THREAD);
const char* nest_host_error_1 = ref_ik->nest_host_error();
const char* nest_host_error_2 = sel_ik->nest_host_error();
if (nest_host_error_1 != NULL || nest_host_error_2 != NULL) {
ss->print(", (%s%s%s)",
(nest_host_error_1 != NULL) ? nest_host_error_1 : "",
@@ -610,7 +610,7 @@ void LinkResolver::check_method_accessability(Klass* ref_klass,
// For private access see if there was a problem with nest host
// resolution, and if so report that as part of the message.
if (sel_method->is_private()) {
print_nest_host_error_on(&ss, ref_klass, sel_klass, THREAD);
print_nest_host_error_on(&ss, ref_klass, sel_klass);
}

Exceptions::fthrow(THREAD_AND_LOCATION,
@@ -955,7 +955,7 @@ void LinkResolver::check_field_accessability(Klass* ref_klass,
// For private access see if there was a problem with nest host
// resolution, and if so report that as part of the message.
if (fd.is_private()) {
print_nest_host_error_on(&ss, ref_klass, sel_klass, THREAD);
print_nest_host_error_on(&ss, ref_klass, sel_klass);
}
Exceptions::fthrow(THREAD_AND_LOCATION,
vmSymbols::java_lang_IllegalAccessError(),
@@ -1247,7 +1247,7 @@ void LinkResolver::runtime_resolve_special_method(CallInfo& result,
Method* instance_method = lookup_instance_method_in_klasses(super_klass,
resolved_method->name(),
resolved_method->signature(),
Klass::PrivateLookupMode::find, CHECK);
Klass::PrivateLookupMode::find);
sel_method = methodHandle(THREAD, instance_method);

// check if found
@@ -1489,7 +1489,7 @@ void LinkResolver::runtime_resolve_interface_method(CallInfo& result,
Method* method = lookup_instance_method_in_klasses(recv_klass,
resolved_method->name(),
resolved_method->signature(),
Klass::PrivateLookupMode::skip, CHECK);
Klass::PrivateLookupMode::skip);
selected_method = methodHandle(THREAD, method);

if (selected_method.is_null() && !check_null_and_abstract) {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2021, 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
@@ -211,7 +211,7 @@ class LinkResolver: AllStatic {
JVMCI_ONLY(public:) // Needed for CompilerToVM.resolveMethod()
// Not Linktime so doesn't take LinkInfo
static Method* lookup_instance_method_in_klasses (Klass* klass, Symbol* name, Symbol* signature,
Klass::PrivateLookupMode private_mode, TRAPS);
Klass::PrivateLookupMode private_mode);
JVMCI_ONLY(private:)

// Similar loader constraint checking functions that throw
@@ -153,9 +153,7 @@ void ArrayKlass::array_klasses_do(void f(Klass* k)) {
}
}

// JVM support

jint ArrayKlass::compute_modifier_flags(TRAPS) const {
jint ArrayKlass::compute_modifier_flags() const {
return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC;
}

@@ -113,7 +113,7 @@ class ArrayKlass: public Klass {


// jvm support
jint compute_modifier_flags(TRAPS) const;
jint compute_modifier_flags() const;

// JVMTI support
jint jvmti_class_status() const;
@@ -389,19 +389,19 @@ InstanceKlass* InstanceKlass::nest_host(TRAPS) {
// If it has an explicit _nest_host_index or _nest_members, these will be ignored.
// We also know the "host" is a valid nest-host in the same package so we can
// assert some of those facts.
void InstanceKlass::set_nest_host(InstanceKlass* host, TRAPS) {
void InstanceKlass::set_nest_host(InstanceKlass* host) {
assert(is_hidden(), "must be a hidden class");
assert(host != NULL, "NULL nest host specified");
assert(_nest_host == NULL, "current class has resolved nest-host");
assert(nest_host_error(THREAD) == NULL, "unexpected nest host resolution error exists: %s",
nest_host_error(THREAD));
assert(nest_host_error() == NULL, "unexpected nest host resolution error exists: %s",
nest_host_error());
assert((host->_nest_host == NULL && host->_nest_host_index == 0) ||
(host->_nest_host == host), "proposed host is not a valid nest-host");
// Can't assert this as package is not set yet:
// assert(is_same_class_package(host), "proposed host is in wrong package");

if (log_is_enabled(Trace, class, nestmates)) {
ResourceMark rm(THREAD);
ResourceMark rm;
const char* msg = "";
// a hidden class does not expect a statically defined nest-host
if (_nest_host_index > 0) {
@@ -452,11 +452,11 @@ bool InstanceKlass::has_nestmate_access_to(InstanceKlass* k, TRAPS) {
return access;
}

const char* InstanceKlass::nest_host_error(TRAPS) {
const char* InstanceKlass::nest_host_error() {
if (_nest_host_index == 0) {
return NULL;
} else {
constantPoolHandle cph(THREAD, constants());
constantPoolHandle cph(Thread::current(), constants());
return SystemDictionary::find_nest_host_error(cph, (int)_nest_host_index);
}
}
@@ -3109,7 +3109,7 @@ InstanceKlass* InstanceKlass::compute_enclosing_class(bool* inner_is_member, TRA
return outer_klass;
}

jint InstanceKlass::compute_modifier_flags(TRAPS) const {
jint InstanceKlass::compute_modifier_flags() const {
jint access = access_flags().as_int();

// But check if it happens to be member class.
@@ -465,7 +465,7 @@ class InstanceKlass: public Klass {
jushort nest_host_index() const { return _nest_host_index; }
void set_nest_host_index(u2 i) { _nest_host_index = i; }
// dynamic nest member support
void set_nest_host(InstanceKlass* host, TRAPS);
void set_nest_host(InstanceKlass* host);

// record components
Array<RecordComponent*>* record_components() const { return _record_components; }
@@ -486,7 +486,7 @@ class InstanceKlass: public Klass {
// Used to construct informative IllegalAccessError messages at a higher level,
// if there was an issue resolving or validating the nest host.
// Returns NULL if there was no error.
const char* nest_host_error(TRAPS);
const char* nest_host_error();
// Returns nest-host class, resolving and validating it if needed.
// Returns NULL if resolution is not possible from the calling context.
InstanceKlass* nest_host(TRAPS);
@@ -1267,8 +1267,7 @@ class InstanceKlass: public Klass {
void restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, PackageEntry* pkg_entry, TRAPS);
void init_shared_package_entry();

// jvm support
jint compute_modifier_flags(TRAPS) const;
jint compute_modifier_flags() const;

public:
// JVMTI support
@@ -751,11 +751,6 @@ const char* Klass::external_kind() const {
return "class";
}

// Unless overridden, modifier_flags is 0.
jint Klass::compute_modifier_flags(TRAPS) const {
return 0;
}

int Klass::atomic_incr_biased_lock_revocation_count() {
return (int) Atomic::add(&_biased_lock_revocation_count, 1);
}
@@ -690,8 +690,7 @@ class Klass : public Metadata {
virtual void release_C_heap_structures();

public:
// jvm support
virtual jint compute_modifier_flags(TRAPS) const;
virtual jint compute_modifier_flags() const = 0;

// JVMTI support
virtual jint jvmti_class_status() const;
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2021, 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
@@ -1245,7 +1245,7 @@ void klassItable::initialize_itable_for_interface(int method_table_offset, Insta
// Invokespecial does not perform selection based on the receiver, so it does not use
// the cached itable.
target = LinkResolver::lookup_instance_method_in_klasses(_klass, m->name(), m->signature(),
Klass::PrivateLookupMode::skip, CHECK);
Klass::PrivateLookupMode::skip);
}
if (target == NULL || !target->is_public() || target->is_abstract() || target->is_overpass()) {
assert(target == NULL || !target->is_overpass() || target->is_public(),
@@ -396,16 +396,14 @@ void ObjArrayKlass::metaspace_pointers_do(MetaspaceClosure* it) {
it->push(&_bottom_klass);
}

// JVM support

jint ObjArrayKlass::compute_modifier_flags(TRAPS) const {
jint ObjArrayKlass::compute_modifier_flags() const {
// The modifier for an objectArray is the same as its element
if (element_klass() == NULL) {
assert(Universe::is_bootstrapping(), "partial objArray only at startup");
return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC;
}
// Return the flags of the bottom element type.
jint element_flags = bottom_klass()->compute_modifier_flags(CHECK_0);
jint element_flags = bottom_klass()->compute_modifier_flags();

return (element_flags & (JVM_ACC_PUBLIC | JVM_ACC_PRIVATE | JVM_ACC_PROTECTED))
| (JVM_ACC_ABSTRACT | JVM_ACC_FINAL);
@@ -154,8 +154,7 @@ class ObjArrayKlass : public ArrayKlass {
inline void oop_oop_iterate_elements_bounded(objArrayOop a, OopClosureType* closure, MemRegion mr);

public:
// JVM support
jint compute_modifier_flags(TRAPS) const;
jint compute_modifier_flags() const;

public:
// Printing
@@ -1350,7 +1350,7 @@ JVM_ENTRY(jint, JVM_GetClassModifiers(JNIEnv *env, jclass cls))
}

Klass* k = java_lang_Class::as_Klass(mirror);
debug_only(int computed_modifiers = k->compute_modifier_flags(CHECK_0));
debug_only(int computed_modifiers = k->compute_modifier_flags());
assert(k->modifier_flags() == computed_modifiers, "modifiers cache is OK");
return k->modifier_flags();
JVM_END
@@ -2366,15 +2366,10 @@ JvmtiEnv::GetClassModifiers(oop k_mirror, jint* modifiers_ptr) {
if (!java_lang_Class::is_primitive(k_mirror)) {
Klass* k = java_lang_Class::as_Klass(k_mirror);
NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS);
result = k->compute_modifier_flags(current_thread);
JavaThread* THREAD = current_thread; // pass to macros
if (HAS_PENDING_EXCEPTION) {
CLEAR_PENDING_EXCEPTION;
return JVMTI_ERROR_INTERNAL;
};
result = k->compute_modifier_flags();

// Reset the deleted ACC_SUPER bit ( deleted in compute_modifier_flags()).
if(k->is_super()) {
// Reset the deleted ACC_SUPER bit (deleted in compute_modifier_flags()).
if (k->is_super()) {
result |= JVM_ACC_SUPER;
}
} else {

0 comments on commit d090adb

Please sign in to comment.