< prev index next >
src/hotspot/share/classfile/systemDictionary.cpp
Print this page
*** 240,255 ****
{
return resolve_or_fail(class_name, Handle(), Handle(), throw_error, THREAD);
}
! // Forwards to resolve_instance_class_or_null
Klass* SystemDictionary::resolve_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS) {
if (FieldType::is_array(class_name)) {
return resolve_array_class_or_null(class_name, class_loader, protection_domain, THREAD);
! } else if (FieldType::is_obj(class_name)) {
ResourceMark rm(THREAD);
// Ignore wrapping L and ;.
TempNewSymbol name = SymbolTable::new_symbol(class_name->as_C_string() + 1,
class_name->utf8_length() - 2, CHECK_NULL);
return resolve_instance_class_or_null(name, class_loader, protection_domain, THREAD);
--- 240,266 ----
{
return resolve_or_fail(class_name, Handle(), Handle(), throw_error, THREAD);
}
! // Forwards to resolve_array_class_or_null or resolve_instance_class_or_null
Klass* SystemDictionary::resolve_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS) {
if (FieldType::is_array(class_name)) {
return resolve_array_class_or_null(class_name, class_loader, protection_domain, THREAD);
! } else {
! return resolve_instance_class_or_null_helper(class_name, class_loader, protection_domain, THREAD);
! }
! }
!
! // name may be in the form of "java/lang/Object" or "Ljava/lang/Object;"
! InstanceKlass* SystemDictionary::resolve_instance_class_or_null_helper(Symbol* class_name,
! Handle class_loader,
! Handle protection_domain,
! TRAPS) {
! assert(class_name != NULL && !FieldType::is_array(class_name), "must be");
! if (FieldType::is_obj(class_name)) {
ResourceMark rm(THREAD);
// Ignore wrapping L and ;.
TempNewSymbol name = SymbolTable::new_symbol(class_name->as_C_string() + 1,
class_name->utf8_length() - 2, CHECK_NULL);
return resolve_instance_class_or_null(name, class_loader, protection_domain, THREAD);
*** 328,348 ****
// thread is loading this class/classloader.
// Be careful when modifying this code: once you have run
// placeholders()->find_and_add(PlaceholderTable::LOAD_SUPER),
// you need to find_and_remove it before returning.
// So be careful to not exit with a CHECK_ macro betweeen these calls.
! Klass* SystemDictionary::resolve_super_or_fail(Symbol* child_name,
! Symbol* class_name,
Handle class_loader,
Handle protection_domain,
bool is_superclass,
TRAPS) {
#if INCLUDE_CDS
if (DumpSharedSpaces) {
// Special processing for CDS dump time.
! Klass* k = SystemDictionaryShared::dump_time_resolve_super_or_fail(child_name,
! class_name, class_loader, protection_domain, is_superclass, CHECK_NULL);
if (k) {
return k;
}
}
#endif // INCLUDE_CDS
--- 339,360 ----
// thread is loading this class/classloader.
// Be careful when modifying this code: once you have run
// placeholders()->find_and_add(PlaceholderTable::LOAD_SUPER),
// you need to find_and_remove it before returning.
// So be careful to not exit with a CHECK_ macro betweeen these calls.
! InstanceKlass* SystemDictionary::resolve_super_or_fail(Symbol* child_name,
! Symbol* super_name,
Handle class_loader,
Handle protection_domain,
bool is_superclass,
TRAPS) {
+ assert(!FieldType::is_array(super_name), "invalid super class name");
#if INCLUDE_CDS
if (DumpSharedSpaces) {
// Special processing for CDS dump time.
! InstanceKlass* k = SystemDictionaryShared::dump_time_resolve_super_or_fail(child_name,
! super_name, class_loader, protection_domain, is_superclass, CHECK_NULL);
if (k) {
return k;
}
}
#endif // INCLUDE_CDS
*** 370,413 ****
// can't throw error holding a lock
bool child_already_loaded = false;
bool throw_circularity_error = false;
{
MutexLocker mu(SystemDictionary_lock, THREAD);
! Klass* childk = find_class(d_hash, child_name, dictionary);
! Klass* quicksuperk;
// to support // loading: if child done loading, just return superclass
! // if class_name, & class_loader don't match:
// if initial define, SD update will give LinkageError
// if redefine: compare_class_versions will give HIERARCHY_CHANGED
// so we don't throw an exception here.
// see: nsk redefclass014 & java.lang.instrument Instrument032
if ((childk != NULL ) && (is_superclass) &&
! ((quicksuperk = childk->super()) != NULL) &&
!
! ((quicksuperk->name() == class_name) &&
(oopDesc::equals(quicksuperk->class_loader(), class_loader())))) {
return quicksuperk;
} else {
PlaceholderEntry* probe = placeholders()->get_entry(p_index, p_hash, child_name, loader_data);
if (probe && probe->check_seen_thread(THREAD, PlaceholderTable::LOAD_SUPER)) {
throw_circularity_error = true;
}
}
if (!throw_circularity_error) {
// Be careful not to exit resolve_super
! PlaceholderEntry* newprobe = placeholders()->find_and_add(p_index, p_hash, child_name, loader_data, PlaceholderTable::LOAD_SUPER, class_name, THREAD);
}
}
if (throw_circularity_error) {
ResourceMark rm(THREAD);
THROW_MSG_NULL(vmSymbols::java_lang_ClassCircularityError(), child_name->as_C_string());
}
// java.lang.Object should have been found above
! assert(class_name != NULL, "null super class for resolving");
// Resolve the super class or interface, check results on return
! Klass* superk = SystemDictionary::resolve_or_null(class_name,
class_loader,
protection_domain,
THREAD);
// Clean up of placeholders moved so that each classloadAction registrar self-cleans up
--- 382,425 ----
// can't throw error holding a lock
bool child_already_loaded = false;
bool throw_circularity_error = false;
{
MutexLocker mu(SystemDictionary_lock, THREAD);
! InstanceKlass* childk = find_class(d_hash, child_name, dictionary);
! InstanceKlass* quicksuperk;
// to support // loading: if child done loading, just return superclass
! // if super_name, & class_loader don't match:
// if initial define, SD update will give LinkageError
// if redefine: compare_class_versions will give HIERARCHY_CHANGED
// so we don't throw an exception here.
// see: nsk redefclass014 & java.lang.instrument Instrument032
if ((childk != NULL ) && (is_superclass) &&
! ((quicksuperk = childk->java_super()) != NULL) &&
! ((quicksuperk->name() == super_name) &&
(oopDesc::equals(quicksuperk->class_loader(), class_loader())))) {
return quicksuperk;
} else {
PlaceholderEntry* probe = placeholders()->get_entry(p_index, p_hash, child_name, loader_data);
if (probe && probe->check_seen_thread(THREAD, PlaceholderTable::LOAD_SUPER)) {
throw_circularity_error = true;
}
}
if (!throw_circularity_error) {
// Be careful not to exit resolve_super
! PlaceholderEntry* newprobe = placeholders()->find_and_add(p_index, p_hash, child_name, loader_data, PlaceholderTable::LOAD_SUPER, super_name, THREAD);
}
}
if (throw_circularity_error) {
ResourceMark rm(THREAD);
THROW_MSG_NULL(vmSymbols::java_lang_ClassCircularityError(), child_name->as_C_string());
}
// java.lang.Object should have been found above
! assert(super_name != NULL, "null super class for resolving");
// Resolve the super class or interface, check results on return
! InstanceKlass* superk =
! SystemDictionary::resolve_instance_class_or_null_helper(super_name,
class_loader,
protection_domain,
THREAD);
// Clean up of placeholders moved so that each classloadAction registrar self-cleans up
*** 421,431 ****
placeholders()->find_and_remove(p_index, p_hash, child_name, loader_data, PlaceholderTable::LOAD_SUPER, THREAD);
SystemDictionary_lock->notify_all();
}
if (HAS_PENDING_EXCEPTION || superk == NULL) {
// can null superk
! superk = handle_resolution_exception(class_name, true, superk, THREAD);
}
return superk;
}
--- 433,447 ----
placeholders()->find_and_remove(p_index, p_hash, child_name, loader_data, PlaceholderTable::LOAD_SUPER, THREAD);
SystemDictionary_lock->notify_all();
}
if (HAS_PENDING_EXCEPTION || superk == NULL) {
// can null superk
! Klass* k = handle_resolution_exception(super_name, true, superk, THREAD);
! assert(k == NULL || k == superk, "must be");
! if (k == NULL) {
! superk = NULL;
! }
}
return superk;
}
*** 637,647 ****
// Be careful when modifying this code: once you have run
// placeholders()->find_and_add(PlaceholderTable::LOAD_INSTANCE),
// you need to find_and_remove it before returning.
// So be careful to not exit with a CHECK_ macro betweeen these calls.
! Klass* SystemDictionary::resolve_instance_class_or_null(Symbol* name,
Handle class_loader,
Handle protection_domain,
TRAPS) {
assert(name != NULL && !FieldType::is_array(name) &&
!FieldType::is_obj(name), "invalid class name");
--- 653,665 ----
// Be careful when modifying this code: once you have run
// placeholders()->find_and_add(PlaceholderTable::LOAD_INSTANCE),
// you need to find_and_remove it before returning.
// So be careful to not exit with a CHECK_ macro betweeen these calls.
! //
! // name must be in the form of "java/lang/Object" -- cannot be "Ljava/lang/Object;"
! InstanceKlass* SystemDictionary::resolve_instance_class_or_null(Symbol* name,
Handle class_loader,
Handle protection_domain,
TRAPS) {
assert(name != NULL && !FieldType::is_array(name) &&
!FieldType::is_obj(name), "invalid class name");
*** 661,671 ****
// This call uses find which checks protection domain already matches
// All subsequent calls use find_class, and set has_loaded_class so that
// before we return a result we call out to java to check for valid protection domain
// to allow returning the Klass* and add it to the pd_set if it is valid
{
! Klass* probe = dictionary->find(d_hash, name, protection_domain);
if (probe != NULL) return probe;
}
// Non-bootstrap class loaders will call out to class loader and
// define via jvm/jni_DefineClass which will acquire the
--- 679,689 ----
// This call uses find which checks protection domain already matches
// All subsequent calls use find_class, and set has_loaded_class so that
// before we return a result we call out to java to check for valid protection domain
// to allow returning the Klass* and add it to the pd_set if it is valid
{
! InstanceKlass* probe = dictionary->find(d_hash, name, protection_domain);
if (probe != NULL) return probe;
}
// Non-bootstrap class loaders will call out to class loader and
// define via jvm/jni_DefineClass which will acquire the
*** 704,714 ****
class_loader.is_null() ? "null" : class_loader->klass()->name()->as_C_string());
{
MutexLocker mu(SystemDictionary_lock, THREAD);
InstanceKlass* check = find_class(d_hash, name, dictionary);
if (check != NULL) {
! // Klass is already loaded, so just return it
class_has_been_loaded = true;
k = check;
} else {
placeholder = placeholders()->get_entry(p_index, p_hash, name, loader_data);
if (placeholder && placeholder->super_load_in_progress()) {
--- 722,732 ----
class_loader.is_null() ? "null" : class_loader->klass()->name()->as_C_string());
{
MutexLocker mu(SystemDictionary_lock, THREAD);
InstanceKlass* check = find_class(d_hash, name, dictionary);
if (check != NULL) {
! // InstanceKlass is already loaded, so just return it
class_has_been_loaded = true;
k = check;
} else {
placeholder = placeholders()->get_entry(p_index, p_hash, name, loader_data);
if (placeholder && placeholder->super_load_in_progress()) {
*** 875,885 ****
}
#ifdef ASSERT
{
ClassLoaderData* loader_data = k->class_loader_data();
MutexLocker mu(SystemDictionary_lock, THREAD);
! Klass* kk = find_class(name, loader_data);
assert(kk == k, "should be present in dictionary");
}
#endif
// return if the protection domain in NULL
--- 893,903 ----
}
#ifdef ASSERT
{
ClassLoaderData* loader_data = k->class_loader_data();
MutexLocker mu(SystemDictionary_lock, THREAD);
! InstanceKlass* kk = find_class(name, loader_data);
assert(kk == k, "should be present in dictionary");
}
#endif
// return if the protection domain in NULL
*** 1306,1319 ****
} else {
assert(s->is_shared(), "must be");
}
}
! Array<Klass*>* interfaces = ik->local_interfaces();
int num_interfaces = interfaces->length();
for (int index = 0; index < num_interfaces; index++) {
! Klass* k = interfaces->at(index);
Symbol* name = k->name();
Klass* i = resolve_super_or_fail(class_name, name, class_loader, protection_domain, false, CHECK_NULL);
if (k != i) {
// The dynamically resolved interface class is not the same as the one we used during dump time,
// so we cannot use ik.
--- 1324,1337 ----
} else {
assert(s->is_shared(), "must be");
}
}
! Array<InstanceKlass*>* interfaces = ik->local_interfaces();
int num_interfaces = interfaces->length();
for (int index = 0; index < num_interfaces; index++) {
! InstanceKlass* k = interfaces->at(index);
Symbol* name = k->name();
Klass* i = resolve_super_or_fail(class_name, name, class_loader, protection_domain, false, CHECK_NULL);
if (k != i) {
// The dynamically resolved interface class is not the same as the one we used during dump time,
// so we cannot use ik.
< prev index next >