8299973: Replace NULL with nullptr in share/utilities/

Reviewed-by: coleenp, stefank, dholmes, kbarrett
This commit is contained in:
Johan Sjölen 2023-01-19 13:42:08 +00:00
parent dea58efb62
commit 1084fd24eb
53 changed files with 563 additions and 563 deletions

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023, 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
@ -42,7 +42,7 @@ static bm_word_t* pseudo_reallocate(const BitMapWithAllocator& derived, bm_word_
assert(new_size_in_words > 0, "precondition");
bm_word_t* map = derived.allocate(new_size_in_words);
if (old_map != NULL) {
if (old_map != nullptr) {
Copy::disjoint_words((HeapWord*)old_map, (HeapWord*) map,
MIN2(old_size_in_words, new_size_in_words));
}
@ -54,7 +54,7 @@ static bm_word_t* pseudo_reallocate(const BitMapWithAllocator& derived, bm_word_
template <class BitMapWithAllocator>
void GrowableBitMap<BitMapWithAllocator>::initialize(idx_t size_in_bits, bool clear) {
assert(map() == NULL, "precondition");
assert(map() == nullptr, "precondition");
assert(size() == 0, "precondition");
resize(size_in_bits, clear);
@ -80,7 +80,7 @@ void GrowableBitMap<BitMapWithAllocator>::resize(idx_t new_size_in_bits, bool cl
if (new_size_in_words == 0) {
derived->free(old_map, old_size_in_words);
update(NULL, 0);
update(nullptr, 0);
return;
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2023, 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
@ -44,7 +44,7 @@ template <class T, MEMFLAGS F> class ChunkedList : public CHeapObj<F> {
}
public:
ChunkedList<T, F>() : _top(_values), _next_used(NULL), _next_free(NULL) {}
ChunkedList<T, F>() : _top(_values), _next_used(nullptr), _next_free(nullptr) {}
bool is_full() const {
return _top == end();

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, 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
@ -67,7 +67,7 @@ class ConcurrentHashTable : public CHeapObj<F> {
Node * volatile _next;
VALUE _value;
public:
Node(const VALUE& value, Node* next = NULL)
Node(const VALUE& value, Node* next = nullptr)
: _next(next), _value(value) {
assert((((uintptr_t)this) & ((uintptr_t)0x3)) == 0,
"Must 16 bit aligned.");
@ -80,7 +80,7 @@ class ConcurrentHashTable : public CHeapObj<F> {
VALUE* value() { return &_value; }
// Creates a node.
static Node* create_node(void* context, const VALUE& value, Node* next = NULL) {
static Node* create_node(void* context, const VALUE& value, Node* next = nullptr) {
return new (CONFIG::allocate_node(context, sizeof(Node), value)) Node(value, next);
}
// Destroys a node.
@ -138,7 +138,7 @@ class ConcurrentHashTable : public CHeapObj<F> {
public:
// A bucket is only one pointer with the embedded state.
Bucket() : _first(NULL) {};
Bucket() : _first(nullptr) {};
// Get the first pointer unmasked.
Node* first() const;
@ -312,7 +312,7 @@ class ConcurrentHashTable : public CHeapObj<F> {
// Finds a node.
template <typename LOOKUP_FUNC>
Node* get_node(const Bucket* const bucket, LOOKUP_FUNC& lookup_f,
bool* have_dead, size_t* loops = NULL) const;
bool* have_dead, size_t* loops = nullptr) const;
// Method for shrinking.
bool internal_shrink_prolog(Thread* thread, size_t log2_size);
@ -333,7 +333,7 @@ class ConcurrentHashTable : public CHeapObj<F> {
// Get a value.
template <typename LOOKUP_FUNC>
VALUE* internal_get(Thread* thread, LOOKUP_FUNC& lookup_f,
bool* grow_hint = NULL);
bool* grow_hint = nullptr);
// Insert and get current value.
template <typename LOOKUP_FUNC, typename FOUND_FUNC>
@ -421,7 +421,7 @@ class ConcurrentHashTable : public CHeapObj<F> {
// This means no paused bucket resize operation is going to resume
// on this table.
bool is_safepoint_safe() { return _resize_lock_owner == NULL; }
bool is_safepoint_safe() { return _resize_lock_owner == nullptr; }
// Re-size operations.
bool shrink(Thread* thread, size_t size_limit_log2 = 0);
@ -440,13 +440,13 @@ class ConcurrentHashTable : public CHeapObj<F> {
// called.
template <typename LOOKUP_FUNC, typename FOUND_FUNC>
bool get(Thread* thread, LOOKUP_FUNC& lookup_f, FOUND_FUNC& foundf,
bool* grow_hint = NULL);
bool* grow_hint = nullptr);
// Returns true true if the item was inserted, duplicates are found with
// LOOKUP_FUNC.
template <typename LOOKUP_FUNC>
bool insert(Thread* thread, LOOKUP_FUNC& lookup_f, const VALUE& value,
bool* grow_hint = NULL, bool* clean_hint = NULL) {
bool* grow_hint = nullptr, bool* clean_hint = nullptr) {
struct NOP {
void operator()(...) const {}
} nop;
@ -457,7 +457,7 @@ class ConcurrentHashTable : public CHeapObj<F> {
// LOOKUP_FUNC then FOUND_FUNC is called.
template <typename LOOKUP_FUNC, typename FOUND_FUNC>
bool insert_get(Thread* thread, LOOKUP_FUNC& lookup_f, VALUE& value, FOUND_FUNC& foundf,
bool* grow_hint = NULL, bool* clean_hint = NULL) {
bool* grow_hint = nullptr, bool* clean_hint = nullptr) {
return internal_insert_get(thread, lookup_f, value, foundf, grow_hint, clean_hint);
}
@ -534,7 +534,7 @@ class ConcurrentHashTable : public CHeapObj<F> {
// The VALUEs are safe as long as you never save the VALUEs outside the
// scope, e.g. after ~MultiGetHandle().
template <typename LOOKUP_FUNC>
VALUE* get(LOOKUP_FUNC& lookup_f, bool* grow_hint = NULL);
VALUE* get(LOOKUP_FUNC& lookup_f, bool* grow_hint = nullptr);
};
private:

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, 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
@ -135,7 +135,7 @@ inline void ConcurrentHashTable<CONFIG, F>::
{
assert(is_locked(), "Must be locked.");
Node* const volatile * ret = first_ptr();
while (clear_state(*ret) != NULL) {
while (clear_state(*ret) != nullptr) {
ret = clear_state(*ret)->next_ptr();
}
release_assign_node_ptr(ret, node);
@ -222,8 +222,8 @@ inline ConcurrentHashTable<CONFIG, F>::
_cs_context(GlobalCounter::critical_section_begin(_thread))
{
// This version is published now.
if (Atomic::load_acquire(&_cht->_invisible_epoch) != NULL) {
Atomic::release_store_fence(&_cht->_invisible_epoch, (Thread*)NULL);
if (Atomic::load_acquire(&_cht->_invisible_epoch) != nullptr) {
Atomic::release_store_fence(&_cht->_invisible_epoch, (Thread*)nullptr);
}
}
@ -252,16 +252,16 @@ inline bool ConcurrentHashTable<CONFIG, F>::
{
// Instantiated for pointer type (true), so we can use prefetch.
// When visiting all Nodes doing this prefetch give around 30%.
Node* pref = prefetch_bucket != NULL ? prefetch_bucket->first() : NULL;
for (Node* next = bucket->first(); next != NULL ; next = next->next()) {
if (pref != NULL) {
Node* pref = prefetch_bucket != nullptr ? prefetch_bucket->first() : nullptr;
for (Node* next = bucket->first(); next != nullptr ; next = next->next()) {
if (pref != nullptr) {
Prefetch::read(*pref->value(), 0);
pref = pref->next();
}
// Read next() Node* once. May be racing with a thread moving the next
// pointers.
Node* next_pref = next->next();
if (next_pref != NULL) {
if (next_pref != nullptr) {
Prefetch::read(*next_pref->value(), 0);
}
if (eval_f(next->value())) {
@ -278,7 +278,7 @@ inline bool ConcurrentHashTable<CONFIG, F>::
EVALUATE_FUNC& eval_f,
Bucket* preb)
{
for (Node* next = bucket->first(); next != NULL ; next = next->next()) {
for (Node* next = bucket->first(); next != nullptr ; next = next->next()) {
if (eval_f(next->value())) {
return true;
}
@ -297,7 +297,7 @@ inline void ConcurrentHashTable<CONFIG, F>::
if (Atomic::load_acquire(&_invisible_epoch) == thread) {
return;
}
assert(_invisible_epoch == NULL, "Two thread doing bulk operations");
assert(_invisible_epoch == nullptr, "Two thread doing bulk operations");
// We set this/next version that we are synchronizing for to not published.
// A reader will zero this flag if it reads this/next version.
Atomic::release_store(&_invisible_epoch, thread);
@ -309,7 +309,7 @@ inline bool ConcurrentHashTable<CONFIG, F>::
try_resize_lock(Thread* locker)
{
if (_resize_lock->try_lock()) {
if (_resize_lock_owner != NULL) {
if (_resize_lock_owner != nullptr) {
assert(locker != _resize_lock_owner, "Already own lock");
// We got mutex but internal state is locked.
_resize_lock->unlock();
@ -335,7 +335,7 @@ inline void ConcurrentHashTable<CONFIG, F>::
_resize_lock->lock_without_safepoint_check();
// If holder of lock dropped mutex for safepoint mutex might be unlocked,
// and _resize_lock_owner will contain the owner.
if (_resize_lock_owner != NULL) {
if (_resize_lock_owner != nullptr) {
assert(locker != _resize_lock_owner, "Already own lock");
// We got mutex but internal state is locked.
_resize_lock->unlock();
@ -354,7 +354,7 @@ inline void ConcurrentHashTable<CONFIG, F>::
{
_invisible_epoch = 0;
assert(locker == _resize_lock_owner, "Not unlocked by locker.");
_resize_lock_owner = NULL;
_resize_lock_owner = nullptr;
_resize_lock->unlock();
}
@ -366,7 +366,7 @@ inline void ConcurrentHashTable<CONFIG, F>::
for (size_t node_it = 0; node_it < _table->_size; node_it++) {
Bucket* bucket = _table->get_buckets() + node_it;
Node* node = bucket->first();
while (node != NULL) {
while (node != nullptr) {
Node* free_node = node;
node = node->next();
Node::destroy_node(_context, free_node);
@ -401,7 +401,7 @@ ConcurrentHashTable<CONFIG, F>::
// All must see this.
GlobalCounter::write_synchronize();
// _new_table not read any more.
_new_table = NULL;
_new_table = nullptr;
DEBUG_ONLY(_new_table = (InternalTable*)POISON_PTR;)
return old_table;
}
@ -411,7 +411,7 @@ inline void ConcurrentHashTable<CONFIG, F>::
internal_grow_range(Thread* thread, size_t start, size_t stop)
{
assert(stop <= _table->_size, "Outside backing array");
assert(_new_table != NULL, "Grow not proper setup before start");
assert(_new_table != nullptr, "Grow not proper setup before start");
// The state is also copied here. Hence all buckets in new table will be
// locked. I call the siblings odd/even, where even have high bit 0 and odd
// have high bit 1.
@ -456,7 +456,7 @@ inline bool ConcurrentHashTable<CONFIG, F>::
Node* const volatile * rem_n_prev = bucket->first_ptr();
Node* rem_n = bucket->first();
bool have_dead = false;
while (rem_n != NULL) {
while (rem_n != nullptr) {
if (lookup_f.equals(rem_n->value(), &have_dead)) {
bucket->release_assign_node_ptr(rem_n_prev, rem_n->next());
break;
@ -468,7 +468,7 @@ inline bool ConcurrentHashTable<CONFIG, F>::
bucket->unlock();
if (rem_n == NULL) {
if (rem_n == nullptr) {
return false;
}
// Publish the deletion.
@ -487,7 +487,7 @@ inline void ConcurrentHashTable<CONFIG, F>::
{
// Here we have resize lock so table is SMR safe, and there is no new
// table. Can do this in parallel if we want.
assert((is_mt && _resize_lock_owner != NULL) ||
assert((is_mt && _resize_lock_owner != nullptr) ||
(!is_mt && _resize_lock_owner == thread), "Re-size lock not held");
Node* ndel_stack[StackBufferSize];
InternalTable* table = get_table();
@ -502,7 +502,7 @@ inline void ConcurrentHashTable<CONFIG, F>::
for (size_t bucket_it = start_idx; bucket_it < stop_idx; bucket_it++) {
Bucket* bucket = table->get_bucket(bucket_it);
Bucket* prefetch_bucket = (bucket_it+1) < stop_idx ?
table->get_bucket(bucket_it+1) : NULL;
table->get_bucket(bucket_it+1) : nullptr;
if (!HaveDeletables<std::is_pointer<VALUE>::value, EVALUATE_FUNC>::
have_deletable(bucket, eval_f, prefetch_bucket)) {
@ -545,7 +545,7 @@ inline void ConcurrentHashTable<CONFIG, F>::
Node* ndel[StackBufferSize];
Node* const volatile * rem_n_prev = bucket->first_ptr();
Node* rem_n = bucket->first();
while (rem_n != NULL) {
while (rem_n != nullptr) {
bool is_dead = false;
lookup_f.equals(rem_n->value(), &is_dead);
if (is_dead) {
@ -625,7 +625,7 @@ ConcurrentHashTable<CONFIG, F>::
{
size_t loop_count = 0;
Node* node = bucket->first();
while (node != NULL) {
while (node != nullptr) {
bool is_dead = false;
++loop_count;
if (lookup_f.equals(node->value(), &is_dead)) {
@ -636,7 +636,7 @@ ConcurrentHashTable<CONFIG, F>::
}
node = node->next();
}
if (loops != NULL) {
if (loops != nullptr) {
*loops = loop_count;
}
return node;
@ -648,16 +648,16 @@ inline bool ConcurrentHashTable<CONFIG, F>::
InternalTable* new_table, size_t even_index, size_t odd_index)
{
Node* aux = old_table->get_bucket(even_index)->first();
if (aux == NULL) {
if (aux == nullptr) {
// This is an empty bucket and in debug we poison first ptr in bucket.
// Therefore we must make sure no readers are looking at this bucket.
// If we don't do a write_synch here, caller must do it.
return false;
}
Node* delete_me = NULL;
Node* delete_me = nullptr;
Node* const volatile * even = new_table->get_bucket(even_index)->first_ptr();
Node* const volatile * odd = new_table->get_bucket(odd_index)->first_ptr();
while (aux != NULL) {
while (aux != nullptr) {
bool dead_hash = false;
size_t aux_hash = CONFIG::get_hash(*aux->value(), &dead_hash);
Node* aux_next = aux->next();
@ -692,9 +692,9 @@ inline bool ConcurrentHashTable<CONFIG, F>::
// chain. E.g. looking for even hash value but got moved to the odd bucket
// chain.
write_synchonize_on_visible_epoch(thread);
if (delete_me != NULL) {
if (delete_me != nullptr) {
Node::destroy_node(_context, delete_me);
delete_me = NULL;
delete_me = nullptr;
}
}
return true;
@ -792,7 +792,7 @@ template <typename CONFIG, MEMFLAGS F>
inline void ConcurrentHashTable<CONFIG, F>::
internal_reset(size_t log2_size)
{
assert(_table != NULL, "table failed");
assert(_table != nullptr, "table failed");
assert(_log2_size_limit >= log2_size, "bad ergo");
delete _table;
@ -869,14 +869,14 @@ inline typename CONFIG::Value* ConcurrentHashTable<CONFIG, F>::
{
bool clean = false;
size_t loops = 0;
VALUE* ret = NULL;
VALUE* ret = nullptr;
const Bucket* bucket = get_bucket(lookup_f.get_hash());
Node* node = get_node(bucket, lookup_f, &clean, &loops);
if (node != NULL) {
if (node != nullptr) {
ret = node->value();
}
if (grow_hint != NULL) {
if (grow_hint != nullptr) {
*grow_hint = loops > _grow_hint;
}
@ -895,7 +895,7 @@ inline bool ConcurrentHashTable<CONFIG, F>::
size_t loops = 0;
size_t i = 0;
uintx hash = lookup_f.get_hash();
Node* new_node = Node::create_node(_context, value, NULL);
Node* new_node = Node::create_node(_context, value, nullptr);
while (true) {
{
@ -903,12 +903,12 @@ inline bool ConcurrentHashTable<CONFIG, F>::
Bucket* bucket = get_bucket(hash);
Node* first_at_start = bucket->first();
Node* old = get_node(bucket, lookup_f, &clean, &loops);
if (old == NULL) {
if (old == nullptr) {
new_node->set_next(first_at_start);
if (bucket->cas_first(new_node, first_at_start)) {
foundf(new_node->value());
JFR_ONLY(safe_stats_add();)
new_node = NULL;
new_node = nullptr;
ret = true;
break; /* leave critical section */
}
@ -928,7 +928,7 @@ inline bool ConcurrentHashTable<CONFIG, F>::
}
}
if (new_node != NULL) {
if (new_node != nullptr) {
// CAS failed and a duplicate was inserted, we must free this node.
Node::destroy_node(_context, new_node);
} else if (i == 0 && clean) {
@ -939,11 +939,11 @@ inline bool ConcurrentHashTable<CONFIG, F>::
clean = false;
}
if (grow_hint != NULL) {
if (grow_hint != nullptr) {
*grow_hint = loops > _grow_hint;
}
if (clean_hint != NULL) {
if (clean_hint != nullptr) {
*clean_hint = clean;
}
@ -956,7 +956,7 @@ inline bool ConcurrentHashTable<CONFIG, F>::
visit_nodes(Bucket* bucket, FUNC& visitor_f)
{
Node* current_node = bucket->first();
while (current_node != NULL) {
while (current_node != nullptr) {
Prefetch::read(current_node->next(), 0);
if (!visitor_f(current_node->value())) {
return false;
@ -1017,9 +1017,9 @@ inline size_t ConcurrentHashTable<CONFIG, F>::
template <typename CONFIG, MEMFLAGS F>
inline ConcurrentHashTable<CONFIG, F>::
ConcurrentHashTable(size_t log2size, size_t log2size_limit, size_t grow_hint, bool enable_statistics, void* context)
: _context(context), _new_table(NULL), _log2_size_limit(log2size_limit),
: _context(context), _new_table(nullptr), _log2_size_limit(log2size_limit),
_log2_start_size(log2size), _grow_hint(grow_hint),
_size_limit_reached(false), _resize_lock_owner(NULL),
_size_limit_reached(false), _resize_lock_owner(nullptr),
_invisible_epoch(0)
{
if (enable_statistics) {
@ -1093,7 +1093,7 @@ inline bool ConcurrentHashTable<CONFIG, F>::
bool ret = false;
ScopedCS cs(thread, this);
VALUE* val = internal_get(thread, lookup_f, grow_hint);
if (val != NULL) {
if (val != nullptr) {
found_f(val);
ret = true;
}
@ -1163,7 +1163,7 @@ inline void ConcurrentHashTable<CONFIG, F>::
// If there is a paused resize we also need to visit the already resized items.
table = get_new_table();
if (table == NULL) {
if (table == nullptr) {
return;
}
DEBUG_ONLY(if (table == POISON_PTR) { return; })
@ -1238,7 +1238,7 @@ inline TableStatistics ConcurrentHashTable<CONFIG, F>::
continue;
}
Node* current_node = bucket->first();
while (current_node != NULL) {
while (current_node != nullptr) {
++count;
literal_bytes += vs_f(current_node->value());
current_node = current_node->next();
@ -1292,11 +1292,11 @@ inline bool ConcurrentHashTable<CONFIG, F>::
if (!try_resize_lock(thread)) {
return false;
}
assert(_new_table == NULL || _new_table == POISON_PTR, "Must be NULL");
assert(_new_table == nullptr || _new_table == POISON_PTR, "Must be nullptr");
for (size_t bucket_it = 0; bucket_it < _table->_size; bucket_it++) {
Bucket* bucket = _table->get_bucket(bucket_it);
assert(!bucket->have_redirect() && !bucket->is_locked(), "Table must be uncontended");
while (bucket->first() != NULL) {
while (bucket->first() != nullptr) {
Node* move_node = bucket->first();
bool ok = bucket->cas_first(move_node->next(), move_node);
assert(ok, "Uncontended cas must work");

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, 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
@ -169,7 +169,7 @@ class ConcurrentHashTable<CONFIG, F>::BulkDeleteTask :
template <typename EVALUATE_FUNC, typename DELETE_FUNC>
bool do_task(Thread* thread, EVALUATE_FUNC& eval_f, DELETE_FUNC& del_f) {
size_t start, stop;
assert(BucketsOperation::_cht->_resize_lock_owner != NULL,
assert(BucketsOperation::_cht->_resize_lock_owner != nullptr,
"Should be locked");
if (!this->claim(&start, &stop)) {
return false;
@ -177,7 +177,7 @@ class ConcurrentHashTable<CONFIG, F>::BulkDeleteTask :
BucketsOperation::_cht->do_bulk_delete_locked_for(thread, start, stop,
eval_f, del_f,
BucketsOperation::_is_mt);
assert(BucketsOperation::_cht->_resize_lock_owner != NULL,
assert(BucketsOperation::_cht->_resize_lock_owner != nullptr,
"Should be locked");
return true;
}
@ -210,13 +210,13 @@ class ConcurrentHashTable<CONFIG, F>::GrowTask :
// Re-sizes a portion of the table. Returns true if there is more work.
bool do_task(Thread* thread) {
size_t start, stop;
assert(BucketsOperation::_cht->_resize_lock_owner != NULL,
assert(BucketsOperation::_cht->_resize_lock_owner != nullptr,
"Should be locked");
if (!this->claim(&start, &stop)) {
return false;
}
BucketsOperation::_cht->internal_grow_range(thread, start, stop);
assert(BucketsOperation::_cht->_resize_lock_owner != NULL,
assert(BucketsOperation::_cht->_resize_lock_owner != nullptr,
"Should be locked");
return true;
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2023, 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
@ -67,8 +67,8 @@ public:
*/
template<bool swap>
static void conjoint_swap_if_needed(const void* src, void* dst, size_t byte_count, size_t elem_size) {
assert(src != NULL, "address must not be NULL");
assert(dst != NULL, "address must not be NULL");
assert(src != nullptr, "address must not be nullptr");
assert(dst != nullptr, "address must not be nullptr");
assert(elem_size == 2 || elem_size == 4 || elem_size == 8,
"incorrect element size: " SIZE_FORMAT, elem_size);
assert(is_aligned(byte_count, elem_size),

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023, 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
@ -73,7 +73,7 @@
static char g_dummy;
char* g_assert_poison = &g_dummy;
static intx g_asserting_thread = 0;
static void* g_assertion_context = NULL;
static void* g_assertion_context = nullptr;
#endif // CAN_SHOW_REGISTERS_ON_ASSERT
// Set to suppress secondary error reporting.
@ -110,7 +110,7 @@ struct Crasher {
Crasher() {
// Using getenv - no other mechanism would work yet.
const char* s = ::getenv("HOTSPOT_FATAL_ERROR_DURING_DYNAMIC_INITIALIZATION");
if (s != NULL && ::strcmp(s, "1") == 0) {
if (s != nullptr && ::strcmp(s, "1") == 0) {
fatal("HOTSPOT_FATAL_ERROR_DURING_DYNAMIC_INITIALIZATION");
}
}
@ -135,7 +135,7 @@ void warning(const char* format, ...) {
#define is_token_break(ch) (isspace(ch) || (ch) == ',')
static const char* last_file_name = NULL;
static const char* last_file_name = nullptr;
static int last_line_no = -1;
// assert/guarantee/... may happen very early during VM initialization.
@ -149,7 +149,7 @@ bool error_is_suppressed(const char* file_name, int line_no) {
int file_name_len = (int)strlen(file_name);
char separator = os::file_separator()[0];
const char* base_name = strrchr(file_name, separator);
if (base_name == NULL)
if (base_name == nullptr)
base_name = file_name;
// scan the SuppressErrorAt option
@ -185,7 +185,7 @@ bool error_is_suppressed(const char* file_name, int line_no) {
const char* foundp;
bool match = false;
while (!match
&& (foundp = strchr(look, sfile[0])) != NULL
&& (foundp = strchr(look, sfile[0])) != nullptr
&& foundp <= look_max) {
match = true;
for (int i = 1; i < sfile_len; i++) {
@ -245,7 +245,7 @@ void report_vm_error(const char* file, int line, const char* error_msg)
static void print_error_for_unit_test(const char* message, const char* detail_fmt, va_list detail_args) {
if (ExecutingUnitTests) {
char detail_msg[256];
if (detail_fmt != NULL) {
if (detail_fmt != nullptr) {
// Special handling for the sake of gtest death tests which expect the assert
// message to be printed in one short line to stderr (see TEST_VM_ASSERT_MSG) and
// cannot be tweaked to accept our normal assert message.
@ -254,7 +254,7 @@ static void print_error_for_unit_test(const char* message, const char* detail_fm
jio_vsnprintf(detail_msg, sizeof(detail_msg), detail_fmt, detail_args_copy);
// the VM assert tests look for "assert failed: "
if (message == NULL) {
if (message == nullptr) {
fprintf(stderr, "assert failed: %s", detail_msg);
} else {
if (strlen(detail_msg) > 0) {
@ -274,9 +274,9 @@ void report_vm_error(const char* file, int line, const char* error_msg, const ch
if (Debugging || error_is_suppressed(file, line)) return;
va_list detail_args;
va_start(detail_args, detail_fmt);
void* context = NULL;
void* context = nullptr;
#ifdef CAN_SHOW_REGISTERS_ON_ASSERT
if (g_assertion_context != NULL && os::current_thread_id() == g_asserting_thread) {
if (g_assertion_context != nullptr && os::current_thread_id() == g_asserting_thread) {
context = g_assertion_context;
}
#endif // CAN_SHOW_REGISTERS_ON_ASSERT
@ -296,9 +296,9 @@ void report_fatal(VMErrorType error_type, const char* file, int line, const char
if (Debugging || error_is_suppressed(file, line)) return;
va_list detail_args;
va_start(detail_args, detail_fmt);
void* context = NULL;
void* context = nullptr;
#ifdef CAN_SHOW_REGISTERS_ON_ASSERT
if (g_assertion_context != NULL && os::current_thread_id() == g_asserting_thread) {
if (g_assertion_context != nullptr && os::current_thread_id() == g_asserting_thread) {
context = g_assertion_context;
}
#endif // CAN_SHOW_REGISTERS_ON_ASSERT
@ -306,7 +306,7 @@ void report_fatal(VMErrorType error_type, const char* file, int line, const char
print_error_for_unit_test("fatal error", detail_fmt, detail_args);
VMError::report_and_die(error_type, "fatal error", detail_fmt, detail_args,
Thread::current_or_null(), NULL, NULL, context,
Thread::current_or_null(), nullptr, nullptr, context,
file, line, 0);
va_end(detail_args);
}
@ -317,7 +317,7 @@ void report_vm_out_of_memory(const char* file, int line, size_t size,
va_list detail_args;
va_start(detail_args, detail_fmt);
print_error_for_unit_test(NULL, detail_fmt, detail_args);
print_error_for_unit_test(nullptr, detail_fmt, detail_args);
VMError::report_and_die(Thread::current_or_null(), file, line, size, vm_err_type, detail_fmt, detail_args);
va_end(detail_args);
@ -421,8 +421,8 @@ extern "C" JNIEXPORT void nm(intptr_t p) {
// Actually we look through all CodeBlobs (the nm name has been kept for backwards compatibility)
Command c("nm");
CodeBlob* cb = CodeCache::find_blob((address)p);
if (cb == NULL) {
tty->print_cr("NULL");
if (cb == nullptr) {
tty->print_cr("null");
} else {
cb->print();
}
@ -432,9 +432,9 @@ extern "C" JNIEXPORT void nm(intptr_t p) {
extern "C" JNIEXPORT void disnm(intptr_t p) {
Command c("disnm");
CodeBlob* cb = CodeCache::find_blob((address) p);
if (cb != NULL) {
if (cb != nullptr) {
nmethod* nm = cb->as_nmethod_or_null();
if (nm != NULL) {
if (nm != nullptr) {
nm->print();
} else {
cb->print();
@ -449,7 +449,7 @@ extern "C" JNIEXPORT void printnm(intptr_t p) {
os::snprintf_checked(buffer, sizeof(buffer), "printnm: " INTPTR_FORMAT, p);
Command c(buffer);
CodeBlob* cb = CodeCache::find_blob((address) p);
if (cb != NULL && cb->is_nmethod()) {
if (cb != nullptr && cb->is_nmethod()) {
nmethod* nm = (nmethod*)cb;
nm->print_nmethod(true);
} else {
@ -484,8 +484,8 @@ extern "C" JNIEXPORT void verify() {
extern "C" JNIEXPORT void pp(void* p) {
Command c("pp");
FlagSetting fl(DisplayVMOutput, true);
if (p == NULL) {
tty->print_cr("NULL");
if (p == nullptr) {
tty->print_cr("null");
return;
}
if (Universe::heap()->is_in(p)) {
@ -516,7 +516,7 @@ extern "C" JNIEXPORT void pp(void* p) {
extern "C" JNIEXPORT void findpc(intptr_t x);
extern "C" JNIEXPORT void ps() { // print stack
if (Thread::current_or_null() == NULL) return;
if (Thread::current_or_null() == nullptr) return;
Command c("ps");
// Prints the stack of the current Java thread
@ -583,7 +583,7 @@ extern "C" JNIEXPORT void psd() {
extern "C" JNIEXPORT void pss() { // print all stacks
if (Thread::current_or_null() == NULL) return;
if (Thread::current_or_null() == nullptr) return;
Command c("pss");
Threads::print(true, PRODUCT_ONLY(false) NOT_PRODUCT(true));
}
@ -620,7 +620,7 @@ extern "C" JNIEXPORT void events() {
extern "C" JNIEXPORT Method* findm(intptr_t pc) {
Command c("findm");
nmethod* nm = CodeCache::find_nmethod((address)pc);
return (nm == NULL) ? (Method*)NULL : nm->method();
return (nm == nullptr) ? (Method*)nullptr : nm->method();
}
@ -761,7 +761,7 @@ extern "C" JNIEXPORT void pns(void* sp, void* fp, void* pc) { // print native st
extern "C" JNIEXPORT void pns2() { // print native stack
Command c("pns2");
static char buf[O_BUFLEN];
if (os::platform_print_native_stack(tty, NULL, buf, sizeof(buf))) {
if (os::platform_print_native_stack(tty, nullptr, buf, sizeof(buf))) {
// We have printed the native stack in platform-specific code,
// so nothing else to do in this case.
} else {
@ -775,7 +775,7 @@ extern "C" JNIEXPORT void pns2() { // print native stack
// Returns true iff the address p is readable and *(intptr_t*)p != errvalue
extern "C" bool dbg_is_safe(const void* p, intptr_t errvalue) {
return p != NULL && SafeFetchN((intptr_t*)const_cast<void*>(p), errvalue) != errvalue;
return p != nullptr && SafeFetchN((intptr_t*)const_cast<void*>(p), errvalue) != errvalue;
}
extern "C" bool dbg_is_good_oop(oopDesc* o) {

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2020 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -38,21 +38,21 @@
#include "decoder_elf.hpp"
#endif
AbstractDecoder* Decoder::_shared_decoder = NULL;
AbstractDecoder* Decoder::_error_handler_decoder = NULL;
AbstractDecoder* Decoder::_shared_decoder = nullptr;
AbstractDecoder* Decoder::_error_handler_decoder = nullptr;
NullDecoder Decoder::_do_nothing_decoder;
AbstractDecoder* Decoder::get_shared_instance() {
assert(shared_decoder_lock()->owned_by_self(), "Require DecoderLock to enter");
if (_shared_decoder == NULL) {
if (_shared_decoder == nullptr) {
_shared_decoder = create_decoder();
}
return _shared_decoder;
}
AbstractDecoder* Decoder::get_error_handler_instance() {
if (_error_handler_decoder == NULL) {
if (_error_handler_decoder == nullptr) {
_error_handler_decoder = create_decoder();
}
return _error_handler_decoder;
@ -69,8 +69,8 @@ AbstractDecoder* Decoder::create_decoder() {
decoder = new (std::nothrow)ElfDecoder();
#endif
if (decoder == NULL || decoder->has_error()) {
if (decoder != NULL) {
if (decoder == nullptr || decoder->has_error()) {
if (decoder != nullptr) {
delete decoder;
}
decoder = &_do_nothing_decoder;
@ -79,7 +79,7 @@ AbstractDecoder* Decoder::create_decoder() {
}
Mutex* Decoder::shared_decoder_lock() {
assert(SharedDecoder_lock != NULL, "Just check");
assert(SharedDecoder_lock != nullptr, "Just check");
return SharedDecoder_lock;
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023, 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
@ -57,7 +57,7 @@ public:
// demangling that was done systematically in the 'modulepath' variant
// is now optional.
virtual bool decode(address pc, char* buf, int buflen, int* offset,
const char* modulepath = NULL, bool demangle = true) = 0;
const char* modulepath = nullptr, bool demangle = true) = 0;
virtual bool decode(address pc, char* buf, int buflen, int* offset, const void* base) = 0;
// demangle a C++ symbol
@ -106,15 +106,15 @@ public:
class Decoder : AllStatic {
public:
static bool decode(address pc, char* buf, int buflen, int* offset, const char* modulepath = NULL, bool demangle = true);
static bool decode(address pc, char* buf, int buflen, int* offset, const char* modulepath = nullptr, bool demangle = true);
static bool decode(address pc, char* buf, int buflen, int* offset, bool demangle) {
return decode(pc, buf, buflen, offset, (const char*) NULL, demangle);
return decode(pc, buf, buflen, offset, (const char*) nullptr, demangle);
}
static bool decode(address pc, char* buf, int buflen, int* offset, const void* base);
static bool demangle(const char* symbol, char* buf, int buflen);
// Attempts to retrieve source file name and line number associated with a pc.
// If filename != NULL, points to a buffer of size filename_len which will receive the
// If filename != nullptr, points to a buffer of size filename_len which will receive the
// file name. File name will be silently truncated if output buffer is too small.
// If is_pc_after_call is true, then pc is treated as pointing to the next instruction
// after a call. The source information for the call instruction is fetched in that case.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2023, 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
@ -30,18 +30,18 @@
#include "runtime/os.hpp"
ElfDecoder::~ElfDecoder() {
if (_opened_elf_files != NULL) {
if (_opened_elf_files != nullptr) {
delete _opened_elf_files;
_opened_elf_files = NULL;
_opened_elf_files = nullptr;
}
}
bool ElfDecoder::decode(address addr, char *buf, int buflen, int* offset, const char* filepath, bool demangle_name) {
assert(filepath, "null file path");
assert(buf != NULL && buflen > 0, "Invalid buffer");
assert(buf != nullptr && buflen > 0, "Invalid buffer");
if (has_error()) return false;
ElfFile* file = get_elf_file(filepath);
if (file == NULL) {
if (file == nullptr) {
return false;
}
@ -81,7 +81,7 @@ bool ElfDecoder::get_source_info(address pc, char* filename, size_t filename_len
const uint32_t unsigned_offset_in_library = (uint32_t)offset_in_library;
ElfFile* file = get_elf_file(filepath);
if (file == NULL) {
if (file == nullptr) {
return false;
}
DWARF_LOG_INFO("##### Find filename and line number for offset " INT32_FORMAT_X_0 " in library %s #####",
@ -106,7 +106,7 @@ ElfFile* ElfDecoder::get_elf_file(const char* filepath) {
ElfFile* file;
file = _opened_elf_files;
while (file != NULL) {
while (file != nullptr) {
if (file->same_elf_file(filepath)) {
return file;
}
@ -114,8 +114,8 @@ ElfFile* ElfDecoder::get_elf_file(const char* filepath) {
}
file = new (std::nothrow)ElfFile(filepath);
if (file != NULL) {
if (_opened_elf_files != NULL) {
if (file != nullptr) {
if (_opened_elf_files != nullptr) {
file->set_next(_opened_elf_files);
}
_opened_elf_files = file;

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2023, 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
@ -34,7 +34,7 @@ class ElfDecoder : public AbstractDecoder {
public:
ElfDecoder() {
_opened_elf_files = NULL;
_opened_elf_files = nullptr;
_decoder_status = no_error;
}
virtual ~ElfDecoder();

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2023, 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
@ -49,7 +49,7 @@ class defaultStream : public xmlTextStream {
// must defer time stamp due to the fact that os::init() hasn't
// yet been called and os::elapsed_counter() may not be valid
defaultStream() {
_log_file = NULL;
_log_file = nullptr;
_inited = false;
_writer = -1;
_last_writer = -1;

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023, 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
@ -46,12 +46,12 @@ const char* ElfFile::USR_LIB_DEBUG_DIRECTORY = "/usr/lib/debug";
// For test only, disable elf section cache and force to read from file directly.
bool ElfFile::_do_not_cache_elf_section = false;
ElfSection::ElfSection(FILE* fd, const Elf_Shdr& hdr) : _section_data(NULL) {
ElfSection::ElfSection(FILE* fd, const Elf_Shdr& hdr) : _section_data(nullptr) {
_stat = load_section(fd, hdr);
}
ElfSection::~ElfSection() {
if (_section_data != NULL) {
if (_section_data != nullptr) {
os::free(_section_data);
}
}
@ -67,7 +67,7 @@ NullDecoder::decoder_status ElfSection::load_section(FILE* const fd, const Elf_S
_section_data = os::malloc(shdr.sh_size, mtInternal);
// No enough memory for caching. It is okay, we can try to read from
// file instead.
if (_section_data == NULL) return NullDecoder::no_error;
if (_section_data == nullptr) return NullDecoder::no_error;
MarkedFileReader mfd(fd);
if (mfd.has_mark() &&
@ -76,19 +76,19 @@ NullDecoder::decoder_status ElfSection::load_section(FILE* const fd, const Elf_S
return NullDecoder::no_error;
} else {
os::free(_section_data);
_section_data = NULL;
_section_data = nullptr;
return NullDecoder::file_invalid;
}
}
bool FileReader::read(void* buf, size_t size) {
assert(buf != NULL, "no buffer");
assert(buf != nullptr, "no buffer");
assert(size > 0, "no space");
return fread(buf, size, 1, _fd) == 1;
}
size_t FileReader::read_buffer(void* buf, size_t size) {
assert(buf != NULL, "no buffer");
assert(buf != nullptr, "no buffer");
assert(size > 0, "no space");
return fread(buf, 1, size, _fd);
}
@ -107,8 +107,8 @@ MarkedFileReader::~MarkedFileReader() {
}
ElfFile::ElfFile(const char* filepath) :
_next(NULL), _filepath(os::strdup(filepath)), _file(NULL),
_symbol_tables(NULL), _string_tables(NULL), _shdr_string_table(NULL), _funcDesc_table(NULL),
_next(nullptr), _filepath(os::strdup(filepath)), _file(nullptr),
_symbol_tables(nullptr), _string_tables(nullptr), _shdr_string_table(nullptr), _funcDesc_table(nullptr),
_status(NullDecoder::no_error), _dwarf_file(nullptr) {
memset(&_elfHdr, 0, sizeof(_elfHdr));
if (_filepath == nullptr) {
@ -121,7 +121,7 @@ ElfFile::ElfFile(const char* filepath) :
ElfFile::~ElfFile() {
cleanup_tables();
if (_file != NULL) {
if (_file != nullptr) {
fclose(_file);
}
@ -165,7 +165,7 @@ NullDecoder::decoder_status ElfFile::parse_elf(const char* filepath) {
assert(filepath, "null file path");
_file = os::fopen(filepath, "r");
if (_file != NULL) {
if (_file != nullptr) {
return load_tables();
} else {
return NullDecoder::file_not_found;
@ -211,11 +211,11 @@ NullDecoder::decoder_status ElfFile::load_tables() {
if (shdr.sh_type == SHT_STRTAB) {
// string tables
ElfStringTable* table = new (std::nothrow) ElfStringTable(fd(), shdr, index);
if (table == NULL) {
if (table == nullptr) {
return NullDecoder::out_of_memory;
}
if (index == _elfHdr.e_shstrndx) {
assert(_shdr_string_table == NULL, "Only set once");
assert(_shdr_string_table == nullptr, "Only set once");
_shdr_string_table = table;
} else {
add_string_table(table);
@ -223,7 +223,7 @@ NullDecoder::decoder_status ElfFile::load_tables() {
} else if (shdr.sh_type == SHT_SYMTAB || shdr.sh_type == SHT_DYNSYM) {
// symbol tables
ElfSymbolTable* table = new (std::nothrow) ElfSymbolTable(fd(), shdr);
if (table == NULL) {
if (table == nullptr) {
return NullDecoder::out_of_memory;
}
add_symbol_table(table);
@ -247,7 +247,7 @@ NullDecoder::decoder_status ElfFile::load_tables() {
}
_funcDesc_table = new (std::nothrow) ElfFuncDescTable(_file, shdr, sect_index);
if (_funcDesc_table == NULL) {
if (_funcDesc_table == nullptr) {
return NullDecoder::out_of_memory;
}
#endif
@ -256,14 +256,14 @@ NullDecoder::decoder_status ElfFile::load_tables() {
#if defined(PPC64) && !defined(ABI_ELFv2)
int ElfFile::section_by_name(const char* name, Elf_Shdr& hdr) {
assert(name != NULL, "No section name");
assert(name != nullptr, "No section name");
size_t len = strlen(name) + 1;
char* buf = (char*)os::malloc(len, mtInternal);
if (buf == NULL) {
if (buf == nullptr) {
return -1;
}
assert(_shdr_string_table != NULL, "Section header string table should be loaded");
assert(_shdr_string_table != nullptr, "Section header string table should be loaded");
ElfStringTable* const table = _shdr_string_table;
MarkedFileReader mfd(fd());
if (!mfd.has_mark() || !mfd.set_position(_elfHdr.e_shoff)) return -1;
@ -299,7 +299,7 @@ bool ElfFile::decode(address addr, char* buf, int buflen, int* offset) {
bool found_symbol = false;
ElfSymbolTable* symbol_table = _symbol_tables;
while (symbol_table != NULL) {
while (symbol_table != nullptr) {
if (symbol_table->lookup(addr, &string_table_index, &pos_in_string_table, &off, _funcDesc_table)) {
found_symbol = true;
break;
@ -312,7 +312,7 @@ bool ElfFile::decode(address addr, char* buf, int buflen, int* offset) {
ElfStringTable* string_table = get_string_table(string_table_index);
if (string_table == NULL) {
if (string_table == nullptr) {
_status = NullDecoder::file_invalid;
return false;
}
@ -322,7 +322,7 @@ bool ElfFile::decode(address addr, char* buf, int buflen, int* offset) {
}
void ElfFile::add_symbol_table(ElfSymbolTable* table) {
if (_symbol_tables == NULL) {
if (_symbol_tables == nullptr) {
_symbol_tables = table;
} else {
table->set_next(_symbol_tables);
@ -331,7 +331,7 @@ void ElfFile::add_symbol_table(ElfSymbolTable* table) {
}
void ElfFile::add_string_table(ElfStringTable* table) {
if (_string_tables == NULL) {
if (_string_tables == nullptr) {
_string_tables = table;
} else {
table->set_next(_string_tables);
@ -341,11 +341,11 @@ void ElfFile::add_string_table(ElfStringTable* table) {
ElfStringTable* ElfFile::get_string_table(int index) {
ElfStringTable* p = _string_tables;
while (p != NULL) {
while (p != nullptr) {
if (p->index() == index) return p;
p = p->next();
}
return NULL;
return nullptr;
}
// Use unified logging to report errors rather than assert() throughout this method as this code is already part of the error reporting

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023, 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
@ -183,8 +183,8 @@ class ElfFile: public CHeapObj<mtInternal> {
bool decode(address addr, char* buf, int buflen, int* offset);
bool same_elf_file(const char* filepath) const {
assert(filepath != NULL, "null file path");
return (_filepath != NULL && !strcmp(filepath, _filepath));
assert(filepath != nullptr, "null file path");
return (_filepath != nullptr && !strcmp(filepath, _filepath));
}
NullDecoder::decoder_status get_status() const {

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2013 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -48,17 +48,17 @@ ElfFuncDescTable::~ElfFuncDescTable() {
address ElfFuncDescTable::lookup(Elf_Word index) {
if (NullDecoder::is_error(_status)) {
return NULL;
return nullptr;
}
address* func_descs = cached_func_descs();
const Elf_Shdr* shdr = _section.section_header();
if (!(shdr->sh_size > 0 && shdr->sh_addr <= index && index <= shdr->sh_addr + shdr->sh_size)) {
// don't put the whole decoder in error mode if we just tried a wrong index
return NULL;
return nullptr;
}
if (func_descs != NULL) {
if (func_descs != nullptr) {
return func_descs[(index - shdr->sh_addr) / sizeof(address)];
} else {
MarkedFileReader mfd(_file);
@ -67,7 +67,7 @@ address ElfFuncDescTable::lookup(Elf_Word index) {
!mfd.set_position(shdr->sh_offset + index - shdr->sh_addr) ||
!mfd.read((void*)&addr, sizeof(addr))) {
_status = NullDecoder::file_invalid;
return NULL;
return nullptr;
}
return addr;
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2013 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -132,7 +132,7 @@ public:
ElfFuncDescTable(FILE* file, Elf_Shdr shdr, int index);
~ElfFuncDescTable();
// return the function address for the function descriptor at 'index' or NULL on error
// return the function address for the function descriptor at 'index' or nullptr on error
address lookup(Elf_Word index);
int get_index() const { return _index; };

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023, 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
@ -34,12 +34,12 @@
// We will try to load whole string table into memory if we can.
// Otherwise, fallback to more expensive file operation.
ElfStringTable::ElfStringTable(FILE* const file, Elf_Shdr& shdr, int index) :
_next(NULL), _index(index), _section(file, shdr), _fd(file) {
_next(nullptr), _index(index), _section(file, shdr), _fd(file) {
_status = _section.status();
}
ElfStringTable::~ElfStringTable() {
if (_next != NULL) {
if (_next != nullptr) {
delete _next;
}
}
@ -55,7 +55,7 @@ bool ElfStringTable::string_at(size_t pos, char* buf, int buflen) {
}
const char* data = (const char*)_section.section_data();
if (data != NULL) {
if (data != nullptr) {
jio_snprintf(buf, buflen, "%s", data + pos);
return true;
} else { // no cache data, read from file instead

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023, 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
@ -31,8 +31,8 @@
#include "utilities/elfSymbolTable.hpp"
ElfSymbolTable::ElfSymbolTable(FILE* const file, Elf_Shdr& shdr) :
_next(NULL), _fd(file), _section(file, shdr) {
assert(file != NULL, "null file handle");
_next(nullptr), _fd(file), _section(file, shdr) {
assert(file != nullptr, "null file handle");
_status = _section.status();
if (_section.section_header()->sh_size % sizeof(Elf_Sym) != 0) {
@ -41,7 +41,7 @@ ElfSymbolTable::ElfSymbolTable(FILE* const file, Elf_Shdr& shdr) :
}
ElfSymbolTable::~ElfSymbolTable() {
if (_next != NULL) {
if (_next != nullptr) {
delete _next;
}
}
@ -51,7 +51,7 @@ bool ElfSymbolTable::compare(const Elf_Sym* sym, address addr, int* stringtableI
Elf_Word st_size = sym->st_size;
const Elf_Shdr* shdr = _section.section_header();
address sym_addr;
if (funcDescTable != NULL && funcDescTable->get_index() == sym->st_shndx) {
if (funcDescTable != nullptr && funcDescTable->get_index() == sym->st_shndx) {
// We need to go another step through the function descriptor table (currently PPC64 only)
sym_addr = funcDescTable->lookup(sym->st_value);
} else {
@ -80,7 +80,7 @@ bool ElfSymbolTable::lookup(address addr, int* stringtableIndex, int* posIndex,
int count = _section.section_header()->sh_size / sym_size;
Elf_Sym* symbols = (Elf_Sym*)_section.section_data();
if (symbols != NULL) {
if (symbols != nullptr) {
for (int index = 0; index < count; index ++) {
if (compare(&symbols[index], addr, stringtableIndex, posIndex, offset, funcDescTable)) {
return true;

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023, 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
@ -33,15 +33,15 @@
#include "utilities/events.hpp"
EventLog* Events::_logs = NULL;
StringEventLog* Events::_messages = NULL;
StringEventLog* Events::_vm_operations = NULL;
ExceptionsEventLog* Events::_exceptions = NULL;
StringEventLog* Events::_redefinitions = NULL;
UnloadingEventLog* Events::_class_unloading = NULL;
StringEventLog* Events::_class_loading = NULL;
StringEventLog* Events::_deopt_messages = NULL;
StringEventLog* Events::_dll_messages = NULL;
EventLog* Events::_logs = nullptr;
StringEventLog* Events::_messages = nullptr;
StringEventLog* Events::_vm_operations = nullptr;
ExceptionsEventLog* Events::_exceptions = nullptr;
StringEventLog* Events::_redefinitions = nullptr;
UnloadingEventLog* Events::_class_unloading = nullptr;
StringEventLog* Events::_class_loading = nullptr;
StringEventLog* Events::_deopt_messages = nullptr;
StringEventLog* Events::_dll_messages = nullptr;
EventLog::EventLog() {
// This normally done during bootstrap when we're only single
@ -56,7 +56,7 @@ EventLog::EventLog() {
// the buffer.
void Events::print_all(outputStream* out, int max) {
EventLog* log = _logs;
while (log != NULL) {
while (log != nullptr) {
log->print_log_on(out, max);
log = log->next();
}
@ -66,7 +66,7 @@ void Events::print_all(outputStream* out, int max) {
void Events::print_one(outputStream* out, const char* log_name, int max) {
EventLog* log = _logs;
int num_printed = 0;
while (log != NULL) {
while (log != nullptr) {
if (log->matches_name_or_handle(log_name)) {
log->print_log_on(out, max);
num_printed ++;
@ -78,7 +78,7 @@ void Events::print_one(outputStream* out, const char* log_name, int max) {
out->print_cr("The name \"%s\" did not match any known event log. "
"Valid event log names are:", log_name);
EventLog* log = _logs;
while (log != NULL) {
while (log != nullptr) {
log->print_names(out);
out->cr();
log = log->next();
@ -118,13 +118,13 @@ EventMarkBase::EventMarkBase(EventLogFunction log_function) :
void EventMarkBase::log_start(const char* format, va_list argp) {
// Save a copy of begin message and log it.
_buffer.printv(format, argp);
_log_function(NULL, "%s", _buffer.buffer());
_log_function(nullptr, "%s", _buffer.buffer());
}
void EventMarkBase::log_end() {
// Append " done" to the begin message and log it
_buffer.append(" done");
_log_function(NULL, "%s", _buffer.buffer());
_log_function(nullptr, "%s", _buffer.buffer());
}
void UnloadingEventLog::log(Thread* thread, InstanceKlass* ik) {

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023, 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
@ -148,7 +148,7 @@ template <class T> class EventLogBase : public EventLog {
void print(outputStream* out, EventRecord<T>& e) {
out->print("Event: %.3f ", e.timestamp);
if (e.thread != NULL) {
if (e.thread != nullptr) {
out->print("Thread " PTR_FORMAT " ", p2i(e.thread));
}
print(out, e.data);
@ -277,7 +277,7 @@ class Events : AllStatic {
};
inline void Events::log(Thread* thread, const char* format, ...) {
if (LogEvents && _messages != NULL) {
if (LogEvents && _messages != nullptr) {
va_list ap;
va_start(ap, format);
_messages->logv(thread, format, ap);
@ -286,7 +286,7 @@ inline void Events::log(Thread* thread, const char* format, ...) {
}
inline void Events::log_vm_operation(Thread* thread, const char* format, ...) {
if (LogEvents && _vm_operations != NULL) {
if (LogEvents && _vm_operations != nullptr) {
va_list ap;
va_start(ap, format);
_vm_operations->logv(thread, format, ap);
@ -295,7 +295,7 @@ inline void Events::log_vm_operation(Thread* thread, const char* format, ...) {
}
inline void Events::log_exception(Thread* thread, const char* format, ...) {
if (LogEvents && _exceptions != NULL) {
if (LogEvents && _exceptions != nullptr) {
va_list ap;
va_start(ap, format);
_exceptions->logv(thread, format, ap);
@ -304,13 +304,13 @@ inline void Events::log_exception(Thread* thread, const char* format, ...) {
}
inline void Events::log_exception(Thread* thread, Handle h_exception, const char* message, const char* file, int line) {
if (LogEvents && _exceptions != NULL) {
if (LogEvents && _exceptions != nullptr) {
_exceptions->log(thread, h_exception, message, file, line);
}
}
inline void Events::log_redefinition(Thread* thread, const char* format, ...) {
if (LogEvents && _redefinitions != NULL) {
if (LogEvents && _redefinitions != nullptr) {
va_list ap;
va_start(ap, format);
_redefinitions->logv(thread, format, ap);
@ -319,13 +319,13 @@ inline void Events::log_redefinition(Thread* thread, const char* format, ...) {
}
inline void Events::log_class_unloading(Thread* thread, InstanceKlass* ik) {
if (LogEvents && _class_unloading != NULL) {
if (LogEvents && _class_unloading != nullptr) {
_class_unloading->log(thread, ik);
}
}
inline void Events::log_class_loading(Thread* thread, const char* format, ...) {
if (LogEvents && _class_loading != NULL) {
if (LogEvents && _class_loading != nullptr) {
va_list ap;
va_start(ap, format);
_class_loading->logv(thread, format, ap);
@ -334,7 +334,7 @@ inline void Events::log_class_loading(Thread* thread, const char* format, ...) {
}
inline void Events::log_deopt_message(Thread* thread, const char* format, ...) {
if (LogEvents && _deopt_messages != NULL) {
if (LogEvents && _deopt_messages != nullptr) {
va_list ap;
va_start(ap, format);
_deopt_messages->logv(thread, format, ap);
@ -343,7 +343,7 @@ inline void Events::log_deopt_message(Thread* thread, const char* format, ...) {
}
inline void Events::log_dll_message(Thread* thread, const char* format, ...) {
if (LogEvents && _dll_messages != NULL) {
if (LogEvents && _dll_messages != nullptr) {
va_list ap;
va_start(ap, format);
_dll_messages->logv(thread, format, ap);
@ -359,7 +359,7 @@ inline void EventLogBase<T>::print_log_on(outputStream* out, int max) {
bool _locked;
MaybeLocker(Mutex* mutex) : _mutex(mutex), _proceed(false), _locked(false) {
if (Thread::current_or_null() == NULL) {
if (Thread::current_or_null() == nullptr) {
_proceed = true;
} else if (VMError::is_error_reported()) {
if (_mutex->try_lock_without_rank_check()) {

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2023, 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
@ -53,7 +53,7 @@ void check_ThreadShadow() {
void ThreadShadow::set_pending_exception(oop exception, const char* file, int line) {
assert(exception != NULL && oopDesc::is_oop(exception), "invalid exception oop");
assert(exception != nullptr && oopDesc::is_oop(exception), "invalid exception oop");
_pending_exception = exception;
_exception_file = file;
_exception_line = line;
@ -61,14 +61,14 @@ void ThreadShadow::set_pending_exception(oop exception, const char* file, int li
void ThreadShadow::clear_pending_exception() {
LogTarget(Debug, exceptions) lt;
if (_pending_exception != NULL && lt.is_enabled()) {
if (_pending_exception != nullptr && lt.is_enabled()) {
ResourceMark rm;
LogStream ls(lt);
ls.print("Thread::clear_pending_exception: cleared exception:");
_pending_exception->print_on(&ls);
}
_pending_exception = NULL;
_exception_file = NULL;
_pending_exception = nullptr;
_exception_file = nullptr;
_exception_line = 0;
}
@ -114,7 +114,7 @@ bool Exceptions::special_exception(JavaThread* thread, const char* file, int lin
bool Exceptions::special_exception(JavaThread* thread, const char* file, int line, Symbol* h_name, const char* message) {
// bootstrapping check
if (!Universe::is_fully_initialized()) {
if (h_name == NULL) {
if (h_name == nullptr) {
// at least an informative message.
vm_exit_during_initialization("Exception", message);
} else {
@ -135,14 +135,14 @@ bool Exceptions::special_exception(JavaThread* thread, const char* file, int lin
// This method should only be called from generated code,
// therefore the exception oop should be in the oopmap.
void Exceptions::_throw_oop(JavaThread* thread, const char* file, int line, oop exception) {
assert(exception != NULL, "exception should not be NULL");
assert(exception != nullptr, "exception should not be nullptr");
Handle h_exception(thread, exception);
_throw(thread, file, line, h_exception);
}
void Exceptions::_throw(JavaThread* thread, const char* file, int line, Handle h_exception, const char* message) {
ResourceMark rm(thread);
assert(h_exception() != NULL, "exception should not be NULL");
assert(h_exception() != nullptr, "exception should not be nullptr");
// tracing (do this up front - so it works during boot strapping)
// Note, the print_value_string() argument is not called unless logging is enabled!
@ -189,7 +189,7 @@ void Exceptions::_throw_msg(JavaThread* thread, const char* file, int line, Symb
// Check for special boot-strapping/compiler-thread handling
if (special_exception(thread, file, line, name, message)) return;
// Create and throw exception
Handle h_cause(thread, NULL);
Handle h_cause(thread, nullptr);
Handle h_exception = new_exception(thread, name, message, h_cause, h_loader, h_protection_domain);
_throw(thread, file, line, h_exception, message);
}
@ -209,15 +209,15 @@ void Exceptions::_throw_cause(JavaThread* thread, const char* file, int line, Sy
if (special_exception(thread, file, line, h_cause)) return;
// Create and throw exception
Handle h_exception = new_exception(thread, name, h_cause, h_loader, h_protection_domain);
_throw(thread, file, line, h_exception, NULL);
_throw(thread, file, line, h_exception, nullptr);
}
void Exceptions::_throw_args(JavaThread* thread, const char* file, int line, Symbol* name, Symbol* signature, JavaCallArguments *args) {
// Check for special boot-strapping/compiler-thread handling
if (special_exception(thread, file, line, name, NULL)) return;
if (special_exception(thread, file, line, name, nullptr)) return;
// Create and throw exception
Handle h_loader(thread, NULL);
Handle h_prot(thread, NULL);
Handle h_loader(thread, nullptr);
Handle h_prot(thread, nullptr);
Handle exception = new_exception(thread, name, signature, args, h_loader, h_prot);
_throw(thread, file, line, exception);
}
@ -226,13 +226,13 @@ void Exceptions::_throw_args(JavaThread* thread, const char* file, int line, Sym
// Methods for default parameters.
// NOTE: These must be here (and not in the header file) because of include circularities.
void Exceptions::_throw_msg_cause(JavaThread* thread, const char* file, int line, Symbol* name, const char* message, Handle h_cause) {
_throw_msg_cause(thread, file, line, name, message, h_cause, Handle(thread, NULL), Handle(thread, NULL));
_throw_msg_cause(thread, file, line, name, message, h_cause, Handle(thread, nullptr), Handle(thread, nullptr));
}
void Exceptions::_throw_msg(JavaThread* thread, const char* file, int line, Symbol* name, const char* message) {
_throw_msg(thread, file, line, name, message, Handle(thread, NULL), Handle(thread, NULL));
_throw_msg(thread, file, line, name, message, Handle(thread, nullptr), Handle(thread, nullptr));
}
void Exceptions::_throw_cause(JavaThread* thread, const char* file, int line, Symbol* name, Handle h_cause) {
_throw_cause(thread, file, line, name, h_cause, Handle(thread, NULL), Handle(thread, NULL));
_throw_cause(thread, file, line, name, h_cause, Handle(thread, nullptr), Handle(thread, nullptr));
}
@ -281,7 +281,7 @@ Handle Exceptions::new_exception(JavaThread* thread, Symbol* name,
Klass* klass = SystemDictionary::resolve_or_fail(name, h_loader, h_protection_domain, true, thread);
if (!thread->has_pending_exception()) {
assert(klass != NULL, "klass must exist");
assert(klass != nullptr, "klass must exist");
h_exception = JavaCalls::construct_new_instance(InstanceKlass::cast(klass),
signature,
args,
@ -335,7 +335,7 @@ Handle Exceptions::new_exception(JavaThread* thread, Symbol* name,
Handle h_loader, Handle h_protection_domain,
ExceptionMsgToUtf8Mode to_utf8_safe) {
JavaCallArguments args;
Symbol* signature = NULL;
Symbol* signature = nullptr;
if (h_cause.is_null()) {
signature = vmSymbols::void_method_signature();
} else {
@ -352,8 +352,8 @@ Handle Exceptions::new_exception(JavaThread* thread, Symbol* name,
Handle h_loader, Handle h_protection_domain,
ExceptionMsgToUtf8Mode to_utf8_safe) {
JavaCallArguments args;
Symbol* signature = NULL;
if (message == NULL) {
Symbol* signature = nullptr;
if (message == nullptr) {
signature = vmSymbols::void_method_signature();
} else {
// There should be no pending exception. The caller is responsible for not calling
@ -401,9 +401,9 @@ Handle Exceptions::new_exception(JavaThread* thread, Symbol* name,
const char* message,
ExceptionMsgToUtf8Mode to_utf8_safe) {
Handle h_loader(thread, NULL);
Handle h_prot(thread, NULL);
Handle h_cause(thread, NULL);
Handle h_loader(thread, nullptr);
Handle h_prot(thread, nullptr);
Handle h_cause(thread, nullptr);
return Exceptions::new_exception(thread, name, message, h_cause, h_loader,
h_prot, to_utf8_safe);
}
@ -420,7 +420,7 @@ void Exceptions::wrap_dynamic_exception(bool is_indy, JavaThread* THREAD) {
bool log_condy = log_is_enabled(Debug, methodhandles, condy) && !is_indy;
LogStreamHandle(Debug, methodhandles, indy) lsh_indy;
LogStreamHandle(Debug, methodhandles, condy) lsh_condy;
LogStream* ls = NULL;
LogStream* ls = nullptr;
if (log_indy) {
ls = &lsh_indy;
} else if (log_condy) {
@ -433,7 +433,7 @@ void Exceptions::wrap_dynamic_exception(bool is_indy, JavaThread* THREAD) {
if (exception->is_a(vmClasses::Error_klass())) {
// Pass through an Error, including BootstrapMethodError, any other form
// of linkage error, or say OutOfMemoryError
if (ls != NULL) {
if (ls != nullptr) {
ls->print_cr("bootstrap method invocation wraps BSME around " PTR_FORMAT, p2i(exception));
exception->print_on(ls);
}
@ -441,7 +441,7 @@ void Exceptions::wrap_dynamic_exception(bool is_indy, JavaThread* THREAD) {
}
// Otherwise wrap the exception in a BootstrapMethodError
if (ls != NULL) {
if (ls != nullptr) {
ls->print_cr("%s throws BSME for " PTR_FORMAT, is_indy ? "invokedynamic" : "dynamic constant", p2i(exception));
exception->print_on(ls);
}
@ -532,11 +532,11 @@ ExceptionMark::~ExceptionMark() {
// caller frees value_string if necessary
void Exceptions::debug_check_abort(const char *value_string, const char* message) {
if (AbortVMOnException != NULL && value_string != NULL &&
if (AbortVMOnException != nullptr && value_string != nullptr &&
strstr(value_string, AbortVMOnException)) {
if (AbortVMOnExceptionMessage == NULL || (message != NULL &&
if (AbortVMOnExceptionMessage == nullptr || (message != nullptr &&
strstr(message, AbortVMOnExceptionMessage))) {
if (message == NULL) {
if (message == nullptr) {
fatal("Saw %s, aborting", value_string);
} else {
fatal("Saw %s: %s, aborting", value_string, message);
@ -546,16 +546,16 @@ void Exceptions::debug_check_abort(const char *value_string, const char* message
}
void Exceptions::debug_check_abort(Handle exception, const char* message) {
if (AbortVMOnException != NULL) {
if (AbortVMOnException != nullptr) {
debug_check_abort_helper(exception, message);
}
}
void Exceptions::debug_check_abort_helper(Handle exception, const char* message) {
ResourceMark rm;
if (message == NULL && exception->is_a(vmClasses::Throwable_klass())) {
if (message == nullptr && exception->is_a(vmClasses::Throwable_klass())) {
oop msg = java_lang_Throwable::message(exception());
if (msg != NULL) {
if (msg != nullptr) {
message = java_lang_String::as_utf8_string(msg);
}
}
@ -566,7 +566,7 @@ void Exceptions::debug_check_abort_helper(Handle exception, const char* message)
void Exceptions::log_exception(Handle exception, const char* message) {
ResourceMark rm;
Symbol* detail_message = java_lang_Throwable::detail_message(exception());
if (detail_message != NULL) {
if (detail_message != nullptr) {
log_info(exceptions)("Exception <%s: %s>\n thrown in %s",
exception->print_value_string(),
detail_message->as_C_string(),

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2023, 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
@ -78,7 +78,7 @@ class ThreadShadow: public CHeapObj<mtThread> {
public:
oop pending_exception() const { return _pending_exception; }
bool has_pending_exception() const { return _pending_exception != NULL; }
bool has_pending_exception() const { return _pending_exception != nullptr; }
const char* exception_file() const { return _exception_file; }
int exception_line() const { return _exception_line; }
@ -94,8 +94,8 @@ class ThreadShadow: public CHeapObj<mtThread> {
// use CLEAR_PENDING_NONASYNC_EXCEPTION to clear probable nonasync exception.
void clear_pending_nonasync_exception();
ThreadShadow() : _pending_exception(NULL),
_exception_file(NULL), _exception_line(0) {}
ThreadShadow() : _pending_exception(nullptr),
_exception_file(nullptr), _exception_line(0) {}
};
@ -124,7 +124,7 @@ class Exceptions {
} ExceptionMsgToUtf8Mode;
// Throw exceptions: w/o message, w/ message & with formatted message.
static void _throw_oop(JavaThread* thread, const char* file, int line, oop exception);
static void _throw(JavaThread* thread, const char* file, int line, Handle exception, const char* msg = NULL);
static void _throw(JavaThread* thread, const char* file, int line, Handle exception, const char* msg = nullptr);
static void _throw_msg(JavaThread* thread, const char* file, int line, Symbol* name, const char* message);
static void _throw_msg(JavaThread* thread, const char* file, int line, Symbol* name, const char* message,
@ -184,9 +184,9 @@ class Exceptions {
static void print_exception_counts_on_error(outputStream* st);
// for AbortVMOnException flag
static void debug_check_abort(Handle exception, const char* message = NULL);
static void debug_check_abort_helper(Handle exception, const char* message = NULL);
static void debug_check_abort(const char *value_string, const char* message = NULL);
static void debug_check_abort(Handle exception, const char* message = nullptr);
static void debug_check_abort_helper(Handle exception, const char* message = nullptr);
static void debug_check_abort(const char *value_string, const char* message = nullptr);
// for logging exceptions
static void log_exception(Handle exception, const char* message);
@ -225,7 +225,7 @@ class Exceptions {
#define CHECK_(result) THREAD); if (HAS_PENDING_EXCEPTION) return result; (void)(0
#define CHECK_0 CHECK_(0)
#define CHECK_NH CHECK_(Handle())
#define CHECK_NULL CHECK_(NULL)
#define CHECK_NULL CHECK_(nullptr)
#define CHECK_false CHECK_(false)
#define CHECK_JNI_ERR CHECK_(JNI_ERR)
@ -234,7 +234,7 @@ class Exceptions {
#define CHECK_AND_CLEAR_(result) THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; return result; } (void)(0
#define CHECK_AND_CLEAR_0 CHECK_AND_CLEAR_(0)
#define CHECK_AND_CLEAR_NH CHECK_AND_CLEAR_(Handle())
#define CHECK_AND_CLEAR_NULL CHECK_AND_CLEAR_(NULL)
#define CHECK_AND_CLEAR_NULL CHECK_AND_CLEAR_(nullptr)
#define CHECK_AND_CLEAR_false CHECK_AND_CLEAR_(false)
// CAUTION: These macros clears all exceptions except probable async exceptions j.l.InternalError.
@ -244,7 +244,7 @@ class Exceptions {
#define CHECK_AND_CLEAR_NONASYNC_(result) THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_NONASYNC_EXCEPTION; return result; } (void)(0
#define CHECK_AND_CLEAR_NONASYNC_0 CHECK_AND_CLEAR_NONASYNC_(0)
#define CHECK_AND_CLEAR_NONASYNC_NH CHECK_AND_CLEAR_NONASYNC_(Handle())
#define CHECK_AND_CLEAR_NONASYNC_NULL CHECK_AND_CLEAR_NONASYNC_(NULL)
#define CHECK_AND_CLEAR_NONASYNC_NULL CHECK_AND_CLEAR_NONASYNC_(nullptr)
#define CHECK_AND_CLEAR_NONASYNC_false CHECK_AND_CLEAR_NONASYNC_(false)
// The THROW... macros should be used to throw an exception. They require a THREAD variable to be
@ -260,7 +260,7 @@ class Exceptions {
{ Exceptions::_throw(THREAD_AND_LOCATION, e); return; }
#define THROW(name) \
{ Exceptions::_throw_msg(THREAD_AND_LOCATION, name, NULL); return; }
{ Exceptions::_throw_msg(THREAD_AND_LOCATION, name, nullptr); return; }
#define THROW_MSG(name, message) \
{ Exceptions::_throw_msg(THREAD_AND_LOCATION, name, message); return; }
@ -281,7 +281,7 @@ class Exceptions {
{ Exceptions::_throw(THREAD_AND_LOCATION, e); return result; }
#define THROW_(name, result) \
{ Exceptions::_throw_msg(THREAD_AND_LOCATION, name, NULL); return result; }
{ Exceptions::_throw_msg(THREAD_AND_LOCATION, name, nullptr); return result; }
#define THROW_MSG_(name, message, result) \
{ Exceptions::_throw_msg(THREAD_AND_LOCATION, name, message); return result; }
@ -306,10 +306,10 @@ class Exceptions {
#define THROW_WRAPPED_0(name, oop_to_wrap) THROW_WRAPPED_(name, oop_to_wrap, 0)
#define THROW_ARG_0(name, signature, arg) THROW_ARG_(name, signature, arg, 0)
#define THROW_MSG_CAUSE_0(name, message, cause) THROW_MSG_CAUSE_(name, message, cause, 0)
#define THROW_MSG_CAUSE_NULL(name, message, cause) THROW_MSG_CAUSE_(name, message, cause, NULL)
#define THROW_MSG_CAUSE_NULL(name, message, cause) THROW_MSG_CAUSE_(name, message, cause, nullptr)
#define THROW_NULL(name) THROW_(name, NULL)
#define THROW_MSG_NULL(name, message) THROW_MSG_(name, message, NULL)
#define THROW_NULL(name) THROW_(name, nullptr)
#define THROW_MSG_NULL(name, message) THROW_MSG_(name, message, nullptr)
// The CATCH macro checks that no exception has been thrown by a function; it is used at
// call sites about which is statically known that the callee cannot throw an exception

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2023, 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
@ -37,7 +37,7 @@ class FilterQueue {
private:
class Node : public CHeapObj<mtInternal> {
public:
Node(const E& e): _next(NULL), _data(e) { }
Node(const E& e): _next(nullptr), _data(e) { }
Node* _next;
E _data;
};
@ -50,10 +50,10 @@ class FilterQueue {
static bool match_all(E d) { return true; }
public:
FilterQueue() : _first(NULL) { }
FilterQueue() : _first(nullptr) { }
bool is_empty() {
return load_first() == NULL;
return load_first() == nullptr;
}
// Adds an item to the queue in a MT safe way, re-entrant.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2023, 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
@ -49,7 +49,7 @@ template <class E>
template <typename MATCH_FUNC>
bool FilterQueue<E>::contains(MATCH_FUNC& match_func) {
Node* cur = load_first();
if (cur == NULL) {
if (cur == nullptr) {
return false;
}
do {
@ -57,7 +57,7 @@ bool FilterQueue<E>::contains(MATCH_FUNC& match_func) {
return true;
}
cur = cur->_next;
} while (cur != NULL);
} while (cur != nullptr);
return false;
}
@ -67,12 +67,12 @@ template <typename MATCH_FUNC>
E FilterQueue<E>::pop(MATCH_FUNC& match_func) {
Node* first = load_first();
Node* cur = first;
Node* prev = NULL;
Node* match = NULL;
Node* match_prev = NULL;
Node* prev = nullptr;
Node* match = nullptr;
Node* match_prev = nullptr;
if (cur == NULL) {
return (E)NULL;
if (cur == nullptr) {
return (E)nullptr;
}
SpinYield yield(SpinYield::default_spin_limit * 10); // Very unlikely with multiple failed CAS.
do {
@ -83,13 +83,13 @@ E FilterQueue<E>::pop(MATCH_FUNC& match_func) {
}
prev = cur;
cur = cur->_next;
} while (cur != NULL);
} while (cur != nullptr);
if (match == NULL) {
return (E)NULL;
if (match == nullptr) {
return (E)nullptr;
}
if (match_prev == NULL) {
if (match_prev == nullptr) {
// Working on first
if (Atomic::cmpxchg(&_first, match, match->_next) == match) {
E ret = match->_data;
@ -100,9 +100,9 @@ E FilterQueue<E>::pop(MATCH_FUNC& match_func) {
// Failed, we need to restart to know the Node prior to the match.
first = load_first();
cur = first;
prev = NULL;
match = NULL;
match_prev = NULL;
prev = nullptr;
match = nullptr;
match_prev = nullptr;
} else {
match_prev->_next = match->_next;
E ret = match->_data;
@ -118,20 +118,20 @@ template <typename MATCH_FUNC>
E FilterQueue<E>::peek(MATCH_FUNC& match_func) {
Node* first = load_first();
Node* cur = first;
Node* match = NULL;
Node* match = nullptr;
if (cur == NULL) {
return (E)NULL;
if (cur == nullptr) {
return (E)nullptr;
}
do {
if (match_func(cur->_data)) {
match = cur;
}
cur = cur->_next;
} while (cur != NULL);
} while (cur != nullptr);
if (match == NULL) {
return (E)NULL;
if (match == nullptr) {
return (E)nullptr;
}
return (E)match->_data;

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023, 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
@ -218,7 +218,7 @@ char type2char_tab[T_CONFLICT+1] = {
// Map BasicType to Java type name
const char* type2name_tab[T_CONFLICT+1] = {
NULL, NULL, NULL, NULL,
nullptr, nullptr, nullptr, nullptr,
"boolean",
"char",
"float",
@ -252,7 +252,7 @@ const char* type2name(BasicType t) {
BasicType name2type(const char* name) {
for (int i = T_BOOLEAN; i <= T_VOID; i++) {
BasicType t = (BasicType)i;
if (type2name_tab[t] != NULL && 0 == strcmp(type2name_tab[t], name))
if (type2name_tab[t] != nullptr && 0 == strcmp(type2name_tab[t], name))
return t;
}
return T_ILLEGAL;

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023, 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
@ -505,7 +505,7 @@ void GrowableArrayWithAllocator<E, Derived>::expand_to(int new_capacity) {
for ( ; i < this->_len; i++) ::new ((void*)&newData[i]) E(this->_data[i]);
for ( ; i < this->_capacity; i++) ::new ((void*)&newData[i]) E();
for (i = 0; i < old_capacity; i++) this->_data[i].~E();
if (this->_data != NULL) {
if (this->_data != nullptr) {
static_cast<Derived*>(this)->deallocate(this->_data);
}
this->_data = newData;
@ -785,7 +785,7 @@ class GrowableArrayCHeap : public GrowableArrayWithAllocator<E, GrowableArrayCHe
static E* allocate(int max, MEMFLAGS flags) {
if (max == 0) {
return NULL;
return nullptr;
}
return (E*)GrowableArrayCHeapAllocator::allocate(max, sizeof(E), flags);
@ -842,7 +842,7 @@ class GrowableArrayIterator : public StackObj {
}
public:
GrowableArrayIterator() : _array(NULL), _position(0) { }
GrowableArrayIterator() : _array(nullptr), _position(0) { }
GrowableArrayIterator<E>& operator++() { ++_position; return *this; }
E operator*() { return _array->at(_position); }

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2023, 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
@ -67,14 +67,14 @@ template <MEMFLAGS F> inline void BasicHashtable<F>::free_entry(BasicHashtableEn
template <MEMFLAGS F> void BasicHashtable<F>::free_buckets() {
FREE_C_HEAP_ARRAY(HashtableBucket, _buckets);
_buckets = NULL;
_buckets = nullptr;
}
// Default overload, for types that are uninteresting.
template<typename T> static size_t literal_size(T) { return 0; }
static size_t literal_size(oop obj) {
if (obj == NULL) {
if (obj == nullptr) {
return 0;
}
@ -121,7 +121,7 @@ template <MEMFLAGS F> bool BasicHashtable<F>::resize(int new_size) {
// Allocate new buckets
HashtableBucket<F>* buckets_new = NEW_C_HEAP_ARRAY2_RETURN_NULL(HashtableBucket<F>, new_size, F, CURRENT_PC);
if (buckets_new == NULL) {
if (buckets_new == nullptr) {
return false;
}
@ -136,7 +136,7 @@ template <MEMFLAGS F> bool BasicHashtable<F>::resize(int new_size) {
// Move entries from the old table to a new table
for (int index_old = 0; index_old < table_size_old; index_old++) {
for (BasicHashtableEntry<F>* p = _buckets[index_old].get_entry(); p != NULL; ) {
for (BasicHashtableEntry<F>* p = _buckets[index_old].get_entry(); p != nullptr; ) {
BasicHashtableEntry<F>* next = p->next();
int index_new = hash_to_index(p->hash());
@ -175,9 +175,9 @@ template <class T, MEMFLAGS F> TableStatistics Hashtable<T, F>::statistics_calcu
for (int i = 0; i < this->table_size(); ++i) {
int count = 0;
for (HashtableEntry<T, F>* e = this->bucket(i);
e != NULL; e = e->next()) {
e != nullptr; e = e->next()) {
count++;
T l = (literal_load_barrier != NULL) ? literal_load_barrier(e) : e->literal();
T l = (literal_load_barrier != nullptr) ? literal_load_barrier(e) : e->literal();
literal_bytes += literal_size(l);
}
summary.add((double)count);
@ -202,7 +202,7 @@ template <class T, MEMFLAGS F> void Hashtable<T, F>::print() {
for (int i = 0; i < BasicHashtable<F>::table_size(); i++) {
HashtableEntry<T, F>* entry = bucket(i);
while(entry != NULL) {
while(entry != nullptr) {
tty->print("%d : ", i);
print_literal(entry->literal());
tty->cr();
@ -218,7 +218,7 @@ template <class T> void BasicHashtable<F>::verify_table(const char* table_name)
int max_bucket_number = 0;
for (int index = 0; index < table_size(); index++) {
int bucket_count = 0;
for (T* probe = (T*)bucket(index); probe != NULL; probe = probe->next()) {
for (T* probe = (T*)bucket(index); probe != nullptr; probe = probe->next()) {
probe->verify();
bucket_count++;
}
@ -237,7 +237,7 @@ template <class T> void BasicHashtable<F>::verify_table(const char* table_name)
if (_number_of_entries > 0 && log_is_enabled(Debug, hashtables)) {
for (int index = 0; index < table_size(); index++) {
int bucket_count = 0;
for (T* probe = (T*)bucket(index); probe != NULL; probe = probe->next()) {
for (T* probe = (T*)bucket(index); probe != nullptr; probe = probe->next()) {
log_debug(hashtables)("bucket %d hash " INTPTR_FORMAT, index, (intptr_t)probe->hash());
bucket_count++;
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2023, 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
@ -97,7 +97,7 @@ private:
public:
// Accessing
void clear() { _entry = NULL; }
void clear() { _entry = nullptr; }
// The following methods use order access methods to avoid race
// conditions in multiprocessor systems.
@ -154,7 +154,7 @@ protected:
// Used when moving the entry to another table or deleting entry.
// Clean up links.
void unlink_entry(BasicHashtableEntry<F>* entry) {
entry->set_next(NULL);
entry->set_next(nullptr);
--_number_of_entries;
}
@ -202,8 +202,8 @@ public:
return this->hash_to_index(compute_hash(name));
}
TableStatistics statistics_calculate(T (*literal_load_barrier)(HashtableEntry<T, F>*) = NULL);
void print_table_statistics(outputStream* st, const char *table_name, T (*literal_load_barrier)(HashtableEntry<T, F>*) = NULL);
TableStatistics statistics_calculate(T (*literal_load_barrier)(HashtableEntry<T, F>*) = nullptr);
void print_table_statistics(outputStream* st, const char *table_name, T (*literal_load_barrier)(HashtableEntry<T, F>*) = nullptr);
protected:

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2023, 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
@ -97,7 +97,7 @@ template <MEMFLAGS F> inline BasicHashtableEntry<F>* HashtableBucket<F>::get_ent
template <MEMFLAGS F> inline void BasicHashtable<F>::set_entry(int index, BasicHashtableEntry<F>* entry) {
_buckets[index].set_entry(entry);
if (entry != NULL) {
if (entry != nullptr) {
JFR_ONLY(_stats_rate.add();)
} else {
JFR_ONLY(_stats_rate.remove();)

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2023, 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
@ -38,7 +38,7 @@
const char* strchrnul_(const char *s, int c) {
const char* tmp = strchr(s, c);
return tmp == NULL ? s + strlen(s) : tmp;
return tmp == nullptr ? s + strlen(s) : tmp;
}
JSON::JSON(const char* text, bool silent, outputStream* st)
@ -48,10 +48,10 @@ JSON::JSON(const char* text, bool silent, outputStream* st)
}
void JSON::parse() {
assert(start != NULL, "Need something to parse");
if (start == NULL) {
assert(start != nullptr, "Need something to parse");
if (start == nullptr) {
_valid = false;
error(INTERNAL_ERROR, "JSON parser was called with a string that was NULL.");
error(INTERNAL_ERROR, "JSON parser was called with a string that was null.");
} else {
_valid = parse_json_value();
}
@ -158,7 +158,7 @@ bool JSON::parse_json_object() {
return false;
}
if (!callback(JSON_OBJECT_BEGIN, NULL, level++)) {
if (!callback(JSON_OBJECT_BEGIN, nullptr, level++)) {
return false;
}
@ -207,7 +207,7 @@ bool JSON::parse_json_object() {
}
assert(c == '}', "array parsing ended without object end token ('}')");
return callback(JSON_OBJECT_END, NULL, --level);
return callback(JSON_OBJECT_END, nullptr, --level);
}
// Should only be called when we actually have the start of an array
@ -222,7 +222,7 @@ bool JSON::parse_json_array() {
return false;
}
if (!callback(JSON_ARRAY_BEGIN, NULL, level++)) {
if (!callback(JSON_ARRAY_BEGIN, nullptr, level++)) {
return false;
}
@ -258,7 +258,7 @@ bool JSON::parse_json_array() {
}
assert(c == ']', "array parsing ended without array end token (']')");
return callback(JSON_ARRAY_END, NULL, --level);
return callback(JSON_ARRAY_END, nullptr, --level);
}
bool JSON::parse_json_string(bool key) {
@ -271,7 +271,7 @@ bool JSON::parse_json_string(bool key) {
}
end = strchr(pos, '"'); // TODO: escapes
if (end == NULL) {
if (end == nullptr) {
error(SYNTAX_ERROR, "String started here never ended. Expected \'\"\' before EOS.");
return false;
}
@ -384,7 +384,7 @@ bool JSON::parse_json_symbol(const char* name, JSON_TYPE symbol) {
mark_pos();
return false;
}
return callback(symbol, NULL, level);
return callback(symbol, nullptr, level);
}
void JSON::mark_pos() {
@ -476,7 +476,7 @@ bool JSON::expect_string(const char* expected_string, const char* error_msg, JSO
u_char c, expected_char;
size_t len;
assert(expected_string != NULL, "need non-null string");
assert(expected_string != nullptr, "need non-null string");
len = strlen(expected_string);
assert(len > 0, "need non-empty string");

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2023, 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
@ -60,10 +60,10 @@ template <class E> class LinkedListNode : public AnyObj {
}
protected:
LinkedListNode() : _next(NULL) { }
LinkedListNode() : _next(nullptr) { }
public:
LinkedListNode(const E& e): _data(e), _next(NULL) { }
LinkedListNode(const E& e): _data(e), _next(nullptr) { }
inline void set_next(LinkedListNode<E>* node) { _next = node; }
inline LinkedListNode<E> * next() const { return _next; }
@ -72,7 +72,7 @@ template <class E> class LinkedListNode : public AnyObj {
const E* peek() const { return &_data; }
bool equals(const E& t) const {
return equal<E>(_data, t, NULL);
return equal<E>(_data, t, nullptr);
}
};
@ -85,17 +85,17 @@ template <class E> class LinkedList : public AnyObj {
NONCOPYABLE(LinkedList<E>);
public:
LinkedList() : _head(NULL) { }
LinkedList() : _head(nullptr) { }
virtual ~LinkedList() {}
inline void set_head(LinkedListNode<E>* h) { _head = h; }
inline LinkedListNode<E>* head() const { return _head; }
inline bool is_empty() const { return head() == NULL; }
inline bool is_empty() const { return head() == nullptr; }
inline size_t size() const {
LinkedListNode<E>* p;
size_t count = 0;
for (p = head(); p != NULL; count++, p = p->next());
for (p = head(); p != nullptr; count++, p = p->next());
return count;
}
@ -126,7 +126,7 @@ template <class E> class LinkedList : public AnyObj {
LinkedListNode<E>* unlink_head() {
LinkedListNode<E>* h = this->head();
if (h != NULL) {
if (h != nullptr) {
this->set_head(h->next());
}
return h;
@ -143,7 +143,7 @@ template <class E, AnyObj::allocation_type T = AnyObj::C_HEAP,
protected:
Arena* _arena;
public:
LinkedListImpl() : _arena(NULL) { }
LinkedListImpl() : _arena(nullptr) { }
LinkedListImpl(Arena* a) : _arena(a) { }
virtual ~LinkedListImpl() {
@ -152,8 +152,8 @@ template <class E, AnyObj::allocation_type T = AnyObj::C_HEAP,
virtual void clear() {
LinkedListNode<E>* p = this->head();
this->set_head(NULL);
while (p != NULL) {
this->set_head(nullptr);
while (p != nullptr) {
LinkedListNode<E>* to_delete = p;
p = p->next();
delete_node(to_delete);
@ -163,7 +163,7 @@ template <class E, AnyObj::allocation_type T = AnyObj::C_HEAP,
// Add an entry to the linked list
virtual LinkedListNode<E>* add(const E& e) {
LinkedListNode<E>* node = this->new_node(e);
if (node != NULL) {
if (node != nullptr) {
this->add(node);
}
@ -171,7 +171,7 @@ template <class E, AnyObj::allocation_type T = AnyObj::C_HEAP,
}
virtual void add(LinkedListNode<E>* node) {
assert(node != NULL, "NULL pointer");
assert(node != nullptr, "nullptr pointer");
node->set_next(this->head());
this->set_head(node);
}
@ -181,22 +181,22 @@ template <class E, AnyObj::allocation_type T = AnyObj::C_HEAP,
virtual void move(LinkedList<E>* list) {
assert(list->storage_type() == this->storage_type(), "Different storage type");
LinkedListNode<E>* node = this->head();
while (node != NULL && node->next() != NULL) {
while (node != nullptr && node->next() != nullptr) {
node = node->next();
}
if (node == NULL) {
if (node == nullptr) {
this->set_head(list->head());
} else {
node->set_next(list->head());
}
// All entries are moved
list->set_head(NULL);
list->set_head(nullptr);
}
virtual bool add(const LinkedList<E>* list) {
LinkedListNode<E>* node = list->head();
while (node != NULL) {
if (this->add(*node->peek()) == NULL) {
while (node != nullptr) {
if (this->add(*node->peek()) == nullptr) {
return false;
}
node = node->next();
@ -207,7 +207,7 @@ template <class E, AnyObj::allocation_type T = AnyObj::C_HEAP,
virtual LinkedListNode<E>* find_node(const E& e) {
LinkedListNode<E>* p = this->head();
while (p != NULL && !p->equals(e)) {
while (p != nullptr && !p->equals(e)) {
p = p->next();
}
return p;
@ -215,23 +215,23 @@ template <class E, AnyObj::allocation_type T = AnyObj::C_HEAP,
E* find(const E& e) {
LinkedListNode<E>* node = find_node(e);
return (node == NULL) ? NULL : node->data();
return (node == nullptr) ? nullptr : node->data();
}
// Add an entry in front of the reference entry
LinkedListNode<E>* insert_before(const E& e, LinkedListNode<E>* ref_node) {
LinkedListNode<E>* node = this->new_node(e);
if (node == NULL) return NULL;
if (node == nullptr) return nullptr;
if (ref_node == this->head()) {
node->set_next(ref_node);
this->set_head(node);
} else {
LinkedListNode<E>* p = this->head();
while (p != NULL && p->next() != ref_node) {
while (p != nullptr && p->next() != ref_node) {
p = p->next();
}
assert(p != NULL, "ref_node not in the list");
assert(p != nullptr, "ref_node not in the list");
node->set_next(ref_node);
p->set_next(node);
}
@ -241,7 +241,7 @@ template <class E, AnyObj::allocation_type T = AnyObj::C_HEAP,
// Add an entry behind the reference entry
LinkedListNode<E>* insert_after(const E& e, LinkedListNode<E>* ref_node) {
LinkedListNode<E>* node = this->new_node(e);
if (node == NULL) return NULL;
if (node == nullptr) return nullptr;
node->set_next(ref_node->next());
ref_node->set_next(node);
return node;
@ -251,9 +251,9 @@ template <class E, AnyObj::allocation_type T = AnyObj::C_HEAP,
// Return true if the entry is successfully removed
virtual bool remove(const E& e) {
LinkedListNode<E>* tmp = this->head();
LinkedListNode<E>* prev = NULL;
LinkedListNode<E>* prev = nullptr;
while (tmp != NULL) {
while (tmp != nullptr) {
if (tmp->equals(e)) {
return remove_after(prev);
}
@ -266,16 +266,16 @@ template <class E, AnyObj::allocation_type T = AnyObj::C_HEAP,
// Remove the node after the reference entry
virtual bool remove_after(LinkedListNode<E>* prev) {
LinkedListNode<E>* to_delete;
if (prev == NULL) {
if (prev == nullptr) {
to_delete = this->unlink_head();
} else {
to_delete = prev->next();
if (to_delete != NULL) {
if (to_delete != nullptr) {
prev->set_next(to_delete->next());
}
}
if (to_delete != NULL) {
if (to_delete != nullptr) {
delete_node(to_delete);
return true;
}
@ -289,10 +289,10 @@ template <class E, AnyObj::allocation_type T = AnyObj::C_HEAP,
delete_node(node);
return true;
}
while (p != NULL && p->next() != node) {
while (p != nullptr && p->next() != node) {
p = p->next();
}
if (p != NULL) {
if (p != nullptr) {
p->set_next(node->next());
delete_node(node);
return true;
@ -302,20 +302,20 @@ template <class E, AnyObj::allocation_type T = AnyObj::C_HEAP,
}
virtual bool remove_before(LinkedListNode<E>* ref) {
assert(ref != NULL, "NULL pointer");
assert(ref != nullptr, "null pointer");
LinkedListNode<E>* p = this->head();
LinkedListNode<E>* to_delete = NULL; // to be deleted
LinkedListNode<E>* prev = NULL; // node before the node to be deleted
while (p != NULL && p != ref) {
LinkedListNode<E>* to_delete = nullptr; // to be deleted
LinkedListNode<E>* prev = nullptr; // node before the node to be deleted
while (p != nullptr && p != ref) {
prev = to_delete;
to_delete = p;
p = p->next();
}
if (p == NULL || to_delete == NULL) return false;
if (p == nullptr || to_delete == nullptr) return false;
assert(to_delete->next() == ref, "Wrong node to delete");
assert(prev == NULL || prev->next() == to_delete,
assert(prev == nullptr || prev->next() == to_delete,
"Sanity check");
if (prev == NULL) {
if (prev == nullptr) {
assert(to_delete == this->head(), "Must be head");
this->set_head(to_delete->next());
} else {
@ -331,7 +331,7 @@ template <class E, AnyObj::allocation_type T = AnyObj::C_HEAP,
LinkedListNode<E>* new_node(const E& e) const {
switch(T) {
case AnyObj::ARENA: {
assert(_arena != NULL, "Arena not set");
assert(_arena != nullptr, "Arena not set");
return new(_arena) LinkedListNode<E>(e);
}
case AnyObj::RESOURCE_AREA:
@ -350,7 +350,7 @@ template <class E, AnyObj::allocation_type T = AnyObj::C_HEAP,
default:
ShouldNotReachHere();
}
return NULL;
return nullptr;
}
// Delete linked list node object
@ -378,19 +378,19 @@ template <class E, int (*FUNC)(const E&, const E&),
virtual void move(LinkedList<E>* list) {
assert(list->storage_type() == this->storage_type(), "Different storage type");
LinkedListNode<E>* node;
while ((node = list->unlink_head()) != NULL) {
while ((node = list->unlink_head()) != nullptr) {
this->add(node);
}
assert(list->is_empty(), "All entries are moved");
}
virtual void add(LinkedListNode<E>* node) {
assert(node != NULL, "NULL pointer");
assert(node != nullptr, "nullptr pointer");
LinkedListNode<E>* tmp = this->head();
LinkedListNode<E>* prev = NULL;
LinkedListNode<E>* prev = nullptr;
int cmp_val;
while (tmp != NULL) {
while (tmp != nullptr) {
cmp_val = FUNC(*tmp->peek(), *node->peek());
if (cmp_val >= 0) {
break;
@ -399,7 +399,7 @@ template <class E, int (*FUNC)(const E&, const E&),
tmp = tmp->next();
}
if (prev != NULL) {
if (prev != nullptr) {
node->set_next(prev->next());
prev->set_next(node);
} else {
@ -415,16 +415,16 @@ template <class E, int (*FUNC)(const E&, const E&),
virtual LinkedListNode<E>* find_node(const E& e) {
LinkedListNode<E>* p = this->head();
while (p != NULL) {
while (p != nullptr) {
int comp_val = FUNC(*p->peek(), e);
if (comp_val == 0) {
return p;
} else if (comp_val > 0) {
return NULL;
return nullptr;
}
p = p->next();
}
return NULL;
return nullptr;
}
};
@ -436,17 +436,17 @@ template <class E> class LinkedListIterator : public StackObj {
public:
LinkedListIterator(LinkedListNode<E>* head) : _p(head) {}
bool is_empty() const { return _p == NULL; }
bool is_empty() const { return _p == nullptr; }
E* next() {
if (_p == NULL) return NULL;
if (_p == nullptr) return nullptr;
E* e = _p->data();
_p = _p->next();
return e;
}
const E* next() const {
if (_p == NULL) return NULL;
if (_p == nullptr) return nullptr;
const E* e = _p->peek();
_p = _p->next();
return e;

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2023, 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
@ -72,11 +72,11 @@ class LockFreeStack {
NONCOPYABLE(LockFreeStack);
public:
LockFreeStack() : _top(NULL) {}
LockFreeStack() : _top(nullptr) {}
~LockFreeStack() { assert(empty(), "stack not empty"); }
// Atomically removes the top object from this stack and returns a
// pointer to that object, or NULL if this stack is empty. Acts as a
// pointer to that object, or nullptr if this stack is empty. Acts as a
// full memory barrier. Subject to ABA behavior; callers must ensure
// usage is safe.
T* pop() {
@ -84,43 +84,43 @@ public:
T* old;
do {
old = result;
T* new_top = NULL;
if (result != NULL) {
T* new_top = nullptr;
if (result != nullptr) {
new_top = next(*result);
}
// CAS even on empty pop, for consistent membar behavior.
result = Atomic::cmpxchg(&_top, result, new_top);
} while (result != old);
if (result != NULL) {
set_next(*result, NULL);
if (result != nullptr) {
set_next(*result, nullptr);
}
return result;
}
// Atomically exchange the list of elements with NULL, returning the old
// Atomically exchange the list of elements with nullptr, returning the old
// list of elements. Acts as a full memory barrier.
// postcondition: empty()
T* pop_all() {
return Atomic::xchg(&_top, (T*)NULL);
return Atomic::xchg(&_top, (T*)nullptr);
}
// Atomically adds value to the top of this stack. Acts as a full
// memory barrier.
void push(T& value) {
assert(next(value) == NULL, "precondition");
assert(next(value) == nullptr, "precondition");
prepend_impl(&value, &value);
}
// Atomically adds the list of objects (designated by first and
// last) before the objects already in this stack, in the same order
// as in the list. Acts as a full memory barrier.
// precondition: next(last) == NULL.
// precondition: next(last) == nullptr.
// postcondition: top() == &first, next(last) == old top().
void prepend(T& first, T& last) {
assert(next(last) == NULL, "precondition");
assert(next(last) == nullptr, "precondition");
#ifdef ASSERT
for (T* p = &first; p != &last; p = next(*p)) {
assert(p != NULL, "invalid prepend list");
assert(p != nullptr, "invalid prepend list");
}
#endif
prepend_impl(&first, &last);
@ -134,16 +134,16 @@ public:
T* last = &first;
while (true) {
T* step_to = next(*last);
if (step_to == NULL) break;
if (step_to == nullptr) break;
last = step_to;
}
prepend_impl(&first, last);
}
// Return true if the stack is empty.
bool empty() const { return top() == NULL; }
bool empty() const { return top() == nullptr; }
// Return the most recently pushed element, or NULL if the stack is empty.
// Return the most recently pushed element, or nullptr if the stack is empty.
// The returned element is not removed from the stack.
T* top() const { return Atomic::load(&_top); }
@ -151,7 +151,7 @@ public:
// pops while the length is being determined.
size_t length() const {
size_t result = 0;
for (const T* current = top(); current != NULL; current = next(*current)) {
for (const T* current = top(); current != nullptr; current = next(*current)) {
++result;
}
return result;

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2023, 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
@ -56,7 +56,7 @@ NativeCallStack::NativeCallStack(address* pc, int frameCount) {
_stack[index] = pc[index];
}
for (; index < NMT_TrackingStackDepth; index ++) {
_stack[index] = NULL;
_stack[index] = nullptr;
}
}
@ -64,7 +64,7 @@ NativeCallStack::NativeCallStack(address* pc, int frameCount) {
int NativeCallStack::frames() const {
int index;
for (index = 0; index < NMT_TrackingStackDepth; index ++) {
if (_stack[index] == NULL) {
if (_stack[index] == nullptr) {
break;
}
}
@ -87,7 +87,7 @@ void NativeCallStack::print_on(outputStream* out, int indent) const {
} else {
for (int frame = 0; frame < NMT_TrackingStackDepth; frame ++) {
pc = get_frame(frame);
if (pc == NULL) break;
if (pc == nullptr) break;
// Print indent
for (int index = 0; index < indent; index ++) out->print(" ");
if (os::dll_address_to_function_name(pc, buf, sizeof(buf), &offset)) {

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2023, 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
@ -94,7 +94,7 @@ public:
// if it is an empty stack
inline bool is_empty() const {
DEBUG_ONLY(assert_not_fake();)
return _stack[0] == NULL;
return _stack[0] == nullptr;
}
// number of stack frames captured

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2023, 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
@ -116,7 +116,7 @@ NumberSeq::NumberSeq(double alpha) :
bool NumberSeq::check_nums(NumberSeq *total, int n, NumberSeq **parts) {
for (int i = 0; i < n; ++i) {
if (parts[i] != NULL && total->num() != parts[i]->num())
if (parts[i] != nullptr && total->num() != parts[i]->num())
return false;
}
return true;

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2023, 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
@ -39,15 +39,15 @@ ObjectBitSet<F>::BitMapFragment::BitMapFragment(uintptr_t granule, BitMapFragmen
template<MEMFLAGS F>
ObjectBitSet<F>::ObjectBitSet() :
_bitmap_fragments(32, 8*K),
_fragment_list(NULL),
_last_fragment_bits(NULL),
_fragment_list(nullptr),
_last_fragment_bits(nullptr),
_last_fragment_granule(UINTPTR_MAX) {
}
template<MEMFLAGS F>
ObjectBitSet<F>::~ObjectBitSet() {
BitMapFragment* current = _fragment_list;
while (current != NULL) {
while (current != nullptr) {
BitMapFragment* next = current->next();
delete current;
current = next;
@ -67,10 +67,10 @@ inline CHeapBitMap* ObjectBitSet<F>::get_fragment_bits(uintptr_t addr) {
if (granule == _last_fragment_granule) {
return _last_fragment_bits;
}
CHeapBitMap* bits = NULL;
CHeapBitMap* bits = nullptr;
CHeapBitMap** found = _bitmap_fragments.get(granule);
if (found != NULL) {
if (found != nullptr) {
bits = *found;
} else {
BitMapFragment* fragment = new BitMapFragment(granule, _fragment_list);

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023, 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
@ -47,7 +47,7 @@ outputStream::outputStream() {
_position = 0;
_precount = 0;
_indentation = 0;
_scratch = NULL;
_scratch = nullptr;
_scratch_len = 0;
}
@ -55,7 +55,7 @@ outputStream::outputStream(bool has_time_stamps) {
_position = 0;
_precount = 0;
_indentation = 0;
_scratch = NULL;
_scratch = nullptr;
_scratch_len = 0;
if (has_time_stamps) _stamp.update();
}
@ -246,7 +246,7 @@ void outputStream::date_stamp(bool guard,
static const int buffer_length = 32;
char buffer[buffer_length];
const char* iso8601_result = os::iso8601_time(buffer, buffer_length);
if (iso8601_result != NULL) {
if (iso8601_result != nullptr) {
print_raw(buffer);
} else {
print_raw(error_time);
@ -390,7 +390,7 @@ void stringStream::write(const char* s, size_t len) {
}
void stringStream::zero_terminate() {
assert(_buffer != NULL &&
assert(_buffer != nullptr &&
_written < _capacity, "sanity");
_buffer[_written] = '\0';
}
@ -463,7 +463,7 @@ static const char* make_log_name_internal(const char* log_name, const char* forc
const char* nametail = log_name;
// Compute buffer length
size_t buffer_length;
if (force_directory != NULL) {
if (force_directory != nullptr) {
buffer_length = strlen(force_directory) + strlen(os::file_separator()) +
strlen(basename) + 1;
} else {
@ -471,7 +471,7 @@ static const char* make_log_name_internal(const char* log_name, const char* forc
}
const char* pts = strstr(basename, "%p");
int pid_pos = (pts == NULL) ? -1 : (pts - nametail);
int pid_pos = (pts == nullptr) ? -1 : (pts - nametail);
if (pid_pos >= 0) {
jio_snprintf(pid_text, sizeof(pid_text), "pid%u", pid);
@ -479,21 +479,21 @@ static const char* make_log_name_internal(const char* log_name, const char* forc
}
pts = strstr(basename, "%t");
int tms_pos = (pts == NULL) ? -1 : (pts - nametail);
int tms_pos = (pts == nullptr) ? -1 : (pts - nametail);
if (tms_pos >= 0) {
buffer_length += strlen(tms);
}
// File name is too long.
if (buffer_length > JVM_MAXPATHLEN) {
return NULL;
return nullptr;
}
// Create big enough buffer.
char *buf = NEW_C_HEAP_ARRAY(char, buffer_length, mtInternal);
strcpy(buf, "");
if (force_directory != NULL) {
if (force_directory != nullptr) {
strcat(buf, force_directory);
strcat(buf, os::file_separator());
nametail = basename; // completely skip directory prefix
@ -501,8 +501,8 @@ static const char* make_log_name_internal(const char* log_name, const char* forc
// who is first, %p or %t?
int first = -1, second = -1;
const char *p1st = NULL;
const char *p2nd = NULL;
const char *p1st = nullptr;
const char *p2nd = nullptr;
if (pid_pos >= 0 && tms_pos >= 0) {
// contains both %p and %t
@ -560,7 +560,7 @@ const char* make_log_name(const char* log_name, const char* force_directory) {
fileStream::fileStream(const char* file_name) {
_file = os::fopen(file_name, "w");
if (_file != NULL) {
if (_file != nullptr) {
_need_close = true;
} else {
warning("Cannot open file %s due to %s\n", file_name, os::strerror(errno));
@ -570,7 +570,7 @@ fileStream::fileStream(const char* file_name) {
fileStream::fileStream(const char* file_name, const char* opentype) {
_file = os::fopen(file_name, opentype);
if (_file != NULL) {
if (_file != nullptr) {
_need_close = true;
} else {
warning("Cannot open file %s due to %s\n", file_name, os::strerror(errno));
@ -579,7 +579,7 @@ fileStream::fileStream(const char* file_name, const char* opentype) {
}
void fileStream::write(const char* s, size_t len) {
if (_file != NULL) {
if (_file != nullptr) {
// Make an unused local variable to avoid warning from gcc compiler.
size_t count = fwrite(s, 1, len, _file);
update_position(s, len);
@ -588,7 +588,7 @@ void fileStream::write(const char* s, size_t len) {
long fileStream::fileSize() {
long size = -1;
if (_file != NULL) {
if (_file != nullptr) {
long pos = ::ftell(_file);
if (pos < 0) return pos;
if (::fseek(_file, 0, SEEK_END) == 0) {
@ -600,8 +600,8 @@ long fileStream::fileSize() {
}
char* fileStream::readln(char *data, int count ) {
char * ret = NULL;
if (_file != NULL) {
char * ret = nullptr;
if (_file != nullptr) {
ret = ::fgets(data, count, _file);
// Get rid of annoying \n char only if it is present.
size_t len = ::strlen(data);
@ -613,14 +613,14 @@ char* fileStream::readln(char *data, int count ) {
}
fileStream::~fileStream() {
if (_file != NULL) {
if (_file != nullptr) {
if (_need_close) fclose(_file);
_file = NULL;
_file = nullptr;
}
}
void fileStream::flush() {
if (_file != NULL) {
if (_file != nullptr) {
fflush(_file);
}
}
@ -636,7 +636,7 @@ void fdStream::write(const char* s, size_t len) {
}
}
defaultStream* defaultStream::instance = NULL;
defaultStream* defaultStream::instance = nullptr;
int defaultStream::_output_fd = 1;
int defaultStream::_error_fd = 2;
FILE* defaultStream::_output_stream = stdout;
@ -658,14 +658,14 @@ bool defaultStream::has_log_file() {
// For safer printing during fatal error handling, do not init logfile
// if a VM error has been reported.
if (!_inited && !VMError::is_error_reported()) init();
return _log_file != NULL;
return _log_file != nullptr;
}
fileStream* defaultStream::open_file(const char* log_name) {
const char* try_name = make_log_name(log_name, NULL);
if (try_name == NULL) {
const char* try_name = make_log_name(log_name, nullptr);
if (try_name == nullptr) {
warning("Cannot open file %s: file name is too long.\n", log_name);
return NULL;
return nullptr;
}
fileStream* file = new (mtInternal) fileStream(try_name);
@ -679,9 +679,9 @@ fileStream* defaultStream::open_file(const char* log_name) {
// Note: This feature is for maintainer use only. No need for L10N.
jio_printf("Warning: Cannot open log file: %s\n", log_name);
try_name = make_log_name(log_name, os::get_temp_directory());
if (try_name == NULL) {
if (try_name == nullptr) {
warning("Cannot open file %s: file name is too long for directory %s.\n", log_name, os::get_temp_directory());
return NULL;
return nullptr;
}
jio_printf("Warning: Forcing option -XX:LogFile=%s\n", try_name);
@ -693,20 +693,20 @@ fileStream* defaultStream::open_file(const char* log_name) {
}
delete file;
return NULL;
return nullptr;
}
void defaultStream::init_log() {
// %%% Need a MutexLocker?
const char* log_name = LogFile != NULL ? LogFile : "hotspot_%p.log";
const char* log_name = LogFile != nullptr ? LogFile : "hotspot_%p.log";
fileStream* file = open_file(log_name);
if (file != NULL) {
if (file != nullptr) {
_log_file = file;
_outer_xmlStream = new(mtInternal) xmlStream(file);
start_log();
} else {
// and leave xtty as NULL
// and leave xtty as nullptr
LogVMOutput = false;
DisplayVMOutput = true;
LogCompilation = false;
@ -748,27 +748,27 @@ void defaultStream::start_log() {
Arguments::print_jvm_args_on(xs->text());
xs->tail("args");
}
if (Arguments::java_command() != NULL) {
if (Arguments::java_command() != nullptr) {
xs->head("command"); xs->text()->print_cr("%s", Arguments::java_command());
xs->tail("command");
}
if (Arguments::sun_java_launcher() != NULL) {
if (Arguments::sun_java_launcher() != nullptr) {
xs->head("launcher"); xs->text()->print_cr("%s", Arguments::sun_java_launcher());
xs->tail("launcher");
}
if (Arguments::system_properties() != NULL) {
if (Arguments::system_properties() != nullptr) {
xs->head("properties");
// Print it as a java-style property list.
// System properties don't generally contain newlines, so don't bother with unparsing.
outputStream *text = xs->text();
for (SystemProperty* p = Arguments::system_properties(); p != NULL; p = p->next()) {
assert(p->key() != NULL, "p->key() is NULL");
for (SystemProperty* p = Arguments::system_properties(); p != nullptr; p = p->next()) {
assert(p->key() != nullptr, "p->key() is nullptr");
if (p->readable()) {
// Print in two stages to avoid problems with long
// keys/values.
text->print_raw(p->key());
text->put('=');
assert(p->value() != NULL, "p->value() is NULL");
assert(p->value() != nullptr, "p->value() is nullptr");
text->print_raw_cr(p->value());
}
}
@ -795,10 +795,10 @@ void defaultStream::finish_log() {
xs->flush();
fileStream* file = _log_file;
_log_file = NULL;
_log_file = nullptr;
delete _outer_xmlStream;
_outer_xmlStream = NULL;
_outer_xmlStream = nullptr;
file->flush();
delete file;
@ -818,8 +818,8 @@ void defaultStream::finish_log_on_error(char *buf, int buflen) {
xs->flush();
fileStream* file = _log_file;
_log_file = NULL;
_outer_xmlStream = NULL;
_log_file = nullptr;
_outer_xmlStream = nullptr;
if (file) {
file->flush();
@ -837,10 +837,10 @@ intx defaultStream::hold(intx writer_id) {
writer_id == NO_WRITER ||
// bootstrap problem
tty_lock == NULL ||
tty_lock == nullptr ||
// can't grab a lock if current Thread isn't set
Thread::current_or_null() == NULL ||
Thread::current_or_null() == nullptr ||
// developer hook
!SerializeVMOutput ||
@ -911,7 +911,7 @@ void defaultStream::write(const char* s, size_t len) {
}
intx ttyLocker::hold_tty() {
if (defaultStream::instance == NULL) return defaultStream::NO_WRITER;
if (defaultStream::instance == nullptr) return defaultStream::NO_WRITER;
intx thread_id = os::current_thread_id();
return defaultStream::instance->hold(thread_id);
}
@ -933,9 +933,9 @@ bool ttyLocker::release_tty_if_locked() {
}
void ttyLocker::break_tty_lock_for_safepoint(intx holder) {
if (defaultStream::instance != NULL &&
if (defaultStream::instance != nullptr &&
defaultStream::instance->writer() == holder) {
if (xtty != NULL) {
if (xtty != nullptr) {
xtty->print_cr("<!-- safepoint while printing -->");
}
defaultStream::instance->release(holder);
@ -944,7 +944,7 @@ void ttyLocker::break_tty_lock_for_safepoint(intx holder) {
}
void ostream_init() {
if (defaultStream::instance == NULL) {
if (defaultStream::instance == nullptr) {
defaultStream::instance = new(mtInternal) defaultStream();
tty = defaultStream::instance;
@ -981,8 +981,8 @@ void ostream_exit() {
delete tmp;
}
delete defaultStream::instance;
xtty = NULL;
defaultStream::instance = NULL;
xtty = nullptr;
defaultStream::instance = nullptr;
}
// ostream_abort() is called by os::abort() when VM is about to die.
@ -990,7 +990,7 @@ void ostream_abort() {
// Here we can't delete tty, just flush its output
if (tty) tty->flush();
if (defaultStream::instance != NULL) {
if (defaultStream::instance != nullptr) {
static char buf[4096];
defaultStream::instance->finish_log_on_error(buf, sizeof(buf));
}
@ -1139,7 +1139,7 @@ bool networkStream::connect(const char *ip, short port) {
server.sin_addr.s_addr = inet_addr(ip);
if (server.sin_addr.s_addr == (uint32_t)-1) {
struct hostent* host = os::get_host_by_name((char*)ip);
if (host != NULL) {
if (host != nullptr) {
memcpy(&server.sin_addr, host->h_addr_list[0], host->h_length);
} else {
return false;

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023, 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
@ -128,7 +128,7 @@ class outputStream : public CHeapObjBase {
// flushing
virtual void flush() {}
virtual void write(const char* str, size_t len) = 0;
virtual void rotate_log(bool force, outputStream* out = NULL) {} // GC log rotation
virtual void rotate_log(bool force, outputStream* out = nullptr) {} // GC log rotation
virtual ~outputStream() {} // close properly on deletion
// Caller may specify their own scratch buffer to use for printing; otherwise,
@ -235,18 +235,18 @@ class fileStream : public outputStream {
FILE* _file;
bool _need_close;
public:
fileStream() { _file = NULL; _need_close = false; }
fileStream() { _file = nullptr; _need_close = false; }
fileStream(const char* file_name);
fileStream(const char* file_name, const char* opentype);
fileStream(FILE* file, bool need_close = false) { _file = file; _need_close = need_close; }
~fileStream();
bool is_open() const { return _file != NULL; }
bool is_open() const { return _file != nullptr; }
virtual void write(const char* c, size_t len);
size_t read(void *data, size_t size, size_t count) { return _file != NULL ? ::fread(data, size, count, _file) : 0; }
size_t read(void *data, size_t size, size_t count) { return _file != nullptr ? ::fread(data, size, count, _file) : 0; }
char* readln(char *data, int count);
int eof() { return _file != NULL ? feof(_file) : -1; }
int eof() { return _file != nullptr ? feof(_file) : -1; }
long fileSize();
void rewind() { if (_file != NULL) ::rewind(_file); }
void rewind() { if (_file != nullptr) ::rewind(_file); }
void flush();
};

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2023, 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
@ -46,7 +46,7 @@ PreserveExceptionMark::~PreserveExceptionMark() {
exception->print_string());
}
if (_preserved_exception_oop() != NULL) {
if (_preserved_exception_oop() != nullptr) {
_thread->set_pending_exception(_preserved_exception_oop(), _preserved_exception_file, _preserved_exception_line);
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2023, 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
@ -112,7 +112,7 @@ public:
Node* const* bucket = old_table;
while (bucket < &old_table[old_size]) {
Node* node = *bucket;
while (node != NULL) {
while (node != nullptr) {
Node* next = node->_next;
unsigned hash = HASH(node->_key);
unsigned index = hash % new_size;

@ -39,11 +39,11 @@ public:
ResourceHashtableNode* _next;
ResourceHashtableNode(unsigned hash, K const& key, V const& value) :
_hash(hash), _key(key), _value(value), _next(NULL) {}
_hash(hash), _key(key), _value(value), _next(nullptr) {}
// Create a node with a default-constructed value.
ResourceHashtableNode(unsigned hash, K const& key) :
_hash(hash), _key(key), _value(), _next(NULL) {}
_hash(hash), _key(key), _value(), _next(nullptr) {}
};
template<
@ -74,7 +74,7 @@ class ResourceHashtableBase : public STORAGE {
Node** lookup_node(unsigned hash, K const& key) {
unsigned index = hash % table_size();
Node** ptr = bucket_at(index);
while (*ptr != NULL) {
while (*ptr != nullptr) {
Node* node = *ptr;
if (node->_hash == hash && EQUALS(key, node->_key)) {
break;
@ -102,7 +102,7 @@ class ResourceHashtableBase : public STORAGE {
const unsigned sz = table_size();
while (bucket < bucket_at(sz)) {
Node* node = *bucket;
while (node != NULL) {
while (node != nullptr) {
Node* cur = node;
node = node->_next;
delete cur;
@ -117,16 +117,16 @@ class ResourceHashtableBase : public STORAGE {
int number_of_entries() const { return _number_of_entries; }
bool contains(K const& key) const {
return get(key) != NULL;
return get(key) != nullptr;
}
V* get(K const& key) const {
unsigned hv = HASH(key);
Node const** ptr = lookup_node(hv, key);
if (*ptr != NULL) {
if (*ptr != nullptr) {
return const_cast<V*>(&(*ptr)->_value);
} else {
return NULL;
return nullptr;
}
}
@ -138,7 +138,7 @@ class ResourceHashtableBase : public STORAGE {
bool put(K const& key, V const& value) {
unsigned hv = HASH(key);
Node** ptr = lookup_node(hv, key);
if (*ptr != NULL) {
if (*ptr != nullptr) {
(*ptr)->_value = value;
return false;
} else {
@ -160,7 +160,7 @@ class ResourceHashtableBase : public STORAGE {
V* put_if_absent(K const& key, bool* p_created) {
unsigned hv = HASH(key);
Node** ptr = lookup_node(hv, key);
if (*ptr == NULL) {
if (*ptr == nullptr) {
if (ALLOC_TYPE == AnyObj::C_HEAP) {
*ptr = new (MEM_TYPE) Node(hv, key);
} else {
@ -182,7 +182,7 @@ class ResourceHashtableBase : public STORAGE {
V* put_if_absent(K const& key, V const& value, bool* p_created) {
unsigned hv = HASH(key);
Node** ptr = lookup_node(hv, key);
if (*ptr == NULL) {
if (*ptr == nullptr) {
if (ALLOC_TYPE == AnyObj::C_HEAP) {
*ptr = new (MEM_TYPE) Node(hv, key, value);
} else {
@ -202,7 +202,7 @@ class ResourceHashtableBase : public STORAGE {
Node** ptr = lookup_node(hv, key);
Node* node = *ptr;
if (node != NULL) {
if (node != nullptr) {
*ptr = node->_next;
if (ALLOC_TYPE == AnyObj::C_HEAP) {
delete node;
@ -232,7 +232,7 @@ class ResourceHashtableBase : public STORAGE {
while (cnt > 0 && bucket < bucket_at(sz)) {
Node* node = *bucket;
while (node != NULL) {
while (node != nullptr) {
bool cont = function(node->_key, node->_value);
if (!cont) { return; }
node = node->_next;
@ -260,7 +260,7 @@ class ResourceHashtableBase : public STORAGE {
const unsigned sz = table_size();
for (unsigned index = 0; index < sz; index++) {
Node** ptr = bucket_at(index);
while (*ptr != NULL) {
while (*ptr != nullptr) {
Node* node = *ptr;
// do_entry must clean up the key and value in Node.
bool clean = iter->do_entry(node->_key, node->_value);
@ -286,7 +286,7 @@ class ResourceHashtableBase : public STORAGE {
while (bucket < bucket_at(sz)) {
Node* node = *bucket;
int count = 0;
while (node != NULL) {
while (node != nullptr) {
literal_bytes += size_function(node->_key, node->_value);
count++;
node = node->_next;

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 2023, 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
@ -104,7 +104,7 @@ public:
size_t max_cache_size = 4, size_t max_size = 0);
inline ~Stack() { clear(true); }
inline bool is_empty() const { return this->_cur_seg == NULL; }
inline bool is_empty() const { return this->_cur_seg == nullptr; }
inline bool is_full() const { return this->_full_seg_size >= this->max_size(); }
// Performance sensitive code should use is_empty() instead of size() == 0 and
@ -169,7 +169,7 @@ public:
ResourceStack(size_t segment_size): Stack<E, F>(segment_size, max_uintx)
{ }
// Set the segment pointers to NULL so the parent dtor does not free them;
// Set the segment pointers to nullptr so the parent dtor does not free them;
// that must be done by the ResourceMark code.
~ResourceStack() { Stack<E, F>::reset(true); }
@ -189,7 +189,7 @@ public:
Stack<E, F>& stack() const { return _stack; }
bool is_empty() const { return _cur_seg == NULL; }
bool is_empty() const { return _cur_seg == nullptr; }
E next() { return *next_addr(); }
E* next_addr();

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 2023, 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
@ -187,7 +187,7 @@ NOINLINE void Stack<E, F>::pop_segment()
DEBUG_ONLY(zap_segment(_cur_seg, true);)
free(_cur_seg, segment_bytes());
}
const bool at_empty_transition = prev == NULL;
const bool at_empty_transition = prev == nullptr;
this->_cur_seg = prev;
this->_cur_seg_size = this->_seg_size;
this->_full_seg_size -= at_empty_transition ? 0 : this->_seg_size;
@ -198,7 +198,7 @@ template <class E, MEMFLAGS F>
void Stack<E, F>::free_segments(E* seg)
{
const size_t bytes = segment_bytes();
while (seg != NULL) {
while (seg != nullptr) {
E* const prev = get_link(seg);
free(seg, bytes);
seg = prev;
@ -210,10 +210,10 @@ void Stack<E, F>::reset(bool reset_cache)
{
this->_cur_seg_size = this->_seg_size; // So push() will alloc a new segment.
this->_full_seg_size = 0;
_cur_seg = NULL;
_cur_seg = nullptr;
if (reset_cache) {
this->_cache_size = 0;
_cache = NULL;
_cache = nullptr;
}
}
@ -227,7 +227,7 @@ void Stack<E, F>::verify(bool at_empty_transition) const
assert(this->_full_seg_size % this->_seg_size == 0, "not a multiple");
assert(at_empty_transition || is_empty() == (size() == 0), "mismatch");
assert((_cache == NULL) == (this->cache_size() == 0), "mismatch");
assert((_cache == nullptr) == (this->cache_size() == 0), "mismatch");
if (is_empty()) {
assert(this->_cur_seg_size == this->segment_size(), "sanity");

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2023, 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
@ -36,7 +36,7 @@ int StringUtils::replace_no_expand(char* string, const char* from, const char* t
size_t to_len = strlen(to);
assert(from_len >= to_len, "must not expand input");
for (char* dst = string; *dst && (dst = strstr(dst, from)) != NULL;) {
for (char* dst = string; *dst && (dst = strstr(dst, from)) != nullptr;) {
char* left_over = dst + from_len;
memmove(dst, to, to_len); // does not copy trailing 0 of <to>
dst += to_len; // skip over the replacement.
@ -48,7 +48,7 @@ int StringUtils::replace_no_expand(char* string, const char* from, const char* t
}
double StringUtils::similarity(const char* str1, size_t len1, const char* str2, size_t len2) {
assert(str1 != NULL && str2 != NULL, "sanity");
assert(str1 != nullptr && str2 != nullptr, "sanity");
// filter out zero-length strings else we will underflow on len-1 below
if (len1 == 0 || len2 == 0) {

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2023, 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
@ -44,8 +44,8 @@ print_on(outputStream* st, int count,
const char* left, // "U5: ["
const char* right // "] (values=%d/length=%d)\n"
) {
if (left == NULL) left = "U5: [";
if (right == NULL) right = "] (values=%d/length=%d)\n";
if (left == nullptr) left = "U5: [";
if (right == nullptr) right = "] (values=%d/length=%d)\n";
int printed = 0;
st->print("%s", left);
for (;;) {

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023, 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
@ -306,7 +306,7 @@ class UNSIGNED5 : AllStatic {
// The %d formats are for the number of printed items and
// their length in bytes, if you want to see that also.
void print_on(outputStream* st, int count = -1,
const char* left = NULL, const char* right = NULL);
const char* left = nullptr, const char* right = nullptr);
};
// Writer example use
@ -323,8 +323,8 @@ class UNSIGNED5 : AllStatic {
OFF _position;
public:
Writer(const ARR& array)
: _array(const_cast<ARR&>(array)), _limit_ptr(NULL), _position(0) {
// Note: if _limit_ptr is NULL, the ARR& is never reassigned,
: _array(const_cast<ARR&>(array)), _limit_ptr(nullptr), _position(0) {
// Note: if _limit_ptr is nullptr, the ARR& is never reassigned,
// because has_limit is false. So the const_cast here is safe.
assert(!has_limit(), "this writer cannot be growable");
}
@ -363,7 +363,7 @@ class UNSIGNED5 : AllStatic {
ARR array() { return _array; }
OFF position() { return _position; }
void set_position(OFF position) { _position = position; }
bool has_limit() { return _limit_ptr != NULL; }
bool has_limit() { return _limit_ptr != nullptr; }
OFF limit() { assert(has_limit(), "needs limit"); return *_limit_ptr; }
OFF remaining() { return limit() - position(); }
};

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023, 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
@ -237,7 +237,7 @@ void UTF8::as_quoted_ascii(const char* utf8_str, int utf8_length, char* buf, int
// no longer used, but could be useful to test output of UTF8::as_quoted_ascii
const char* UTF8::from_quoted_ascii(const char* quoted_ascii_str) {
const char *ptr = quoted_ascii_str;
char* result = NULL;
char* result = nullptr;
while (*ptr != '\0') {
char c = *ptr;
if (c < 32 || c >= 127) break;
@ -248,11 +248,11 @@ const char* UTF8::from_quoted_ascii(const char* quoted_ascii_str) {
}
// everything up to this point was ok.
int length = ptr - quoted_ascii_str;
char* buffer = NULL;
char* buffer = nullptr;
for (int round = 0; round < 2; round++) {
while (*ptr != '\0') {
if (*ptr != '\\') {
if (buffer != NULL) {
if (buffer != nullptr) {
buffer[length] = *ptr;
}
length++;
@ -280,7 +280,7 @@ const char* UTF8::from_quoted_ascii(const char* quoted_ascii_str) {
ShouldNotReachHere();
}
}
if (buffer == NULL) {
if (buffer == nullptr) {
char utf8_buffer[4];
char* next = (char*)utf8_write((u_char*)utf8_buffer, value);
length += next - utf8_buffer;
@ -290,10 +290,10 @@ const char* UTF8::from_quoted_ascii(const char* quoted_ascii_str) {
}
break;
}
case 't': if (buffer != NULL) buffer[length] = '\t'; ptr += 2; length++; break;
case 'n': if (buffer != NULL) buffer[length] = '\n'; ptr += 2; length++; break;
case 'r': if (buffer != NULL) buffer[length] = '\r'; ptr += 2; length++; break;
case 'f': if (buffer != NULL) buffer[length] = '\f'; ptr += 2; length++; break;
case 't': if (buffer != nullptr) buffer[length] = '\t'; ptr += 2; length++; break;
case 'n': if (buffer != nullptr) buffer[length] = '\n'; ptr += 2; length++; break;
case 'r': if (buffer != nullptr) buffer[length] = '\r'; ptr += 2; length++; break;
case 'f': if (buffer != nullptr) buffer[length] = '\f'; ptr += 2; length++; break;
default:
ShouldNotReachHere();
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023, 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
@ -73,14 +73,14 @@ class UTF8 : AllStatic {
// Utility methods
// Returns NULL if 'c' it not found. This only works as long
// Returns nullptr if 'c' it not found. This only works as long
// as 'c' is an ASCII character
static const jbyte* strrchr(const jbyte* base, int length, jbyte c) {
assert(length >= 0, "sanity check");
assert(c >= 0, "does not work for non-ASCII characters");
// Skip backwards in string until 'c' is found or end is reached
while(--length >= 0 && base[length] != c);
return (length < 0) ? NULL : &base[length];
return (length < 0) ? nullptr : &base[length];
}
static bool equal(const jbyte* base1, int length1, const jbyte* base2,int length2);
static bool is_supplementary_character(const unsigned char* str);

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -28,10 +28,10 @@
#include "runtime/os.hpp"
#include "utilities/virtualizationSupport.hpp"
static void *dlHandle = NULL;
static void *dlHandle = nullptr;
static GuestLib_StatGet_t GuestLib_StatGet = NULL;
static GuestLib_StatFree_t GuestLib_StatFree = NULL;
static GuestLib_StatGet_t GuestLib_StatGet = nullptr;
static GuestLib_StatFree_t GuestLib_StatFree = nullptr;
static bool has_host_information = false;
static bool has_resource_information = false;
@ -48,22 +48,22 @@ void VirtualizationSupport::initialize() {
dlHandle = os::dll_load("vmGuestLib", ebuf, sizeof ebuf);
#ifdef LINUX
if (dlHandle == NULL) {
if (dlHandle == nullptr) {
// the open-vm-tools have a different guest lib name
// on some distros e.g. SLES12 the open-vm-tools are the default,
// so use the different libname as a fallback
dlHandle = os::dll_load("/usr/lib64/libguestlib.so.0", ebuf, sizeof ebuf);
}
#endif
if (dlHandle == NULL) {
if (dlHandle == nullptr) {
return;
}
GuestLib_StatGet = CAST_TO_FN_PTR(GuestLib_StatGet_t, os::dll_lookup(dlHandle, "VMGuestLib_StatGet"));
GuestLib_StatFree = CAST_TO_FN_PTR(GuestLib_StatFree_t, os::dll_lookup(dlHandle, "VMGuestLib_StatFree"));
if (GuestLib_StatGet != NULL && GuestLib_StatFree != NULL) {
char* result_info = NULL;
if (GuestLib_StatGet != nullptr && GuestLib_StatFree != nullptr) {
char* result_info = nullptr;
size_t result_size = 0;
VMGuestLibError sg_error = GuestLib_StatGet("text", "resources", &result_info, &result_size);
if (sg_error == VMGUESTLIB_ERROR_SUCCESS) {
@ -91,8 +91,8 @@ void VirtualizationSupport::print_virtualization_info(outputStream* st) {
st->print_cr("%s", extended_resource_info_at_startup);
}
// current resource info
if (GuestLib_StatGet != NULL && GuestLib_StatFree != NULL) {
char* result_info = NULL;
if (GuestLib_StatGet != nullptr && GuestLib_StatFree != nullptr) {
char* result_info = nullptr;
size_t result_size = 0;
VMGuestLibError sg_error = GuestLib_StatGet("text", "resources", &result_info, &result_size);
if (sg_error == VMGUESTLIB_ERROR_SUCCESS) {

@ -124,17 +124,17 @@ static const char* env_list[] = {
// A simple parser for -XX:OnError, usage:
// ptr = OnError;
// while ((cmd = next_OnError_command(buffer, sizeof(buffer), &ptr) != NULL)
// while ((cmd = next_OnError_command(buffer, sizeof(buffer), &ptr) != nullptr)
// ... ...
static char* next_OnError_command(char* buf, int buflen, const char** ptr) {
if (ptr == NULL || *ptr == NULL) return NULL;
if (ptr == nullptr || *ptr == nullptr) return nullptr;
const char* cmd = *ptr;
// skip leading blanks or ';'
while (*cmd == ' ' || *cmd == ';') cmd++;
if (*cmd == '\0') return NULL;
if (*cmd == '\0') return nullptr;
const char * cmdend = cmd;
while (*cmdend != '\0' && *cmdend != ';') cmdend++;
@ -146,11 +146,11 @@ static char* next_OnError_command(char* buf, int buflen, const char** ptr) {
}
static void print_bug_submit_message(outputStream *out, Thread *thread) {
if (out == NULL) return;
if (out == nullptr) return;
const char *url = Arguments::java_vendor_url_bug();
if (url == NULL || *url == '\0')
if (url == nullptr || *url == '\0')
url = JDK_Version::runtime_vendor_vm_bug_url();
if (url != NULL && *url != '\0') {
if (url != nullptr && *url != '\0') {
out->print_raw_cr("# If you would like to submit a bug report, please visit:");
out->print_raw ("# ");
out->print_raw_cr(url);
@ -182,7 +182,7 @@ char* VMError::error_string(char* buf, int buflen) {
"%s (0x%x) at pc=" PTR_FORMAT ", pid=%d, tid=" UINTX_FORMAT,
signame, _id, _pc,
os::current_process_id(), os::current_thread_id());
} else if (_filename != NULL && _lineno > 0) {
} else if (_filename != nullptr && _lineno > 0) {
// skip directory names
int n = jio_snprintf(buf, buflen,
"Internal Error at %s:%d, pid=%d, tid=" UINTX_FORMAT,
@ -271,7 +271,7 @@ static bool add_if_absent(address value, address* list, int list_capacity) {
* been printed. If the code unit is an InterpreterCodelet or StubCodeDesc, it is
* only printed if `is_crash_pc` is true.
*
* @param printed array of code units that have already been printed (delimited by NULL entry)
* @param printed array of code units that have already been printed (delimited by nullptr entry)
* @param printed_capacity the capacity of `printed`
* @return true if the code unit was printed, false otherwise
*/
@ -426,13 +426,13 @@ static void report_vm_version(outputStream* st, char* buf, int buflen) {
// VM version
st->print_cr("#");
JDK_Version::current().to_string(buf, buflen);
const char* runtime_name = JDK_Version::runtime_name() != NULL ?
const char* runtime_name = JDK_Version::runtime_name() != nullptr ?
JDK_Version::runtime_name() : "";
const char* runtime_version = JDK_Version::runtime_version() != NULL ?
const char* runtime_version = JDK_Version::runtime_version() != nullptr ?
JDK_Version::runtime_version() : "";
const char* vendor_version = JDK_Version::runtime_vendor_version() != NULL ?
const char* vendor_version = JDK_Version::runtime_vendor_version() != nullptr ?
JDK_Version::runtime_vendor_version() : "";
const char* jdk_debug_level = VM_Version::printable_jdk_debug_level() != NULL ?
const char* jdk_debug_level = VM_Version::printable_jdk_debug_level() != nullptr ?
VM_Version::printable_jdk_debug_level() : "";
st->print_cr("# JRE version: %s%s%s (%s) (%sbuild %s)", runtime_name,
@ -671,7 +671,7 @@ void VMError::report(outputStream* st, bool _verbose) {
st->print("%s", buf);
st->print(" (0x%x)", _id); // signal number
st->print(" at pc=" PTR_FORMAT, p2i(_pc));
if (_siginfo != NULL && os::signal_sent_by_kill(_siginfo)) {
if (_siginfo != nullptr && os::signal_sent_by_kill(_siginfo)) {
st->print(" (sent by kill)");
}
} else {
@ -680,7 +680,7 @@ void VMError::report(outputStream* st, bool _verbose) {
} else {
st->print("Out of Memory Error");
}
if (_filename != NULL && _lineno > 0) {
if (_filename != nullptr && _lineno > 0) {
#ifdef PRODUCT
// In product mode chop off pathname
const char *file = get_filename_only();
@ -838,7 +838,7 @@ void VMError::report(outputStream* st, bool _verbose) {
_verbose && _thread != nullptr && (_thread->is_Named_thread()))
// printing Java thread stack trace if it is involved in GC crash
Thread* thread = ((NamedThread *)_thread)->processed_thread();
if (thread != NULL && thread->is_Java_thread()) {
if (thread != nullptr && thread->is_Java_thread()) {
JavaThread* jt = JavaThread::cast(thread);
st->print_cr("JavaThread " PTR_FORMAT " (nid = %d) was being processed", p2i(jt), jt->osthread()->thread_id());
print_stack_trace(st, jt, buf, sizeof(buf), true);
@ -1006,7 +1006,7 @@ void VMError::report(outputStream* st, bool _verbose) {
STEP_IF("printing heap information", _verbose)
GCLogPrecious::print_on_error(st);
if (Universe::heap() != NULL) {
if (Universe::heap() != nullptr) {
Universe::heap()->print_on_error(st);
st->cr();
}
@ -1299,7 +1299,7 @@ int VMError::prepare_log_file(const char* pattern, const char* default_pattern,
int fd = -1;
// If possible, use specified pattern to construct log file name
if (pattern != NULL) {
if (pattern != nullptr) {
fd = expand_and_open(pattern, overwrite_existing, buf, buflen, 0);
}
@ -1307,7 +1307,7 @@ int VMError::prepare_log_file(const char* pattern, const char* default_pattern,
// so use the default name in the current directory
if (fd == -1) {
const char* cwd = os::get_current_directory(buf, buflen);
if (cwd != NULL) {
if (cwd != nullptr) {
size_t pos = strlen(cwd);
int fsep_len = jio_snprintf(&buf[pos], buflen-pos, "%s", os::file_separator());
pos += fsep_len;
@ -1320,7 +1320,7 @@ int VMError::prepare_log_file(const char* pattern, const char* default_pattern,
// try temp directory if it exists.
if (fd == -1) {
const char* tmpdir = os::get_temp_directory();
if (tmpdir != NULL && strlen(tmpdir) > 0) {
if (tmpdir != nullptr && strlen(tmpdir) > 0) {
int pos = jio_snprintf(buf, buflen, "%s%s", tmpdir, os::file_separator());
if (pos > 0) {
fd = expand_and_open(default_pattern, overwrite_existing, buf, buflen, pos);
@ -1336,7 +1336,7 @@ void VMError::report_and_die(Thread* thread, unsigned int sig, address pc, void*
{
va_list detail_args;
va_start(detail_args, detail_fmt);
report_and_die(sig, NULL, detail_fmt, detail_args, thread, pc, siginfo, context, NULL, 0, 0);
report_and_die(sig, nullptr, detail_fmt, detail_args, thread, pc, siginfo, context, nullptr, 0, 0);
va_end(detail_args);
}
@ -1348,12 +1348,12 @@ void VMError::report_and_die(Thread* thread, unsigned int sig, address pc, void*
void VMError::report_and_die(Thread* thread, void* context, const char* filename, int lineno, const char* message,
const char* detail_fmt, va_list detail_args)
{
report_and_die(INTERNAL_ERROR, message, detail_fmt, detail_args, thread, NULL, NULL, context, filename, lineno, 0);
report_and_die(INTERNAL_ERROR, message, detail_fmt, detail_args, thread, nullptr, nullptr, context, filename, lineno, 0);
}
void VMError::report_and_die(Thread* thread, const char* filename, int lineno, size_t size,
VMErrorType vm_err_type, const char* detail_fmt, va_list detail_args) {
report_and_die(vm_err_type, NULL, detail_fmt, detail_args, thread, NULL, NULL, NULL, filename, lineno, size);
report_and_die(vm_err_type, nullptr, detail_fmt, detail_args, thread, nullptr, nullptr, nullptr, filename, lineno, size);
}
void VMError::report_and_die(int id, const char* message, const char* detail_fmt, va_list detail_args,
@ -1514,10 +1514,10 @@ void VMError::report_and_die(int id, const char* message, const char* detail_fmt
} else {
if (should_report_bug(id)) {
st->print(", Internal Error (%s:%d)",
filename == NULL ? "??" : filename, lineno);
filename == nullptr ? "??" : filename, lineno);
} else {
st->print(", Out of Memory Error (%s:%d)",
filename == NULL ? "??" : filename, lineno);
filename == nullptr ? "??" : filename, lineno);
}
}
st->print_cr("]");
@ -1609,12 +1609,12 @@ void VMError::report_and_die(int id, const char* message, const char* detail_fmt
if (DumpReplayDataOnError && _thread && _thread->is_Compiler_thread() && !skip_replay) {
skip_replay = true;
ciEnv* env = ciEnv::current();
if (env != NULL) {
if (env != nullptr) {
const bool overwrite = false; // We do not overwrite an existing replay file.
int fd = prepare_log_file(ReplayDataFile, "replay_pid%p.log", overwrite, buffer, sizeof(buffer));
if (fd != -1) {
FILE* replay_data_file = os::fdopen(fd, "w");
if (replay_data_file != NULL) {
if (replay_data_file != nullptr) {
fileStream replay_data_stream(replay_data_file, /*need_close=*/true);
env->dump_replay_data_unsafe(&replay_data_stream);
out.print_raw("#\n# Compiler replay data is saved as:\n# ");
@ -1629,7 +1629,7 @@ void VMError::report_and_die(int id, const char* message, const char* detail_fmt
}
#if INCLUDE_JVMCI
if (JVMCI::fatal_log_filename() != NULL) {
if (JVMCI::fatal_log_filename() != nullptr) {
out.print_raw("#\n# The JVMCI shared library error report file is saved as:\n# ");
out.print_raw_cr(JVMCI::fatal_log_filename());
}
@ -1657,7 +1657,7 @@ void VMError::report_and_die(int id, const char* message, const char* detail_fmt
char* cmd;
const char* ptr = OnError;
while ((cmd = next_OnError_command(buffer, sizeof(buffer), &ptr)) != NULL){
while ((cmd = next_OnError_command(buffer, sizeof(buffer), &ptr)) != nullptr){
out.print_raw ("# Executing ");
#if defined(LINUX) || defined(_ALLBSD_SOURCE)
out.print_raw ("/bin/sh -c ");
@ -1675,7 +1675,7 @@ void VMError::report_and_die(int id, const char* message, const char* detail_fmt
}
// done with OnError
OnError = NULL;
OnError = nullptr;
}
if (WINDOWS_ONLY(!UseOSErrorReporting) NOT_WINDOWS(true)) {
@ -1718,7 +1718,7 @@ void VM_ReportJavaOutOfMemory::doit() {
char* cmd;
const char* ptr = OnOutOfMemoryError;
while ((cmd = next_OnError_command(buffer, sizeof(buffer), &ptr)) != NULL){
while ((cmd = next_OnError_command(buffer, sizeof(buffer), &ptr)) != nullptr){
tty->print("# Executing ");
#if defined(LINUX)
tty->print ("/bin/sh -c ");
@ -1760,8 +1760,8 @@ bool VMError::check_timeout() {
// Do not check for timeouts if we still have a message box to show to the
// user or if there are OnError handlers to be run.
if (ShowMessageBoxOnError
|| (OnError != NULL && OnError[0] != '\0')
|| Arguments::abort_hook() != NULL) {
|| (OnError != nullptr && OnError[0] != '\0')
|| Arguments::abort_hook() != nullptr) {
return false;
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2022 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -42,7 +42,7 @@ class VMError : public AllStatic {
static const char* _message;
static char _detail_msg[1024];
static Thread* _thread; // NULL if it's native thread
static Thread* _thread; // nullptr if it's native thread
// additional info for crashes
static address _pc; // faulting PC
@ -187,7 +187,7 @@ public:
DEBUG_ONLY(static void controlled_crash(int how);)
// Non-NULL address guaranteed to generate a SEGV mapping error on read, for test purposes.
// Non-null address guaranteed to generate a SEGV mapping error on read, for test purposes.
static constexpr intptr_t segfault_address = (1 * K) AIX_ONLY(+ (4 * K));
// Max value for the ErrorLogPrintCodeLimit flag.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2023, 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
@ -94,7 +94,7 @@ void xmlStream::write_text(const char* s, size_t len) {
for (size_t i = 0; i < len; i++) {
char ch = s[i];
// Escape special chars.
const char* esc = NULL;
const char* esc = nullptr;
switch (ch) {
// These are important only in attrs, but we do them always:
case '\'': esc = "&apos;"; break;
@ -104,7 +104,7 @@ void xmlStream::write_text(const char* s, size_t len) {
// This is a freebie.
case '>': esc = "&gt;"; break;
}
if (esc != NULL) {
if (esc != nullptr) {
if (written < i) {
out()->write(&s[written], i - written);
written = i;
@ -153,7 +153,7 @@ void xmlStream::see_tag(const char* tag, bool push) {
// tag goes up until either null or space:
const char* tag_end = strchr(tag, ' ');
size_t tag_len = (tag_end == NULL) ? strlen(tag) : tag_end - tag;
size_t tag_len = (tag_end == nullptr) ? strlen(tag) : tag_end - tag;
assert(tag_len > 0, "tag must not be empty");
// push the tag onto the stack, pulling down the pointer
char* old_ptr = _element_close_stack_ptr;
@ -355,7 +355,7 @@ void xmlStream::va_done(const char* format, va_list ap) {
const char* kind = format;
const char* kind_end = strchr(kind, ' ');
size_t kind_len;
if (kind_end != NULL) {
if (kind_end != nullptr) {
kind_len = kind_end - kind;
int n = os::snprintf(buffer, sizeof(buffer), "%.*s_done", (int)kind_len, kind);
assert((size_t)n < sizeof(buffer), "Unexpected number of characters in string");
@ -388,7 +388,7 @@ void xmlStream::stamp() {
// This is used only when there is no ciMethod available.
void xmlStream::method(Method* method) {
assert_if_no_error(inside_attrs(), "printing attributes");
if (method == NULL) return;
if (method == nullptr) return;
print_raw(" method='");
method_text(method);
print("' bytes='%d'", method->code_size());
@ -399,7 +399,7 @@ void xmlStream::method(Method* method) {
int throwouts = method->interpreter_throwout_count();
if (throwouts != 0) print(" throwouts='%d'", throwouts);
MethodData* mdo = method->method_data();
if (mdo != NULL) {
if (mdo != nullptr) {
uint cnt;
cnt = mdo->decompile_count();
if (cnt != 0) print(" decompiles='%d'", cnt);
@ -417,7 +417,7 @@ void xmlStream::method(Method* method) {
void xmlStream::method_text(Method* method) {
ResourceMark rm;
assert_if_no_error(inside_attrs(), "printing attributes");
if (method == NULL) return;
if (method == nullptr) return;
text()->print("%s", method->method_holder()->external_name());
print_raw(" "); // " " is easier for tools to parse than "::"
method->name()->print_symbol_on(text());
@ -431,7 +431,7 @@ void xmlStream::method_text(Method* method) {
// This is used only when there is no ciKlass available.
void xmlStream::klass(Klass* klass) {
assert_if_no_error(inside_attrs(), "printing attributes");
if (klass == NULL) return;
if (klass == nullptr) return;
print_raw(" klass='");
klass_text(klass);
print_raw("'");
@ -439,14 +439,14 @@ void xmlStream::klass(Klass* klass) {
void xmlStream::klass_text(Klass* klass) {
assert_if_no_error(inside_attrs(), "printing attributes");
if (klass == NULL) return;
if (klass == nullptr) return;
//klass->print_short_name(log->out());
klass->name()->print_symbol_on(out());
}
void xmlStream::name(const Symbol* name) {
assert_if_no_error(inside_attrs(), "printing attributes");
if (name == NULL) return;
if (name == nullptr) return;
print_raw(" name='");
name_text(name);
print_raw("'");
@ -454,14 +454,14 @@ void xmlStream::name(const Symbol* name) {
void xmlStream::name_text(const Symbol* name) {
assert_if_no_error(inside_attrs(), "printing attributes");
if (name == NULL) return;
if (name == nullptr) return;
//name->print_short_name(text());
name->print_symbol_on(text());
}
void xmlStream::object(const char* attr, Handle x) {
assert_if_no_error(inside_attrs(), "printing attributes");
if (x == NULL) return;
if (x == nullptr) return;
print_raw(" ");
print_raw(attr);
print_raw("='");
@ -471,14 +471,14 @@ void xmlStream::object(const char* attr, Handle x) {
void xmlStream::object_text(Handle x) {
assert_if_no_error(inside_attrs(), "printing attributes");
if (x == NULL) return;
if (x == nullptr) return;
x->print_value_on(text());
}
void xmlStream::object(const char* attr, Metadata* x) {
assert_if_no_error(inside_attrs(), "printing attributes");
if (x == NULL) return;
if (x == nullptr) return;
print_raw(" ");
print_raw(attr);
print_raw("='");
@ -488,7 +488,7 @@ void xmlStream::object(const char* attr, Metadata* x) {
void xmlStream::object_text(Metadata* x) {
assert_if_no_error(inside_attrs(), "printing attributes");
if (x == NULL) return;
if (x == nullptr) return;
//x->print_value_on(text());
if (x->is_method())
method_text((Method*)x);
@ -505,12 +505,12 @@ void xmlStream::flush() {
}
void xmlTextStream::flush() {
if (_outer_xmlStream == NULL) return;
if (_outer_xmlStream == nullptr) return;
_outer_xmlStream->flush();
}
void xmlTextStream::write(const char* str, size_t len) {
if (_outer_xmlStream == NULL) return;
if (_outer_xmlStream == nullptr) return;
_outer_xmlStream->write_text(str, len);
update_position(str, len);
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2023, 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
@ -41,7 +41,7 @@ class xmlTextStream : public outputStream {
xmlStream* _outer_xmlStream;
xmlTextStream() { _outer_xmlStream = NULL; }
xmlTextStream() { _outer_xmlStream = nullptr; }
public:
virtual void flush(); // _outer.flush();
@ -97,7 +97,7 @@ class xmlStream : public outputStream {
xmlStream(outputStream* out) { initialize(out); }
DEBUG_ONLY(virtual ~xmlStream();)
bool is_open() { return _out != NULL; }
bool is_open() { return _out != nullptr; }
// text output
bool inside_attrs() { return _markup_state != BODY; }
@ -182,6 +182,6 @@ class xmlStream : public outputStream {
// Standard log file, null if no logging is happening.
extern xmlStream* xtty;
// Note: If ::xtty != NULL, ::tty == ::xtty->text().
// Note: If ::xtty != nullptr, ::tty == ::xtty->text().
#endif // SHARE_UTILITIES_XMLSTREAM_HPP