< prev index next >
src/hotspot/share/classfile/systemDictionary.cpp
Print this page
@@ -240,16 +240,27 @@
{
return resolve_or_fail(class_name, Handle(), Handle(), throw_error, THREAD);
}
-// Forwards to resolve_instance_class_or_null
+// 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 if (FieldType::is_obj(class_name)) {
+ } 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,21 +339,22 @@
// 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,
+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.
- Klass* k = SystemDictionaryShared::dump_time_resolve_super_or_fail(child_name,
- class_name, class_loader, protection_domain, is_superclass, CHECK_NULL);
+ 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,44 +382,44 @@
// 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;
+ InstanceKlass* childk = find_class(d_hash, child_name, dictionary);
+ InstanceKlass* quicksuperk;
// to support // loading: if child done loading, just return superclass
- // if class_name, & class_loader don't match:
+ // 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->super()) != NULL) &&
-
- ((quicksuperk->name() == class_name) &&
+ ((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, class_name, THREAD);
+ 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(class_name != NULL, "null super class for resolving");
+ assert(super_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,
+ 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,11 +433,15 @@
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);
+ 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,11 +653,13 @@
// 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,
+//
+// 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,11 +679,11 @@
// 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);
+ 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,11 +722,11 @@
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
+ // 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,11 +893,11 @@
}
#ifdef ASSERT
{
ClassLoaderData* loader_data = k->class_loader_data();
MutexLocker mu(SystemDictionary_lock, THREAD);
- Klass* kk = find_class(name, loader_data);
+ InstanceKlass* kk = find_class(name, loader_data);
assert(kk == k, "should be present in dictionary");
}
#endif
// return if the protection domain in NULL
@@ -1306,14 +1324,14 @@
} else {
assert(s->is_shared(), "must be");
}
}
- Array<Klass*>* interfaces = ik->local_interfaces();
+ Array<InstanceKlass*>* interfaces = ik->local_interfaces();
int num_interfaces = interfaces->length();
for (int index = 0; index < num_interfaces; index++) {
- Klass* k = interfaces->at(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 >