Skip to content

Commit

Permalink
8301077: Replace NULL with nullptr in share/services/
Browse files Browse the repository at this point in the history
Reviewed-by: cjplummer, coleenp
  • Loading branch information
jdksjolen committed Jan 27, 2023
1 parent dff4131 commit 5c1ec82
Show file tree
Hide file tree
Showing 44 changed files with 856 additions and 856 deletions.
48 changes: 24 additions & 24 deletions src/hotspot/share/services/attachListener.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 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
Expand Down Expand Up @@ -172,7 +172,7 @@ static jint data_dump(AttachOperation* op, outputStream* out) {
static jint thread_dump(AttachOperation* op, outputStream* out) {
bool print_concurrent_locks = false;
bool print_extended_info = false;
if (op->arg(0) != NULL) {
if (op->arg(0) != nullptr) {
for (int i = 0; op->arg(0)[i] != 0; ++i) {
if (op->arg(0)[i] == 'l') {
print_concurrent_locks = true;
Expand Down Expand Up @@ -219,12 +219,12 @@ static jint jcmd(AttachOperation* op, outputStream* out) {
// arg2: Compress level
jint dump_heap(AttachOperation* op, outputStream* out) {
const char* path = op->arg(0);
if (path == NULL || path[0] == '\0') {
if (path == nullptr || path[0] == '\0') {
out->print_cr("No dump file specified");
} else {
bool live_objects_only = true; // default is true to retain the behavior before this change is made
const char* arg1 = op->arg(1);
if (arg1 != NULL && (strlen(arg1) > 0)) {
if (arg1 != nullptr && (strlen(arg1) > 0)) {
if (strcmp(arg1, "-all") != 0 && strcmp(arg1, "-live") != 0) {
out->print_cr("Invalid argument to dumpheap operation: %s", arg1);
return JNI_ERR;
Expand All @@ -234,7 +234,7 @@ jint dump_heap(AttachOperation* op, outputStream* out) {

const char* num_str = op->arg(2);
uintx level = 0;
if (num_str != NULL && num_str[0] != '\0') {
if (num_str != nullptr && num_str[0] != '\0') {
if (!Arguments::parse_uintx(num_str, &level, 0)) {
out->print_cr("Invalid compress level: [%s]", num_str);
return JNI_ERR;
Expand All @@ -261,15 +261,15 @@ jint dump_heap(AttachOperation* op, outputStream* out) {
//
// Input arguments :-
// arg0: "-live" or "-all"
// arg1: Name of the dump file or NULL
// arg1: Name of the dump file or null
// arg2: parallel thread number
static jint heap_inspection(AttachOperation* op, outputStream* out) {
bool live_objects_only = true; // default is true to retain the behavior before this change is made
outputStream* os = out; // if path not specified or path is NULL, use out
fileStream* fs = NULL;
outputStream* os = out; // if path not specified or path is null, use out
fileStream* fs = nullptr;
const char* arg0 = op->arg(0);
uint parallel_thread_num = MAX2<uint>(1, (uint)os::initial_active_processor_count() * 3 / 8);
if (arg0 != NULL && (strlen(arg0) > 0)) {
if (arg0 != nullptr && (strlen(arg0) > 0)) {
if (strcmp(arg0, "-all") != 0 && strcmp(arg0, "-live") != 0) {
out->print_cr("Invalid argument to inspectheap operation: %s", arg0);
return JNI_ERR;
Expand All @@ -278,17 +278,17 @@ static jint heap_inspection(AttachOperation* op, outputStream* out) {
}

const char* path = op->arg(1);
if (path != NULL && path[0] != '\0') {
if (path != nullptr && path[0] != '\0') {
// create file
fs = new (mtInternal) fileStream(path);
if (fs == NULL) {
if (fs == nullptr) {
out->print_cr("Failed to allocate space for file: %s", path);
}
os = fs;
}

const char* num_str = op->arg(2);
if (num_str != NULL && num_str[0] != '\0') {
if (num_str != nullptr && num_str[0] != '\0') {
uintx num;
if (!Arguments::parse_uintx(num_str, &num, 0)) {
out->print_cr("Invalid parallel thread number: [%s]", num_str);
Expand All @@ -300,7 +300,7 @@ static jint heap_inspection(AttachOperation* op, outputStream* out) {

VM_GC_HeapInspection heapop(os, live_objects_only /* request full gc */, parallel_thread_num);
VMThread::execute(&heapop);
if (os != NULL && os != out) {
if (os != nullptr && os != out) {
out->print_cr("Heap inspection file created: %s", path);
delete fs;
}
Expand All @@ -310,8 +310,8 @@ static jint heap_inspection(AttachOperation* op, outputStream* out) {
// Implementation of "setflag" command
static jint set_flag(AttachOperation* op, outputStream* out) {

const char* name = NULL;
if ((name = op->arg(0)) == NULL) {
const char* name = nullptr;
if ((name = op->arg(0)) == nullptr) {
out->print_cr("flag name is missing");
return JNI_ERR;
}
Expand All @@ -336,8 +336,8 @@ static jint set_flag(AttachOperation* op, outputStream* out) {
// Implementation of "printflag" command
// See also: PrintVMFlagsDCmd class
static jint print_flag(AttachOperation* op, outputStream* out) {
const char* name = NULL;
if ((name = op->arg(0)) == NULL) {
const char* name = nullptr;
if ((name = op->arg(0)) == nullptr) {
out->print_cr("flag name is missing");
return JNI_ERR;
}
Expand Down Expand Up @@ -365,7 +365,7 @@ static AttachOperationFunctionInfo funcs[] = {
{ "setflag", set_flag },
{ "printflag", print_flag },
{ "jcmd", jcmd },
{ NULL, NULL }
{ nullptr, nullptr }
};


Expand All @@ -378,7 +378,7 @@ static void attach_listener_thread_entry(JavaThread* thread, TRAPS) {
os::set_priority(thread, NearMaxPriority);

assert(thread == Thread::current(), "Must be");
assert(thread->stack_base() != NULL && thread->stack_size() > 0,
assert(thread->stack_base() != nullptr && thread->stack_size() > 0,
"Should already be setup");

if (AttachListener::pd_init() != 0) {
Expand All @@ -389,7 +389,7 @@ static void attach_listener_thread_entry(JavaThread* thread, TRAPS) {

for (;;) {
AttachOperation* op = AttachListener::dequeue();
if (op == NULL) {
if (op == nullptr) {
AttachListener::set_state(AL_NOT_INITIALIZED);
return; // dequeue failed or shutdown
}
Expand All @@ -407,8 +407,8 @@ static void attach_listener_thread_entry(JavaThread* thread, TRAPS) {
res = JNI_ERR;
} else {
// find the function to dispatch too
AttachOperationFunctionInfo* info = NULL;
for (int i=0; funcs[i].name != NULL; i++) {
AttachOperationFunctionInfo* info = nullptr;
for (int i=0; funcs[i].name != nullptr; i++) {
const char* name = funcs[i].name;
assert(strlen(name) <= AttachOperation::name_length_max, "operation <= name_length_max");
if (strcmp(op->name(), name) == 0) {
Expand All @@ -418,11 +418,11 @@ static void attach_listener_thread_entry(JavaThread* thread, TRAPS) {
}

// check for platform dependent attach operation
if (info == NULL) {
if (info == nullptr) {
info = AttachListener::pd_find_operation(op->name());
}

if (info != NULL) {
if (info != nullptr) {
// dispatch to the function that implements this operation
res = (info->func)(op, &st);
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/services/attachListener.hpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 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
Expand Down Expand Up @@ -168,7 +168,7 @@ class AttachOperation: public CHeapObj<mtInternal> {
// set an argument value
void set_arg(int i, char* arg) {
assert(i>=0 && i<arg_count_max, "invalid argument index");
if (arg == NULL) {
if (arg == nullptr) {
_arg[i][0] = '\0';
} else {
assert(strlen(arg) <= arg_length_max, "exceeds maximum argument length");
Expand All @@ -182,7 +182,7 @@ class AttachOperation: public CHeapObj<mtInternal> {
AttachOperation(const char* name) {
set_name(name);
for (int i=0; i<arg_count_max; i++) {
set_arg(i, NULL);
set_arg(i, nullptr);
}
}

Expand Down
26 changes: 13 additions & 13 deletions src/hotspot/share/services/classLoadingService.cpp
@@ -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
Expand Down Expand Up @@ -45,10 +45,10 @@
#define HOTSPOT_CLASS_loaded HOTSPOT_CLASS_LOADED
#define DTRACE_CLASSLOAD_PROBE(type, clss, shared) \
{ \
char* data = NULL; \
char* data = nullptr; \
int len = 0; \
Symbol* name = (clss)->name(); \
if (name != NULL) { \
if (name != nullptr) { \
data = (char*)name->bytes(); \
len = name->utf8_length(); \
} \
Expand All @@ -64,17 +64,17 @@

#if INCLUDE_MANAGEMENT
// counters for classes loaded from class files
PerfCounter* ClassLoadingService::_classes_loaded_count = NULL;
PerfCounter* ClassLoadingService::_classes_unloaded_count = NULL;
PerfCounter* ClassLoadingService::_classbytes_loaded = NULL;
PerfCounter* ClassLoadingService::_classbytes_unloaded = NULL;
PerfCounter* ClassLoadingService::_classes_loaded_count = nullptr;
PerfCounter* ClassLoadingService::_classes_unloaded_count = nullptr;
PerfCounter* ClassLoadingService::_classbytes_loaded = nullptr;
PerfCounter* ClassLoadingService::_classbytes_unloaded = nullptr;

// counters for classes loaded from shared archive
PerfCounter* ClassLoadingService::_shared_classes_loaded_count = NULL;
PerfCounter* ClassLoadingService::_shared_classes_unloaded_count = NULL;
PerfCounter* ClassLoadingService::_shared_classbytes_loaded = NULL;
PerfCounter* ClassLoadingService::_shared_classbytes_unloaded = NULL;
PerfVariable* ClassLoadingService::_class_methods_size = NULL;
PerfCounter* ClassLoadingService::_shared_classes_loaded_count = nullptr;
PerfCounter* ClassLoadingService::_shared_classes_unloaded_count = nullptr;
PerfCounter* ClassLoadingService::_shared_classbytes_loaded = nullptr;
PerfCounter* ClassLoadingService::_shared_classbytes_unloaded = nullptr;
PerfVariable* ClassLoadingService::_class_methods_size = nullptr;

void ClassLoadingService::init() {
EXCEPTION_MARK;
Expand Down Expand Up @@ -180,7 +180,7 @@ static size_t compute_class_size(InstanceKlass* k) {
// FIXME: Need to count the contents of methods
class_size += k->constants()->size();
class_size += k->local_interfaces()->size();
if (k->transitive_interfaces() != NULL) {
if (k->transitive_interfaces() != nullptr) {
class_size += k->transitive_interfaces()->size();
}
// We do not have to count implementors, since we only store one!
Expand Down
30 changes: 15 additions & 15 deletions src/hotspot/share/services/diagnosticArgument.cpp
@@ -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
Expand Down Expand Up @@ -32,7 +32,7 @@

StringArrayArgument::StringArrayArgument() {
_array = new (mtServiceability) GrowableArray<char *>(32, mtServiceability);
assert(_array != NULL, "Sanity check");
assert(_array != nullptr, "Sanity check");
}

StringArrayArgument::~StringArrayArgument() {
Expand All @@ -43,7 +43,7 @@ StringArrayArgument::~StringArrayArgument() {
}

void StringArrayArgument::add(const char* str, size_t len) {
if (str != NULL) {
if (str != nullptr) {
char* ptr = NEW_C_HEAP_ARRAY(char, len+1, mtInternal);
strncpy(ptr, str, len);
ptr[len] = 0;
Expand Down Expand Up @@ -84,7 +84,7 @@ void GenDCmdArgument::to_string(MemorySizeArgument m, char* buf, size_t len) con
}

void GenDCmdArgument::to_string(char* c, char* buf, size_t len) const {
jio_snprintf(buf, len, "%s", (c != NULL) ? c : "");
jio_snprintf(buf, len, "%s", (c != nullptr) ? c : "");
}

void GenDCmdArgument::to_string(StringArrayArgument* f, char* buf, size_t len) const {
Expand All @@ -111,15 +111,15 @@ void GenDCmdArgument::to_string(StringArrayArgument* f, char* buf, size_t len) c
template <> void DCmdArgument<jlong>::parse_value(const char* str,
size_t len, TRAPS) {
int scanned = -1;
if (str == NULL
if (str == nullptr
|| sscanf(str, JLONG_FORMAT "%n", &_value, &scanned) != 1
|| (size_t)scanned != len)
{
const int maxprint = 64;
Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::java_lang_IllegalArgumentException(),
"Integer parsing error in command argument '%s'. Could not parse: %.*s%s.\n", _name,
MIN2((int)len, maxprint),
(str == NULL ? "<null>" : str),
(str == nullptr ? "<null>" : str),
(len > maxprint ? "..." : ""));
}
}
Expand Down Expand Up @@ -180,8 +180,8 @@ template <> void DCmdArgument<bool>::destroy_value() { }

template <> void DCmdArgument<char*>::parse_value(const char* str,
size_t len, TRAPS) {
if (str == NULL) {
_value = NULL;
if (str == nullptr) {
_value = nullptr;
} else {
_value = NEW_C_HEAP_ARRAY(char, len + 1, mtInternal);
int n = os::snprintf(_value, len + 1, "%.*s", (int)len, str);
Expand All @@ -190,24 +190,24 @@ template <> void DCmdArgument<char*>::parse_value(const char* str,
}

template <> void DCmdArgument<char*>::init_value(TRAPS) {
if (has_default() && _default_string != NULL) {
if (has_default() && _default_string != nullptr) {
this->parse_value(_default_string, strlen(_default_string), THREAD);
if (HAS_PENDING_EXCEPTION) {
fatal("Default string must be parsable");
}
} else {
set_value(NULL);
set_value(nullptr);
}
}

template <> void DCmdArgument<char*>::destroy_value() {
FREE_C_HEAP_ARRAY(char, _value);
set_value(NULL);
set_value(nullptr);
}

template <> void DCmdArgument<NanoTimeArgument>::parse_value(const char* str,
size_t len, TRAPS) {
if (str == NULL) {
if (str == nullptr) {
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
"Integer parsing error nanotime value: syntax error, value is null\n");
}
Expand Down Expand Up @@ -296,15 +296,15 @@ template <> void DCmdArgument<StringArrayArgument*>::init_value(TRAPS) {
}

template <> void DCmdArgument<StringArrayArgument*>::destroy_value() {
if (_value != NULL) {
if (_value != nullptr) {
delete _value;
set_value(NULL);
set_value(nullptr);
}
}

template <> void DCmdArgument<MemorySizeArgument>::parse_value(const char* str,
size_t len, TRAPS) {
if (str == NULL) {
if (str == nullptr) {
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
"Parsing error memory size value: syntax error, value is null\n");
}
Expand Down
10 changes: 5 additions & 5 deletions src/hotspot/share/services/diagnosticArgument.hpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 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
Expand Down Expand Up @@ -71,7 +71,7 @@ class GenDCmdArgument : public ResourceObj {
bool _allow_multiple;
GenDCmdArgument(const char* name, const char* description, const char* type,
const char* default_string, bool mandatory)
: _next(NULL), _name(name), _description(description), _type(type),
: _next(nullptr), _name(name), _description(description), _type(type),
_default_string(default_string), _is_set(false), _is_mandatory(mandatory),
_allow_multiple(false) {}
public:
Expand All @@ -83,8 +83,8 @@ class GenDCmdArgument : public ResourceObj {
void set_is_set(bool b) { _is_set = b; }
bool allow_multiple() const { return _allow_multiple; }
bool is_mandatory() const { return _is_mandatory; }
bool has_value() const { return _is_set || _default_string != NULL; }
bool has_default() const { return _default_string != NULL; }
bool has_value() const { return _is_set || _default_string != nullptr; }
bool has_default() const { return _default_string != nullptr; }
void read_value(const char* str, size_t len, TRAPS);
virtual void parse_value(const char* str, size_t len, TRAPS) = 0;
virtual void init_value(TRAPS) = 0;
Expand Down Expand Up @@ -112,7 +112,7 @@ template <class ArgType> class DCmdArgument: public GenDCmdArgument {
public:
DCmdArgument(const char* name, const char* description, const char* type,
bool mandatory) :
GenDCmdArgument(name, description, type, NULL, mandatory) { }
GenDCmdArgument(name, description, type, nullptr, mandatory) { }
DCmdArgument(const char* name, const char* description, const char* type,
bool mandatory, const char* defaultvalue) :
GenDCmdArgument(name, description, type, defaultvalue, mandatory)
Expand Down

1 comment on commit 5c1ec82

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.