8139163: InstanceKlass::cast passes through NULL

Reduce raw (InstanceKlass*) casts and InstanceKlass::cast, which no long allows null

Reviewed-by: twisti, kbarrett
This commit is contained in:
Coleen Phillimore 2015-10-26 13:11:36 -04:00
parent 25cc742a8f
commit 5179fc3488
43 changed files with 215 additions and 252 deletions

View file

@ -88,10 +88,10 @@ const int SystemDictionary::_primelist[_prime_array_size] = {1009,2017,4049,50
oop SystemDictionary::_system_loader_lock_obj = NULL;
Klass* SystemDictionary::_well_known_klasses[SystemDictionary::WKID_LIMIT]
InstanceKlass* SystemDictionary::_well_known_klasses[SystemDictionary::WKID_LIMIT]
= { NULL /*, NULL...*/ };
Klass* SystemDictionary::_box_klasses[T_VOID+1] = { NULL /*, NULL...*/ };
InstanceKlass* SystemDictionary::_box_klasses[T_VOID+1] = { NULL /*, NULL...*/ };
oop SystemDictionary::_java_system_loader = NULL;
@ -99,7 +99,7 @@ bool SystemDictionary::_has_loadClassInternal = false;
bool SystemDictionary::_has_checkPackageAccess = false;
// lazily initialized klass variables
Klass* volatile SystemDictionary::_abstract_ownable_synchronizer_klass = NULL;
InstanceKlass* volatile SystemDictionary::_abstract_ownable_synchronizer_klass = NULL;
// ----------------------------------------------------------------------------
@ -357,7 +357,7 @@ Klass* SystemDictionary::resolve_super_or_fail(Symbol* child_name,
// so we don't throw an exception here.
// see: nsk redefclass014 & java.lang.instrument Instrument032
if ((childk != NULL ) && (is_superclass) &&
((quicksuperk = InstanceKlass::cast(childk)->super()) != NULL) &&
((quicksuperk = childk->super()) != NULL) &&
((quicksuperk->name() == class_name) &&
(quicksuperk->class_loader() == class_loader()))) {
@ -1257,8 +1257,7 @@ instanceKlassHandle SystemDictionary::load_shared_class(instanceKlassHandle ik,
}
// notify a class loaded from shared object
ClassLoadingService::notify_class_loaded(InstanceKlass::cast(ik()),
true /* shared class */);
ClassLoadingService::notify_class_loaded(ik(), true /* shared class */);
}
return ik;
}
@ -1805,7 +1804,7 @@ void SystemDictionary::load_abstract_ownable_synchronizer_klass(TRAPS) {
Klass* k = resolve_or_fail(vmSymbols::java_util_concurrent_locks_AbstractOwnableSynchronizer(), true, CHECK);
// Force a fence to prevent any read before the write completes
OrderAccess::fence();
_abstract_ownable_synchronizer_klass = k;
_abstract_ownable_synchronizer_klass = InstanceKlass::cast(k);
}
}
@ -1846,14 +1845,16 @@ bool SystemDictionary::initialize_wk_klass(WKID id, int init_opt, TRAPS) {
int info = wk_init_info[id - FIRST_WKID];
int sid = (info >> CEIL_LG_OPTION_LIMIT);
Symbol* symbol = vmSymbols::symbol_at((vmSymbols::SID)sid);
Klass** klassp = &_well_known_klasses[id];
InstanceKlass** klassp = &_well_known_klasses[id];
bool must_load = (init_opt < SystemDictionary::Opt);
if ((*klassp) == NULL) {
Klass* k;
if (must_load) {
(*klassp) = resolve_or_fail(symbol, true, CHECK_0); // load required class
k = resolve_or_fail(symbol, true, CHECK_0); // load required class
} else {
(*klassp) = resolve_or_null(symbol, CHECK_0); // load optional klass
k = resolve_or_null(symbol, CHECK_0); // load optional klass
}
(*klassp) = (k == NULL) ? NULL : InstanceKlass::cast(k);
}
return ((*klassp) != NULL);
}