8209087: Clean up runtime code that compares 'this' to NULL
Remove 'this' to NULL comparisons from methods and check if calling objects of these methods could be NULL. Reviewed-by: lfoltan, gziemski
This commit is contained in:
parent
417d396b54
commit
ef3c0a2458
@ -172,7 +172,11 @@ void VerificationType::print_on(outputStream* st) const {
|
||||
} else if (is_uninitialized()) {
|
||||
st->print("uninitialized %d", bci());
|
||||
} else {
|
||||
name()->print_value_on(st);
|
||||
if (name() != NULL) {
|
||||
name()->print_value_on(st);
|
||||
} else {
|
||||
st->print_cr("NULL");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -294,28 +294,20 @@ void Symbol::metaspace_pointers_do(MetaspaceClosure* it) {
|
||||
}
|
||||
|
||||
void Symbol::print_on(outputStream* st) const {
|
||||
if (this == NULL) {
|
||||
st->print_cr("NULL");
|
||||
} else {
|
||||
st->print("Symbol: '");
|
||||
print_symbol_on(st);
|
||||
st->print("'");
|
||||
st->print(" count %d", refcount());
|
||||
}
|
||||
st->print("Symbol: '");
|
||||
print_symbol_on(st);
|
||||
st->print("'");
|
||||
st->print(" count %d", refcount());
|
||||
}
|
||||
|
||||
// The print_value functions are present in all builds, to support the
|
||||
// disassembler and error reporting.
|
||||
void Symbol::print_value_on(outputStream* st) const {
|
||||
if (this == NULL) {
|
||||
st->print("NULL");
|
||||
} else {
|
||||
st->print("'");
|
||||
for (int i = 0; i < utf8_length(); i++) {
|
||||
st->print("%c", char_at(i));
|
||||
}
|
||||
st->print("'");
|
||||
st->print("'");
|
||||
for (int i = 0; i < utf8_length(); i++) {
|
||||
st->print("%c", char_at(i));
|
||||
}
|
||||
st->print("'");
|
||||
}
|
||||
|
||||
bool Symbol::is_valid(Symbol* s) {
|
||||
|
@ -323,7 +323,12 @@ void PerfDataManager::add_item(PerfData* p, bool sampled) {
|
||||
}
|
||||
|
||||
PerfData* PerfDataManager::find_by_name(const char* name) {
|
||||
return _all->find_by_name(name);
|
||||
// if add_item hasn't been called the list won't be initialized
|
||||
if (_all != NULL) {
|
||||
return _all->find_by_name(name);
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
PerfDataList* PerfDataManager::all() {
|
||||
@ -591,10 +596,6 @@ bool PerfDataList::by_name(void* name, PerfData* pd) {
|
||||
|
||||
PerfData* PerfDataList::find_by_name(const char* name) {
|
||||
|
||||
// if add_item hasn't been called the list won't be initialized
|
||||
if (this == NULL)
|
||||
return NULL;
|
||||
|
||||
int i = _set->find((void*)name, PerfDataList::by_name);
|
||||
|
||||
if (i >= 0 && i <= _set->length())
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2018, 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
|
||||
@ -58,7 +58,11 @@ inline int PerfDataManager::constants_count() {
|
||||
}
|
||||
|
||||
inline bool PerfDataManager::exists(const char* name) {
|
||||
return _all->contains(name);
|
||||
if (_all != NULL) {
|
||||
return _all->contains(name);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SHARE_VM_RUNTIME_PERFDATA_INLINE_HPP
|
||||
|
Loading…
x
Reference in New Issue
Block a user