From b76a52f2104b63e84e5d09f47ce01dd0cb3935d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Sj=C3=B6len?= Date: Tue, 31 Jan 2023 14:22:44 +0000 Subject: [PATCH] 8301076: Replace NULL with nullptr in share/prims/ Reviewed-by: kbarrett, dholmes --- .../share/prims/foreignGlobals.inline.hpp | 4 +- src/hotspot/share/prims/forte.cpp | 46 +- src/hotspot/share/prims/jni.cpp | 288 +++---- src/hotspot/share/prims/jniCheck.cpp | 114 +-- src/hotspot/share/prims/jniCheck.hpp | 4 +- src/hotspot/share/prims/jvm.cpp | 340 ++++---- .../prims/jvmtiClassFileReconstituter.cpp | 74 +- .../prims/jvmtiClassFileReconstituter.hpp | 14 +- .../share/prims/jvmtiCodeBlobEvents.cpp | 24 +- .../share/prims/jvmtiDeferredUpdates.cpp | 14 +- .../share/prims/jvmtiDeferredUpdates.hpp | 4 +- src/hotspot/share/prims/jvmtiEnv.cpp | 760 +++++++++--------- src/hotspot/share/prims/jvmtiEnvBase.cpp | 288 +++---- src/hotspot/share/prims/jvmtiEnvBase.hpp | 38 +- .../share/prims/jvmtiEnvThreadState.cpp | 42 +- .../share/prims/jvmtiEnvThreadState.hpp | 4 +- .../share/prims/jvmtiEventController.cpp | 46 +- .../share/prims/jvmtiEventController.hpp | 8 +- src/hotspot/share/prims/jvmtiExport.cpp | 466 +++++------ src/hotspot/share/prims/jvmtiExport.hpp | 18 +- src/hotspot/share/prims/jvmtiExtensions.cpp | 60 +- .../share/prims/jvmtiGetLoadedClasses.cpp | 10 +- src/hotspot/share/prims/jvmtiImpl.cpp | 132 +-- src/hotspot/share/prims/jvmtiImpl.hpp | 18 +- src/hotspot/share/prims/jvmtiRawMonitor.cpp | 40 +- .../share/prims/jvmtiRedefineClasses.cpp | 154 ++-- .../share/prims/jvmtiRedefineClasses.hpp | 6 +- src/hotspot/share/prims/jvmtiTagMap.cpp | 182 ++--- src/hotspot/share/prims/jvmtiTagMapTable.cpp | 4 +- src/hotspot/share/prims/jvmtiTagMapTable.hpp | 2 +- src/hotspot/share/prims/jvmtiThreadState.cpp | 108 +-- src/hotspot/share/prims/jvmtiThreadState.hpp | 24 +- .../share/prims/jvmtiThreadState.inline.hpp | 44 +- src/hotspot/share/prims/jvmtiTrace.cpp | 28 +- src/hotspot/share/prims/jvmtiUtil.cpp | 6 +- src/hotspot/share/prims/jvmtiUtil.hpp | 4 +- src/hotspot/share/prims/methodHandles.cpp | 136 ++-- src/hotspot/share/prims/nativeLookup.cpp | 82 +- src/hotspot/share/prims/perf.cpp | 18 +- .../share/prims/resolvedMethodTable.cpp | 16 +- .../share/prims/scopedMemoryAccess.cpp | 6 +- src/hotspot/share/prims/stackwalk.cpp | 48 +- src/hotspot/share/prims/stackwalk.hpp | 6 +- src/hotspot/share/prims/unsafe.cpp | 62 +- src/hotspot/share/prims/upcallLinker.cpp | 6 +- src/hotspot/share/prims/vectorSupport.cpp | 6 +- src/hotspot/share/prims/whitebox.cpp | 270 +++---- 47 files changed, 2037 insertions(+), 2037 deletions(-) diff --git a/src/hotspot/share/prims/foreignGlobals.inline.hpp b/src/hotspot/share/prims/foreignGlobals.inline.hpp index 13053f0d1f881..bc5c47bcbf527 100644 --- a/src/hotspot/share/prims/foreignGlobals.inline.hpp +++ b/src/hotspot/share/prims/foreignGlobals.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, 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 @@ -43,7 +43,7 @@ void ForeignGlobals::parse_register_array(objArrayOop jarray, StorageType type_i } inline const char* null_safe_string(const char* str) { - return str == nullptr ? "NULL" : str; + return str == nullptr ? "null" : str; } #endif // SHARE_PRIMS_FOREIGN_GLOBALS_INLINE_HPP diff --git a/src/hotspot/share/prims/forte.cpp b/src/hotspot/share/prims/forte.cpp index cd417acab98c8..ff0bd6949a221 100644 --- a/src/hotspot/share/prims/forte.cpp +++ b/src/hotspot/share/prims/forte.cpp @@ -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 @@ -158,7 +158,7 @@ static bool is_decipherable_compiled_frame(JavaThread* thread, frame* fr, Compil PcDesc* pc_desc = nm->pc_desc_at(fr->pc()); // Did we find a useful PcDesc? - if (pc_desc != NULL && + if (pc_desc != nullptr && pc_desc->scope_decode_offset() != DebugInformationRecorder::serialized_null) { return true; } @@ -172,7 +172,7 @@ static bool is_decipherable_compiled_frame(JavaThread* thread, frame* fr, Compil PcDesc* pc_desc = nm->pc_desc_near(fr->pc() + 1); // Now do we have a useful PcDesc? - if (pc_desc == NULL || + if (pc_desc == nullptr || pc_desc->scope_decode_offset() == DebugInformationRecorder::serialized_null) { // No debug information is available for this PC. // @@ -207,7 +207,7 @@ static bool is_decipherable_compiled_frame(JavaThread* thread, frame* fr, Compil // Determine if 'fr' is a walkable interpreted frame. Returns false // if it is not. *method_p, and *bci_p are not set when false is -// returned. *method_p is non-NULL if frame was executing a Java +// returned. *method_p is non-null if frame was executing a Java // method. *bci_p is != -1 if a valid BCI in the Java method could // be found. // Note: this method returns true when a valid Java method is found @@ -273,13 +273,13 @@ static bool is_decipherable_interpreted_frame(JavaThread* thread, // Check the return value of find_initial_Java_frame and the value of // 'method_p' to decide on how use the results returned by this method. // -// If 'method_p' is not NULL, an initial Java frame has been found and +// If 'method_p' is not null, an initial Java frame has been found and // the stack can be walked starting from that initial frame. In this case, // 'method_p' points to the Method that the initial frame belongs to and // the initial Java frame is returned in initial_frame_p. // // find_initial_Java_frame() returns true if a Method has been found (i.e., -// 'method_p' is not NULL) and the initial frame that belongs to that Method +// 'method_p' is not null) and the initial frame that belongs to that Method // is decipherable. // // A frame is considered to be decipherable: @@ -292,7 +292,7 @@ static bool is_decipherable_interpreted_frame(JavaThread* thread, // Note that find_initial_Java_frame() can return false even if an initial // Java method was found (e.g., there is no PCDesc available for the method). // -// If 'method_p' is NULL, it was not possible to find a Java frame when +// If 'method_p' is null, it was not possible to find a Java frame when // walking the stack starting from 'fr'. In this case find_initial_Java_frame // returns false. @@ -305,10 +305,10 @@ static bool find_initial_Java_frame(JavaThread* thread, // It is possible that for a frame containing a compiled method // we can capture the method but no bci. If we get no // bci the frame isn't walkable but the method is usable. - // Therefore we init the returned Method* to NULL so the + // Therefore we init the returned Method* to null so the // caller can make the distinction. - *method_p = NULL; + *method_p = nullptr; // On the initial call to this method the frame we get may not be // recognizable to us. This should only happen if we are in a JRT_LEAF @@ -333,11 +333,11 @@ static bool find_initial_Java_frame(JavaThread* thread, } if (candidate.is_entry_frame()) { - // jcw is NULL if the java call wrapper could not be found + // jcw is null if the java call wrapper could not be found JavaCallWrapper* jcw = candidate.entry_frame_call_wrapper_if_safe(thread); // If initial frame is frame from StubGenerator and there is no // previous anchor, there are no java frames associated with a method - if (jcw == NULL || jcw->is_first_frame()) { + if (jcw == nullptr || jcw->is_first_frame()) { return false; } } @@ -363,7 +363,7 @@ static bool find_initial_Java_frame(JavaThread* thread, // it see if we can find such a frame because only frames with codeBlobs // are possible Java frames. - if (fr->cb() == NULL) { + if (fr->cb() == nullptr) { // See if we can find a useful frame int loop_count; @@ -376,9 +376,9 @@ static bool find_initial_Java_frame(JavaThread* thread, for (loop_count = 0; loop_max == 0 || loop_count < loop_max; loop_count++) { if (!candidate.safe_for_sender(thread)) return false; candidate = candidate.sender(&map); - if (candidate.cb() != NULL) break; + if (candidate.cb() != nullptr) break; } - if (candidate.cb() == NULL) return false; + if (candidate.cb() == nullptr) return false; } // We have a frame known to be in the codeCache @@ -393,11 +393,11 @@ static bool find_initial_Java_frame(JavaThread* thread, for (loop_count = 0; loop_max == 0 || loop_count < loop_max; loop_count++) { if (candidate.is_entry_frame()) { - // jcw is NULL if the java call wrapper couldn't be found + // jcw is null if the java call wrapper couldn't be found JavaCallWrapper *jcw = candidate.entry_frame_call_wrapper_if_safe(thread); // If initial frame is frame from StubGenerator and there is no // previous anchor, there are no java frames associated with a method - if (jcw == NULL || jcw->is_first_frame()) { + if (jcw == nullptr || jcw->is_first_frame()) { return false; } } @@ -443,7 +443,7 @@ static bool find_initial_Java_frame(JavaThread* thread, // is_decipherable_compiled_frame may modify candidate's pc *initial_frame_p = candidate; - assert(nm->pc_desc_at(candidate.pc()) != NULL, "debug information must be available if the frame is decipherable"); + assert(nm->pc_desc_at(candidate.pc()) != nullptr, "debug information must be available if the frame is decipherable"); return true; } @@ -457,7 +457,7 @@ static bool find_initial_Java_frame(JavaThread* thread, // since once we find a frame in the code cache they // all should be there. - if (candidate.cb() == NULL) return false; + if (candidate.cb() == nullptr) return false; } @@ -478,13 +478,13 @@ static void forte_fill_call_trace_given_top(JavaThread* thd, int count; count = 0; - assert(trace->frames != NULL, "trace->frames must be non-NULL"); + assert(trace->frames != nullptr, "trace->frames must be non-null"); // Walk the stack starting from 'top_frame' and search for an initial Java frame. find_initial_Java_frame(thd, &top_frame, &initial_Java_frame, &method, &bci); // Check if a Java Method has been found. - if (method == NULL) return; + if (method == nullptr) return; if (!Method::is_valid_method(method)) { trace->num_frames = ticks_GC_active; // -2 @@ -579,7 +579,7 @@ void AsyncGetCallTrace(ASGCT_CallTrace *trace, jint depth, void* ucontext) { Thread* raw_thread = Thread::current_or_null_safe(); JavaThread* thread; - if (trace->env_id == NULL || raw_thread == NULL || !raw_thread->is_Java_thread() || + if (trace->env_id == nullptr || raw_thread == nullptr || !raw_thread->is_Java_thread() || (thread = JavaThread::cast(raw_thread))->is_exiting()) { // bad env_id, thread has exited or thread is exiting trace->num_frames = ticks_thread_exit; // -8 @@ -710,8 +710,8 @@ void Forte::register_stub(const char* name, address start, address end) { assert(pointer_delta(end, start, sizeof(jbyte)) < INT_MAX, "Code size exceeds maximum range"); - collector_func_load((char*)name, NULL, NULL, start, - pointer_delta(end, start, sizeof(jbyte)), 0, NULL); + collector_func_load((char*)name, nullptr, nullptr, start, + pointer_delta(end, start, sizeof(jbyte)), 0, nullptr); #endif // !_WINDOWS } diff --git a/src/hotspot/share/prims/jni.cpp b/src/hotspot/share/prims/jni.cpp index 1aa7eaad986e6..816dfd448e700 100644 --- a/src/hotspot/share/prims/jni.cpp +++ b/src/hotspot/share/prims/jni.cpp @@ -197,9 +197,9 @@ bool jfieldIDWorkaround::is_valid_jfieldID(Klass* k, jfieldID id) { } else { JNIid* result = (JNIid*) id; #ifdef ASSERT - return result != NULL && result->is_static_field_id(); + return result != nullptr && result->is_static_field_id(); #else - return result != NULL; + return result != nullptr; #endif } } @@ -241,7 +241,7 @@ bool jfieldIDWorkaround::klass_hash_ok(Klass* k, jfieldID id) { if ((k->identity_hash() & klass_mask) == klass_hash) return true; k = k->super(); - } while (k != NULL); + } while (k != nullptr); return false; } @@ -278,16 +278,16 @@ JNI_ENTRY(jclass, jni_DefineClass(JNIEnv *env, const char *name, jobject loaderR HOTSPOT_JNI_DEFINECLASS_ENTRY( env, (char*) name, loaderRef, (char*) buf, bufLen); - jclass cls = NULL; + jclass cls = nullptr; DT_RETURN_MARK(DefineClass, jclass, (const jclass&)cls); // Class resolution will get the class name from the .class stream if the name is null. - TempNewSymbol class_name = name == NULL ? NULL : + TempNewSymbol class_name = name == nullptr ? nullptr : SystemDictionary::class_name_symbol(name, vmSymbols::java_lang_NoClassDefFoundError(), CHECK_NULL); ResourceMark rm(THREAD); - ClassFileStream st((u1*)buf, bufLen, NULL, ClassFileStream::verify); + ClassFileStream st((u1*)buf, bufLen, nullptr, ClassFileStream::verify); Handle class_loader (THREAD, JNIHandles::resolve(loaderRef)); Handle protection_domain; ClassLoadInfo cl_info(protection_domain); @@ -312,7 +312,7 @@ DT_RETURN_MARK_DECL(FindClass, jclass JNI_ENTRY(jclass, jni_FindClass(JNIEnv *env, const char *name)) HOTSPOT_JNI_FINDCLASS_ENTRY(env, (char *)name); - jclass result = NULL; + jclass result = nullptr; DT_RETURN_MARK(FindClass, jclass, (const jclass&)result); // This should be ClassNotFoundException imo. @@ -326,10 +326,10 @@ JNI_ENTRY(jclass, jni_FindClass(JNIEnv *env, const char *name)) Klass* k = thread->security_get_caller_class(0); // default to the system loader when no context Handle loader(THREAD, SystemDictionary::java_system_loader()); - if (k != NULL) { + if (k != nullptr) { // Special handling to make sure JNI_OnLoad and JNI_OnUnload are executed // in the correct class context. - if (k->class_loader() == NULL && + if (k->class_loader() == nullptr && k->name() == vmSymbols::jdk_internal_loader_NativeLibraries()) { JavaValue result(T_OBJECT); JavaCalls::call_static(&result, k, @@ -337,10 +337,10 @@ JNI_ENTRY(jclass, jni_FindClass(JNIEnv *env, const char *name)) vmSymbols::void_class_signature(), CHECK_NULL); // When invoked from JNI_OnLoad, NativeLibraries::getFromClass returns - // a non-NULL Class object. When invoked from JNI_OnUnload, - // it will return NULL to indicate no context. + // a non-null Class object. When invoked from JNI_OnUnload, + // it will return null to indicate no context. oop mirror = result.get_oop(); - if (mirror != NULL) { + if (mirror != nullptr) { Klass* fromClass = java_lang_Class::as_Klass(mirror); loader = Handle(THREAD, fromClass->class_loader()); protection_domain = Handle(THREAD, fromClass->protection_domain()); @@ -353,7 +353,7 @@ JNI_ENTRY(jclass, jni_FindClass(JNIEnv *env, const char *name)) result = find_class_from_class_loader(env, class_name, true, loader, protection_domain, true, thread); - if (log_is_enabled(Debug, class, resolve) && result != NULL) { + if (log_is_enabled(Debug, class, resolve) && result != nullptr) { trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result))); } @@ -366,12 +366,12 @@ DT_RETURN_MARK_DECL(FromReflectedMethod, jmethodID JNI_ENTRY(jmethodID, jni_FromReflectedMethod(JNIEnv *env, jobject method)) HOTSPOT_JNI_FROMREFLECTEDMETHOD_ENTRY(env, method); - jmethodID ret = NULL; + jmethodID ret = nullptr; DT_RETURN_MARK(FromReflectedMethod, jmethodID, (const jmethodID&)ret); // method is a handle to a java.lang.reflect.Method object oop reflected = JNIHandles::resolve_non_null(method); - oop mirror = NULL; + oop mirror = nullptr; int slot = 0; if (reflected->klass() == vmClasses::reflect_Constructor_klass()) { @@ -387,7 +387,7 @@ JNI_ENTRY(jmethodID, jni_FromReflectedMethod(JNIEnv *env, jobject method)) // Make sure class is initialized before handing id's out to methods k1->initialize(CHECK_NULL); Method* m = InstanceKlass::cast(k1)->method_with_idnum(slot); - ret = m==NULL? NULL : m->jmethod_id(); // return NULL if reflected method deleted + ret = m==nullptr? nullptr : m->jmethod_id(); // return null if reflected method deleted return ret; JNI_END @@ -397,7 +397,7 @@ DT_RETURN_MARK_DECL(FromReflectedField, jfieldID JNI_ENTRY(jfieldID, jni_FromReflectedField(JNIEnv *env, jobject field)) HOTSPOT_JNI_FROMREFLECTEDFIELD_ENTRY(env, field); - jfieldID ret = NULL; + jfieldID ret = nullptr; DT_RETURN_MARK(FromReflectedField, jfieldID, (const jfieldID&)ret); // field is a handle to a java.lang.reflect.Field object @@ -414,7 +414,7 @@ JNI_ENTRY(jfieldID, jni_FromReflectedField(JNIEnv *env, jobject field)) if (modifiers & JVM_ACC_STATIC) { intptr_t offset = InstanceKlass::cast(k1)->field_offset( slot ); JNIid* id = InstanceKlass::cast(k1)->jni_id_for(offset); - assert(id != NULL, "corrupt Field object"); + assert(id != nullptr, "corrupt Field object"); debug_only(id->set_is_static_field_id();) // A jfieldID for a static field is a JNIid specifying the field holder and the offset within the Klass* ret = jfieldIDWorkaround::to_static_jfieldID(id); @@ -437,7 +437,7 @@ DT_RETURN_MARK_DECL(ToReflectedMethod, jobject JNI_ENTRY(jobject, jni_ToReflectedMethod(JNIEnv *env, jclass cls, jmethodID method_id, jboolean isStatic)) HOTSPOT_JNI_TOREFLECTEDMETHOD_ENTRY(env, cls, (uintptr_t) method_id, isStatic); - jobject ret = NULL; + jobject ret = nullptr; DT_RETURN_MARK(ToReflectedMethod, jobject, (const jobject&)ret); methodHandle m (THREAD, Method::resolve_jmethod_id(method_id)); @@ -458,19 +458,19 @@ DT_RETURN_MARK_DECL(GetSuperclass, jclass JNI_ENTRY(jclass, jni_GetSuperclass(JNIEnv *env, jclass sub)) HOTSPOT_JNI_GETSUPERCLASS_ENTRY(env, sub); - jclass obj = NULL; + jclass obj = nullptr; DT_RETURN_MARK(GetSuperclass, jclass, (const jclass&)obj); oop mirror = JNIHandles::resolve_non_null(sub); - // primitive classes return NULL - if (java_lang_Class::is_primitive(mirror)) return NULL; + // primitive classes return null + if (java_lang_Class::is_primitive(mirror)) return nullptr; // Rules of Class.getSuperClass as implemented by KLass::java_super: // arrays return Object - // interfaces return NULL + // interfaces return null // proper classes return Klass::super() Klass* k = java_lang_Class::as_Klass(mirror); - if (k->is_interface()) return NULL; + if (k->is_interface()) return nullptr; // return mirror for superclass Klass* super = k->java_super(); @@ -480,7 +480,7 @@ JNI_ENTRY(jclass, jni_GetSuperclass(JNIEnv *env, jclass sub)) : k->super() ) ); assert(super == super2, "java_super computation depends on interface, array, other super"); - obj = (super == NULL) ? NULL : (jclass) JNIHandles::make_local(THREAD, super->java_mirror()); + obj = (super == nullptr) ? nullptr : (jclass) JNIHandles::make_local(THREAD, super->java_mirror()); return obj; JNI_END @@ -498,7 +498,7 @@ JNI_ENTRY_NO_PRESERVE(jboolean, jni_IsAssignableFrom(JNIEnv *env, jclass sub, jc } Klass* sub_klass = java_lang_Class::as_Klass(sub_mirror); Klass* super_klass = java_lang_Class::as_Klass(super_mirror); - assert(sub_klass != NULL && super_klass != NULL, "invalid arguments to jni_IsAssignableFrom"); + assert(sub_klass != nullptr && super_klass != nullptr, "invalid arguments to jni_IsAssignableFrom"); jboolean ret = sub_klass->is_subtype_of(super_klass) ? JNI_TRUE : JNI_FALSE; @@ -576,7 +576,7 @@ JNI_ENTRY_NO_PRESERVE(void, jni_ExceptionDescribe(JNIEnv *env)) Handle ex(thread, thread->pending_exception()); thread->clear_pending_exception(); jio_fprintf(defaultStream::error_stream(), "Exception "); - if (thread != NULL && thread->threadObj() != NULL) { + if (thread != nullptr && thread->threadObj() != nullptr) { ResourceMark rm(THREAD); jio_fprintf(defaultStream::error_stream(), "in thread \"%s\" ", thread->name()); @@ -613,7 +613,7 @@ JNI_ENTRY_NO_PRESERVE(void, jni_ExceptionClear(JNIEnv *env)) // The jni code might be using this API to clear java thrown exception. // So just mark jvmti thread exception state as exception caught. JvmtiThreadState *state = JavaThread::current()->jvmti_thread_state(); - if (state != NULL && state->is_exception_detected()) { + if (state != nullptr && state->is_exception_detected()) { state->set_exception_caught(); } thread->clear_pending_exception(); @@ -655,13 +655,13 @@ JNI_ENTRY(jobject, jni_PopLocalFrame(JNIEnv *env, jobject result)) Handle result_handle(thread, JNIHandles::resolve(result)); JNIHandleBlock* old_handles = thread->active_handles(); JNIHandleBlock* new_handles = old_handles->pop_frame_link(); - if (new_handles != NULL) { - // As a sanity check we only release the handle blocks if the pop_frame_link is not NULL. + if (new_handles != nullptr) { + // As a sanity check we only release the handle blocks if the pop_frame_link is not null. // This way code will still work if PopLocalFrame is called without a corresponding - // PushLocalFrame call. Note that we set the pop_frame_link to NULL explicitly, otherwise + // PushLocalFrame call. Note that we set the pop_frame_link to null explicitly, otherwise // the release_block call will release the blocks. thread->set_active_handles(new_handles); - old_handles->set_pop_frame_link(NULL); // clear link we won't release new_handles below + old_handles->set_pop_frame_link(nullptr); // clear link we won't release new_handles below JNIHandleBlock::release_block(old_handles, thread); // may block result = JNIHandles::make_local(thread, result_handle()); } @@ -737,7 +737,7 @@ JNI_LEAF(jobjectRefType, jni_GetObjectRefType(JNIEnv *env, jobject obj)) HOTSPOT_JNI_GETOBJECTREFTYPE_ENTRY(env, obj); jobjectRefType ret = JNIInvalidRefType; - if (obj != NULL) { + if (obj != nullptr) { ret = JNIHandles::handle_type(thread, obj); } @@ -768,7 +768,7 @@ class JNI_ArgumentPusher : public SignatureIterator { : SignatureIterator(method->signature(), Fingerprinter(methodHandle(Thread::current(), method)).fingerprint()) { - _arguments = NULL; + _arguments = nullptr; } public: @@ -895,7 +895,7 @@ static void jni_invoke_static(JNIEnv *env, JavaValue* result, jobject receiver, static void jni_invoke_nonstatic(JNIEnv *env, JavaValue* result, jobject receiver, JNICallType call_type, jmethodID method_id, JNI_ArgumentPusher *args, TRAPS) { oop recv = JNIHandles::resolve(receiver); - if (recv == NULL) { + if (recv == nullptr) { THROW(vmSymbols::java_lang_NullPointerException()); } Handle h_recv(THREAD, recv); @@ -960,7 +960,7 @@ DT_RETURN_MARK_DECL(AllocObject, jobject JNI_ENTRY(jobject, jni_AllocObject(JNIEnv *env, jclass clazz)) HOTSPOT_JNI_ALLOCOBJECT_ENTRY(env, clazz); - jobject ret = NULL; + jobject ret = nullptr; DT_RETURN_MARK(AllocObject, jobject, (const jobject&)ret); instanceOop i = InstanceKlass::allocate_instance(JNIHandles::resolve_non_null(clazz), CHECK_NULL); @@ -974,7 +974,7 @@ DT_RETURN_MARK_DECL(NewObjectA, jobject JNI_ENTRY(jobject, jni_NewObjectA(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args)) HOTSPOT_JNI_NEWOBJECTA_ENTRY(env, clazz, (uintptr_t) methodID); - jobject obj = NULL; + jobject obj = nullptr; DT_RETURN_MARK(NewObjectA, jobject, (const jobject&)obj); instanceOop i = InstanceKlass::allocate_instance(JNIHandles::resolve_non_null(clazz), CHECK_NULL); @@ -992,7 +992,7 @@ DT_RETURN_MARK_DECL(NewObjectV, jobject JNI_ENTRY(jobject, jni_NewObjectV(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)) HOTSPOT_JNI_NEWOBJECTV_ENTRY(env, clazz, (uintptr_t) methodID); - jobject obj = NULL; + jobject obj = nullptr; DT_RETURN_MARK(NewObjectV, jobject, (const jobject&)obj); instanceOop i = InstanceKlass::allocate_instance(JNIHandles::resolve_non_null(clazz), CHECK_NULL); @@ -1010,7 +1010,7 @@ DT_RETURN_MARK_DECL(NewObject, jobject JNI_ENTRY(jobject, jni_NewObject(JNIEnv *env, jclass clazz, jmethodID methodID, ...)) HOTSPOT_JNI_NEWOBJECT_ENTRY(env, clazz, (uintptr_t) methodID); - jobject obj = NULL; + jobject obj = nullptr; DT_RETURN_MARK(NewObject, jobject, (const jobject&)obj); instanceOop i = InstanceKlass::allocate_instance(JNIHandles::resolve_non_null(clazz), CHECK_NULL); @@ -1040,11 +1040,11 @@ JNI_ENTRY_NO_PRESERVE(jboolean, jni_IsInstanceOf(JNIEnv *env, jobject obj, jclas HOTSPOT_JNI_ISINSTANCEOF_ENTRY(env, obj, clazz); jboolean ret = JNI_TRUE; - if (obj != NULL) { + if (obj != nullptr) { ret = JNI_FALSE; Klass* k = java_lang_Class::as_Klass( JNIHandles::resolve_non_null(clazz)); - if (k != NULL) { + if (k != nullptr) { ret = JNIHandles::resolve_non_null(obj)->is_a(k) ? JNI_TRUE : JNI_FALSE; } } @@ -1061,13 +1061,13 @@ static jmethodID get_method_id(JNIEnv *env, jclass clazz, const char *name_str, // The class should have been loaded (we have an instance of the class // passed in) so the method and signature should already be in the symbol // table. If they're not there, the method doesn't exist. - const char *name_to_probe = (name_str == NULL) + const char *name_to_probe = (name_str == nullptr) ? vmSymbols::object_initializer_name()->as_C_string() : name_str; TempNewSymbol name = SymbolTable::probe(name_to_probe, (int)strlen(name_to_probe)); TempNewSymbol signature = SymbolTable::probe(sig, (int)strlen(sig)); - if (name == NULL || signature == NULL) { + if (name == nullptr || signature == nullptr) { THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), name_str); } @@ -1092,15 +1092,15 @@ static jmethodID get_method_id(JNIEnv *env, jclass clazz, const char *name_str, if (klass->is_instance_klass()) { m = InstanceKlass::cast(klass)->find_method(name, signature); } else { - m = NULL; + m = nullptr; } } else { m = klass->lookup_method(name, signature); - if (m == NULL && klass->is_instance_klass()) { + if (m == nullptr && klass->is_instance_klass()) { m = InstanceKlass::cast(klass)->lookup_method_in_ordered_interfaces(name, signature); } } - if (m == NULL || (m->is_static() != is_static)) { + if (m == nullptr || (m->is_static() != is_static)) { ResourceMark rm(THREAD); THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), err_msg("%s%s.%s%s", is_static ? "static " : "", klass->signature_name(), name_str, sig)); } @@ -1548,7 +1548,7 @@ JNI_ENTRY(ResultType, \ va_start(args, methodID); \ JavaValue jvalue(Tag); \ JNI_ArgumentPusherVaArg ap(methodID, args); \ - jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ + jni_invoke_static(env, &jvalue, nullptr, JNI_STATIC, methodID, &ap, CHECK_0); \ va_end(args); \ ret = jvalue.get_##ResultType(); \ return ret;\ @@ -1604,7 +1604,7 @@ JNI_ENTRY(ResultType, \ /* Make sure class is initialized before trying to invoke its method */ \ Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); \ k->initialize(CHECK_0); \ - jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ + jni_invoke_static(env, &jvalue, nullptr, JNI_STATIC, methodID, &ap, CHECK_0); \ va_end(args); \ ret = jvalue.get_##ResultType(); \ return ret;\ @@ -1657,7 +1657,7 @@ JNI_ENTRY(ResultType, \ \ JavaValue jvalue(Tag); \ JNI_ArgumentPusherArray ap(methodID, args); \ - jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ + jni_invoke_static(env, &jvalue, nullptr, JNI_STATIC, methodID, &ap, CHECK_0); \ ret = jvalue.get_##ResultType(); \ return ret;\ JNI_END @@ -1708,7 +1708,7 @@ JNI_ENTRY(void, jni_CallStaticVoidMethod(JNIEnv *env, jclass cls, jmethodID meth va_start(args, methodID); JavaValue jvalue(T_VOID); JNI_ArgumentPusherVaArg ap(methodID, args); - jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK); + jni_invoke_static(env, &jvalue, nullptr, JNI_STATIC, methodID, &ap, CHECK); va_end(args); JNI_END @@ -1719,7 +1719,7 @@ JNI_ENTRY(void, jni_CallStaticVoidMethodV(JNIEnv *env, jclass cls, jmethodID met JavaValue jvalue(T_VOID); JNI_ArgumentPusherVaArg ap(methodID, args); - jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK); + jni_invoke_static(env, &jvalue, nullptr, JNI_STATIC, methodID, &ap, CHECK); JNI_END @@ -1729,7 +1729,7 @@ JNI_ENTRY(void, jni_CallStaticVoidMethodA(JNIEnv *env, jclass cls, jmethodID met JavaValue jvalue(T_VOID); JNI_ArgumentPusherArray ap(methodID, args); - jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK); + jni_invoke_static(env, &jvalue, nullptr, JNI_STATIC, methodID, &ap, CHECK); JNI_END @@ -1754,7 +1754,7 @@ JNI_ENTRY(jfieldID, jni_GetFieldID(JNIEnv *env, jclass clazz, // table. If they're not there, the field doesn't exist. TempNewSymbol fieldname = SymbolTable::probe(name, (int)strlen(name)); TempNewSymbol signame = SymbolTable::probe(sig, (int)strlen(sig)); - if (fieldname == NULL || signame == NULL) { + if (fieldname == nullptr || signame == nullptr) { ResourceMark rm; THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), err_msg("%s.%s %s", k->external_name(), name, sig)); } @@ -1936,7 +1936,7 @@ DT_RETURN_MARK_DECL(ToReflectedField, jobject JNI_ENTRY(jobject, jni_ToReflectedField(JNIEnv *env, jclass cls, jfieldID fieldID, jboolean isStatic)) HOTSPOT_JNI_TOREFLECTEDFIELD_ENTRY(env, cls, (uintptr_t) fieldID, isStatic); - jobject ret = NULL; + jobject ret = nullptr; DT_RETURN_MARK(ToReflectedField, jobject, (const jobject&)ret); fieldDescriptor fd; @@ -1971,7 +1971,7 @@ DT_RETURN_MARK_DECL(GetStaticFieldID, jfieldID JNI_ENTRY(jfieldID, jni_GetStaticFieldID(JNIEnv *env, jclass clazz, const char *name, const char *sig)) HOTSPOT_JNI_GETSTATICFIELDID_ENTRY(env, clazz, (char *) name, (char *) sig); - jfieldID ret = NULL; + jfieldID ret = nullptr; DT_RETURN_MARK(GetStaticFieldID, jfieldID, (const jfieldID&)ret); // The class should have been loaded (we have an instance of the class @@ -1979,7 +1979,7 @@ JNI_ENTRY(jfieldID, jni_GetStaticFieldID(JNIEnv *env, jclass clazz, // table. If they're not there, the field doesn't exist. TempNewSymbol fieldname = SymbolTable::probe(name, (int)strlen(name)); TempNewSymbol signame = SymbolTable::probe(sig, (int)strlen(sig)); - if (fieldname == NULL || signame == NULL) { + if (fieldname == nullptr || signame == nullptr) { THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); } Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz)); @@ -2013,7 +2013,7 @@ JNI_ENTRY(jobject, jni_GetStaticObjectField(JNIEnv *env, jclass clazz, jfieldID // Keep JVMTI addition small and only check enabled flag here. // jni_GetField_probe() assumes that is okay to create handles. if (JvmtiExport::should_post_field_access()) { - JvmtiExport::jni_GetField_probe(thread, NULL, NULL, id->holder(), fieldID, true); + JvmtiExport::jni_GetField_probe(thread, nullptr, nullptr, id->holder(), fieldID, true); } jobject ret = JNIHandles::make_local(THREAD, id->holder()->java_mirror()->obj_field(id->offset())); HOTSPOT_JNI_GETSTATICOBJECTFIELD_RETURN(ret); @@ -2037,7 +2037,7 @@ JNI_ENTRY(Return, jni_GetStatic##Result##Field(JNIEnv *env, jclass clazz, jfield /* Keep JVMTI addition small and only check enabled flag here. */ \ /* jni_GetField_probe() assumes that is okay to create handles. */ \ if (JvmtiExport::should_post_field_access()) { \ - JvmtiExport::jni_GetField_probe(thread, NULL, NULL, id->holder(), fieldID, true); \ + JvmtiExport::jni_GetField_probe(thread, nullptr, nullptr, id->holder(), fieldID, true); \ } \ ret = id->holder()->java_mirror()-> Fieldname##_field (id->offset()); \ return ret;\ @@ -2070,7 +2070,7 @@ JNI_ENTRY(void, jni_SetStaticObjectField(JNIEnv *env, jclass clazz, jfieldID fie if (JvmtiExport::should_post_field_modification()) { jvalue field_value; field_value.l = value; - JvmtiExport::jni_SetField_probe(thread, NULL, NULL, id->holder(), fieldID, true, JVM_SIGNATURE_CLASS, (jvalue *)&field_value); + JvmtiExport::jni_SetField_probe(thread, nullptr, nullptr, id->holder(), fieldID, true, JVM_SIGNATURE_CLASS, (jvalue *)&field_value); } id->holder()->java_mirror()->obj_field_put(id->offset(), JNIHandles::resolve(value)); HOTSPOT_JNI_SETSTATICOBJECTFIELD_RETURN(); @@ -2091,7 +2091,7 @@ JNI_ENTRY(void, jni_SetStatic##Result##Field(JNIEnv *env, jclass clazz, jfieldID if (JvmtiExport::should_post_field_modification()) { \ jvalue field_value; \ field_value.unionType = value; \ - JvmtiExport::jni_SetField_probe(thread, NULL, NULL, id->holder(), fieldID, true, SigType, (jvalue *)&field_value); \ + JvmtiExport::jni_SetField_probe(thread, nullptr, nullptr, id->holder(), fieldID, true, SigType, (jvalue *)&field_value); \ } \ if (SigType == JVM_SIGNATURE_BOOLEAN) { value = ((jboolean)value) & 1; } \ id->holder()->java_mirror()-> Fieldname##_field_put (id->offset(), value); \ @@ -2135,7 +2135,7 @@ DT_RETURN_MARK_DECL(NewString, jstring JNI_ENTRY(jstring, jni_NewString(JNIEnv *env, const jchar *unicodeChars, jsize len)) HOTSPOT_JNI_NEWSTRING_ENTRY(env, (uint16_t *) unicodeChars, len); - jstring ret = NULL; + jstring ret = nullptr; DT_RETURN_MARK(NewString, jstring, (const jstring&)ret); oop string=java_lang_String::create_oop_from_unicode((jchar*) unicodeChars, len, CHECK_NULL); ret = (jstring) JNIHandles::make_local(THREAD, string); @@ -2156,15 +2156,15 @@ JNI_END JNI_ENTRY_NO_PRESERVE(const jchar*, jni_GetStringChars( JNIEnv *env, jstring string, jboolean *isCopy)) HOTSPOT_JNI_GETSTRINGCHARS_ENTRY(env, string, (uintptr_t *) isCopy); - jchar* buf = NULL; + jchar* buf = nullptr; oop s = JNIHandles::resolve_non_null(string); typeArrayOop s_value = java_lang_String::value(s); - if (s_value != NULL) { + if (s_value != nullptr) { int s_len = java_lang_String::length(s, s_value); bool is_latin1 = java_lang_String::is_latin1(s); buf = NEW_C_HEAP_ARRAY_RETURN_NULL(jchar, s_len + 1, mtInternal); // add one for zero termination - /* JNI Specification states return NULL on OOM */ - if (buf != NULL) { + /* JNI Specification states return null on OOM */ + if (buf != nullptr) { if (s_len > 0) { if (!is_latin1) { ArrayAccess<>::arraycopy_to_native(s_value, (size_t) typeArrayOopDesc::element_offset(0), @@ -2177,7 +2177,7 @@ JNI_ENTRY_NO_PRESERVE(const jchar*, jni_GetStringChars( } buf[s_len] = 0; //%note jni_5 - if (isCopy != NULL) { + if (isCopy != nullptr) { *isCopy = JNI_TRUE; } } @@ -2190,7 +2190,7 @@ JNI_END JNI_ENTRY_NO_PRESERVE(void, jni_ReleaseStringChars(JNIEnv *env, jstring str, const jchar *chars)) HOTSPOT_JNI_RELEASESTRINGCHARS_ENTRY(env, str, (uint16_t *) chars); //%note jni_6 - if (chars != NULL) { + if (chars != nullptr) { // Since String objects are supposed to be immutable, don't copy any // new data back. A bad user will have to go after the char array. FreeHeap((void*) chars); @@ -2226,16 +2226,16 @@ JNI_END JNI_ENTRY(const char*, jni_GetStringUTFChars(JNIEnv *env, jstring string, jboolean *isCopy)) HOTSPOT_JNI_GETSTRINGUTFCHARS_ENTRY(env, string, (uintptr_t *) isCopy); - char* result = NULL; + char* result = nullptr; oop java_string = JNIHandles::resolve_non_null(string); typeArrayOop s_value = java_lang_String::value(java_string); - if (s_value != NULL) { + if (s_value != nullptr) { size_t length = java_lang_String::utf8_length(java_string, s_value); - /* JNI Specification states return NULL on OOM */ + /* JNI Specification states return null on OOM */ result = AllocateHeap(length + 1, mtInternal, AllocFailStrategy::RETURN_NULL); - if (result != NULL) { + if (result != nullptr) { java_lang_String::as_utf8_string(java_string, s_value, result, (int) length + 1); - if (isCopy != NULL) { + if (isCopy != nullptr) { *isCopy = JNI_TRUE; } } @@ -2247,7 +2247,7 @@ JNI_END JNI_LEAF(void, jni_ReleaseStringUTFChars(JNIEnv *env, jstring str, const char *chars)) HOTSPOT_JNI_RELEASESTRINGUTFCHARS_ENTRY(env, str, (char *) chars); - if (chars != NULL) { + if (chars != nullptr) { FreeHeap((char*) chars); } HOTSPOT_JNI_RELEASESTRINGUTFCHARS_RETURN(); @@ -2273,14 +2273,14 @@ DT_RETURN_MARK_DECL(NewObjectArray, jobjectArray JNI_ENTRY(jobjectArray, jni_NewObjectArray(JNIEnv *env, jsize length, jclass elementClass, jobject initialElement)) HOTSPOT_JNI_NEWOBJECTARRAY_ENTRY(env, length, elementClass, initialElement); - jobjectArray ret = NULL; + jobjectArray ret = nullptr; DT_RETURN_MARK(NewObjectArray, jobjectArray, (const jobjectArray&)ret); Klass* ek = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(elementClass)); Klass* ak = ek->array_klass(CHECK_NULL); ObjArrayKlass::cast(ak)->initialize(CHECK_NULL); objArrayOop result = ObjArrayKlass::cast(ak)->allocate(length, CHECK_NULL); oop initial_value = JNIHandles::resolve(initialElement); - if (initial_value != NULL) { // array already initialized with NULL + if (initial_value != nullptr) { // array already initialized with null for (int index = 0; index < length; index++) { result->obj_at_put(index, initial_value); } @@ -2294,7 +2294,7 @@ DT_RETURN_MARK_DECL(GetObjectArrayElement, jobject JNI_ENTRY(jobject, jni_GetObjectArrayElement(JNIEnv *env, jobjectArray array, jsize index)) HOTSPOT_JNI_GETOBJECTARRAYELEMENT_ENTRY(env, array, index); - jobject ret = NULL; + jobject ret = nullptr; DT_RETURN_MARK(GetObjectArrayElement, jobject, (const jobject&)ret); objArrayOop a = objArrayOop(JNIHandles::resolve_non_null(array)); if (a->is_within_bounds(index)) { @@ -2318,7 +2318,7 @@ JNI_ENTRY(void, jni_SetObjectArrayElement(JNIEnv *env, jobjectArray array, jsize objArrayOop a = objArrayOop(JNIHandles::resolve_non_null(array)); oop v = JNIHandles::resolve(value); if (a->is_within_bounds(index)) { - if (v == NULL || v->is_a(ObjArrayKlass::cast(a->klass())->element_klass())) { + if (v == nullptr || v->is_a(ObjArrayKlass::cast(a->klass())->element_klass())) { a->obj_at_put(index, v); } else { ResourceMark rm(THREAD); @@ -2352,7 +2352,7 @@ JNI_END JNI_ENTRY(Return, \ jni_New##Result##Array(JNIEnv *env, jsize len)) \ EntryProbe; \ - Return ret = NULL;\ + Return ret = nullptr;\ DT_RETURN_MARK(New##Result##Array, Return, (const Return&)ret);\ \ oop obj= oopFactory::Allocator(len, CHECK_NULL); \ @@ -2388,11 +2388,11 @@ DEFINE_NEWSCALARARRAY(jdoubleArray, new_doubleArray, Double, // Return an address which will fault if the caller writes to it. static char* get_bad_address() { - static char* bad_address = NULL; - if (bad_address == NULL) { + static char* bad_address = nullptr; + if (bad_address == nullptr) { size_t size = os::vm_allocation_granularity(); bad_address = os::reserve_memory(size); - if (bad_address != NULL) { + if (bad_address != nullptr) { os::protect_memory(bad_address, size, os::MEM_PROT_READ, /*is_committed*/false); MemTracker::record_virtual_memory_type((void*)bad_address, mtInternal); @@ -2414,17 +2414,17 @@ JNI_ENTRY_NO_PRESERVE(ElementType*, \ ElementType* result; \ int len = a->length(); \ if (len == 0) { \ - if (isCopy != NULL) { \ + if (isCopy != nullptr) { \ *isCopy = JNI_FALSE; \ } \ - /* Empty array: legal but useless, can't return NULL. \ + /* Empty array: legal but useless, can't return null. \ * Return a pointer to something useless. \ * Avoid asserts in typeArrayOop. */ \ result = (ElementType*)get_bad_address(); \ } else { \ - /* JNI Specification states return NULL on OOM */ \ + /* JNI Specification states return null on OOM */ \ result = NEW_C_HEAP_ARRAY_RETURN_NULL(ElementType, len, mtInternal); \ - if (result != NULL) { \ + if (result != nullptr) { \ /* copy the array to the c chunk */ \ ArrayAccess<>::arraycopy_to_native(a, typeArrayOopDesc::element_offset(0), \ result, len); \ @@ -2634,12 +2634,12 @@ JNI_ENTRY(jint, jni_RegisterNatives(JNIEnv *env, jclass clazz, oop cl = k->class_loader(); InstanceKlass* ik = InstanceKlass::cast(k); // Check for a platform class - if ((cl == NULL || SystemDictionary::is_platform_class_loader(cl)) && + if ((cl == nullptr || SystemDictionary::is_platform_class_loader(cl)) && ik->module()->is_named()) { Klass* caller = thread->security_get_caller_class(1); // If no caller class, or caller class has a different loader, then // issue a warning below. - do_warning = (caller == NULL) || caller->class_loader() != cl; + do_warning = (caller == nullptr) || caller->class_loader() != cl; } } @@ -2655,7 +2655,7 @@ JNI_ENTRY(jint, jni_RegisterNatives(JNIEnv *env, jclass clazz, TempNewSymbol name = SymbolTable::probe(meth_name, meth_name_len); TempNewSymbol signature = SymbolTable::probe(meth_sig, (int)strlen(meth_sig)); - if (name == NULL || signature == NULL) { + if (name == nullptr || signature == nullptr) { ResourceMark rm(THREAD); stringStream st; st.print("Method %s.%s%s not found", k->external_name(), meth_name, meth_sig); @@ -2689,7 +2689,7 @@ JNI_ENTRY(jint, jni_UnregisterNatives(JNIEnv *env, jclass clazz)) Method* m = InstanceKlass::cast(k)->methods()->at(index); if (m->is_native()) { m->clear_native_function(); - m->set_signature_handler(NULL); + m->set_signature_handler(nullptr); } } } @@ -2710,7 +2710,7 @@ JNI_ENTRY(jint, jni_MonitorEnter(JNIEnv *env, jobject jobj)) DT_RETURN_MARK(MonitorEnter, jint, (const jint&)ret); // If the object is null, we can't do anything with it - if (jobj == NULL) { + if (jobj == nullptr) { THROW_(vmSymbols::java_lang_NullPointerException(), JNI_ERR); } @@ -2728,7 +2728,7 @@ JNI_ENTRY(jint, jni_MonitorExit(JNIEnv *env, jobject jobj)) DT_RETURN_MARK(MonitorExit, jint, (const jint&)ret); // Don't do anything with a null object - if (jobj == NULL) { + if (jobj == nullptr) { THROW_(vmSymbols::java_lang_NullPointerException(), JNI_ERR); } @@ -2786,7 +2786,7 @@ JNI_ENTRY(void, jni_GetStringUTFRegion(JNIEnv *env, jstring string, jsize start, // as_utf8_string null-terminates the result string } else { // JDK null-terminates the buffer even in len is zero - if (buf != NULL) { + if (buf != nullptr) { buf[0] = 0; } } @@ -2803,7 +2803,7 @@ JNI_ENTRY(void*, jni_GetPrimitiveArrayCritical(JNIEnv *env, jarray array, jboole BasicType type = TypeArrayKlass::cast(a->klass())->element_type(); void* ret = arrayOop(a())->base(type); - if (isCopy != NULL) { + if (isCopy != nullptr) { *isCopy = JNI_FALSE; } HOTSPOT_JNI_GETPRIMITIVEARRAYCRITICAL_RETURN(ret); @@ -2830,20 +2830,20 @@ JNI_ENTRY(const jchar*, jni_GetStringCritical(JNIEnv *env, jstring string, jbool Universe::heap()->pin_object(thread, s_value()); ret = (jchar*) s_value->base(T_CHAR); - if (isCopy != NULL) *isCopy = JNI_FALSE; + if (isCopy != nullptr) *isCopy = JNI_FALSE; } else { // Inflate latin1 encoded string to UTF16 typeArrayOop s_value = java_lang_String::value(s); int s_len = java_lang_String::length(s, s_value); ret = NEW_C_HEAP_ARRAY_RETURN_NULL(jchar, s_len + 1, mtInternal); // add one for zero termination - /* JNI Specification states return NULL on OOM */ - if (ret != NULL) { + /* JNI Specification states return null on OOM */ + if (ret != nullptr) { for (int i = 0; i < s_len; i++) { ret[i] = ((jchar) s_value->byte_at(i)) & 0xff; } ret[s_len] = 0; } - if (isCopy != NULL) *isCopy = JNI_TRUE; + if (isCopy != nullptr) *isCopy = JNI_TRUE; } HOTSPOT_JNI_GETSTRINGCRITICAL_RETURN((uint16_t *) ret); return ret; @@ -2875,8 +2875,8 @@ JNI_ENTRY(jweak, jni_NewWeakGlobalRef(JNIEnv *env, jobject ref)) HOTSPOT_JNI_NEWWEAKGLOBALREF_ENTRY(env, ref); Handle ref_handle(thread, JNIHandles::resolve(ref)); jweak ret = JNIHandles::make_weak_global(ref_handle, AllocFailStrategy::RETURN_NULL); - if (ret == NULL) { - THROW_OOP_(Universe::out_of_memory_error_c_heap(), NULL); + if (ret == nullptr) { + THROW_OOP_(Universe::out_of_memory_error_c_heap(), nullptr); } HOTSPOT_JNI_NEWWEAKGLOBALREF_RETURN(ret); return ret; @@ -2904,12 +2904,12 @@ JNI_END static int directBufferSupportInitializeStarted = 0; static volatile int directBufferSupportInitializeEnded = 0; static volatile int directBufferSupportInitializeFailed = 0; -static jclass bufferClass = NULL; -static jclass directBufferClass = NULL; -static jclass directByteBufferClass = NULL; -static jmethodID directByteBufferConstructor = NULL; -static jfieldID directBufferAddressField = NULL; -static jfieldID bufferCapacityField = NULL; +static jclass bufferClass = nullptr; +static jclass directBufferClass = nullptr; +static jclass directByteBufferClass = nullptr; +static jmethodID directByteBufferConstructor = nullptr; +static jfieldID directBufferAddressField = nullptr; +static jfieldID bufferCapacityField = nullptr; static jclass lookupOne(JNIEnv* env, const char* name, TRAPS) { Handle loader; // null (bootstrap) loader @@ -2918,19 +2918,19 @@ static jclass lookupOne(JNIEnv* env, const char* name, TRAPS) { TempNewSymbol sym = SymbolTable::new_symbol(name); jclass result = find_class_from_class_loader(env, sym, true, loader, protection_domain, true, CHECK_NULL); - if (log_is_enabled(Debug, class, resolve) && result != NULL) { + if (log_is_enabled(Debug, class, resolve) && result != nullptr) { trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result))); } return result; } -// These lookups are done with the NULL (bootstrap) ClassLoader to +// These lookups are done with the null (bootstrap) ClassLoader to // circumvent any security checks that would be done by jni_FindClass. JNI_ENTRY(bool, lookupDirectBufferClasses(JNIEnv* env)) { - if ((bufferClass = lookupOne(env, "java/nio/Buffer", thread)) == NULL) { return false; } - if ((directBufferClass = lookupOne(env, "sun/nio/ch/DirectBuffer", thread)) == NULL) { return false; } - if ((directByteBufferClass = lookupOne(env, "java/nio/DirectByteBuffer", thread)) == NULL) { return false; } + if ((bufferClass = lookupOne(env, "java/nio/Buffer", thread)) == nullptr) { return false; } + if ((directBufferClass = lookupOne(env, "sun/nio/ch/DirectBuffer", thread)) == nullptr) { return false; } + if ((directByteBufferClass = lookupOne(env, "java/nio/DirectByteBuffer", thread)) == nullptr) { return false; } return true; } JNI_END @@ -2952,8 +2952,8 @@ static bool initializeDirectBufferSupport(JNIEnv* env, JavaThread* thread) { directBufferClass = (jclass) env->NewGlobalRef(directBufferClass); directByteBufferClass = (jclass) env->NewGlobalRef(directByteBufferClass); - // Global refs will be NULL if out-of-memory (no exception is pending) - if (bufferClass == NULL || directBufferClass == NULL || directByteBufferClass == NULL) { + // Global refs will be null if out-of-memory (no exception is pending) + if (bufferClass == nullptr || directBufferClass == nullptr || directByteBufferClass == nullptr) { directBufferSupportInitializeFailed = 1; return false; } @@ -2978,9 +2978,9 @@ static bool initializeDirectBufferSupport(JNIEnv* env, JavaThread* thread) { return false; } - if ((directByteBufferConstructor == NULL) || - (directBufferAddressField == NULL) || - (bufferCapacityField == NULL)) { + if ((directByteBufferConstructor == nullptr) || + (directBufferAddressField == nullptr) || + (bufferCapacityField == nullptr)) { directBufferSupportInitializeFailed = 1; return false; } @@ -3004,8 +3004,8 @@ extern "C" jobject JNICALL jni_NewDirectByteBuffer(JNIEnv *env, void* address, j if (!directBufferSupportInitializeEnded) { if (!initializeDirectBufferSupport(env, thread)) { - HOTSPOT_JNI_NEWDIRECTBYTEBUFFER_RETURN(NULL); - return NULL; + HOTSPOT_JNI_NEWDIRECTBYTEBUFFER_RETURN(nullptr); + return nullptr; } } @@ -3025,7 +3025,7 @@ extern "C" void* JNICALL jni_GetDirectBufferAddress(JNIEnv *env, jobject buf) JavaThread* thread = JavaThread::thread_from_jni_environment(env); HOTSPOT_JNI_GETDIRECTBUFFERADDRESS_ENTRY(env, buf); - void* ret = NULL; + void* ret = nullptr; DT_RETURN_MARK(GetDirectBufferAddress, void*, (const void*&)ret); if (!directBufferSupportInitializeEnded) { @@ -3034,7 +3034,7 @@ extern "C" void* JNICALL jni_GetDirectBufferAddress(JNIEnv *env, jobject buf) } } - if ((buf != NULL) && (!env->IsInstanceOf(buf, directBufferClass))) { + if ((buf != nullptr) && (!env->IsInstanceOf(buf, directBufferClass))) { return 0; } @@ -3061,7 +3061,7 @@ extern "C" jlong JNICALL jni_GetDirectBufferCapacity(JNIEnv *env, jobject buf) } } - if (buf == NULL) { + if (buf == nullptr) { return -1; } @@ -3097,7 +3097,7 @@ JNI_END JNI_ENTRY(jboolean, jni_IsVirtualThread(JNIEnv* env, jobject obj)) oop thread_obj = JNIHandles::resolve_external_guard(obj); - if (thread_obj != NULL && thread_obj->is_a(vmClasses::BasicVirtualThread_klass())) { + if (thread_obj != nullptr && thread_obj->is_a(vmClasses::BasicVirtualThread_klass())) { return JNI_TRUE; } else { return JNI_FALSE; @@ -3107,11 +3107,11 @@ JNI_END // Structure containing all jni functions struct JNINativeInterface_ jni_NativeInterface = { - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, - NULL, + nullptr, jni_GetVersion, @@ -3464,7 +3464,7 @@ struct JNINativeInterface_* jni_functions_nocheck() { } static void post_thread_start_event(const JavaThread* jt) { - assert(jt != NULL, "invariant"); + assert(jt != nullptr, "invariant"); EventThreadStart event; if (event.should_commit()) { event.set_thread(JFR_JVM_THREAD_ID(jt)); @@ -3684,10 +3684,10 @@ _JNI_IMPORT_OR_EXPORT_ jint JNICALL JNI_GetCreatedJavaVMs(JavaVM **vm_buf, jsize HOTSPOT_JNI_GETCREATEDJAVAVMS_ENTRY((void **) vm_buf, bufLen, (uintptr_t *) numVMs); if (vm_created == 1) { - if (numVMs != NULL) *numVMs = 1; + if (numVMs != nullptr) *numVMs = 1; if (bufLen > 0) *vm_buf = (JavaVM *)(&main_vm); } else { - if (numVMs != NULL) *numVMs = 0; + if (numVMs != nullptr) *numVMs = 0; } HOTSPOT_JNI_GETCREATEDJAVAVMS_RETURN(JNI_OK); return JNI_OK; @@ -3712,7 +3712,7 @@ static jint JNICALL jni_DestroyJavaVM_inner(JavaVM *vm) { JavaVMAttachArgs destroyargs; destroyargs.version = CurrentVersion; destroyargs.name = (char *)"DestroyJavaVM"; - destroyargs.group = NULL; + destroyargs.group = nullptr; res = vm->AttachCurrentThread((void **)&env, (void *)&destroyargs); if (res != JNI_OK) { return res; @@ -3764,7 +3764,7 @@ static jint attach_current_thread(JavaVM *vm, void **penv, void *_args, bool dae */ Thread* t = Thread::current_or_null(); - if (t != NULL) { + if (t != nullptr) { // If executing from an atexit hook we may be in the VMThread. if (t->is_Java_thread()) { // If the thread has been attached this operation is a no-op @@ -3808,13 +3808,13 @@ static jint attach_current_thread(JavaVM *vm, void **penv, void *_args, bool dae Threads::add(thread, daemon); } // Create thread group and name info from attach arguments - oop group = NULL; - char* thread_name = NULL; - if (args != NULL && Threads::is_supported_jni_version(args->version)) { + oop group = nullptr; + char* thread_name = nullptr; + if (args != nullptr && Threads::is_supported_jni_version(args->version)) { group = JNIHandles::resolve(args->group); - thread_name = args->name; // may be NULL + thread_name = args->name; // may be null } - if (group == NULL) group = Universe::main_thread_group(); + if (group == nullptr) group = Universe::main_thread_group(); // Create Java level thread object and attach it to this thread bool attach_failed = false; @@ -3889,7 +3889,7 @@ jint JNICALL jni_DetachCurrentThread(JavaVM *vm) { Thread* current = Thread::current_or_null(); // If the thread has already been detached the operation is a no-op - if (current == NULL) { + if (current == nullptr) { HOTSPOT_JNI_DETACHCURRENTTHREAD_RETURN(JNI_OK); return JNI_OK; } @@ -3945,14 +3945,14 @@ jint JNICALL jni_GetEnv(JavaVM *vm, void **penv, jint version) { DT_RETURN_MARK(GetEnv, jint, (const jint&)ret); if (vm_created == 0) { - *penv = NULL; + *penv = nullptr; ret = JNI_EDETACHED; return ret; } // No JVM TI with --enable-preview and no continuations support. if (!VMContinuations && Arguments::enable_preview() && JvmtiExport::is_jvmti_version(version)) { - *penv = NULL; + *penv = nullptr; ret = JNI_EVERSION; return ret; } @@ -3969,7 +3969,7 @@ jint JNICALL jni_GetEnv(JavaVM *vm, void **penv, jint version) { #endif // !JVMPI_VERSION_1 Thread* thread = Thread::current_or_null(); - if (thread != NULL && thread->is_Java_thread()) { + if (thread != nullptr && thread->is_Java_thread()) { if (Threads::is_supported_jni_version_including_1_1(version)) { *(JNIEnv**)penv = JavaThread::cast(thread)->jni_environment(); ret = JNI_OK; @@ -3988,12 +3988,12 @@ jint JNICALL jni_GetEnv(JavaVM *vm, void **penv, jint version) { ret = JNI_EVERSION; return ret; } else { - *penv = NULL; + *penv = nullptr; ret = JNI_EVERSION; return ret; } } else { - *penv = NULL; + *penv = nullptr; ret = JNI_EDETACHED; return ret; } @@ -4016,9 +4016,9 @@ jint JNICALL jni_AttachCurrentThreadAsDaemon(JavaVM *vm, void **penv, void *_arg } // End extern "C" const struct JNIInvokeInterface_ jni_InvokeInterface = { - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, jni_DestroyJavaVM, jni_AttachCurrentThread, diff --git a/src/hotspot/share/prims/jniCheck.cpp b/src/hotspot/share/prims/jniCheck.cpp index 70187f7818511..70598dc7eb7c1 100644 --- a/src/hotspot/share/prims/jniCheck.cpp +++ b/src/hotspot/share/prims/jniCheck.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2022, 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 @@ -92,7 +92,7 @@ static struct JNINativeInterface_ * unchecked_jni_NativeInterface; extern "C" { \ result_type JNICALL header { \ Thread* cur = Thread::current_or_null(); \ - if (cur == NULL || !cur->is_Java_thread()) { \ + if (cur == nullptr || !cur->is_Java_thread()) { \ tty->print_cr("%s", fatal_using_jnienv_in_nonjava); \ os::abort(true); \ } \ @@ -101,7 +101,7 @@ extern "C" { \ if (env != xenv) { \ NativeReportJNIFatalError(thr, warn_wrong_jnienv); \ } \ - MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, thr)); \ + MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, thr)); \ VM_ENTRY_BASE(result_type, header, thr) @@ -273,7 +273,7 @@ checkInstanceFieldID(JavaThread* thr, jfieldID fid, jobject obj, int ftype) /* validate the object being passed and then get its class */ ASSERT_OOPS_ALLOWED; oop oopObj = jniCheck::validate_object(thr, obj); - if (oopObj == NULL) { + if (oopObj == nullptr) { ReportJNIFatalError(thr, fatal_null_object); } Klass* k_oop = oopObj->klass(); @@ -303,7 +303,7 @@ checkString(JavaThread* thr, jstring js) { ASSERT_OOPS_ALLOWED; oop s = jniCheck::validate_object(thr, js); - if ((s == NULL) || !java_lang_String::is_instance(s)) + if ((s == nullptr) || !java_lang_String::is_instance(s)) ReportJNIFatalError(thr, fatal_non_string); } @@ -314,7 +314,7 @@ check_is_array(JavaThread* thr, jarray jArray) arrayOop aOop; aOop = (arrayOop)jniCheck::validate_object(thr, jArray); - if (aOop == NULL || !aOop->is_array()) { + if (aOop == nullptr || !aOop->is_array()) { ReportJNIFatalError(thr, fatal_non_array); } return aOop; @@ -369,9 +369,9 @@ static void* check_jni_wrap_copy_array(JavaThread* thr, jarray array, static void* check_wrapped_array(JavaThread* thr, const char* fn_name, void* obj, void* carray, size_t* rsz) { - if (carray == NULL) { - tty->print_cr("%s: elements vector NULL" PTR_FORMAT, fn_name, p2i(obj)); - NativeReportJNIFatalError(thr, "Elements vector NULL"); + if (carray == nullptr) { + tty->print_cr("%s: elements vector null" PTR_FORMAT, fn_name, p2i(obj)); + NativeReportJNIFatalError(thr, "Elements vector null"); } GuardedMemory guarded(carray); void* orig_result = guarded.get_tag(); @@ -381,13 +381,13 @@ static void* check_wrapped_array(JavaThread* thr, const char* fn_name, DEBUG_ONLY(guarded.print_on(tty);) // This may crash. NativeReportJNIFatalError(thr, err_msg("%s: failed bounds check", fn_name)); } - if (orig_result == NULL) { + if (orig_result == nullptr) { tty->print_cr("%s: unrecognized elements. array: " PTR_FORMAT " carray: " PTR_FORMAT, fn_name, p2i(obj), p2i(carray)); DEBUG_ONLY(guarded.print_on(tty);) // This may crash. NativeReportJNIFatalError(thr, err_msg("%s: unrecognized elements", fn_name)); } - if (rsz != NULL) { + if (rsz != nullptr) { *rsz = guarded.get_user_size(); } return orig_result; @@ -422,12 +422,12 @@ static void* check_wrapped_array_release(JavaThread* thr, const char* fn_name, } oop jniCheck::validate_handle(JavaThread* thr, jobject obj) { - if ((obj != NULL) && (JNIHandles::handle_type(thr, obj) != JNIInvalidRefType)) { + if ((obj != nullptr) && (JNIHandles::handle_type(thr, obj) != JNIInvalidRefType)) { ASSERT_OOPS_ALLOWED; return JNIHandles::resolve_external_guard(obj); } ReportJNIFatalError(thr, fatal_bad_ref_to_jni); - return NULL; + return nullptr; } @@ -435,7 +435,7 @@ Method* jniCheck::validate_jmethod_id(JavaThread* thr, jmethodID method_id) { ASSERT_OOPS_ALLOWED; // do the fast jmethodID check first Method* m = Method::checked_resolve_jmethod_id(method_id); - if (m == NULL) { + if (m == nullptr) { ReportJNIFatalError(thr, fatal_wrong_class_or_method); } // jmethodIDs are handles in the class loader data, @@ -448,10 +448,10 @@ Method* jniCheck::validate_jmethod_id(JavaThread* thr, jmethodID method_id) { oop jniCheck::validate_object(JavaThread* thr, jobject obj) { - if (obj == NULL) return NULL; + if (obj == nullptr) return nullptr; ASSERT_OOPS_ALLOWED; oop oopObj = jniCheck::validate_handle(thr, obj); - if (oopObj == NULL) { + if (oopObj == nullptr) { ReportJNIFatalError(thr, fatal_bad_ref_to_jni); } return oopObj; @@ -461,7 +461,7 @@ oop jniCheck::validate_object(JavaThread* thr, jobject obj) { // passed to JNI findClass should not be decorated unless they are // array descriptors. void jniCheck::validate_class_descriptor(JavaThread* thr, const char* name) { - if (name == NULL) return; // implementation accepts NULL so just return + if (name == nullptr) return; // implementation accepts null so just return size_t len = strlen(name); @@ -485,7 +485,7 @@ void jniCheck::validate_class_descriptor(JavaThread* thr, const char* name) { Klass* jniCheck::validate_class(JavaThread* thr, jclass clazz, bool allow_primitive) { ASSERT_OOPS_ALLOWED; oop mirror = jniCheck::validate_handle(thr, clazz); - if (mirror == NULL) { + if (mirror == nullptr) { ReportJNIFatalError(thr, fatal_received_null_class); } @@ -495,7 +495,7 @@ Klass* jniCheck::validate_class(JavaThread* thr, jclass clazz, bool allow_primit Klass* k = java_lang_Class::as_Klass(mirror); // Make allowances for primitive classes ... - if (!(k != NULL || (allow_primitive && java_lang_Class::is_primitive(mirror)))) { + if (!(k != nullptr || (allow_primitive && java_lang_Class::is_primitive(mirror)))) { ReportJNIFatalError(thr, fatal_class_not_a_class); } return k; @@ -503,7 +503,7 @@ Klass* jniCheck::validate_class(JavaThread* thr, jclass clazz, bool allow_primit void jniCheck::validate_throwable_klass(JavaThread* thr, Klass* klass) { ASSERT_OOPS_ALLOWED; - assert(klass != NULL, "klass argument must have a value"); + assert(klass != nullptr, "klass argument must have a value"); if (!klass->is_instance_klass() || !klass->is_subclass_of(vmClasses::Throwable_klass())) { @@ -516,7 +516,7 @@ void jniCheck::validate_call(JavaThread* thr, jclass clazz, jmethodID method_id, Method* m = jniCheck::validate_jmethod_id(thr, method_id); InstanceKlass* holder = m->method_holder(); - if (clazz != NULL) { + if (clazz != nullptr) { Klass* k = jniCheck::validate_class(thr, clazz, false); // Check that method is in the class, must be InstanceKlass if (!InstanceKlass::cast(k)->is_subtype_of(holder)) { @@ -524,9 +524,9 @@ void jniCheck::validate_call(JavaThread* thr, jclass clazz, jmethodID method_id, } } - if (obj != NULL) { + if (obj != nullptr) { oop recv = jniCheck::validate_object(thr, obj); - assert(recv != NULL, "validate_object checks that"); + assert(recv != nullptr, "validate_object checks that"); Klass* rk = recv->klass(); // Check that the object is a subtype of method holder too. @@ -654,9 +654,9 @@ JNI_ENTRY_CHECKED(jint, functionEnter(thr); IN_VM( oop oopObj = jniCheck::validate_object(thr, obj); - if (oopObj == NULL) { - // Unchecked Throw tolerates a NULL obj, so just warn - ReportJNIWarning(thr, "JNI Throw called with NULL throwable"); + if (oopObj == nullptr) { + // Unchecked Throw tolerates a null obj, so just warn + ReportJNIWarning(thr, "JNI Throw called with null throwable"); } else { jniCheck::validate_throwable_klass(thr, oopObj->klass()); } @@ -673,7 +673,7 @@ JNI_ENTRY_CHECKED(jint, functionEnter(thr); IN_VM( Klass* k = jniCheck::validate_class(thr, clazz, false); - assert(k != NULL, "validate_class shouldn't return NULL Klass*"); + assert(k != nullptr, "validate_class shouldn't return null Klass*"); jniCheck::validate_throwable_klass(thr, k); ) jint result = UNCHECKED()->ThrowNew(env, clazz, msg); @@ -739,7 +739,7 @@ JNI_ENTRY_CHECKED(jobject, jobject lobj)) functionEnter(thr); IN_VM( - if (lobj != NULL) { + if (lobj != nullptr) { jniCheck::validate_handle(thr, lobj); } ) @@ -785,13 +785,13 @@ JNI_ENTRY_CHECKED(jboolean, functionEnterExceptionAllowed(thr); IN_VM( /* This JNI function can be used to compare weak global references - * to NULL objects. If the handles are valid, but contain NULL, + * to nullptr objects. If the handles are valid, but contain nullptr, * then don't attempt to validate the object. */ - if (obj1 != NULL && jniCheck::validate_handle(thr, obj1) != NULL) { + if (obj1 != nullptr && jniCheck::validate_handle(thr, obj1) != nullptr) { jniCheck::validate_object(thr, obj1); } - if (obj2 != NULL && jniCheck::validate_handle(thr, obj2) != NULL) { + if (obj2 != nullptr && jniCheck::validate_handle(thr, obj2) != nullptr) { jniCheck::validate_object(thr, obj2); } ) @@ -805,7 +805,7 @@ JNI_ENTRY_CHECKED(jobject, jobject ref)) functionEnter(thr); IN_VM( - if (ref != NULL) { + if (ref != nullptr) { jniCheck::validate_handle(thr, ref); } ) @@ -932,7 +932,7 @@ JNI_ENTRY_CHECKED(ResultType, \ functionEnter(thr); \ va_list args; \ IN_VM( \ - jniCheck::validate_call(thr, NULL, methodID, obj); \ + jniCheck::validate_call(thr, nullptr, methodID, obj); \ ) \ va_start(args,methodID); \ ResultType result =UNCHECKED()->Call##Result##MethodV(env, obj, methodID, \ @@ -950,7 +950,7 @@ JNI_ENTRY_CHECKED(ResultType, \ va_list args)) \ functionEnter(thr); \ IN_VM(\ - jniCheck::validate_call(thr, NULL, methodID, obj); \ + jniCheck::validate_call(thr, nullptr, methodID, obj); \ ) \ ResultType result = UNCHECKED()->Call##Result##MethodV(env, obj, methodID,\ args); \ @@ -966,7 +966,7 @@ JNI_ENTRY_CHECKED(ResultType, \ const jvalue * args)) \ functionEnter(thr); \ IN_VM( \ - jniCheck::validate_call(thr, NULL, methodID, obj); \ + jniCheck::validate_call(thr, nullptr, methodID, obj); \ ) \ ResultType result = UNCHECKED()->Call##Result##MethodA(env, obj, methodID,\ args); \ @@ -993,7 +993,7 @@ JNI_ENTRY_CHECKED(void, functionEnter(thr); va_list args; IN_VM( - jniCheck::validate_call(thr, NULL, methodID, obj); + jniCheck::validate_call(thr, nullptr, methodID, obj); ) va_start(args,methodID); UNCHECKED()->CallVoidMethodV(env,obj,methodID,args); @@ -1009,7 +1009,7 @@ JNI_ENTRY_CHECKED(void, va_list args)) functionEnter(thr); IN_VM( - jniCheck::validate_call(thr, NULL, methodID, obj); + jniCheck::validate_call(thr, nullptr, methodID, obj); ) UNCHECKED()->CallVoidMethodV(env,obj,methodID,args); thr->set_pending_jni_exception_check("CallVoidMethodV"); @@ -1023,7 +1023,7 @@ JNI_ENTRY_CHECKED(void, const jvalue * args)) functionEnter(thr); IN_VM( - jniCheck::validate_call(thr, NULL, methodID, obj); + jniCheck::validate_call(thr, nullptr, methodID, obj); ) UNCHECKED()->CallVoidMethodA(env,obj,methodID,args); thr->set_pending_jni_exception_check("CallVoidMethodA"); @@ -1442,14 +1442,14 @@ JNI_ENTRY_CHECKED(const jchar *, IN_VM( checkString(thr, str); ) - jchar* new_result = NULL; + jchar* new_result = nullptr; const jchar *result = UNCHECKED()->GetStringChars(env,str,isCopy); - assert (isCopy == NULL || *isCopy == JNI_TRUE, "GetStringChars didn't return a copy as expected"); - if (result != NULL) { - size_t len = UNCHECKED()->GetStringLength(env,str) + 1; // + 1 for NULL termination + assert (isCopy == nullptr || *isCopy == JNI_TRUE, "GetStringChars didn't return a copy as expected"); + if (result != nullptr) { + size_t len = UNCHECKED()->GetStringLength(env,str) + 1; // + 1 for null termination len *= sizeof(jchar); new_result = (jchar*) GuardedMemory::wrap_copy(result, len, STRING_TAG); - if (new_result == NULL) { + if (new_result == nullptr) { vm_exit_out_of_memory(len, OOM_MALLOC_ERROR, "checked_jni_GetStringChars"); } // Avoiding call to UNCHECKED()->ReleaseStringChars() since that will fire unexpected dtrace probes @@ -1468,7 +1468,7 @@ JNI_ENTRY_CHECKED(void, IN_VM( checkString(thr, str); ) - if (chars == NULL) { + if (chars == nullptr) { // still do the unchecked call to allow dtrace probes UNCHECKED()->ReleaseStringChars(env,str,chars); } @@ -1526,13 +1526,13 @@ JNI_ENTRY_CHECKED(const char *, IN_VM( checkString(thr, str); ) - char* new_result = NULL; + char* new_result = nullptr; const char *result = UNCHECKED()->GetStringUTFChars(env,str,isCopy); - assert (isCopy == NULL || *isCopy == JNI_TRUE, "GetStringUTFChars didn't return a copy as expected"); - if (result != NULL) { - size_t len = strlen(result) + 1; // + 1 for NULL termination + assert (isCopy == nullptr || *isCopy == JNI_TRUE, "GetStringUTFChars didn't return a copy as expected"); + if (result != nullptr) { + size_t len = strlen(result) + 1; // + 1 for null termination new_result = (char*) GuardedMemory::wrap_copy(result, len, STRING_UTF_TAG); - if (new_result == NULL) { + if (new_result == nullptr) { vm_exit_out_of_memory(len, OOM_MALLOC_ERROR, "checked_jni_GetStringUTFChars"); } // Avoiding call to UNCHECKED()->ReleaseStringUTFChars() since that will fire unexpected dtrace probes @@ -1551,7 +1551,7 @@ JNI_ENTRY_CHECKED(void, IN_VM( checkString(thr, str); ) - if (chars == NULL) { + if (chars == nullptr) { // still do the unchecked call to allow dtrace probes UNCHECKED()->ReleaseStringUTFChars(env,str,chars); } @@ -1657,7 +1657,7 @@ JNI_ENTRY_CHECKED(ElementType *, \ ElementType *result = UNCHECKED()->Get##Result##ArrayElements(env, \ array, \ isCopy); \ - if (result != NULL) { \ + if (result != nullptr) { \ result = (ElementType *) check_jni_wrap_copy_array(thr, array, result); \ } \ functionExit(thr); \ @@ -1838,7 +1838,7 @@ JNI_ENTRY_CHECKED(void *, check_is_primitive_array(thr, array); ) void *result = UNCHECKED()->GetPrimitiveArrayCritical(env, array, isCopy); - if (result != NULL) { + if (result != nullptr) { result = check_jni_wrap_copy_array(thr, array, result); } functionExit(thr); @@ -1894,7 +1894,7 @@ JNI_ENTRY_CHECKED(jweak, jobject obj)) functionEnter(thr); IN_VM( - if (obj != NULL) { + if (obj != nullptr) { jniCheck::validate_handle(thr, obj); } ) @@ -1998,11 +1998,11 @@ JNI_END * Structure containing all checked jni functions */ struct JNINativeInterface_ checked_jni_NativeInterface = { - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, - NULL, + nullptr, checked_jni_GetVersion, diff --git a/src/hotspot/share/prims/jniCheck.hpp b/src/hotspot/share/prims/jniCheck.hpp index a41c79441d698..186884f9e49f3 100644 --- a/src/hotspot/share/prims/jniCheck.hpp +++ b/src/hotspot/share/prims/jniCheck.hpp @@ -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 @@ -51,7 +51,7 @@ class jniCheck : public AllStatic { static Klass* validate_class(JavaThread* thr, jclass clazz, bool allow_primitive = false); static void validate_class_descriptor(JavaThread* thr, const char* name); static void validate_throwable_klass(JavaThread* thr, Klass* klass); - static void validate_call(JavaThread* thr, jclass clazz, jmethodID method_id, jobject obj = NULL); + static void validate_call(JavaThread* thr, jclass clazz, jmethodID method_id, jobject obj = nullptr); static Method* validate_jmethod_id(JavaThread* thr, jmethodID method_id); }; diff --git a/src/hotspot/share/prims/jvm.cpp b/src/hotspot/share/prims/jvm.cpp index d79b31bdb300a..ade54717d4973 100644 --- a/src/hotspot/share/prims/jvm.cpp +++ b/src/hotspot/share/prims/jvm.cpp @@ -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 @@ -147,9 +147,9 @@ static void trace_class_resolution_impl(Klass* to_class, TRAPS) { ResourceMark rm; int line_number = -1; - const char * source_file = NULL; + const char * source_file = nullptr; const char * trace = "explicit"; - InstanceKlass* caller = NULL; + InstanceKlass* caller = nullptr; JavaThread* jthread = THREAD; if (jthread->has_last_Java_frame()) { vframeStream vfst(jthread); @@ -160,7 +160,7 @@ static void trace_class_resolution_impl(Klass* to_class, TRAPS) { TempNewSymbol privileged_action = SymbolTable::new_symbol("java/security/PrivilegedAction"); Klass* privileged_action_klass = SystemDictionary::resolve_or_fail(privileged_action, false, CHECK); - Method* last_caller = NULL; + Method* last_caller = nullptr; while (!vfst.at_end()) { Method* m = vfst.method(); @@ -186,7 +186,7 @@ static void trace_class_resolution_impl(Klass* to_class, TRAPS) { vfst.next(); found_it = true; } - } else if (last_caller != NULL && + } else if (last_caller != nullptr && last_caller->method_holder()->name() == vmSymbols::java_lang_ClassLoader() && last_caller->name() == vmSymbols::loadClass_name()) { @@ -206,17 +206,17 @@ static void trace_class_resolution_impl(Klass* to_class, TRAPS) { trace = vfst.method()->name_and_sig_as_C_string(); } Symbol* s = caller->source_file_name(); - if (s != NULL) { + if (s != nullptr) { source_file = s->as_C_string(); } } } - if (caller != NULL) { + if (caller != nullptr) { if (to_class != caller) { const char * from = caller->external_name(); const char * to = to_class->external_name(); // print in a single call to reduce interleaving between threads - if (source_file != NULL) { + if (source_file != nullptr) { log_debug(class, resolve)("%s %s %s:%d (%s)", from, to, source_file, line_number, trace); } else { log_debug(class, resolve)("%s %s (%s)", from, to, trace); @@ -289,7 +289,7 @@ JVM_END JVM_ENTRY(void, JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos, jobject dst, jint dst_pos, jint length)) // Check if we have null pointers - if (src == NULL || dst == NULL) { + if (src == nullptr || dst == nullptr) { THROW(vmSymbols::java_lang_NullPointerException()); } arrayOop s = arrayOop(JNIHandles::resolve_non_null(src)); @@ -306,7 +306,7 @@ static void set_property(Handle props, const char* key, const char* value, TRAPS // public synchronized Object put(Object key, Object value); HandleMark hm(THREAD); Handle key_str = java_lang_String::create_from_platform_dependent_str(key, CHECK); - Handle value_str = java_lang_String::create_from_platform_dependent_str((value != NULL ? value : ""), CHECK); + Handle value_str = java_lang_String::create_from_platform_dependent_str((value != nullptr ? value : ""), CHECK); JavaCalls::call_virtual(&r, props, vmClasses::Properties_klass(), @@ -339,12 +339,12 @@ JVM_ENTRY(jobjectArray, JVM_GetProperties(JNIEnv *env)) objArrayOop r = oopFactory::new_objArray(ik, (count + fixedCount) * 2, CHECK_NULL); objArrayHandle result_h(THREAD, r); - while (p != NULL) { + while (p != nullptr) { const char * key = p->key(); if (strcmp(key, "sun.nio.MaxDirectMemorySize") != 0) { const char * value = p->value(); Handle key_str = java_lang_String::create_from_platform_dependent_str(key, CHECK_NULL); - Handle value_str = java_lang_String::create_from_platform_dependent_str((value != NULL ? value : ""), CHECK_NULL); + Handle value_str = java_lang_String::create_from_platform_dependent_str((value != nullptr ? value : ""), CHECK_NULL); result_h->obj_at_put(ndx * 2, key_str()); result_h->obj_at_put(ndx * 2 + 1, value_str()); ndx++; @@ -508,17 +508,17 @@ JVM_END // java.lang.NullPointerException /////////////////////////////////////////// JVM_ENTRY(jstring, JVM_GetExtendedNPEMessage(JNIEnv *env, jthrowable throwable)) - if (!ShowCodeDetailsInExceptionMessages) return NULL; + if (!ShowCodeDetailsInExceptionMessages) return nullptr; oop exc = JNIHandles::resolve_non_null(throwable); Method* method; int bci; if (!java_lang_Throwable::get_top_method_and_bci(exc, &method, &bci)) { - return NULL; + return nullptr; } if (method->is_native()) { - return NULL; + return nullptr; } stringStream ss; @@ -527,7 +527,7 @@ JVM_ENTRY(jstring, JVM_GetExtendedNPEMessage(JNIEnv *env, jthrowable throwable)) oop result = java_lang_String::create_oop_from_str(ss.base(), CHECK_NULL); return (jstring) JNIHandles::make_local(THREAD, result); } else { - return NULL; + return nullptr; } JVM_END @@ -557,7 +557,7 @@ JVM_ENTRY(jobject, JVM_CallStackWalk(JNIEnv *env, jobject stackStream, jlong mod jint skip_frames, jobject contScope, jobject cont, jint frame_count, jint start_index, jobjectArray frames)) if (!thread->has_last_Java_frame()) { - THROW_MSG_(vmSymbols::java_lang_InternalError(), "doStackWalk: no stack trace", NULL); + THROW_MSG_(vmSymbols::java_lang_InternalError(), "doStackWalk: no stack trace", nullptr); } Handle stackStream_h(THREAD, JNIHandles::resolve_non_null(stackStream)); @@ -571,7 +571,7 @@ JVM_ENTRY(jobject, JVM_CallStackWalk(JNIEnv *env, jobject stackStream, jlong mod int limit = start_index + frame_count; if (frames_array_h->length() < limit) { - THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(), "not enough space in buffers", NULL); + THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(), "not enough space in buffers", nullptr); } oop result = StackWalk::walk(stackStream_h, mode, skip_frames, contScope_h, cont_h, @@ -612,8 +612,8 @@ JVM_END JVM_ENTRY(jint, JVM_IHashCode(JNIEnv* env, jobject handle)) - // as implemented in the classic virtual machine; return 0 if object is NULL - return handle == NULL ? 0 : ObjectSynchronizer::FastHashCode (THREAD, JNIHandles::resolve_non_null(handle)) ; + // as implemented in the classic virtual machine; return 0 if object is null + return handle == nullptr ? 0 : ObjectSynchronizer::FastHashCode (THREAD, JNIHandles::resolve_non_null(handle)) ; JVM_END @@ -673,7 +673,7 @@ JVM_ENTRY(jobject, JVM_Clone(JNIEnv* env, jobject handle)) // Make shallow object copy const size_t size = obj->size(); - oop new_obj_oop = NULL; + oop new_obj_oop = nullptr; if (obj->is_array()) { const int length = ((arrayOop)obj())->length(); new_obj_oop = Universe::heap()->array_allocate(klass, size, length, @@ -735,7 +735,7 @@ JVM_ENTRY(jclass, JVM_GetCallerClass(JNIEnv* env)) // Cf. LibraryCallKit::inline_native_Reflection_getCallerClass for (int n = 0; !vfst.at_end(); vfst.security_next(), n++) { Method* m = vfst.method(); - assert(m != NULL, "sanity"); + assert(m != nullptr, "sanity"); switch (n) { case 0: // This must only be called from Reflection.getCallerClass @@ -757,17 +757,17 @@ JVM_ENTRY(jclass, JVM_GetCallerClass(JNIEnv* env)) break; } } - return NULL; + return nullptr; JVM_END JVM_ENTRY(jclass, JVM_FindPrimitiveClass(JNIEnv* env, const char* utf)) - oop mirror = NULL; + oop mirror = nullptr; BasicType t = name2type(utf); if (t != T_ILLEGAL && !is_reference_type(t)) { mirror = Universe::java_mirror(t); } - if (mirror == NULL) { + if (mirror == nullptr) { THROW_MSG_0(vmSymbols::java_lang_ClassNotFoundException(), (char*) utf); } else { return (jclass) JNIHandles::make_local(THREAD, mirror); @@ -781,17 +781,17 @@ JVM_END JVM_ENTRY(jclass, JVM_FindClassFromBootLoader(JNIEnv* env, const char* name)) // Java libraries should ensure that name is never null or illegal. - if (name == NULL || (int)strlen(name) > Symbol::max_length()) { + if (name == nullptr || (int)strlen(name) > Symbol::max_length()) { // It's impossible to create this class; the name cannot fit // into the constant pool. - return NULL; + return nullptr; } assert(UTF8::is_legal_utf8((const unsigned char*)name, (int)strlen(name), false), "illegal UTF name"); TempNewSymbol h_name = SymbolTable::new_symbol(name); Klass* k = SystemDictionary::resolve_or_null(h_name, CHECK_NULL); - if (k == NULL) { - return NULL; + if (k == nullptr) { + return nullptr; } if (log_is_enabled(Debug, class, resolve)) { @@ -810,13 +810,13 @@ JVM_ENTRY(jclass, JVM_FindClassFromCaller(JNIEnv* env, const char* name, oop loader_oop = JNIHandles::resolve(loader); oop from_class = JNIHandles::resolve(caller); - oop protection_domain = NULL; + oop protection_domain = nullptr; // If loader is null, shouldn't call ClassLoader.checkPackageAccess; otherwise get // NPE. Put it in another way, the bootstrap class loader has all permission and // thus no checkPackageAccess equivalence in the VM class loader. - // The caller is also passed as NULL by the java code if there is no security + // The caller is also passed as null by the java code if there is no security // manager to avoid the performance cost of getting the calling class. - if (from_class != NULL && loader_oop != NULL) { + if (from_class != nullptr && loader_oop != nullptr) { protection_domain = java_lang_Class::as_Klass(from_class)->protection_domain(); } @@ -825,7 +825,7 @@ JVM_ENTRY(jclass, JVM_FindClassFromCaller(JNIEnv* env, const char* name, jclass result = find_class_from_class_loader(env, h_name, init, h_loader, h_prot, false, THREAD); - if (log_is_enabled(Debug, class, resolve) && result != NULL) { + if (log_is_enabled(Debug, class, resolve) && result != nullptr) { trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result))); } return result; @@ -838,12 +838,12 @@ JVM_ENTRY(jclass, JVM_FindClassFromClass(JNIEnv *env, const char *name, SystemDictionary::class_name_symbol(name, vmSymbols::java_lang_ClassNotFoundException(), CHECK_NULL); oop from_class_oop = JNIHandles::resolve(from); - Klass* from_class = (from_class_oop == NULL) - ? (Klass*)NULL + Klass* from_class = (from_class_oop == nullptr) + ? (Klass*)nullptr : java_lang_Class::as_Klass(from_class_oop); - oop class_loader = NULL; - oop protection_domain = NULL; - if (from_class != NULL) { + oop class_loader = nullptr; + oop protection_domain = nullptr; + if (from_class != nullptr) { class_loader = from_class->class_loader(); protection_domain = from_class->protection_domain(); } @@ -852,7 +852,7 @@ JVM_ENTRY(jclass, JVM_FindClassFromClass(JNIEnv *env, const char *name, jclass result = find_class_from_class_loader(env, h_name, init, h_loader, h_prot, true, thread); - if (log_is_enabled(Debug, class, resolve) && result != NULL) { + if (log_is_enabled(Debug, class, resolve) && result != nullptr) { // this function is generally only used for class loading during verification. ResourceMark rm; oop from_mirror = JNIHandles::resolve_non_null(from); @@ -873,7 +873,7 @@ static jclass jvm_define_class_common(const char *name, jobject loader, const jbyte *buf, jsize len, jobject pd, const char *source, TRAPS) { - if (source == NULL) source = "__JVM_DefineClass__"; + if (source == nullptr) source = "__JVM_DefineClass__"; JavaThread* jt = THREAD; @@ -889,7 +889,7 @@ static jclass jvm_define_class_common(const char *name, } // Class resolution will get the class name from the .class stream if the name is null. - TempNewSymbol class_name = name == NULL ? NULL : + TempNewSymbol class_name = name == nullptr ? nullptr : SystemDictionary::class_name_symbol(name, vmSymbols::java_lang_NoClassDefFoundError(), CHECK_NULL); @@ -928,7 +928,7 @@ static jclass jvm_lookup_define_class(jclass lookup, const char *name, Klass* lookup_k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(lookup)); // Lookup class must be a non-null instance - if (lookup_k == NULL) { + if (lookup_k == nullptr) { THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Lookup class is null"); } assert(lookup_k->is_instance_klass(), "Lookup class must be an instance klass"); @@ -940,7 +940,7 @@ static jclass jvm_lookup_define_class(jclass lookup, const char *name, bool is_strong = (flags & STRONG_LOADER_LINK) == STRONG_LOADER_LINK; bool vm_annotations = (flags & ACCESS_VM_ANNOTATIONS) == ACCESS_VM_ANNOTATIONS; - InstanceKlass* host_class = NULL; + InstanceKlass* host_class = nullptr; if (is_nestmate) { host_class = InstanceKlass::cast(lookup_k)->nest_host(CHECK_NULL); } @@ -955,7 +955,7 @@ static jclass jvm_lookup_define_class(jclass lookup, const char *name, if (!is_hidden) { // classData is only applicable for hidden classes - if (classData != NULL) { + if (classData != nullptr) { THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "classData is only applicable for hidden classes"); } if (is_nestmate) { @@ -974,7 +974,7 @@ static jclass jvm_lookup_define_class(jclass lookup, const char *name, } // Class resolution will get the class name from the .class stream if the name is null. - TempNewSymbol class_name = name == NULL ? NULL : + TempNewSymbol class_name = name == nullptr ? nullptr : SystemDictionary::class_name_symbol(name, vmSymbols::java_lang_NoClassDefFoundError(), CHECK_NULL); @@ -982,7 +982,7 @@ static jclass jvm_lookup_define_class(jclass lookup, const char *name, const char* source = is_nestmate ? host_class->external_name() : "__JVM_LookupDefineClass__"; ClassFileStream st((u1*)buf, len, source, ClassFileStream::verify); - InstanceKlass* ik = NULL; + InstanceKlass* ik = nullptr; if (!is_hidden) { ClassLoadInfo cl_info(protection_domain); ik = SystemDictionary::resolve_from_stream(&st, class_name, @@ -1034,7 +1034,7 @@ static jclass jvm_lookup_define_class(jclass lookup, const char *name, } JVM_ENTRY(jclass, JVM_DefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize len, jobject pd)) - return jvm_define_class_common(name, loader, buf, len, pd, NULL, THREAD); + return jvm_define_class_common(name, loader, buf, len, pd, nullptr, THREAD); JVM_END /* @@ -1051,11 +1051,11 @@ JVM_END JVM_ENTRY(jclass, JVM_LookupDefineClass(JNIEnv *env, jclass lookup, const char *name, const jbyte *buf, jsize len, jobject pd, jboolean initialize, int flags, jobject classData)) - if (lookup == NULL) { + if (lookup == nullptr) { THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Lookup class is null"); } - assert(buf != NULL, "buf must not be NULL"); + assert(buf != nullptr, "buf must not be null"); return jvm_lookup_define_class(lookup, name, buf, len, pd, initialize, flags, classData, THREAD); JVM_END @@ -1072,7 +1072,7 @@ JVM_ENTRY(jclass, JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name) char* str = java_lang_String::as_utf8_string(h_name()); // Sanity check, don't expect null - if (str == NULL) return NULL; + if (str == nullptr) return nullptr; // Internalize the string, converting '.' to '/' in string. char* p = (char*)str; @@ -1087,25 +1087,25 @@ JVM_ENTRY(jclass, JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name) if (str_len > Symbol::max_length()) { // It's impossible to create this class; the name cannot fit // into the constant pool. - return NULL; + return nullptr; } TempNewSymbol klass_name = SymbolTable::new_symbol(str, str_len); // Security Note: // The Java level wrapper will perform the necessary security check allowing - // us to pass the NULL as the initiating class loader. + // us to pass the null as the initiating class loader. Handle h_loader(THREAD, JNIHandles::resolve(loader)); Klass* k = SystemDictionary::find_instance_or_array_klass(THREAD, klass_name, h_loader, Handle()); #if INCLUDE_CDS - if (k == NULL) { + if (k == nullptr) { // If the class is not already loaded, try to see if it's in the shared // archive for the current classloader (h_loader). k = SystemDictionaryShared::find_or_load_shared_class(klass_name, h_loader, CHECK_NULL); } #endif - return (k == NULL) ? NULL : + return (k == nullptr) ? nullptr : (jclass) JNIHandles::make_local(THREAD, k->java_mirror()); JVM_END @@ -1153,7 +1153,7 @@ JVM_END // Reflection support ////////////////////////////////////////////////////////////////////////////// JVM_ENTRY(jstring, JVM_InitClassName(JNIEnv *env, jclass cls)) - assert (cls != NULL, "illegal class"); + assert (cls != nullptr, "illegal class"); JvmtiVMObjectAllocEventCollector oam; ResourceMark rm(THREAD); HandleMark hm(THREAD); @@ -1231,14 +1231,14 @@ JVM_ENTRY(jobjectArray, JVM_GetClassSigners(JNIEnv *env, jclass cls)) oop mirror = JNIHandles::resolve_non_null(cls); if (java_lang_Class::is_primitive(mirror)) { // There are no signers for primitive types - return NULL; + return nullptr; } objArrayHandle signers(THREAD, java_lang_Class::signers(mirror)); // If there are no signers set in the class, or if the class - // is an array, return NULL. - if (signers == NULL) return NULL; + // is an array, return null. + if (signers == nullptr) return nullptr; // copy of the signers array Klass* element = ObjArrayKlass::cast(signers->klass())->element_klass(); @@ -1268,13 +1268,13 @@ JVM_END JVM_ENTRY(jobject, JVM_GetProtectionDomain(JNIEnv *env, jclass cls)) oop mirror = JNIHandles::resolve_non_null(cls); - if (mirror == NULL) { - THROW_(vmSymbols::java_lang_NullPointerException(), NULL); + if (mirror == nullptr) { + THROW_(vmSymbols::java_lang_NullPointerException(), nullptr); } if (java_lang_Class::is_primitive(mirror)) { // Primitive types does not have a protection domain. - return NULL; + return nullptr; } oop pd = java_lang_Class::protection_domain(mirror); @@ -1289,7 +1289,7 @@ JVM_ENTRY(jobject, JVM_GetInheritedAccessControlContext(JNIEnv *env, jclass cls) JVM_END JVM_ENTRY(jobject, JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls)) - if (!UsePrivilegedStack) return NULL; + if (!UsePrivilegedStack) return nullptr; ResourceMark rm(THREAD); GrowableArray* local_array = new GrowableArray(12); @@ -1299,10 +1299,10 @@ JVM_ENTRY(jobject, JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls)) // duplicate consecutive protection domains into a single one, as // well as stopping when we hit a privileged frame. - oop previous_protection_domain = NULL; - Handle privileged_context(thread, NULL); + oop previous_protection_domain = nullptr; + Handle privileged_context(thread, nullptr); bool is_privileged = false; - oop protection_domain = NULL; + oop protection_domain = nullptr; // Iterate through Java frames vframeStream vfst(thread); @@ -1333,7 +1333,7 @@ JVM_ENTRY(jobject, JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls)) protection_domain = method->method_holder()->protection_domain(); } - if ((previous_protection_domain != protection_domain) && (protection_domain != NULL)) { + if ((previous_protection_domain != protection_domain) && (protection_domain != nullptr)) { local_array->push(Handle(thread, protection_domain)); previous_protection_domain = protection_domain; } @@ -1345,7 +1345,7 @@ JVM_ENTRY(jobject, JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls)) // either all the domains on the stack were system domains, or // we had a privileged system domain if (local_array->is_empty()) { - if (is_privileged && privileged_context.is_null()) return NULL; + if (is_privileged && privileged_context.is_null()) return nullptr; oop result = java_security_AccessControlContext::create(objArrayHandle(), is_privileged, privileged_context, CHECK_NULL); return JNIHandles::make_local(THREAD, result); @@ -1403,18 +1403,18 @@ JVM_ENTRY(jobject, JVM_FindScopedValueBindings(JNIEnv *env, jclass cls)) StackValue* head_sv = locals->at(loc); // jdk/incubator/concurrent/ScopedValue$Snapshot Handle result = head_sv->get_obj(); assert(!head_sv->obj_is_scalar_replaced(), "found scalar-replaced object"); - if (result() != NULL) { + if (result() != nullptr) { return JNIHandles::make_local(THREAD, result()); } } } - return NULL; + return nullptr; JVM_END JVM_ENTRY(jboolean, JVM_IsArrayClass(JNIEnv *env, jclass cls)) Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); - return (k != NULL) && k->is_array_klass() ? true : false; + return (k != nullptr) && k->is_array_klass() ? true : false; JVM_END @@ -1511,18 +1511,18 @@ JVM_ENTRY(jclass, JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass)) // ofClass is a reference to a java_lang_Class object. oop ofMirror = JNIHandles::resolve_non_null(ofClass); if (java_lang_Class::is_primitive(ofMirror)) { - return NULL; + return nullptr; } Klass* klass = java_lang_Class::as_Klass(ofMirror); if (!klass->is_instance_klass()) { - return NULL; + return nullptr; } bool inner_is_member = false; Klass* outer_klass = InstanceKlass::cast(klass)->compute_enclosing_class(&inner_is_member, CHECK_NULL); - if (outer_klass == NULL) return NULL; // already a top-level class - if (!inner_is_member) return NULL; // a hidden class (inside a method) + if (outer_klass == nullptr) return nullptr; // already a top-level class + if (!inner_is_member) return nullptr; // a hidden class (inside a method) return (jclass) JNIHandles::make_local(THREAD, outer_klass->java_mirror()); } JVM_END @@ -1531,11 +1531,11 @@ JVM_ENTRY(jstring, JVM_GetSimpleBinaryName(JNIEnv *env, jclass cls)) { oop mirror = JNIHandles::resolve_non_null(cls); if (java_lang_Class::is_primitive(mirror)) { - return NULL; + return nullptr; } Klass* klass = java_lang_Class::as_Klass(mirror); if (!klass->is_instance_klass()) { - return NULL; + return nullptr; } InstanceKlass* k = InstanceKlass::cast(klass); int ooff = 0, noff = 0; @@ -1547,12 +1547,12 @@ JVM_ENTRY(jstring, JVM_GetSimpleBinaryName(JNIEnv *env, jclass cls)) return (jstring) JNIHandles::make_local(THREAD, str()); } } - return NULL; + return nullptr; } JVM_END JVM_ENTRY(jstring, JVM_GetClassSignature(JNIEnv *env, jclass cls)) - assert (cls != NULL, "illegal class"); + assert (cls != nullptr, "illegal class"); JvmtiVMObjectAllocEventCollector oam; ResourceMark rm(THREAD); oop mirror = JNIHandles::resolve_non_null(cls); @@ -1561,17 +1561,17 @@ JVM_ENTRY(jstring, JVM_GetClassSignature(JNIEnv *env, jclass cls)) Klass* k = java_lang_Class::as_Klass(mirror); if (k->is_instance_klass()) { Symbol* sym = InstanceKlass::cast(k)->generic_signature(); - if (sym == NULL) return NULL; + if (sym == nullptr) return nullptr; Handle str = java_lang_String::create_from_symbol(sym, CHECK_NULL); return (jstring) JNIHandles::make_local(THREAD, str()); } } - return NULL; + return nullptr; JVM_END JVM_ENTRY(jbyteArray, JVM_GetClassAnnotations(JNIEnv *env, jclass cls)) - assert (cls != NULL, "illegal class"); + assert (cls != nullptr, "illegal class"); oop mirror = JNIHandles::resolve_non_null(cls); // Return null for arrays and primitives if (!java_lang_Class::is_primitive(mirror)) { @@ -1581,7 +1581,7 @@ JVM_ENTRY(jbyteArray, JVM_GetClassAnnotations(JNIEnv *env, jclass cls)) return (jbyteArray) JNIHandles::make_local(THREAD, a); } } - return NULL; + return nullptr; JVM_END @@ -1618,7 +1618,7 @@ static Method* jvm_get_method_common(jobject method) { // some of this code was adapted from from jni_FromReflectedMethod oop reflected = JNIHandles::resolve_non_null(method); - oop mirror = NULL; + oop mirror = nullptr; int slot = 0; if (reflected->klass() == vmClasses::reflect_Constructor_klass()) { @@ -1633,52 +1633,52 @@ static Method* jvm_get_method_common(jobject method) { Klass* k = java_lang_Class::as_Klass(mirror); Method* m = InstanceKlass::cast(k)->method_with_idnum(slot); - assert(m != NULL, "cannot find method"); - return m; // caller has to deal with NULL in product mode + assert(m != nullptr, "cannot find method"); + return m; // caller has to deal with null in product mode } /* Type use annotations support (JDK 1.8) */ JVM_ENTRY(jbyteArray, JVM_GetClassTypeAnnotations(JNIEnv *env, jclass cls)) - assert (cls != NULL, "illegal class"); + assert (cls != nullptr, "illegal class"); ResourceMark rm(THREAD); // Return null for arrays and primitives if (!java_lang_Class::is_primitive(JNIHandles::resolve(cls))) { Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls)); if (k->is_instance_klass()) { AnnotationArray* type_annotations = InstanceKlass::cast(k)->class_type_annotations(); - if (type_annotations != NULL) { + if (type_annotations != nullptr) { typeArrayOop a = Annotations::make_java_array(type_annotations, CHECK_NULL); return (jbyteArray) JNIHandles::make_local(THREAD, a); } } } - return NULL; + return nullptr; JVM_END JVM_ENTRY(jbyteArray, JVM_GetMethodTypeAnnotations(JNIEnv *env, jobject method)) - assert (method != NULL, "illegal method"); + assert (method != nullptr, "illegal method"); // method is a handle to a java.lang.reflect.Method object Method* m = jvm_get_method_common(method); - if (m == NULL) { - return NULL; + if (m == nullptr) { + return nullptr; } AnnotationArray* type_annotations = m->type_annotations(); - if (type_annotations != NULL) { + if (type_annotations != nullptr) { typeArrayOop a = Annotations::make_java_array(type_annotations, CHECK_NULL); return (jbyteArray) JNIHandles::make_local(THREAD, a); } - return NULL; + return nullptr; JVM_END JVM_ENTRY(jbyteArray, JVM_GetFieldTypeAnnotations(JNIEnv *env, jobject field)) - assert (field != NULL, "illegal field"); + assert (field != nullptr, "illegal field"); fieldDescriptor fd; bool gotFd = jvm_get_field_common(field, fd); if (!gotFd) { - return NULL; + return nullptr; } return (jbyteArray) JNIHandles::make_local(THREAD, Annotations::make_java_array(fd.type_annotations(), THREAD)); @@ -1703,7 +1703,7 @@ JVM_ENTRY(jobjectArray, JVM_GetMethodParameters(JNIEnv *env, jobject method)) // parameter data. Return null to indicate this to the reflection // API. assert(num_params == -1, "num_params should be -1 if it is less than zero"); - return (jobjectArray)NULL; + return (jobjectArray)nullptr; } else { // Otherwise, we return something up to reflection, even if it is // a zero-length array. Why? Because in some cases this can @@ -1728,9 +1728,9 @@ JVM_ENTRY(jobjectArray, JVM_GetMethodParameters(JNIEnv *env, jobject method)) for (int i = 0; i < num_params; i++) { MethodParametersElement* params = mh->method_parameters_start(); - // For a 0 index, give a NULL symbol + // For a 0 index, give a null symbol Symbol* sym = 0 != params[i].name_cp_index ? - mh->constants()->symbol_at(params[i].name_cp_index) : NULL; + mh->constants()->symbol_at(params[i].name_cp_index) : nullptr; int flags = params[i].flags; oop param = Reflection::new_parameter(reflected_method, i, sym, flags, CHECK_NULL); @@ -1797,7 +1797,7 @@ JVM_END JVM_ENTRY(jboolean, JVM_IsRecord(JNIEnv *env, jclass cls)) { Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); - if (k != NULL && k->is_instance_klass()) { + if (k != nullptr && k->is_instance_klass()) { InstanceKlass* ik = InstanceKlass::cast(k); return ik->is_record(); } else { @@ -1807,7 +1807,7 @@ JVM_ENTRY(jboolean, JVM_IsRecord(JNIEnv *env, jclass cls)) JVM_END // Returns an array containing the components of the Record attribute, -// or NULL if the attribute is not present. +// or null if the attribute is not present. // // Note that this function returns the components of the Record attribute // even if the class is not a record. @@ -1818,7 +1818,7 @@ JVM_ENTRY(jobjectArray, JVM_GetRecordComponents(JNIEnv* env, jclass ofClass)) InstanceKlass* ik = InstanceKlass::cast(c); Array* components = ik->record_components(); - if (components != NULL) { + if (components != nullptr) { JvmtiVMObjectAllocEventCollector oam; constantPoolHandle cp(THREAD, ik->constants()); int length = components->length(); @@ -1829,14 +1829,14 @@ JVM_ENTRY(jobjectArray, JVM_GetRecordComponents(JNIEnv* env, jclass ofClass)) for (int x = 0; x < length; x++) { RecordComponent* component = components->at(x); - assert(component != NULL, "unexpected NULL record component"); + assert(component != nullptr, "unexpected null record component"); oop component_oop = java_lang_reflect_RecordComponent::create(ik, component, CHECK_NULL); components_h->obj_at_put(x, component_oop); } return (jobjectArray)JNIHandles::make_local(THREAD, components_h()); } - return NULL; + return nullptr; } JVM_END @@ -1903,7 +1903,7 @@ static jobjectArray get_class_declared_methods_helper( if (method.is_null()) { // Method may have been deleted and seems this API can handle null // Otherwise should probably put a method that throws NSME - result->obj_at_put(i, NULL); + result->obj_at_put(i, nullptr); } else { oop m; if (want_constructor) { @@ -1966,7 +1966,7 @@ JVM_ENTRY(jclass, JVM_GetNestHost(JNIEnv* env, jclass current)) assert(c->is_instance_klass(), "must be"); InstanceKlass* ck = InstanceKlass::cast(c); InstanceKlass* host = ck->nest_host(THREAD); - return (jclass) (host == NULL ? NULL : + return (jclass) (host == nullptr ? nullptr : JNIHandles::make_local(THREAD, host->java_mirror())); } JVM_END @@ -1985,7 +1985,7 @@ JVM_ENTRY(jobjectArray, JVM_GetNestMembers(JNIEnv* env, jclass current)) { JvmtiVMObjectAllocEventCollector oam; Array* members = host->nest_members(); - int length = members == NULL ? 0 : members->length(); + int length = members == nullptr ? 0 : members->length(); log_trace(class, nestmates)(" - host has %d listed nest members", length); @@ -2001,7 +2001,7 @@ JVM_ENTRY(jobjectArray, JVM_GetNestMembers(JNIEnv* env, jclass current)) Klass* k = host->constants()->klass_at(cp_index, THREAD); if (HAS_PENDING_EXCEPTION) { if (PENDING_EXCEPTION->is_a(vmClasses::VirtualMachineError_klass())) { - return NULL; // propagate VMEs + return nullptr; // propagate VMEs } if (log_is_enabled(Trace, class, nestmates)) { stringStream ss; @@ -2077,7 +2077,7 @@ JVM_ENTRY(jobjectArray, JVM_GetPermittedSubclasses(JNIEnv* env, jclass current)) Klass* k = ik->constants()->klass_at(cp_index, THREAD); if (HAS_PENDING_EXCEPTION) { if (PENDING_EXCEPTION->is_a(vmClasses::VirtualMachineError_klass())) { - return NULL; // propagate VMEs + return nullptr; // propagate VMEs } if (log_is_enabled(Trace, class, sealed)) { stringStream ss; @@ -2107,7 +2107,7 @@ JVM_ENTRY(jobjectArray, JVM_GetPermittedSubclasses(JNIEnv* env, jclass current)) } return (jobjectArray)JNIHandles::make_local(THREAD, result()); } else { - return NULL; + return nullptr; } } JVM_END @@ -2128,7 +2128,7 @@ JVM_ENTRY(jobject, JVM_GetClassConstantPool(JNIEnv *env, jclass cls)) return JNIHandles::make_local(THREAD, jcp()); } } - return NULL; + return nullptr; } JVM_END @@ -2163,7 +2163,7 @@ JVM_ENTRY(jclass, JVM_ConstantPoolGetClassAtIfLoaded(JNIEnv *env, jobject obj, j THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); } Klass* k = ConstantPool::klass_at_if_loaded(cp, index); - if (k == NULL) return NULL; + if (k == nullptr) return nullptr; return (jclass) JNIHandles::make_local(THREAD, k->java_mirror()); } JVM_END @@ -2179,7 +2179,7 @@ static jobject get_method_at_helper(const constantPoolHandle& cp, jint index, bo k_o = cp->klass_at(klass_ref, CHECK_NULL); } else { k_o = ConstantPool::klass_at_if_loaded(cp, klass_ref); - if (k_o == NULL) return NULL; + if (k_o == nullptr) return nullptr; } InstanceKlass* k = InstanceKlass::cast(k_o); Symbol* name = cp->uncached_name_ref_at(index); @@ -2228,14 +2228,14 @@ static jobject get_field_at_helper(constantPoolHandle cp, jint index, bool force k_o = cp->klass_at(klass_ref, CHECK_NULL); } else { k_o = ConstantPool::klass_at_if_loaded(cp, klass_ref); - if (k_o == NULL) return NULL; + if (k_o == nullptr) return nullptr; } InstanceKlass* k = InstanceKlass::cast(k_o); Symbol* name = cp->uncached_name_ref_at(index); Symbol* sig = cp->uncached_signature_ref_at(index); fieldDescriptor fd; Klass* target_klass = k->find_field(name, sig, &fd); - if (target_klass == NULL) { + if (target_klass == nullptr) { THROW_MSG_0(vmSymbols::java_lang_RuntimeException(), "Unable to look up field in target class"); } oop field = Reflection::new_field(&fd, CHECK_NULL); @@ -2437,7 +2437,7 @@ JVM_END // Assertion support. ////////////////////////////////////////////////////////// JVM_ENTRY(jboolean, JVM_DesiredAssertionStatus(JNIEnv *env, jclass unused, jclass cls)) - assert(cls != NULL, "bad class"); + assert(cls != nullptr, "bad class"); oop r = JNIHandles::resolve(cls); assert(! java_lang_Class::is_primitive(r), "primitive classes not allowed"); @@ -2449,7 +2449,7 @@ JVM_ENTRY(jboolean, JVM_DesiredAssertionStatus(JNIEnv *env, jclass unused, jclas ResourceMark rm(THREAD); const char* name = k->name()->as_C_string(); - bool system_class = k->class_loader() == NULL; + bool system_class = k->class_loader() == nullptr; return JavaAssertions::enabled(name, system_class); JVM_END @@ -2671,7 +2671,7 @@ JVM_ENTRY(const char*, JVM_GetCPFieldNameUTF(JNIEnv *env, jclass cls, jint cp_in fatal("JVM_GetCPFieldNameUTF: illegal constant"); } ShouldNotReachHere(); - return NULL; + return nullptr; JVM_END @@ -2687,7 +2687,7 @@ JVM_ENTRY(const char*, JVM_GetCPMethodNameUTF(JNIEnv *env, jclass cls, jint cp_i fatal("JVM_GetCPMethodNameUTF: illegal constant"); } ShouldNotReachHere(); - return NULL; + return nullptr; JVM_END @@ -2703,7 +2703,7 @@ JVM_ENTRY(const char*, JVM_GetCPMethodSignatureUTF(JNIEnv *env, jclass cls, jint fatal("JVM_GetCPMethodSignatureUTF: illegal constant"); } ShouldNotReachHere(); - return NULL; + return nullptr; JVM_END @@ -2718,7 +2718,7 @@ JVM_ENTRY(const char*, JVM_GetCPFieldSignatureUTF(JNIEnv *env, jclass cls, jint fatal("JVM_GetCPFieldSignatureUTF: illegal constant"); } ShouldNotReachHere(); - return NULL; + return nullptr; JVM_END @@ -2745,7 +2745,7 @@ JVM_ENTRY(const char*, JVM_GetCPFieldClassNameUTF(JNIEnv *env, jclass cls, jint fatal("JVM_GetCPFieldClassNameUTF: illegal constant"); } ShouldNotReachHere(); - return NULL; + return nullptr; JVM_END @@ -2764,7 +2764,7 @@ JVM_ENTRY(const char*, JVM_GetCPMethodClassNameUTF(JNIEnv *env, jclass cls, jint fatal("JVM_GetCPMethodClassNameUTF: illegal constant"); } ShouldNotReachHere(); - return NULL; + return nullptr; JVM_END @@ -2878,7 +2878,7 @@ int jio_fprintf(FILE* f, const char *fmt, ...) { ATTRIBUTE_PRINTF(2, 0) int jio_vfprintf(FILE* f, const char *fmt, va_list args) { - if (Arguments::vfprintf_hook() != NULL) { + if (Arguments::vfprintf_hook() != nullptr) { return Arguments::vfprintf_hook()(f, fmt, args); } else { return vfprintf(f, fmt, args); @@ -2898,7 +2898,7 @@ JNIEXPORT int jio_printf(const char *fmt, ...) { // HotSpot specific jio method void jio_print(const char* s, size_t len) { // Try to make this function as atomic as possible. - if (Arguments::vfprintf_hook() != NULL) { + if (Arguments::vfprintf_hook() != nullptr) { jio_fprintf(defaultStream::output_stream(), "%.*s", (int)len, s); } else { // Make an unused local variable to avoid warning from gcc compiler. @@ -2951,7 +2951,7 @@ JVM_ENTRY(void, JVM_StartThread(JNIEnv* env, jobject jthread)) return; } #endif - JavaThread *native_thread = NULL; + JavaThread *native_thread = nullptr; // We cannot hold the Threads_lock when we throw an exception, // due to rank ordering issues. Example: we might need to grab the @@ -2971,7 +2971,7 @@ JVM_ENTRY(void, JVM_StartThread(JNIEnv* env, jobject jthread)) // there is a small window between the Thread object being created // (with its JavaThread set) and the update to its threadStatus, so we // have to check for this - if (java_lang_Thread::thread(JNIHandles::resolve_non_null(jthread)) != NULL) { + if (java_lang_Thread::thread(JNIHandles::resolve_non_null(jthread)) != nullptr) { throw_illegal_thread_state = true; } else { jlong size = @@ -2991,7 +2991,7 @@ JVM_ENTRY(void, JVM_StartThread(JNIEnv* env, jobject jthread)) // that we only grab the lock if the thread was created successfully - // then we can also do this check and throw the exception in the // JavaThread constructor. - if (native_thread->osthread() != NULL) { + if (native_thread->osthread() != nullptr) { // Note: the current thread is not being used within "prepare". native_thread->prepare(jthread); } @@ -3002,9 +3002,9 @@ JVM_ENTRY(void, JVM_StartThread(JNIEnv* env, jobject jthread)) THROW(vmSymbols::java_lang_IllegalThreadStateException()); } - assert(native_thread != NULL, "Starting null thread?"); + assert(native_thread != nullptr, "Starting null thread?"); - if (native_thread->osthread() == NULL) { + if (native_thread->osthread() == nullptr) { ResourceMark rm(thread); log_warning(os, thread)("Failed to start the native thread for java.lang.Thread \"%s\"", JavaThread::name_for(JNIHandles::resolve_non_null(jthread))); @@ -3034,8 +3034,8 @@ JVM_END JVM_ENTRY(void, JVM_SetThreadPriority(JNIEnv* env, jobject jthread, jint prio)) ThreadsListHandle tlh(thread); - oop java_thread = NULL; - JavaThread* receiver = NULL; + oop java_thread = nullptr; + JavaThread* receiver = nullptr; bool is_alive = tlh.cv_internal_thread_to_JavaThread(jthread, &receiver, &java_thread); java_lang_Thread::set_priority(java_thread, (ThreadPriority)prio); @@ -3093,13 +3093,13 @@ JVM_END JVM_ENTRY(jobject, JVM_CurrentCarrierThread(JNIEnv* env, jclass threadClass)) oop jthread = thread->threadObj(); - assert(jthread != NULL, "no current carrier thread!"); + assert(jthread != nullptr, "no current carrier thread!"); return JNIHandles::make_local(THREAD, jthread); JVM_END JVM_ENTRY(jobject, JVM_CurrentThread(JNIEnv* env, jclass threadClass)) oop theThread = thread->vthread(); - assert(theThread != (oop)NULL, "no current thread!"); + assert(theThread != (oop)nullptr, "no current thread!"); return JNIHandles::make_local(THREAD, theThread); JVM_END @@ -3116,8 +3116,8 @@ JVM_END JVM_ENTRY(void, JVM_Interrupt(JNIEnv* env, jobject jthread)) ThreadsListHandle tlh(thread); - JavaThread* receiver = NULL; - bool is_alive = tlh.cv_internal_thread_to_JavaThread(jthread, &receiver, NULL); + JavaThread* receiver = nullptr; + bool is_alive = tlh.cv_internal_thread_to_JavaThread(jthread, &receiver, nullptr); if (is_alive) { // jthread refers to a live JavaThread. receiver->interrupt(); @@ -3127,7 +3127,7 @@ JVM_END // Return true iff the current thread has locked the object passed in JVM_ENTRY(jboolean, JVM_HoldsLock(JNIEnv* env, jclass threadClass, jobject obj)) - if (obj == NULL) { + if (obj == nullptr) { THROW_(vmSymbols::java_lang_NullPointerException(), JNI_FALSE); } Handle h_obj(THREAD, JNIHandles::resolve(obj)); @@ -3180,7 +3180,7 @@ JVM_ENTRY(jobjectArray, JVM_GetClassContext(JNIEnv *env)) JvmtiVMObjectAllocEventCollector oam; vframeStream vfst(thread); - if (vmClasses::reflect_CallerSensitive_klass() != NULL) { + if (vmClasses::reflect_CallerSensitive_klass() != nullptr) { // This must only be called from SecurityManager.getClassContext Method* m = vfst.method(); if (!(m->method_holder() == vmClasses::SecurityManager_klass() && @@ -3238,7 +3238,7 @@ JVM_END JVM_ENTRY(jobject, JVM_GetAndClearReferencePendingList(JNIEnv* env)) MonitorLocker ml(Heap_lock); oop ref = Universe::reference_pending_list(); - if (ref != NULL) { + if (ref != nullptr) { Universe::clear_reference_pending_list(); } return JNIHandles::make_local(THREAD, ref); @@ -3269,7 +3269,7 @@ JVM_ENTRY(void, JVM_ReferenceClear(JNIEnv* env, jobject ref)) oop ref_oop = JNIHandles::resolve_non_null(ref); // FinalReference has it's own implementation of clear(). assert(!java_lang_ref_Reference::is_final(ref_oop), "precondition"); - if (java_lang_ref_Reference::unknown_referent_no_keepalive(ref_oop) == NULL) { + if (java_lang_ref_Reference::unknown_referent_no_keepalive(ref_oop) == nullptr) { // If the referent has already been cleared then done. // However, if the referent is dead but has not yet been cleared by // concurrent reference processing, it should NOT be cleared here. @@ -3303,7 +3303,7 @@ JVM_ENTRY(jobject, JVM_LatestUserDefinedLoader(JNIEnv *env)) for (vframeStream vfst(thread); !vfst.at_end(); vfst.next()) { InstanceKlass* ik = vfst.method()->method_holder(); oop loader = ik->class_loader(); - if (loader != NULL && !SystemDictionary::is_platform_class_loader(loader)) { + if (loader != nullptr && !SystemDictionary::is_platform_class_loader(loader)) { // Skip reflection related frames if (!ik->is_subclass_of(vmClasses::reflect_MethodAccessorImpl_klass()) && !ik->is_subclass_of(vmClasses::reflect_ConstructorAccessorImpl_klass())) { @@ -3311,7 +3311,7 @@ JVM_ENTRY(jobject, JVM_LatestUserDefinedLoader(JNIEnv *env)) } } } - return NULL; + return nullptr; JVM_END @@ -3320,7 +3320,7 @@ JVM_END // resolve array handle and check arguments static inline arrayOop check_array(JNIEnv *env, jobject arr, bool type_array_only, TRAPS) { - if (arr == NULL) { + if (arr == nullptr) { THROW_0(vmSymbols::java_lang_NullPointerException()); } oop a = JNIHandles::resolve_non_null(arr); @@ -3420,7 +3420,7 @@ JVM_ENTRY_NO_ENV(void*, JVM_LoadLibrary(const char* name, jboolean throwExceptio ThreadToNativeFromVM ttnfvm(thread); load_result = os::dll_load(name, ebuf, sizeof ebuf); } - if (load_result == NULL) { + if (load_result == nullptr) { if (throwException) { char msg[1024]; jio_snprintf(msg, sizeof msg, "%s: %s", name, ebuf); @@ -3453,7 +3453,7 @@ JVM_END JVM_LEAF(void*, JVM_FindLibraryEntry(void* handle, const char* name)) void* find_result = os::dll_lookup(handle, name); log_info(library)("%s %s in library with handle " INTPTR_FORMAT, - find_result != NULL ? "Found" : "Failed to find", + find_result != nullptr ? "Found" : "Failed to find", name, p2i(handle)); return find_result; JVM_END @@ -3478,7 +3478,7 @@ JVM_END JVM_ENTRY(jstring, JVM_InternString(JNIEnv *env, jstring str)) JvmtiVMObjectAllocEventCollector oam; - if (str == NULL) return NULL; + if (str == nullptr) return nullptr; oop string = JNIHandles::resolve_non_null(str); oop result = StringTable::intern(string, CHECK_NULL); return (jstring) JNIHandles::make_local(THREAD, result); @@ -3526,9 +3526,9 @@ jclass find_class_from_class_loader(JNIEnv* env, Symbol* name, jboolean init, jboolean throwError, TRAPS) { // Security Note: // The Java level wrapper will perform the necessary security check allowing - // us to pass the NULL as the initiating class loader. The VM is responsible for + // us to pass the null as the initiating class loader. The VM is responsible for // the checkPackageAccess relative to the initiating class loader via the - // protection_domain. The protection_domain is passed as NULL by the java code + // protection_domain. The protection_domain is passed as null by the java code // if there is no security manager in 3-arg Class.forName(). Klass* klass = SystemDictionary::resolve_or_fail(name, loader, protection_domain, throwError != 0, CHECK_NULL); @@ -3552,7 +3552,7 @@ JVM_ENTRY(jobject, JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jo jobject res = JNIHandles::make_local(THREAD, result); if (JvmtiExport::should_post_vm_object_alloc()) { oop ret_type = java_lang_reflect_Method::return_type(method_handle()); - assert(ret_type != NULL, "sanity check: ret_type oop must not be NULL!"); + assert(ret_type != nullptr, "sanity check: ret_type oop must not be null!"); if (java_lang_Class::is_primitive(ret_type)) { // Only for primitive type vm allocates memory for java object. // See box() method. @@ -3615,8 +3615,8 @@ JVM_ENTRY(void, JVM_RegisterLambdaProxyClassForArchiving(JNIEnv* env, assert(lambda_ik->is_hidden(), "must be a hidden class"); assert(!lambda_ik->is_non_strong_hidden(), "expected a strong hidden class"); - Symbol* interface_method_name = NULL; - if (interfaceMethodName != NULL) { + Symbol* interface_method_name = nullptr; + if (interfaceMethodName != nullptr) { interface_method_name = java_lang_String::as_symbol(JNIHandles::resolve_non_null(interfaceMethodName)); } Handle factory_type_oop(THREAD, JNIHandles::resolve_non_null(factoryType)); @@ -3646,16 +3646,16 @@ JVM_ENTRY(jclass, JVM_LookupLambdaProxyClassFromArchive(JNIEnv* env, jobject dynamicMethodType)) #if INCLUDE_CDS - if (interfaceMethodName == NULL || factoryType == NULL || interfaceMethodType == NULL || - implementationMember == NULL || dynamicMethodType == NULL) { - THROW_(vmSymbols::java_lang_NullPointerException(), NULL); + if (interfaceMethodName == nullptr || factoryType == nullptr || interfaceMethodType == nullptr || + implementationMember == nullptr || dynamicMethodType == nullptr) { + THROW_(vmSymbols::java_lang_NullPointerException(), nullptr); } Klass* caller_k = java_lang_Class::as_Klass(JNIHandles::resolve(caller)); InstanceKlass* caller_ik = InstanceKlass::cast(caller_k); if (!caller_ik->is_shared()) { // there won't be a shared lambda class if the caller_ik is not in the shared archive. - return NULL; + return nullptr; } Symbol* interface_method_name = java_lang_String::as_symbol(JNIHandles::resolve_non_null(interfaceMethodName)); @@ -3674,14 +3674,14 @@ JVM_ENTRY(jclass, JVM_LookupLambdaProxyClassFromArchive(JNIEnv* env, InstanceKlass* lambda_ik = SystemDictionaryShared::get_shared_lambda_proxy_class(caller_ik, interface_method_name, factory_type, interface_method_type, m, dynamic_method_type); - jclass jcls = NULL; - if (lambda_ik != NULL) { + jclass jcls = nullptr; + if (lambda_ik != nullptr) { InstanceKlass* loaded_lambda = SystemDictionaryShared::prepare_shared_lambda_proxy_class(lambda_ik, caller_ik, THREAD); - jcls = loaded_lambda == NULL ? NULL : (jclass) JNIHandles::make_local(THREAD, loaded_lambda->java_mirror()); + jcls = loaded_lambda == nullptr ? nullptr : (jclass) JNIHandles::make_local(THREAD, loaded_lambda->java_mirror()); } return jcls; #else - return NULL; + return nullptr; #endif // INCLUDE_CDS JVM_END @@ -3726,7 +3726,7 @@ JVM_END JVM_ENTRY(void, JVM_LogLambdaFormInvoker(JNIEnv *env, jstring line)) #if INCLUDE_CDS assert(ClassListWriter::is_enabled() || DynamicDumpSharedSpaces, "Should be set and open or do dynamic dump"); - if (line != NULL) { + if (line != nullptr) { ResourceMark rm(THREAD); Handle h_line (THREAD, JNIHandles::resolve_non_null(line)); char* c_line = java_lang_String::as_utf8_string(h_line()); @@ -3789,7 +3789,7 @@ JVM_ENTRY(jobjectArray, JVM_DumpThreads(JNIEnv *env, jclass threadClass, jobject JvmtiVMObjectAllocEventCollector oam; // Check if threads is null - if (threads == NULL) { + if (threads == nullptr) { THROW_(vmSymbols::java_lang_NullPointerException(), 0); } @@ -3846,22 +3846,22 @@ JVM_ENTRY(jobjectArray, JVM_GetEnclosingMethodInfo(JNIEnv *env, jclass ofClass)) { JvmtiVMObjectAllocEventCollector oam; - if (ofClass == NULL) { - return NULL; + if (ofClass == nullptr) { + return nullptr; } Handle mirror(THREAD, JNIHandles::resolve_non_null(ofClass)); // Special handling for primitive objects if (java_lang_Class::is_primitive(mirror())) { - return NULL; + return nullptr; } Klass* k = java_lang_Class::as_Klass(mirror()); if (!k->is_instance_klass()) { - return NULL; + return nullptr; } InstanceKlass* ik = InstanceKlass::cast(k); int encl_method_class_idx = ik->enclosing_method_class_index(); if (encl_method_class_idx == 0) { - return NULL; + return nullptr; } objArrayOop dest_o = oopFactory::new_objArray(vmClasses::Object_klass(), 3, CHECK_NULL); objArrayHandle dest(THREAD, dest_o); @@ -3889,7 +3889,7 @@ JVM_ENTRY(jobjectArray, JVM_GetVmArguments(JNIEnv *env)) ResourceMark rm(THREAD); if (Arguments::num_jvm_args() == 0 && Arguments::num_jvm_flags() == 0) { - return NULL; + return nullptr; } char** vm_flags = Arguments::jvm_flags_array(); @@ -3944,7 +3944,7 @@ JVM_ENTRY(void, JVM_VirtualThreadMountEnd(JNIEnv* env, jobject vthread, jboolean { MutexLocker mu(JvmtiThreadState_lock); JvmtiThreadState* state = thread->jvmti_thread_state(); - if (state != NULL && state->is_pending_interp_only_mode()) { + if (state != nullptr && state->is_pending_interp_only_mode()) { JvmtiEventController::enter_interp_only_mode(); } } @@ -4002,11 +4002,11 @@ JVM_ENTRY(void, JVM_VirtualThreadUnmountBegin(JNIEnv* env, jobject vthread, jboo assert(!thread->is_in_VTMS_transition(), "sanity check"); JvmtiVTMSTransitionDisabler::start_VTMS_transition(vthread, /* is_mount */ false); - if (last_unmount && thread->jvmti_thread_state() != NULL) { + if (last_unmount && thread->jvmti_thread_state() != nullptr) { JvmtiExport::cleanup_thread(thread); - thread->set_jvmti_thread_state(NULL); + thread->set_jvmti_thread_state(nullptr); oop vt = JNIHandles::resolve(vthread); - java_lang_Thread::set_jvmti_thread_state(vt, NULL); + java_lang_Thread::set_jvmti_thread_state(vt, nullptr); } thread->rebind_to_jvmti_thread_state_of(ct()); #else diff --git a/src/hotspot/share/prims/jvmtiClassFileReconstituter.cpp b/src/hotspot/share/prims/jvmtiClassFileReconstituter.cpp index 1942d3b110606..3fbb6e3b2b1eb 100644 --- a/src/hotspot/share/prims/jvmtiClassFileReconstituter.cpp +++ b/src/hotspot/share/prims/jvmtiClassFileReconstituter.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 @@ -71,8 +71,8 @@ void JvmtiClassFileReconstituter::write_field_infos() { guarantee(name_index != 0 && signature_index != 0, "bad constant pool index for field"); // int offset = ik()->field_offset( index ); int generic_signature_index = fs.generic_signature_index(); - AnnotationArray* anno = fields_anno == NULL ? NULL : fields_anno->at(fs.index()); - AnnotationArray* type_anno = fields_type_anno == NULL ? NULL : fields_type_anno->at(fs.index()); + AnnotationArray* anno = fields_anno == nullptr ? nullptr : fields_anno->at(fs.index()); + AnnotationArray* type_anno = fields_type_anno == nullptr ? nullptr : fields_type_anno->at(fs.index()); // JVMSpec| field_info { // JVMSpec| u2 access_flags; @@ -95,10 +95,10 @@ void JvmtiClassFileReconstituter::write_field_infos() { if (generic_signature_index != 0) { ++attr_count; } - if (anno != NULL) { + if (anno != nullptr) { ++attr_count; // has RuntimeVisibleAnnotations attribute } - if (type_anno != NULL) { + if (type_anno != nullptr) { ++attr_count; // has RuntimeVisibleTypeAnnotations attribute } @@ -115,10 +115,10 @@ void JvmtiClassFileReconstituter::write_field_infos() { if (generic_signature_index != 0) { write_signature_attribute(generic_signature_index); } - if (anno != NULL) { + if (anno != nullptr) { write_annotations_attribute("RuntimeVisibleAnnotations", anno); } - if (type_anno != NULL) { + if (type_anno != nullptr) { write_annotations_attribute("RuntimeVisibleTypeAnnotations", type_anno); } } @@ -319,7 +319,7 @@ void JvmtiClassFileReconstituter::write_method_parameter_attribute(const ConstMe // JVMSpec| u2 sourcefile_index; // JVMSpec| } void JvmtiClassFileReconstituter::write_source_file_attribute() { - assert(ik()->source_file_name() != NULL, "caller must check"); + assert(ik()->source_file_name() != nullptr, "caller must check"); write_attribute_name_index("SourceFile"); write_u4(2); // always length 2 @@ -333,7 +333,7 @@ void JvmtiClassFileReconstituter::write_source_file_attribute() { // JSR45| u1 debug_extension[attribute_length]; // JSR45| } void JvmtiClassFileReconstituter::write_source_debug_extension_attribute() { - assert(ik()->source_debug_extension() != NULL, "caller must check"); + assert(ik()->source_debug_extension() != nullptr, "caller must check"); write_attribute_name_index("SourceDebugExtension"); int len = (int)strlen(ik()->source_debug_extension()); @@ -493,10 +493,10 @@ void JvmtiClassFileReconstituter::write_record_attribute() { length += 8; // Signature attribute size assert(component->attributes_count() > 0, "Bad component attributes count"); } - if (component->annotations() != NULL) { + if (component->annotations() != nullptr) { length += 6 + component->annotations()->length(); } - if (component->type_annotations() != NULL) { + if (component->type_annotations() != nullptr) { length += 6 + component->type_annotations()->length(); } } @@ -512,10 +512,10 @@ void JvmtiClassFileReconstituter::write_record_attribute() { if (component->generic_signature_index() != 0) { write_signature_attribute(component->generic_signature_index()); } - if (component->annotations() != NULL) { + if (component->annotations() != nullptr) { write_annotations_attribute("RuntimeVisibleAnnotations", component->annotations()); } - if (component->type_annotations() != NULL) { + if (component->type_annotations() != nullptr) { write_annotations_attribute("RuntimeVisibleTypeAnnotations", component->type_annotations()); } } @@ -711,7 +711,7 @@ void JvmtiClassFileReconstituter::write_method_info(const methodHandle& method) if (const_method->has_checked_exceptions()) { ++attr_count; // has Exceptions attribute } - if (default_anno != NULL) { + if (default_anno != nullptr) { ++attr_count; // has AnnotationDefault attribute } if (const_method->has_method_parameters()) { @@ -724,13 +724,13 @@ void JvmtiClassFileReconstituter::write_method_info(const methodHandle& method) if (generic_signature_index != 0) { ++attr_count; } - if (anno != NULL) { + if (anno != nullptr) { ++attr_count; // has RuntimeVisibleAnnotations attribute } - if (param_anno != NULL) { + if (param_anno != nullptr) { ++attr_count; // has RuntimeVisibleParameterAnnotations attribute } - if (type_anno != NULL) { + if (type_anno != nullptr) { ++attr_count; // has RuntimeVisibleTypeAnnotations attribute } @@ -741,7 +741,7 @@ void JvmtiClassFileReconstituter::write_method_info(const methodHandle& method) if (const_method->has_checked_exceptions()) { write_exceptions_attribute(const_method); } - if (default_anno != NULL) { + if (default_anno != nullptr) { write_annotations_attribute("AnnotationDefault", default_anno); } if (const_method->has_method_parameters()) { @@ -754,13 +754,13 @@ void JvmtiClassFileReconstituter::write_method_info(const methodHandle& method) if (generic_signature_index != 0) { write_signature_attribute(generic_signature_index); } - if (anno != NULL) { + if (anno != nullptr) { write_annotations_attribute("RuntimeVisibleAnnotations", anno); } - if (param_anno != NULL) { + if (param_anno != nullptr) { write_annotations_attribute("RuntimeVisibleParameterAnnotations", param_anno); } - if (type_anno != NULL) { + if (type_anno != nullptr) { write_annotations_attribute("RuntimeVisibleTypeAnnotations", type_anno); } } @@ -775,25 +775,25 @@ void JvmtiClassFileReconstituter::write_class_attributes() { AnnotationArray* type_anno = ik()->class_type_annotations(); int attr_count = 0; - if (generic_signature != NULL) { + if (generic_signature != nullptr) { ++attr_count; } - if (ik()->source_file_name() != NULL) { + if (ik()->source_file_name() != nullptr) { ++attr_count; } - if (ik()->source_debug_extension() != NULL) { + if (ik()->source_debug_extension() != nullptr) { ++attr_count; } if (inner_classes_length > 0) { ++attr_count; } - if (anno != NULL) { + if (anno != nullptr) { ++attr_count; // has RuntimeVisibleAnnotations attribute } - if (type_anno != NULL) { + if (type_anno != nullptr) { ++attr_count; // has RuntimeVisibleTypeAnnotations attribute } - if (cpool()->operands() != NULL) { + if (cpool()->operands() != nullptr) { ++attr_count; } if (ik()->nest_host_index() != 0) { @@ -805,25 +805,25 @@ void JvmtiClassFileReconstituter::write_class_attributes() { if (ik()->permitted_subclasses() != Universe::the_empty_short_array()) { ++attr_count; } - if (ik()->record_components() != NULL) { + if (ik()->record_components() != nullptr) { ++attr_count; } write_u2(attr_count); - if (generic_signature != NULL) { + if (generic_signature != nullptr) { write_signature_attribute(symbol_to_cpool_index(generic_signature)); } - if (ik()->source_file_name() != NULL) { + if (ik()->source_file_name() != nullptr) { write_source_file_attribute(); } - if (ik()->source_debug_extension() != NULL) { + if (ik()->source_debug_extension() != nullptr) { write_source_debug_extension_attribute(); } - if (anno != NULL) { + if (anno != nullptr) { write_annotations_attribute("RuntimeVisibleAnnotations", anno); } - if (type_anno != NULL) { + if (type_anno != nullptr) { write_annotations_attribute("RuntimeVisibleTypeAnnotations", type_anno); } if (ik()->nest_host_index() != 0) { @@ -835,10 +835,10 @@ void JvmtiClassFileReconstituter::write_class_attributes() { if (ik()->permitted_subclasses() != Universe::the_empty_short_array()) { write_permitted_subclasses_attribute(); } - if (ik()->record_components() != NULL) { + if (ik()->record_components() != nullptr) { write_record_attribute(); } - if (cpool()->operands() != NULL) { + if (cpool()->operands() != nullptr) { write_bootstrapmethod_attribute(); } if (inner_classes_length > 0) { @@ -919,7 +919,7 @@ void JvmtiClassFileReconstituter::write_class_file_format() { // JVMSpec| u2 super_class; write_u2(class_symbol_to_cpool_index(ik()->name())); Klass* super_class = ik()->super(); - write_u2(super_class == NULL? 0 : // zero for java.lang.Object + write_u2(super_class == nullptr? 0 : // zero for java.lang.Object class_symbol_to_cpool_index(super_class->name())); // JVMSpec| u2 interfaces_count; @@ -967,7 +967,7 @@ address JvmtiClassFileReconstituter::writeable_address(size_t size) { void JvmtiClassFileReconstituter::write_attribute_name_index(const char* name) { TempNewSymbol sym = SymbolTable::probe(name, (int)strlen(name)); - assert(sym != NULL, "attribute name symbol not found"); + assert(sym != nullptr, "attribute name symbol not found"); u2 attr_name_index = symbol_to_cpool_index(sym); assert(attr_name_index != 0, "attribute name symbol not in constant pool"); write_u2(attr_name_index); diff --git a/src/hotspot/share/prims/jvmtiClassFileReconstituter.hpp b/src/hotspot/share/prims/jvmtiClassFileReconstituter.hpp index 8322b43fcb42e..25f3cbf706452 100644 --- a/src/hotspot/share/prims/jvmtiClassFileReconstituter.hpp +++ b/src/hotspot/share/prims/jvmtiClassFileReconstituter.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 @@ -56,13 +56,13 @@ class JvmtiConstantPoolReconstituter : public StackObj { JvmtiConstantPoolReconstituter(InstanceKlass* ik); ~JvmtiConstantPoolReconstituter() { - if (_symmap != NULL) { + if (_symmap != nullptr) { delete _symmap; - _symmap = NULL; + _symmap = nullptr; } - if (_classmap != NULL) { + if (_classmap != nullptr) { delete _classmap; - _classmap = NULL; + _classmap = nullptr; } } @@ -73,8 +73,8 @@ class JvmtiConstantPoolReconstituter : public StackObj { int cpool_size() { return _cpool_size; } void copy_cpool_bytes(unsigned char *cpool_bytes) { - if (cpool_bytes == NULL) { - assert(cpool_bytes != NULL, "cpool_bytes pointer must not be NULL"); + if (cpool_bytes == nullptr) { + assert(cpool_bytes != nullptr, "cpool_bytes pointer must not be null"); return; } cpool()->copy_cpool_bytes(cpool_size(), _symmap, cpool_bytes); diff --git a/src/hotspot/share/prims/jvmtiCodeBlobEvents.cpp b/src/hotspot/share/prims/jvmtiCodeBlobEvents.cpp index bd68cee810d70..bc3957a41b900 100644 --- a/src/hotspot/share/prims/jvmtiCodeBlobEvents.cpp +++ b/src/hotspot/share/prims/jvmtiCodeBlobEvents.cpp @@ -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 @@ -53,7 +53,7 @@ // // collector.collect(); // JvmtiCodeBlobDesc* blob = collector.first(); -// while (blob != NULL) { +// while (blob != nullptr) { // : // blob = collector.next(); // } @@ -70,11 +70,11 @@ class CodeBlobCollector : StackObj { static void do_vtable_stub(VtableStub* vs); public: CodeBlobCollector() { - _code_blobs = NULL; + _code_blobs = nullptr; _pos = -1; } ~CodeBlobCollector() { - if (_code_blobs != NULL) { + if (_code_blobs != nullptr) { for (int i=0; i<_code_blobs->length(); i++) { FreeHeap(_code_blobs->at(i)); } @@ -87,9 +87,9 @@ class CodeBlobCollector : StackObj { // iteration support - return first code blob JvmtiCodeBlobDesc* first() { - assert(_code_blobs != NULL, "not collected"); + assert(_code_blobs != nullptr, "not collected"); if (_code_blobs->length() == 0) { - return NULL; + return nullptr; } _pos = 0; return _code_blobs->at(0); @@ -99,7 +99,7 @@ class CodeBlobCollector : StackObj { JvmtiCodeBlobDesc* next() { assert(_pos >= 0, "iteration not started"); if (_pos+1 >= _code_blobs->length()) { - return NULL; + return nullptr; } return _code_blobs->at(++_pos); } @@ -170,13 +170,13 @@ void CodeBlobCollector::do_vtable_stub(VtableStub* vs) { void CodeBlobCollector::collect() { assert_locked_or_safepoint(CodeCache_lock); - assert(_global_code_blobs == NULL, "checking"); + assert(_global_code_blobs == nullptr, "checking"); // create the global list _global_code_blobs = new (mtServiceability) GrowableArray(50, mtServiceability); // iterate over the stub code descriptors and put them in the list first. - for (StubCodeDesc* desc = StubCodeDesc::first(); desc != NULL; desc = StubCodeDesc::next(desc)) { + for (StubCodeDesc* desc = StubCodeDesc::first(); desc != nullptr; desc = StubCodeDesc::next(desc)) { _global_code_blobs->append(new JvmtiCodeBlobDesc(desc->name(), desc->begin(), desc->end())); } @@ -192,7 +192,7 @@ void CodeBlobCollector::collect() { // make the global list the instance list so that it can be used // for other iterations. _code_blobs = _global_code_blobs; - _global_code_blobs = NULL; + _global_code_blobs = nullptr; } @@ -212,7 +212,7 @@ jvmtiError JvmtiCodeBlobEvents::generate_dynamic_code_events(JvmtiEnv* env) { // iterate over the collected list and post an event for each blob JvmtiCodeBlobDesc* blob = collector.first(); - while (blob != NULL) { + while (blob != nullptr) { JvmtiExport::post_dynamic_code_generated(env, blob->name(), blob->code_begin(), blob->code_end()); blob = collector.next(); } @@ -262,7 +262,7 @@ void JvmtiCodeBlobEvents::build_jvmti_addr_location_map(nmethod *nm, jint *map_length_ptr) { ResourceMark rm; - jvmtiAddrLocationMap* map = NULL; + jvmtiAddrLocationMap* map = nullptr; jint map_length = 0; diff --git a/src/hotspot/share/prims/jvmtiDeferredUpdates.cpp b/src/hotspot/share/prims/jvmtiDeferredUpdates.cpp index 36dbd06879d2a..bddbdd4f9ffef 100644 --- a/src/hotspot/share/prims/jvmtiDeferredUpdates.cpp +++ b/src/hotspot/share/prims/jvmtiDeferredUpdates.cpp @@ -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. * Copyright (c) 2020 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -27,7 +27,7 @@ #include "prims/jvmtiDeferredUpdates.hpp" void JvmtiDeferredUpdates::create_for(JavaThread* thread) { - assert(thread->deferred_updates() == NULL, "already allocated"); + assert(thread->deferred_updates() == nullptr, "already allocated"); thread->set_deferred_updates(new JvmtiDeferredUpdates()); } @@ -40,7 +40,7 @@ JvmtiDeferredUpdates::~JvmtiDeferredUpdates() { } void JvmtiDeferredUpdates::inc_relock_count_after_wait(JavaThread* thread) { - if (thread->deferred_updates() == NULL) { + if (thread->deferred_updates() == nullptr) { create_for(thread); } thread->deferred_updates()->inc_relock_count_after_wait(); @@ -49,11 +49,11 @@ void JvmtiDeferredUpdates::inc_relock_count_after_wait(JavaThread* thread) { int JvmtiDeferredUpdates::get_and_reset_relock_count_after_wait(JavaThread* jt) { JvmtiDeferredUpdates* updates = jt->deferred_updates(); int result = 0; - if (updates != NULL) { + if (updates != nullptr) { result = updates->get_and_reset_relock_count_after_wait(); if (updates->count() == 0) { delete updates; - jt->set_deferred_updates(NULL); + jt->set_deferred_updates(nullptr); } } return result; @@ -61,7 +61,7 @@ int JvmtiDeferredUpdates::get_and_reset_relock_count_after_wait(JavaThread* jt) void JvmtiDeferredUpdates::delete_updates_for_frame(JavaThread* jt, intptr_t* frame_id) { JvmtiDeferredUpdates* updates = jt->deferred_updates(); - if (updates != NULL) { + if (updates != nullptr) { GrowableArray* list = updates->deferred_locals(); assert(list->length() > 0, "Updates holder not deleted"); int i = 0; @@ -78,7 +78,7 @@ void JvmtiDeferredUpdates::delete_updates_for_frame(JavaThread* jt, intptr_t* fr } } while ( i < list->length() ); if (updates->count() == 0) { - jt->set_deferred_updates(NULL); + jt->set_deferred_updates(nullptr); // Free deferred updates. // Note, the 'list' of local variable updates is embedded in 'updates'. delete updates; diff --git a/src/hotspot/share/prims/jvmtiDeferredUpdates.hpp b/src/hotspot/share/prims/jvmtiDeferredUpdates.hpp index 585d1f21018d6..f23f942780aaf 100644 --- a/src/hotspot/share/prims/jvmtiDeferredUpdates.hpp +++ b/src/hotspot/share/prims/jvmtiDeferredUpdates.hpp @@ -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. * Copyright (c) 2020 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -141,7 +141,7 @@ class JvmtiDeferredUpdates : public CHeapObj { static void create_for(JavaThread* thread); static GrowableArray* deferred_locals(JavaThread* jt) { - return jt->deferred_updates() == NULL ? NULL : jt->deferred_updates()->deferred_locals(); + return jt->deferred_updates() == nullptr ? nullptr : jt->deferred_updates()->deferred_locals(); } // Relocking has to be deferred if the lock owning thread is currently waiting on the monitor. diff --git a/src/hotspot/share/prims/jvmtiEnv.cpp b/src/hotspot/share/prims/jvmtiEnv.cpp index ee0425777c65e..a2917f1b5b989 100644 --- a/src/hotspot/share/prims/jvmtiEnv.cpp +++ b/src/hotspot/share/prims/jvmtiEnv.cpp @@ -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 @@ -130,31 +130,31 @@ class VM_JNIFunctionTableCopier : public VM_Operation { // Memory Management functions // -// mem_ptr - pre-checked for NULL +// mem_ptr - pre-checked for null jvmtiError JvmtiEnv::Allocate(jlong size, unsigned char** mem_ptr) { return allocate(size, mem_ptr); } /* end Allocate */ -// mem - NULL is a valid value, must be checked +// mem - null is a valid value, must be checked jvmtiError JvmtiEnv::Deallocate(unsigned char* mem) { return deallocate(mem); } /* end Deallocate */ // thread - NOT protected by ThreadsListHandle and NOT pre-checked -// data - NULL is a valid value, must be checked +// data - null is a valid value, must be checked jvmtiError JvmtiEnv::SetThreadLocalStorage(jthread thread, const void* data) { JavaThread* current = JavaThread::current(); - JvmtiThreadState* state = NULL; + JvmtiThreadState* state = nullptr; JvmtiVTMSTransitionDisabler disabler; ThreadsListHandle tlh(current); - JavaThread* java_thread = NULL; - oop thread_obj = NULL; - if (thread == NULL) { + JavaThread* java_thread = nullptr; + oop thread_obj = nullptr; + if (thread == nullptr) { java_thread = current; state = java_thread->jvmti_thread_state(); } else { @@ -164,16 +164,16 @@ JvmtiEnv::SetThreadLocalStorage(jthread thread, const void* data) { } state = java_lang_Thread::jvmti_thread_state(thread_obj); } - if (state == NULL) { - if (data == NULL) { - // leaving state unset same as data set to NULL + if (state == nullptr) { + if (data == nullptr) { + // leaving state unset same as data set to null return JVMTI_ERROR_NONE; } // otherwise, create the state HandleMark hm(current); Handle thread_handle(current, thread_obj); state = JvmtiThreadState::state_for(java_thread, thread_handle); - if (state == NULL) { + if (state == nullptr) { return JVMTI_ERROR_THREAD_NOT_ALIVE; } } @@ -183,13 +183,13 @@ JvmtiEnv::SetThreadLocalStorage(jthread thread, const void* data) { // thread - NOT protected by ThreadsListHandle and NOT pre-checked -// data_ptr - pre-checked for NULL +// data_ptr - pre-checked for null jvmtiError JvmtiEnv::GetThreadLocalStorage(jthread thread, void** data_ptr) { JavaThread* current_thread = JavaThread::current(); - if (thread == NULL) { + if (thread == nullptr) { JvmtiThreadState* state = current_thread->jvmti_thread_state(); - *data_ptr = (state == NULL) ? NULL : + *data_ptr = (state == nullptr) ? nullptr : state->env_thread_state(this)->get_agent_thread_local_storage_data(); } else { // jvmti_GetThreadLocalStorage is "in native" and doesn't transition @@ -205,8 +205,8 @@ JvmtiEnv::GetThreadLocalStorage(jthread thread, void** data_ptr) { JvmtiVTMSTransitionDisabler disabler; ThreadsListHandle tlh(current_thread); - JavaThread* java_thread = NULL; - oop thread_obj = NULL; + JavaThread* java_thread = nullptr; + oop thread_obj = nullptr; jvmtiError err = get_threadOop_and_JavaThread(tlh.list(), thread, &java_thread, &thread_obj); if (err != JVMTI_ERROR_NONE) { return err; @@ -215,7 +215,7 @@ JvmtiEnv::GetThreadLocalStorage(jthread thread, void** data_ptr) { HandleMark hm(current_thread); Handle thread_handle(current_thread, thread_obj); JvmtiThreadState* state = JvmtiThreadState::state_for(java_thread, thread_handle); - *data_ptr = (state == NULL) ? NULL : + *data_ptr = (state == nullptr) ? nullptr : state->env_thread_state(this)->get_agent_thread_local_storage_data(); } return JVMTI_ERROR_NONE; @@ -225,8 +225,8 @@ JvmtiEnv::GetThreadLocalStorage(jthread thread, void** data_ptr) { // Module functions // -// module_count_ptr - pre-checked for NULL -// modules_ptr - pre-checked for NULL +// module_count_ptr - pre-checked for null +// modules_ptr - pre-checked for null jvmtiError JvmtiEnv::GetAllModules(jint* module_count_ptr, jobject** modules_ptr) { JvmtiModuleClosure jmc; @@ -235,9 +235,9 @@ JvmtiEnv::GetAllModules(jint* module_count_ptr, jobject** modules_ptr) { } /* end GetAllModules */ -// class_loader - NULL is a valid value, must be pre-checked -// package_name - pre-checked for NULL -// module_ptr - pre-checked for NULL +// class_loader - null is a valid value, must be pre-checked +// package_name - pre-checked for null +// module_ptr - pre-checked for null jvmtiError JvmtiEnv::GetNamedModule(jobject class_loader, const char* package_name, jobject* module_ptr) { JavaThread* THREAD = JavaThread::current(); // For exception macros. @@ -249,13 +249,13 @@ JvmtiEnv::GetNamedModule(jobject class_loader, const char* package_name, jobject return JVMTI_ERROR_ILLEGAL_ARGUMENT; } oop module = Modules::get_named_module(h_loader, package_name); - *module_ptr = module != NULL ? JNIHandles::make_local(THREAD, module) : NULL; + *module_ptr = module != nullptr ? JNIHandles::make_local(THREAD, module) : nullptr; return JVMTI_ERROR_NONE; } /* end GetNamedModule */ -// module - pre-checked for NULL -// to_module - pre-checked for NULL +// module - pre-checked for null +// to_module - pre-checked for null jvmtiError JvmtiEnv::AddModuleReads(jobject module, jobject to_module) { JavaThread* THREAD = JavaThread::current(); // For exception macros. @@ -274,9 +274,9 @@ JvmtiEnv::AddModuleReads(jobject module, jobject to_module) { } /* end AddModuleReads */ -// module - pre-checked for NULL -// pkg_name - pre-checked for NULL -// to_module - pre-checked for NULL +// module - pre-checked for null +// pkg_name - pre-checked for null +// to_module - pre-checked for null jvmtiError JvmtiEnv::AddModuleExports(jobject module, const char* pkg_name, jobject to_module) { JavaThread* THREAD = JavaThread::current(); // For exception macros. @@ -296,9 +296,9 @@ JvmtiEnv::AddModuleExports(jobject module, const char* pkg_name, jobject to_modu } /* end AddModuleExports */ -// module - pre-checked for NULL -// pkg_name - pre-checked for NULL -// to_module - pre-checked for NULL +// module - pre-checked for null +// pkg_name - pre-checked for null +// to_module - pre-checked for null jvmtiError JvmtiEnv::AddModuleOpens(jobject module, const char* pkg_name, jobject to_module) { JavaThread* THREAD = JavaThread::current(); // For exception macros. @@ -318,8 +318,8 @@ JvmtiEnv::AddModuleOpens(jobject module, const char* pkg_name, jobject to_module } /* end AddModuleOpens */ -// module - pre-checked for NULL -// service - pre-checked for NULL +// module - pre-checked for null +// service - pre-checked for null jvmtiError JvmtiEnv::AddModuleUses(jobject module, jclass service) { JavaThread* THREAD = JavaThread::current(); // For exception macros. @@ -339,9 +339,9 @@ JvmtiEnv::AddModuleUses(jobject module, jclass service) { } /* end AddModuleUses */ -// module - pre-checked for NULL -// service - pre-checked for NULL -// impl_class - pre-checked for NULL +// module - pre-checked for null +// service - pre-checked for null +// impl_class - pre-checked for null jvmtiError JvmtiEnv::AddModuleProvides(jobject module, jclass service, jclass impl_class) { JavaThread* THREAD = JavaThread::current(); // For exception macros. @@ -366,8 +366,8 @@ JvmtiEnv::AddModuleProvides(jobject module, jclass service, jclass impl_class) { return JvmtiExport::add_module_provides(h_module, h_service, h_impl_class, THREAD); } /* end AddModuleProvides */ -// module - pre-checked for NULL -// is_modifiable_class_ptr - pre-checked for NULL +// module - pre-checked for null +// is_modifiable_class_ptr - pre-checked for null jvmtiError JvmtiEnv::IsModifiableModule(jobject module, jboolean* is_modifiable_module_ptr) { JavaThread* current = JavaThread::current(); @@ -387,17 +387,17 @@ JvmtiEnv::IsModifiableModule(jobject module, jboolean* is_modifiable_module_ptr) // Class functions // -// class_count_ptr - pre-checked for NULL -// classes_ptr - pre-checked for NULL +// class_count_ptr - pre-checked for null +// classes_ptr - pre-checked for null jvmtiError JvmtiEnv::GetLoadedClasses(jint* class_count_ptr, jclass** classes_ptr) { return JvmtiGetLoadedClasses::getLoadedClasses(this, class_count_ptr, classes_ptr); } /* end GetLoadedClasses */ -// initiating_loader - NULL is a valid value, must be checked -// class_count_ptr - pre-checked for NULL -// classes_ptr - pre-checked for NULL +// initiating_loader - null is a valid value, must be checked +// class_count_ptr - pre-checked for null +// classes_ptr - pre-checked for null jvmtiError JvmtiEnv::GetClassLoaderClasses(jobject initiating_loader, jint* class_count_ptr, jclass** classes_ptr) { return JvmtiGetLoadedClasses::getClassLoaderClasses(this, initiating_loader, @@ -405,7 +405,7 @@ JvmtiEnv::GetClassLoaderClasses(jobject initiating_loader, jint* class_count_ptr } /* end GetClassLoaderClasses */ // k_mirror - may be primitive, this must be checked -// is_modifiable_class_ptr - pre-checked for NULL +// is_modifiable_class_ptr - pre-checked for null jvmtiError JvmtiEnv::IsModifiableClass(oop k_mirror, jboolean* is_modifiable_class_ptr) { *is_modifiable_class_ptr = VM_RedefineClasses::is_modifiable_class(k_mirror)? @@ -414,7 +414,7 @@ JvmtiEnv::IsModifiableClass(oop k_mirror, jboolean* is_modifiable_class_ptr) { } /* end IsModifiableClass */ // class_count - pre-checked to be greater than or equal to 0 -// classes - pre-checked for NULL +// classes - pre-checked for null jvmtiError JvmtiEnv::RetransformClasses(jint class_count, const jclass* classes) { //TODO: add locking @@ -432,7 +432,7 @@ JvmtiEnv::RetransformClasses(jint class_count, const jclass* classes) { jclass jcls = classes[index]; oop k_mirror = JNIHandles::resolve_external_guard(jcls); - if (k_mirror == NULL) { + if (k_mirror == nullptr) { return JVMTI_ERROR_INVALID_CLASS; } if (!k_mirror->is_a(vmClasses::Class_klass())) { @@ -451,7 +451,7 @@ JvmtiEnv::RetransformClasses(jint class_count, const jclass* classes) { } InstanceKlass* ik = InstanceKlass::cast(klass); - if (ik->get_cached_class_file_bytes() == NULL) { + if (ik->get_cached_class_file_bytes() == nullptr) { // Not cached, we need to reconstitute the class file from the // VM representation. We don't attach the reconstituted class // bytes to the InstanceKlass here because they have not been @@ -485,7 +485,7 @@ JvmtiEnv::RetransformClasses(jint class_count, const jclass* classes) { // class_count - pre-checked to be greater than or equal to 0 -// class_definitions - pre-checked for NULL +// class_definitions - pre-checked for null jvmtiError JvmtiEnv::RedefineClasses(jint class_count, const jvmtiClassDefinition* class_definitions) { //TODO: add locking @@ -506,7 +506,7 @@ JvmtiEnv::RedefineClasses(jint class_count, const jvmtiClassDefinition* class_de // Object functions // -// size_ptr - pre-checked for NULL +// size_ptr - pre-checked for null jvmtiError JvmtiEnv::GetObjectSize(jobject object, jlong* size_ptr) { oop mirror = JNIHandles::resolve_external_guard(object); @@ -519,17 +519,17 @@ JvmtiEnv::GetObjectSize(jobject object, jlong* size_ptr) { // Method functions // -// prefix - NULL is a valid value, must be checked +// prefix - null is a valid value, must be checked jvmtiError JvmtiEnv::SetNativeMethodPrefix(const char* prefix) { - return prefix == NULL? - SetNativeMethodPrefixes(0, NULL) : + return prefix == nullptr? + SetNativeMethodPrefixes(0, nullptr) : SetNativeMethodPrefixes(1, (char**)&prefix); } /* end SetNativeMethodPrefix */ // prefix_count - pre-checked to be greater than or equal to 0 -// prefixes - pre-checked for NULL +// prefixes - pre-checked for null jvmtiError JvmtiEnv::SetNativeMethodPrefixes(jint prefix_count, char** prefixes) { // Have to grab JVMTI thread state lock to be sure that some thread @@ -547,7 +547,7 @@ JvmtiEnv::SetNativeMethodPrefixes(jint prefix_count, char** prefixes) { // Event Management functions // -// callbacks - NULL is a valid value, must be checked +// callbacks - null is a valid value, must be checked // size_of_callbacks - pre-checked to be greater than or equal to 0 jvmtiError JvmtiEnv::SetEventCallbacks(const jvmtiEventCallbacks* callbacks, jint size_of_callbacks) { @@ -557,7 +557,7 @@ JvmtiEnv::SetEventCallbacks(const jvmtiEventCallbacks* callbacks, jint size_of_c } /* end SetEventCallbacks */ -// event_thread - NULL is a valid value, must be checked +// event_thread - null is a valid value, must be checked jvmtiError JvmtiEnv::SetEventNotificationMode(jvmtiEventMode mode, jvmtiEvent event_type, jthread event_thread, ...) { bool enabled = (mode == JVMTI_ENABLE); @@ -577,19 +577,19 @@ JvmtiEnv::SetEventNotificationMode(jvmtiEventMode mode, jvmtiEvent event_type, j } JvmtiVTMSTransitionDisabler disabler; - if (event_thread == NULL) { - // Can be called at Agent_OnLoad() time with event_thread == NULL + if (event_thread == nullptr) { + // Can be called at Agent_OnLoad() time with event_thread == nullptr // when Thread::current() does not work yet so we cannot create a // ThreadsListHandle that is common to both thread-specific and // global code paths. - JvmtiEventController::set_user_enabled(this, NULL, (oop) NULL, event_type, enabled); + JvmtiEventController::set_user_enabled(this, nullptr, (oop) nullptr, event_type, enabled); } else { // We have a specified event_thread. ThreadsListHandle tlh; - JavaThread* java_thread = NULL; - oop thread_obj = NULL; + JavaThread* java_thread = nullptr; + oop thread_obj = nullptr; jvmtiError err = get_threadOop_and_JavaThread(tlh.list(), event_thread, &java_thread, &thread_obj); if (err != JVMTI_ERROR_NONE) { return err; @@ -610,7 +610,7 @@ JvmtiEnv::SetEventNotificationMode(jvmtiEventMode mode, jvmtiEvent event_type, j // Capability functions // -// capabilities_ptr - pre-checked for NULL +// capabilities_ptr - pre-checked for null jvmtiError JvmtiEnv::GetPotentialCapabilities(jvmtiCapabilities* capabilities_ptr) { JvmtiManageCapabilities::get_potential_capabilities(get_capabilities(), @@ -620,7 +620,7 @@ JvmtiEnv::GetPotentialCapabilities(jvmtiCapabilities* capabilities_ptr) { } /* end GetPotentialCapabilities */ -// capabilities_ptr - pre-checked for NULL +// capabilities_ptr - pre-checked for null jvmtiError JvmtiEnv::AddCapabilities(const jvmtiCapabilities* capabilities_ptr) { return JvmtiManageCapabilities::add_capabilities(get_capabilities(), @@ -630,7 +630,7 @@ JvmtiEnv::AddCapabilities(const jvmtiCapabilities* capabilities_ptr) { } /* end AddCapabilities */ -// capabilities_ptr - pre-checked for NULL +// capabilities_ptr - pre-checked for null jvmtiError JvmtiEnv::RelinquishCapabilities(const jvmtiCapabilities* capabilities_ptr) { JvmtiManageCapabilities::relinquish_capabilities(get_capabilities(), capabilities_ptr, get_capabilities()); @@ -638,7 +638,7 @@ JvmtiEnv::RelinquishCapabilities(const jvmtiCapabilities* capabilities_ptr) { } /* end RelinquishCapabilities */ -// capabilities_ptr - pre-checked for NULL +// capabilities_ptr - pre-checked for null jvmtiError JvmtiEnv::GetCapabilities(jvmtiCapabilities* capabilities_ptr) { JvmtiManageCapabilities::copy_capabilities(get_capabilities(), capabilities_ptr); @@ -649,7 +649,7 @@ JvmtiEnv::GetCapabilities(jvmtiCapabilities* capabilities_ptr) { // Class Loader Search functions // -// segment - pre-checked for NULL +// segment - pre-checked for null jvmtiError JvmtiEnv::AddToBootstrapClassLoaderSearch(const char* segment) { jvmtiPhase phase = get_phase(); @@ -668,7 +668,7 @@ JvmtiEnv::AddToBootstrapClassLoaderSearch(const char* segment) { // create the zip entry ClassPathZipEntry* zip_entry = ClassLoader::create_class_path_zip_entry(segment, true); - if (zip_entry == NULL) { + if (zip_entry == nullptr) { return JVMTI_ERROR_ILLEGAL_ARGUMENT; } @@ -687,13 +687,13 @@ JvmtiEnv::AddToBootstrapClassLoaderSearch(const char* segment) { } /* end AddToBootstrapClassLoaderSearch */ -// segment - pre-checked for NULL +// segment - pre-checked for null jvmtiError JvmtiEnv::AddToSystemClassLoaderSearch(const char* segment) { jvmtiPhase phase = get_phase(); if (phase == JVMTI_PHASE_ONLOAD) { - for (SystemProperty* p = Arguments::system_properties(); p != NULL; p = p->next()) { + for (SystemProperty* p = Arguments::system_properties(); p != nullptr; p = p->next()) { if (strcmp("java.class.path", p->key()) == 0) { p->append_value(segment); break; @@ -710,7 +710,7 @@ JvmtiEnv::AddToSystemClassLoaderSearch(const char* segment) { // create the zip entry (which will open the zip file and hence // check that the segment is indeed a zip file). ClassPathZipEntry* zip_entry = ClassLoader::create_class_path_zip_entry(segment, false); - if (zip_entry == NULL) { + if (zip_entry == nullptr) { return JVMTI_ERROR_ILLEGAL_ARGUMENT; } delete zip_entry; // no longer needed @@ -758,7 +758,7 @@ JvmtiEnv::AddToSystemClassLoaderSearch(const char* segment) { // General functions // -// phase_ptr - pre-checked for NULL +// phase_ptr - pre-checked for null jvmtiError JvmtiEnv::GetPhase(jvmtiPhase* phase_ptr) { *phase_ptr = phase(); @@ -773,7 +773,7 @@ JvmtiEnv::DisposeEnvironment() { } /* end DisposeEnvironment */ -// data - NULL is a valid value, must be checked +// data - null is a valid value, must be checked jvmtiError JvmtiEnv::SetEnvironmentLocalStorage(const void* data) { set_env_local_storage(data); @@ -781,14 +781,14 @@ JvmtiEnv::SetEnvironmentLocalStorage(const void* data) { } /* end SetEnvironmentLocalStorage */ -// data_ptr - pre-checked for NULL +// data_ptr - pre-checked for null jvmtiError JvmtiEnv::GetEnvironmentLocalStorage(void** data_ptr) { *data_ptr = (void*)get_env_local_storage(); return JVMTI_ERROR_NONE; } /* end GetEnvironmentLocalStorage */ -// version_ptr - pre-checked for NULL +// version_ptr - pre-checked for null jvmtiError JvmtiEnv::GetVersionNumber(jint* version_ptr) { *version_ptr = JVMTI_VERSION; @@ -796,14 +796,14 @@ JvmtiEnv::GetVersionNumber(jint* version_ptr) { } /* end GetVersionNumber */ -// name_ptr - pre-checked for NULL +// name_ptr - pre-checked for null jvmtiError JvmtiEnv::GetErrorName(jvmtiError error, char** name_ptr) { if (error < JVMTI_ERROR_NONE || error > JVMTI_ERROR_MAX) { return JVMTI_ERROR_ILLEGAL_ARGUMENT; } const char *name = JvmtiUtil::error_name(error); - if (name == NULL) { + if (name == nullptr) { return JVMTI_ERROR_ILLEGAL_ARGUMENT; } size_t len = strlen(name) + 1; @@ -840,7 +840,7 @@ JvmtiEnv::SetVerboseFlag(jvmtiVerboseFlag flag, jboolean value) { } /* end SetVerboseFlag */ -// format_ptr - pre-checked for NULL +// format_ptr - pre-checked for null jvmtiError JvmtiEnv::GetJLocationFormat(jvmtiJlocationFormat* format_ptr) { *format_ptr = JVMTI_JLOCATION_JVMBCI; @@ -852,15 +852,15 @@ JvmtiEnv::GetJLocationFormat(jvmtiJlocationFormat* format_ptr) { // // thread - NOT protected by ThreadsListHandle and NOT pre-checked -// thread_state_ptr - pre-checked for NULL +// thread_state_ptr - pre-checked for null jvmtiError JvmtiEnv::GetThreadState(jthread thread, jint* thread_state_ptr) { JavaThread* current_thread = JavaThread::current(); JvmtiVTMSTransitionDisabler disabler; ThreadsListHandle tlh(current_thread); - JavaThread* java_thread = NULL; - oop thread_oop = NULL; + JavaThread* java_thread = nullptr; + oop thread_oop = nullptr; jvmtiError err = get_threadOop_and_JavaThread(tlh.list(), thread, &java_thread, &thread_oop); if (err != JVMTI_ERROR_NONE && err != JVMTI_ERROR_THREAD_NOT_ALIVE) { // We got an error code so we don't have a JavaThread*, but only @@ -878,7 +878,7 @@ JvmtiEnv::GetThreadState(jthread thread, jint* thread_state_ptr) { } /* end GetThreadState */ -// thread_ptr - pre-checked for NULL +// thread_ptr - pre-checked for null jvmtiError JvmtiEnv::GetCurrentThread(jthread* thread_ptr) { JavaThread* cur_thread = JavaThread::current(); @@ -889,12 +889,12 @@ JvmtiEnv::GetCurrentThread(jthread* thread_ptr) { } /* end GetCurrentThread */ -// threads_count_ptr - pre-checked for NULL -// threads_ptr - pre-checked for NULL +// threads_count_ptr - pre-checked for null +// threads_ptr - pre-checked for null jvmtiError JvmtiEnv::GetAllThreads(jint* threads_count_ptr, jthread** threads_ptr) { int nthreads = 0; - Handle *thread_objs = NULL; + Handle *thread_objs = nullptr; Thread* current_thread = Thread::current(); ResourceMark rm(current_thread); HandleMark hm(current_thread); @@ -905,7 +905,7 @@ JvmtiEnv::GetAllThreads(jint* threads_count_ptr, jthread** threads_ptr) { *threads_count_ptr = nthreads; if (nthreads == 0) { - *threads_ptr = NULL; + *threads_ptr = nullptr; return JVMTI_ERROR_NONE; } @@ -930,8 +930,8 @@ JvmtiEnv::SuspendThread(jthread thread) { JavaThread* current = JavaThread::current(); jvmtiError err; - JavaThread* java_thread = NULL; - oop thread_oop = NULL; + JavaThread* java_thread = nullptr; + oop thread_oop = nullptr; { JvmtiVTMSTransitionDisabler disabler(true); ThreadsListHandle tlh(current); @@ -943,24 +943,24 @@ JvmtiEnv::SuspendThread(jthread thread) { // Do not use JvmtiVTMSTransitionDisabler in context of self suspend to avoid deadlocks. if (java_thread != current) { - err = suspend_thread(thread_oop, java_thread, /* single_suspend */ true, NULL); + err = suspend_thread(thread_oop, java_thread, /* single_suspend */ true, nullptr); return err; } } // Do self suspend for current JavaThread. - err = suspend_thread(thread_oop, current, /* single_suspend */ true, NULL); + err = suspend_thread(thread_oop, current, /* single_suspend */ true, nullptr); return err; } /* end SuspendThread */ // request_count - pre-checked to be greater than or equal to 0 -// request_list - pre-checked for NULL -// results - pre-checked for NULL +// request_list - pre-checked for null +// results - pre-checked for null jvmtiError JvmtiEnv::SuspendThreadList(jint request_count, const jthread* request_list, jvmtiError* results) { JavaThread* current = JavaThread::current(); HandleMark hm(current); - Handle self_tobj = Handle(current, NULL); + Handle self_tobj = Handle(current, nullptr); int self_idx = -1; { @@ -968,18 +968,18 @@ JvmtiEnv::SuspendThreadList(jint request_count, const jthread* request_list, jvm ThreadsListHandle tlh(current); for (int i = 0; i < request_count; i++) { - JavaThread *java_thread = NULL; - oop thread_oop = NULL; + JavaThread *java_thread = nullptr; + oop thread_oop = nullptr; jthread thread = request_list[i]; jvmtiError err = JvmtiExport::cv_external_thread_to_JavaThread(tlh.list(), thread, &java_thread, &thread_oop); - if (thread_oop != NULL && + if (thread_oop != nullptr && java_lang_VirtualThread::is_instance(thread_oop) && !JvmtiEnvBase::is_vthread_alive(thread_oop)) { err = JVMTI_ERROR_THREAD_NOT_ALIVE; } if (err != JVMTI_ERROR_NONE) { - if (thread_oop == NULL || err != JVMTI_ERROR_INVALID_THREAD) { + if (thread_oop == nullptr || err != JVMTI_ERROR_INVALID_THREAD) { results[i] = err; continue; } @@ -989,14 +989,14 @@ JvmtiEnv::SuspendThreadList(jint request_count, const jthread* request_list, jvm self_tobj = Handle(current, thread_oop); continue; // self suspend after all other suspends } - results[i] = suspend_thread(thread_oop, java_thread, /* single_suspend */ true, NULL); + results[i] = suspend_thread(thread_oop, java_thread, /* single_suspend */ true, nullptr); } } // Self suspend after all other suspends if necessary. // Do not use JvmtiVTMSTransitionDisabler in context of self suspend to avoid deadlocks. - if (self_tobj() != NULL) { + if (self_tobj() != nullptr) { // there should not be any error for current java_thread - results[self_idx] = suspend_thread(self_tobj(), current, /* single_suspend */ true, NULL); + results[self_idx] = suspend_thread(self_tobj(), current, /* single_suspend */ true, nullptr); } // per-thread suspend results returned via results parameter return JVMTI_ERROR_NONE; @@ -1013,7 +1013,7 @@ JvmtiEnv::SuspendAllVirtualThreads(jint except_count, const jthread* except_list } JavaThread* current = JavaThread::current(); HandleMark hm(current); - Handle self_tobj = Handle(current, NULL); + Handle self_tobj = Handle(current, nullptr); { ResourceMark rm(current); @@ -1041,7 +1041,7 @@ JvmtiEnv::SuspendAllVirtualThreads(jint except_count, const jthread* except_list if (!java_thread->is_exiting() && !java_thread->is_jvmti_agent_thread() && !java_thread->is_hidden_from_external_view() && - vt_oop != NULL && + vt_oop != nullptr && java_lang_VirtualThread::is_instance(vt_oop) && JvmtiEnvBase::is_vthread_alive(vt_oop) && !JvmtiVTSuspender::is_vthread_suspended(vt_oop) && @@ -1051,7 +1051,7 @@ JvmtiEnv::SuspendAllVirtualThreads(jint except_count, const jthread* except_list self_tobj = Handle(current, vt_oop); continue; // self suspend after all other suspends } - suspend_thread(vt_oop, java_thread, /* single_suspend */ false, NULL); + suspend_thread(vt_oop, java_thread, /* single_suspend */ false, nullptr); } } JvmtiVTSuspender::register_all_vthreads_suspend(); @@ -1067,8 +1067,8 @@ JvmtiEnv::SuspendAllVirtualThreads(jint except_count, const jthread* except_list } // Self suspend after all other suspends if necessary. // Do not use JvmtiVTMSTransitionDisabler in context of self suspend to avoid deadlocks. - if (self_tobj() != NULL) { - suspend_thread(self_tobj(), current, /* single_suspend */ false, NULL); + if (self_tobj() != nullptr) { + suspend_thread(self_tobj(), current, /* single_suspend */ false, nullptr); } return JVMTI_ERROR_NONE; } /* end SuspendAllVirtualThreads */ @@ -1080,8 +1080,8 @@ JvmtiEnv::ResumeThread(jthread thread) { JvmtiVTMSTransitionDisabler disabler(true); ThreadsListHandle tlh; - JavaThread* java_thread = NULL; - oop thread_oop = NULL; + JavaThread* java_thread = nullptr; + oop thread_oop = nullptr; jvmtiError err = get_threadOop_and_JavaThread(tlh.list(), thread, &java_thread, &thread_oop); if (err != JVMTI_ERROR_NONE) { return err; @@ -1092,12 +1092,12 @@ JvmtiEnv::ResumeThread(jthread thread) { // request_count - pre-checked to be greater than or equal to 0 -// request_list - pre-checked for NULL -// results - pre-checked for NULL +// request_list - pre-checked for null +// results - pre-checked for null jvmtiError JvmtiEnv::ResumeThreadList(jint request_count, const jthread* request_list, jvmtiError* results) { - oop thread_oop = NULL; - JavaThread* java_thread = NULL; + oop thread_oop = nullptr; + JavaThread* java_thread = nullptr; JvmtiVTMSTransitionDisabler disabler(true); ThreadsListHandle tlh; @@ -1105,13 +1105,13 @@ JvmtiEnv::ResumeThreadList(jint request_count, const jthread* request_list, jvmt jthread thread = request_list[i]; jvmtiError err = JvmtiExport::cv_external_thread_to_JavaThread(tlh.list(), thread, &java_thread, &thread_oop); - if (thread_oop != NULL && + if (thread_oop != nullptr && java_lang_VirtualThread::is_instance(thread_oop) && !JvmtiEnvBase::is_vthread_alive(thread_oop)) { err = JVMTI_ERROR_THREAD_NOT_ALIVE; } if (err != JVMTI_ERROR_NONE) { - if (thread_oop == NULL || err != JVMTI_ERROR_INVALID_THREAD) { + if (thread_oop == nullptr || err != JVMTI_ERROR_INVALID_THREAD) { results[i] = err; continue; } @@ -1154,7 +1154,7 @@ JvmtiEnv::ResumeAllVirtualThreads(jint except_count, const jthread* except_list) if (!java_thread->is_exiting() && !java_thread->is_jvmti_agent_thread() && !java_thread->is_hidden_from_external_view() && - vt_oop != NULL && + vt_oop != nullptr && java_lang_VirtualThread::is_instance(vt_oop) && JvmtiEnvBase::is_vthread_alive(vt_oop) && JvmtiVTSuspender::is_vthread_suspended(vt_oop) && @@ -1183,14 +1183,14 @@ JvmtiEnv::StopThread(jthread thread, jobject exception) { JvmtiVTMSTransitionDisabler disabler; ThreadsListHandle tlh(current_thread); - JavaThread* java_thread = NULL; - oop thread_oop = NULL; + JavaThread* java_thread = nullptr; + oop thread_oop = nullptr; NULL_CHECK(thread, JVMTI_ERROR_INVALID_THREAD); jvmtiError err = get_threadOop_and_JavaThread(tlh.list(), thread, &java_thread, &thread_oop); - if (thread_oop != NULL && java_lang_VirtualThread::is_instance(thread_oop)) { + if (thread_oop != nullptr && java_lang_VirtualThread::is_instance(thread_oop)) { // No support for virtual threads (yet). return JVMTI_ERROR_UNSUPPORTED_OPERATION; } @@ -1216,8 +1216,8 @@ JvmtiEnv::InterruptThread(jthread thread) { JvmtiVTMSTransitionDisabler disabler; ThreadsListHandle tlh(current_thread); - JavaThread* java_thread = NULL; - oop thread_obj = NULL; + JavaThread* java_thread = nullptr; + oop thread_obj = nullptr; jvmtiError err = get_threadOop_and_JavaThread(tlh.list(), thread, &java_thread, &thread_obj); if (err != JVMTI_ERROR_NONE) { return err; @@ -1249,23 +1249,23 @@ JvmtiEnv::InterruptThread(jthread thread) { // thread - NOT protected by ThreadsListHandle and NOT pre-checked -// info_ptr - pre-checked for NULL +// info_ptr - pre-checked for null jvmtiError JvmtiEnv::GetThreadInfo(jthread thread, jvmtiThreadInfo* info_ptr) { JavaThread* current_thread = JavaThread::current(); ResourceMark rm(current_thread); HandleMark hm(current_thread); - JavaThread* java_thread = NULL; - oop thread_oop = NULL; + JavaThread* java_thread = nullptr; + oop thread_oop = nullptr; JvmtiVTMSTransitionDisabler disabler; ThreadsListHandle tlh(current_thread); - // if thread is NULL the current thread is used - if (thread == NULL) { + // if thread is null the current thread is used + if (thread == nullptr) { java_thread = JavaThread::current(); thread_oop = get_vthread_or_thread_oop(java_thread); - if (thread_oop == NULL || !thread_oop->is_a(vmClasses::Thread_klass())) { + if (thread_oop == nullptr || !thread_oop->is_a(vmClasses::Thread_klass())) { return JVMTI_ERROR_INVALID_THREAD; } } else { @@ -1276,7 +1276,7 @@ JvmtiEnv::GetThreadInfo(jthread thread, jvmtiThreadInfo* info_ptr) { // thread_oop. // In the virtual thread case the cv_external_thread_to_JavaThread is expected to correctly set // the thread_oop and return JVMTI_ERROR_INVALID_THREAD which we ignore here. - if (thread_oop == NULL) { + if (thread_oop == nullptr) { return err; } } @@ -1296,7 +1296,7 @@ JvmtiEnv::GetThreadInfo(jthread thread, jvmtiThreadInfo* info_ptr) { priority = (ThreadPriority)JVMTI_THREAD_NORM_PRIORITY; is_daemon = true; if (java_lang_VirtualThread::state(thread_obj()) == java_lang_VirtualThread::TERMINATED) { - thread_group = Handle(current_thread, NULL); + thread_group = Handle(current_thread, nullptr); } else { thread_group = Handle(current_thread, java_lang_Thread_Constants::get_VTHREAD_GROUP()); } @@ -1304,14 +1304,14 @@ JvmtiEnv::GetThreadInfo(jthread thread, jvmtiThreadInfo* info_ptr) { priority = java_lang_Thread::priority(thread_obj()); is_daemon = java_lang_Thread::is_daemon(thread_obj()); if (java_lang_Thread::get_thread_status(thread_obj()) == JavaThreadStatus::TERMINATED) { - thread_group = Handle(current_thread, NULL); + thread_group = Handle(current_thread, nullptr); } else { thread_group = Handle(current_thread, java_lang_Thread::threadGroup(thread_obj())); } } oop loader = java_lang_Thread::context_class_loader(thread_obj()); - if (loader != NULL) { + if (loader != nullptr) { // Do the same as Thread.getContextClassLoader and set context_class_loader to be // the system class loader when the field value is the "not supported" placeholder. if (loader == java_lang_Thread_Constants::get_NOT_SUPPORTED_CLASSLOADER()) { @@ -1322,15 +1322,15 @@ JvmtiEnv::GetThreadInfo(jthread thread, jvmtiThreadInfo* info_ptr) { { const char *n; - if (name() != NULL) { + if (name() != nullptr) { n = java_lang_String::as_utf8_string(name()); } else { int utf8_length = 0; - n = UNICODE::as_utf8((jchar*) NULL, utf8_length); + n = UNICODE::as_utf8((jchar*) nullptr, utf8_length); } info_ptr->name = (char *) jvmtiMalloc(strlen(n)+1); - if (info_ptr->name == NULL) + if (info_ptr->name == nullptr) return JVMTI_ERROR_OUT_OF_MEMORY; strcpy(info_ptr->name, n); @@ -1338,7 +1338,7 @@ JvmtiEnv::GetThreadInfo(jthread thread, jvmtiThreadInfo* info_ptr) { info_ptr->is_daemon = is_daemon; info_ptr->priority = priority; - info_ptr->context_class_loader = (context_class_loader.is_null()) ? NULL : + info_ptr->context_class_loader = (context_class_loader.is_null()) ? nullptr : jni_reference(context_class_loader); info_ptr->thread_group = jni_reference(thread_group); @@ -1347,8 +1347,8 @@ JvmtiEnv::GetThreadInfo(jthread thread, jvmtiThreadInfo* info_ptr) { // thread - NOT protected by ThreadsListHandle and NOT pre-checked -// owned_monitor_count_ptr - pre-checked for NULL -// owned_monitors_ptr - pre-checked for NULL +// owned_monitor_count_ptr - pre-checked for null +// owned_monitors_ptr - pre-checked for null jvmtiError JvmtiEnv::GetOwnedMonitorInfo(jthread thread, jint* owned_monitor_count_ptr, jobject** owned_monitors_ptr) { JavaThread* calling_thread = JavaThread::current(); @@ -1361,8 +1361,8 @@ JvmtiEnv::GetOwnedMonitorInfo(jthread thread, jint* owned_monitor_count_ptr, job JvmtiVTMSTransitionDisabler disabler; ThreadsListHandle tlh(calling_thread); - JavaThread* java_thread = NULL; - oop thread_oop = NULL; + JavaThread* java_thread = nullptr; + oop thread_oop = nullptr; jvmtiError err = get_threadOop_and_JavaThread(tlh.list(), thread, &java_thread, &thread_oop); if (err != JVMTI_ERROR_NONE) { delete owned_monitors_list; @@ -1371,7 +1371,7 @@ JvmtiEnv::GetOwnedMonitorInfo(jthread thread, jint* owned_monitor_count_ptr, job if (java_lang_VirtualThread::is_instance(thread_oop)) { // There is no monitor info to collect if target virtual thread is unmounted. - if (java_thread != NULL) { + if (java_thread != nullptr) { VirtualThreadGetOwnedMonitorInfoClosure op(this, Handle(calling_thread, thread_oop), owned_monitors_list); @@ -1420,8 +1420,8 @@ JvmtiEnv::GetOwnedMonitorInfo(jthread thread, jint* owned_monitor_count_ptr, job // thread - NOT protected by ThreadsListHandle and NOT pre-checked -// monitor_info_count_ptr - pre-checked for NULL -// monitor_info_ptr - pre-checked for NULL +// monitor_info_count_ptr - pre-checked for null +// monitor_info_ptr - pre-checked for null jvmtiError JvmtiEnv::GetOwnedMonitorStackDepthInfo(jthread thread, jint* monitor_info_count_ptr, jvmtiMonitorStackDepthInfo** monitor_info_ptr) { JavaThread* calling_thread = JavaThread::current(); @@ -1434,8 +1434,8 @@ JvmtiEnv::GetOwnedMonitorStackDepthInfo(jthread thread, jint* monitor_info_count JvmtiVTMSTransitionDisabler disabler; ThreadsListHandle tlh(calling_thread); - JavaThread* java_thread = NULL; - oop thread_oop = NULL; + JavaThread* java_thread = nullptr; + oop thread_oop = nullptr; jvmtiError err = get_threadOop_and_JavaThread(tlh.list(), thread, &java_thread, &thread_oop); if (err != JVMTI_ERROR_NONE) { delete owned_monitors_list; @@ -1444,7 +1444,7 @@ JvmtiEnv::GetOwnedMonitorStackDepthInfo(jthread thread, jint* monitor_info_count if (java_lang_VirtualThread::is_instance(thread_oop)) { // There is no monitor info to collect if target virtual thread is unmounted. - if (java_thread != NULL) { + if (java_thread != nullptr) { VirtualThreadGetOwnedMonitorInfoClosure op(this, Handle(calling_thread, thread_oop), owned_monitors_list); @@ -1495,7 +1495,7 @@ JvmtiEnv::GetOwnedMonitorStackDepthInfo(jthread thread, jint* monitor_info_count // thread - NOT protected by ThreadsListHandle and NOT pre-checked -// monitor_ptr - pre-checked for NULL +// monitor_ptr - pre-checked for null jvmtiError JvmtiEnv::GetCurrentContendedMonitor(jthread thread, jobject* monitor_ptr) { JavaThread* calling_thread = JavaThread::current(); @@ -1504,8 +1504,8 @@ JvmtiEnv::GetCurrentContendedMonitor(jthread thread, jobject* monitor_ptr) { JvmtiVTMSTransitionDisabler disabler; ThreadsListHandle tlh(calling_thread); - JavaThread* java_thread = NULL; - oop thread_oop = NULL; + JavaThread* java_thread = nullptr; + oop thread_oop = nullptr; jvmtiError err = get_threadOop_and_JavaThread(tlh.list(), thread, &java_thread, &thread_oop); if (err != JVMTI_ERROR_NONE) { return err; @@ -1513,12 +1513,12 @@ JvmtiEnv::GetCurrentContendedMonitor(jthread thread, jobject* monitor_ptr) { if (java_lang_VirtualThread::is_instance(thread_oop)) { // There is no monitor info to collect if target virtual thread is unmounted. - if (java_thread != NULL) { + if (java_thread != nullptr) { GetCurrentContendedMonitorClosure op(calling_thread, this, monitor_ptr, /* is_virtual */ true); Handshake::execute(&op, java_thread); err = op.result(); } else { - *monitor_ptr = NULL; + *monitor_ptr = nullptr; if (!JvmtiEnvBase::is_vthread_alive(thread_oop)) { err = JVMTI_ERROR_THREAD_NOT_ALIVE; } @@ -1540,27 +1540,27 @@ JvmtiEnv::GetCurrentContendedMonitor(jthread thread, jobject* monitor_ptr) { // thread - NOT protected by ThreadsListHandle and NOT pre-checked -// proc - pre-checked for NULL -// arg - NULL is a valid value, must be checked +// proc - pre-checked for null +// arg - null is a valid value, must be checked jvmtiError JvmtiEnv::RunAgentThread(jthread thread, jvmtiStartFunction proc, const void* arg, jint priority) { JavaThread* current_thread = JavaThread::current(); - JavaThread* java_thread = NULL; - oop thread_oop = NULL; + JavaThread* java_thread = nullptr; + oop thread_oop = nullptr; ThreadsListHandle tlh(current_thread); jvmtiError err = JvmtiExport::cv_external_thread_to_JavaThread(tlh.list(), thread, &java_thread, &thread_oop); if (err != JVMTI_ERROR_NONE) { // We got an error code so we don't have a JavaThread *, but // only return an error from here if we didn't get a valid // thread_oop. - if (thread_oop == NULL) { + if (thread_oop == nullptr) { return err; } // We have a valid thread_oop. } - if (java_thread != NULL) { + if (java_thread != nullptr) { // 'thread' refers to an existing JavaThread. return JVMTI_ERROR_INVALID_THREAD; } @@ -1579,7 +1579,7 @@ JvmtiEnv::RunAgentThread(jthread thread, jvmtiStartFunction proc, const void* ar // At this point it may be possible that no osthread was created for the // JavaThread due to lack of resources. - if (new_thread->osthread() == NULL) { + if (new_thread->osthread() == nullptr) { // The new thread is not known to Thread-SMR yet so we can just delete. delete new_thread; return JVMTI_ERROR_OUT_OF_MEMORY; @@ -1595,8 +1595,8 @@ JvmtiEnv::RunAgentThread(jthread thread, jvmtiStartFunction proc, const void* ar // Thread Group functions // -// group_count_ptr - pre-checked for NULL -// groups_ptr - pre-checked for NULL +// group_count_ptr - pre-checked for null +// groups_ptr - pre-checked for null jvmtiError JvmtiEnv::GetTopThreadGroups(jint* group_count_ptr, jthreadGroup** groups_ptr) { JavaThread* current_thread = JavaThread::current(); @@ -1621,7 +1621,7 @@ JvmtiEnv::GetTopThreadGroups(jint* group_count_ptr, jthreadGroup** groups_ptr) { } /* end GetTopThreadGroups */ -// info_ptr - pre-checked for NULL +// info_ptr - pre-checked for null jvmtiError JvmtiEnv::GetThreadGroupInfo(jthreadGroup group, jvmtiThreadGroupInfo* info_ptr) { Thread* current_thread = Thread::current(); @@ -1645,21 +1645,21 @@ JvmtiEnv::GetThreadGroupInfo(jthreadGroup group, jvmtiThreadGroupInfo* info_ptr) info_ptr->max_priority = max_priority; info_ptr->parent = jni_reference(parent_group); - if (name != NULL) { + if (name != nullptr) { info_ptr->name = (char*)jvmtiMalloc(strlen(name)+1); NULL_CHECK(info_ptr->name, JVMTI_ERROR_OUT_OF_MEMORY); strcpy(info_ptr->name, name); } else { - info_ptr->name = NULL; + info_ptr->name = nullptr; } return JVMTI_ERROR_NONE; } /* end GetThreadGroupInfo */ -// thread_count_ptr - pre-checked for NULL -// threads_ptr - pre-checked for NULL -// group_count_ptr - pre-checked for NULL -// groups_ptr - pre-checked for NULL +// thread_count_ptr - pre-checked for null +// threads_ptr - pre-checked for null +// group_count_ptr - pre-checked for null +// groups_ptr - pre-checked for null jvmtiError JvmtiEnv::GetThreadGroupChildren(jthreadGroup group, jint* thread_count_ptr, jthread** threads_ptr, jint* group_count_ptr, jthreadGroup** groups_ptr) { jvmtiError err; @@ -1667,7 +1667,7 @@ JvmtiEnv::GetThreadGroupChildren(jthreadGroup group, jint* thread_count_ptr, jth oop group_obj = JNIHandles::resolve_external_guard(group); NULL_CHECK(group_obj, JVMTI_ERROR_INVALID_THREAD_GROUP); - Handle *thread_objs = NULL; + Handle *thread_objs = nullptr; objArrayHandle group_objs; jint nthreads = 0; jint ngroups = 0; @@ -1691,10 +1691,10 @@ JvmtiEnv::GetThreadGroupChildren(jthreadGroup group, jint* thread_count_ptr, jth *thread_count_ptr = nthreads; *threads_ptr = new_jthreadArray(nthreads, thread_objs); *groups_ptr = new_jthreadGroupArray(ngroups, group_objs); - if (nthreads > 0 && *threads_ptr == NULL) { + if (nthreads > 0 && *threads_ptr == nullptr) { return JVMTI_ERROR_OUT_OF_MEMORY; } - if (ngroups > 0 && *groups_ptr == NULL) { + if (ngroups > 0 && *groups_ptr == nullptr) { return JVMTI_ERROR_OUT_OF_MEMORY; } @@ -1708,8 +1708,8 @@ JvmtiEnv::GetThreadGroupChildren(jthreadGroup group, jint* thread_count_ptr, jth // thread - NOT protected by ThreadsListHandle and NOT pre-checked // max_frame_count - pre-checked to be greater than or equal to 0 -// frame_buffer - pre-checked for NULL -// count_ptr - pre-checked for NULL +// frame_buffer - pre-checked for null +// count_ptr - pre-checked for null jvmtiError JvmtiEnv::GetStackTrace(jthread thread, jint start_depth, jint max_frame_count, jvmtiFrameInfo* frame_buffer, jint* count_ptr) { JavaThread* current_thread = JavaThread::current(); @@ -1718,15 +1718,15 @@ JvmtiEnv::GetStackTrace(jthread thread, jint start_depth, jint max_frame_count, JvmtiVTMSTransitionDisabler disabler; ThreadsListHandle tlh(current_thread); - JavaThread* java_thread = NULL; - oop thread_obj = NULL; + JavaThread* java_thread = nullptr; + oop thread_obj = nullptr; jvmtiError err = get_threadOop_and_JavaThread(tlh.list(), thread, &java_thread, &thread_obj); if (err != JVMTI_ERROR_NONE) { return err; } if (java_lang_VirtualThread::is_instance(thread_obj)) { - if (java_thread == NULL) { // Target virtual thread is unmounted. + if (java_thread == nullptr) { // Target virtual thread is unmounted. ResourceMark rm(current_thread); VM_VirtualThreadGetStackTrace op(this, Handle(current_thread, thread_obj), @@ -1757,8 +1757,8 @@ JvmtiEnv::GetStackTrace(jthread thread, jint start_depth, jint max_frame_count, // max_frame_count - pre-checked to be greater than or equal to 0 -// stack_info_ptr - pre-checked for NULL -// thread_count_ptr - pre-checked for NULL +// stack_info_ptr - pre-checked for null +// thread_count_ptr - pre-checked for null jvmtiError JvmtiEnv::GetAllStackTraces(jint max_frame_count, jvmtiStackInfo** stack_info_ptr, jint* thread_count_ptr) { jvmtiError err = JVMTI_ERROR_NONE; @@ -1775,9 +1775,9 @@ JvmtiEnv::GetAllStackTraces(jint max_frame_count, jvmtiStackInfo** stack_info_pt // thread_count - pre-checked to be greater than or equal to 0 -// thread_list - pre-checked for NULL +// thread_list - pre-checked for null // max_frame_count - pre-checked to be greater than or equal to 0 -// stack_info_ptr - pre-checked for NULL +// stack_info_ptr - pre-checked for null jvmtiError JvmtiEnv::GetThreadListStackTraces(jint thread_count, const jthread* thread_list, jint max_frame_count, jvmtiStackInfo** stack_info_ptr) { jvmtiError err = JVMTI_ERROR_NONE; @@ -1791,13 +1791,13 @@ JvmtiEnv::GetThreadListStackTraces(jint thread_count, const jthread* thread_list jthread thread = thread_list[0]; JavaThread *java_thread; - oop thread_obj = NULL; + oop thread_obj = nullptr; err = get_threadOop_and_JavaThread(tlh.list(), thread, &java_thread, &thread_obj); if (err != JVMTI_ERROR_NONE) { return err; } - if (java_lang_VirtualThread::is_instance(thread_obj) && java_thread == NULL) { + if (java_lang_VirtualThread::is_instance(thread_obj) && java_thread == nullptr) { // Target virtual thread is unmounted. ResourceMark rm(current_thread); MultipleStackTracesCollector collector(this, max_frame_count); @@ -1827,7 +1827,7 @@ JvmtiEnv::GetThreadListStackTraces(jint thread_count, const jthread* thread_list // thread - NOT protected by ThreadsListHandle and NOT pre-checked -// count_ptr - pre-checked for NULL +// count_ptr - pre-checked for null jvmtiError JvmtiEnv::GetFrameCount(jthread thread, jint* count_ptr) { JavaThread* current_thread = JavaThread::current(); @@ -1836,15 +1836,15 @@ JvmtiEnv::GetFrameCount(jthread thread, jint* count_ptr) { JvmtiVTMSTransitionDisabler disabler; ThreadsListHandle tlh(current_thread); - JavaThread* java_thread = NULL; - oop thread_obj = NULL; + JavaThread* java_thread = nullptr; + oop thread_obj = nullptr; jvmtiError err = get_threadOop_and_JavaThread(tlh.list(), thread, &java_thread, &thread_obj); if (err != JVMTI_ERROR_NONE) { return err; } if (java_lang_VirtualThread::is_instance(thread_obj)) { - if (java_thread == NULL) { // Target virtual thread is unmounted. + if (java_thread == nullptr) { // Target virtual thread is unmounted. VM_VirtualThreadGetFrameCount op(this, Handle(current_thread, thread_obj), count_ptr); VMThread::execute(&op); return op.result(); @@ -1874,17 +1874,17 @@ JvmtiEnv::PopFrame(jthread thread) { JavaThread* current_thread = JavaThread::current(); HandleMark hm(current_thread); - if (thread == NULL) { + if (thread == nullptr) { return JVMTI_ERROR_INVALID_THREAD; } JvmtiVTMSTransitionDisabler disabler; ThreadsListHandle tlh(current_thread); - JavaThread* java_thread = NULL; - oop thread_obj = NULL; + JavaThread* java_thread = nullptr; + oop thread_obj = nullptr; jvmtiError err = get_threadOop_and_JavaThread(tlh.list(), thread, &java_thread, &thread_obj); - if (thread_obj != NULL && java_lang_VirtualThread::is_instance(thread_obj)) { + if (thread_obj != nullptr && java_lang_VirtualThread::is_instance(thread_obj)) { // No support for virtual threads (yet). return JVMTI_ERROR_OPAQUE_FRAME; } @@ -1894,7 +1894,7 @@ JvmtiEnv::PopFrame(jthread thread) { // retrieve or create the state JvmtiThreadState* state = JvmtiThreadState::state_for(java_thread); - if (state == NULL) { + if (state == nullptr) { return JVMTI_ERROR_THREAD_NOT_ALIVE; } @@ -1918,8 +1918,8 @@ JvmtiEnv::PopFrame(jthread thread) { // thread - NOT protected by ThreadsListHandle and NOT pre-checked // depth - pre-checked as non-negative -// method_ptr - pre-checked for NULL -// location_ptr - pre-checked for NULL +// method_ptr - pre-checked for null +// location_ptr - pre-checked for null jvmtiError JvmtiEnv::GetFrameLocation(jthread thread, jint depth, jmethodID* method_ptr, jlocation* location_ptr) { JavaThread* current_thread = JavaThread::current(); @@ -1928,15 +1928,15 @@ JvmtiEnv::GetFrameLocation(jthread thread, jint depth, jmethodID* method_ptr, jl JvmtiVTMSTransitionDisabler disabler; ThreadsListHandle tlh(current_thread); - JavaThread* java_thread = NULL; - oop thread_obj = NULL; + JavaThread* java_thread = nullptr; + oop thread_obj = nullptr; jvmtiError err = get_threadOop_and_JavaThread(tlh.list(), thread, &java_thread, &thread_obj); if (err != JVMTI_ERROR_NONE) { return err; } if (java_lang_VirtualThread::is_instance(thread_obj)) { - if (java_thread == NULL) { // Target virtual thread is unmounted. + if (java_thread == nullptr) { // Target virtual thread is unmounted. err = get_frame_location(thread_obj, depth, method_ptr, location_ptr); return err; } @@ -1968,8 +1968,8 @@ JvmtiEnv::NotifyFramePop(jthread thread, jint depth) { JvmtiVTMSTransitionDisabler disabler; ThreadsListHandle tlh; - JavaThread* java_thread = NULL; - oop thread_obj = NULL; + JavaThread* java_thread = nullptr; + oop thread_obj = nullptr; jvmtiError err = get_threadOop_and_JavaThread(tlh.list(), thread, &java_thread, &thread_obj); if (err != JVMTI_ERROR_NONE) { return err; @@ -1979,14 +1979,14 @@ JvmtiEnv::NotifyFramePop(jthread thread, jint depth) { HandleMark hm(current); Handle thread_handle(current, thread_obj); JvmtiThreadState *state = JvmtiThreadState::state_for(java_thread, thread_handle); - if (state == NULL) { + if (state == nullptr) { return JVMTI_ERROR_THREAD_NOT_ALIVE; } if (java_lang_VirtualThread::is_instance(thread_handle())) { VirtualThreadSetFramePopClosure op(this, thread_handle, state, depth); MutexLocker mu(current, JvmtiThreadState_lock); - if (java_thread == NULL || java_thread == current) { + if (java_thread == nullptr || java_thread == current) { // Target virtual thread is unmounted or current. op.doit(java_thread, true /* self */); } else { @@ -2068,31 +2068,31 @@ JvmtiEnv::ForceEarlyReturnVoid(jthread thread) { // Heap functions // -// klass - NULL is a valid value, must be checked -// initial_object - NULL is a valid value, must be checked -// callbacks - pre-checked for NULL -// user_data - NULL is a valid value, must be checked +// klass - null is a valid value, must be checked +// initial_object - null is a valid value, must be checked +// callbacks - pre-checked for null +// user_data - null is a valid value, must be checked jvmtiError JvmtiEnv::FollowReferences(jint heap_filter, jclass klass, jobject initial_object, const jvmtiHeapCallbacks* callbacks, const void* user_data) { // check klass if provided - Klass* k = NULL; - if (klass != NULL) { + Klass* k = nullptr; + if (klass != nullptr) { oop k_mirror = JNIHandles::resolve_external_guard(klass); - if (k_mirror == NULL) { + if (k_mirror == nullptr) { return JVMTI_ERROR_INVALID_CLASS; } if (java_lang_Class::is_primitive(k_mirror)) { return JVMTI_ERROR_NONE; } k = java_lang_Class::as_Klass(k_mirror); - if (klass == NULL) { + if (klass == nullptr) { return JVMTI_ERROR_INVALID_CLASS; } } - if (initial_object != NULL) { + if (initial_object != nullptr) { oop init_obj = JNIHandles::resolve_external_guard(initial_object); - if (init_obj == NULL) { + if (init_obj == nullptr) { return JVMTI_ERROR_INVALID_OBJECT; } } @@ -2106,23 +2106,23 @@ JvmtiEnv::FollowReferences(jint heap_filter, jclass klass, jobject initial_objec } /* end FollowReferences */ -// klass - NULL is a valid value, must be checked -// callbacks - pre-checked for NULL -// user_data - NULL is a valid value, must be checked +// klass - null is a valid value, must be checked +// callbacks - pre-checked for null +// user_data - null is a valid value, must be checked jvmtiError JvmtiEnv::IterateThroughHeap(jint heap_filter, jclass klass, const jvmtiHeapCallbacks* callbacks, const void* user_data) { // check klass if provided - Klass* k = NULL; - if (klass != NULL) { + Klass* k = nullptr; + if (klass != nullptr) { oop k_mirror = JNIHandles::resolve_external_guard(klass); - if (k_mirror == NULL) { + if (k_mirror == nullptr) { return JVMTI_ERROR_INVALID_CLASS; } if (java_lang_Class::is_primitive(k_mirror)) { return JVMTI_ERROR_NONE; } k = java_lang_Class::as_Klass(k_mirror); - if (k == NULL) { + if (k == nullptr) { return JVMTI_ERROR_INVALID_CLASS; } } @@ -2133,7 +2133,7 @@ JvmtiEnv::IterateThroughHeap(jint heap_filter, jclass klass, const jvmtiHeapCall } /* end IterateThroughHeap */ -// tag_ptr - pre-checked for NULL +// tag_ptr - pre-checked for null jvmtiError JvmtiEnv::GetTag(jobject object, jlong* tag_ptr) { oop o = JNIHandles::resolve_external_guard(object); @@ -2153,10 +2153,10 @@ JvmtiEnv::SetTag(jobject object, jlong tag) { // tag_count - pre-checked to be greater than or equal to 0 -// tags - pre-checked for NULL -// count_ptr - pre-checked for NULL -// object_result_ptr - NULL is a valid value, must be checked -// tag_result_ptr - NULL is a valid value, must be checked +// tags - pre-checked for null +// count_ptr - pre-checked for null +// object_result_ptr - null is a valid value, must be checked +// tag_result_ptr - null is a valid value, must be checked jvmtiError JvmtiEnv::GetObjectsWithTags(jint tag_count, const jlong* tags, jint* count_ptr, jobject** object_result_ptr, jlong** tag_result_ptr) { TraceTime t("GetObjectsWithTags", TRACETIME_LOG(Debug, jvmti, objecttagging)); @@ -2175,8 +2175,8 @@ JvmtiEnv::ForceGarbageCollection() { // Heap (1.0) functions // -// object_reference_callback - pre-checked for NULL -// user_data - NULL is a valid value, must be checked +// object_reference_callback - pre-checked for null +// user_data - null is a valid value, must be checked jvmtiError JvmtiEnv::IterateOverObjectsReachableFromObject(jobject object, jvmtiObjectReferenceCallback object_reference_callback, const void* user_data) { oop o = JNIHandles::resolve_external_guard(object); @@ -2186,10 +2186,10 @@ JvmtiEnv::IterateOverObjectsReachableFromObject(jobject object, jvmtiObjectRefer } /* end IterateOverObjectsReachableFromObject */ -// heap_root_callback - NULL is a valid value, must be checked -// stack_ref_callback - NULL is a valid value, must be checked -// object_ref_callback - NULL is a valid value, must be checked -// user_data - NULL is a valid value, must be checked +// heap_root_callback - null is a valid value, must be checked +// stack_ref_callback - null is a valid value, must be checked +// object_ref_callback - null is a valid value, must be checked +// user_data - null is a valid value, must be checked jvmtiError JvmtiEnv::IterateOverReachableObjects(jvmtiHeapRootCallback heap_root_callback, jvmtiStackReferenceCallback stack_ref_callback, jvmtiObjectReferenceCallback object_ref_callback, const void* user_data) { TraceTime t("IterateOverReachableObjects", TRACETIME_LOG(Debug, jvmti, objecttagging)); @@ -2198,21 +2198,21 @@ JvmtiEnv::IterateOverReachableObjects(jvmtiHeapRootCallback heap_root_callback, } /* end IterateOverReachableObjects */ -// heap_object_callback - pre-checked for NULL -// user_data - NULL is a valid value, must be checked +// heap_object_callback - pre-checked for null +// user_data - null is a valid value, must be checked jvmtiError JvmtiEnv::IterateOverHeap(jvmtiHeapObjectFilter object_filter, jvmtiHeapObjectCallback heap_object_callback, const void* user_data) { TraceTime t("IterateOverHeap", TRACETIME_LOG(Debug, jvmti, objecttagging)); Thread *thread = Thread::current(); HandleMark hm(thread); - JvmtiTagMap::tag_map_for(this)->iterate_over_heap(object_filter, NULL, heap_object_callback, user_data); + JvmtiTagMap::tag_map_for(this)->iterate_over_heap(object_filter, nullptr, heap_object_callback, user_data); return JVMTI_ERROR_NONE; } /* end IterateOverHeap */ // k_mirror - may be primitive, this must be checked -// heap_object_callback - pre-checked for NULL -// user_data - NULL is a valid value, must be checked +// heap_object_callback - pre-checked for null +// user_data - null is a valid value, must be checked jvmtiError JvmtiEnv::IterateOverInstancesOfClass(oop k_mirror, jvmtiHeapObjectFilter object_filter, jvmtiHeapObjectCallback heap_object_callback, const void* user_data) { if (java_lang_Class::is_primitive(k_mirror)) { @@ -2220,7 +2220,7 @@ JvmtiEnv::IterateOverInstancesOfClass(oop k_mirror, jvmtiHeapObjectFilter object return JVMTI_ERROR_NONE; } Klass* klass = java_lang_Class::as_Klass(k_mirror); - if (klass == NULL) { + if (klass == nullptr) { return JVMTI_ERROR_INVALID_CLASS; } TraceTime t("IterateOverInstancesOfClass", TRACETIME_LOG(Debug, jvmti, objecttagging)); @@ -2235,7 +2235,7 @@ JvmtiEnv::IterateOverInstancesOfClass(oop k_mirror, jvmtiHeapObjectFilter object // thread - NOT protected by ThreadsListHandle and NOT pre-checked // depth - pre-checked as non-negative -// value_ptr - pre-checked for NULL +// value_ptr - pre-checked for null jvmtiError JvmtiEnv::GetLocalObject(jthread thread, jint depth, jint slot, jobject* value_ptr) { JavaThread* current_thread = JavaThread::current(); @@ -2246,8 +2246,8 @@ JvmtiEnv::GetLocalObject(jthread thread, jint depth, jint slot, jobject* value_p JvmtiVTMSTransitionDisabler disabler; ThreadsListHandle tlh(current_thread); - JavaThread* java_thread = NULL; - oop thread_obj = NULL; + JavaThread* java_thread = nullptr; + oop thread_obj = nullptr; jvmtiError err = get_threadOop_and_JavaThread(tlh.list(), thread, &java_thread, &thread_obj); if (err != JVMTI_ERROR_NONE) { return err; @@ -2276,7 +2276,7 @@ JvmtiEnv::GetLocalObject(jthread thread, jint depth, jint slot, jobject* value_p // thread - NOT protected by ThreadsListHandle and NOT pre-checked // depth - pre-checked as non-negative -// value - pre-checked for NULL +// value - pre-checked for null jvmtiError JvmtiEnv::GetLocalInstance(jthread thread, jint depth, jobject* value_ptr){ JavaThread* current_thread = JavaThread::current(); @@ -2287,8 +2287,8 @@ JvmtiEnv::GetLocalInstance(jthread thread, jint depth, jobject* value_ptr){ JvmtiVTMSTransitionDisabler disabler; ThreadsListHandle tlh(current_thread); - JavaThread* java_thread = NULL; - oop thread_obj = NULL; + JavaThread* java_thread = nullptr; + oop thread_obj = nullptr; jvmtiError err = get_threadOop_and_JavaThread(tlh.list(), thread, &java_thread, &thread_obj); if (err != JVMTI_ERROR_NONE) { return err; @@ -2318,7 +2318,7 @@ JvmtiEnv::GetLocalInstance(jthread thread, jint depth, jobject* value_ptr){ // thread - NOT protected by ThreadsListHandle and NOT pre-checked // depth - pre-checked as non-negative -// value_ptr - pre-checked for NULL +// value_ptr - pre-checked for null jvmtiError JvmtiEnv::GetLocalInt(jthread thread, jint depth, jint slot, jint* value_ptr) { JavaThread* current_thread = JavaThread::current(); @@ -2329,8 +2329,8 @@ JvmtiEnv::GetLocalInt(jthread thread, jint depth, jint slot, jint* value_ptr) { JvmtiVTMSTransitionDisabler disabler; ThreadsListHandle tlh(current_thread); - JavaThread* java_thread = NULL; - oop thread_obj = NULL; + JavaThread* java_thread = nullptr; + oop thread_obj = nullptr; jvmtiError err = get_threadOop_and_JavaThread(tlh.list(), thread, &java_thread, &thread_obj); if (err != JVMTI_ERROR_NONE) { return err; @@ -2360,7 +2360,7 @@ JvmtiEnv::GetLocalInt(jthread thread, jint depth, jint slot, jint* value_ptr) { // thread - NOT protected by ThreadsListHandle and NOT pre-checked // depth - pre-checked as non-negative -// value_ptr - pre-checked for NULL +// value_ptr - pre-checked for null jvmtiError JvmtiEnv::GetLocalLong(jthread thread, jint depth, jint slot, jlong* value_ptr) { JavaThread* current_thread = JavaThread::current(); @@ -2371,8 +2371,8 @@ JvmtiEnv::GetLocalLong(jthread thread, jint depth, jint slot, jlong* value_ptr) JvmtiVTMSTransitionDisabler disabler; ThreadsListHandle tlh(current_thread); - JavaThread* java_thread = NULL; - oop thread_obj = NULL; + JavaThread* java_thread = nullptr; + oop thread_obj = nullptr; jvmtiError err = get_threadOop_and_JavaThread(tlh.list(), thread, &java_thread, &thread_obj); if (err != JVMTI_ERROR_NONE) { return err; @@ -2402,7 +2402,7 @@ JvmtiEnv::GetLocalLong(jthread thread, jint depth, jint slot, jlong* value_ptr) // thread - NOT protected by ThreadsListHandle and NOT pre-checked // depth - pre-checked as non-negative -// value_ptr - pre-checked for NULL +// value_ptr - pre-checked for null jvmtiError JvmtiEnv::GetLocalFloat(jthread thread, jint depth, jint slot, jfloat* value_ptr) { JavaThread* current_thread = JavaThread::current(); @@ -2413,8 +2413,8 @@ JvmtiEnv::GetLocalFloat(jthread thread, jint depth, jint slot, jfloat* value_ptr JvmtiVTMSTransitionDisabler disabler; ThreadsListHandle tlh(current_thread); - JavaThread* java_thread = NULL; - oop thread_obj = NULL; + JavaThread* java_thread = nullptr; + oop thread_obj = nullptr; jvmtiError err = get_threadOop_and_JavaThread(tlh.list(), thread, &java_thread, &thread_obj); if (err != JVMTI_ERROR_NONE) { return err; @@ -2444,7 +2444,7 @@ JvmtiEnv::GetLocalFloat(jthread thread, jint depth, jint slot, jfloat* value_ptr // thread - NOT protected by ThreadsListHandle and NOT pre-checked // depth - pre-checked as non-negative -// value_ptr - pre-checked for NULL +// value_ptr - pre-checked for null jvmtiError JvmtiEnv::GetLocalDouble(jthread thread, jint depth, jint slot, jdouble* value_ptr) { JavaThread* current_thread = JavaThread::current(); @@ -2455,8 +2455,8 @@ JvmtiEnv::GetLocalDouble(jthread thread, jint depth, jint slot, jdouble* value_p JvmtiVTMSTransitionDisabler disabler; ThreadsListHandle tlh(current_thread); - JavaThread* java_thread = NULL; - oop thread_obj = NULL; + JavaThread* java_thread = nullptr; + oop thread_obj = nullptr; jvmtiError err = get_threadOop_and_JavaThread(tlh.list(), thread, &java_thread, &thread_obj); if (err != JVMTI_ERROR_NONE) { return err; @@ -2496,8 +2496,8 @@ JvmtiEnv::SetLocalObject(jthread thread, jint depth, jint slot, jobject value) { JvmtiVTMSTransitionDisabler disabler; ThreadsListHandle tlh(current_thread); - JavaThread* java_thread = NULL; - oop thread_obj = NULL; + JavaThread* java_thread = nullptr; + oop thread_obj = nullptr; jvmtiError err = get_threadOop_and_JavaThread(tlh.list(), thread, &java_thread, &thread_obj); if (err != JVMTI_ERROR_NONE) { return err; @@ -2533,8 +2533,8 @@ JvmtiEnv::SetLocalInt(jthread thread, jint depth, jint slot, jint value) { JvmtiVTMSTransitionDisabler disabler; ThreadsListHandle tlh(current_thread); - JavaThread* java_thread = NULL; - oop thread_obj = NULL; + JavaThread* java_thread = nullptr; + oop thread_obj = nullptr; jvmtiError err = get_threadOop_and_JavaThread(tlh.list(), thread, &java_thread, &thread_obj); if (err != JVMTI_ERROR_NONE) { return err; @@ -2570,8 +2570,8 @@ JvmtiEnv::SetLocalLong(jthread thread, jint depth, jint slot, jlong value) { JvmtiVTMSTransitionDisabler disabler; ThreadsListHandle tlh(current_thread); - JavaThread* java_thread = NULL; - oop thread_obj = NULL; + JavaThread* java_thread = nullptr; + oop thread_obj = nullptr; jvmtiError err = get_threadOop_and_JavaThread(tlh.list(), thread, &java_thread, &thread_obj); if (err != JVMTI_ERROR_NONE) { return err; @@ -2607,8 +2607,8 @@ JvmtiEnv::SetLocalFloat(jthread thread, jint depth, jint slot, jfloat value) { JvmtiVTMSTransitionDisabler disabler; ThreadsListHandle tlh(current_thread); - JavaThread* java_thread = NULL; - oop thread_obj = NULL; + JavaThread* java_thread = nullptr; + oop thread_obj = nullptr; jvmtiError err = get_threadOop_and_JavaThread(tlh.list(), thread, &java_thread, &thread_obj); if (err != JVMTI_ERROR_NONE) { return err; @@ -2644,8 +2644,8 @@ JvmtiEnv::SetLocalDouble(jthread thread, jint depth, jint slot, jdouble value) { JvmtiVTMSTransitionDisabler disabler; ThreadsListHandle tlh(current_thread); - JavaThread* java_thread = NULL; - oop thread_obj = NULL; + JavaThread* java_thread = nullptr; + oop thread_obj = nullptr; jvmtiError err = get_threadOop_and_JavaThread(tlh.list(), thread, &java_thread, &thread_obj); if (err != JVMTI_ERROR_NONE) { return err; @@ -2673,7 +2673,7 @@ JvmtiEnv::SetLocalDouble(jthread thread, jint depth, jint slot, jdouble value) { // Breakpoint functions // -// method - pre-checked for validity, but may be NULL meaning obsolete method +// method - pre-checked for validity, but may be null meaning obsolete method jvmtiError JvmtiEnv::SetBreakpoint(Method* method, jlocation location) { NULL_CHECK(method, JVMTI_ERROR_INVALID_METHODID); @@ -2699,7 +2699,7 @@ JvmtiEnv::SetBreakpoint(Method* method, jlocation location) { } /* end SetBreakpoint */ -// method - pre-checked for validity, but may be NULL meaning obsolete method +// method - pre-checked for validity, but may be null meaning obsolete method jvmtiError JvmtiEnv::ClearBreakpoint(Method* method, jlocation location) { NULL_CHECK(method, JVMTI_ERROR_INVALID_METHODID); @@ -2784,19 +2784,19 @@ JvmtiEnv::ClearFieldModificationWatch(fieldDescriptor* fdesc_ptr) { // k_mirror - may be primitive, this must be checked -// signature_ptr - NULL is a valid value, must be checked -// generic_ptr - NULL is a valid value, must be checked +// signature_ptr - null is a valid value, must be checked +// generic_ptr - null is a valid value, must be checked jvmtiError JvmtiEnv::GetClassSignature(oop k_mirror, char** signature_ptr, char** generic_ptr) { ResourceMark rm; bool isPrimitive = java_lang_Class::is_primitive(k_mirror); - Klass* k = NULL; + Klass* k = nullptr; if (!isPrimitive) { k = java_lang_Class::as_Klass(k_mirror); NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS); } - if (signature_ptr != NULL) { - char* result = NULL; + if (signature_ptr != nullptr) { + char* result = nullptr; if (isPrimitive) { char tchar = type2char(java_lang_Class::primitive_type(k_mirror)); result = (char*) jvmtiMalloc(2); @@ -2809,13 +2809,13 @@ JvmtiEnv::GetClassSignature(oop k_mirror, char** signature_ptr, char** generic_p } *signature_ptr = result; } - if (generic_ptr != NULL) { - *generic_ptr = NULL; + if (generic_ptr != nullptr) { + *generic_ptr = nullptr; if (!isPrimitive && k->is_instance_klass()) { Symbol* soo = InstanceKlass::cast(k)->generic_signature(); - if (soo != NULL) { + if (soo != nullptr) { const char *gen_sig = soo->as_C_string(); - if (gen_sig != NULL) { + if (gen_sig != nullptr) { char* gen_result; jvmtiError err = allocate(strlen(gen_sig) + 1, (unsigned char **)&gen_result); @@ -2833,7 +2833,7 @@ JvmtiEnv::GetClassSignature(oop k_mirror, char** signature_ptr, char** generic_p // k_mirror - may be primitive, this must be checked -// status_ptr - pre-checked for NULL +// status_ptr - pre-checked for null jvmtiError JvmtiEnv::GetClassStatus(oop k_mirror, jint* status_ptr) { jint result = 0; @@ -2851,7 +2851,7 @@ JvmtiEnv::GetClassStatus(oop k_mirror, jint* status_ptr) { // k_mirror - may be primitive, this must be checked -// source_name_ptr - pre-checked for NULL +// source_name_ptr - pre-checked for null jvmtiError JvmtiEnv::GetSourceFileName(oop k_mirror, char** source_name_ptr) { if (java_lang_Class::is_primitive(k_mirror)) { @@ -2879,7 +2879,7 @@ JvmtiEnv::GetSourceFileName(oop k_mirror, char** source_name_ptr) { // k_mirror - may be primitive, this must be checked -// modifiers_ptr - pre-checked for NULL +// modifiers_ptr - pre-checked for null jvmtiError JvmtiEnv::GetClassModifiers(oop k_mirror, jint* modifiers_ptr) { JavaThread* current_thread = JavaThread::current(); @@ -2903,8 +2903,8 @@ JvmtiEnv::GetClassModifiers(oop k_mirror, jint* modifiers_ptr) { // k_mirror - may be primitive, this must be checked -// method_count_ptr - pre-checked for NULL -// methods_ptr - pre-checked for NULL +// method_count_ptr - pre-checked for null +// methods_ptr - pre-checked for null jvmtiError JvmtiEnv::GetClassMethods(oop k_mirror, jint* method_count_ptr, jmethodID** methods_ptr) { JavaThread* current_thread = JavaThread::current(); @@ -2944,14 +2944,14 @@ JvmtiEnv::GetClassMethods(oop k_mirror, jint* method_count_ptr, jmethodID** meth int result_index = JvmtiExport::can_maintain_original_method_order() ? ik->method_ordering()->at(index) : index; assert(result_index >= 0 && result_index < result_length, "invalid original method index"); if (m->is_overpass()) { - result_list[result_index] = NULL; + result_list[result_index] = nullptr; skipped++; continue; } jmethodID id; if (jmethodids_found) { id = m->find_jmethod_id_or_null(); - if (id == NULL) { + if (id == nullptr) { // If we find an uninitialized value, make sure there is // enough space for all the uninitialized values we might // find. @@ -2967,11 +2967,11 @@ JvmtiEnv::GetClassMethods(oop k_mirror, jint* method_count_ptr, jmethodID** meth // Fill in return value. if (skipped > 0) { - // copy results skipping NULL methodIDs + // copy results skipping null methodIDs *methods_ptr = (jmethodID*)jvmtiMalloc((result_length - skipped) * sizeof(jmethodID)); *method_count_ptr = result_length - skipped; for (index = 0, skipped = 0; index < result_length; index++) { - if (result_list[index] == NULL) { + if (result_list[index] == nullptr) { skipped++; } else { (*methods_ptr)[index - skipped] = result_list[index]; @@ -2988,8 +2988,8 @@ JvmtiEnv::GetClassMethods(oop k_mirror, jint* method_count_ptr, jmethodID** meth // k_mirror - may be primitive, this must be checked -// field_count_ptr - pre-checked for NULL -// fields_ptr - pre-checked for NULL +// field_count_ptr - pre-checked for null +// fields_ptr - pre-checked for null jvmtiError JvmtiEnv::GetClassFields(oop k_mirror, jint* field_count_ptr, jfieldID** fields_ptr) { if (java_lang_Class::is_primitive(k_mirror)) { @@ -3042,8 +3042,8 @@ JvmtiEnv::GetClassFields(oop k_mirror, jint* field_count_ptr, jfieldID** fields_ // k_mirror - may be primitive, this must be checked -// interface_count_ptr - pre-checked for NULL -// interfaces_ptr - pre-checked for NULL +// interface_count_ptr - pre-checked for null +// interfaces_ptr - pre-checked for null jvmtiError JvmtiEnv::GetImplementedInterfaces(oop k_mirror, jint* interface_count_ptr, jclass** interfaces_ptr) { { @@ -3068,7 +3068,7 @@ JvmtiEnv::GetImplementedInterfaces(oop k_mirror, jint* interface_count_ptr, jcla } Array* interface_list = InstanceKlass::cast(k)->local_interfaces(); - const int result_length = (interface_list == NULL ? 0 : interface_list->length()); + const int result_length = (interface_list == nullptr ? 0 : interface_list->length()); jclass* result_list = (jclass*) jvmtiMalloc(result_length * sizeof(jclass)); for (int i_index = 0; i_index < result_length; i_index += 1) { InstanceKlass* klass_at = interface_list->at(i_index); @@ -3087,8 +3087,8 @@ JvmtiEnv::GetImplementedInterfaces(oop k_mirror, jint* interface_count_ptr, jcla // k_mirror - may be primitive, this must be checked -// minor_version_ptr - pre-checked for NULL -// major_version_ptr - pre-checked for NULL +// minor_version_ptr - pre-checked for null +// major_version_ptr - pre-checked for null jvmtiError JvmtiEnv::GetClassVersionNumbers(oop k_mirror, jint* minor_version_ptr, jint* major_version_ptr) { if (java_lang_Class::is_primitive(k_mirror)) { @@ -3113,9 +3113,9 @@ JvmtiEnv::GetClassVersionNumbers(oop k_mirror, jint* minor_version_ptr, jint* ma // k_mirror - may be primitive, this must be checked -// constant_pool_count_ptr - pre-checked for NULL -// constant_pool_byte_count_ptr - pre-checked for NULL -// constant_pool_bytes_ptr - pre-checked for NULL +// constant_pool_count_ptr - pre-checked for null +// constant_pool_byte_count_ptr - pre-checked for null +// constant_pool_bytes_ptr - pre-checked for null jvmtiError JvmtiEnv::GetConstantPool(oop k_mirror, jint* constant_pool_count_ptr, jint* constant_pool_byte_count_ptr, unsigned char** constant_pool_bytes_ptr) { if (java_lang_Class::is_primitive(k_mirror)) { @@ -3164,14 +3164,14 @@ JvmtiEnv::GetConstantPool(oop k_mirror, jint* constant_pool_count_ptr, jint* con // k_mirror - may be primitive, this must be checked -// is_interface_ptr - pre-checked for NULL +// is_interface_ptr - pre-checked for null jvmtiError JvmtiEnv::IsInterface(oop k_mirror, jboolean* is_interface_ptr) { { bool result = false; if (!java_lang_Class::is_primitive(k_mirror)) { Klass* k = java_lang_Class::as_Klass(k_mirror); - if (k != NULL && k->is_interface()) { + if (k != nullptr && k->is_interface()) { result = true; } } @@ -3183,14 +3183,14 @@ JvmtiEnv::IsInterface(oop k_mirror, jboolean* is_interface_ptr) { // k_mirror - may be primitive, this must be checked -// is_array_class_ptr - pre-checked for NULL +// is_array_class_ptr - pre-checked for null jvmtiError JvmtiEnv::IsArrayClass(oop k_mirror, jboolean* is_array_class_ptr) { { bool result = false; if (!java_lang_Class::is_primitive(k_mirror)) { Klass* k = java_lang_Class::as_Klass(k_mirror); - if (k != NULL && k->is_array_klass()) { + if (k != nullptr && k->is_array_klass()) { result = true; } } @@ -3202,7 +3202,7 @@ JvmtiEnv::IsArrayClass(oop k_mirror, jboolean* is_array_class_ptr) { // k_mirror - may be primitive, this must be checked -// classloader_ptr - pre-checked for NULL +// classloader_ptr - pre-checked for null jvmtiError JvmtiEnv::GetClassLoader(oop k_mirror, jobject* classloader_ptr) { { @@ -3216,7 +3216,7 @@ JvmtiEnv::GetClassLoader(oop k_mirror, jobject* classloader_ptr) { NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS); oop result_oop = k->class_loader(); - if (result_oop == NULL) { + if (result_oop == nullptr) { *classloader_ptr = (jclass) jni_reference(Handle()); return JVMTI_ERROR_NONE; } @@ -3229,7 +3229,7 @@ JvmtiEnv::GetClassLoader(oop k_mirror, jobject* classloader_ptr) { // k_mirror - may be primitive, this must be checked -// source_debug_extension_ptr - pre-checked for NULL +// source_debug_extension_ptr - pre-checked for null jvmtiError JvmtiEnv::GetSourceDebugExtension(oop k_mirror, char** source_debug_extension_ptr) { { @@ -3257,7 +3257,7 @@ JvmtiEnv::GetSourceDebugExtension(oop k_mirror, char** source_debug_extension_pt // Object functions // -// hash_code_ptr - pre-checked for NULL +// hash_code_ptr - pre-checked for null jvmtiError JvmtiEnv::GetObjectHashCode(jobject object, jint* hash_code_ptr) { oop mirror = JNIHandles::resolve_external_guard(object); @@ -3272,7 +3272,7 @@ JvmtiEnv::GetObjectHashCode(jobject object, jint* hash_code_ptr) { } /* end GetObjectHashCode */ -// info_ptr - pre-checked for NULL +// info_ptr - pre-checked for null jvmtiError JvmtiEnv::GetObjectMonitorUsage(jobject object, jvmtiMonitorUsage* info_ptr) { // This needs to be performed at a safepoint to gather stable data @@ -3287,37 +3287,37 @@ JvmtiEnv::GetObjectMonitorUsage(jobject object, jvmtiMonitorUsage* info_ptr) { // Field functions // -// name_ptr - NULL is a valid value, must be checked -// signature_ptr - NULL is a valid value, must be checked -// generic_ptr - NULL is a valid value, must be checked +// name_ptr - null is a valid value, must be checked +// signature_ptr - null is a valid value, must be checked +// generic_ptr - null is a valid value, must be checked jvmtiError JvmtiEnv::GetFieldName(fieldDescriptor* fdesc_ptr, char** name_ptr, char** signature_ptr, char** generic_ptr) { JavaThread* current_thread = JavaThread::current(); ResourceMark rm(current_thread); - if (name_ptr == NULL) { + if (name_ptr == nullptr) { // just don't return the name } else { const char* fieldName = fdesc_ptr->name()->as_C_string(); *name_ptr = (char*) jvmtiMalloc(strlen(fieldName) + 1); - if (*name_ptr == NULL) + if (*name_ptr == nullptr) return JVMTI_ERROR_OUT_OF_MEMORY; strcpy(*name_ptr, fieldName); } - if (signature_ptr== NULL) { + if (signature_ptr== nullptr) { // just don't return the signature } else { const char* fieldSignature = fdesc_ptr->signature()->as_C_string(); *signature_ptr = (char*) jvmtiMalloc(strlen(fieldSignature) + 1); - if (*signature_ptr == NULL) + if (*signature_ptr == nullptr) return JVMTI_ERROR_OUT_OF_MEMORY; strcpy(*signature_ptr, fieldSignature); } - if (generic_ptr != NULL) { - *generic_ptr = NULL; + if (generic_ptr != nullptr) { + *generic_ptr = nullptr; Symbol* soop = fdesc_ptr->generic_signature(); - if (soop != NULL) { + if (soop != nullptr) { const char* gen_sig = soop->as_C_string(); - if (gen_sig != NULL) { + if (gen_sig != nullptr) { jvmtiError err = allocate(strlen(gen_sig) + 1, (unsigned char **)generic_ptr); if (err != JVMTI_ERROR_NONE) { return err; @@ -3330,7 +3330,7 @@ JvmtiEnv::GetFieldName(fieldDescriptor* fdesc_ptr, char** name_ptr, char** signa } /* end GetFieldName */ -// declaring_class_ptr - pre-checked for NULL +// declaring_class_ptr - pre-checked for null jvmtiError JvmtiEnv::GetFieldDeclaringClass(fieldDescriptor* fdesc_ptr, jclass* declaring_class_ptr) { @@ -3339,7 +3339,7 @@ JvmtiEnv::GetFieldDeclaringClass(fieldDescriptor* fdesc_ptr, jclass* declaring_c } /* end GetFieldDeclaringClass */ -// modifiers_ptr - pre-checked for NULL +// modifiers_ptr - pre-checked for null jvmtiError JvmtiEnv::GetFieldModifiers(fieldDescriptor* fdesc_ptr, jint* modifiers_ptr) { @@ -3351,7 +3351,7 @@ JvmtiEnv::GetFieldModifiers(fieldDescriptor* fdesc_ptr, jint* modifiers_ptr) { } /* end GetFieldModifiers */ -// is_synthetic_ptr - pre-checked for NULL +// is_synthetic_ptr - pre-checked for null jvmtiError JvmtiEnv::IsFieldSynthetic(fieldDescriptor* fdesc_ptr, jboolean* is_synthetic_ptr) { *is_synthetic_ptr = fdesc_ptr->is_synthetic(); @@ -3363,24 +3363,24 @@ JvmtiEnv::IsFieldSynthetic(fieldDescriptor* fdesc_ptr, jboolean* is_synthetic_pt // Method functions // -// method - pre-checked for validity, but may be NULL meaning obsolete method -// name_ptr - NULL is a valid value, must be checked -// signature_ptr - NULL is a valid value, must be checked -// generic_ptr - NULL is a valid value, must be checked +// method - pre-checked for validity, but may be null meaning obsolete method +// name_ptr - null is a valid value, must be checked +// signature_ptr - null is a valid value, must be checked +// generic_ptr - null is a valid value, must be checked jvmtiError JvmtiEnv::GetMethodName(Method* method, char** name_ptr, char** signature_ptr, char** generic_ptr) { NULL_CHECK(method, JVMTI_ERROR_INVALID_METHODID); JavaThread* current_thread = JavaThread::current(); ResourceMark rm(current_thread); // get the utf8 name and signature - if (name_ptr == NULL) { + if (name_ptr == nullptr) { // just don't return the name } else { const char* utf8_name = (const char *) method->name()->as_utf8(); *name_ptr = (char *) jvmtiMalloc(strlen(utf8_name)+1); strcpy(*name_ptr, utf8_name); } - if (signature_ptr == NULL) { + if (signature_ptr == nullptr) { // just don't return the signature } else { const char* utf8_signature = (const char *) method->signature()->as_utf8(); @@ -3388,12 +3388,12 @@ JvmtiEnv::GetMethodName(Method* method, char** name_ptr, char** signature_ptr, c strcpy(*signature_ptr, utf8_signature); } - if (generic_ptr != NULL) { - *generic_ptr = NULL; + if (generic_ptr != nullptr) { + *generic_ptr = nullptr; Symbol* soop = method->generic_signature(); - if (soop != NULL) { + if (soop != nullptr) { const char* gen_sig = soop->as_C_string(); - if (gen_sig != NULL) { + if (gen_sig != nullptr) { jvmtiError err = allocate(strlen(gen_sig) + 1, (unsigned char **)generic_ptr); if (err != JVMTI_ERROR_NONE) { return err; @@ -3406,8 +3406,8 @@ JvmtiEnv::GetMethodName(Method* method, char** name_ptr, char** signature_ptr, c } /* end GetMethodName */ -// method - pre-checked for validity, but may be NULL meaning obsolete method -// declaring_class_ptr - pre-checked for NULL +// method - pre-checked for validity, but may be null meaning obsolete method +// declaring_class_ptr - pre-checked for null jvmtiError JvmtiEnv::GetMethodDeclaringClass(Method* method, jclass* declaring_class_ptr) { NULL_CHECK(method, JVMTI_ERROR_INVALID_METHODID); @@ -3416,8 +3416,8 @@ JvmtiEnv::GetMethodDeclaringClass(Method* method, jclass* declaring_class_ptr) { } /* end GetMethodDeclaringClass */ -// method - pre-checked for validity, but may be NULL meaning obsolete method -// modifiers_ptr - pre-checked for NULL +// method - pre-checked for validity, but may be null meaning obsolete method +// modifiers_ptr - pre-checked for null jvmtiError JvmtiEnv::GetMethodModifiers(Method* method, jint* modifiers_ptr) { NULL_CHECK(method, JVMTI_ERROR_INVALID_METHODID); @@ -3426,8 +3426,8 @@ JvmtiEnv::GetMethodModifiers(Method* method, jint* modifiers_ptr) { } /* end GetMethodModifiers */ -// method - pre-checked for validity, but may be NULL meaning obsolete method -// max_ptr - pre-checked for NULL +// method - pre-checked for validity, but may be null meaning obsolete method +// max_ptr - pre-checked for null jvmtiError JvmtiEnv::GetMaxLocals(Method* method, jint* max_ptr) { NULL_CHECK(method, JVMTI_ERROR_INVALID_METHODID); @@ -3437,8 +3437,8 @@ JvmtiEnv::GetMaxLocals(Method* method, jint* max_ptr) { } /* end GetMaxLocals */ -// method - pre-checked for validity, but may be NULL meaning obsolete method -// size_ptr - pre-checked for NULL +// method - pre-checked for validity, but may be null meaning obsolete method +// size_ptr - pre-checked for null jvmtiError JvmtiEnv::GetArgumentsSize(Method* method, jint* size_ptr) { NULL_CHECK(method, JVMTI_ERROR_INVALID_METHODID); @@ -3449,9 +3449,9 @@ JvmtiEnv::GetArgumentsSize(Method* method, jint* size_ptr) { } /* end GetArgumentsSize */ -// method - pre-checked for validity, but may be NULL meaning obsolete method -// entry_count_ptr - pre-checked for NULL -// table_ptr - pre-checked for NULL +// method - pre-checked for validity, but may be null meaning obsolete method +// entry_count_ptr - pre-checked for null +// table_ptr - pre-checked for null jvmtiError JvmtiEnv::GetLineNumberTable(Method* method, jint* entry_count_ptr, jvmtiLineNumberEntry** table_ptr) { NULL_CHECK(method, JVMTI_ERROR_INVALID_METHODID); @@ -3491,9 +3491,9 @@ JvmtiEnv::GetLineNumberTable(Method* method, jint* entry_count_ptr, jvmtiLineNum } /* end GetLineNumberTable */ -// method - pre-checked for validity, but may be NULL meaning obsolete method -// start_location_ptr - pre-checked for NULL -// end_location_ptr - pre-checked for NULL +// method - pre-checked for validity, but may be null meaning obsolete method +// start_location_ptr - pre-checked for null +// end_location_ptr - pre-checked for null jvmtiError JvmtiEnv::GetMethodLocation(Method* method, jlocation* start_location_ptr, jlocation* end_location_ptr) { @@ -3511,9 +3511,9 @@ JvmtiEnv::GetMethodLocation(Method* method, jlocation* start_location_ptr, jloca } /* end GetMethodLocation */ -// method - pre-checked for validity, but may be NULL meaning obsolete method -// entry_count_ptr - pre-checked for NULL -// table_ptr - pre-checked for NULL +// method - pre-checked for validity, but may be null meaning obsolete method +// entry_count_ptr - pre-checked for null +// table_ptr - pre-checked for null jvmtiError JvmtiEnv::GetLocalVariableTable(Method* method, jint* entry_count_ptr, jvmtiLocalVariableEntry** table_ptr) { @@ -3548,9 +3548,9 @@ JvmtiEnv::GetLocalVariableTable(Method* method, jint* entry_count_ptr, jvmtiLoca jint slot = (jint) table[i].slot; // get utf8 name and signature - char *name_buf = NULL; - char *sig_buf = NULL; - char *gen_sig_buf = NULL; + char *name_buf = nullptr; + char *sig_buf = nullptr; + char *gen_sig_buf = nullptr; { ResourceMark rm(current_thread); @@ -3588,9 +3588,9 @@ JvmtiEnv::GetLocalVariableTable(Method* method, jint* entry_count_ptr, jvmtiLoca } /* end GetLocalVariableTable */ -// method - pre-checked for validity, but may be NULL meaning obsolete method -// bytecode_count_ptr - pre-checked for NULL -// bytecodes_ptr - pre-checked for NULL +// method - pre-checked for validity, but may be null meaning obsolete method +// bytecode_count_ptr - pre-checked for null +// bytecodes_ptr - pre-checked for null jvmtiError JvmtiEnv::GetBytecodes(Method* method, jint* bytecode_count_ptr, unsigned char** bytecodes_ptr) { NULL_CHECK(method, JVMTI_ERROR_INVALID_METHODID); @@ -3610,8 +3610,8 @@ JvmtiEnv::GetBytecodes(Method* method, jint* bytecode_count_ptr, unsigned char** } /* end GetBytecodes */ -// method - pre-checked for validity, but may be NULL meaning obsolete method -// is_native_ptr - pre-checked for NULL +// method - pre-checked for validity, but may be null meaning obsolete method +// is_native_ptr - pre-checked for null jvmtiError JvmtiEnv::IsMethodNative(Method* method, jboolean* is_native_ptr) { NULL_CHECK(method, JVMTI_ERROR_INVALID_METHODID); @@ -3620,8 +3620,8 @@ JvmtiEnv::IsMethodNative(Method* method, jboolean* is_native_ptr) { } /* end IsMethodNative */ -// method - pre-checked for validity, but may be NULL meaning obsolete method -// is_synthetic_ptr - pre-checked for NULL +// method - pre-checked for validity, but may be null meaning obsolete method +// is_synthetic_ptr - pre-checked for null jvmtiError JvmtiEnv::IsMethodSynthetic(Method* method, jboolean* is_synthetic_ptr) { NULL_CHECK(method, JVMTI_ERROR_INVALID_METHODID); @@ -3630,8 +3630,8 @@ JvmtiEnv::IsMethodSynthetic(Method* method, jboolean* is_synthetic_ptr) { } /* end IsMethodSynthetic */ -// method - pre-checked for validity, but may be NULL meaning obsolete method -// is_obsolete_ptr - pre-checked for NULL +// method - pre-checked for validity, but may be null meaning obsolete method +// is_obsolete_ptr - pre-checked for null jvmtiError JvmtiEnv::IsMethodObsolete(Method* method, jboolean* is_obsolete_ptr) { if (use_version_1_0_semantics() && @@ -3642,7 +3642,7 @@ JvmtiEnv::IsMethodObsolete(Method* method, jboolean* is_obsolete_ptr) { return JVMTI_ERROR_MUST_POSSESS_CAPABILITY; } - if (method == NULL || method->is_obsolete()) { + if (method == nullptr || method->is_obsolete()) { *is_obsolete_ptr = true; } else { *is_obsolete_ptr = false; @@ -3654,8 +3654,8 @@ JvmtiEnv::IsMethodObsolete(Method* method, jboolean* is_obsolete_ptr) { // Raw Monitor functions // -// name - pre-checked for NULL -// monitor_ptr - pre-checked for NULL +// name - pre-checked for null +// monitor_ptr - pre-checked for null jvmtiError JvmtiEnv::CreateRawMonitor(const char* name, jrawMonitorID* monitor_ptr) { JvmtiRawMonitor* rmonitor = new JvmtiRawMonitor(name); @@ -3692,7 +3692,7 @@ JvmtiEnv::DestroyRawMonitor(JvmtiRawMonitor * rmonitor) { } } } - if (rmonitor->owner() != NULL) { + if (rmonitor->owner() != nullptr) { // The caller is trying to destroy a monitor that is locked by // someone else. While this is not forbidden by the JVMTI // spec, it will cause an assertion failure on systems that don't @@ -3802,7 +3802,7 @@ JvmtiEnv::RawMonitorNotifyAll(JvmtiRawMonitor * rmonitor) { // -// function_table - pre-checked for NULL +// function_table - pre-checked for null jvmtiError JvmtiEnv::SetJNIFunctionTable(const jniNativeInterface* function_table) { // Copy jni function table at safepoint. @@ -3813,11 +3813,11 @@ JvmtiEnv::SetJNIFunctionTable(const jniNativeInterface* function_table) { } /* end SetJNIFunctionTable */ -// function_table - pre-checked for NULL +// function_table - pre-checked for null jvmtiError JvmtiEnv::GetJNIFunctionTable(jniNativeInterface** function_table) { *function_table=(jniNativeInterface*)jvmtiMalloc(sizeof(jniNativeInterface)); - if (*function_table == NULL) + if (*function_table == nullptr) return JVMTI_ERROR_OUT_OF_MEMORY; memcpy(*function_table,(JavaThread::current())->get_jni_functions(),sizeof(jniNativeInterface)); return JVMTI_ERROR_NONE; @@ -3854,23 +3854,23 @@ JvmtiEnv::GenerateEvents(jvmtiEvent event_type) { // Extension Mechanism functions // -// extension_count_ptr - pre-checked for NULL -// extensions - pre-checked for NULL +// extension_count_ptr - pre-checked for null +// extensions - pre-checked for null jvmtiError JvmtiEnv::GetExtensionFunctions(jint* extension_count_ptr, jvmtiExtensionFunctionInfo** extensions) { return JvmtiExtensions::get_functions(this, extension_count_ptr, extensions); } /* end GetExtensionFunctions */ -// extension_count_ptr - pre-checked for NULL -// extensions - pre-checked for NULL +// extension_count_ptr - pre-checked for null +// extensions - pre-checked for null jvmtiError JvmtiEnv::GetExtensionEvents(jint* extension_count_ptr, jvmtiExtensionEventInfo** extensions) { return JvmtiExtensions::get_events(this, extension_count_ptr, extensions); } /* end GetExtensionEvents */ -// callback - NULL is a valid value, must be checked +// callback - null is a valid value, must be checked jvmtiError JvmtiEnv::SetExtensionEventCallback(jint extension_event_index, jvmtiExtensionEvent callback) { return JvmtiExtensions::set_event_callback(this, extension_event_index, callback); @@ -3880,7 +3880,7 @@ JvmtiEnv::SetExtensionEventCallback(jint extension_event_index, jvmtiExtensionEv // Timers functions // -// info_ptr - pre-checked for NULL +// info_ptr - pre-checked for null jvmtiError JvmtiEnv::GetCurrentThreadCpuTimerInfo(jvmtiTimerInfo* info_ptr) { os::current_thread_cpu_time_info(info_ptr); @@ -3888,7 +3888,7 @@ JvmtiEnv::GetCurrentThreadCpuTimerInfo(jvmtiTimerInfo* info_ptr) { } /* end GetCurrentThreadCpuTimerInfo */ -// nanos_ptr - pre-checked for NULL +// nanos_ptr - pre-checked for null jvmtiError JvmtiEnv::GetCurrentThreadCpuTime(jlong* nanos_ptr) { Thread* thread = Thread::current(); @@ -3905,7 +3905,7 @@ JvmtiEnv::GetCurrentThreadCpuTime(jlong* nanos_ptr) { } /* end GetCurrentThreadCpuTime */ -// info_ptr - pre-checked for NULL +// info_ptr - pre-checked for null jvmtiError JvmtiEnv::GetThreadCpuTimerInfo(jvmtiTimerInfo* info_ptr) { os::thread_cpu_time_info(info_ptr); @@ -3913,17 +3913,17 @@ JvmtiEnv::GetThreadCpuTimerInfo(jvmtiTimerInfo* info_ptr) { } /* end GetThreadCpuTimerInfo */ -// nanos_ptr - pre-checked for NULL +// nanos_ptr - pre-checked for null jvmtiError JvmtiEnv::GetThreadCpuTime(jthread thread, jlong* nanos_ptr) { JavaThread* current_thread = JavaThread::current(); ThreadsListHandle tlh(current_thread); - JavaThread* java_thread = NULL; - oop thread_oop = NULL; + JavaThread* java_thread = nullptr; + oop thread_oop = nullptr; jvmtiError err = get_threadOop_and_JavaThread(tlh.list(), thread, &java_thread, &thread_oop); - if (thread_oop != NULL && java_lang_VirtualThread::is_instance(thread_oop)) { + if (thread_oop != nullptr && java_lang_VirtualThread::is_instance(thread_oop)) { // No support for virtual threads (yet). return JVMTI_ERROR_UNSUPPORTED_OPERATION; } @@ -3937,7 +3937,7 @@ JvmtiEnv::GetThreadCpuTime(jthread thread, jlong* nanos_ptr) { } /* end GetThreadCpuTime */ -// info_ptr - pre-checked for NULL +// info_ptr - pre-checked for null jvmtiError JvmtiEnv::GetTimerInfo(jvmtiTimerInfo* info_ptr) { os::javaTimeNanos_info(info_ptr); @@ -3945,7 +3945,7 @@ JvmtiEnv::GetTimerInfo(jvmtiTimerInfo* info_ptr) { } /* end GetTimerInfo */ -// nanos_ptr - pre-checked for NULL +// nanos_ptr - pre-checked for null jvmtiError JvmtiEnv::GetTime(jlong* nanos_ptr) { *nanos_ptr = os::javaTimeNanos(); @@ -3953,7 +3953,7 @@ JvmtiEnv::GetTime(jlong* nanos_ptr) { } /* end GetTime */ -// processor_count_ptr - pre-checked for NULL +// processor_count_ptr - pre-checked for null jvmtiError JvmtiEnv::GetAvailableProcessors(jint* processor_count_ptr) { *processor_count_ptr = os::active_processor_count(); @@ -3973,8 +3973,8 @@ JvmtiEnv::SetHeapSamplingInterval(jint sampling_interval) { // System Properties functions // -// count_ptr - pre-checked for NULL -// property_ptr - pre-checked for NULL +// count_ptr - pre-checked for null +// property_ptr - pre-checked for null jvmtiError JvmtiEnv::GetSystemProperties(jint* count_ptr, char*** property_ptr) { jvmtiError err = JVMTI_ERROR_NONE; @@ -3989,7 +3989,7 @@ JvmtiEnv::GetSystemProperties(jint* count_ptr, char*** property_ptr) { } int readable_count = 0; // Loop through the system properties until all the readable properties are found. - for (SystemProperty* p = Arguments::system_properties(); p != NULL && readable_count < *count_ptr; p = p->next()) { + for (SystemProperty* p = Arguments::system_properties(); p != nullptr && readable_count < *count_ptr; p = p->next()) { if (p->readable()) { const char *key = p->key(); char **tmp_value = *property_ptr+readable_count; @@ -4012,8 +4012,8 @@ JvmtiEnv::GetSystemProperties(jint* count_ptr, char*** property_ptr) { } /* end GetSystemProperties */ -// property - pre-checked for NULL -// value_ptr - pre-checked for NULL +// property - pre-checked for null +// value_ptr - pre-checked for null jvmtiError JvmtiEnv::GetSystemProperty(const char* property, char** value_ptr) { jvmtiError err = JVMTI_ERROR_NONE; @@ -4021,7 +4021,7 @@ JvmtiEnv::GetSystemProperty(const char* property, char** value_ptr) { // Return JVMTI_ERROR_NOT_AVAILABLE if property is not readable or doesn't exist. value = Arguments::PropertyList_get_readable_value(Arguments::system_properties(), property); - if (value == NULL) { + if (value == nullptr) { err = JVMTI_ERROR_NOT_AVAILABLE; } else { err = allocate((strlen(value)+1) * sizeof(char), (unsigned char **)value_ptr); @@ -4033,11 +4033,11 @@ JvmtiEnv::GetSystemProperty(const char* property, char** value_ptr) { } /* end GetSystemProperty */ -// property - pre-checked for NULL -// value - NULL is a valid value, must be checked +// property - pre-checked for null +// value - null is a valid value, must be checked jvmtiError JvmtiEnv::SetSystemProperty(const char* property, const char* value_ptr) { - for (SystemProperty* p = Arguments::system_properties(); p != NULL; p = p->next()) { + for (SystemProperty* p = Arguments::system_properties(); p != nullptr; p = p->next()) { if (strcmp(property, p->key()) == 0) { if (p->writeable()) { if (p->set_value(value_ptr, AllocFailStrategy::RETURN_NULL)) { diff --git a/src/hotspot/share/prims/jvmtiEnvBase.cpp b/src/hotspot/share/prims/jvmtiEnvBase.cpp index 8f78f0727fee1..37541bcfcff47 100644 --- a/src/hotspot/share/prims/jvmtiEnvBase.cpp +++ b/src/hotspot/share/prims/jvmtiEnvBase.cpp @@ -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 @@ -69,7 +69,7 @@ // JvmtiEnvBase // -JvmtiEnvBase* JvmtiEnvBase::_head_environment = NULL; +JvmtiEnvBase* JvmtiEnvBase::_head_environment = nullptr; bool JvmtiEnvBase::_globally_initialized = false; volatile bool JvmtiEnvBase::_needs_clean_up = false; @@ -114,11 +114,11 @@ JvmtiEnvBase::initialize() { // addition. Note: NoSafepointVerifier cannot, currently, be used before // threads exist. JvmtiEnvIterator it; - JvmtiEnvBase *previous_env = NULL; - for (JvmtiEnvBase* env = it.first(); env != NULL; env = it.next(env)) { + JvmtiEnvBase *previous_env = nullptr; + for (JvmtiEnvBase* env = it.first(); env != nullptr; env = it.next(env)) { previous_env = env; } - if (previous_env == NULL) { + if (previous_env == nullptr) { _head_environment = this; } else { previous_env->set_next_environment(this); @@ -199,11 +199,11 @@ JvmtiEnvBase::use_version_1_2_semantics() { JvmtiEnvBase::JvmtiEnvBase(jint version) : _env_event_enable() { _version = version; - _env_local_storage = NULL; - _tag_map = NULL; + _env_local_storage = nullptr; + _tag_map = nullptr; _native_method_prefix_count = 0; - _native_method_prefixes = NULL; - _next = NULL; + _native_method_prefixes = nullptr; + _next = nullptr; _class_file_load_hook_ever_enabled = false; // Moot since ClassFileLoadHook not yet enabled. @@ -211,7 +211,7 @@ JvmtiEnvBase::JvmtiEnvBase(jint version) : _env_event_enable() { // for environment creation during ClassFileLoadHook. _is_retransformable = true; - // all callbacks initially NULL + // all callbacks initially null memset(&_event_callbacks,0,sizeof(jvmtiEventCallbacks)); // all capabilities initially off @@ -225,7 +225,7 @@ JvmtiEnvBase::JvmtiEnvBase(jint version) : _env_event_enable() { JvmtiEventController::env_initialize((JvmtiEnv*)this); #ifdef JVMTI_TRACE - _jvmti_external.functions = TraceJVMTI != NULL ? &jvmtiTrace_Interface : &jvmti_Interface; + _jvmti_external.functions = TraceJVMTI != nullptr ? &jvmtiTrace_Interface : &jvmti_Interface; #else _jvmti_external.functions = &jvmti_Interface; #endif @@ -261,12 +261,12 @@ JvmtiEnvBase::env_dispose() { JvmtiManageCapabilities::relinquish_capabilities(caps, caps, caps); // Same situation as with events (see above) - set_native_method_prefixes(0, NULL); + set_native_method_prefixes(0, nullptr); JvmtiTagMap* tag_map_to_clear = tag_map_acquire(); // A tag map can be big, clear it now to save memory until // the destructor runs. - if (tag_map_to_clear != NULL) { + if (tag_map_to_clear != nullptr) { tag_map_to_clear->clear(); } @@ -281,9 +281,9 @@ JvmtiEnvBase::~JvmtiEnvBase() { // disposed environment could have been reallocated. // Make sure it is gone. JvmtiTagMap* tag_map_to_deallocate = _tag_map; - set_tag_map(NULL); + set_tag_map(nullptr); // A tag map can be big, deallocate it now - if (tag_map_to_deallocate != NULL) { + if (tag_map_to_deallocate != nullptr) { delete tag_map_to_deallocate; } @@ -302,9 +302,9 @@ JvmtiEnvBase::periodic_clean_up() { // Unlink all invalid environments from the list of environments // and deallocate them JvmtiEnvIterator it; - JvmtiEnvBase* previous_env = NULL; + JvmtiEnvBase* previous_env = nullptr; JvmtiEnvBase* env = it.first(); - while (env != NULL) { + while (env != nullptr) { if (env->is_valid()) { previous_env = env; env = it.next(env); @@ -312,7 +312,7 @@ JvmtiEnvBase::periodic_clean_up() { // This one isn't valid, remove it from the list and deallocate it JvmtiEnvBase* defunct_env = env; env = it.next(env); - if (previous_env == NULL) { + if (previous_env == nullptr) { _head_environment = env; } else { previous_env->set_next_environment(env); @@ -401,16 +401,16 @@ JvmtiEnvBase::set_native_method_prefixes(jint prefix_count, char** prefixes) { // allocate and install the new prefixex if (prefix_count == 0 || !is_valid()) { _native_method_prefix_count = 0; - _native_method_prefixes = NULL; + _native_method_prefixes = nullptr; } else { // there are prefixes, allocate an array to hold them, and fill it char** new_prefixes = (char**)os::malloc((prefix_count) * sizeof(char*), mtInternal); - if (new_prefixes == NULL) { + if (new_prefixes == nullptr) { return JVMTI_ERROR_OUT_OF_MEMORY; } for (int i = 0; i < prefix_count; i++) { char* prefix = prefixes[i]; - if (prefix == NULL) { + if (prefix == nullptr) { for (int j = 0; j < (i-1); j++) { os::free(new_prefixes[j]); } @@ -418,7 +418,7 @@ JvmtiEnvBase::set_native_method_prefixes(jint prefix_count, char** prefixes) { return JVMTI_ERROR_NULL_POINTER; } prefix = os::strdup(prefixes[i]); - if (prefix == NULL) { + if (prefix == nullptr) { for (int j = 0; j < (i-1); j++) { os::free(new_prefixes[j]); } @@ -459,7 +459,7 @@ JvmtiEnvBase::get_all_native_method_prefixes(int* count_ptr) { GrowableArray* prefix_array =new GrowableArray(5); JvmtiEnvIterator it; - for (JvmtiEnvBase* env = it.first(); env != NULL; env = it.next(env)) { + for (JvmtiEnvBase* env = it.first(); env != nullptr; env = it.next(env)) { int prefix_count = env->get_native_method_prefix_count(); char** prefixes = env->get_native_method_prefixes(); for (int j = 0; j < prefix_count; j++) { @@ -494,7 +494,7 @@ JvmtiEnvBase::set_event_callbacks(const jvmtiEventCallbacks* callbacks, // Now that JvmtiThreadState_lock is held, prevent a possible race condition where events // are re-enabled by a call to set event callbacks where the DisposeEnvironment // occurs after the boiler-plate environment check and before the lock is acquired. - if (callbacks != NULL && is_valid()) { + if (callbacks != nullptr && is_valid()) { if (size_of_callbacks < (jint)byte_cnt) { byte_cnt = size_of_callbacks; } @@ -508,7 +508,7 @@ JvmtiEnvBase::set_event_callbacks(const jvmtiEventCallbacks* callbacks, // mean much better out of memory handling unsigned char * JvmtiEnvBase::jvmtiMalloc(jlong size) { - unsigned char* mem = NULL; + unsigned char* mem = nullptr; jvmtiError result = allocate(size, &mem); assert(result == JVMTI_ERROR_NONE, "Allocate failed"); return mem; @@ -540,11 +540,11 @@ void JvmtiEnvBase::destroy_jni_reference(JavaThread *thread, jobject jobj) { jthread * JvmtiEnvBase::new_jthreadArray(int length, Handle *handles) { if (length == 0) { - return NULL; + return nullptr; } jthread* objArray = (jthread *) jvmtiMalloc(sizeof(jthread) * length); - NULL_CHECK(objArray, NULL); + NULL_CHECK(objArray, nullptr); for (int i = 0; i < length; i++) { objArray[i] = (jthread)jni_reference(handles[i]); @@ -555,11 +555,11 @@ JvmtiEnvBase::new_jthreadArray(int length, Handle *handles) { jthreadGroup * JvmtiEnvBase::new_jthreadGroupArray(int length, objArrayHandle groups) { if (length == 0) { - return NULL; + return nullptr; } jthreadGroup* objArray = (jthreadGroup *) jvmtiMalloc(sizeof(jthreadGroup) * length); - NULL_CHECK(objArray, NULL); + NULL_CHECK(objArray, nullptr); for (int i = 0; i < length; i++) { objArray[i] = (jthreadGroup)JNIHandles::make_local(groups->obj_at(i)); @@ -567,12 +567,12 @@ JvmtiEnvBase::new_jthreadGroupArray(int length, objArrayHandle groups) { return objArray; } -// Return the vframe on the specified thread and depth, NULL if no such frame. +// Return the vframe on the specified thread and depth, null if no such frame. // The thread and the oops in the returned vframe might not have been processed. javaVFrame* JvmtiEnvBase::jvf_for_thread_and_depth(JavaThread* java_thread, jint depth) { if (!java_thread->has_last_Java_frame()) { - return NULL; + return nullptr; } RegisterMap reg_map(java_thread, RegisterMap::UpdateMap::include, @@ -582,7 +582,7 @@ JvmtiEnvBase::jvf_for_thread_and_depth(JavaThread* java_thread, jint depth) { jvf = JvmtiEnvBase::check_and_skip_hidden_frames(java_thread, jvf); - for (int d = 0; jvf != NULL && d < depth; d++) { + for (int d = 0; jvf != nullptr && d < depth; d++) { jvf = jvf->java_sender(); } return jvf; @@ -595,7 +595,7 @@ JvmtiEnvBase::jvf_for_thread_and_depth(JavaThread* java_thread, jint depth) { jclass JvmtiEnvBase::get_jni_class_non_null(Klass* k) { - assert(k != NULL, "k != NULL"); + assert(k != nullptr, "k != null"); Thread *thread = Thread::current(); return (jclass)jni_reference(Handle(thread, k->java_mirror())); } @@ -627,11 +627,11 @@ JvmtiEnvBase::is_vthread_alive(oop vt) { java_lang_VirtualThread::state(vt) != java_lang_VirtualThread::TERMINATED; } -// Return JavaThread if virtual thread is mounted, NULL otherwise. +// Return JavaThread if virtual thread is mounted, null otherwise. JavaThread* JvmtiEnvBase::get_JavaThread_or_null(oop vthread) { oop carrier_thread = java_lang_VirtualThread::carrier_thread(vthread); - if (carrier_thread == NULL) { - return NULL; + if (carrier_thread == nullptr) { + return nullptr; } JavaThread* java_thread = java_lang_Thread::thread(carrier_thread); @@ -642,19 +642,19 @@ JavaThread* JvmtiEnvBase::get_JavaThread_or_null(oop vthread) { StackWatermarkSet::start_processing(java_thread, StackWatermarkKind::gc); oop cont = java_lang_VirtualThread::continuation(vthread); - assert(cont != NULL, "must be"); + assert(cont != nullptr, "must be"); assert(Continuation::continuation_scope(cont) == java_lang_VirtualThread::vthread_scope(), "must be"); - return Continuation::is_continuation_mounted(java_thread, cont) ? java_thread : NULL; + return Continuation::is_continuation_mounted(java_thread, cont) ? java_thread : nullptr; } javaVFrame* JvmtiEnvBase::check_and_skip_hidden_frames(bool is_in_VTMS_transition, javaVFrame* jvf) { // The second condition is needed to hide notification methods. - if (!is_in_VTMS_transition && (jvf == NULL || !jvf->method()->jvmti_mount_transition())) { + if (!is_in_VTMS_transition && (jvf == nullptr || !jvf->method()->jvmti_mount_transition())) { return jvf; // No frames to skip. } // Find jvf with a method annotated with @JvmtiMountTransition. - for ( ; jvf != NULL; jvf = jvf->java_sender()) { + for ( ; jvf != nullptr; jvf = jvf->java_sender()) { if (jvf->method()->jvmti_mount_transition()) { // Cannot actually appear in an unmounted continuation; they're never frozen. jvf = jvf->java_sender(); // Skip annotated method. break; @@ -676,7 +676,7 @@ JvmtiEnvBase::check_and_skip_hidden_frames(JavaThread* jt, javaVFrame* jvf) { javaVFrame* JvmtiEnvBase::check_and_skip_hidden_frames(oop vthread, javaVFrame* jvf) { JvmtiThreadState* state = java_lang_Thread::jvmti_thread_state(vthread); - if (state == NULL) { + if (state == nullptr) { // nothing to skip return jvf; } @@ -691,22 +691,22 @@ JvmtiEnvBase::get_vthread_jvf(oop vthread) { Thread* cur_thread = Thread::current(); oop cont = java_lang_VirtualThread::continuation(vthread); - javaVFrame* jvf = NULL; + javaVFrame* jvf = nullptr; JavaThread* java_thread = get_JavaThread_or_null(vthread); - if (java_thread != NULL) { + if (java_thread != nullptr) { if (!java_thread->has_last_Java_frame()) { // TBD: This is a temporary work around to avoid a guarantee caused by // the native enterSpecial frame on the top. No frames will be found // by the JVMTI functions such as GetStackTrace. - return NULL; + return nullptr; } vframeStream vfs(java_thread); - jvf = vfs.at_end() ? NULL : vfs.asJavaVFrame(); + jvf = vfs.at_end() ? nullptr : vfs.asJavaVFrame(); jvf = check_and_skip_hidden_frames(java_thread, jvf); } else { vframeStream vfs(cont); - jvf = vfs.at_end() ? NULL : vfs.asJavaVFrame(); + jvf = vfs.at_end() ? nullptr : vfs.asJavaVFrame(); jvf = check_and_skip_hidden_frames(vthread, jvf); } return jvf; @@ -732,16 +732,16 @@ jint JvmtiEnvBase::get_thread_state(oop thread_oop, JavaThread* jt) { jint state = 0; - if (thread_oop != NULL) { + if (thread_oop != nullptr) { // Get most state bits. state = (jint)java_lang_Thread::get_thread_status(thread_oop); } - if (jt != NULL) { + if (jt != nullptr) { // We have a JavaThread* so add more state bits. JavaThreadState jts = jt->thread_state(); if (jt->is_carrier_thread_suspended() || - ((jt->jvmti_vthread() == NULL || jt->jvmti_vthread() == thread_oop) && jt->is_suspended())) { + ((jt->jvmti_vthread() == nullptr || jt->jvmti_vthread() == thread_oop) && jt->is_suspended())) { // Suspended non-virtual thread. state |= JVMTI_THREAD_STATE_SUSPENDED; } @@ -761,7 +761,7 @@ JvmtiEnvBase::get_vthread_state(oop thread_oop, JavaThread* java_thread) { bool ext_suspended = JvmtiVTSuspender::is_vthread_suspended(thread_oop); jint interrupted = java_lang_Thread::interrupted(thread_oop); - if (java_thread != NULL) { + if (java_thread != nullptr) { // If virtual thread is blocked on a monitor enter the BLOCKED_ON_MONITOR_ENTER bit // is set for carrier thread instead of virtual. // Other state bits except filtered ones are expected to be the same. @@ -787,7 +787,7 @@ JvmtiEnvBase::get_vthread_state(oop thread_oop, JavaThread* java_thread) { jvmtiError JvmtiEnvBase::get_live_threads(JavaThread* current_thread, Handle group_hdl, jint *count_ptr, Handle **thread_objs_p) { jint count = 0; - Handle *thread_objs = NULL; + Handle *thread_objs = nullptr; ThreadsListEnumerator tle(current_thread, /* include_jvmti_agent_threads */ true); int nthreads = tle.num_threads(); if (nthreads > 0) { @@ -861,7 +861,7 @@ JvmtiEnvBase::count_locked_objects(JavaThread *java_thread, Handle hobj) { RegisterMap::ProcessFrames::include, RegisterMap::WalkContinuation::skip); - for (javaVFrame *jvf = java_thread->last_java_vframe(®_map); jvf != NULL; + for (javaVFrame *jvf = java_thread->last_java_vframe(®_map); jvf != nullptr; jvf = jvf->java_sender()) { GrowableArray* mons = jvf->monitors(); if (!mons->is_empty()) { @@ -870,7 +870,7 @@ JvmtiEnvBase::count_locked_objects(JavaThread *java_thread, Handle hobj) { if (mi->owner_is_scalar_replaced()) continue; // see if owner of the monitor is our object - if (mi->owner() != NULL && mi->owner() == hobj()) { + if (mi->owner() != nullptr && mi->owner() == hobj()) { ret++; } } @@ -891,28 +891,28 @@ JvmtiEnvBase::get_current_contended_monitor(JavaThread *calling_thread, JavaThre *monitor_ptr = nullptr; return JVMTI_ERROR_NONE; } - oop obj = NULL; + oop obj = nullptr; // The ObjectMonitor* can't be async deflated since we are either // at a safepoint or the calling thread is operating on itself so // it cannot leave the underlying wait()/enter() call. ObjectMonitor *mon = java_thread->current_waiting_monitor(); - if (mon == NULL) { + if (mon == nullptr) { // thread is not doing an Object.wait() call mon = java_thread->current_pending_monitor(); - if (mon != NULL) { + if (mon != nullptr) { // The thread is trying to enter() an ObjectMonitor. obj = mon->object(); - assert(obj != NULL, "ObjectMonitor should have a valid object!"); + assert(obj != nullptr, "ObjectMonitor should have a valid object!"); } // implied else: no contended ObjectMonitor } else { // thread is doing an Object.wait() call obj = mon->object(); - assert(obj != NULL, "Object.wait() should have an object"); + assert(obj != nullptr, "Object.wait() should have an object"); } - if (obj == NULL) { - *monitor_ptr = NULL; + if (obj == nullptr) { + *monitor_ptr = nullptr; } else { HandleMark hm(current_thread); Handle hobj(current_thread, obj); @@ -949,7 +949,7 @@ JvmtiEnvBase::get_owned_monitors(JavaThread *calling_thread, JavaThread* java_th int depth = 0; for (javaVFrame *jvf = get_cthread_last_java_vframe(java_thread, ®_map); - jvf != NULL; jvf = jvf->java_sender()) { + jvf != nullptr; jvf = jvf->java_sender()) { if (MaxJavaStackTraceDepth == 0 || depth++ < MaxJavaStackTraceDepth) { // check for stack too deep // add locked objects for this frame into list err = get_locked_objects_in_frame(calling_thread, java_thread, jvf, owned_monitors_list, depth-1); @@ -977,7 +977,7 @@ JvmtiEnvBase::get_owned_monitors(JavaThread* calling_thread, JavaThread* java_th "call by myself or at handshake"); int depth = 0; - for ( ; jvf != NULL; jvf = jvf->java_sender()) { + for ( ; jvf != nullptr; jvf = jvf->java_sender()) { if (MaxJavaStackTraceDepth == 0 || depth++ < MaxJavaStackTraceDepth) { // check for stack too deep // Add locked objects for this frame into list. err = get_locked_objects_in_frame(calling_thread, java_thread, jvf, owned_monitors_list, depth - 1); @@ -1009,25 +1009,25 @@ JvmtiEnvBase::get_locked_objects_in_frame(JavaThread* calling_thread, JavaThread return err; // this javaVFrame holds no monitors } - oop wait_obj = NULL; + oop wait_obj = nullptr; { // The ObjectMonitor* can't be async deflated since we are either // at a safepoint or the calling thread is operating on itself so // it cannot leave the underlying wait() call. // Save object of current wait() call (if any) for later comparison. ObjectMonitor *mon = java_thread->current_waiting_monitor(); - if (mon != NULL) { + if (mon != nullptr) { wait_obj = mon->object(); } } - oop pending_obj = NULL; + oop pending_obj = nullptr; { // The ObjectMonitor* can't be async deflated since we are either // at a safepoint or the calling thread is operating on itself so // it cannot leave the underlying enter() call. // Save object of current enter() call (if any) for later comparison. ObjectMonitor *mon = java_thread->current_pending_monitor(); - if (mon != NULL) { + if (mon != nullptr) { pending_obj = mon->object(); } } @@ -1038,7 +1038,7 @@ JvmtiEnvBase::get_locked_objects_in_frame(JavaThread* calling_thread, JavaThread if (mi->owner_is_scalar_replaced()) continue; oop obj = mi->owner(); - if (obj == NULL) { + if (obj == nullptr) { // this monitor doesn't have an owning object so skip it continue; } @@ -1098,10 +1098,10 @@ JvmtiEnvBase::get_stack_trace(javaVFrame *jvf, if (start_depth != 0) { if (start_depth > 0) { - for (int j = 0; j < start_depth && jvf != NULL; j++) { + for (int j = 0; j < start_depth && jvf != nullptr; j++) { jvf = jvf->java_sender(); } - if (jvf == NULL) { + if (jvf == nullptr) { // start_depth is deeper than the stack depth. return JVMTI_ERROR_ILLEGAL_ARGUMENT; } @@ -1110,13 +1110,13 @@ JvmtiEnvBase::get_stack_trace(javaVFrame *jvf, // part of the stack. // Optimize to limit the number of times that java_sender() is called. javaVFrame *jvf_cursor = jvf; - javaVFrame *jvf_prev = NULL; - javaVFrame *jvf_prev_prev = NULL; + javaVFrame *jvf_prev = nullptr; + javaVFrame *jvf_prev_prev = nullptr; int j = 0; - while (jvf_cursor != NULL) { + while (jvf_cursor != nullptr) { jvf_prev_prev = jvf_prev; jvf_prev = jvf_cursor; - for (j = 0; j > start_depth && jvf_cursor != NULL; j--) { + for (j = 0; j > start_depth && jvf_cursor != nullptr; j--) { jvf_cursor = jvf_cursor->java_sender(); } } @@ -1125,7 +1125,7 @@ JvmtiEnvBase::get_stack_trace(javaVFrame *jvf, jvf = jvf_prev; } else { // We need to back up further to get to the right place. - if (jvf_prev_prev == NULL) { + if (jvf_prev_prev == nullptr) { // The -start_depth is greater than the stack depth. return JVMTI_ERROR_ILLEGAL_ARGUMENT; } @@ -1140,7 +1140,7 @@ JvmtiEnvBase::get_stack_trace(javaVFrame *jvf, } } } - for (; count < max_count && jvf != NULL; count++) { + for (; count < max_count && jvf != nullptr; count++) { frame_buffer[count].method = jvf->method()->jmethod_id(); frame_buffer[count].location = (jvf->method()->is_native() ? -1 : jvf->bci()); jvf = jvf->java_sender(); @@ -1183,7 +1183,7 @@ jint JvmtiEnvBase::get_frame_count(javaVFrame *jvf) { int count = 0; - while (jvf != NULL) { + while (jvf != nullptr) { jvf = jvf->java_sender(); count++; } @@ -1231,12 +1231,12 @@ JvmtiEnvBase::get_frame_location(javaVFrame* jvf, jint depth, jmethodID* method_ptr, jlocation* location_ptr) { int cur_depth = 0; - while (jvf != NULL && cur_depth < depth) { + while (jvf != nullptr && cur_depth < depth) { jvf = jvf->java_sender(); cur_depth++; } assert(depth >= cur_depth, "ran out of frames too soon"); - if (jvf == NULL) { + if (jvf == nullptr) { return JVMTI_ERROR_NO_MORE_FRAMES; } Method* method = jvf->method(); @@ -1285,16 +1285,16 @@ JvmtiEnvBase::get_frame_location(oop vthread_oop, jint depth, jvmtiError JvmtiEnvBase::set_frame_pop(JvmtiThreadState* state, javaVFrame* jvf, jint depth) { - for (int d = 0; jvf != NULL && d < depth; d++) { + for (int d = 0; jvf != nullptr && d < depth; d++) { jvf = jvf->java_sender(); } - if (jvf == NULL) { + if (jvf == nullptr) { return JVMTI_ERROR_NO_MORE_FRAMES; } if (jvf->method()->is_native()) { return JVMTI_ERROR_OPAQUE_FRAME; } - assert(jvf->frame_pointer() != NULL, "frame pointer mustn't be NULL"); + assert(jvf->frame_pointer() != nullptr, "frame pointer mustn't be null"); int frame_number = (int)get_frame_count(jvf); state->env_thread_state((JvmtiEnvBase*)this)->set_frame_pop(frame_number); return JVMTI_ERROR_NONE; @@ -1303,27 +1303,27 @@ JvmtiEnvBase::set_frame_pop(JvmtiThreadState* state, javaVFrame* jvf, jint depth bool JvmtiEnvBase::is_cthread_with_mounted_vthread(JavaThread* jt) { oop thread_oop = jt->threadObj(); - assert(thread_oop != NULL, "sanity check"); + assert(thread_oop != nullptr, "sanity check"); oop mounted_vt = jt->jvmti_vthread(); - return mounted_vt != NULL && mounted_vt != thread_oop; + return mounted_vt != nullptr && mounted_vt != thread_oop; } bool JvmtiEnvBase::is_cthread_with_continuation(JavaThread* jt) { - const ContinuationEntry* cont_entry = NULL; + const ContinuationEntry* cont_entry = nullptr; if (jt->has_last_Java_frame()) { cont_entry = jt->vthread_continuation(); } - return cont_entry != NULL && is_cthread_with_mounted_vthread(jt); + return cont_entry != nullptr && is_cthread_with_mounted_vthread(jt); } -// If (thread == NULL) then return current thread object. +// If (thread == null) then return current thread object. // Otherwise return JNIHandles::resolve_external_guard(thread). oop JvmtiEnvBase::current_thread_obj_or_resolve_external_guard(jthread thread) { oop thread_obj = JNIHandles::resolve_external_guard(thread); - if (thread == NULL) { + if (thread == nullptr) { thread_obj = get_vthread_or_thread_oop(JavaThread::current()); } return thread_obj; @@ -1333,13 +1333,13 @@ jvmtiError JvmtiEnvBase::get_threadOop_and_JavaThread(ThreadsList* t_list, jthread thread, JavaThread** jt_pp, oop* thread_oop_p) { JavaThread* cur_thread = JavaThread::current(); - JavaThread* java_thread = NULL; - oop thread_oop = NULL; + JavaThread* java_thread = nullptr; + oop thread_oop = nullptr; - if (thread == NULL) { + if (thread == nullptr) { java_thread = cur_thread; thread_oop = get_vthread_or_thread_oop(java_thread); - if (thread_oop == NULL || !thread_oop->is_a(vmClasses::Thread_klass())) { + if (thread_oop == nullptr || !thread_oop->is_a(vmClasses::Thread_klass())) { return JVMTI_ERROR_INVALID_THREAD; } } else { @@ -1349,12 +1349,12 @@ JvmtiEnvBase::get_threadOop_and_JavaThread(ThreadsList* t_list, jthread thread, // an error from here if we didn't get a valid thread_oop. In a vthread case // the cv_external_thread_to_JavaThread is expected to correctly set the // thread_oop and return JVMTI_ERROR_INVALID_THREAD which we ignore here. - if (thread_oop == NULL || err != JVMTI_ERROR_INVALID_THREAD) { + if (thread_oop == nullptr || err != JVMTI_ERROR_INVALID_THREAD) { *thread_oop_p = thread_oop; return err; } } - if (java_thread == NULL && java_lang_VirtualThread::is_instance(thread_oop)) { + if (java_thread == nullptr && java_lang_VirtualThread::is_instance(thread_oop)) { java_thread = get_JavaThread_or_null(thread_oop); } } @@ -1386,16 +1386,16 @@ JvmtiEnvBase::get_object_monitor_usage(JavaThread* calling_thread, jobject objec } ThreadsListHandle tlh(current_thread); - JavaThread *owning_thread = NULL; - ObjectMonitor *mon = NULL; + JavaThread *owning_thread = nullptr; + ObjectMonitor *mon = nullptr; jvmtiMonitorUsage ret = { - NULL, 0, 0, NULL, 0, NULL + nullptr, 0, 0, nullptr, 0, nullptr }; uint32_t debug_bits = 0; // first derive the object's owner and entry_count (if any) owning_thread = ObjectSynchronizer::get_lock_owner(tlh.list(), hobj); - if (owning_thread != NULL) { + if (owning_thread != nullptr) { Handle th(current_thread, get_vthread_or_thread_oop(owning_thread)); ret.owner = (jthread)jni_reference(calling_thread, th); @@ -1411,7 +1411,7 @@ JvmtiEnvBase::get_object_monitor_usage(JavaThread* calling_thread, jobject objec markWord mark = hobj->mark(); if (mark.has_monitor()) { mon = mark.monitor(); - assert(mon != NULL, "must have monitor"); + assert(mon != nullptr, "must have monitor"); // this object has a heavyweight monitor nWant = mon->contentions(); // # of threads contending for monitor nWait = mon->waiters(); // # of threads in Object.wait() @@ -1437,11 +1437,11 @@ JvmtiEnvBase::get_object_monitor_usage(JavaThread* calling_thread, jobject objec } // now derive the rest of the fields - if (mon != NULL) { + if (mon != nullptr) { // this object has a heavyweight monitor // Number of waiters may actually be less than the waiter count. - // So NULL out memory so that unused memory will be NULL. + // So null out memory so that unused memory will be null. memset(ret.waiters, 0, ret.waiter_count * sizeof(jthread *)); memset(ret.notify_waiters, 0, ret.notify_waiter_count * sizeof(jthread *)); @@ -1468,13 +1468,13 @@ JvmtiEnvBase::get_object_monitor_usage(JavaThread* calling_thread, jobject objec int offset = nWant; // add after any contending threads ObjectWaiter *waiter = mon->first_waiter(); for (int i = 0, j = 0; i < nWait; i++) { - if (waiter == NULL) { + if (waiter == nullptr) { // robustness: the waiting list has gotten smaller nWait = j; break; } JavaThread *w = mon->thread_of_waiter(waiter); - if (w != NULL) { + if (w != nullptr) { // If the thread was found on the ObjectWaiter list, then // it has not been notified. This thread can't change the // state of the monitor so it doesn't need to be suspended. @@ -1503,13 +1503,13 @@ JvmtiEnvBase::get_object_monitor_usage(JavaThread* calling_thread, jobject objec jvmtiError JvmtiEnvBase::check_thread_list(jint count, const jthread* list) { - if (list == NULL && count != 0) { + if (list == nullptr && count != 0) { return JVMTI_ERROR_NULL_POINTER; } for (int i = 0; i < count; i++) { jthread thread = list[i]; oop thread_oop = JNIHandles::resolve_external_guard(thread); - if (thread_oop == NULL || !thread_oop->is_a(vmClasses::VirtualThread_klass())) { + if (thread_oop == nullptr || !thread_oop->is_a(vmClasses::VirtualThread_klass())) { return JVMTI_ERROR_INVALID_THREAD; } } @@ -1544,14 +1544,14 @@ JvmtiEnvBase::suspend_thread(oop thread_oop, JavaThread* java_thread, bool singl } JvmtiVTSuspender::register_vthread_suspend(thread_h()); // Check if virtual thread is mounted and there is a java_thread. - // A non-NULL java_thread is always passed in the !single_suspend case. + // A non-null java_thread is always passed in the !single_suspend case. oop carrier_thread = java_lang_VirtualThread::carrier_thread(thread_h()); - java_thread = carrier_thread == NULL ? NULL : java_lang_Thread::thread(carrier_thread); + java_thread = carrier_thread == nullptr ? nullptr : java_lang_Thread::thread(carrier_thread); } // The java_thread can be still blocked in VTMS transition after a previous JVMTI resume call. // There is no need to suspend the java_thread in this case. After vthread unblocking, // it will check for ext_suspend request and suspend itself if necessary. - if (java_thread == NULL || java_thread->is_suspended()) { + if (java_thread == nullptr || java_thread->is_suspended()) { // We are done if the virtual thread is unmounted or // the java_thread is externally suspended. return JVMTI_ERROR_NONE; @@ -1612,14 +1612,14 @@ JvmtiEnvBase::resume_thread(oop thread_oop, JavaThread* java_thread, bool single } JvmtiVTSuspender::register_vthread_resume(thread_h()); // Check if virtual thread is mounted and there is a java_thread. - // A non-NULL java_thread is always passed in the !single_resume case. + // A non-null java_thread is always passed in the !single_resume case. oop carrier_thread = java_lang_VirtualThread::carrier_thread(thread_h()); - java_thread = carrier_thread == NULL ? NULL : java_lang_Thread::thread(carrier_thread); + java_thread = carrier_thread == nullptr ? nullptr : java_lang_Thread::thread(carrier_thread); } // The java_thread can be still blocked in VTMS transition after a previous JVMTI suspend call. // There is no need to resume the java_thread in this case. After vthread unblocking, // it will check for is_vthread_suspended request and remain resumed if necessary. - if (java_thread == NULL || !java_thread->is_suspended()) { + if (java_thread == nullptr || !java_thread->is_suspended()) { // We are done if the virtual thread is unmounted or // the java_thread is not externally suspended. return JVMTI_ERROR_NONE; @@ -1674,7 +1674,7 @@ jvmtiError ResourceTracker::allocate(jlong size, unsigned char** mem_ptr) { _allocations->append(ptr); *mem_ptr = ptr; } else { - *mem_ptr = NULL; + *mem_ptr = nullptr; _failed = true; } return err; @@ -1688,7 +1688,7 @@ unsigned char* ResourceTracker::allocate(jlong size) { char* ResourceTracker::strdup(const char* str) { char *dup_str = (char*)allocate(strlen(str)+1); - if (dup_str != NULL) { + if (dup_str != nullptr) { strcpy(dup_str, str); } return dup_str; @@ -1709,7 +1709,7 @@ MultipleStackTracesCollector::fill_frames(jthread jt, JavaThread *thr, oop threa #ifdef ASSERT Thread *current_thread = Thread::current(); assert(SafepointSynchronize::is_at_safepoint() || - thr == NULL || + thr == nullptr || thr->is_handshake_safe_for(current_thread), "unmounted virtual thread / call by myself / at safepoint / at handshake"); #endif @@ -1721,7 +1721,7 @@ MultipleStackTracesCollector::fill_frames(jthread jt, JavaThread *thr, oop threa node->next = head(); set_head(node); infop->frame_count = 0; - infop->frame_buffer = NULL; + infop->frame_buffer = nullptr; infop->thread = jt; if (java_lang_VirtualThread::is_instance(thread_oop)) { @@ -1735,7 +1735,7 @@ MultipleStackTracesCollector::fill_frames(jthread jt, JavaThread *thr, oop threa } } else { state = JvmtiEnvBase::get_thread_state(thread_oop, thr); - if (thr != NULL && (state & JVMTI_THREAD_STATE_ALIVE) != 0) { + if (thr != nullptr && (state & JVMTI_THREAD_STATE_ALIVE) != 0) { infop->frame_buffer = NEW_RESOURCE_ARRAY(jvmtiFrameInfo, max_frame_count()); _result = env()->get_stack_trace(thr, 0, max_frame_count(), infop->frame_buffer, &(infop->frame_count)); @@ -1762,13 +1762,13 @@ MultipleStackTracesCollector::allocate_and_fill_stacks(jint thread_count) { // insert stack info backwards since linked list is backwards // insert frame info forwards // walk the StackInfoNodes - for (struct StackInfoNode *sin = head(); sin != NULL; sin = sin->next) { + for (struct StackInfoNode *sin = head(); sin != nullptr; sin = sin->next) { jint frame_count = sin->info.frame_count; size_t frames_size = frame_count * sizeof(jvmtiFrameInfo); --si; memcpy(si, &(sin->info), sizeof(jvmtiStackInfo)); if (frames_size == 0) { - si->frame_buffer = NULL; + si->frame_buffer = nullptr; } else { memcpy(fi, sin->info.frame_buffer, frames_size); si->frame_buffer = fi; // point to the new allocated copy of the frames @@ -1789,8 +1789,8 @@ VM_GetThreadListStackTraces::doit() { ThreadsListHandle tlh; for (int i = 0; i < _thread_count; ++i) { jthread jt = _thread_list[i]; - JavaThread* java_thread = NULL; - oop thread_oop = NULL; + JavaThread* java_thread = nullptr; + oop thread_oop = nullptr; jvmtiError err = JvmtiExport::cv_external_thread_to_JavaThread(tlh.list(), jt, &java_thread, &thread_oop); if (err != JVMTI_ERROR_NONE) { // We got an error code so we don't have a JavaThread *, but @@ -1798,7 +1798,7 @@ VM_GetThreadListStackTraces::doit() { // thread_oop. // In the virtual thread case the cv_external_thread_to_JavaThread is expected to correctly set // the thread_oop and return JVMTI_ERROR_INVALID_THREAD which we ignore here. - if (thread_oop == NULL) { + if (thread_oop == nullptr) { _collector.set_result(err); return; } @@ -1814,7 +1814,7 @@ GetSingleStackTraceClosure::do_thread(Thread *target) { JavaThread *jt = JavaThread::cast(target); oop thread_oop = jt->threadObj(); - if (!jt->is_exiting() && thread_oop != NULL) { + if (!jt->is_exiting() && thread_oop != nullptr) { ResourceMark rm; _collector.fill_frames(_jthread, jt, thread_oop); _collector.allocate_and_fill_stacks(1); @@ -1829,7 +1829,7 @@ VM_GetAllStackTraces::doit() { _final_thread_count = 0; for (JavaThreadIteratorWithHandle jtiwh; JavaThread *jt = jtiwh.next(); ) { oop thread_oop = jt->threadObj(); - if (thread_oop != NULL && + if (thread_oop != nullptr && !jt->is_exiting() && java_lang_Thread::is_alive(thread_oop) && !jt->is_hidden_from_external_view()) { @@ -1880,7 +1880,7 @@ JvmtiEnvBase::check_top_frame(Thread* current_thread, JavaThread* java_thread, // Check that the jobject class matches the return type signature. jobject jobj = value.l; - if (tos == atos && jobj != NULL) { // NULL reference is allowed + if (tos == atos && jobj != nullptr) { // null reference is allowed Handle ob_h(current_thread, JNIHandles::resolve_external_guard(jobj)); NULL_CHECK(ob_h, JVMTI_ERROR_INVALID_OBJECT); Klass* ob_k = ob_h()->klass(); @@ -1915,11 +1915,11 @@ JvmtiEnvBase::force_early_return(jthread thread, jvalue value, TosState tos) { JvmtiVTMSTransitionDisabler disabler; ThreadsListHandle tlh(current_thread); - JavaThread* java_thread = NULL; - oop thread_obj = NULL; + JavaThread* java_thread = nullptr; + oop thread_obj = nullptr; jvmtiError err = get_threadOop_and_JavaThread(tlh.list(), thread, &java_thread, &thread_obj); - if (thread_obj != NULL && java_lang_VirtualThread::is_instance(thread_obj)) { + if (thread_obj != nullptr && java_lang_VirtualThread::is_instance(thread_obj)) { // No support for virtual threads (yet). return JVMTI_ERROR_OPAQUE_FRAME; } @@ -1929,7 +1929,7 @@ JvmtiEnvBase::force_early_return(jthread thread, jvalue value, TosState tos) { // retrieve or create the state JvmtiThreadState* state = JvmtiThreadState::state_for(java_thread); - if (state == NULL) { + if (state == nullptr) { return JVMTI_ERROR_THREAD_NOT_ALIVE; } @@ -1990,8 +1990,8 @@ SetForceEarlyReturn::doit(Thread *target, bool self) { if (_result != JVMTI_ERROR_NONE) { return; } - assert(_tos != atos || _value.l == NULL || ret_ob_h() != NULL, - "return object oop must not be NULL if jobject is not NULL"); + assert(_tos != atos || _value.l == nullptr || ret_ob_h() != nullptr, + "return object oop must not be null if jobject is not null"); // Update the thread state to reflect that the top frame must be // forced to return. @@ -2044,12 +2044,12 @@ JvmtiMonitorClosure::do_monitor(ObjectMonitor* mon) { } } -GrowableArray* JvmtiModuleClosure::_tbl = NULL; +GrowableArray* JvmtiModuleClosure::_tbl = nullptr; void JvmtiModuleClosure::do_module(ModuleEntry* entry) { assert_locked_or_safepoint(Module_lock); OopHandle module = entry->module_handle(); - guarantee(module.resolve() != NULL, "module object is NULL"); + guarantee(module.resolve() != nullptr, "module object is null"); _tbl->push(module); } @@ -2060,7 +2060,7 @@ JvmtiModuleClosure::get_all_modules(JvmtiEnv* env, jint* module_count_ptr, jobje MutexLocker ml(Module_lock); _tbl = new GrowableArray(77); - if (_tbl == NULL) { + if (_tbl == nullptr) { return JVMTI_ERROR_OUT_OF_MEMORY; } @@ -2071,13 +2071,13 @@ JvmtiModuleClosure::get_all_modules(JvmtiEnv* env, jint* module_count_ptr, jobje guarantee(len > 0, "at least one module must be present"); jobject* array = (jobject*)env->jvmtiMalloc((jlong)(len * sizeof(jobject))); - if (array == NULL) { + if (array == nullptr) { return JVMTI_ERROR_OUT_OF_MEMORY; } for (jint idx = 0; idx < len; idx++) { array[idx] = JNIHandles::make_local(_tbl->at(idx).resolve()); } - _tbl = NULL; + _tbl = nullptr; *modules_ptr = array; *module_count_ptr = len; return JVMTI_ERROR_NONE; @@ -2139,7 +2139,7 @@ UpdateForPopTopFrameClosure::doit(Thread *target, bool self) { // There can be two situations here: // 1. There are no more java frames // 2. Two top java frames are separated by non-java native frames - if (JvmtiEnvBase::jvf_for_thread_and_depth(java_thread, 1) == NULL) { + if (JvmtiEnvBase::jvf_for_thread_and_depth(java_thread, 1) == nullptr) { _result = JVMTI_ERROR_NO_MORE_FRAMES; return; } else { @@ -2205,7 +2205,7 @@ SetFramePopClosure::doit(Thread *target, bool self) { void GetOwnedMonitorInfoClosure::do_thread(Thread *target) { JavaThread *jt = JavaThread::cast(target); - if (!jt->is_exiting() && (jt->threadObj() != NULL)) { + if (!jt->is_exiting() && (jt->threadObj() != nullptr)) { _result = ((JvmtiEnvBase *)_env)->get_owned_monitors(_calling_thread, jt, _owned_monitors_list); @@ -2215,7 +2215,7 @@ GetOwnedMonitorInfoClosure::do_thread(Thread *target) { void GetCurrentContendedMonitorClosure::do_thread(Thread *target) { JavaThread *jt = JavaThread::cast(target); - if (!jt->is_exiting() && (jt->threadObj() != NULL)) { + if (!jt->is_exiting() && (jt->threadObj() != nullptr)) { _result = ((JvmtiEnvBase *)_env)->get_current_contended_monitor(_calling_thread, jt, _owned_monitor_ptr, @@ -2240,7 +2240,7 @@ VM_VirtualThreadGetStackTrace::doit() { void GetStackTraceClosure::do_thread(Thread *target) { JavaThread *jt = JavaThread::cast(target); - if (!jt->is_exiting() && jt->threadObj() != NULL) { + if (!jt->is_exiting() && jt->threadObj() != nullptr) { _result = ((JvmtiEnvBase *)_env)->get_stack_trace(jt, _start_depth, _max_count, _frame_buffer, _count_ptr); @@ -2256,7 +2256,7 @@ PrintStackTraceClosure::do_thread_impl(Thread *target) { ResourceMark rm (current_thread); const char* tname = JvmtiTrace::safe_get_thread_name(java_thread); oop t_oop = java_thread->jvmti_vthread(); - t_oop = t_oop == NULL ? java_thread->threadObj() : t_oop; + t_oop = t_oop == nullptr ? java_thread->threadObj() : t_oop; bool is_vt_suspended = java_lang_VirtualThread::is_instance(t_oop) && JvmtiVTSuspender::is_vthread_suspended(t_oop); log_error(jvmti)("%s(%s) exiting: %d is_susp: %d is_thread_susp: %d is_vthread_susp: %d " @@ -2273,7 +2273,7 @@ PrintStackTraceClosure::do_thread_impl(Thread *target) { ResourceMark rm(current_thread); HandleMark hm(current_thread); javaVFrame *jvf = java_thread->last_java_vframe(®_map); - while (jvf != NULL) { + while (jvf != nullptr) { log_error(jvmti)(" %s:%d", jvf->method()->external_name(), jvf->method()->line_number_from_bci(jvf->bci())); @@ -2305,7 +2305,7 @@ void GetFrameCountClosure::do_thread(Thread *target) { JavaThread* jt = JavaThread::cast(target); assert(target == jt, "just checking"); - if (!jt->is_exiting() && jt->threadObj() != NULL) { + if (!jt->is_exiting() && jt->threadObj() != nullptr) { _result = ((JvmtiEnvBase*)_env)->get_frame_count(jt, _count_ptr); } } @@ -2313,7 +2313,7 @@ GetFrameCountClosure::do_thread(Thread *target) { void GetFrameLocationClosure::do_thread(Thread *target) { JavaThread *jt = JavaThread::cast(target); - if (!jt->is_exiting() && jt->threadObj() != NULL) { + if (!jt->is_exiting() && jt->threadObj() != nullptr) { _result = ((JvmtiEnvBase*)_env)->get_frame_location(jt, _depth, _method_ptr, _location_ptr); } @@ -2332,7 +2332,7 @@ VirtualThreadGetOwnedMonitorInfoClosure::do_thread(Thread *target) { javaVFrame *jvf = JvmtiEnvBase::get_vthread_jvf(_vthread_h()); - if (!java_thread->is_exiting() && java_thread->threadObj() != NULL) { + if (!java_thread->is_exiting() && java_thread->threadObj() != nullptr) { _result = ((JvmtiEnvBase *)_env)->get_owned_monitors(java_thread, java_thread, jvf, @@ -2385,7 +2385,7 @@ VirtualThreadGetThreadStateClosure::do_thread(Thread *target) { oop carrier_thread_oop = java_lang_VirtualThread::carrier_thread(_vthread_h()); jint state; - if (vthread_state == java_lang_VirtualThread::RUNNING && carrier_thread_oop != NULL) { + if (vthread_state == java_lang_VirtualThread::RUNNING && carrier_thread_oop != nullptr) { state = (jint) java_lang_Thread::get_thread_status(carrier_thread_oop); JavaThread* java_thread = java_lang_Thread::thread(carrier_thread_oop); if (java_thread->is_suspended()) { diff --git a/src/hotspot/share/prims/jvmtiEnvBase.hpp b/src/hotspot/share/prims/jvmtiEnvBase.hpp index 1a3f463c02a96..ea2267e449ff1 100644 --- a/src/hotspot/share/prims/jvmtiEnvBase.hpp +++ b/src/hotspot/share/prims/jvmtiEnvBase.hpp @@ -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 @@ -91,7 +91,7 @@ class JvmtiEnvBase : public CHeapObj { // check if thread_oop represents a passive carrier thread static bool is_passive_carrier_thread(JavaThread* java_thread, oop thread_oop) { - return java_thread != NULL && java_thread->jvmti_vthread() != NULL + return java_thread != nullptr && java_thread->jvmti_vthread() != nullptr && java_thread->jvmti_vthread() != thread_oop && java_thread->threadObj() == thread_oop; } @@ -149,7 +149,7 @@ class JvmtiEnvBase : public CHeapObj { void set_next_environment(JvmtiEnvBase* env) { _next = env; } static JvmtiEnv* head_environment() { JVMTI_ONLY(return (JvmtiEnv*)_head_environment); - NOT_JVMTI(return NULL); + NOT_JVMTI(return nullptr); } public: @@ -167,7 +167,7 @@ class JvmtiEnvBase : public CHeapObj { return byte_offset_of(JvmtiEnvBase, _jvmti_external); }; - // If (thread == NULL) then return current thread object. + // If (thread == nullptr) then return current thread object. // Otherwise return JNIHandles::resolve_external_guard(thread). static oop current_thread_obj_or_resolve_external_guard(jthread thread); @@ -175,23 +175,23 @@ class JvmtiEnvBase : public CHeapObj { // A passive carrier thread is not treated as current. static bool is_JavaThread_current(JavaThread* jt, oop thr_obj) { JavaThread* current = JavaThread::current(); - // jt can be NULL in case of a virtual thread - if (jt == NULL || jt != current) { + // jt can be null in case of a virtual thread + if (jt == nullptr || jt != current) { return false; } oop cur_obj = current->jvmti_vthread(); - // cur_obj == NULL is true for normal platform threads only + // cur_obj == nullptr is true for normal platform threads only // otherwise it can be virtual or carrier thread. - return cur_obj == NULL || cur_obj == thr_obj; + return cur_obj == nullptr || cur_obj == thr_obj; } static jvmtiError get_JavaThread(ThreadsList* tlist, jthread thread, JavaThread** jt_pp) { jvmtiError err = JVMTI_ERROR_NONE; - if (thread == NULL) { + if (thread == nullptr) { *jt_pp = JavaThread::current(); } else { - err = JvmtiExport::cv_external_thread_to_JavaThread(tlist, thread, jt_pp, NULL); + err = JvmtiExport::cv_external_thread_to_JavaThread(tlist, thread, jt_pp, nullptr); } return err; } @@ -200,7 +200,7 @@ class JvmtiEnvBase : public CHeapObj { // return virtual thread oop. Otherwise, return thread oop. static oop get_vthread_or_thread_oop(JavaThread* jt) { oop result = jt->threadObj(); - if (jt->jvmti_vthread() != NULL) { + if (jt->jvmti_vthread() != nullptr) { result = jt->jvmti_vthread(); } return result; @@ -236,7 +236,7 @@ class JvmtiEnvBase : public CHeapObj { // not yet been deallocated. As a result, this test should only be used as an // optimization for the no environment case. static bool environments_might_exist() { - return head_environment() != NULL; + return head_environment() != nullptr; } static void check_for_periodic_clean_up(); @@ -250,10 +250,10 @@ class JvmtiEnvBase : public CHeapObj { return JVMTI_ERROR_ILLEGAL_ARGUMENT; } if (size == 0) { - *mem_ptr = NULL; + *mem_ptr = nullptr; } else { *mem_ptr = (unsigned char *)os::malloc((size_t)size, mtInternal); - if (*mem_ptr == NULL) { + if (*mem_ptr == nullptr) { return JVMTI_ERROR_OUT_OF_MEMORY; } } @@ -261,7 +261,7 @@ class JvmtiEnvBase : public CHeapObj { } jvmtiError deallocate(unsigned char* mem) { - if (mem != NULL) { + if (mem != nullptr) { os::free(mem); } return JVMTI_ERROR_NONE; @@ -294,7 +294,7 @@ class JvmtiEnvBase : public CHeapObj { bool has_callback(jvmtiEvent event_type) { assert(event_type >= JVMTI_MIN_EVENT_TYPE_VAL && event_type <= JVMTI_MAX_EVENT_TYPE_VAL, "checking"); - return ((void**)&_event_callbacks)[event_type-JVMTI_MIN_EVENT_TYPE_VAL] != NULL; + return ((void**)&_event_callbacks)[event_type-JVMTI_MIN_EVENT_TYPE_VAL] != nullptr; } jvmtiEventCallbacks* callbacks() { @@ -358,7 +358,7 @@ class JvmtiEnvBase : public CHeapObj { // check if virtual thread is not terminated (alive) static bool is_vthread_alive(oop vt); - // return JavaThread if virtual thread is mounted, NULL otherwise + // return JavaThread if virtual thread is mounted, null otherwise static JavaThread* get_JavaThread_or_null(oop vthread); // get virtual thread last java vframe @@ -611,10 +611,10 @@ class MultipleStackTracesCollector { MultipleStackTracesCollector(JvmtiEnv *env, jint max_frame_count) : _env(env), _max_frame_count(max_frame_count), - _stack_info(NULL), + _stack_info(nullptr), _result(JVMTI_ERROR_NONE), _frame_count_total(0), - _head(NULL) { + _head(nullptr) { } void set_result(jvmtiError result) { _result = result; } void fill_frames(jthread jt, JavaThread *thr, oop thread_oop); diff --git a/src/hotspot/share/prims/jvmtiEnvThreadState.cpp b/src/hotspot/share/prims/jvmtiEnvThreadState.cpp index d1d7f0ca146f9..d847c60d10303 100644 --- a/src/hotspot/share/prims/jvmtiEnvThreadState.cpp +++ b/src/hotspot/share/prims/jvmtiEnvThreadState.cpp @@ -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 @@ -130,25 +130,25 @@ JvmtiEnvThreadState::JvmtiEnvThreadState(JvmtiThreadState* state, JvmtiEnvBase * _event_enable() { _state = state; _env = (JvmtiEnv*)env; - _next = NULL; - _frame_pops = NULL; + _next = nullptr; + _frame_pops = nullptr; _current_bci = 0; - _current_method_id = NULL; + _current_method_id = nullptr; _breakpoint_posted = false; _single_stepping_posted = false; - _agent_thread_local_storage_data = NULL; + _agent_thread_local_storage_data = nullptr; } JvmtiEnvThreadState::~JvmtiEnvThreadState() { delete _frame_pops; - _frame_pops = NULL; + _frame_pops = nullptr; } bool JvmtiEnvThreadState::is_virtual() { return _state->is_virtual(); } -// Use _thread_saved if cthread is detached from JavaThread (_thread == NULL). +// Use _thread_saved if cthread is detached from JavaThread (_thread == nullptr). JavaThread* JvmtiEnvThreadState::get_thread_or_saved() { return _state->get_thread_or_saved(); } @@ -215,25 +215,25 @@ JvmtiFramePops* JvmtiEnvThreadState::get_frame_pops() { #ifdef ASSERT Thread *current = Thread::current(); #endif - assert(get_thread() == NULL || get_thread()->is_handshake_safe_for(current), + assert(get_thread() == nullptr || get_thread()->is_handshake_safe_for(current), "frame pop data only accessible from same or detached thread or direct handshake"); - if (_frame_pops == NULL) { + if (_frame_pops == nullptr) { _frame_pops = new JvmtiFramePops(); - assert(_frame_pops != NULL, "_frame_pops != NULL"); + assert(_frame_pops != nullptr, "_frame_pops != null"); } return _frame_pops; } bool JvmtiEnvThreadState::has_frame_pops() { - return _frame_pops == NULL? false : (_frame_pops->length() > 0); + return _frame_pops == nullptr? false : (_frame_pops->length() > 0); } void JvmtiEnvThreadState::set_frame_pop(int frame_number) { #ifdef ASSERT Thread *current = Thread::current(); #endif - assert(get_thread() == NULL || get_thread()->is_handshake_safe_for(current), + assert(get_thread() == nullptr || get_thread()->is_handshake_safe_for(current), "frame pop data only accessible from same or detached thread or direct handshake"); JvmtiFramePop fpop(frame_number); JvmtiEventController::set_frame_pop(this, fpop); @@ -244,7 +244,7 @@ void JvmtiEnvThreadState::clear_frame_pop(int frame_number) { #ifdef ASSERT Thread *current = Thread::current(); #endif - assert(get_thread() == NULL || get_thread()->is_handshake_safe_for(current), + assert(get_thread() == nullptr || get_thread()->is_handshake_safe_for(current), "frame pop data only accessible from same or detached thread or direct handshake"); JvmtiFramePop fpop(frame_number); JvmtiEventController::clear_frame_pop(this, fpop); @@ -255,9 +255,9 @@ bool JvmtiEnvThreadState::is_frame_pop(int cur_frame_number) { #ifdef ASSERT Thread *current = Thread::current(); #endif - assert(get_thread() == NULL || get_thread()->is_handshake_safe_for(current), + assert(get_thread() == nullptr || get_thread()->is_handshake_safe_for(current), "frame pop data only accessible from same or detached thread or direct handshake"); - if (!jvmti_thread_state()->is_interp_only_mode() || _frame_pops == NULL) { + if (!jvmti_thread_state()->is_interp_only_mode() || _frame_pops == nullptr) { return false; } JvmtiFramePop fp(cur_frame_number); @@ -274,7 +274,7 @@ class VM_VirtualThreadGetCurrentLocation : public VM_Operation { public: VM_VirtualThreadGetCurrentLocation(Handle vthread_h) : _vthread_h(vthread_h), - _method_id(NULL), + _method_id(nullptr), _bci(0), _completed(false) {} @@ -287,8 +287,8 @@ class VM_VirtualThreadGetCurrentLocation : public VM_Operation { ResourceMark rm; javaVFrame* jvf = JvmtiEnvBase::get_vthread_jvf(_vthread_h()); - if (jvf != NULL) { - // jvf can be NULL, when the native enterSpecial frame is on the top. + if (jvf != nullptr) { + // jvf can be null, when the native enterSpecial frame is on the top. Method* method = jvf->method(); _method_id = method->jmethod_id(); _bci = jvf->bci(); @@ -312,7 +312,7 @@ class GetCurrentLocationClosure : public HandshakeClosure { public: GetCurrentLocationClosure() : HandshakeClosure("GetCurrentLocation"), - _method_id(NULL), + _method_id(nullptr), _bci(0), _completed(false) {} void do_thread(Thread *target) { @@ -327,7 +327,7 @@ class GetCurrentLocationClosure : public HandshakeClosure { // We must recheck that the last Java frame still exists. if (!jt->is_exiting() && jt->has_last_Java_frame()) { javaVFrame* vf = jt->last_java_vframe(&rm); - if (vf != NULL) { + if (vf != nullptr) { Method* method = vf->method(); _method_id = method->jmethod_id(); _bci = vf->bci(); @@ -378,7 +378,7 @@ void JvmtiEnvThreadState::reset_current_location(jvmtiEvent event_type, bool ena oop thread_oop = jvmti_thread_state()->get_thread_oop(); assert(!jvmti_thread_state()->is_in_VTMS_transition(), "sanity check"); - if (thread == NULL && event_type == JVMTI_EVENT_SINGLE_STEP && is_virtual()) { + if (thread == nullptr && event_type == JVMTI_EVENT_SINGLE_STEP && is_virtual()) { // Handle the unmounted virtual thread case. jmethodID method_id; int bci; diff --git a/src/hotspot/share/prims/jvmtiEnvThreadState.hpp b/src/hotspot/share/prims/jvmtiEnvThreadState.hpp index 04bedf69c19e7..544d4eff5f1eb 100644 --- a/src/hotspot/share/prims/jvmtiEnvThreadState.hpp +++ b/src/hotspot/share/prims/jvmtiEnvThreadState.hpp @@ -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 @@ -153,7 +153,7 @@ class JvmtiEnvThreadState : public CHeapObj { // here. void compare_and_set_current_location(Method* method, address location, jvmtiEvent event); - void clear_current_location() { set_current_location((jmethodID)NULL, 0); } + void clear_current_location() { set_current_location((jmethodID)nullptr, 0); } void reset_current_location(jvmtiEvent event, bool enabled); diff --git a/src/hotspot/share/prims/jvmtiEventController.cpp b/src/hotspot/share/prims/jvmtiEventController.cpp index faa4868d32e59..033365071229d 100644 --- a/src/hotspot/share/prims/jvmtiEventController.cpp +++ b/src/hotspot/share/prims/jvmtiEventController.cpp @@ -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 @@ -211,7 +211,7 @@ class EnterInterpOnlyModeClosure : public HandshakeClosure { JavaThread* jt = JavaThread::cast(th); JvmtiThreadState* state = jt->jvmti_thread_state(); - assert(state != NULL, "sanity check"); + assert(state != nullptr, "sanity check"); assert(state->get_thread() == jt, "handshake unsafe conditions"); if (!state->is_pending_interp_only_mode()) { _completed = true; @@ -358,20 +358,20 @@ void JvmtiEventControllerPrivate::enter_interp_only_mode(JvmtiThreadState *state JavaThread *target = state->get_thread(); Thread *current = Thread::current(); - assert(state != NULL, "sanity check"); + assert(state != nullptr, "sanity check"); if (state->is_pending_interp_only_mode()) { return; // An EnterInterpOnlyModeClosure handshake is already pending for execution. } // This flag will be cleared in EnterInterpOnlyModeClosure handshake. state->set_pending_interp_only_mode(true); - if (target == NULL) { // an unmounted virtual thread + if (target == nullptr) { // an unmounted virtual thread return; // EnterInterpOnlyModeClosure will be executed right after mount. } EnterInterpOnlyModeClosure hs; if (target->is_handshake_safe_for(current)) { hs.do_thread(target); } else { - assert(state->get_thread() != NULL, "sanity check"); + assert(state->get_thread() != nullptr, "sanity check"); Handshake::execute(&hs, target); guarantee(hs.completed(), "Handshake failed: Target thread is not alive?"); } @@ -437,7 +437,7 @@ JvmtiEventControllerPrivate::flush_object_free_events(JvmtiEnvBase* env) { // need to ensure the env is cleaned up and any events that should // be posted are posted. JvmtiTagMap* tag_map = env->tag_map_acquire(); - if (tag_map != NULL) { + if (tag_map != nullptr) { tag_map->flush_object_free_events(); } } @@ -447,7 +447,7 @@ JvmtiEventControllerPrivate::set_enabled_events_with_lock(JvmtiEnvBase* env, jlo // The state for ObjectFree events must be enabled or disabled // under the TagMap lock, to allow pending object posting events to complete. JvmtiTagMap* tag_map = env->tag_map_acquire(); - if (tag_map != NULL) { + if (tag_map != nullptr) { MutexLocker ml(tag_map->lock(), Mutex::_no_safepoint_check_flag); env->env_event_enable()->_event_enabled.set_bits(now_enabled); } else { @@ -555,7 +555,7 @@ JvmtiEventControllerPrivate::recompute_env_thread_enabled(JvmtiEnvThreadState* e // set external state accordingly. Only thread-filtered events are included. jlong JvmtiEventControllerPrivate::recompute_thread_enabled(JvmtiThreadState *state) { - if (state == NULL) { + if (state == nullptr) { // associated JavaThread is exiting return (jlong)0; } @@ -571,7 +571,7 @@ JvmtiEventControllerPrivate::recompute_thread_enabled(JvmtiThreadState *state) { // have been disposed. These JvmtiEnvThreadStates must not be filtered // as recompute must be called on them to disable their events, JvmtiEnvThreadStateIterator it(state); - for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { + for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) { any_env_enabled |= recompute_env_thread_enabled(ets, state); has_frame_pops |= ets->has_frame_pops(); } @@ -581,7 +581,7 @@ JvmtiEventControllerPrivate::recompute_thread_enabled(JvmtiThreadState *state) { // mark if event is truly enabled on this thread in any environment state->thread_event_enable()->_event_enabled.set_bits(any_env_enabled); - if (state->get_thread() != NULL) { + if (state->get_thread() != nullptr) { // The JavaThread for carrier or mounted virtual thread case. // Update the cached value for thread-specific should_post_on_exceptions value. bool should_post_on_exceptions = (any_env_enabled & SHOULD_POST_ON_EXCEPTIONS_BITS) != 0; @@ -632,7 +632,7 @@ JvmtiEventControllerPrivate::recompute_enabled() { // This must be done separately from thread-filtered events, since some // events can occur before any threads exist. JvmtiEnvIterator it; - for (JvmtiEnvBase* env = it.first(); env != NULL; env = it.next(env)) { + for (JvmtiEnvBase* env = it.first(); env != nullptr; env = it.next(env)) { any_env_thread_enabled |= recompute_env_enabled(env); } @@ -648,7 +648,7 @@ JvmtiEventControllerPrivate::recompute_enabled() { // create the thread state for mounted virtual thread if missing oop vt_oop = tp->jvmti_vthread(); - if (vt_oop != NULL && java_lang_VirtualThread::is_instance(vt_oop)) { + if (vt_oop != nullptr && java_lang_VirtualThread::is_instance(vt_oop)) { state = JvmtiThreadState::state_for_while_locked(tp, vt_oop); } } @@ -742,7 +742,7 @@ JvmtiEventControllerPrivate::thread_started(JavaThread *thread) { MutexLocker mu(JvmtiThreadState_lock); // create the thread state if missing JvmtiThreadState *state = JvmtiThreadState::state_for_while_locked(thread); - if (state != NULL) { // skip threads with no JVMTI thread state + if (state != nullptr) { // skip threads with no JVMTI thread state recompute_thread_enabled(state); } } @@ -758,7 +758,7 @@ JvmtiEventControllerPrivate::thread_ended(JavaThread *thread) { EC_TRACE(("[%s] # thread ended", JvmtiTrace::safe_get_thread_name(thread))); JvmtiThreadState *state = thread->jvmti_thread_state(); - assert(state != NULL, "else why are we here?"); + assert(state != nullptr, "else why are we here?"); delete state; } @@ -809,7 +809,7 @@ JvmtiEventControllerPrivate::set_extension_event_callback(JvmtiEnvBase *env, // set event callbacks, where the DisposeEnvironment occurs after the boiler-plate // environment check and before the lock is acquired. // We can safely do the is_valid check now, as JvmtiThreadState_lock is held. - bool enabling = (callback != NULL) && (env->is_valid()); + bool enabling = (callback != nullptr) && (env->is_valid()); // update the callback jvmtiExtEventCallbacks* ext_callbacks = env->ext_callbacks(); @@ -855,7 +855,7 @@ JvmtiEventControllerPrivate::env_initialize(JvmtiEnvBase *env) { env->initialize(); // add the JvmtiEnvThreadState to each JvmtiThreadState - for (JvmtiThreadState *state = JvmtiThreadState::first(); state != NULL; state = state->next()) { + for (JvmtiThreadState *state = JvmtiThreadState::first(); state != nullptr; state = state->next()) { state->add_env(env); assert((JvmtiEnv*)(state->env_thread_state(env)->get_env()) == env, "sanity check"); } @@ -871,11 +871,11 @@ JvmtiEventControllerPrivate::env_dispose(JvmtiEnvBase *env) { // Before the environment is marked disposed, disable all events on this // environment (by zapping the callbacks). As a result, the disposed // environment will not call event handlers. - set_event_callbacks(env, NULL, 0); + set_event_callbacks(env, nullptr, 0); for (jint extension_event_index = EXT_MIN_EVENT_TYPE_VAL; extension_event_index <= EXT_MAX_EVENT_TYPE_VAL; ++extension_event_index) { - set_extension_event_callback(env, extension_event_index, NULL); + set_extension_event_callback(env, extension_event_index, nullptr); } // Let the environment finish disposing itself. @@ -889,18 +889,18 @@ JvmtiEventControllerPrivate::set_user_enabled(JvmtiEnvBase *env, JavaThread *thr assert(Threads::number_of_threads() == 0 || JvmtiThreadState_lock->is_locked(), "sanity check"); EC_TRACE(("[%s] # user %s event %s", - thread==NULL? "ALL": JvmtiTrace::safe_get_thread_name(thread), + thread==nullptr? "ALL": JvmtiTrace::safe_get_thread_name(thread), enabled? "enabled" : "disabled", JvmtiTrace::event_name(event_type))); - if (thread == NULL && thread_oop_h() == NULL) { - // NULL thread and NULL thread_oop now indicate setting globally instead - // of setting thread specific since NULL thread by itself means an + if (thread == nullptr && thread_oop_h() == nullptr) { + // null thread and null thread_oop now indicate setting globally instead + // of setting thread specific since null thread by itself means an // unmounted virtual thread. env->env_event_enable()->set_user_enabled(event_type, enabled); } else { // create the thread state (if it didn't exist before) JvmtiThreadState *state = JvmtiThreadState::state_for_while_locked(thread, thread_oop_h()); - if (state != NULL) { + if (state != nullptr) { state->env_thread_state(env)->event_enable()->set_user_enabled(event_type, enabled); } } diff --git a/src/hotspot/share/prims/jvmtiEventController.hpp b/src/hotspot/share/prims/jvmtiEventController.hpp index a53038adbd1a0..9b236b29204fb 100644 --- a/src/hotspot/share/prims/jvmtiEventController.hpp +++ b/src/hotspot/share/prims/jvmtiEventController.hpp @@ -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 @@ -210,14 +210,14 @@ class JvmtiEventController : AllStatic { && ((int)event_type <= TOTAL_MAX_EVENT_TYPE_VAL); } - // Use (thread == NULL) to enable/disable an event globally. - // Use (thread != NULL) to enable/disable an event for a particular thread. + // Use (thread == nullptr) to enable/disable an event globally. + // Use (thread != nullptr) to enable/disable an event for a particular thread. // thread is ignored for events that can only be specified globally static void set_user_enabled(JvmtiEnvBase *env, JavaThread *thread, oop thread_oop, jvmtiEvent event_type, bool enabled); // Setting callbacks changes computed enablement and must be done - // at a safepoint otherwise a NULL callback could be attempted + // at a safepoint otherwise a null callback could be attempted static void set_event_callbacks(JvmtiEnvBase *env, const jvmtiEventCallbacks* callbacks, jint size_of_callbacks); diff --git a/src/hotspot/share/prims/jvmtiExport.cpp b/src/hotspot/share/prims/jvmtiExport.cpp index 67e2e652c4871..b315c2f3b67dd 100644 --- a/src/hotspot/share/prims/jvmtiExport.cpp +++ b/src/hotspot/share/prims/jvmtiExport.cpp @@ -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 @@ -122,12 +122,12 @@ class JvmtiThreadEventTransition : StackObj { ThreadStateTransition::transition_from_vm(_jthread, _thread_in_native); } } else { - _jthread = NULL; + _jthread = nullptr; } } ~JvmtiThreadEventTransition() { - if (_jthread != NULL) + if (_jthread != nullptr) ThreadStateTransition::transition_from_native(_jthread, _saved_state); } }; @@ -151,7 +151,7 @@ class JvmtiEventMark : public StackObj { JvmtiThreadState *state = thread->jvmti_thread_state(); // we are before an event. // Save current jvmti thread exception state. - if (state != NULL) { + if (state != nullptr) { _saved_exception_state = state->get_exception_state(); } @@ -165,7 +165,7 @@ class JvmtiEventMark : public StackObj { JvmtiThreadState* state = _thread->jvmti_thread_state(); // we are continuing after an event. - if (state != NULL) { + if (state != nullptr) { // Restore the jvmti thread exception state. state->restore_exception_state(_saved_exception_state); } @@ -173,7 +173,7 @@ class JvmtiEventMark : public StackObj { jobject to_jobject(oop obj) { return JNIHandles::make_local(_thread,obj); } - jclass to_jclass(Klass* klass) { return (klass == NULL ? NULL : (jclass)to_jobject(klass->java_mirror())); } + jclass to_jclass(Klass* klass) { return (klass == nullptr ? nullptr : (jclass)to_jobject(klass->java_mirror())); } jmethodID to_jmethodID(const methodHandle& method) { return method->jmethod_id(); } @@ -199,7 +199,7 @@ class JvmtiVirtualThreadEventMark : public JvmtiEventMark { public: JvmtiVirtualThreadEventMark(JavaThread *thread) : JvmtiEventMark(thread) { - assert(thread->vthread() != NULL || thread->threadObj() == NULL, "sanity check"); + assert(thread->vthread() != nullptr || thread->threadObj() == nullptr, "sanity check"); _jthread = to_jobject(thread->vthread()); }; jthread jni_thread() { return (jthread)_jthread; } @@ -260,11 +260,11 @@ class JvmtiClassFileLoadEventMark : public JvmtiThreadEventMark { public: JvmtiClassFileLoadEventMark(JavaThread *thread, Symbol* name, Handle class_loader, Handle prot_domain, Klass* class_being_redefined) : JvmtiThreadEventMark(thread) { - _class_name = name != NULL? name->as_utf8() : NULL; + _class_name = name != nullptr? name->as_utf8() : nullptr; _jloader = (jobject)to_jobject(class_loader()); _protection_domain = (jobject)to_jobject(prot_domain()); - if (class_being_redefined == NULL) { - _class_being_redefined = NULL; + if (class_being_redefined == nullptr) { + _class_being_redefined = nullptr; } else { _class_being_redefined = (jclass)to_jclass(class_being_redefined); } @@ -405,7 +405,7 @@ JvmtiExport::get_jvmti_interface(JavaVM *jvm, void **penv, jint version) { } else { // Called at the wrong time - *penv = NULL; + *penv = nullptr; return JNI_EDETACHED; } } @@ -635,7 +635,7 @@ void JvmtiExport::post_early_vm_start() { JvmtiEventController::vm_start(); JvmtiEnvIterator it; - for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { + for (JvmtiEnv* env = it.first(); env != nullptr; env = it.next(env)) { // Only early vmstart envs post early VMStart event if (env->early_vmstart_env() && env->is_enabled(JVMTI_EVENT_VM_START)) { EVT_TRACE(JVMTI_EVENT_VM_START, ("Evt Early VM start event sent" )); @@ -643,7 +643,7 @@ void JvmtiExport::post_early_vm_start() { JvmtiThreadEventMark jem(thread); JvmtiJavaThreadEventTransition jet(thread); jvmtiEventVMStart callback = env->callbacks()->VMStart; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external(), jem.jni_env()); } } @@ -657,7 +657,7 @@ void JvmtiExport::post_vm_start() { JvmtiEventController::vm_start(); JvmtiEnvIterator it; - for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { + for (JvmtiEnv* env = it.first(); env != nullptr; env = it.next(env)) { // Early vmstart envs do not post normal VMStart event if (!env->early_vmstart_env() && env->is_enabled(JVMTI_EVENT_VM_START)) { EVT_TRACE(JVMTI_EVENT_VM_START, ("Evt VM start event sent" )); @@ -666,23 +666,23 @@ void JvmtiExport::post_vm_start() { JvmtiThreadEventMark jem(thread); JvmtiJavaThreadEventTransition jet(thread); jvmtiEventVMStart callback = env->callbacks()->VMStart; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external(), jem.jni_env()); } } } } -static OopStorage* _jvmti_oop_storage = NULL; -static OopStorage* _weak_tag_storage = NULL; +static OopStorage* _jvmti_oop_storage = nullptr; +static OopStorage* _weak_tag_storage = nullptr; OopStorage* JvmtiExport::jvmti_oop_storage() { - assert(_jvmti_oop_storage != NULL, "not yet initialized"); + assert(_jvmti_oop_storage != nullptr, "not yet initialized"); return _jvmti_oop_storage; } OopStorage* JvmtiExport::weak_tag_storage() { - assert(_weak_tag_storage != NULL, "not yet initialized"); + assert(_weak_tag_storage != nullptr, "not yet initialized"); return _weak_tag_storage; } @@ -701,7 +701,7 @@ void JvmtiExport::post_vm_initialized() { JvmtiEventController::vm_init(); JvmtiEnvIterator it; - for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { + for (JvmtiEnv* env = it.first(); env != nullptr; env = it.next(env)) { if (env->is_enabled(JVMTI_EVENT_VM_INIT)) { EVT_TRACE(JVMTI_EVENT_VM_INIT, ("Evt VM init event sent" )); @@ -709,7 +709,7 @@ void JvmtiExport::post_vm_initialized() { JvmtiThreadEventMark jem(thread); JvmtiJavaThreadEventTransition jet(thread); jvmtiEventVMInit callback = env->callbacks()->VMInit; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread()); } } @@ -723,7 +723,7 @@ void JvmtiExport::post_vm_death() { JvmtiTagMap::flush_all_object_free_events(); JvmtiEnvIterator it; - for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { + for (JvmtiEnv* env = it.first(); env != nullptr; env = it.next(env)) { if (env->is_enabled(JVMTI_EVENT_VM_DEATH)) { EVT_TRACE(JVMTI_EVENT_VM_DEATH, ("Evt VM death event sent" )); @@ -731,7 +731,7 @@ void JvmtiExport::post_vm_death() { JvmtiEventMark jem(thread); JvmtiJavaThreadEventTransition jet(thread); jvmtiEventVMDeath callback = env->callbacks()->VMDeath; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external(), jem.jni_env()); } } @@ -757,7 +757,7 @@ JvmtiExport::get_all_native_method_prefixes(int* count_ptr) { // specified ThreadsList. The ThreadsListHandle in the caller "protects" // the returned JavaThread *. // -// If thread_oop_p is not NULL, then the caller wants to use the oop +// If thread_oop_p is not null, then the caller wants to use the oop // after this call so the oop is returned. On success, *jt_pp is set // to the converted JavaThread * and JVMTI_ERROR_NONE is returned. // On error, returns various JVMTI_ERROR_* values. @@ -767,17 +767,17 @@ JvmtiExport::cv_external_thread_to_JavaThread(ThreadsList * t_list, jthread thread, JavaThread ** jt_pp, oop * thread_oop_p) { - assert(t_list != NULL, "must have a ThreadsList"); - assert(jt_pp != NULL, "must have a return JavaThread pointer"); + assert(t_list != nullptr, "must have a ThreadsList"); + assert(jt_pp != nullptr, "must have a return JavaThread pointer"); // thread_oop_p is optional so no assert() - if (thread_oop_p != NULL) { - *thread_oop_p = NULL; + if (thread_oop_p != nullptr) { + *thread_oop_p = nullptr; } oop thread_oop = JNIHandles::resolve_external_guard(thread); - if (thread_oop == NULL) { - // NULL jthread, GC'ed jthread or a bad JNI handle. + if (thread_oop == nullptr) { + // null jthread, GC'ed jthread or a bad JNI handle. return JVMTI_ERROR_INVALID_THREAD; } // Looks like an oop at this point. @@ -788,14 +788,14 @@ JvmtiExport::cv_external_thread_to_JavaThread(ThreadsList * t_list, } // Looks like a java.lang.Thread oop at this point. - if (thread_oop_p != NULL) { + if (thread_oop_p != nullptr) { // Return the oop to the caller; the caller may still want // the oop even if this function returns an error. *thread_oop_p = thread_oop; } JavaThread * java_thread = java_lang_Thread::thread(thread_oop); - if (java_thread == NULL) { + if (java_thread == nullptr) { if (java_lang_VirtualThread::is_instance(thread_oop)) { return JVMTI_ERROR_INVALID_THREAD; } @@ -830,9 +830,9 @@ JvmtiExport::cv_external_thread_to_JavaThread(ThreadsList * t_list, jvmtiError JvmtiExport::cv_oop_to_JavaThread(ThreadsList * t_list, oop thread_oop, JavaThread ** jt_pp) { - assert(t_list != NULL, "must have a ThreadsList"); - assert(thread_oop != NULL, "must have an oop"); - assert(jt_pp != NULL, "must have a return JavaThread pointer"); + assert(t_list != nullptr, "must have a ThreadsList"); + assert(thread_oop != nullptr, "must have an oop"); + assert(jt_pp != nullptr, "must have a return JavaThread pointer"); if (!thread_oop->is_a(vmClasses::Thread_klass())) { // The oop is not a java.lang.Thread. @@ -841,7 +841,7 @@ JvmtiExport::cv_oop_to_JavaThread(ThreadsList * t_list, oop thread_oop, // Looks like a java.lang.Thread oop at this point. JavaThread * java_thread = java_lang_Thread::thread(thread_oop); - if (java_thread == NULL) { + if (java_thread == nullptr) { // The java.lang.Thread does not contain a JavaThread * so it has // not yet run or it has died. return JVMTI_ERROR_THREAD_NOT_ALIVE; @@ -892,21 +892,21 @@ class JvmtiClassFileLoadHookPoster : public StackObj { _thread = JavaThread::current(); _curr_len = *end_ptr - *data_ptr; _curr_data = *data_ptr; - _curr_env = NULL; + _curr_env = nullptr; _cached_class_file_ptr = cache_ptr; _has_been_modified = false; assert(!_thread->is_in_any_VTMS_transition(), "CFLH events are not allowed in any VTMS transition"); _state = _thread->jvmti_thread_state(); - if (_state != NULL) { + if (_state != nullptr) { _class_being_redefined = _state->get_class_being_redefined(); _load_kind = _state->get_class_load_kind(); - Klass* klass = (_class_being_redefined == NULL) ? NULL : _class_being_redefined; - if (_load_kind != jvmti_class_load_kind_load && klass != NULL) { + Klass* klass = (_class_being_redefined == nullptr) ? nullptr : _class_being_redefined; + if (_load_kind != jvmti_class_load_kind_load && klass != nullptr) { ModuleEntry* module_entry = InstanceKlass::cast(klass)->module(); - assert(module_entry != NULL, "module_entry should always be set"); + assert(module_entry != nullptr, "module_entry should always be set"); if (module_entry->is_named() && - module_entry->module() != NULL && + module_entry->module() != nullptr && !module_entry->has_default_read_edges()) { if (!module_entry->set_has_default_read_edges()) { // We won a potential race. @@ -924,7 +924,7 @@ class JvmtiClassFileLoadHookPoster : public StackObj { _state->clear_class_being_redefined(); } else { // redefine and retransform will always set the thread state - _class_being_redefined = NULL; + _class_being_redefined = nullptr; _load_kind = jvmti_class_load_kind_load; } } @@ -942,7 +942,7 @@ class JvmtiClassFileLoadHookPoster : public StackObj { // for class load and redefine, // call the non-retransformable agents JvmtiEnvIterator it; - for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { + for (JvmtiEnv* env = it.first(); env != nullptr; env = it.next(env)) { if (!env->is_retransformable() && env->is_enabled(JVMTI_EVENT_CLASS_FILE_LOAD_HOOK)) { // non-retransformable agents cannot retransform back, // so no need to cache the original class file bytes @@ -951,7 +951,7 @@ class JvmtiClassFileLoadHookPoster : public StackObj { } } JvmtiEnvIterator it; - for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { + for (JvmtiEnv* env = it.first(); env != nullptr; env = it.next(env)) { // retransformable agents get all events if (env->is_retransformable() && env->is_enabled(JVMTI_EVENT_CLASS_FILE_LOAD_HOOK)) { // retransformable agents need to cache the original class file @@ -965,14 +965,14 @@ class JvmtiClassFileLoadHookPoster : public StackObj { if (env->phase() == JVMTI_PHASE_PRIMORDIAL && !env->early_class_hook_env()) { return; } - unsigned char *new_data = NULL; + unsigned char *new_data = nullptr; jint new_len = 0; JvmtiClassFileLoadEventMark jem(_thread, _h_name, _class_loader, _h_protection_domain, _class_being_redefined); JvmtiJavaThreadEventTransition jet(_thread); jvmtiEventClassFileLoadHook callback = env->callbacks()->ClassFileLoadHook; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external(), jem.jni_env(), jem.class_being_redefined(), jem.jloader(), jem.class_name(), @@ -980,16 +980,16 @@ class JvmtiClassFileLoadHookPoster : public StackObj { _curr_len, _curr_data, &new_len, &new_data); } - if (new_data != NULL) { + if (new_data != nullptr) { // this agent has modified class data. _has_been_modified = true; - if (caching_needed && *_cached_class_file_ptr == NULL) { + if (caching_needed && *_cached_class_file_ptr == nullptr) { // data has been changed by the new retransformable agent // and it hasn't already been cached, cache it JvmtiCachedClassFileData *p; p = (JvmtiCachedClassFileData *)os::malloc( offset_of(JvmtiCachedClassFileData, data) + _curr_len, mtInternal); - if (p == NULL) { + if (p == nullptr) { vm_exit_out_of_memory(offset_of(JvmtiCachedClassFileData, data) + _curr_len, OOM_MALLOC_ERROR, "unable to allocate cached copy of original class bytes"); @@ -1033,7 +1033,7 @@ bool JvmtiExport::is_early_phase() { bool JvmtiExport::has_early_class_hook_env() { JvmtiEnvIterator it; - for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { + for (JvmtiEnv* env = it.first(); env != nullptr; env = it.next(env)) { if (env->early_class_hook_env()) { return true; } @@ -1081,7 +1081,7 @@ static inline Klass* oop_to_klass(oop obj) { if (k == vmClasses::Class_klass()) { if (!java_lang_Class::is_primitive(obj)) { k = java_lang_Class::as_Klass(obj); - assert(k != NULL, "class for non-primitive mirror must exist"); + assert(k != nullptr, "class for non-primitive mirror must exist"); } } return k; @@ -1108,11 +1108,11 @@ class JvmtiCompiledMethodLoadEventMark : public JvmtiMethodEventMark { jvmtiAddrLocationMap *_map; const void *_compile_info; public: - JvmtiCompiledMethodLoadEventMark(JavaThread *thread, nmethod *nm, void* compile_info_ptr = NULL) + JvmtiCompiledMethodLoadEventMark(JavaThread *thread, nmethod *nm, void* compile_info_ptr = nullptr) : JvmtiMethodEventMark(thread,methodHandle(thread, nm->method())) { _code_data = nm->code_begin(); _code_size = nm->code_size(); - _compile_info = compile_info_ptr; // Set void pointer of compiledMethodLoad Event. Default value is NULL. + _compile_info = compile_info_ptr; // Set void pointer of compiledMethodLoad Event. Default value is null. JvmtiCodeBlobEvents::build_jvmti_addr_location_map(nm, &_map, &_map_length); } ~JvmtiCompiledMethodLoadEventMark() { @@ -1156,7 +1156,7 @@ void JvmtiExport::post_compiled_method_unload( // post the event for each environment that has this event enabled. JvmtiEnvIterator it; - for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { + for (JvmtiEnv* env = it.first(); env != nullptr; env = it.next(env)) { if (env->is_enabled(JVMTI_EVENT_COMPILED_METHOD_UNLOAD)) { if (env->phase() == JVMTI_PHASE_PRIMORDIAL) { continue; @@ -1170,7 +1170,7 @@ void JvmtiExport::post_compiled_method_unload( JvmtiEventMark jem(thread); JvmtiJavaThreadEventTransition jet(thread); jvmtiEventCompiledMethodUnload callback = env->callbacks()->CompiledMethodUnload; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external(), method, code_begin); } } @@ -1187,7 +1187,7 @@ void JvmtiExport::post_raw_breakpoint(JavaThread *thread, Method* method, addres methodHandle mh(thread, method); JvmtiThreadState *state = thread->jvmti_thread_state(); - if (state == NULL) { + if (state == nullptr) { return; } if (thread->is_in_any_VTMS_transition()) { @@ -1197,22 +1197,22 @@ void JvmtiExport::post_raw_breakpoint(JavaThread *thread, Method* method, addres EVT_TRIG_TRACE(JVMTI_EVENT_BREAKPOINT, ("[%s] Trg Breakpoint triggered", JvmtiTrace::safe_get_thread_name(thread))); JvmtiEnvThreadStateIterator it(state); - for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { + for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) { ets->compare_and_set_current_location(mh(), location, JVMTI_EVENT_BREAKPOINT); if (!ets->breakpoint_posted() && ets->is_enabled(JVMTI_EVENT_BREAKPOINT)) { ThreadState old_os_state = thread->osthread()->get_state(); thread->osthread()->set_state(BREAKPOINTED); EVT_TRACE(JVMTI_EVENT_BREAKPOINT, ("[%s] Evt Breakpoint sent %s.%s @ " INTX_FORMAT, JvmtiTrace::safe_get_thread_name(thread), - (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(), - (mh() == NULL) ? "NULL" : mh()->name()->as_C_string(), + (mh() == nullptr) ? "null" : mh()->klass_name()->as_C_string(), + (mh() == nullptr) ? "null" : mh()->name()->as_C_string(), location - mh()->code_base() )); JvmtiEnv *env = ets->get_env(); JvmtiLocationEventMark jem(thread, mh, location); JvmtiJavaThreadEventTransition jet(thread); jvmtiEventBreakpoint callback = env->callbacks()->Breakpoint; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(), jem.jni_methodID(), jem.location()); } @@ -1277,7 +1277,7 @@ bool JvmtiExport::_should_post_vthread_unmount = fals void JvmtiExport::check_vthread_and_suspend_at_safepoint(JavaThread *thread) { oop vt = thread->jvmti_vthread(); - if (vt != NULL && java_lang_VirtualThread::is_instance(vt)) { + if (vt != nullptr && java_lang_VirtualThread::is_instance(vt)) { int64_t id = java_lang_Thread::thread_id(vt); ThreadBlockInVM tbivm(thread); @@ -1301,7 +1301,7 @@ void JvmtiExport::at_single_stepping_point(JavaThread *thread, Method* method, a // update information about current location and post a step event JvmtiThreadState *state = thread->jvmti_thread_state(); - if (state == NULL) { + if (state == nullptr) { return; } EVT_TRIG_TRACE(JVMTI_EVENT_SINGLE_STEP, ("[%s] Trg Single Step triggered", @@ -1320,7 +1320,7 @@ void JvmtiExport::at_single_stepping_point(JavaThread *thread, Method* method, a void JvmtiExport::expose_single_stepping(JavaThread *thread) { JvmtiThreadState *state = thread->jvmti_thread_state(); - if (state != NULL) { + if (state != nullptr) { state->clear_hide_single_stepping(); } } @@ -1328,7 +1328,7 @@ void JvmtiExport::expose_single_stepping(JavaThread *thread) { bool JvmtiExport::hide_single_stepping(JavaThread *thread) { JvmtiThreadState *state = thread->jvmti_thread_state(); - if (state != NULL && state->is_enabled(JVMTI_EVENT_SINGLE_STEP)) { + if (state != nullptr && state->is_enabled(JVMTI_EVENT_SINGLE_STEP)) { state->set_hide_single_stepping(); return true; } else { @@ -1343,7 +1343,7 @@ void JvmtiExport::post_class_load(JavaThread *thread, Klass* klass) { HandleMark hm(thread); JvmtiThreadState* state = thread->jvmti_thread_state(); - if (state == NULL) { + if (state == nullptr) { return; } if (thread->is_in_tmp_VTMS_transition()) { @@ -1354,7 +1354,7 @@ void JvmtiExport::post_class_load(JavaThread *thread, Klass* klass) { EVT_TRIG_TRACE(JVMTI_EVENT_CLASS_LOAD, ("[%s] Trg Class Load triggered", JvmtiTrace::safe_get_thread_name(thread))); JvmtiEnvThreadStateIterator it(state); - for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { + for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) { if (ets->is_enabled(JVMTI_EVENT_CLASS_LOAD)) { JvmtiEnv *env = ets->get_env(); if (env->phase() == JVMTI_PHASE_PRIMORDIAL) { @@ -1362,11 +1362,11 @@ void JvmtiExport::post_class_load(JavaThread *thread, Klass* klass) { } EVT_TRACE(JVMTI_EVENT_CLASS_LOAD, ("[%s] Evt Class Load sent %s", JvmtiTrace::safe_get_thread_name(thread), - klass==NULL? "NULL" : klass->external_name() )); + klass==nullptr? "null" : klass->external_name() )); JvmtiClassEventMark jem(thread, klass); JvmtiJavaThreadEventTransition jet(thread); jvmtiEventClassLoad callback = env->callbacks()->ClassLoad; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(), jem.jni_class()); } } @@ -1381,7 +1381,7 @@ void JvmtiExport::post_class_prepare(JavaThread *thread, Klass* klass) { HandleMark hm(thread); JvmtiThreadState* state = thread->jvmti_thread_state(); - if (state == NULL) { + if (state == nullptr) { return; } if (thread->is_in_tmp_VTMS_transition()) { @@ -1392,7 +1392,7 @@ void JvmtiExport::post_class_prepare(JavaThread *thread, Klass* klass) { EVT_TRIG_TRACE(JVMTI_EVENT_CLASS_PREPARE, ("[%s] Trg Class Prepare triggered", JvmtiTrace::safe_get_thread_name(thread))); JvmtiEnvThreadStateIterator it(state); - for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { + for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) { if (ets->is_enabled(JVMTI_EVENT_CLASS_PREPARE)) { JvmtiEnv *env = ets->get_env(); if (env->phase() == JVMTI_PHASE_PRIMORDIAL) { @@ -1400,11 +1400,11 @@ void JvmtiExport::post_class_prepare(JavaThread *thread, Klass* klass) { } EVT_TRACE(JVMTI_EVENT_CLASS_PREPARE, ("[%s] Evt Class Prepare sent %s", JvmtiTrace::safe_get_thread_name(thread), - klass==NULL? "NULL" : klass->external_name() )); + klass==nullptr? "null" : klass->external_name() )); JvmtiClassEventMark jem(thread, klass); JvmtiJavaThreadEventTransition jet(thread); jvmtiEventClassPrepare callback = env->callbacks()->ClassPrepare; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(), jem.jni_class()); } } @@ -1437,7 +1437,7 @@ void JvmtiExport::post_class_unload_internal(const char* name) { if (JvmtiEventController::is_enabled((jvmtiEvent)EXT_EVENT_CLASS_UNLOAD)) { JvmtiEnvIterator it; - for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { + for (JvmtiEnv* env = it.first(); env != nullptr; env = it.next(env)) { if (env->phase() == JVMTI_PHASE_PRIMORDIAL) { continue; } @@ -1447,7 +1447,7 @@ void JvmtiExport::post_class_unload_internal(const char* name) { JvmtiEventMark jem(thread); JvmtiJavaThreadEventTransition jet(thread); jvmtiExtensionEvent callback = env->ext_callbacks()->ClassUnload; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external(), jem.jni_env(), name); } } @@ -1472,7 +1472,7 @@ void JvmtiExport::post_thread_start(JavaThread *thread) { if (JvmtiEventController::is_enabled(JVMTI_EVENT_THREAD_START) && !thread->is_hidden_from_external_view()) { JvmtiEnvIterator it; - for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { + for (JvmtiEnv* env = it.first(); env != nullptr; env = it.next(env)) { if (env->phase() == JVMTI_PHASE_PRIMORDIAL) { continue; } @@ -1483,7 +1483,7 @@ void JvmtiExport::post_thread_start(JavaThread *thread) { JvmtiVirtualThreadEventMark jem(thread); JvmtiJavaThreadEventTransition jet(thread); jvmtiEventThreadStart callback = env->callbacks()->ThreadStart; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread()); } } @@ -1500,7 +1500,7 @@ void JvmtiExport::post_thread_end(JavaThread *thread) { JvmtiTrace::safe_get_thread_name(thread))); JvmtiThreadState *state = thread->jvmti_thread_state(); - if (state == NULL) { + if (state == nullptr) { return; } @@ -1509,7 +1509,7 @@ void JvmtiExport::post_thread_end(JavaThread *thread) { !thread->is_hidden_from_external_view()) { JvmtiEnvThreadStateIterator it(state); - for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { + for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) { if (ets->is_enabled(JVMTI_EVENT_THREAD_END)) { JvmtiEnv *env = ets->get_env(); if (env->phase() == JVMTI_PHASE_PRIMORDIAL) { @@ -1521,7 +1521,7 @@ void JvmtiExport::post_thread_end(JavaThread *thread) { JvmtiVirtualThreadEventMark jem(thread); JvmtiJavaThreadEventTransition jet(thread); jvmtiEventThreadEnd callback = env->callbacks()->ThreadEnd; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread()); } } @@ -1538,14 +1538,14 @@ void JvmtiExport::post_vthread_start(jobject vthread) { JavaThread *cur_thread = JavaThread::current(); JvmtiThreadState *state = cur_thread->jvmti_thread_state(); - if (state == NULL) { + if (state == nullptr) { return; } if (state->is_enabled(JVMTI_EVENT_VIRTUAL_THREAD_START)) { JvmtiEnvThreadStateIterator it(state); - for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { + for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) { JvmtiEnv *env = ets->get_env(); if (env->phase() == JVMTI_PHASE_PRIMORDIAL) { continue; @@ -1556,7 +1556,7 @@ void JvmtiExport::post_vthread_start(jobject vthread) { JvmtiVirtualThreadEventMark jem(cur_thread); JvmtiJavaThreadEventTransition jet(cur_thread); jvmtiEventVirtualThreadStart callback = env->callbacks()->VirtualThreadStart; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread()); } } @@ -1572,14 +1572,14 @@ void JvmtiExport::post_vthread_end(jobject vthread) { JavaThread *cur_thread = JavaThread::current(); JvmtiThreadState *state = cur_thread->jvmti_thread_state(); - if (state == NULL) { + if (state == nullptr) { return; } if (state->is_enabled(JVMTI_EVENT_VIRTUAL_THREAD_END)) { JvmtiEnvThreadStateIterator it(state); - for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { + for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) { JvmtiEnv *env = ets->get_env(); if (env->phase() == JVMTI_PHASE_PRIMORDIAL) { continue; @@ -1590,7 +1590,7 @@ void JvmtiExport::post_vthread_end(jobject vthread) { JvmtiVirtualThreadEventMark jem(cur_thread); JvmtiJavaThreadEventTransition jet(cur_thread); jvmtiEventVirtualThreadEnd callback = env->callbacks()->VirtualThreadEnd; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external(), jem.jni_env(), vthread); } } @@ -1607,14 +1607,14 @@ void JvmtiExport::post_vthread_mount(jobject vthread) { EVT_TRIG_TRACE(EXT_EVENT_VIRTUAL_THREAD_MOUNT, ("[%p] Trg Virtual Thread Mount event triggered", vthread)); JvmtiThreadState *state = thread->jvmti_thread_state(); - if (state == NULL) { + if (state == nullptr) { return; } if (state->is_enabled((jvmtiEvent)EXT_EVENT_VIRTUAL_THREAD_MOUNT)) { JvmtiEnvThreadStateIterator it(state); - for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { + for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) { JvmtiEnv *env = ets->get_env(); if (env->phase() == JVMTI_PHASE_PRIMORDIAL) { continue; @@ -1625,7 +1625,7 @@ void JvmtiExport::post_vthread_mount(jobject vthread) { JvmtiVirtualThreadEventMark jem(thread); JvmtiJavaThreadEventTransition jet(thread); jvmtiExtensionEvent callback = env->ext_callbacks()->VirtualThreadMount; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread()); } } @@ -1642,14 +1642,14 @@ void JvmtiExport::post_vthread_unmount(jobject vthread) { EVT_TRIG_TRACE(EXT_EVENT_VIRTUAL_THREAD_UNMOUNT, ("[%p] Trg Virtual Thread Unmount event triggered", vthread)); JvmtiThreadState *state = thread->jvmti_thread_state(); - if (state == NULL) { + if (state == nullptr) { return; } if (state->is_enabled((jvmtiEvent)EXT_EVENT_VIRTUAL_THREAD_UNMOUNT)) { JvmtiEnvThreadStateIterator it(state); - for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { + for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) { JvmtiEnv *env = ets->get_env(); if (env->phase() == JVMTI_PHASE_PRIMORDIAL) { continue; @@ -1660,7 +1660,7 @@ void JvmtiExport::post_vthread_unmount(jobject vthread) { JvmtiVirtualThreadEventMark jem(thread); JvmtiJavaThreadEventTransition jet(thread); jvmtiExtensionEvent callback = env->ext_callbacks()->VirtualThreadUnmount; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread()); } } @@ -1675,7 +1675,7 @@ void JvmtiExport::continuation_yield_cleanup(JavaThread* thread, jint continuati assert(thread == JavaThread::current(), "must be"); JvmtiThreadState *state = thread->jvmti_thread_state(); - if (state == NULL) { + if (state == nullptr) { return; } state->invalidate_cur_stack_depth(); @@ -1685,7 +1685,7 @@ void JvmtiExport::continuation_yield_cleanup(JavaThread* thread, jint continuati JvmtiEnvThreadStateIterator it(state); int top_frame_num = state->cur_stack_depth() + continuation_frame_count; - for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { + for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) { if (!ets->has_frame_pops()) { continue; } @@ -1703,7 +1703,7 @@ void JvmtiExport::continuation_yield_cleanup(JavaThread* thread, jint continuati } void JvmtiExport::post_object_free(JvmtiEnv* env, GrowableArray* objects) { - assert(objects != NULL, "Nothing to post"); + assert(objects != nullptr, "Nothing to post"); JavaThread *javaThread = JavaThread::current(); if (javaThread->is_in_any_VTMS_transition()) { @@ -1719,7 +1719,7 @@ void JvmtiExport::post_object_free(JvmtiEnv* env, GrowableArray* objects) JvmtiThreadEventMark jem(javaThread); JvmtiJavaThreadEventTransition jet(javaThread); jvmtiEventObjectFree callback = env->callbacks()->ObjectFree; - if (callback != NULL) { + if (callback != nullptr) { for (int index = 0; index < objects->length(); index++) { (*callback)(env->jvmti_external(), objects->at(index)); } @@ -1749,16 +1749,16 @@ void JvmtiExport::post_resource_exhausted(jint resource_exhausted_flags, const c EVT_TRIG_TRACE(JVMTI_EVENT_RESOURCE_EXHAUSTED, ("Trg resource exhausted event triggered" )); JvmtiEnvIterator it; - for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { + for (JvmtiEnv* env = it.first(); env != nullptr; env = it.next(env)) { if (env->is_enabled(JVMTI_EVENT_RESOURCE_EXHAUSTED)) { EVT_TRACE(JVMTI_EVENT_RESOURCE_EXHAUSTED, ("Evt resource exhausted event sent" )); JvmtiThreadEventMark jem(thread); JvmtiJavaThreadEventTransition jet(thread); jvmtiEventResourceExhausted callback = env->callbacks()->ResourceExhausted; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external(), jem.jni_env(), - resource_exhausted_flags, NULL, description); + resource_exhausted_flags, nullptr, description); } } } @@ -1769,7 +1769,7 @@ void JvmtiExport::post_method_entry(JavaThread *thread, Method* method, frame cu methodHandle mh(thread, method); JvmtiThreadState* state = thread->jvmti_thread_state(); - if (state == NULL || !state->is_interp_only_mode()) { + if (state == nullptr || !state->is_interp_only_mode()) { // for any thread that actually wants method entry, interp_only_mode is set return; } @@ -1778,25 +1778,25 @@ void JvmtiExport::post_method_entry(JavaThread *thread, Method* method, frame cu } EVT_TRIG_TRACE(JVMTI_EVENT_METHOD_ENTRY, ("[%s] Trg Method Entry triggered %s.%s", JvmtiTrace::safe_get_thread_name(thread), - (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(), - (mh() == NULL) ? "NULL" : mh()->name()->as_C_string() )); + (mh() == nullptr) ? "null" : mh()->klass_name()->as_C_string(), + (mh() == nullptr) ? "null" : mh()->name()->as_C_string() )); state->incr_cur_stack_depth(); if (state->is_enabled(JVMTI_EVENT_METHOD_ENTRY)) { JvmtiEnvThreadStateIterator it(state); - for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { + for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) { if (ets->is_enabled(JVMTI_EVENT_METHOD_ENTRY)) { EVT_TRACE(JVMTI_EVENT_METHOD_ENTRY, ("[%s] Evt Method Entry sent %s.%s", JvmtiTrace::safe_get_thread_name(thread), - (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(), - (mh() == NULL) ? "NULL" : mh()->name()->as_C_string() )); + (mh() == nullptr) ? "null" : mh()->klass_name()->as_C_string(), + (mh() == nullptr) ? "null" : mh()->name()->as_C_string() )); JvmtiEnv *env = ets->get_env(); JvmtiMethodEventMark jem(thread, mh); JvmtiJavaThreadEventTransition jet(thread); jvmtiEventMethodEntry callback = env->callbacks()->MethodEntry; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(), jem.jni_methodID()); } } @@ -1810,7 +1810,7 @@ void JvmtiExport::post_method_exit(JavaThread* thread, Method* method, frame cur JvmtiThreadState *state = thread->jvmti_thread_state(); - if (state == NULL || !state->is_interp_only_mode()) { + if (state == nullptr || !state->is_interp_only_mode()) { // for any thread that actually wants method exit, interp_only_mode is set return; } @@ -1863,23 +1863,23 @@ void JvmtiExport::post_method_exit_inner(JavaThread* thread, EVT_TRIG_TRACE(JVMTI_EVENT_METHOD_EXIT, ("[%s] Trg Method Exit triggered %s.%s", JvmtiTrace::safe_get_thread_name(thread), - (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(), - (mh() == NULL) ? "NULL" : mh()->name()->as_C_string() )); + (mh() == nullptr) ? "null" : mh()->klass_name()->as_C_string(), + (mh() == nullptr) ? "null" : mh()->name()->as_C_string() )); if (state->is_enabled(JVMTI_EVENT_METHOD_EXIT)) { JvmtiEnvThreadStateIterator it(state); - for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { + for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) { if (ets->is_enabled(JVMTI_EVENT_METHOD_EXIT)) { EVT_TRACE(JVMTI_EVENT_METHOD_EXIT, ("[%s] Evt Method Exit sent %s.%s", JvmtiTrace::safe_get_thread_name(thread), - (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(), - (mh() == NULL) ? "NULL" : mh()->name()->as_C_string() )); + (mh() == nullptr) ? "null" : mh()->klass_name()->as_C_string(), + (mh() == nullptr) ? "null" : mh()->name()->as_C_string() )); JvmtiEnv *env = ets->get_env(); JvmtiMethodEventMark jem(thread, mh); JvmtiJavaThreadEventTransition jet(thread); jvmtiEventMethodExit callback = env->callbacks()->MethodExit; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(), jem.jni_methodID(), exception_exit, value); } @@ -1888,7 +1888,7 @@ void JvmtiExport::post_method_exit_inner(JavaThread* thread, } JvmtiEnvThreadStateIterator it(state); - for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { + for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) { if (ets->has_frame_pops()) { int cur_frame_number = state->cur_stack_depth(); @@ -1898,15 +1898,15 @@ void JvmtiExport::post_method_exit_inner(JavaThread* thread, if (ets->is_enabled(JVMTI_EVENT_FRAME_POP)) { EVT_TRACE(JVMTI_EVENT_FRAME_POP, ("[%s] Evt Frame Pop sent %s.%s", JvmtiTrace::safe_get_thread_name(thread), - (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(), - (mh() == NULL) ? "NULL" : mh()->name()->as_C_string() )); + (mh() == nullptr) ? "null" : mh()->klass_name()->as_C_string(), + (mh() == nullptr) ? "null" : mh()->name()->as_C_string() )); // we also need to issue a frame pop event for this frame JvmtiEnv *env = ets->get_env(); JvmtiMethodEventMark jem(thread, mh); JvmtiJavaThreadEventTransition jet(thread); jvmtiEventFramePop callback = env->callbacks()->FramePop; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(), jem.jni_methodID(), exception_exit); } @@ -1930,7 +1930,7 @@ void JvmtiExport::post_single_step(JavaThread *thread, Method* method, address l methodHandle mh(thread, method); JvmtiThreadState *state = thread->jvmti_thread_state(); - if (state == NULL) { + if (state == nullptr) { return; } if (mh->jvmti_mount_transition() || thread->is_in_any_VTMS_transition()) { @@ -1938,20 +1938,20 @@ void JvmtiExport::post_single_step(JavaThread *thread, Method* method, address l } JvmtiEnvThreadStateIterator it(state); - for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { + for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) { ets->compare_and_set_current_location(mh(), location, JVMTI_EVENT_SINGLE_STEP); if (!ets->single_stepping_posted() && ets->is_enabled(JVMTI_EVENT_SINGLE_STEP)) { EVT_TRACE(JVMTI_EVENT_SINGLE_STEP, ("[%s] Evt Single Step sent %s.%s @ " INTX_FORMAT, JvmtiTrace::safe_get_thread_name(thread), - (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(), - (mh() == NULL) ? "NULL" : mh()->name()->as_C_string(), + (mh() == nullptr) ? "null" : mh()->klass_name()->as_C_string(), + (mh() == nullptr) ? "null" : mh()->name()->as_C_string(), location - mh()->code_base() )); JvmtiEnv *env = ets->get_env(); JvmtiLocationEventMark jem(thread, mh, location); JvmtiJavaThreadEventTransition jet(thread); jvmtiEventSingleStep callback = env->callbacks()->SingleStep; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(), jem.jni_methodID(), jem.location()); } @@ -1972,7 +1972,7 @@ void JvmtiExport::post_exception_throw(JavaThread *thread, Method* method, addre KeepStackGCProcessedMark ksgcpm(thread); JvmtiThreadState *state = thread->jvmti_thread_state(); - if (state == NULL) { + if (state == nullptr) { return; } if (thread->is_in_any_VTMS_transition()) { @@ -1984,14 +1984,14 @@ void JvmtiExport::post_exception_throw(JavaThread *thread, Method* method, addre if (!state->is_exception_detected()) { state->set_exception_detected(); JvmtiEnvThreadStateIterator it(state); - for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { - if (ets->is_enabled(JVMTI_EVENT_EXCEPTION) && (exception != NULL)) { + for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) { + if (ets->is_enabled(JVMTI_EVENT_EXCEPTION) && (exception != nullptr)) { EVT_TRACE(JVMTI_EVENT_EXCEPTION, ("[%s] Evt Exception thrown sent %s.%s @ " INTX_FORMAT, JvmtiTrace::safe_get_thread_name(thread), - (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(), - (mh() == NULL) ? "NULL" : mh()->name()->as_C_string(), + (mh() == nullptr) ? "null" : mh()->klass_name()->as_C_string(), + (mh() == nullptr) ? "null" : mh()->name()->as_C_string(), location - mh()->code_base() )); JvmtiEnv *env = ets->get_env(); @@ -2004,7 +2004,7 @@ void JvmtiExport::post_exception_throw(JavaThread *thread, Method* method, addre bool should_repeat; vframeStream st(thread); assert(!st.at_end(), "cannot be at end"); - Method* current_method = NULL; + Method* current_method = nullptr; // A GC may occur during the Method::fast_exception_handler_bci_for() // call below if it needs to load the constraint class. Using a // methodHandle to keep the 'current_method' from being deallocated @@ -2039,7 +2039,7 @@ void JvmtiExport::post_exception_throw(JavaThread *thread, Method* method, addre JvmtiJavaThreadEventTransition jet(thread); jvmtiEventException callback = env->callbacks()->Exception; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(), jem.jni_methodID(), jem.location(), jem.exception(), @@ -2060,14 +2060,14 @@ void JvmtiExport::notice_unwind_due_to_exception(JavaThread *thread, Method* met Handle exception_handle(thread, exception); JvmtiThreadState *state = thread->jvmti_thread_state(); - if (state == NULL) { + if (state == nullptr) { return; } EVT_TRIG_TRACE(JVMTI_EVENT_EXCEPTION_CATCH, ("[%s] Trg unwind_due_to_exception triggered %s.%s @ %s" INTX_FORMAT " - %s", JvmtiTrace::safe_get_thread_name(thread), - (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(), - (mh() == NULL) ? "NULL" : mh()->name()->as_C_string(), + (mh() == nullptr) ? "null" : mh()->klass_name()->as_C_string(), + (mh() == nullptr) ? "null" : mh()->name()->as_C_string(), location==0? "no location:" : "", location==0? 0 : location - mh()->code_base(), in_handler_frame? "in handler frame" : "not handler frame" )); @@ -2091,7 +2091,7 @@ void JvmtiExport::notice_unwind_due_to_exception(JavaThread *thread, Method* met } } else { // In exception handler frame. Report exception catch. - assert(location != NULL, "must be a known location"); + assert(location != nullptr, "must be a known location"); // Update cur_stack_depth - the frames above the current frame // have been unwound due to this exception: assert(!state->is_exception_caught(), "exception must not be caught yet."); @@ -2101,20 +2101,20 @@ void JvmtiExport::notice_unwind_due_to_exception(JavaThread *thread, Method* met return; // no events should be posted if thread is in any VTMS transition } JvmtiEnvThreadStateIterator it(state); - for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { - if (ets->is_enabled(JVMTI_EVENT_EXCEPTION_CATCH) && (exception_handle() != NULL)) { + for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) { + if (ets->is_enabled(JVMTI_EVENT_EXCEPTION_CATCH) && (exception_handle() != nullptr)) { EVT_TRACE(JVMTI_EVENT_EXCEPTION_CATCH, ("[%s] Evt ExceptionCatch sent %s.%s @ " INTX_FORMAT, JvmtiTrace::safe_get_thread_name(thread), - (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(), - (mh() == NULL) ? "NULL" : mh()->name()->as_C_string(), + (mh() == nullptr) ? "null" : mh()->klass_name()->as_C_string(), + (mh() == nullptr) ? "null" : mh()->name()->as_C_string(), location - mh()->code_base() )); JvmtiEnv *env = ets->get_env(); JvmtiExceptionEventMark jem(thread, mh, location, exception_handle); JvmtiJavaThreadEventTransition jet(thread); jvmtiEventExceptionCatch callback = env->callbacks()->ExceptionCatch; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(), jem.jni_methodID(), jem.location(), jem.exception()); @@ -2131,7 +2131,7 @@ oop JvmtiExport::jni_GetField_probe(JavaThread *thread, jobject jobj, oop obj, // At least one field access watch is set so we have more work to do. post_field_access_by_jni(thread, obj, klass, fieldID, is_static); // event posting can block so refetch oop if we were passed a jobj - if (jobj != NULL) return JNIHandles::resolve_non_null(jobj); + if (jobj != nullptr) return JNIHandles::resolve_non_null(jobj); } return obj; } @@ -2160,7 +2160,7 @@ void JvmtiExport::post_field_access_by_jni(JavaThread *thread, oop obj, Handle h_obj; if (!is_static) { // non-static field accessors have an object, but we need a handle - assert(obj != NULL, "non-static needs an object"); + assert(obj != nullptr, "non-static needs an object"); h_obj = Handle(thread, obj); } post_field_access(thread, @@ -2176,7 +2176,7 @@ void JvmtiExport::post_field_access(JavaThread *thread, Method* method, methodHandle mh(thread, method); JvmtiThreadState *state = thread->jvmti_thread_state(); - if (state == NULL) { + if (state == nullptr) { return; } if (thread->is_in_any_VTMS_transition()) { @@ -2186,12 +2186,12 @@ void JvmtiExport::post_field_access(JavaThread *thread, Method* method, EVT_TRIG_TRACE(JVMTI_EVENT_FIELD_ACCESS, ("[%s] Trg Field Access event triggered", JvmtiTrace::safe_get_thread_name(thread))); JvmtiEnvThreadStateIterator it(state); - for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { + for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) { if (ets->is_enabled(JVMTI_EVENT_FIELD_ACCESS)) { EVT_TRACE(JVMTI_EVENT_FIELD_ACCESS, ("[%s] Evt Field Access event sent %s.%s @ " INTX_FORMAT, JvmtiTrace::safe_get_thread_name(thread), - (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(), - (mh() == NULL) ? "NULL" : mh()->name()->as_C_string(), + (mh() == nullptr) ? "null" : mh()->klass_name()->as_C_string(), + (mh() == nullptr) ? "null" : mh()->name()->as_C_string(), location - mh()->code_base() )); JvmtiEnv *env = ets->get_env(); @@ -2200,7 +2200,7 @@ void JvmtiExport::post_field_access(JavaThread *thread, Method* method, jobject field_jobject = jem.to_jobject(object()); JvmtiJavaThreadEventTransition jet(thread); jvmtiEventFieldAccess callback = env->callbacks()->FieldAccess; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(), jem.jni_methodID(), jem.location(), field_jclass, field_jobject, field); @@ -2216,7 +2216,7 @@ oop JvmtiExport::jni_SetField_probe(JavaThread *thread, jobject jobj, oop obj, // At least one field modification watch is set so we have more work to do. post_field_modification_by_jni(thread, obj, klass, fieldID, is_static, sig_type, value); // event posting can block so refetch oop if we were passed a jobj - if (jobj != NULL) return JNIHandles::resolve_non_null(jobj); + if (jobj != nullptr) return JNIHandles::resolve_non_null(jobj); } return obj; } @@ -2247,7 +2247,7 @@ void JvmtiExport::post_field_modification_by_jni(JavaThread *thread, oop obj, Handle h_obj; if (!is_static) { // non-static field accessors have an object, but we need a handle - assert(obj != NULL, "non-static needs an object"); + assert(obj != nullptr, "non-static needs an object"); h_obj = Handle(thread, obj); } post_field_modification(thread, @@ -2332,7 +2332,7 @@ void JvmtiExport::post_field_modification(JavaThread *thread, Method* method, methodHandle mh(thread, method); JvmtiThreadState *state = thread->jvmti_thread_state(); - if (state == NULL) { + if (state == nullptr) { return; } if (thread->is_in_any_VTMS_transition()) { @@ -2343,13 +2343,13 @@ void JvmtiExport::post_field_modification(JavaThread *thread, Method* method, ("[%s] Trg Field Modification event triggered", JvmtiTrace::safe_get_thread_name(thread))); JvmtiEnvThreadStateIterator it(state); - for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { + for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) { if (ets->is_enabled(JVMTI_EVENT_FIELD_MODIFICATION)) { EVT_TRACE(JVMTI_EVENT_FIELD_MODIFICATION, ("[%s] Evt Field Modification event sent %s.%s @ " INTX_FORMAT, JvmtiTrace::safe_get_thread_name(thread), - (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(), - (mh() == NULL) ? "NULL" : mh()->name()->as_C_string(), + (mh() == nullptr) ? "null" : mh()->klass_name()->as_C_string(), + (mh() == nullptr) ? "null" : mh()->name()->as_C_string(), location - mh()->code_base() )); JvmtiEnv *env = ets->get_env(); @@ -2358,7 +2358,7 @@ void JvmtiExport::post_field_modification(JavaThread *thread, Method* method, jobject field_jobject = jem.to_jobject(object()); JvmtiJavaThreadEventTransition jet(thread); jvmtiEventFieldModification callback = env->callbacks()->FieldModification; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(), jem.jni_methodID(), jem.location(), field_jclass, field_jobject, field, sig_type, *value_ptr); @@ -2382,16 +2382,16 @@ void JvmtiExport::post_native_method_bind(Method* method, address* function_ptr) if (JvmtiEventController::is_enabled(JVMTI_EVENT_NATIVE_METHOD_BIND)) { JvmtiEnvIterator it; - for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { + for (JvmtiEnv* env = it.first(); env != nullptr; env = it.next(env)) { if (env->is_enabled(JVMTI_EVENT_NATIVE_METHOD_BIND)) { EVT_TRACE(JVMTI_EVENT_NATIVE_METHOD_BIND, ("[%s] Evt Native Method Bind event sent", JvmtiTrace::safe_get_thread_name(thread) )); JvmtiMethodEventMark jem(thread, mh); JvmtiJavaThreadEventTransition jet(thread); - JNIEnv* jni_env = (env->phase() == JVMTI_PHASE_PRIMORDIAL) ? NULL : jem.jni_env(); + JNIEnv* jni_env = (env->phase() == JVMTI_PHASE_PRIMORDIAL) ? nullptr : jem.jni_env(); jvmtiEventNativeMethodBind callback = env->callbacks()->NativeMethodBind; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external(), jni_env, jem.jni_thread(), jem.jni_methodID(), (void*)(*function_ptr), (void**)function_ptr); } @@ -2405,7 +2405,7 @@ jvmtiCompiledMethodLoadInlineRecord* create_inline_record(nmethod* nm) { jint numstackframes = 0; jvmtiCompiledMethodLoadInlineRecord* record = (jvmtiCompiledMethodLoadInlineRecord*)NEW_RESOURCE_OBJ(jvmtiCompiledMethodLoadInlineRecord); record->header.kind = JVMTI_CMLR_INLINE_INFO; - record->header.next = NULL; + record->header.next = nullptr; record->header.majorinfoversion = JVMTI_CMLR_MAJOR_VERSION_1; record->header.minorinfoversion = JVMTI_CMLR_MINOR_VERSION_0; record->numpcs = 0; @@ -2418,10 +2418,10 @@ jvmtiCompiledMethodLoadInlineRecord* create_inline_record(nmethod* nm) { for(PcDesc* p = nm->scopes_pcs_begin(); p < nm->scopes_pcs_end(); p++) { if(p->scope_decode_offset() == DebugInformationRecorder::serialized_null) continue; void* pc_address = (void*)p->real_pc(nm); - assert(pc_address != NULL, "pc_address must be non-null"); + assert(pc_address != nullptr, "pc_address must be non-null"); record->pcinfo[scope].pc = pc_address; numstackframes=0; - for(ScopeDesc* sd = nm->scope_desc_at(p->real_pc(nm));sd != NULL;sd = sd->sender()) { + for(ScopeDesc* sd = nm->scope_desc_at(p->real_pc(nm));sd != nullptr;sd = sd->sender()) { numstackframes++; } assert(numstackframes != 0, "numstackframes must be nonzero."); @@ -2429,9 +2429,9 @@ jvmtiCompiledMethodLoadInlineRecord* create_inline_record(nmethod* nm) { record->pcinfo[scope].bcis = (jint *)NEW_RESOURCE_ARRAY(jint, numstackframes); record->pcinfo[scope].numstackframes = numstackframes; int stackframe = 0; - for(ScopeDesc* sd = nm->scope_desc_at(p->real_pc(nm));sd != NULL;sd = sd->sender()) { - // sd->method() can be NULL for stubs but not for nmethods. To be completely robust, include an assert that we should never see a null sd->method() - guarantee(sd->method() != NULL, "sd->method() cannot be null."); + for(ScopeDesc* sd = nm->scope_desc_at(p->real_pc(nm));sd != nullptr;sd = sd->sender()) { + // sd->method() can be null for stubs but not for nmethods. To be completely robust, include an assert that we should never see a null sd->method() + guarantee(sd->method() != nullptr, "sd->method() cannot be null."); record->pcinfo[scope].methods[stackframe] = sd->method()->jmethod_id(); record->pcinfo[scope].bcis[stackframe] = sd->bci(); stackframe++; @@ -2455,7 +2455,7 @@ void JvmtiExport::post_compiled_method_load(nmethod *nm) { JvmtiTrace::safe_get_thread_name(thread))); JvmtiEnvIterator it; - for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { + for (JvmtiEnv* env = it.first(); env != nullptr; env = it.next(env)) { post_compiled_method_load(env, nm); } } @@ -2466,7 +2466,7 @@ void JvmtiExport::post_compiled_method_load(JvmtiEnv* env, nmethod *nm) { return; } jvmtiEventCompiledMethodLoad callback = env->callbacks()->CompiledMethodLoad; - if (callback == NULL) { + if (callback == nullptr) { return; } JavaThread* thread = JavaThread::current(); @@ -2476,8 +2476,8 @@ void JvmtiExport::post_compiled_method_load(JvmtiEnv* env, nmethod *nm) { EVT_TRACE(JVMTI_EVENT_COMPILED_METHOD_LOAD, ("[%s] method compile load event sent %s.%s ", JvmtiTrace::safe_get_thread_name(thread), - (nm->method() == NULL) ? "NULL" : nm->method()->klass_name()->as_C_string(), - (nm->method() == NULL) ? "NULL" : nm->method()->name()->as_C_string())); + (nm->method() == nullptr) ? "null" : nm->method()->klass_name()->as_C_string(), + (nm->method() == nullptr) ? "null" : nm->method()->name()->as_C_string())); ResourceMark rm(thread); HandleMark hm(thread); @@ -2492,7 +2492,7 @@ void JvmtiExport::post_compiled_method_load(JvmtiEnv* env, nmethod *nm) { } void JvmtiExport::post_dynamic_code_generated_internal(const char *name, const void *code_begin, const void *code_end) { - assert(name != NULL && name[0] != '\0', "sanity check"); + assert(name != nullptr && name[0] != '\0', "sanity check"); JavaThread* thread = JavaThread::current(); @@ -2506,7 +2506,7 @@ void JvmtiExport::post_dynamic_code_generated_internal(const char *name, const v ("[%s] method dynamic code generated event triggered", JvmtiTrace::safe_get_thread_name(thread))); JvmtiEnvIterator it; - for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { + for (JvmtiEnv* env = it.first(); env != nullptr; env = it.next(env)) { if (env->is_enabled(JVMTI_EVENT_DYNAMIC_CODE_GENERATED)) { EVT_TRACE(JVMTI_EVENT_DYNAMIC_CODE_GENERATED, ("[%s] dynamic code generated event sent for %s", @@ -2515,7 +2515,7 @@ void JvmtiExport::post_dynamic_code_generated_internal(const char *name, const v JvmtiJavaThreadEventTransition jet(thread); jint length = (jint)pointer_delta(code_end, code_begin, sizeof(char)); jvmtiEventDynamicCodeGenerated callback = env->callbacks()->DynamicCodeGenerated; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external(), name, (void*)code_begin, length); } } @@ -2557,7 +2557,7 @@ void JvmtiExport::post_dynamic_code_generated(JvmtiEnv* env, const char *name, JvmtiJavaThreadEventTransition jet(thread); jint length = (jint)pointer_delta(code_end, code_begin, sizeof(char)); jvmtiEventDynamicCodeGenerated callback = env->callbacks()->DynamicCodeGenerated; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external(), name, (void*)code_begin, length); } } @@ -2573,12 +2573,12 @@ void JvmtiExport::post_dynamic_code_generated_while_holding_locks(const char* na // register the stub with the current dynamic code event collector // Cannot take safepoint here so do not use state_for to get // jvmti thread state. - // The collector and/or state might be NULL if JvmtiDynamicCodeEventCollector + // The collector and/or state might be null if JvmtiDynamicCodeEventCollector // has been initialized while JVMTI_EVENT_DYNAMIC_CODE_GENERATED was disabled. JvmtiThreadState* state = thread->jvmti_thread_state(); - if (state != NULL) { + if (state != nullptr) { JvmtiDynamicCodeEventCollector *collector = state->get_dynamic_code_event_collector(); - if (collector != NULL) { + if (collector != nullptr) { collector->register_stub(name, code_begin, code_end); } } @@ -2587,17 +2587,17 @@ void JvmtiExport::post_dynamic_code_generated_while_holding_locks(const char* na // Collect all the vm internally allocated objects which are visible to java world void JvmtiExport::record_vm_internal_object_allocation(oop obj) { Thread* thread = Thread::current_or_null(); - if (thread != NULL && thread->is_Java_thread()) { + if (thread != nullptr && thread->is_Java_thread()) { // Can not take safepoint here. NoSafepointVerifier no_sfpt; // Cannot take safepoint here so do not use state_for to get // jvmti thread state. JvmtiThreadState *state = JavaThread::cast(thread)->jvmti_thread_state(); - if (state != NULL) { - // state is non NULL when VMObjectAllocEventCollector is enabled. + if (state != nullptr) { + // state is non null when VMObjectAllocEventCollector is enabled. JvmtiVMObjectAllocEventCollector *collector; collector = state->get_vm_object_alloc_event_collector(); - if (collector != NULL && collector->is_enabled()) { + if (collector != nullptr && collector->is_enabled()) { // Don't record classes as these will be notified via the ClassLoad // event. if (obj->klass() != vmClasses::Class_klass()) { @@ -2611,18 +2611,18 @@ void JvmtiExport::record_vm_internal_object_allocation(oop obj) { // Collect all the sampled allocated objects. void JvmtiExport::record_sampled_internal_object_allocation(oop obj) { Thread* thread = Thread::current_or_null(); - if (thread != NULL && thread->is_Java_thread()) { + if (thread != nullptr && thread->is_Java_thread()) { // Can not take safepoint here. NoSafepointVerifier no_sfpt; // Cannot take safepoint here so do not use state_for to get // jvmti thread state. JvmtiThreadState *state = JavaThread::cast(thread)->jvmti_thread_state(); - if (state != NULL) { - // state is non NULL when SampledObjectAllocEventCollector is enabled. + if (state != nullptr) { + // state is non null when SampledObjectAllocEventCollector is enabled. JvmtiSampledObjectAllocEventCollector *collector; collector = state->get_sampled_object_alloc_event_collector(); - if (collector != NULL && collector->is_enabled()) { + if (collector != nullptr && collector->is_enabled()) { collector->record_allocation(obj); } } @@ -2635,15 +2635,15 @@ void JvmtiExport::post_garbage_collection_finish() { ("[%s] garbage collection finish event triggered", JvmtiTrace::safe_get_thread_name(thread))); JvmtiEnvIterator it; - for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { + for (JvmtiEnv* env = it.first(); env != nullptr; env = it.next(env)) { if (env->is_enabled(JVMTI_EVENT_GARBAGE_COLLECTION_FINISH)) { EVT_TRACE(JVMTI_EVENT_GARBAGE_COLLECTION_FINISH, ("[%s] garbage collection finish event sent", JvmtiTrace::safe_get_thread_name(thread))); JvmtiThreadEventTransition jet(thread); - // JNIEnv is NULL here because this event is posted from VM Thread + // JNIEnv is null here because this event is posted from VM Thread jvmtiEventGarbageCollectionFinish callback = env->callbacks()->GarbageCollectionFinish; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external()); } } @@ -2656,15 +2656,15 @@ void JvmtiExport::post_garbage_collection_start() { ("[%s] garbage collection start event triggered", JvmtiTrace::safe_get_thread_name(thread))); JvmtiEnvIterator it; - for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { + for (JvmtiEnv* env = it.first(); env != nullptr; env = it.next(env)) { if (env->is_enabled(JVMTI_EVENT_GARBAGE_COLLECTION_START)) { EVT_TRACE(JVMTI_EVENT_GARBAGE_COLLECTION_START, ("[%s] garbage collection start event sent", JvmtiTrace::safe_get_thread_name(thread))); JvmtiThreadEventTransition jet(thread); - // JNIEnv is NULL here because this event is posted from VM Thread + // JNIEnv is null here because this event is posted from VM Thread jvmtiEventGarbageCollectionStart callback = env->callbacks()->GarbageCollectionStart; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external()); } } @@ -2677,15 +2677,15 @@ void JvmtiExport::post_data_dump() { ("[%s] data dump request event triggered", JvmtiTrace::safe_get_thread_name(thread))); JvmtiEnvIterator it; - for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { + for (JvmtiEnv* env = it.first(); env != nullptr; env = it.next(env)) { if (env->is_enabled(JVMTI_EVENT_DATA_DUMP_REQUEST)) { EVT_TRACE(JVMTI_EVENT_DATA_DUMP_REQUEST, ("[%s] data dump request event sent", JvmtiTrace::safe_get_thread_name(thread))); JvmtiThreadEventTransition jet(thread); - // JNIEnv is NULL here because this event is posted from VM Thread + // JNIEnv is null here because this event is posted from VM Thread jvmtiEventDataDumpRequest callback = env->callbacks()->DataDumpRequest; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external()); } } @@ -2695,7 +2695,7 @@ void JvmtiExport::post_data_dump() { void JvmtiExport::post_monitor_contended_enter(JavaThread *thread, ObjectMonitor *obj_mntr) { oop object = obj_mntr->object(); JvmtiThreadState *state = thread->jvmti_thread_state(); - if (state == NULL) { + if (state == nullptr) { return; } if (thread->is_in_any_VTMS_transition()) { @@ -2709,7 +2709,7 @@ void JvmtiExport::post_monitor_contended_enter(JavaThread *thread, ObjectMonitor ("[%s] monitor contended enter event triggered", JvmtiTrace::safe_get_thread_name(thread))); JvmtiEnvThreadStateIterator it(state); - for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { + for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) { if (ets->is_enabled(JVMTI_EVENT_MONITOR_CONTENDED_ENTER)) { EVT_TRACE(JVMTI_EVENT_MONITOR_CONTENDED_ENTER, ("[%s] monitor contended enter event sent", @@ -2718,7 +2718,7 @@ void JvmtiExport::post_monitor_contended_enter(JavaThread *thread, ObjectMonitor JvmtiEnv *env = ets->get_env(); JvmtiThreadEventTransition jet(thread); jvmtiEventMonitorContendedEnter callback = env->callbacks()->MonitorContendedEnter; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(), jem.jni_object()); } } @@ -2728,7 +2728,7 @@ void JvmtiExport::post_monitor_contended_enter(JavaThread *thread, ObjectMonitor void JvmtiExport::post_monitor_contended_entered(JavaThread *thread, ObjectMonitor *obj_mntr) { oop object = obj_mntr->object(); JvmtiThreadState *state = thread->jvmti_thread_state(); - if (state == NULL) { + if (state == nullptr) { return; } if (thread->is_in_any_VTMS_transition()) { @@ -2743,7 +2743,7 @@ void JvmtiExport::post_monitor_contended_entered(JavaThread *thread, ObjectMonit JvmtiTrace::safe_get_thread_name(thread))); JvmtiEnvThreadStateIterator it(state); - for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { + for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) { if (ets->is_enabled(JVMTI_EVENT_MONITOR_CONTENDED_ENTERED)) { EVT_TRACE(JVMTI_EVENT_MONITOR_CONTENDED_ENTERED, ("[%s] monitor contended enter event sent", @@ -2752,7 +2752,7 @@ void JvmtiExport::post_monitor_contended_entered(JavaThread *thread, ObjectMonit JvmtiEnv *env = ets->get_env(); JvmtiThreadEventTransition jet(thread); jvmtiEventMonitorContendedEntered callback = env->callbacks()->MonitorContendedEntered; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(), jem.jni_object()); } } @@ -2762,7 +2762,7 @@ void JvmtiExport::post_monitor_contended_entered(JavaThread *thread, ObjectMonit void JvmtiExport::post_monitor_wait(JavaThread *thread, oop object, jlong timeout) { JvmtiThreadState *state = thread->jvmti_thread_state(); - if (state == NULL) { + if (state == nullptr) { return; } if (thread->is_in_any_VTMS_transition()) { @@ -2776,7 +2776,7 @@ void JvmtiExport::post_monitor_wait(JavaThread *thread, oop object, ("[%s] monitor wait event triggered", JvmtiTrace::safe_get_thread_name(thread))); JvmtiEnvThreadStateIterator it(state); - for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { + for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) { if (ets->is_enabled(JVMTI_EVENT_MONITOR_WAIT)) { EVT_TRACE(JVMTI_EVENT_MONITOR_WAIT, ("[%s] monitor wait event sent", @@ -2785,7 +2785,7 @@ void JvmtiExport::post_monitor_wait(JavaThread *thread, oop object, JvmtiEnv *env = ets->get_env(); JvmtiThreadEventTransition jet(thread); jvmtiEventMonitorWait callback = env->callbacks()->MonitorWait; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(), jem.jni_object(), timeout); } @@ -2796,7 +2796,7 @@ void JvmtiExport::post_monitor_wait(JavaThread *thread, oop object, void JvmtiExport::post_monitor_waited(JavaThread *thread, ObjectMonitor *obj_mntr, jboolean timed_out) { oop object = obj_mntr->object(); JvmtiThreadState *state = thread->jvmti_thread_state(); - if (state == NULL) { + if (state == nullptr) { return; } if (thread->is_in_any_VTMS_transition()) { @@ -2810,7 +2810,7 @@ void JvmtiExport::post_monitor_waited(JavaThread *thread, ObjectMonitor *obj_mnt ("[%s] monitor waited event triggered", JvmtiTrace::safe_get_thread_name(thread))); JvmtiEnvThreadStateIterator it(state); - for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { + for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) { if (ets->is_enabled(JVMTI_EVENT_MONITOR_WAITED)) { EVT_TRACE(JVMTI_EVENT_MONITOR_WAITED, ("[%s] monitor waited event sent", @@ -2819,7 +2819,7 @@ void JvmtiExport::post_monitor_waited(JavaThread *thread, ObjectMonitor *obj_mnt JvmtiEnv *env = ets->get_env(); JvmtiThreadEventTransition jet(thread); jvmtiEventMonitorWaited callback = env->callbacks()->MonitorWaited; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(), jem.jni_object(), timed_out); } @@ -2828,7 +2828,7 @@ void JvmtiExport::post_monitor_waited(JavaThread *thread, ObjectMonitor *obj_mnt } void JvmtiExport::post_vm_object_alloc(JavaThread *thread, oop object) { - if (object == NULL) { + if (object == nullptr) { return; } if (thread->is_in_any_VTMS_transition()) { @@ -2840,16 +2840,16 @@ void JvmtiExport::post_vm_object_alloc(JavaThread *thread, oop object) { EVT_TRIG_TRACE(JVMTI_EVENT_VM_OBJECT_ALLOC, ("[%s] Trg vm object alloc triggered", JvmtiTrace::safe_get_thread_name(thread))); JvmtiEnvIterator it; - for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { + for (JvmtiEnv* env = it.first(); env != nullptr; env = it.next(env)) { if (env->is_enabled(JVMTI_EVENT_VM_OBJECT_ALLOC)) { EVT_TRACE(JVMTI_EVENT_VM_OBJECT_ALLOC, ("[%s] Evt vmobject alloc sent %s", JvmtiTrace::safe_get_thread_name(thread), - object==NULL? "NULL" : object->klass()->external_name())); + object==nullptr? "null" : object->klass()->external_name())); JvmtiObjectAllocEventMark jem(thread, h()); JvmtiJavaThreadEventTransition jet(thread); jvmtiEventVMObjectAlloc callback = env->callbacks()->VMObjectAlloc; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(), jem.jni_jobject(), jem.jni_class(), jem.size()); } @@ -2859,10 +2859,10 @@ void JvmtiExport::post_vm_object_alloc(JavaThread *thread, oop object) { void JvmtiExport::post_sampled_object_alloc(JavaThread *thread, oop object) { JvmtiThreadState *state = thread->jvmti_thread_state(); - if (state == NULL) { + if (state == nullptr) { return; } - if (object == NULL) { + if (object == nullptr) { return; } if (thread->is_in_any_VTMS_transition()) { @@ -2875,18 +2875,18 @@ void JvmtiExport::post_sampled_object_alloc(JavaThread *thread, oop object) { ("[%s] Trg sampled object alloc triggered", JvmtiTrace::safe_get_thread_name(thread))); JvmtiEnvThreadStateIterator it(state); - for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { + for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) { if (ets->is_enabled(JVMTI_EVENT_SAMPLED_OBJECT_ALLOC)) { EVT_TRACE(JVMTI_EVENT_SAMPLED_OBJECT_ALLOC, ("[%s] Evt sampled object alloc sent %s", JvmtiTrace::safe_get_thread_name(thread), - object == NULL ? "NULL" : object->klass()->external_name())); + object == nullptr ? "null" : object->klass()->external_name())); JvmtiEnv *env = ets->get_env(); JvmtiObjectAllocEventMark jem(thread, h()); JvmtiJavaThreadEventTransition jet(thread); jvmtiEventSampledObjectAlloc callback = env->callbacks()->SampledObjectAlloc; - if (callback != NULL) { + if (callback != nullptr) { (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(), jem.jni_jobject(), jem.jni_class(), jem.size()); } @@ -2900,7 +2900,7 @@ void JvmtiExport::cleanup_thread(JavaThread* thread) { assert(JavaThread::current() == thread, "thread is not current"); MutexLocker mu(thread, JvmtiThreadState_lock); - if (thread->jvmti_thread_state() != NULL) { + if (thread->jvmti_thread_state() != nullptr) { // This has to happen after the thread state is removed, which is // why it is not in post_thread_end_event like its complement // Maybe both these functions should be rolled into the posts? @@ -2912,7 +2912,7 @@ void JvmtiExport::clear_detected_exception(JavaThread* thread) { assert(JavaThread::current() == thread, "thread is not current"); JvmtiThreadState* state = thread->jvmti_thread_state(); - if (state != NULL) { + if (state != nullptr) { state->clear_exception_state(); } } @@ -2935,16 +2935,16 @@ jint JvmtiExport::load_agent_library(const char *agent, const char *absParam, const char *options, outputStream* st) { char ebuf[1024] = {0}; char buffer[JVM_MAXPATHLEN]; - void* library = NULL; + void* library = nullptr; jint result = JNI_ERR; const char *on_attach_symbols[] = AGENT_ONATTACH_SYMBOLS; size_t num_symbol_entries = ARRAY_SIZE(on_attach_symbols); // The abs parameter should be "true" or "false" - bool is_absolute_path = (absParam != NULL) && (strcmp(absParam,"true")==0); + bool is_absolute_path = (absParam != nullptr) && (strcmp(absParam,"true")==0); // Initially marked as invalid. It will be set to valid if we can find the agent - AgentLibrary *agent_lib = new AgentLibrary(agent, options, is_absolute_path, NULL); + AgentLibrary *agent_lib = new AgentLibrary(agent, options, is_absolute_path, nullptr); // Check for statically linked in agent. If not found then if the path is // absolute we attempt to load the library. Otherwise we try to load it @@ -2959,14 +2959,14 @@ jint JvmtiExport::load_agent_library(const char *agent, const char *absParam, agent)) { library = os::dll_load(buffer, ebuf, sizeof ebuf); } - if (library == NULL) { + if (library == nullptr) { // not found - try OS default library path if (os::dll_build_name(buffer, sizeof(buffer), agent)) { library = os::dll_load(buffer, ebuf, sizeof ebuf); } } } - if (library != NULL) { + if (library != nullptr) { agent_lib->set_os_lib(library); agent_lib->set_valid(); } @@ -2975,10 +2975,10 @@ jint JvmtiExport::load_agent_library(const char *agent, const char *absParam, // function if (agent_lib->valid()) { // Lookup the Agent_OnAttach function - OnAttachEntry_t on_attach_entry = NULL; + OnAttachEntry_t on_attach_entry = nullptr; on_attach_entry = CAST_TO_FN_PTR(OnAttachEntry_t, os::find_agent_function(agent_lib, false, on_attach_symbols, num_symbol_entries)); - if (on_attach_entry == NULL) { + if (on_attach_entry == nullptr) { // Agent_OnAttach missing - unload library if (!agent_lib->is_static_lib()) { os::dll_unload(library); @@ -2994,7 +2994,7 @@ jint JvmtiExport::load_agent_library(const char *agent, const char *absParam, JvmtiThreadEventMark jem(THREAD); JvmtiJavaThreadEventTransition jet(THREAD); - result = (*on_attach_entry)(&main_vm, (char*)options, NULL); + result = (*on_attach_entry)(&main_vm, (char*)options, nullptr); // Agent_OnAttach may have used JNI if (THREAD->is_pending_jni_exception_check()) { @@ -3038,9 +3038,9 @@ jint JvmtiExport::load_agent_library(const char *agent, const char *absParam, void JvmtiEventCollector::setup_jvmti_thread_state() { // set this event collector to be the current one. JvmtiThreadState* state = JvmtiThreadState::state_for(JavaThread::current()); - // state can only be NULL if the current thread is exiting which + // state can only be null if the current thread is exiting which // should not happen since we're trying to configure for event collection - guarantee(state != NULL, "exiting thread called setup_jvmti_thread_state"); + guarantee(state != nullptr, "exiting thread called setup_jvmti_thread_state"); if (is_vm_object_alloc_event()) { JvmtiVMObjectAllocEventCollector *prev = state->get_vm_object_alloc_event_collector(); @@ -3077,7 +3077,7 @@ void JvmtiEventCollector::unset_jvmti_thread_state() { } JvmtiThreadState* state = JavaThread::current()->jvmti_thread_state(); - if (state != NULL) { + if (state != nullptr) { // restore the previous event collector (if any) if (is_vm_object_alloc_event()) { if (state->get_vm_object_alloc_event_collector() == this) { @@ -3105,7 +3105,7 @@ void JvmtiEventCollector::unset_jvmti_thread_state() { } // create the dynamic code event collector -JvmtiDynamicCodeEventCollector::JvmtiDynamicCodeEventCollector() : _code_blobs(NULL) { +JvmtiDynamicCodeEventCollector::JvmtiDynamicCodeEventCollector() : _code_blobs(nullptr) { if (JvmtiExport::should_post_dynamic_code_generated()) { setup_jvmti_thread_state(); } @@ -3116,7 +3116,7 @@ JvmtiDynamicCodeEventCollector::JvmtiDynamicCodeEventCollector() : _code_blobs(N JvmtiDynamicCodeEventCollector::~JvmtiDynamicCodeEventCollector() { assert(!JavaThread::current()->owns_locks(), "all locks must be released to post deferred events"); // iterate over any code blob descriptors that we collected - if (_code_blobs != NULL) { + if (_code_blobs != nullptr) { for (int i=0; i<_code_blobs->length(); i++) { JvmtiCodeBlobDesc* blob = _code_blobs->at(i); JvmtiExport::post_dynamic_code_generated(blob->name(), blob->code_begin(), blob->code_end()); @@ -3129,7 +3129,7 @@ JvmtiDynamicCodeEventCollector::~JvmtiDynamicCodeEventCollector() { // register a stub void JvmtiDynamicCodeEventCollector::register_stub(const char* name, address start, address end) { - if (_code_blobs == NULL) { + if (_code_blobs == nullptr) { _code_blobs = new (mtServiceability) GrowableArray(1, mtServiceability); } _code_blobs->append(new JvmtiCodeBlobDesc(name, start, end)); @@ -3137,7 +3137,7 @@ void JvmtiDynamicCodeEventCollector::register_stub(const char* name, address sta // Setup current thread to record vm allocated objects. JvmtiObjectAllocEventCollector::JvmtiObjectAllocEventCollector() : - _allocated(NULL), _enable(false), _post_callback(NULL) { + _allocated(nullptr), _enable(false), _post_callback(nullptr) { } // Post vm_object_alloc event for vm allocated objects visible to java @@ -3152,32 +3152,32 @@ void JvmtiObjectAllocEventCollector::generate_call_for_allocated() { _allocated->at(i).release(JvmtiExport::jvmti_oop_storage()); } - delete _allocated, _allocated = NULL; + delete _allocated, _allocated = nullptr; } } void JvmtiObjectAllocEventCollector::record_allocation(oop obj) { assert(is_enabled(), "Object alloc event collector is not enabled"); - if (_allocated == NULL) { + if (_allocated == nullptr) { _allocated = new (mtServiceability) GrowableArray(1, mtServiceability); } _allocated->push(OopHandle(JvmtiExport::jvmti_oop_storage(), obj)); } // Disable collection of VMObjectAlloc events -NoJvmtiVMObjectAllocMark::NoJvmtiVMObjectAllocMark() : _collector(NULL) { +NoJvmtiVMObjectAllocMark::NoJvmtiVMObjectAllocMark() : _collector(nullptr) { // a no-op if VMObjectAlloc event is not enabled if (!JvmtiExport::should_post_vm_object_alloc()) { return; } Thread* thread = Thread::current_or_null(); - if (thread != NULL && thread->is_Java_thread()) { + if (thread != nullptr && thread->is_Java_thread()) { JavaThread* current_thread = JavaThread::cast(thread); JvmtiThreadState *state = current_thread->jvmti_thread_state(); - if (state != NULL) { + if (state != nullptr) { JvmtiVMObjectAllocEventCollector *collector; collector = state->get_vm_object_alloc_event_collector(); - if (collector != NULL && collector->is_enabled()) { + if (collector != nullptr && collector->is_enabled()) { _collector = collector; _collector->set_enabled(false); } diff --git a/src/hotspot/share/prims/jvmtiExport.hpp b/src/hotspot/share/prims/jvmtiExport.hpp index 18558e1491153..6576053f5afc9 100644 --- a/src/hotspot/share/prims/jvmtiExport.hpp +++ b/src/hotspot/share/prims/jvmtiExport.hpp @@ -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 @@ -319,14 +319,14 @@ class JvmtiExport : public AllStatic { static oop jni_GetField_probe (JavaThread *thread, jobject jobj, oop obj, Klass* klass, jfieldID fieldID, bool is_static) - NOT_JVMTI_RETURN_(NULL); + NOT_JVMTI_RETURN_(nullptr); static void post_field_access_by_jni (JavaThread *thread, oop obj, Klass* klass, jfieldID fieldID, bool is_static) NOT_JVMTI_RETURN; static void post_field_access (JavaThread *thread, Method* method, address location, Klass* field_klass, Handle object, jfieldID field) NOT_JVMTI_RETURN; static oop jni_SetField_probe (JavaThread *thread, jobject jobj, oop obj, Klass* klass, jfieldID fieldID, bool is_static, char sig_type, - jvalue *value) NOT_JVMTI_RETURN_(NULL); + jvalue *value) NOT_JVMTI_RETURN_(nullptr); static void post_field_modification_by_jni(JavaThread *thread, oop obj, Klass* klass, jfieldID fieldID, bool is_static, char sig_type, jvalue *value); @@ -427,7 +427,7 @@ class JvmtiExport : public AllStatic { #endif // SetNativeMethodPrefix support - static char** get_all_native_method_prefixes(int* count_ptr) NOT_JVMTI_RETURN_(NULL); + static char** get_all_native_method_prefixes(int* count_ptr) NOT_JVMTI_RETURN_(nullptr); // JavaThread lifecycle support: static jvmtiError cv_external_thread_to_JavaThread(ThreadsList * t_list, @@ -448,7 +448,7 @@ class JvmtiCodeBlobDesc : public CHeapObj { public: JvmtiCodeBlobDesc(const char *name, address code_begin, address code_end) { - assert(name != NULL, "all code blobs must be named"); + assert(name != nullptr, "all code blobs must be named"); strncpy(_name, name, sizeof(_name) - 1); _name[sizeof(_name)-1] = '\0'; _code_begin = code_begin; @@ -467,7 +467,7 @@ class JvmtiEventCollector : public StackObj { bool _unset_jvmti_thread_state; public: - JvmtiEventCollector() : _prev(NULL), _unset_jvmti_thread_state(false) {} + JvmtiEventCollector() : _prev(nullptr), _unset_jvmti_thread_state(false) {} void setup_jvmti_thread_state(); // Set this collector in current thread, returns if success. void unset_jvmti_thread_state(); // Reset previous collector in current thread. @@ -582,10 +582,10 @@ class JvmtiSampledObjectAllocEventCollector : public JvmtiObjectAllocEventCollec class NoJvmtiVMObjectAllocMark : public StackObj { private: - // enclosing collector if enabled, NULL otherwise + // enclosing collector if enabled, null otherwise JvmtiVMObjectAllocEventCollector *_collector; - bool was_enabled() { return _collector != NULL; } + bool was_enabled() { return _collector != nullptr; } public: NoJvmtiVMObjectAllocMark() NOT_JVMTI_RETURN; @@ -609,7 +609,7 @@ class JvmtiHideSingleStepping : public StackObj { public: JvmtiHideSingleStepping(JavaThread * thread) { - assert(thread != NULL, "sanity check"); + assert(thread != nullptr, "sanity check"); _single_step_hidden = false; _thread = thread; diff --git a/src/hotspot/share/prims/jvmtiExtensions.cpp b/src/hotspot/share/prims/jvmtiExtensions.cpp index fc3a9ff67a5f9..b40ad7ddbd108 100644 --- a/src/hotspot/share/prims/jvmtiExtensions.cpp +++ b/src/hotspot/share/prims/jvmtiExtensions.cpp @@ -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 @@ -42,14 +42,14 @@ GrowableArray* JvmtiExtensions::_ext_events; // Extension Functions // static jvmtiError JNICALL IsClassUnloadingEnabled(const jvmtiEnv* env, ...) { - jboolean* enabled = NULL; + jboolean* enabled = nullptr; va_list ap; va_start(ap, env); enabled = va_arg(ap, jboolean *); va_end(ap); - if (enabled == NULL) { + if (enabled == nullptr) { return JVMTI_ERROR_NULL_POINTER; } *enabled = (jboolean)ClassUnloading; @@ -65,11 +65,11 @@ static jvmtiError JNICALL GetVirtualThread(const jvmtiEnv* env, ...) { JavaThread* current_thread = JavaThread::current(); ResourceMark rm(current_thread); - jthread thread = NULL; - jthread* vthread_ptr = NULL; - JavaThread* java_thread = NULL; - oop cthread_oop = NULL; - oop thread_oop = NULL; + jthread thread = nullptr; + jthread* vthread_ptr = nullptr; + JavaThread* java_thread = nullptr; + oop cthread_oop = nullptr; + oop thread_oop = nullptr; va_list ap; va_start(ap, env); @@ -83,7 +83,7 @@ static jvmtiError JNICALL GetVirtualThread(const jvmtiEnv* env, ...) { jvmtiError err; - if (thread == NULL) { + if (thread == nullptr) { java_thread = current_thread; cthread_oop = java_thread->threadObj(); } else { @@ -92,21 +92,21 @@ static jvmtiError JNICALL GetVirtualThread(const jvmtiEnv* env, ...) { return err; } } - if (vthread_ptr == NULL) { + if (vthread_ptr == nullptr) { return JVMTI_ERROR_NULL_POINTER; } - if (cthread_oop == NULL || java_lang_VirtualThread::is_instance(cthread_oop)) { + if (cthread_oop == nullptr || java_lang_VirtualThread::is_instance(cthread_oop)) { return JVMTI_ERROR_INVALID_THREAD; } - *vthread_ptr = NULL; + *vthread_ptr = nullptr; JvmtiThreadState *state = JvmtiThreadState::state_for(java_thread); - if (state == NULL) { + if (state == nullptr) { return JVMTI_ERROR_THREAD_NOT_ALIVE; } oop vthread_oop = java_thread->jvmti_vthread(); if (!java_lang_VirtualThread::is_instance(vthread_oop)) { // not a virtual thread - vthread_oop = NULL; + vthread_oop = nullptr; } *vthread_ptr = (jthread)JNIHandles::make_local(current_thread, vthread_oop); return JVMTI_ERROR_NONE; @@ -121,8 +121,8 @@ static jvmtiError JNICALL GetCarrierThread(const jvmtiEnv* env, ...) { JavaThread* current_thread = JavaThread::current(); HandleMark hm(current_thread); - jthread vthread = NULL; - jthread* thread_ptr = NULL; + jthread vthread = nullptr; + jthread* thread_ptr = nullptr; va_list ap; va_start(ap, env); @@ -135,9 +135,9 @@ static jvmtiError JNICALL GetCarrierThread(const jvmtiEnv* env, ...) { ThreadsListHandle tlh(current_thread); JavaThread* java_thread; - oop vthread_oop = NULL; + oop vthread_oop = nullptr; - if (vthread == NULL) { + if (vthread == nullptr) { vthread = (jthread)JNIHandles::make_local(current_thread, JvmtiEnvBase::get_vthread_or_thread_oop(current_thread)); } jvmtiError err = JvmtiExport::cv_external_thread_to_JavaThread(tlh.list(), vthread, &java_thread, &vthread_oop); @@ -147,7 +147,7 @@ static jvmtiError JNICALL GetCarrierThread(const jvmtiEnv* env, ...) { // thread_oop. // In a vthread case the cv_external_thread_to_JavaThread is expected to correctly set // the thread_oop and return JVMTI_ERROR_INVALID_THREAD which we ignore here. - if (vthread_oop == NULL) { + if (vthread_oop == nullptr) { return err; } } @@ -155,7 +155,7 @@ static jvmtiError JNICALL GetCarrierThread(const jvmtiEnv* env, ...) { if (!java_lang_VirtualThread::is_instance(vthread_oop)) { return JVMTI_ERROR_INVALID_THREAD; } - if (thread_ptr == NULL) { + if (thread_ptr == nullptr) { return JVMTI_ERROR_NULL_POINTER; } VirtualThreadGetThreadClosure op(Handle(current_thread, vthread_oop), thread_ptr); @@ -198,7 +198,7 @@ void JvmtiExtensions::register_extensions() { sizeof(func_params0)/sizeof(func_params0[0]), func_params0, 0, // no non-universal errors - NULL + nullptr }; static jvmtiExtensionFunctionInfo ext_func1 = { @@ -270,7 +270,7 @@ jvmtiError JvmtiExtensions::get_functions(JvmtiEnv* env, jint* extension_count_ptr, jvmtiExtensionFunctionInfo** extensions) { - guarantee(_ext_functions != NULL, "registration not done"); + guarantee(_ext_functions != nullptr, "registration not done"); ResourceTracker rt(env); @@ -306,7 +306,7 @@ jvmtiError JvmtiExtensions::get_functions(JvmtiEnv* env, ext_funcs[i].param_count = param_count; if (param_count == 0) { - ext_funcs[i].params = NULL; + ext_funcs[i].params = nullptr; } else { err = rt.allocate(param_count*sizeof(jvmtiParamInfo), (unsigned char**)&(ext_funcs[i].params)); @@ -335,7 +335,7 @@ jvmtiError JvmtiExtensions::get_functions(JvmtiEnv* env, jint error_count = _ext_functions->at(i)->error_count; ext_funcs[i].error_count = error_count; if (error_count == 0) { - ext_funcs[i].errors = NULL; + ext_funcs[i].errors = nullptr; } else { err = rt.allocate(error_count*sizeof(jvmtiError), (unsigned char**)&(ext_funcs[i].errors)); @@ -359,7 +359,7 @@ jvmtiError JvmtiExtensions::get_events(JvmtiEnv* env, jint* extension_count_ptr, jvmtiExtensionEventInfo** extensions) { - guarantee(_ext_events != NULL, "registration not done"); + guarantee(_ext_events != nullptr, "registration not done"); ResourceTracker rt(env); @@ -394,7 +394,7 @@ jvmtiError JvmtiExtensions::get_events(JvmtiEnv* env, ext_events[i].param_count = param_count; if (param_count == 0) { - ext_events[i].params = NULL; + ext_events[i].params = nullptr; } else { err = rt.allocate(param_count*sizeof(jvmtiParamInfo), (unsigned char**)&(ext_events[i].params)); @@ -430,13 +430,13 @@ jvmtiError JvmtiExtensions::set_event_callback(JvmtiEnv* env, jint extension_event_index, jvmtiExtensionEvent callback) { - guarantee(_ext_events != NULL, "registration not done"); + guarantee(_ext_events != nullptr, "registration not done"); - jvmtiExtensionEventInfo* event = NULL; + jvmtiExtensionEventInfo* event = nullptr; // if there are extension events registered then validate that the // extension_event_index matches one of the registered events. - if (_ext_events != NULL) { + if (_ext_events != nullptr) { for (int i=0; i<_ext_events->length(); i++ ) { if (_ext_events->at(i)->extension_event_index == extension_event_index) { event = _ext_events->at(i); @@ -446,7 +446,7 @@ jvmtiError JvmtiExtensions::set_event_callback(JvmtiEnv* env, } // invalid event index - if (event == NULL) { + if (event == nullptr) { return JVMTI_ERROR_ILLEGAL_ARGUMENT; } diff --git a/src/hotspot/share/prims/jvmtiGetLoadedClasses.cpp b/src/hotspot/share/prims/jvmtiGetLoadedClasses.cpp index 33be1b6fab513..ce3ce616c098b 100644 --- a/src/hotspot/share/prims/jvmtiGetLoadedClasses.cpp +++ b/src/hotspot/share/prims/jvmtiGetLoadedClasses.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 @@ -75,7 +75,7 @@ class LoadedClassesClosure : public KlassClosure { if (_dictionary_walk) { // Collect array classes this way when walking the dictionary (because array classes are // not in the dictionary). - for (Klass* l = k->array_klass_or_null(); l != NULL; l = l->array_klass_or_null()) { + for (Klass* l = k->array_klass_or_null(); l != nullptr; l = l->array_klass_or_null()) { _classStack.push((jclass) _env->jni_reference(Handle(_cur_thread, l->java_mirror()))); } } @@ -128,11 +128,11 @@ JvmtiGetLoadedClasses::getClassLoaderClasses(JvmtiEnv *env, jobject initiatingLo oop loader = JNIHandles::resolve(initiatingLoader); // All classes loaded from this loader as initiating loader are // requested, so only need to walk this loader's ClassLoaderData - // dictionary, or the NULL ClassLoaderData dictionary for bootstrap loader. - if (loader != NULL) { + // dictionary, or the null ClassLoaderData dictionary for bootstrap loader. + if (loader != nullptr) { ClassLoaderData* data = java_lang_ClassLoader::loader_data_acquire(loader); // ClassLoader may not be used yet for loading. - if (data != NULL && data->dictionary() != NULL) { + if (data != nullptr && data->dictionary() != nullptr) { data->dictionary()->all_entries_do(&closure); } } else { diff --git a/src/hotspot/share/prims/jvmtiImpl.cpp b/src/hotspot/share/prims/jvmtiImpl.cpp index 81a5c50ea182b..c9c3974b591a5 100644 --- a/src/hotspot/share/prims/jvmtiImpl.cpp +++ b/src/hotspot/share/prims/jvmtiImpl.cpp @@ -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 @@ -108,21 +108,21 @@ void GrowableCache::recache() { // mode. The call to remove() will rebuild the cache again // without the bad entry. // - if (_cache[i] == NULL) { - assert(false, "cannot recache NULL elements"); + if (_cache[i] == nullptr) { + assert(false, "cannot recache null elements"); remove(i); return; } } - _cache[len] = NULL; + _cache[len] = nullptr; _listener_fun(_this_obj,_cache); } bool GrowableCache::equals(void* v, GrowableElement *e2) { GrowableElement *e1 = (GrowableElement *) v; - assert(e1 != NULL, "e1 != NULL"); - assert(e2 != NULL, "e2 != NULL"); + assert(e1 != nullptr, "e1 != nullptr"); + assert(e2 != nullptr, "e2 != nullptr"); return e1->equals(e2); } @@ -132,10 +132,10 @@ bool GrowableCache::equals(void* v, GrowableElement *e2) { // GrowableCache::GrowableCache() { - _this_obj = NULL; - _listener_fun = NULL; - _elements = NULL; - _cache = NULL; + _this_obj = nullptr; + _listener_fun = nullptr; + _elements = nullptr; + _cache = nullptr; } GrowableCache::~GrowableCache() { @@ -159,7 +159,7 @@ int GrowableCache::length() { // get the value of the index element in the collection GrowableElement* GrowableCache::at(int index) { GrowableElement *e = (GrowableElement *) _elements->at(index); - assert(e != NULL, "e != NULL"); + assert(e != nullptr, "e != nullptr"); return e; } @@ -177,7 +177,7 @@ void GrowableCache::append(GrowableElement* e) { // remove the element at index void GrowableCache::remove (int index) { GrowableElement *e = _elements->at(index); - assert(e != NULL, "e != NULL"); + assert(e != nullptr, "e != nullptr"); _elements->remove(e); delete e; recache(); @@ -200,7 +200,7 @@ void GrowableCache::clear() { JvmtiBreakpoint::JvmtiBreakpoint(Method* m_method, jlocation location) : _method(m_method), _bci((int)location) { - assert(_method != NULL, "No method for breakpoint."); + assert(_method != nullptr, "No method for breakpoint."); assert(_bci >= 0, "Negative bci for breakpoint."); oop class_holder_oop = _method->method_holder()->klass_holder(); _class_holder = OopHandle(JvmtiExport::jvmti_oop_storage(), class_holder_oop); @@ -236,7 +236,7 @@ void JvmtiBreakpoint::each_method_version_do(method_action meth_act) { // search previous versions if they exist for (InstanceKlass* pv_node = ik->previous_versions(); - pv_node != NULL; + pv_node != nullptr; pv_node = pv_node->previous_versions()) { Array* methods = pv_node->methods(); @@ -277,8 +277,8 @@ void JvmtiBreakpoint::clear() { void JvmtiBreakpoint::print_on(outputStream* out) const { #ifndef PRODUCT ResourceMark rm; - const char *class_name = (_method == NULL) ? "NULL" : _method->klass_name()->as_C_string(); - const char *method_name = (_method == NULL) ? "NULL" : _method->name()->as_C_string(); + const char *class_name = (_method == nullptr) ? "null" : _method->klass_name()->as_C_string(); + const char *method_name = (_method == nullptr) ? "null" : _method->name()->as_C_string(); out->print("Breakpoint(%s,%s,%d,%p)", class_name, method_name, _bci, getBcp()); #endif } @@ -402,23 +402,23 @@ void JvmtiBreakpoints::clearall_in_class_at_safepoint(Klass* klass) { // class JvmtiCurrentBreakpoints // -JvmtiBreakpoints *JvmtiCurrentBreakpoints::_jvmti_breakpoints = NULL; -address * JvmtiCurrentBreakpoints::_breakpoint_list = NULL; +JvmtiBreakpoints *JvmtiCurrentBreakpoints::_jvmti_breakpoints = nullptr; +address * JvmtiCurrentBreakpoints::_breakpoint_list = nullptr; JvmtiBreakpoints& JvmtiCurrentBreakpoints::get_jvmti_breakpoints() { - if (_jvmti_breakpoints != NULL) return (*_jvmti_breakpoints); + if (_jvmti_breakpoints != nullptr) return (*_jvmti_breakpoints); _jvmti_breakpoints = new JvmtiBreakpoints(listener_fun); - assert(_jvmti_breakpoints != NULL, "_jvmti_breakpoints != NULL"); + assert(_jvmti_breakpoints != nullptr, "_jvmti_breakpoints != nullptr"); return (*_jvmti_breakpoints); } void JvmtiCurrentBreakpoints::listener_fun(void *this_obj, address *cache) { JvmtiBreakpoints *this_jvmti = (JvmtiBreakpoints *) this_obj; - assert(this_jvmti != NULL, "this_jvmti != NULL"); + assert(this_jvmti != nullptr, "this_jvmti != nullptr"); debug_only(int n = this_jvmti->length();); - assert(cache[n] == NULL, "cache must be NULL terminated"); + assert(cache[n] == nullptr, "cache must be null terminated"); set_breakpoint_list(cache); } @@ -438,7 +438,7 @@ VM_BaseGetOrSetLocal::VM_BaseGetOrSetLocal(JavaThread* calling_thread, jint dept , _index(index) , _type(type) , _value(value) - , _jvf(NULL) + , _jvf(nullptr) , _set(set) , _self(self) , _result(JVMTI_ERROR_NONE) @@ -451,9 +451,9 @@ VM_BaseGetOrSetLocal::VM_BaseGetOrSetLocal(JavaThread* calling_thread, jint dept // This may cause unexpected consequences like CFLH or class-init JVMTI events. // It is better to avoid such a behavior. bool VM_BaseGetOrSetLocal::is_assignable(const char* ty_sign, Klass* klass, Thread* thread) { - assert(ty_sign != NULL, "type signature must not be NULL"); - assert(thread != NULL, "thread must not be NULL"); - assert(klass != NULL, "klass must not be NULL"); + assert(ty_sign != nullptr, "type signature must not be null"); + assert(thread != nullptr, "thread must not be null"); + assert(klass != nullptr, "klass must not be null"); int len = (int) strlen(ty_sign); if (ty_sign[0] == JVM_SIGNATURE_CLASS && @@ -545,7 +545,7 @@ bool VM_BaseGetOrSetLocal::check_slot_type_lvt(javaVFrame* jvf) { } jobject jobj = _value.l; - if (_set && slot_type == T_OBJECT && jobj != NULL) { // NULL reference is allowed + if (_set && slot_type == T_OBJECT && jobj != nullptr) { // null reference is allowed // Check that the jobject class matches the return type signature. oop obj = JNIHandles::resolve_external_guard(jobj); NULL_CHECK(obj, (_result = JVMTI_ERROR_INVALID_OBJECT, false)); @@ -606,7 +606,7 @@ bool VM_GetOrSetLocal::doit_prologue() { void VM_BaseGetOrSetLocal::doit() { _jvf = get_java_vframe(); - if (_jvf == NULL) { + if (_jvf == nullptr) { return; }; @@ -745,15 +745,15 @@ bool VM_BaseGetOrSetLocal::allow_nested_vm_operations() const { // Constructor for non-object getter VM_GetOrSetLocal::VM_GetOrSetLocal(JavaThread* thread, jint depth, jint index, BasicType type, bool self) - : VM_BaseGetOrSetLocal(NULL, depth, index, type, _DEFAULT_VALUE, false, self), + : VM_BaseGetOrSetLocal(nullptr, depth, index, type, _DEFAULT_VALUE, false, self), _thread(thread), - _eb(false, NULL, NULL) + _eb(false, nullptr, nullptr) { } // Constructor for object or non-object setter VM_GetOrSetLocal::VM_GetOrSetLocal(JavaThread* thread, jint depth, jint index, BasicType type, jvalue value, bool self) - : VM_BaseGetOrSetLocal(NULL, depth, index, type, value, true, self), + : VM_BaseGetOrSetLocal(nullptr, depth, index, type, value, true, self), _thread(thread), _eb(type == T_OBJECT, JavaThread::current(), thread) { @@ -769,7 +769,7 @@ VM_GetOrSetLocal::VM_GetOrSetLocal(JavaThread* thread, JavaThread* calling_threa vframe *VM_GetOrSetLocal::get_vframe() { if (!_thread->has_last_Java_frame()) { - return NULL; + return nullptr; } RegisterMap reg_map(_thread, RegisterMap::UpdateMap::include, @@ -777,7 +777,7 @@ vframe *VM_GetOrSetLocal::get_vframe() { RegisterMap::WalkContinuation::include); vframe *vf = JvmtiEnvBase::get_cthread_last_java_vframe(_thread, ®_map); int d = 0; - while ((vf != NULL) && (d < _depth)) { + while ((vf != nullptr) && (d < _depth)) { vf = vf->java_sender(); d++; } @@ -788,17 +788,17 @@ javaVFrame *VM_GetOrSetLocal::get_java_vframe() { vframe* vf = get_vframe(); if (!(_self || _thread->is_carrier_thread_suspended())) { _result = JVMTI_ERROR_THREAD_NOT_SUSPENDED; - return NULL; + return nullptr; } - if (vf == NULL) { + if (vf == nullptr) { _result = JVMTI_ERROR_NO_MORE_FRAMES; - return NULL; + return nullptr; } javaVFrame *jvf = (javaVFrame*)vf; if (!vf->is_java_frame()) { _result = JVMTI_ERROR_OPAQUE_FRAME; - return NULL; + return nullptr; } return jvf; } @@ -816,7 +816,7 @@ VM_GetReceiver::VM_GetReceiver( // Constructor for non-object getter VM_VirtualThreadGetOrSetLocal::VM_VirtualThreadGetOrSetLocal(JvmtiEnv* env, Handle vthread_h, jint depth, jint index, BasicType type, bool self) - : VM_BaseGetOrSetLocal(NULL, depth, index, type, _DEFAULT_VALUE, false, self) + : VM_BaseGetOrSetLocal(nullptr, depth, index, type, _DEFAULT_VALUE, false, self) { _env = env; _vthread_h = vthread_h; @@ -825,7 +825,7 @@ VM_VirtualThreadGetOrSetLocal::VM_VirtualThreadGetOrSetLocal(JvmtiEnv* env, Hand // Constructor for object or non-object setter VM_VirtualThreadGetOrSetLocal::VM_VirtualThreadGetOrSetLocal(JvmtiEnv* env, Handle vthread_h, jint depth, jint index, BasicType type, jvalue value, bool self) - : VM_BaseGetOrSetLocal(NULL, depth, index, type, value, true, self) + : VM_BaseGetOrSetLocal(nullptr, depth, index, type, value, true, self) { _env = env; _vthread_h = vthread_h; @@ -843,15 +843,15 @@ VM_VirtualThreadGetOrSetLocal::VM_VirtualThreadGetOrSetLocal(JvmtiEnv* env, Hand javaVFrame *VM_VirtualThreadGetOrSetLocal::get_java_vframe() { Thread* cur_thread = Thread::current(); oop cont = java_lang_VirtualThread::continuation(_vthread_h()); - assert(cont != NULL, "vthread contintuation must not be NULL"); + assert(cont != nullptr, "vthread contintuation must not be null"); - javaVFrame* jvf = NULL; + javaVFrame* jvf = nullptr; JavaThread* java_thread = JvmtiEnvBase::get_JavaThread_or_null(_vthread_h()); - bool is_cont_mounted = (java_thread != NULL); + bool is_cont_mounted = (java_thread != nullptr); if (!(_self || JvmtiVTSuspender::is_vthread_suspended(_vthread_h()))) { _result = JVMTI_ERROR_THREAD_NOT_SUSPENDED; - return NULL; + return nullptr; } if (is_cont_mounted) { @@ -870,19 +870,19 @@ javaVFrame *VM_VirtualThreadGetOrSetLocal::get_java_vframe() { } } int d = 0; - while ((jvf != NULL) && (d < _depth)) { + while ((jvf != nullptr) && (d < _depth)) { jvf = jvf->java_sender(); d++; } - if (d < _depth || jvf == NULL) { + if (d < _depth || jvf == nullptr) { _result = JVMTI_ERROR_NO_MORE_FRAMES; - return NULL; + return nullptr; } if ((_set && !is_cont_mounted) || !jvf->is_java_frame()) { _result = JVMTI_ERROR_OPAQUE_FRAME; - return NULL; + return nullptr; } return jvf; } @@ -982,11 +982,11 @@ void JvmtiDeferredEvent::post() { case TYPE_DYNAMIC_CODE_GENERATED: { JvmtiExport::post_dynamic_code_generated_internal( // if strdup failed give the event a default name - (_event_data.dynamic_code_generated.name == NULL) + (_event_data.dynamic_code_generated.name == nullptr) ? "unknown_code" : _event_data.dynamic_code_generated.name, _event_data.dynamic_code_generated.code_begin, _event_data.dynamic_code_generated.code_end); - if (_event_data.dynamic_code_generated.name != NULL) { + if (_event_data.dynamic_code_generated.name != nullptr) { // release our copy os::free((void *)_event_data.dynamic_code_generated.name); } @@ -995,9 +995,9 @@ void JvmtiDeferredEvent::post() { case TYPE_CLASS_UNLOAD: { JvmtiExport::post_class_unload_internal( // if strdup failed give the event a default name - (_event_data.class_unload.name == NULL) + (_event_data.class_unload.name == nullptr) ? "unknown_class" : _event_data.class_unload.name); - if (_event_data.class_unload.name != NULL) { + if (_event_data.class_unload.name != nullptr) { // release our copy os::free((void *)_event_data.class_unload.name); } @@ -1023,7 +1023,7 @@ void JvmtiDeferredEvent::run_nmethod_entry_barriers() { // Keep the nmethod for compiled_method_load from being unloaded. void JvmtiDeferredEvent::oops_do(OopClosure* f, CodeBlobClosure* cf) { - if (cf != NULL && _type == TYPE_COMPILED_METHOD_LOAD) { + if (cf != nullptr && _type == TYPE_COMPILED_METHOD_LOAD) { cf->do_code_blob(_event_data.compiled_method_load); } } @@ -1031,7 +1031,7 @@ void JvmtiDeferredEvent::oops_do(OopClosure* f, CodeBlobClosure* cf) { // The GC calls this and marks the nmethods here on the stack so that // they cannot be unloaded while in the queue. void JvmtiDeferredEvent::nmethods_do(CodeBlobClosure* cf) { - if (cf != NULL && _type == TYPE_COMPILED_METHOD_LOAD) { + if (cf != nullptr && _type == TYPE_COMPILED_METHOD_LOAD) { cf->do_code_blob(_event_data.compiled_method_load); } } @@ -1045,39 +1045,39 @@ bool JvmtiDeferredEventQueue::has_events() { // The events on the queue should all be posted after the live phase so this is an // ok check. Before the live phase, DynamicCodeGenerated events are posted directly. // If we add other types of events to the deferred queue, this could get ugly. - return JvmtiEnvBase::get_phase() == JVMTI_PHASE_LIVE && _queue_head != NULL; + return JvmtiEnvBase::get_phase() == JVMTI_PHASE_LIVE && _queue_head != nullptr; } void JvmtiDeferredEventQueue::enqueue(JvmtiDeferredEvent event) { // Events get added to the end of the queue (and are pulled off the front). QueueNode* node = new QueueNode(event); - if (_queue_tail == NULL) { + if (_queue_tail == nullptr) { _queue_tail = _queue_head = node; } else { - assert(_queue_tail->next() == NULL, "Must be the last element in the list"); + assert(_queue_tail->next() == nullptr, "Must be the last element in the list"); _queue_tail->set_next(node); _queue_tail = node; } - assert((_queue_head == NULL) == (_queue_tail == NULL), + assert((_queue_head == nullptr) == (_queue_tail == nullptr), "Inconsistent queue markers"); } JvmtiDeferredEvent JvmtiDeferredEventQueue::dequeue() { - assert(_queue_head != NULL, "Nothing to dequeue"); + assert(_queue_head != nullptr, "Nothing to dequeue"); - if (_queue_head == NULL) { + if (_queue_head == nullptr) { // Just in case this happens in product; it shouldn't but let's not crash return JvmtiDeferredEvent(); } QueueNode* node = _queue_head; _queue_head = _queue_head->next(); - if (_queue_head == NULL) { - _queue_tail = NULL; + if (_queue_head == nullptr) { + _queue_tail = nullptr; } - assert((_queue_head == NULL) == (_queue_tail == NULL), + assert((_queue_head == nullptr) == (_queue_tail == nullptr), "Inconsistent queue markers"); JvmtiDeferredEvent event = node->event(); @@ -1087,27 +1087,27 @@ JvmtiDeferredEvent JvmtiDeferredEventQueue::dequeue() { void JvmtiDeferredEventQueue::post(JvmtiEnv* env) { // Post events while nmethods are still in the queue and can't be unloaded. - while (_queue_head != NULL) { + while (_queue_head != nullptr) { _queue_head->event().post_compiled_method_load_event(env); dequeue(); } } void JvmtiDeferredEventQueue::run_nmethod_entry_barriers() { - for(QueueNode* node = _queue_head; node != NULL; node = node->next()) { + for(QueueNode* node = _queue_head; node != nullptr; node = node->next()) { node->event().run_nmethod_entry_barriers(); } } void JvmtiDeferredEventQueue::oops_do(OopClosure* f, CodeBlobClosure* cf) { - for(QueueNode* node = _queue_head; node != NULL; node = node->next()) { + for(QueueNode* node = _queue_head; node != nullptr; node = node->next()) { node->event().oops_do(f, cf); } } void JvmtiDeferredEventQueue::nmethods_do(CodeBlobClosure* cf) { - for(QueueNode* node = _queue_head; node != NULL; node = node->next()) { + for(QueueNode* node = _queue_head; node != nullptr; node = node->next()) { node->event().nmethods_do(cf); } } diff --git a/src/hotspot/share/prims/jvmtiImpl.hpp b/src/hotspot/share/prims/jvmtiImpl.hpp index 353896b386ff1..851dec72ee7db 100644 --- a/src/hotspot/share/prims/jvmtiImpl.hpp +++ b/src/hotspot/share/prims/jvmtiImpl.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -52,7 +52,7 @@ class JvmtiBreakpoints; // // GrowableCache is a permanent CHeap growable array of // -// In addition, the GrowableCache maintains a NULL terminated cache array of type address +// In addition, the GrowableCache maintains a null terminated cache array of type address // that's created from the element array using the function: // address GrowableElement::getCacheValue(). // @@ -162,7 +162,7 @@ class JvmtiBreakpoint : public GrowableElement { OopHandle _class_holder; // keeps _method memory from being deallocated public: - JvmtiBreakpoint() : _method(NULL), _bci(0) {} + JvmtiBreakpoint() : _method(nullptr), _bci(0) {} JvmtiBreakpoint(Method* m_method, jlocation location); virtual ~JvmtiBreakpoint(); bool equals(JvmtiBreakpoint& bp); @@ -248,7 +248,7 @@ class JvmtiCurrentBreakpoints : public AllStatic { // Current breakpoints, lazily initialized by get_jvmti_breakpoints(); static JvmtiBreakpoints *_jvmti_breakpoints; - // NULL terminated cache of byte-code pointers corresponding to current breakpoints. + // null terminated cache of byte-code pointers corresponding to current breakpoints. // Updated only at safepoints (with listener_fun) when the cache is moved. // It exists only to make is_breakpoint fast. static address *_breakpoint_list; @@ -289,7 +289,7 @@ class VM_ChangeBreakpoints : public VM_Operation { _breakpoints = ¤t_bps; _bp = bp; _operation = operation; - assert(bp != NULL, "bp != NULL"); + assert(bp != nullptr, "bp != null"); } VMOp_Type type() const { return VMOp_ChangeBreakpoints; } @@ -521,7 +521,7 @@ class JvmtiDeferredEventQueue : public CHeapObj { public: QueueNode(const JvmtiDeferredEvent& event) - : _event(event), _next(NULL) {} + : _event(event), _next(nullptr) {} JvmtiDeferredEvent& event() { return _event; } QueueNode* next() const { return _next; } @@ -533,7 +533,7 @@ class JvmtiDeferredEventQueue : public CHeapObj { QueueNode* _queue_tail; public: - JvmtiDeferredEventQueue() : _queue_head(NULL), _queue_tail(NULL) {} + JvmtiDeferredEventQueue() : _queue_head(nullptr), _queue_tail(nullptr) {} bool has_events() NOT_JVMTI_RETURN_(false); JvmtiDeferredEvent dequeue() NOT_JVMTI_RETURN_(JvmtiDeferredEvent()); @@ -549,7 +549,7 @@ class JvmtiDeferredEventQueue : public CHeapObj { void oops_do(OopClosure* f, CodeBlobClosure* cf) NOT_JVMTI_RETURN; }; -// Utility macro that checks for NULL pointers: -#define NULL_CHECK(X, Y) if ((X) == NULL) { return (Y); } +// Utility macro that checks for null pointers: +#define NULL_CHECK(X, Y) if ((X) == nullptr) { return (Y); } #endif // SHARE_PRIMS_JVMTIIMPL_HPP diff --git a/src/hotspot/share/prims/jvmtiRawMonitor.cpp b/src/hotspot/share/prims/jvmtiRawMonitor.cpp index c7531afa0b033..179a53ba851a6 100644 --- a/src/hotspot/share/prims/jvmtiRawMonitor.cpp +++ b/src/hotspot/share/prims/jvmtiRawMonitor.cpp @@ -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 @@ -31,7 +31,7 @@ #include "runtime/orderAccess.hpp" #include "runtime/threads.hpp" -JvmtiRawMonitor::QNode::QNode(Thread* thread) : _next(NULL), _prev(NULL), +JvmtiRawMonitor::QNode::QNode(Thread* thread) : _next(nullptr), _prev(nullptr), _event(thread->_ParkEvent), _notified(0), _t_state(TS_RUN) { } @@ -59,12 +59,12 @@ void JvmtiPendingMonitors::transition_raw_monitors() { // class JvmtiRawMonitor // -JvmtiRawMonitor::JvmtiRawMonitor(const char* name) : _owner(NULL), +JvmtiRawMonitor::JvmtiRawMonitor(const char* name) : _owner(nullptr), _recursions(0), - _entry_list(NULL), - _wait_set(NULL), + _entry_list(nullptr), + _wait_set(nullptr), _magic(JVMTI_RM_MAGIC), - _name(NULL) { + _name(nullptr) { #ifdef ASSERT _name = strcpy(NEW_C_HEAP_ARRAY(char, strlen(name) + 1, mtInternal), name); #endif @@ -138,7 +138,7 @@ void JvmtiRawMonitor::simple_enter(Thread* self) { node._next = _entry_list; _entry_list = &node; OrderAccess::fence(); - if (_owner == NULL && Atomic::replace_if_null(&_owner, self)) { + if (_owner == nullptr && Atomic::replace_if_null(&_owner, self)) { _entry_list = node._next; RawMonitor_lock->unlock(); if (self->is_Java_thread()) { @@ -155,22 +155,22 @@ void JvmtiRawMonitor::simple_enter(Thread* self) { void JvmtiRawMonitor::simple_exit(Thread* self) { guarantee(_owner == self, "invariant"); - Atomic::release_store(&_owner, (Thread*)NULL); + Atomic::release_store(&_owner, (Thread*)nullptr); OrderAccess::fence(); if (self->is_Java_thread()) { Continuation::unpin(JavaThread::cast(self)); } - if (_entry_list == NULL) { + if (_entry_list == nullptr) { return; } RawMonitor_lock->lock_without_safepoint_check(); QNode* w = _entry_list; - if (w != NULL) { + if (w != nullptr) { _entry_list = w->_next; } RawMonitor_lock->unlock(); - if (w != NULL) { + if (w != nullptr) { guarantee(w ->_t_state == QNode::TS_ENTER, "invariant"); // Once we set _t_state to TS_RUN the waiting thread can complete // simple_enter and 'w' is pointing into random stack space. So we have @@ -205,12 +205,12 @@ inline void JvmtiRawMonitor::dequeue_waiter(QNode& node) { if (node._t_state == QNode::TS_WAIT) { // Simple O(n) unlink, but performance isn't critical here. QNode* p; - QNode* q = NULL; + QNode* q = nullptr; for (p = _wait_set; p != &node; p = p->_next) { q = p; } guarantee(p == &node, "invariant"); - if (q == NULL) { + if (q == nullptr) { guarantee (p == _wait_set, "invariant"); _wait_set = p->_next; } else { @@ -281,7 +281,7 @@ int JvmtiRawMonitor::simple_wait(Thread* self, jlong millis) { void JvmtiRawMonitor::simple_notify(Thread* self, bool all) { guarantee(_owner == self, "invariant"); - if (_wait_set == NULL) { + if (_wait_set == nullptr) { return; } @@ -292,15 +292,15 @@ void JvmtiRawMonitor::simple_notify(Thread* self, bool all) { // We use (B), which is crude and results in lots of futile // context switching. In particular (B) induces lots of contention. - ParkEvent* ev = NULL; // consider using a small auto array ... + ParkEvent* ev = nullptr; // consider using a small auto array ... RawMonitor_lock->lock_without_safepoint_check(); for (;;) { QNode* w = _wait_set; - if (w == NULL) break; + if (w == nullptr) break; _wait_set = w->_next; - if (ev != NULL) { + if (ev != nullptr) { ev->unpark(); - ev = NULL; + ev = nullptr; } ev = w->_event; OrderAccess::loadstore(); @@ -311,7 +311,7 @@ void JvmtiRawMonitor::simple_notify(Thread* self, bool all) { } } RawMonitor_lock->unlock(); - if (ev != NULL) { + if (ev != nullptr) { ev->unpark(); } return; @@ -351,7 +351,7 @@ void JvmtiRawMonitor::raw_enter(Thread* self) { } } - self->set_current_pending_raw_monitor(NULL); + self->set_current_pending_raw_monitor(nullptr); guarantee(_owner == self, "invariant"); guarantee(_recursions == 0, "invariant"); diff --git a/src/hotspot/share/prims/jvmtiRedefineClasses.cpp b/src/hotspot/share/prims/jvmtiRedefineClasses.cpp index 52ae972a588ed..b28a8c4a859e8 100644 --- a/src/hotspot/share/prims/jvmtiRedefineClasses.cpp +++ b/src/hotspot/share/prims/jvmtiRedefineClasses.cpp @@ -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 @@ -64,12 +64,12 @@ #include "utilities/bitMap.inline.hpp" #include "utilities/events.hpp" -Array* VM_RedefineClasses::_old_methods = NULL; -Array* VM_RedefineClasses::_new_methods = NULL; -Method** VM_RedefineClasses::_matching_old_methods = NULL; -Method** VM_RedefineClasses::_matching_new_methods = NULL; -Method** VM_RedefineClasses::_deleted_methods = NULL; -Method** VM_RedefineClasses::_added_methods = NULL; +Array* VM_RedefineClasses::_old_methods = nullptr; +Array* VM_RedefineClasses::_new_methods = nullptr; +Method** VM_RedefineClasses::_matching_old_methods = nullptr; +Method** VM_RedefineClasses::_matching_new_methods = nullptr; +Method** VM_RedefineClasses::_deleted_methods = nullptr; +Method** VM_RedefineClasses::_added_methods = nullptr; int VM_RedefineClasses::_matching_methods_length = 0; int VM_RedefineClasses::_deleted_methods_length = 0; int VM_RedefineClasses::_added_methods_length = 0; @@ -86,7 +86,7 @@ VM_RedefineClasses::VM_RedefineClasses(jint class_count, _class_load_kind = class_load_kind; _any_class_has_resolved_methods = false; _res = JVMTI_ERROR_NONE; - _the_class = NULL; + _the_class = nullptr; _id = next_id(); } @@ -103,7 +103,7 @@ void VM_RedefineClasses::lock_classes() { MonitorLocker ml(RedefineClasses_lock); - if (redef_classes == NULL) { + if (redef_classes == nullptr) { redef_classes = new (mtClass) GrowableArray(1, mtClass); state->set_classes_being_redefined(redef_classes); } @@ -141,7 +141,7 @@ void VM_RedefineClasses::lock_classes() { void VM_RedefineClasses::unlock_classes() { JvmtiThreadState *state = JvmtiThreadState::state_for(JavaThread::current()); GrowableArray* redef_classes = state->get_classes_being_redefined(); - assert(redef_classes != NULL, "_classes_being_redefined is not allocated"); + assert(redef_classes != nullptr, "_classes_being_redefined is not allocated"); MonitorLocker ml(RedefineClasses_lock); @@ -170,13 +170,13 @@ bool VM_RedefineClasses::doit_prologue() { _res = JVMTI_ERROR_NONE; return false; } - if (_class_defs == NULL) { + if (_class_defs == nullptr) { _res = JVMTI_ERROR_NULL_POINTER; return false; } for (int i = 0; i < _class_count; i++) { - if (_class_defs[i].klass == NULL) { + if (_class_defs[i].klass == nullptr) { _res = JVMTI_ERROR_INVALID_CLASS; return false; } @@ -184,7 +184,7 @@ bool VM_RedefineClasses::doit_prologue() { _res = JVMTI_ERROR_INVALID_CLASS_FORMAT; return false; } - if (_class_defs[i].class_bytes == NULL) { + if (_class_defs[i].class_bytes == nullptr) { _res = JVMTI_ERROR_NULL_POINTER; return false; } @@ -211,14 +211,14 @@ bool VM_RedefineClasses::doit_prologue() { if (_res != JVMTI_ERROR_NONE) { // free any successfully created classes, since none are redefined for (int i = 0; i < _class_count; i++) { - if (_scratch_classes[i] != NULL) { + if (_scratch_classes[i] != nullptr) { ClassLoaderData* cld = _scratch_classes[i]->class_loader_data(); // Free the memory for this class at class unloading time. Not before // because CMS might think this is still live. InstanceKlass* ik = get_ik(_class_defs[i].klass); if (ik->get_cached_class_file() == _scratch_classes[i]->get_cached_class_file()) { // Don't double-free cached_class_file copied from the original class if error. - _scratch_classes[i]->set_cached_class_file(NULL); + _scratch_classes[i]->set_cached_class_file(nullptr); } cld->add_to_deallocate_list(InstanceKlass::cast(_scratch_classes[i])); } @@ -311,7 +311,7 @@ void VM_RedefineClasses::doit_epilogue() { os::free(_scratch_classes); // Reset the_class to null for error printing. - _the_class = NULL; + _the_class = nullptr; if (log_is_enabled(Info, redefine, class, timer)) { // Used to have separate timers for "doit" and "all", but the timer @@ -335,7 +335,7 @@ bool VM_RedefineClasses::is_modifiable_class(oop klass_mirror) { } Klass* k = java_lang_Class::as_Klass(klass_mirror); // classes for arrays cannot be redefined - if (k == NULL || !k->is_instance_klass()) { + if (k == nullptr || !k->is_instance_klass()) { return false; } @@ -479,7 +479,7 @@ void VM_RedefineClasses::append_entry(const constantPoolHandle& scratch_cp, int new_name_and_type_ref_i = find_or_append_indirect_entry(scratch_cp, name_and_type_ref_i, merge_cp_p, merge_cp_length_p); - const char *entry_name = NULL; + const char *entry_name = nullptr; switch (scratch_cp->tag_at(scratch_i).value()) { case JVM_CONSTANT_Fieldref: entry_name = "Fieldref"; @@ -720,7 +720,7 @@ int VM_RedefineClasses::find_or_append_operand(const constantPoolHandle& scratch void VM_RedefineClasses::finalize_operands_merge(const constantPoolHandle& merge_cp, TRAPS) { - if (merge_cp->operands() == NULL) { + if (merge_cp->operands() == nullptr) { return; } // Shrink the merge_cp operands @@ -738,7 +738,7 @@ void VM_RedefineClasses::finalize_operands_merge(const constantPoolHandle& merge } } // Clean-up - _operands_index_map_p = NULL; + _operands_index_map_p = nullptr; _operands_cur_length = 0; _operands_index_map_count = 0; } // end finalize_operands_merge() @@ -775,7 +775,7 @@ static jvmtiError check_attribute_arrays(const char* attr_name, Symbol** the_syms = NEW_RESOURCE_ARRAY_RETURN_NULL(Symbol*, array_len); Symbol** scr_syms = NEW_RESOURCE_ARRAY_RETURN_NULL(Symbol*, array_len); - if (the_syms == NULL || scr_syms == NULL) { + if (the_syms == nullptr || scr_syms == nullptr) { return JVMTI_ERROR_OUT_OF_MEMORY; } @@ -845,8 +845,8 @@ static jvmtiError check_record_attribute(InstanceKlass* the_class, InstanceKlass // Get lists of record components. Array* the_record = the_class->record_components(); Array* scr_record = scratch_class->record_components(); - bool the_record_exists = the_record != NULL; - bool scr_record_exists = scr_record != NULL; + bool the_record_exists = the_record != nullptr; + bool scr_record_exists = scr_record != nullptr; if (the_record_exists && scr_record_exists) { int the_num_components = the_record->length(); @@ -877,9 +877,9 @@ static jvmtiError check_record_attribute(InstanceKlass* the_class, InstanceKlass int the_gen_sig = the_component->generic_signature_index(); int scr_gen_sig = scr_component->generic_signature_index(); - const Symbol* const the_gen_sig_sym = (the_gen_sig == 0 ? NULL : + const Symbol* const the_gen_sig_sym = (the_gen_sig == 0 ? nullptr : the_cp->symbol_at(the_component->generic_signature_index())); - const Symbol* const scr_gen_sig_sym = (scr_gen_sig == 0 ? NULL : + const Symbol* const scr_gen_sig_sym = (scr_gen_sig == 0 ? nullptr : scr_cp->symbol_at(scr_component->generic_signature_index())); if (the_gen_sig_sym != scr_gen_sig_sym) { log_info(redefine, class, record) @@ -928,16 +928,16 @@ jvmtiError VM_RedefineClasses::compare_and_normalize_class_versions( // Check superclasses, or rather their names, since superclasses themselves can be // requested to replace. - // Check for NULL superclass first since this might be java.lang.Object + // Check for null superclass first since this might be java.lang.Object if (the_class->super() != scratch_class->super() && - (the_class->super() == NULL || scratch_class->super() == NULL || + (the_class->super() == nullptr || scratch_class->super() == nullptr || the_class->super()->name() != scratch_class->super()->name())) { log_info(redefine, class, normalize) ("redefined class %s superclass change error: superclass changed from %s to %s.", the_class->external_name(), - the_class->super() == NULL ? "NULL" : the_class->super()->external_name(), - scratch_class->super() == NULL ? "NULL" : scratch_class->super()->external_name()); + the_class->super() == nullptr ? "null" : the_class->super()->external_name(), + scratch_class->super() == nullptr ? "null" : scratch_class->super()->external_name()); return JVMTI_ERROR_UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED; } @@ -1150,7 +1150,7 @@ jvmtiError VM_RedefineClasses::compare_and_normalize_class_versions( u2 old_num = k_old_method->method_idnum(); if (new_num != old_num) { Method* idnum_owner = scratch_class->method_with_idnum(old_num); - if (idnum_owner != NULL) { + if (idnum_owner != nullptr) { // There is already a method assigned this idnum -- switch them // Take current and original idnum from the new_method idnum_owner->set_method_idnum(new_num); @@ -1190,7 +1190,7 @@ jvmtiError VM_RedefineClasses::compare_and_normalize_class_versions( } u2 new_num = k_new_method->method_idnum(); Method* idnum_owner = scratch_class->method_with_idnum(num); - if (idnum_owner != NULL) { + if (idnum_owner != nullptr) { // There is already a method assigned this idnum -- switch them // Take current and original idnum from the new_method idnum_owner->set_method_idnum(new_num); @@ -1350,21 +1350,21 @@ jvmtiError VM_RedefineClasses::load_new_class_versions() { // For consistency allocate memory using os::malloc wrapper. _scratch_classes = (InstanceKlass**) os::malloc(sizeof(InstanceKlass*) * _class_count, mtClass); - if (_scratch_classes == NULL) { + if (_scratch_classes == nullptr) { return JVMTI_ERROR_OUT_OF_MEMORY; } // Zero initialize the _scratch_classes array. for (int i = 0; i < _class_count; i++) { - _scratch_classes[i] = NULL; + _scratch_classes[i] = nullptr; } JavaThread* current = JavaThread::current(); ResourceMark rm(current); JvmtiThreadState *state = JvmtiThreadState::state_for(current); - // state can only be NULL if the current thread is exiting which + // state can only be null if the current thread is exiting which // should not happen since we're trying to do a RedefineClasses - guarantee(state != NULL, "exiting thread calling load_new_class_versions"); + guarantee(state != nullptr, "exiting thread calling load_new_class_versions"); for (int i = 0; i < _class_count; i++) { // Create HandleMark so that any handles created while loading new class // versions are deleted. Constant pools are deallocated while merging @@ -1435,7 +1435,7 @@ jvmtiError VM_RedefineClasses::load_new_class_versions() { if (HAS_PENDING_EXCEPTION) { Symbol* ex_name = PENDING_EXCEPTION->klass()->name(); oop message = java_lang_Throwable::message(PENDING_EXCEPTION); - if (message != NULL) { + if (message != nullptr) { char* ex_msg = java_lang_String::as_utf8_string(message); log_info(redefine, class, load, exceptions)("link_class exception: '%s %s'", ex_name->as_C_string(), ex_msg); @@ -1600,11 +1600,11 @@ bool VM_RedefineClasses::merge_constant_pools(const constantPoolHandle& old_cp, const constantPoolHandle& scratch_cp, constantPoolHandle *merge_cp_p, int *merge_cp_length_p, TRAPS) { - if (merge_cp_p == NULL) { + if (merge_cp_p == nullptr) { assert(false, "caller must provide scratch constantPool"); return false; // robustness } - if (merge_cp_length_p == NULL) { + if (merge_cp_length_p == nullptr) { assert(false, "caller must provide scratch CP length"); return false; // robustness } @@ -1784,10 +1784,10 @@ class MergeCPCleaner { ConstantPool* _scratch_cp; public: MergeCPCleaner(ClassLoaderData* loader_data, ConstantPool* merge_cp) : - _loader_data(loader_data), _cp(merge_cp), _scratch_cp(NULL) {} + _loader_data(loader_data), _cp(merge_cp), _scratch_cp(nullptr) {} ~MergeCPCleaner() { _loader_data->add_to_deallocate_list(_cp); - if (_scratch_cp != NULL) { + if (_scratch_cp != nullptr) { _loader_data->add_to_deallocate_list(_scratch_cp); } } @@ -1850,7 +1850,7 @@ jvmtiError VM_RedefineClasses::merge_cp_and_rewrite( merge_cp->set_pool_holder(scratch_class); bool result = merge_constant_pools(old_cp, scratch_cp, &merge_cp, &merge_cp_length, THREAD); - merge_cp->set_pool_holder(NULL); + merge_cp->set_pool_holder(nullptr); if (!result) { // The merge can fail due to memory allocation failure or due @@ -2062,7 +2062,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_nest_attributes( // Rewrite constant pool references in the Record attribute. bool VM_RedefineClasses::rewrite_cp_refs_in_record_attribute(InstanceKlass* scratch_class) { Array* components = scratch_class->record_components(); - if (components != NULL) { + if (components != nullptr) { for (int i = 0; i < components->length(); i++) { RecordComponent* component = components->at(i); u2 cp_index = component->name_index(); @@ -2075,7 +2075,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_record_attribute(InstanceKlass* scra } AnnotationArray* annotations = component->annotations(); - if (annotations != NULL && annotations->length() != 0) { + if (annotations != nullptr && annotations->length() != 0) { int byte_i = 0; // byte index into annotations if (!rewrite_cp_refs_in_annotations_typeArray(annotations, byte_i)) { log_debug(redefine, class, annotation)("bad record_component_annotations at %d", i); @@ -2085,7 +2085,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_record_attribute(InstanceKlass* scra } AnnotationArray* type_annotations = component->type_annotations(); - if (type_annotations != NULL && type_annotations->length() != 0) { + if (type_annotations != nullptr && type_annotations->length() != 0) { int byte_i = 0; // byte index into annotations if (!rewrite_cp_refs_in_annotations_typeArray(type_annotations, byte_i)) { log_debug(redefine, class, annotation)("bad record_component_type_annotations at %d", i); @@ -2103,7 +2103,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_permitted_subclasses_attribute( InstanceKlass* scratch_class) { Array* permitted_subclasses = scratch_class->permitted_subclasses(); - assert(permitted_subclasses != NULL, "unexpected null permitted_subclasses"); + assert(permitted_subclasses != nullptr, "unexpected null permitted_subclasses"); for (int i = 0; i < permitted_subclasses->length(); i++) { u2 cp_index = permitted_subclasses->at(i); permitted_subclasses->at_put(i, find_new_index(cp_index)); @@ -2116,7 +2116,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_methods(InstanceKlass* scratch_class Array* methods = scratch_class->methods(); - if (methods == NULL || methods->length() == 0) { + if (methods == nullptr || methods->length() == 0) { // no methods so nothing to do return true; } @@ -2214,7 +2214,7 @@ void VM_RedefineClasses::rewrite_cp_refs_in_method(methodHandle method, // and put_native_u2(). Bytes::put_Java_u2(bcp, new_index); - Relocator rc(method, NULL /* no RelocatorListener needed */); + Relocator rc(method, nullptr /* no RelocatorListener needed */); methodHandle m; { PauseNoSafepointVerifier pnsv(&nsv); @@ -2283,7 +2283,7 @@ void VM_RedefineClasses::rewrite_cp_refs_in_method(methodHandle method, bool VM_RedefineClasses::rewrite_cp_refs_in_class_annotations(InstanceKlass* scratch_class) { AnnotationArray* class_annotations = scratch_class->class_annotations(); - if (class_annotations == NULL || class_annotations->length() == 0) { + if (class_annotations == nullptr || class_annotations->length() == 0) { // no class_annotations so nothing to do return true; } @@ -2569,7 +2569,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_fields_annotations( Array* fields_annotations = scratch_class->fields_annotations(); - if (fields_annotations == NULL || fields_annotations->length() == 0) { + if (fields_annotations == nullptr || fields_annotations->length() == 0) { // no fields_annotations so nothing to do return true; } @@ -2578,7 +2578,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_fields_annotations( for (int i = 0; i < fields_annotations->length(); i++) { AnnotationArray* field_annotations = fields_annotations->at(i); - if (field_annotations == NULL || field_annotations->length() == 0) { + if (field_annotations == nullptr || field_annotations->length() == 0) { // this field does not have any annotations so skip it continue; } @@ -2603,7 +2603,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_methods_annotations( Method* m = scratch_class->methods()->at(i); AnnotationArray* method_annotations = m->constMethod()->method_annotations(); - if (method_annotations == NULL || method_annotations->length() == 0) { + if (method_annotations == nullptr || method_annotations->length() == 0) { // this method does not have any annotations so skip it continue; } @@ -2639,7 +2639,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_methods_parameter_annotations( for (int i = 0; i < scratch_class->methods()->length(); i++) { Method* m = scratch_class->methods()->at(i); AnnotationArray* method_parameter_annotations = m->constMethod()->parameter_annotations(); - if (method_parameter_annotations == NULL + if (method_parameter_annotations == nullptr || method_parameter_annotations->length() == 0) { // this method does not have any parameter annotations so skip it continue; @@ -2687,7 +2687,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_methods_default_annotations( for (int i = 0; i < scratch_class->methods()->length(); i++) { Method* m = scratch_class->methods()->at(i); AnnotationArray* method_default_annotations = m->constMethod()->default_annotations(); - if (method_default_annotations == NULL + if (method_default_annotations == nullptr || method_default_annotations->length() == 0) { // this method does not have any default annotations so skip it continue; @@ -2712,7 +2712,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_class_type_annotations( InstanceKlass* scratch_class) { AnnotationArray* class_type_annotations = scratch_class->class_type_annotations(); - if (class_type_annotations == NULL || class_type_annotations->length() == 0) { + if (class_type_annotations == nullptr || class_type_annotations->length() == 0) { // no class_type_annotations so nothing to do return true; } @@ -2729,7 +2729,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_class_type_annotations( bool VM_RedefineClasses::rewrite_cp_refs_in_fields_type_annotations(InstanceKlass* scratch_class) { Array* fields_type_annotations = scratch_class->fields_type_annotations(); - if (fields_type_annotations == NULL || fields_type_annotations->length() == 0) { + if (fields_type_annotations == nullptr || fields_type_annotations->length() == 0) { // no fields_type_annotations so nothing to do return true; } @@ -2738,7 +2738,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_fields_type_annotations(InstanceKlas for (int i = 0; i < fields_type_annotations->length(); i++) { AnnotationArray* field_type_annotations = fields_type_annotations->at(i); - if (field_type_annotations == NULL || field_type_annotations->length() == 0) { + if (field_type_annotations == nullptr || field_type_annotations->length() == 0) { // this field does not have any annotations so skip it continue; } @@ -2764,7 +2764,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_methods_type_annotations( Method* m = scratch_class->methods()->at(i); AnnotationArray* method_type_annotations = m->constMethod()->type_annotations(); - if (method_type_annotations == NULL || method_type_annotations->length() == 0) { + if (method_type_annotations == nullptr || method_type_annotations->length() == 0) { // this method does not have any annotations so skip it continue; } @@ -3736,7 +3736,7 @@ void VM_RedefineClasses::AdjustAndCleanMetadata::do_klass(Klass* k) { Array* methods = ik->methods(); int num_methods = methods->length(); for (int index = 0; index < num_methods; ++index) { - if (methods->at(index)->method_data() != NULL) { + if (methods->at(index)->method_data() != nullptr) { methods->at(index)->method_data()->clean_weak_method_links(); } } @@ -3775,16 +3775,16 @@ void VM_RedefineClasses::AdjustAndCleanMetadata::do_klass(Klass* k) { // this klass' constant pool cache may need adjustment ConstantPool* other_cp = ik->constants(); cp_cache = other_cp->cache(); - if (cp_cache != NULL) { + if (cp_cache != nullptr) { cp_cache->adjust_method_entries(&trace_name_printed); } // the previous versions' constant pool caches may need adjustment for (InstanceKlass* pv_node = ik->previous_versions(); - pv_node != NULL; + pv_node != nullptr; pv_node = pv_node->previous_versions()) { cp_cache = pv_node->constants()->cache(); - if (cp_cache != NULL) { + if (cp_cache != nullptr) { cp_cache->adjust_method_entries(&trace_name_printed); } } @@ -3795,7 +3795,7 @@ void VM_RedefineClasses::update_jmethod_ids() { for (int j = 0; j < _matching_methods_length; ++j) { Method* old_method = _matching_old_methods[j]; jmethodID jmid = old_method->find_jmethod_id_or_null(); - if (jmid != NULL) { + if (jmid != nullptr) { // There is a jmethodID, change it to point to the new method Method* new_method = _matching_new_methods[j]; Method::change_method_associated_with_jmethod_id(jmid, new_method); @@ -3978,9 +3978,9 @@ class TransferNativeFunctionRegistration { Method* search_prefix_name_space(int depth, char* name_str, size_t name_len, Symbol* signature) { TempNewSymbol name_symbol = SymbolTable::probe(name_str, (int)name_len); - if (name_symbol != NULL) { + if (name_symbol != nullptr) { Method* method = the_class->lookup_method(name_symbol, signature); - if (method != NULL) { + if (method != nullptr) { // Even if prefixed, intermediate methods must exist. if (method->is_native()) { // Wahoo, we found a (possibly prefixed) version of the method, return it. @@ -3989,7 +3989,7 @@ class TransferNativeFunctionRegistration { if (depth < prefix_count) { // Try applying further prefixes (other than this one). method = search_prefix_name_space(depth+1, name_str, name_len, signature); - if (method != NULL) { + if (method != nullptr) { return method; // found } @@ -4003,7 +4003,7 @@ class TransferNativeFunctionRegistration { strcat(trial_name_str, name_str); method = search_prefix_name_space(depth+1, trial_name_str, trial_len, signature); - if (method != NULL) { + if (method != nullptr) { // If found along this branch, it was prefixed, mark as such method->set_is_prefixed_native(); return method; // found @@ -4011,7 +4011,7 @@ class TransferNativeFunctionRegistration { } } } - return NULL; // This whole branch bore nothing + return nullptr; // This whole branch bore nothing } // Return the method name with old prefixes stripped away. @@ -4056,7 +4056,7 @@ class TransferNativeFunctionRegistration { if (old_method->is_native() && old_method->has_native_function()) { Method* new_method = strip_and_search_for_new_native(old_method); - if (new_method != NULL) { + if (new_method != nullptr) { // Actually set the native function in the new method. // Redefine does not send events (except CFLH), certainly not this // behind the scenes re-registration. @@ -4260,7 +4260,7 @@ void VM_RedefineClasses::redefine_single_class(Thread* current, jclass the_jclas PreviousVersionWalker pvw(ik); do { ik = pvw.next_previous_version(); - if (ik != NULL) { + if (ik != nullptr) { // attach previous version of klass to the new constant pool ik->set_constants(scratch_class->constants()); @@ -4273,7 +4273,7 @@ void VM_RedefineClasses::redefine_single_class(Thread* current, jclass the_jclas method->set_constants(scratch_class->constants()); } } - } while (ik != NULL); + } while (ik != nullptr); } #endif @@ -4343,9 +4343,9 @@ void VM_RedefineClasses::redefine_single_class(Thread* current, jclass the_jclas the_class->set_cached_class_file(scratch_class->get_cached_class_file()); } - // NULL out in scratch class to not delete twice. The class to be redefined + // null out in scratch class to not delete twice. The class to be redefined // always owns these bytes. - scratch_class->set_cached_class_file(NULL); + scratch_class->set_cached_class_file(nullptr); // Replace inner_classes Array* old_inner_classes = the_class->inner_classes(); @@ -4367,7 +4367,7 @@ void VM_RedefineClasses::redefine_single_class(Thread* current, jclass the_jclas // Copy the "source debug extension" attribute from new class version the_class->set_source_debug_extension( scratch_class->source_debug_extension(), - scratch_class->source_debug_extension() == NULL ? 0 : + scratch_class->source_debug_extension() == nullptr ? 0 : (int)strlen(scratch_class->source_debug_extension())); // Use of javac -g could be different in the old and the new @@ -4411,7 +4411,7 @@ void VM_RedefineClasses::redefine_single_class(Thread* current, jclass the_jclas _timer_rsc_phase2.start(); } - if (the_class->oop_map_cache() != NULL) { + if (the_class->oop_map_cache() != nullptr) { // Flush references to any obsolete methods from the oop map cache // so that obsolete methods are not pinned. the_class->oop_map_cache()->flush_obsolete_entries(); @@ -4498,8 +4498,8 @@ void VM_RedefineClasses::CheckClass::do_klass(Klass* k) { } // the constant pool cache should never contain non-deleted old or obsolete methods - if (ik->constants() != NULL && - ik->constants()->cache() != NULL && + if (ik->constants() != nullptr && + ik->constants()->cache() != nullptr && !ik->constants()->cache()->check_no_old_or_obsolete_entries()) { if (log_is_enabled(Trace, redefine, class, obsolete, metadata)) { log_trace(redefine, class, obsolete, metadata) @@ -4595,7 +4595,7 @@ void VM_RedefineClasses::dump_methods() { void VM_RedefineClasses::print_on_error(outputStream* st) const { VM_Operation::print_on_error(st); - if (_the_class != NULL) { + if (_the_class != nullptr) { ResourceMark rm; st->print_cr(", redefining class %s", _the_class->external_name()); } diff --git a/src/hotspot/share/prims/jvmtiRedefineClasses.hpp b/src/hotspot/share/prims/jvmtiRedefineClasses.hpp index 100b00d655229..ac4ccede7bee9 100644 --- a/src/hotspot/share/prims/jvmtiRedefineClasses.hpp +++ b/src/hotspot/share/prims/jvmtiRedefineClasses.hpp @@ -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 @@ -540,10 +540,10 @@ class VM_RedefineClasses: public VM_Operation { static bool is_modifiable_class(oop klass_mirror); static jint get_cached_class_file_len(JvmtiCachedClassFileData *cache) { - return cache == NULL ? 0 : cache->length; + return cache == nullptr ? 0 : cache->length; } static unsigned char * get_cached_class_file_bytes(JvmtiCachedClassFileData *cache) { - return cache == NULL ? NULL : cache->data; + return cache == nullptr ? nullptr : cache->data; } // Error printing diff --git a/src/hotspot/share/prims/jvmtiTagMap.cpp b/src/hotspot/share/prims/jvmtiTagMap.cpp index f73bc7432cb4e..3bf859da8e4a2 100644 --- a/src/hotspot/share/prims/jvmtiTagMap.cpp +++ b/src/hotspot/share/prims/jvmtiTagMap.cpp @@ -80,7 +80,7 @@ JvmtiTagMap::JvmtiTagMap(JvmtiEnv* env) : _posting_events(false) { assert(JvmtiThreadState_lock->is_locked(), "sanity check"); - assert(((JvmtiEnvBase *)env)->tag_map() == NULL, "tag map already exists for environment"); + assert(((JvmtiEnvBase *)env)->tag_map() == nullptr, "tag map already exists for environment"); _hashmap = new JvmtiTagMapTable(); @@ -93,11 +93,11 @@ JvmtiTagMap::~JvmtiTagMap() { // no lock acquired as we assume the enclosing environment is // also being destroyed. - ((JvmtiEnvBase *)_env)->set_tag_map(NULL); + ((JvmtiEnvBase *)_env)->set_tag_map(nullptr); // finally destroy the hashmap delete _hashmap; - _hashmap = NULL; + _hashmap = nullptr; } // Called by env_dispose() to reclaim memory before deallocation. @@ -112,10 +112,10 @@ void JvmtiTagMap::clear() { // doesn't exist then it is created. JvmtiTagMap* JvmtiTagMap::tag_map_for(JvmtiEnv* env) { JvmtiTagMap* tag_map = ((JvmtiEnvBase*)env)->tag_map_acquire(); - if (tag_map == NULL) { + if (tag_map == nullptr) { MutexLocker mu(JvmtiThreadState_lock); tag_map = ((JvmtiEnvBase*)env)->tag_map(); - if (tag_map == NULL) { + if (tag_map == nullptr) { tag_map = new JvmtiTagMap(env); } } else { @@ -143,7 +143,7 @@ void JvmtiTagMap::check_hashmap(GrowableArray* objects) { if (is_empty()) { return; } if (_needs_cleaning && - objects != NULL && + objects != nullptr && env()->is_enabled(JVMTI_EVENT_OBJECT_FREE)) { remove_dead_entries_locked(objects); } @@ -156,9 +156,9 @@ void JvmtiTagMap::check_hashmaps_for_heapwalk(GrowableArray* objects) { // Verify that the tag map tables are valid and unconditionally post events // that are expected to be posted before gc_notification. JvmtiEnvIterator it; - for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { + for (JvmtiEnv* env = it.first(); env != nullptr; env = it.next(env)) { JvmtiTagMap* tag_map = env->tag_map_acquire(); - if (tag_map != NULL) { + if (tag_map != nullptr) { // The ZDriver may be walking the hashmaps concurrently so this lock is needed. MutexLocker ml(tag_map->lock(), Mutex::_no_safepoint_check_flag); tag_map->check_hashmap(objects); @@ -340,7 +340,7 @@ void JvmtiTagMap::set_tag(jobject object, jlong tag) { // SetTag should not post events because the JavaThread has to // transition to native for the callback and this cannot stop for // safepoints with the hashmap lock held. - check_hashmap(NULL); /* don't collect dead objects */ + check_hashmap(nullptr); /* don't collect dead objects */ // resolve the object oop o = JNIHandles::resolve_non_null(object); @@ -375,7 +375,7 @@ jlong JvmtiTagMap::get_tag(jobject object) { // GetTag should not post events because the JavaThread has to // transition to native for the callback and this cannot stop for // safepoints with the hashmap lock held. - check_hashmap(NULL); /* don't collect dead objects */ + check_hashmap(nullptr); /* don't collect dead objects */ // resolve the object oop o = JNIHandles::resolve_non_null(object); @@ -535,7 +535,7 @@ JvmtiCachedClassFieldMap::JvmtiCachedClassFieldMap(ClassFieldMap* field_map) { } JvmtiCachedClassFieldMap::~JvmtiCachedClassFieldMap() { - if (_field_map != NULL) { + if (_field_map != nullptr) { delete _field_map; } } @@ -563,7 +563,7 @@ bool ClassFieldMapCacheMark::_is_active; // record that the given InstanceKlass is caching a field map void JvmtiCachedClassFieldMap::add_to_class_list(InstanceKlass* ik) { - if (_class_list == NULL) { + if (_class_list == nullptr) { _class_list = new (mtServiceability) GrowableArray(initial_class_count, mtServiceability); } @@ -581,8 +581,8 @@ ClassFieldMap* JvmtiCachedClassFieldMap::get_map_of_instance_fields(oop obj) { // return cached map if possible JvmtiCachedClassFieldMap* cached_map = ik->jvmti_cached_class_field_map(); - if (cached_map != NULL) { - assert(cached_map->field_map() != NULL, "missing field list"); + if (cached_map != nullptr) { + assert(cached_map->field_map() != nullptr, "missing field list"); return cached_map->field_map(); } else { ClassFieldMap* field_map = ClassFieldMap::create_map_of_instance_fields(obj); @@ -596,22 +596,22 @@ ClassFieldMap* JvmtiCachedClassFieldMap::get_map_of_instance_fields(oop obj) { // remove the fields maps cached from all instanceKlasses void JvmtiCachedClassFieldMap::clear_cache() { assert(Thread::current()->is_VM_thread(), "must be VMThread"); - if (_class_list != NULL) { + if (_class_list != nullptr) { for (int i = 0; i < _class_list->length(); i++) { InstanceKlass* ik = _class_list->at(i); JvmtiCachedClassFieldMap* cached_map = ik->jvmti_cached_class_field_map(); - assert(cached_map != NULL, "should not be NULL"); - ik->set_jvmti_cached_class_field_map(NULL); + assert(cached_map != nullptr, "should not be null"); + ik->set_jvmti_cached_class_field_map(nullptr); delete cached_map; // deletes the encapsulated field map } delete _class_list; - _class_list = NULL; + _class_list = nullptr; } } // returns the number of ClassFieldMap cached by instanceKlasses int JvmtiCachedClassFieldMap::cached_field_map_count() { - return (_class_list == NULL) ? 0 : _class_list->length(); + return (_class_list == nullptr) ? 0 : _class_list->length(); } // helper function to indicate if an object is filtered by its tag or class tag @@ -638,7 +638,7 @@ static inline bool is_filtered_by_heap_filter(jlong obj_tag, // helper function to indicate if an object is filtered by a klass filter static inline bool is_filtered_by_klass_filter(oop obj, Klass* klass_filter) { - if (klass_filter != NULL) { + if (klass_filter != nullptr) { if (obj->klass() != klass_filter) { return true; } @@ -679,7 +679,7 @@ static jint invoke_string_value_callback(jvmtiStringPrimitiveValueCallback cb, // JDK-6584008: the value field may be null if a String instance is // partially constructed. - if (s_value == NULL) { + if (s_value == nullptr) { return 0; } // get the string value and length @@ -942,12 +942,12 @@ void IterateOverHeapObjectClosure::do_object(oop o) { if (is_iteration_aborted()) return; // instanceof check when filtering by klass - if (klass() != NULL && !o->is_a(klass())) { + if (klass() != nullptr && !o->is_a(klass())) { return; } // skip if object is a dormant shared object whose mirror hasn't been loaded - if (o != NULL && o->klass()->java_mirror() == NULL) { + if (o != nullptr && o->klass()->java_mirror() == nullptr) { log_debug(cds, heap)("skipped dormant archived object " INTPTR_FORMAT " (%s)", p2i(o), o->klass()->external_name()); return; @@ -1033,7 +1033,7 @@ void IterateThroughHeapObjectClosure::do_object(oop obj) { if (is_filtered_by_klass_filter(obj, klass())) return; // skip if object is a dormant shared object whose mirror hasn't been loaded - if (obj != NULL && obj->klass()->java_mirror() == NULL) { + if (obj != nullptr && obj->klass()->java_mirror() == nullptr) { log_debug(cds, heap)("skipped dormant archived object " INTPTR_FORMAT " (%s)", p2i(obj), obj->klass()->external_name()); return; @@ -1052,7 +1052,7 @@ void IterateThroughHeapObjectClosure::do_object(oop obj) { int len = is_array ? arrayOop(obj)->length() : -1; // invoke the object callback (if callback is provided) - if (callbacks()->heap_iteration_callback != NULL) { + if (callbacks()->heap_iteration_callback != nullptr) { jvmtiHeapIterationCallback cb = callbacks()->heap_iteration_callback; jint res = (*cb)(wrapper.klass_tag(), wrapper.obj_size(), @@ -1063,7 +1063,7 @@ void IterateThroughHeapObjectClosure::do_object(oop obj) { } // for objects and classes we report primitive fields if callback provided - if (callbacks()->primitive_field_callback != NULL && obj->is_instance()) { + if (callbacks()->primitive_field_callback != nullptr && obj->is_instance()) { jint res; jvmtiPrimitiveFieldCallback cb = callbacks()->primitive_field_callback; if (obj->klass() == vmClasses::Class_klass()) { @@ -1082,7 +1082,7 @@ void IterateThroughHeapObjectClosure::do_object(oop obj) { // string callback if (!is_array && - callbacks()->string_primitive_value_callback != NULL && + callbacks()->string_primitive_value_callback != nullptr && obj->klass() == vmClasses::String_klass()) { jint res = invoke_string_value_callback( callbacks()->string_primitive_value_callback, @@ -1094,7 +1094,7 @@ void IterateThroughHeapObjectClosure::do_object(oop obj) { // array callback if (is_array && - callbacks()->array_primitive_value_callback != NULL && + callbacks()->array_primitive_value_callback != nullptr && obj->is_typeArray()) { jint res = invoke_array_primitive_value_callback( callbacks()->array_primitive_value_callback, @@ -1166,10 +1166,10 @@ void JvmtiTagMap::remove_dead_entries_locked(GrowableArray* objects) { if (_needs_cleaning) { // Recheck whether to post object free events under the lock. if (!env()->is_enabled(JVMTI_EVENT_OBJECT_FREE)) { - objects = NULL; + objects = nullptr; } log_info(jvmti, table)("TagMap table needs cleaning%s", - ((objects != NULL) ? " and posting" : "")); + ((objects != nullptr) ? " and posting" : "")); hashmap()->remove_dead_entries(objects); _needs_cleaning = false; } @@ -1182,7 +1182,7 @@ void JvmtiTagMap::remove_dead_entries(GrowableArray* objects) { void JvmtiTagMap::post_dead_objects(GrowableArray* const objects) { assert(Thread::current()->is_Java_thread(), "Must post from JavaThread"); - if (objects != NULL && objects->length() > 0) { + if (objects != nullptr && objects->length() > 0) { JvmtiExport::post_object_free(env(), objects); log_info(jvmti, table)("%d free object posted", objects->length()); } @@ -1220,7 +1220,7 @@ void JvmtiTagMap::flush_object_free_events() { ml.notify_all(); } } else { - remove_dead_entries(NULL); + remove_dead_entries(nullptr); } } @@ -1266,12 +1266,12 @@ class TagObjectCollector : public JvmtiTagMapKeyClosure { // SATB marking similar to other j.l.ref.Reference referents. This is // achieved by using a phantom load in the object() accessor. oop o = key.object(); - if (o == NULL) { + if (o == nullptr) { _some_dead_found = true; // skip this whole entry return true; } - assert(o != NULL && Universe::heap()->is_in(o), "sanity check"); + assert(o != nullptr && Universe::heap()->is_in(o), "sanity check"); jobject ref = JNIHandles::make_local(_thread, o); _object_results->append(ref); _tag_results->append(value); @@ -1287,9 +1287,9 @@ class TagObjectCollector : public JvmtiTagMapKeyClosure { int count = _object_results->length(); assert(count >= 0, "sanity check"); - // if object_result_ptr is not NULL then allocate the result and copy + // if object_result_ptr is not null then allocate the result and copy // in the object references. - if (object_result_ptr != NULL) { + if (object_result_ptr != nullptr) { error = _env->Allocate(count * sizeof(jobject), (unsigned char**)object_result_ptr); if (error != JVMTI_ERROR_NONE) { return error; @@ -1299,12 +1299,12 @@ class TagObjectCollector : public JvmtiTagMapKeyClosure { } } - // if tag_result_ptr is not NULL then allocate the result and copy + // if tag_result_ptr is not null then allocate the result and copy // in the tag values. - if (tag_result_ptr != NULL) { + if (tag_result_ptr != nullptr) { error = _env->Allocate(count * sizeof(jlong), (unsigned char**)tag_result_ptr); if (error != JVMTI_ERROR_NONE) { - if (object_result_ptr != NULL) { + if (object_result_ptr != nullptr) { _env->Deallocate((unsigned char*)object_result_ptr); } return error; @@ -1384,7 +1384,7 @@ class BasicHeapWalkContext: public HeapWalkContext { _heap_root_callback(heap_root_callback), _stack_ref_callback(stack_ref_callback), _object_ref_callback(object_ref_callback), - _last_referrer(NULL), + _last_referrer(nullptr), _last_referrer_tag(0) { } @@ -1587,7 +1587,7 @@ void CallbackInvoker::initialize_for_advanced_heap_walk(JvmtiTagMap* tag_map, inline bool CallbackInvoker::invoke_basic_heap_root_callback(jvmtiHeapRootKind root_kind, oop obj) { // if we heap roots should be reported jvmtiHeapRootCallback cb = basic_context()->heap_root_callback(); - if (cb == NULL) { + if (cb == nullptr) { return check_for_visit(obj); } @@ -1599,7 +1599,7 @@ inline bool CallbackInvoker::invoke_basic_heap_root_callback(jvmtiHeapRootKind r (void*)user_data()); // push root to visit stack when following references if (control == JVMTI_ITERATION_CONTINUE && - basic_context()->object_ref_callback() != NULL) { + basic_context()->object_ref_callback() != nullptr) { visit_stack()->push(obj); } return control != JVMTI_ITERATION_ABORT; @@ -1614,7 +1614,7 @@ inline bool CallbackInvoker::invoke_basic_stack_ref_callback(jvmtiHeapRootKind r oop obj) { // if we stack refs should be reported jvmtiStackReferenceCallback cb = basic_context()->stack_ref_callback(); - if (cb == NULL) { + if (cb == nullptr) { return check_for_visit(obj); } @@ -1630,7 +1630,7 @@ inline bool CallbackInvoker::invoke_basic_stack_ref_callback(jvmtiHeapRootKind r (void*)user_data()); // push root to visit stack when following references if (control == JVMTI_ITERATION_CONTINUE && - basic_context()->object_ref_callback() != NULL) { + basic_context()->object_ref_callback() != nullptr) { visit_stack()->push(obj); } return control != JVMTI_ITERATION_ABORT; @@ -1687,7 +1687,7 @@ inline bool CallbackInvoker::invoke_advanced_heap_root_callback(jvmtiHeapReferen // check that callback is provided jvmtiHeapReferenceCallback cb = context->heap_reference_callback(); - if (cb == NULL) { + if (cb == nullptr) { return check_for_visit(obj); } @@ -1711,12 +1711,12 @@ inline bool CallbackInvoker::invoke_advanced_heap_root_callback(jvmtiHeapReferen // invoke the callback jint res = (*cb)(ref_kind, - NULL, // referrer info + nullptr, // referrer info wrapper.klass_tag(), 0, // referrer_class_tag is 0 for heap root wrapper.obj_size(), wrapper.obj_tag_p(), - NULL, // referrer_tag_p + nullptr, // referrer_tag_p len, (void*)user_data()); if (res & JVMTI_VISIT_ABORT) { @@ -1741,7 +1741,7 @@ inline bool CallbackInvoker::invoke_advanced_stack_ref_callback(jvmtiHeapReferen // check that callback is provider jvmtiHeapReferenceCallback cb = context->heap_reference_callback(); - if (cb == NULL) { + if (cb == nullptr) { return check_for_visit(obj); } @@ -1779,7 +1779,7 @@ inline bool CallbackInvoker::invoke_advanced_stack_ref_callback(jvmtiHeapReferen 0, // referrer_class_tag is 0 for heap root (stack) wrapper.obj_size(), wrapper.obj_tag_p(), - NULL, // referrer_tag is 0 for root + nullptr, // referrer_tag is 0 for root len, (void*)user_data()); @@ -1793,7 +1793,7 @@ inline bool CallbackInvoker::invoke_advanced_stack_ref_callback(jvmtiHeapReferen } // This mask is used to pass reference_info to a jvmtiHeapReferenceCallback -// only for ref_kinds defined by the JVM TI spec. Otherwise, NULL is passed. +// only for ref_kinds defined by the JVM TI spec. Otherwise, null is passed. #define REF_INFO_MASK ((1 << JVMTI_HEAP_REFERENCE_FIELD) \ | (1 << JVMTI_HEAP_REFERENCE_STATIC_FIELD) \ | (1 << JVMTI_HEAP_REFERENCE_ARRAY_ELEMENT) \ @@ -1814,7 +1814,7 @@ inline bool CallbackInvoker::invoke_advanced_object_reference_callback(jvmtiHeap // check that callback is provider jvmtiHeapReferenceCallback cb = context->heap_reference_callback(); - if (cb == NULL) { + if (cb == nullptr) { return check_for_visit(obj); } @@ -1841,7 +1841,7 @@ inline bool CallbackInvoker::invoke_advanced_object_reference_callback(jvmtiHeap // invoke the callback int res = (*cb)(ref_kind, - (REF_INFO_MASK & (1 << ref_kind)) ? &reference_info : NULL, + (REF_INFO_MASK & (1 << ref_kind)) ? &reference_info : nullptr, wrapper.klass_tag(), wrapper.referrer_klass_tag(), wrapper.obj_size(), @@ -1880,7 +1880,7 @@ inline bool CallbackInvoker::report_primitive_array_values(oop obj) { assert(obj->is_typeArray(), "not a primitive array"); AdvancedHeapWalkContext* context = advanced_context(); - assert(context->array_primitive_value_callback() != NULL, "no callback"); + assert(context->array_primitive_value_callback() != nullptr, "no callback"); // apply class filter if (is_filtered_by_klass_filter(obj, context->klass_filter())) { @@ -1909,7 +1909,7 @@ inline bool CallbackInvoker::report_string_value(oop str) { assert(str->klass() == vmClasses::String_klass(), "not a string"); AdvancedHeapWalkContext* context = advanced_context(); - assert(context->string_primitive_value_callback() != NULL, "no callback"); + assert(context->string_primitive_value_callback() != nullptr, "no callback"); // apply class filter if (is_filtered_by_klass_filter(str, context->klass_filter())) { @@ -1944,7 +1944,7 @@ inline bool CallbackInvoker::report_primitive_field(jvmtiHeapReferenceKind ref_k static jvmtiHeapReferenceInfo reference_info = { 0 }; AdvancedHeapWalkContext* context = advanced_context(); - assert(context->primitive_field_callback() != NULL, "no callback"); + assert(context->primitive_field_callback() != nullptr, "no callback"); // apply class filter if (is_filtered_by_klass_filter(obj, context->klass_filter())) { @@ -2171,7 +2171,7 @@ class SimpleRootsClosure : public OopClosure { oop o = NativeAccess::oop_load(obj_p); // ignore null - if (o == NULL) { + if (o == nullptr) { return; } @@ -2215,7 +2215,7 @@ class JNILocalRootsClosure : public OopClosure { oop o = *obj_p; // ignore null - if (o == NULL) { + if (o == nullptr) { return; } @@ -2321,7 +2321,7 @@ VM_HeapWalkOperation::VM_HeapWalkOperation(JvmtiTagMap* tag_map, _is_advanced_heap_walk = false; _tag_map = tag_map; _initial_object = initial_object; - _following_object_refs = (callbacks.object_ref_callback() != NULL); + _following_object_refs = (callbacks.object_ref_callback() != nullptr); _reporting_primitive_fields = false; _reporting_primitive_array_values = false; _reporting_string_values = false; @@ -2340,9 +2340,9 @@ VM_HeapWalkOperation::VM_HeapWalkOperation(JvmtiTagMap* tag_map, _tag_map = tag_map; _initial_object = initial_object; _following_object_refs = true; - _reporting_primitive_fields = (callbacks.primitive_field_callback() != NULL);; - _reporting_primitive_array_values = (callbacks.array_primitive_value_callback() != NULL);; - _reporting_string_values = (callbacks.string_primitive_value_callback() != NULL);; + _reporting_primitive_fields = (callbacks.primitive_field_callback() != nullptr);; + _reporting_primitive_array_values = (callbacks.array_primitive_value_callback() != nullptr);; + _reporting_string_values = (callbacks.string_primitive_value_callback() != nullptr);; _visit_stack = create_visit_stack(); _dead_objects = objects; CallbackInvoker::initialize_for_advanced_heap_walk(tag_map, _visit_stack, user_data, callbacks, &_bitset); @@ -2350,9 +2350,9 @@ VM_HeapWalkOperation::VM_HeapWalkOperation(JvmtiTagMap* tag_map, VM_HeapWalkOperation::~VM_HeapWalkOperation() { if (_following_object_refs) { - assert(_visit_stack != NULL, "checking"); + assert(_visit_stack != nullptr, "checking"); delete _visit_stack; - _visit_stack = NULL; + _visit_stack = nullptr; } } @@ -2371,7 +2371,7 @@ inline bool VM_HeapWalkOperation::iterate_over_array(oop o) { // non-null element for (int index=0; indexlength(); index++) { oop elem = array->obj_at(index); - if (elem == NULL) { + if (elem == nullptr) { continue; } @@ -2436,7 +2436,7 @@ inline bool VM_HeapWalkOperation::iterate_over_class(oop java_class) { // super (only if something more interesting than java.lang.Object) InstanceKlass* java_super = ik->java_super(); - if (java_super != NULL && java_super != vmClasses::Object_klass()) { + if (java_super != nullptr && java_super != vmClasses::Object_klass()) { oop super = java_super->java_mirror(); if (!CallbackInvoker::report_superclass_reference(mirror, super)) { return false; @@ -2445,7 +2445,7 @@ inline bool VM_HeapWalkOperation::iterate_over_class(oop java_class) { // class loader oop cl = ik->class_loader(); - if (cl != NULL) { + if (cl != nullptr) { if (!CallbackInvoker::report_class_loader_reference(mirror, cl)) { return false; } @@ -2453,7 +2453,7 @@ inline bool VM_HeapWalkOperation::iterate_over_class(oop java_class) { // protection domain oop pd = ik->protection_domain(); - if (pd != NULL) { + if (pd != nullptr) { if (!CallbackInvoker::report_protection_domain_reference(mirror, pd)) { return false; } @@ -2461,7 +2461,7 @@ inline bool VM_HeapWalkOperation::iterate_over_class(oop java_class) { // signers oop signers = ik->signers(); - if (signers != NULL) { + if (signers != nullptr) { if (!CallbackInvoker::report_signers_reference(mirror, signers)) { return false; } @@ -2477,7 +2477,7 @@ inline bool VM_HeapWalkOperation::iterate_over_class(oop java_class) { if (tag.is_string()) { entry = pool->resolved_string_at(i); // If the entry is non-null it is resolved. - if (entry == NULL) { + if (entry == nullptr) { continue; } } else if (tag.is_klass()) { @@ -2488,7 +2488,7 @@ inline bool VM_HeapWalkOperation::iterate_over_class(oop java_class) { assert(tag.is_unresolved_klass(), "must be"); constantPoolHandle cp(Thread::current(), pool); Klass* klass = ConstantPool::klass_at_if_loaded(cp, i); - if (klass == NULL) { + if (klass == nullptr) { continue; } entry = klass->java_mirror(); @@ -2506,7 +2506,7 @@ inline bool VM_HeapWalkOperation::iterate_over_class(oop java_class) { Array* interfaces = ik->local_interfaces(); for (i = 0; i < interfaces->length(); i++) { oop interf = interfaces->at(i)->java_mirror(); - if (interf == NULL) { + if (interf == nullptr) { continue; } if (!CallbackInvoker::report_interface_reference(mirror, interf)) { @@ -2523,7 +2523,7 @@ inline bool VM_HeapWalkOperation::iterate_over_class(oop java_class) { if (!is_primitive_field_type(type)) { oop fld_o = mirror->obj_field(field->field_offset()); assert(verify_static_oop(ik, mirror, field->field_offset()), "sanity check"); - if (fld_o != NULL) { + if (fld_o != nullptr) { int slot = field->field_index(); if (!CallbackInvoker::report_static_field_reference(mirror, fld_o, slot)) { delete field_map; @@ -2566,7 +2566,7 @@ inline bool VM_HeapWalkOperation::iterate_over_object(oop o) { if (!is_primitive_field_type(type)) { oop fld_o = o->obj_field_access(field->field_offset()); // ignore any objects that aren't visible to profiler - if (fld_o != NULL) { + if (fld_o != nullptr) { assert(Universe::heap()->is_in(fld_o), "unsafe code should not " "have references to Klass* anymore"); int slot = field->field_index(); @@ -2643,7 +2643,7 @@ inline bool VM_HeapWalkOperation::collect_stack_roots(JavaThread* java_thread, JNILocalRootsClosure* blk) { oop threadObj = java_thread->threadObj(); - assert(threadObj != NULL, "sanity check"); + assert(threadObj != nullptr, "sanity check"); // only need to get the thread's tag once per thread jlong thread_tag = tag_for(_tag_map, threadObj); @@ -2668,9 +2668,9 @@ inline bool VM_HeapWalkOperation::collect_stack_roots(JavaThread* java_thread, bool is_top_frame = true; int depth = 0; - frame* last_entry_frame = NULL; + frame* last_entry_frame = nullptr; - while (vf != NULL) { + while (vf != nullptr) { if (vf->is_java_frame()) { // java frame (interpreted, compiled, ...) @@ -2685,7 +2685,7 @@ inline bool VM_HeapWalkOperation::collect_stack_roots(JavaThread* java_thread, for (int slot=0; slotsize(); slot++) { if (locals->at(slot)->type() == T_OBJECT) { oop o = locals->obj_at(slot)(); - if (o == NULL) { + if (o == nullptr) { continue; } @@ -2701,7 +2701,7 @@ inline bool VM_HeapWalkOperation::collect_stack_roots(JavaThread* java_thread, for (int index=0; index < exprs->size(); index++) { if (exprs->at(index)->type() == T_OBJECT) { oop o = exprs->obj_at(index)(); - if (o == NULL) { + if (o == nullptr) { continue; } @@ -2714,7 +2714,7 @@ inline bool VM_HeapWalkOperation::collect_stack_roots(JavaThread* java_thread, } // Follow oops from compiled nmethod - if (jvf->cb() != NULL && jvf->cb()->is_nmethod()) { + if (jvf->cb() != nullptr && jvf->cb()->is_nmethod()) { blk->set_context(thread_tag, tid, depth, method); jvf->cb()->as_nmethod()->oops_do(blk); } @@ -2724,20 +2724,20 @@ inline bool VM_HeapWalkOperation::collect_stack_roots(JavaThread* java_thread, // JNI locals for the top frame. java_thread->active_handles()->oops_do(blk); } else { - if (last_entry_frame != NULL) { + if (last_entry_frame != nullptr) { // JNI locals for the entry frame assert(last_entry_frame->is_entry_frame(), "checking"); last_entry_frame->entry_frame_call_wrapper()->handles()->oops_do(blk); } } } - last_entry_frame = NULL; + last_entry_frame = nullptr; depth++; } else { // externalVFrame - for an entry frame then we report the JNI locals // when we find the corresponding javaVFrame frame* fr = vf->frame_pointer(); - assert(fr != NULL, "sanity check"); + assert(fr != nullptr, "sanity check"); if (fr->is_entry_frame()) { last_entry_frame = fr; } @@ -2748,7 +2748,7 @@ inline bool VM_HeapWalkOperation::collect_stack_roots(JavaThread* java_thread, } } else { // no last java frame but there may be JNI locals - blk->set_context(thread_tag, tid, 0, (jmethodID)NULL); + blk->set_context(thread_tag, tid, 0, (jmethodID)nullptr); java_thread->active_handles()->oops_do(blk); } return true; @@ -2762,7 +2762,7 @@ inline bool VM_HeapWalkOperation::collect_stack_roots() { JNILocalRootsClosure blk; for (JavaThreadIteratorWithHandle jtiwh; JavaThread *thread = jtiwh.next(); ) { oop threadObj = thread->threadObj(); - if (threadObj != NULL && !thread->is_exiting() && !thread->is_hidden_from_external_view()) { + if (threadObj != nullptr && !thread->is_exiting() && !thread->is_hidden_from_external_view()) { // Collect the simple root for this thread before we // collect its stack roots if (!CallbackInvoker::report_simple_root(JVMTI_HEAP_REFERENCE_THREAD, @@ -2878,7 +2878,7 @@ void JvmtiTagMap::iterate_over_objects_reachable_from_object(jobject object, GrowableArray dead_objects(&dead_object_arena, 10, 0, 0); { MutexLocker ml(Heap_lock); - BasicHeapWalkContext context(NULL, NULL, object_ref_callback); + BasicHeapWalkContext context(nullptr, nullptr, object_ref_callback); VM_HeapWalkOperation op(this, initial_object, context, user_data, &dead_objects); VMThread::execute(&op); } @@ -2925,9 +2925,9 @@ void JvmtiTagMap::set_needs_cleaning() { DEBUG_ONLY(notified_needs_cleaning = true;) JvmtiEnvIterator it; - for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { + for (JvmtiEnv* env = it.first(); env != nullptr; env = it.next(env)) { JvmtiTagMap* tag_map = env->tag_map_acquire(); - if (tag_map != NULL) { + if (tag_map != nullptr) { tag_map->_needs_cleaning = !tag_map->is_empty(); } } @@ -2947,9 +2947,9 @@ void JvmtiTagMap::gc_notification(size_t num_dead_entries) { // If no dead entries then cancel cleaning requests. if (num_dead_entries == 0) { JvmtiEnvIterator it; - for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { + for (JvmtiEnv* env = it.first(); env != nullptr; env = it.next(env)) { JvmtiTagMap* tag_map = env->tag_map_acquire(); - if (tag_map != NULL) { + if (tag_map != nullptr) { MutexLocker ml (tag_map->lock(), Mutex::_no_safepoint_check_flag); tag_map->_needs_cleaning = false; } @@ -2969,9 +2969,9 @@ bool JvmtiTagMap::has_object_free_events_and_reset() { void JvmtiTagMap::flush_all_object_free_events() { JavaThread* thread = JavaThread::current(); JvmtiEnvIterator it; - for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { + for (JvmtiEnv* env = it.first(); env != nullptr; env = it.next(env)) { JvmtiTagMap* tag_map = env->tag_map_acquire(); - if (tag_map != NULL) { + if (tag_map != nullptr) { tag_map->flush_object_free_events(); ThreadBlockInVM tbiv(thread); // Be safepoint-polite while looping. } diff --git a/src/hotspot/share/prims/jvmtiTagMapTable.cpp b/src/hotspot/share/prims/jvmtiTagMapTable.cpp index 738fe9aa20048..9b0dda67e21fa 100644 --- a/src/hotspot/share/prims/jvmtiTagMapTable.cpp +++ b/src/hotspot/share/prims/jvmtiTagMapTable.cpp @@ -134,8 +134,8 @@ void JvmtiTagMapTable::remove_dead_entries(GrowableArray* objects) { GrowableArray* _objects; IsDead(GrowableArray* objects) : _objects(objects) {} bool do_entry(const JvmtiTagMapKey& entry, jlong tag) { - if (entry.object_no_keepalive() == NULL) { - if (_objects != NULL) { + if (entry.object_no_keepalive() == nullptr) { + if (_objects != nullptr) { _objects->append(tag); } return true; diff --git a/src/hotspot/share/prims/jvmtiTagMapTable.hpp b/src/hotspot/share/prims/jvmtiTagMapTable.hpp index 7d52cf4fa73bc..8e3631abb0081 100644 --- a/src/hotspot/share/prims/jvmtiTagMapTable.hpp +++ b/src/hotspot/share/prims/jvmtiTagMapTable.hpp @@ -55,7 +55,7 @@ class JvmtiTagMapKey : public CHeapObj { oop object_no_keepalive() const; static unsigned get_hash(const JvmtiTagMapKey& entry) { - assert(entry._obj != NULL, "must lookup obj to hash"); + assert(entry._obj != nullptr, "must lookup obj to hash"); return entry._obj->identity_hash(); } diff --git a/src/hotspot/share/prims/jvmtiThreadState.cpp b/src/hotspot/share/prims/jvmtiThreadState.cpp index 1a5f320cd6330..9c247eb75059d 100644 --- a/src/hotspot/share/prims/jvmtiThreadState.cpp +++ b/src/hotspot/share/prims/jvmtiThreadState.cpp @@ -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 @@ -51,28 +51,28 @@ static const int UNKNOWN_STACK_DEPTH = -99; // Thread local storage for JVMTI. // -JvmtiThreadState *JvmtiThreadState::_head = NULL; +JvmtiThreadState *JvmtiThreadState::_head = nullptr; JvmtiThreadState::JvmtiThreadState(JavaThread* thread, oop thread_oop) : _thread_event_enable() { assert(JvmtiThreadState_lock->is_locked(), "sanity check"); _thread = thread; - _thread_saved = NULL; + _thread_saved = nullptr; _exception_state = ES_CLEARED; _debuggable = true; _hide_single_stepping = false; _pending_interp_only_mode = false; _hide_level = 0; _pending_step_for_popframe = false; - _class_being_redefined = NULL; + _class_being_redefined = nullptr; _class_load_kind = jvmti_class_load_kind_load; - _classes_being_redefined = NULL; - _head_env_thread_state = NULL; - _dynamic_code_event_collector = NULL; - _vm_object_alloc_event_collector = NULL; - _sampled_object_alloc_event_collector = NULL; - _the_class_for_redefinition_verification = NULL; - _scratch_class_for_redefinition_verification = NULL; + _classes_being_redefined = nullptr; + _head_env_thread_state = nullptr; + _dynamic_code_event_collector = nullptr; + _vm_object_alloc_event_collector = nullptr; + _sampled_object_alloc_event_collector = nullptr; + _the_class_for_redefinition_verification = nullptr; + _scratch_class_for_redefinition_verification = nullptr; _cur_stack_depth = UNKNOWN_STACK_DEPTH; _saved_interp_only_mode = 0; @@ -81,9 +81,9 @@ JvmtiThreadState::JvmtiThreadState(JavaThread* thread, oop thread_oop) _earlyret_state = earlyret_inactive; _earlyret_tos = ilgl; _earlyret_value.j = 0L; - _earlyret_oop = NULL; + _earlyret_oop = nullptr; - _jvmti_event_queue = NULL; + _jvmti_event_queue = nullptr; _is_in_VTMS_transition = false; _is_virtual = false; @@ -92,7 +92,7 @@ JvmtiThreadState::JvmtiThreadState(JavaThread* thread, oop thread_oop) // add all the JvmtiEnvThreadState to the new JvmtiThreadState { JvmtiEnvIterator it; - for (JvmtiEnvBase* env = it.first(); env != NULL; env = it.next(env)) { + for (JvmtiEnvBase* env = it.first(); env != nullptr; env = it.next(env)) { if (env->is_valid()) { add_env(env); } @@ -105,21 +105,21 @@ JvmtiThreadState::JvmtiThreadState(JavaThread* thread, oop thread_oop) // See periodic_clean_up(). debug_only(NoSafepointVerifier nosafepoint;) - _prev = NULL; + _prev = nullptr; _next = _head; - if (_head != NULL) { + if (_head != nullptr) { _head->_prev = this; } _head = this; } - if (thread_oop != NULL) { + if (thread_oop != nullptr) { java_lang_Thread::set_jvmti_thread_state(thread_oop, this); _is_virtual = java_lang_VirtualThread::is_instance(thread_oop); } - if (thread != NULL) { - if (thread_oop == NULL || thread->jvmti_vthread() == NULL || thread->jvmti_vthread() == thread_oop) { + if (thread != nullptr) { + if (thread_oop == nullptr || thread->jvmti_vthread() == nullptr || thread->jvmti_vthread() == thread_oop) { // The JavaThread for carrier or mounted virtual thread case. // Set this only if thread_oop is current thread->jvmti_vthread(). thread->set_jvmti_thread_state(this); @@ -132,18 +132,18 @@ JvmtiThreadState::JvmtiThreadState(JavaThread* thread, oop thread_oop) JvmtiThreadState::~JvmtiThreadState() { assert(JvmtiThreadState_lock->is_locked(), "sanity check"); - if (_classes_being_redefined != NULL) { + if (_classes_being_redefined != nullptr) { delete _classes_being_redefined; // free the GrowableArray on C heap } // clear this as the state for the thread - get_thread()->set_jvmti_thread_state(NULL); + get_thread()->set_jvmti_thread_state(nullptr); // zap our env thread states { JvmtiEnvBase::entering_dying_thread_env_iteration(); JvmtiEnvThreadStateIterator it(this); - for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ) { + for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ) { JvmtiEnvThreadState* zap = ets; ets = it.next(ets); delete zap; @@ -157,21 +157,21 @@ JvmtiThreadState::~JvmtiThreadState() { // See periodic_clean_up(). debug_only(NoSafepointVerifier nosafepoint;) - if (_prev == NULL) { + if (_prev == nullptr) { assert(_head == this, "sanity check"); _head = _next; } else { assert(_head != this, "sanity check"); _prev->_next = _next; } - if (_next != NULL) { + if (_next != nullptr) { _next->_prev = _prev; } - _next = NULL; - _prev = NULL; + _next = nullptr; + _prev = nullptr; } - if (get_thread_oop() != NULL) { - java_lang_Thread::set_jvmti_thread_state(get_thread_oop(), NULL); + if (get_thread_oop() != nullptr) { + java_lang_Thread::set_jvmti_thread_state(get_thread_oop(), nullptr); } _thread_oop_h.release(JvmtiExport::jvmti_oop_storage()); } @@ -185,13 +185,13 @@ JvmtiThreadState::periodic_clean_up() { // because the latter requires the JvmtiThreadState_lock. // This iteration is safe at a safepoint as well, see the NoSafepointVerifier // asserts at all list manipulation sites. - for (JvmtiThreadState *state = _head; state != NULL; state = state->next()) { + for (JvmtiThreadState *state = _head; state != nullptr; state = state->next()) { // For each environment thread state corresponding to an invalid environment // unlink it from the list and deallocate it. JvmtiEnvThreadStateIterator it(state); - JvmtiEnvThreadState* previous_ets = NULL; + JvmtiEnvThreadState* previous_ets = nullptr; JvmtiEnvThreadState* ets = it.first(); - while (ets != NULL) { + while (ets != nullptr) { if (ets->get_env()->is_valid()) { previous_ets = ets; ets = it.next(ets); @@ -199,7 +199,7 @@ JvmtiThreadState::periodic_clean_up() { // This one isn't valid, remove it from the list and deallocate it JvmtiEnvThreadState* defunct_ets = ets; ets = ets->next(); - if (previous_ets == NULL) { + if (previous_ets == nullptr) { assert(state->head_env_thread_state() == defunct_ets, "sanity check"); state->set_head_env_thread_state(ets); } else { @@ -244,7 +244,7 @@ JvmtiVTMSTransitionDisabler::JvmtiVTMSTransitionDisabler(bool is_SR) { if (!Continuations::enabled()) { return; // JvmtiVTMSTransitionDisabler is no-op without virtual threads } - if (Thread::current_or_null() == NULL) { + if (Thread::current_or_null() == nullptr) { return; // Detached thread, can be a call from Agent_OnLoad. } _is_SR = is_SR; @@ -255,7 +255,7 @@ JvmtiVTMSTransitionDisabler::~JvmtiVTMSTransitionDisabler() { if (!Continuations::enabled()) { return; // JvmtiVTMSTransitionDisabler is a no-op without virtual threads } - if (Thread::current_or_null() == NULL) { + if (Thread::current_or_null() == nullptr) { return; // Detached thread, can be a call from Agent_OnLoad. } enable_VTMS_transitions(); @@ -380,7 +380,7 @@ JvmtiVTMSTransitionDisabler::start_VTMS_transition(jthread vthread, bool is_moun assert(!thread->is_in_VTMS_transition(), "VTMS_transition sanity check"); thread->set_is_in_VTMS_transition(true); JvmtiThreadState* vstate = java_lang_Thread::jvmti_thread_state(vth()); - if (vstate != NULL) { + if (vstate != nullptr) { vstate->set_is_in_VTMS_transition(true); } } @@ -394,7 +394,7 @@ JvmtiVTMSTransitionDisabler::finish_VTMS_transition(jthread vthread, bool is_mou oop vt = JNIHandles::resolve_external_guard(vthread); int64_t thread_id = java_lang_Thread::thread_id(vt); JvmtiThreadState* vstate = java_lang_Thread::jvmti_thread_state(vt); - if (vstate != NULL) { + if (vstate != nullptr) { vstate->set_is_in_VTMS_transition(false); } @@ -530,11 +530,11 @@ void JvmtiThreadState::add_env(JvmtiEnvBase *env) { debug_only(NoSafepointVerifier nosafepoint;) JvmtiEnvThreadStateIterator it(this); - JvmtiEnvThreadState* previous_ets = NULL; - for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { + JvmtiEnvThreadState* previous_ets = nullptr; + for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) { previous_ets = ets; } - if (previous_ets == NULL) { + if (previous_ets == nullptr) { set_head_env_thread_state(new_ets); } else { previous_ets->set_next(new_ets); @@ -543,14 +543,14 @@ void JvmtiThreadState::add_env(JvmtiEnvBase *env) { } void JvmtiThreadState::enter_interp_only_mode() { - assert(_thread != NULL, "sanity check"); + assert(_thread != nullptr, "sanity check"); _thread->increment_interp_only_mode(); invalidate_cur_stack_depth(); } void JvmtiThreadState::leave_interp_only_mode() { assert(is_interp_only_mode(), "leaving interp only when not in interp only mode"); - if (_thread == NULL) { + if (_thread == nullptr) { // Unmounted virtual thread updates the saved value. --_saved_interp_only_mode; } else { @@ -564,7 +564,7 @@ int JvmtiThreadState::count_frames() { JavaThread* thread = get_thread_or_saved(); javaVFrame *jvf; ResourceMark rm; - if (thread == NULL) { + if (thread == nullptr) { oop thread_obj = get_thread_oop(); jvf = JvmtiEnvBase::get_vthread_jvf(thread_obj); } else { @@ -670,7 +670,7 @@ void JvmtiThreadState::process_pending_step_for_popframe() { // and current method_id after pop and step for recursive calls. // Force the step by clearing the last location. JvmtiEnvThreadStateIterator it(this); - for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { + for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) { ets->clear_current_location(); } } @@ -692,7 +692,7 @@ void JvmtiThreadState::update_for_pop_top_frame() { int popframe_number = cur_stack_depth(); { JvmtiEnvThreadStateIterator it(this); - for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { + for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) { if (ets->is_frame_pop(popframe_number)) { ets->clear_frame_pop(popframe_number); } @@ -723,7 +723,7 @@ void JvmtiThreadState::process_pending_step_for_earlyret() { // is the case, then we consider our return from compiled code to // complete the ForceEarlyReturn request and we clear the condition. clr_earlyret_pending(); - set_earlyret_oop(NULL); + set_earlyret_oop(nullptr); clr_earlyret_value(); } @@ -745,7 +745,7 @@ void JvmtiThreadState::process_pending_step_for_earlyret() { // method_id after earlyret and step for recursive calls. // Force the step by clearing the last location. JvmtiEnvThreadStateIterator it(this); - for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { + for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) { ets->clear_current_location(); } } @@ -754,21 +754,21 @@ void JvmtiThreadState::oops_do(OopClosure* f, CodeBlobClosure* cf) { f->do_oop((oop*) &_earlyret_oop); // Keep nmethods from unloading on the event queue - if (_jvmti_event_queue != NULL) { + if (_jvmti_event_queue != nullptr) { _jvmti_event_queue->oops_do(f, cf); } } void JvmtiThreadState::nmethods_do(CodeBlobClosure* cf) { // Keep nmethods from unloading on the event queue - if (_jvmti_event_queue != NULL) { + if (_jvmti_event_queue != nullptr) { _jvmti_event_queue->nmethods_do(cf); } } // Thread local event queue. void JvmtiThreadState::enqueue_event(JvmtiDeferredEvent* event) { - if (_jvmti_event_queue == NULL) { + if (_jvmti_event_queue == nullptr) { _jvmti_event_queue = new JvmtiDeferredEventQueue(); } // copy the event @@ -776,15 +776,15 @@ void JvmtiThreadState::enqueue_event(JvmtiDeferredEvent* event) { } void JvmtiThreadState::post_events(JvmtiEnv* env) { - if (_jvmti_event_queue != NULL) { + if (_jvmti_event_queue != nullptr) { _jvmti_event_queue->post(env); // deletes each queue node delete _jvmti_event_queue; - _jvmti_event_queue = NULL; + _jvmti_event_queue = nullptr; } } void JvmtiThreadState::run_nmethod_entry_barriers() { - if (_jvmti_event_queue != NULL) { + if (_jvmti_event_queue != nullptr) { _jvmti_event_queue->run_nmethod_entry_barriers(); } } @@ -794,8 +794,8 @@ oop JvmtiThreadState::get_thread_oop() { } void JvmtiThreadState::set_thread(JavaThread* thread) { - _thread_saved = NULL; // Common case. - if (!_is_virtual && thread == NULL) { + _thread_saved = nullptr; // Common case. + if (!_is_virtual && thread == nullptr) { // Save JavaThread* if carrier thread is being detached. _thread_saved = _thread; } diff --git a/src/hotspot/share/prims/jvmtiThreadState.hpp b/src/hotspot/share/prims/jvmtiThreadState.hpp index e58c895afe471..029f2852eef4c 100644 --- a/src/hotspot/share/prims/jvmtiThreadState.hpp +++ b/src/hotspot/share/prims/jvmtiThreadState.hpp @@ -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 @@ -192,11 +192,11 @@ class JvmtiThreadState : public CHeapObj { JvmtiThreadState *_next; JvmtiThreadState *_prev; - // holds the current dynamic code event collector, NULL if no event collector in use + // holds the current dynamic code event collector, null if no event collector in use JvmtiDynamicCodeEventCollector* _dynamic_code_event_collector; - // holds the current vm object alloc event collector, NULL if no event collector in use + // holds the current vm object alloc event collector, null if no event collector in use JvmtiVMObjectAllocEventCollector* _vm_object_alloc_event_collector; - // holds the current sampled object alloc event collector, NULL if no event collector in use + // holds the current sampled object alloc event collector, null if no event collector in use JvmtiSampledObjectAllocEventCollector* _sampled_object_alloc_event_collector; // Should only be created by factory methods @@ -234,7 +234,7 @@ class JvmtiThreadState : public CHeapObj { // Used by the interpreter for fullspeed debugging support bool is_interp_only_mode() { - return _thread == NULL ? _saved_interp_only_mode != 0 : _thread->is_interp_only_mode(); + return _thread == nullptr ? _saved_interp_only_mode != 0 : _thread->is_interp_only_mode(); } void enter_interp_only_mode(); void leave_interp_only_mode(); @@ -263,7 +263,7 @@ class JvmtiThreadState : public CHeapObj { int count_frames(); inline JavaThread *get_thread() { return _thread; } - inline JavaThread *get_thread_or_saved(); // return _thread_saved if _thread is NULL + inline JavaThread *get_thread_or_saved(); // return _thread_saved if _thread is null // Needed for virtual threads as they can migrate to different JavaThread's. // Also used for carrier threads to clear/restore _thread. @@ -331,7 +331,7 @@ class JvmtiThreadState : public CHeapObj { } inline void clear_class_being_redefined() { - _class_being_redefined = NULL; + _class_being_redefined = nullptr; _class_load_kind = jvmti_class_load_kind_load; } @@ -384,13 +384,13 @@ class JvmtiThreadState : public CHeapObj { _scratch_class_for_redefinition_verification = scratch_class; } - inline void clear_class_versions_map() { set_class_versions_map(NULL, NULL); } + inline void clear_class_versions_map() { set_class_versions_map(nullptr, nullptr); } static inline Klass* class_to_verify_considering_redefinition(Klass* klass, JavaThread *thread) { JvmtiThreadState *state = thread->jvmti_thread_state(); - if (state != NULL && state->_the_class_for_redefinition_verification != NULL) { + if (state != nullptr && state->_the_class_for_redefinition_verification != nullptr) { if (state->_the_class_for_redefinition_verification == klass) { klass = state->_scratch_class_for_redefinition_verification; } @@ -442,10 +442,10 @@ class JvmtiThreadState : public CHeapObj { void update_for_pop_top_frame(); // already holding JvmtiThreadState_lock - retrieve or create JvmtiThreadState - // Can return NULL if JavaThread is exiting. - static JvmtiThreadState *state_for_while_locked(JavaThread *thread, oop thread_oop = NULL); + // Can return null if JavaThread is exiting. + static JvmtiThreadState *state_for_while_locked(JavaThread *thread, oop thread_oop = nullptr); // retrieve or create JvmtiThreadState - // Can return NULL if JavaThread is exiting. + // Can return null if JavaThread is exiting. static JvmtiThreadState *state_for(JavaThread *thread, Handle thread_handle = Handle()); // JVMTI ForceEarlyReturn support diff --git a/src/hotspot/share/prims/jvmtiThreadState.inline.hpp b/src/hotspot/share/prims/jvmtiThreadState.inline.hpp index 8c466e72841dc..bbcbe14e56e99 100644 --- a/src/hotspot/share/prims/jvmtiThreadState.inline.hpp +++ b/src/hotspot/share/prims/jvmtiThreadState.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2022, 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 @@ -56,12 +56,12 @@ inline JvmtiEnvThreadState* JvmtiEnvThreadStateIterator::next(JvmtiEnvThreadStat JvmtiEnvThreadState* JvmtiThreadState::env_thread_state(JvmtiEnvBase *env) { JvmtiEnvThreadStateIterator it(this); - for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { + for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) { if ((JvmtiEnvBase*)(ets->get_env()) == env) { return ets; } } - return NULL; + return nullptr; } JvmtiEnvThreadState* JvmtiThreadState::head_env_thread_state() { @@ -74,27 +74,27 @@ void JvmtiThreadState::set_head_env_thread_state(JvmtiEnvThreadState* ets) { inline JvmtiThreadState* JvmtiThreadState::state_for_while_locked(JavaThread *thread, oop thread_oop) { assert(JvmtiThreadState_lock->is_locked(), "sanity check"); - assert(thread != NULL || thread_oop != NULL, "sanity check"); + assert(thread != nullptr || thread_oop != nullptr, "sanity check"); NoSafepointVerifier nsv; // oop is safe to use. - if (thread_oop == NULL) { // Then thread should not be NULL (see assert above). - thread_oop = thread->jvmti_vthread() != NULL ? thread->jvmti_vthread() : thread->threadObj(); + if (thread_oop == nullptr) { // Then thread should not be null (see assert above). + thread_oop = thread->jvmti_vthread() != nullptr ? thread->jvmti_vthread() : thread->threadObj(); } - // In a case of unmounted virtual thread the thread can be NULL. - JvmtiThreadState *state = thread == NULL ? NULL : thread->jvmti_thread_state(); + // In a case of unmounted virtual thread the thread can be null. + JvmtiThreadState *state = thread == nullptr ? nullptr : thread->jvmti_thread_state(); - if (state == NULL && thread != NULL && thread->is_exiting()) { + if (state == nullptr && thread != nullptr && thread->is_exiting()) { // Don't add a JvmtiThreadState to a thread that is exiting. - return NULL; + return nullptr; } - if (state == NULL || state->get_thread_oop() != thread_oop) { + if (state == nullptr || state->get_thread_oop() != thread_oop) { // Check if java_lang_Thread already has a link to the JvmtiThreadState. - if (thread_oop != NULL) { // thread_oop can be NULL during early VMStart. + if (thread_oop != nullptr) { // thread_oop can be null during early VMStart. state = java_lang_Thread::jvmti_thread_state(thread_oop); } - if (state == NULL) { // Need to create state. + if (state == nullptr) { // Need to create state. state = new JvmtiThreadState(thread, thread_oop); } } @@ -102,10 +102,10 @@ inline JvmtiThreadState* JvmtiThreadState::state_for_while_locked(JavaThread *th } inline JvmtiThreadState* JvmtiThreadState::state_for(JavaThread *thread, Handle thread_handle) { - // In a case of unmounted virtual thread the thread can be NULL. - JvmtiThreadState* state = thread_handle == NULL ? thread->jvmti_thread_state() : + // In a case of unmounted virtual thread the thread can be null. + JvmtiThreadState* state = thread_handle == nullptr ? thread->jvmti_thread_state() : java_lang_Thread::jvmti_thread_state(thread_handle()); - if (state == NULL) { + if (state == nullptr) { MutexLocker mu(JvmtiThreadState_lock); // check again with the lock held state = state_for_while_locked(thread, thread_handle()); @@ -118,8 +118,8 @@ inline JvmtiThreadState* JvmtiThreadState::state_for(JavaThread *thread, Handle } inline JavaThread* JvmtiThreadState::get_thread_or_saved() { - // Use _thread_saved if cthread is detached from JavaThread (_thread == NULL). - return (_thread == NULL && !is_virtual()) ? _thread_saved : _thread; + // Use _thread_saved if cthread is detached from JavaThread (_thread == null). + return (_thread == nullptr && !is_virtual()) ? _thread_saved : _thread; } inline void JvmtiThreadState::set_should_post_on_exceptions(bool val) { @@ -127,17 +127,17 @@ inline void JvmtiThreadState::set_should_post_on_exceptions(bool val) { } inline void JvmtiThreadState::unbind_from(JvmtiThreadState* state, JavaThread* thread) { - if (state == NULL) { + if (state == nullptr) { return; } // Save thread's interp_only_mode. state->_saved_interp_only_mode = thread->get_interp_only_mode(); - state->set_thread(NULL); // Make sure stale _thread value is never used. + state->set_thread(nullptr); // Make sure stale _thread value is never used. } inline void JvmtiThreadState::bind_to(JvmtiThreadState* state, JavaThread* thread) { // Restore thread's interp_only_mode. - thread->set_interp_only_mode(state == NULL ? 0 : state->_saved_interp_only_mode); + thread->set_interp_only_mode(state == nullptr ? 0 : state->_saved_interp_only_mode); // Make continuation notice the interp_only_mode change. Continuation::set_cont_fastpath_thread_state(thread); @@ -145,7 +145,7 @@ inline void JvmtiThreadState::bind_to(JvmtiThreadState* state, JavaThread* threa // Bind JavaThread to JvmtiThreadState. thread->set_jvmti_thread_state(state); - if (state != NULL) { + if (state != nullptr) { // Bind to JavaThread. state->set_thread(thread); } diff --git a/src/hotspot/share/prims/jvmtiTrace.cpp b/src/hotspot/share/prims/jvmtiTrace.cpp index 0325def9a37c4..cf4b8b021a9df 100644 --- a/src/hotspot/share/prims/jvmtiTrace.cpp +++ b/src/hotspot/share/prims/jvmtiTrace.cpp @@ -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 @@ -79,7 +79,7 @@ void JvmtiTrace::initialize() { const char *very_end; const char *curr; - if (TraceJVMTI != NULL) { + if (TraceJVMTI != nullptr) { curr = TraceJVMTI; } else { curr = ""; // hack in fixed tracing here @@ -98,18 +98,18 @@ void JvmtiTrace::initialize() { very_end = curr + strlen(curr); while (curr < very_end) { const char *curr_end = strchr(curr, ','); - if (curr_end == NULL) { + if (curr_end == nullptr) { curr_end = very_end; } const char *op_pos = strchr(curr, '+'); const char *minus_pos = strchr(curr, '-'); - if (minus_pos != NULL && (minus_pos < op_pos || op_pos == NULL)) { + if (minus_pos != nullptr && (minus_pos < op_pos || op_pos == nullptr)) { op_pos = minus_pos; } char op; const char *flags = op_pos + 1; const char *flags_end = curr_end; - if (op_pos == NULL || op_pos > curr_end) { + if (op_pos == nullptr || op_pos > curr_end) { flags = "ies"; flags_end = flags + strlen(flags); op_pos = curr_end; @@ -190,7 +190,7 @@ void JvmtiTrace::initialize() { do_op = true; } else { const char *fname = function_name(i); - if (fname != NULL) { + if (fname != nullptr) { size_t fnlen = strlen(fname); if (len==fnlen && strncmp(curr, fname, fnlen)==0) { log_trace(jvmti)("Tracing the function: %s", fname); @@ -219,7 +219,7 @@ void JvmtiTrace::initialize() { do_op = true; } else { const char *ename = event_name(i); - if (ename != NULL) { + if (ename != nullptr) { size_t evtlen = strlen(ename); if (len==evtlen && strncmp(curr, ename, evtlen)==0) { log_trace(jvmti)("Tracing the event: %s", ename); @@ -271,22 +271,22 @@ const char* JvmtiTrace::enum_name(const char** names, const jint* values, jint v // return a valid string no matter what state the thread is in const char *JvmtiTrace::safe_get_thread_name(Thread *thread) { - if (thread == NULL) { - return "NULL"; + if (thread == nullptr) { + return "null"; } if (!thread->is_Java_thread()) { return thread->name(); } JavaThread* java_thread = JavaThread::cast(thread); oop threadObj = java_thread->jvmti_vthread(); - if (threadObj == NULL) { + if (threadObj == nullptr) { threadObj = java_thread->threadObj(); } - if (threadObj == NULL) { - return "NULL"; + if (threadObj == nullptr) { + return "null"; } oop name = java_lang_Thread::name(threadObj); - if (name == NULL) { + if (name == nullptr) { return ""; } return java_lang_String::as_utf8_string(name); @@ -308,7 +308,7 @@ const char * JvmtiTrace::get_class_name(oop k_mirror) { return "primitive"; } Klass* k_oop = java_lang_Class::as_Klass(k_mirror); - if (k_oop == NULL) { + if (k_oop == nullptr) { return "INVALID"; } return k_oop->external_name(); diff --git a/src/hotspot/share/prims/jvmtiUtil.cpp b/src/hotspot/share/prims/jvmtiUtil.cpp index 640081b8ad5ab..7c348b415fe40 100644 --- a/src/hotspot/share/prims/jvmtiUtil.cpp +++ b/src/hotspot/share/prims/jvmtiUtil.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, 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 @@ -34,10 +34,10 @@ // class JvmtiUtil // -ResourceArea* JvmtiUtil::_single_threaded_resource_area = NULL; +ResourceArea* JvmtiUtil::_single_threaded_resource_area = nullptr; ResourceArea* JvmtiUtil::single_threaded_resource_area() { - if (_single_threaded_resource_area == NULL) { + if (_single_threaded_resource_area == nullptr) { // lazily create the single threaded resource area // pick a size which is not a standard since the pools don't exist yet _single_threaded_resource_area = new (mtInternal) ResourceArea(Chunk::non_pool_size); diff --git a/src/hotspot/share/prims/jvmtiUtil.hpp b/src/hotspot/share/prims/jvmtiUtil.hpp index 5f8c6cd15426c..b0d8e5bebafb3 100644 --- a/src/hotspot/share/prims/jvmtiUtil.hpp +++ b/src/hotspot/share/prims/jvmtiUtil.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -81,7 +81,7 @@ class SafeResourceMark : public ResourceMark { return JvmtiUtil::single_threaded_resource_area(); } thread = Thread::current_or_null(); - if (thread == NULL) { + if (thread == nullptr) { return JvmtiUtil::single_threaded_resource_area(); } return thread->resource_area(); diff --git a/src/hotspot/share/prims/methodHandles.cpp b/src/hotspot/share/prims/methodHandles.cpp index 46e68c5cc7ee4..b00af7d64cd41 100644 --- a/src/hotspot/share/prims/methodHandles.cpp +++ b/src/hotspot/share/prims/methodHandles.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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 @@ -77,15 +77,15 @@ */ bool MethodHandles::_enabled = false; // set true after successful native linkage -MethodHandlesAdapterBlob* MethodHandles::_adapter_code = NULL; +MethodHandlesAdapterBlob* MethodHandles::_adapter_code = nullptr; /** * Generates method handle adapters. Returns 'false' if memory allocation * failed and true otherwise. */ void MethodHandles::generate_adapters() { - assert(vmClasses::MethodHandle_klass() != NULL, "should be present"); - assert(_adapter_code == NULL, "generate only once"); + assert(vmClasses::MethodHandle_klass() != nullptr, "should be present"); + assert(_adapter_code == nullptr, "generate only once"); ResourceMark rm; TraceTime timer("MethodHandles adapters generation", TRACETIME_LOG(Info, startuptime)); @@ -112,7 +112,7 @@ void MethodHandlesAdapterGenerator::generate() { vmIntrinsics::ID iid = Interpreter::method_handle_intrinsic(mk); StubCodeMark mark(this, "MethodHandle::interpreter_entry", vmIntrinsics::name_at(iid)); address entry = MethodHandles::generate_method_handle_interpreter_entry(_masm, iid); - if (entry != NULL) { + if (entry != nullptr) { Interpreter::set_entry_for_kind(mk, entry); } // If the entry is not set, it will throw AbstractMethodError. @@ -164,7 +164,7 @@ Handle MethodHandles::resolve_MemberName_type(Handle mname, Klass* caller, TRAPS return type; // already resolved } Symbol* signature = java_lang_String::as_symbol_or_null(type()); - if (signature == NULL) { + if (signature == nullptr) { return empty; // no such signature exists in the VM } Handle resolved; @@ -195,14 +195,14 @@ oop MethodHandles::init_MemberName(Handle mname, Handle target, TRAPS) { oop clazz = java_lang_reflect_Field::clazz(target_oop); // fd.field_holder() int slot = java_lang_reflect_Field::slot(target_oop); // fd.index() Klass* k = java_lang_Class::as_Klass(clazz); - if (k != NULL && k->is_instance_klass()) { + if (k != nullptr && k->is_instance_klass()) { fieldDescriptor fd(InstanceKlass::cast(k), slot); oop mname2 = init_field_MemberName(mname, fd); - if (mname2 != NULL) { + if (mname2 != nullptr) { // Since we have the reified name and type handy, add them to the result. - if (java_lang_invoke_MemberName::name(mname2) == NULL) + if (java_lang_invoke_MemberName::name(mname2) == nullptr) java_lang_invoke_MemberName::set_name(mname2, java_lang_reflect_Field::name(target_oop)); - if (java_lang_invoke_MemberName::type(mname2) == NULL) + if (java_lang_invoke_MemberName::type(mname2) == nullptr) java_lang_invoke_MemberName::set_type(mname2, java_lang_reflect_Field::type(target_oop)); } return mname2; @@ -211,10 +211,10 @@ oop MethodHandles::init_MemberName(Handle mname, Handle target, TRAPS) { oop clazz = java_lang_reflect_Method::clazz(target_oop); int slot = java_lang_reflect_Method::slot(target_oop); Klass* k = java_lang_Class::as_Klass(clazz); - if (k != NULL && k->is_instance_klass()) { + if (k != nullptr && k->is_instance_klass()) { Method* m = InstanceKlass::cast(k)->method_with_idnum(slot); - if (m == NULL || is_signature_polymorphic(m->intrinsic_id())) - return NULL; // do not resolve unless there is a concrete signature + if (m == nullptr || is_signature_polymorphic(m->intrinsic_id())) + return nullptr; // do not resolve unless there is a concrete signature CallInfo info(m, k, CHECK_NULL); return init_method_MemberName(mname, info); } @@ -222,14 +222,14 @@ oop MethodHandles::init_MemberName(Handle mname, Handle target, TRAPS) { oop clazz = java_lang_reflect_Constructor::clazz(target_oop); int slot = java_lang_reflect_Constructor::slot(target_oop); Klass* k = java_lang_Class::as_Klass(clazz); - if (k != NULL && k->is_instance_klass()) { + if (k != nullptr && k->is_instance_klass()) { Method* m = InstanceKlass::cast(k)->method_with_idnum(slot); - if (m == NULL) return NULL; + if (m == nullptr) return nullptr; CallInfo info(m, k, CHECK_NULL); return init_method_MemberName(mname, info); } } - return NULL; + return nullptr; } oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info) { @@ -237,7 +237,7 @@ oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info) { methodHandle m(Thread::current(), info.resolved_method()); assert(m.not_null(), "null method handle"); InstanceKlass* m_klass = m->method_holder(); - assert(m_klass != NULL, "null holder for method handle"); + assert(m_klass != nullptr, "null holder for method handle"); int flags = (jushort)( m->access_flags().as_short() & JVM_RECOGNIZED_METHOD_MODIFIERS ); int vmindex = Method::invalid_vtable_index; LogTarget(Debug, methodhandles, indy) lt_indy; @@ -290,7 +290,7 @@ oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info) { } if (!m->is_public()) { assert(m->is_public(), "virtual call must be to public interface method"); - return NULL; // elicit an error later in product build + return nullptr; // elicit an error later in product build } assert(info.resolved_klass()->is_subtype_of(m_klass_non_interface), "virtual call must be type-safe"); m_klass = m_klass_non_interface; @@ -323,7 +323,7 @@ oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info) { } break; - default: assert(false, "bad CallInfo"); return NULL; + default: assert(false, "bad CallInfo"); return nullptr; } // @CallerSensitive annotation detected @@ -358,15 +358,15 @@ oop MethodHandles::init_field_MemberName(Handle mname, fieldDescriptor& fd, bool oop mname_oop = mname(); java_lang_invoke_MemberName::set_flags (mname_oop, flags); - java_lang_invoke_MemberName::set_method (mname_oop, NULL); + java_lang_invoke_MemberName::set_method (mname_oop, nullptr); java_lang_invoke_MemberName::set_vmindex(mname_oop, vmindex); java_lang_invoke_MemberName::set_clazz (mname_oop, ik->java_mirror()); oop type = field_signature_type_or_null(fd.signature()); oop name = field_name_or_null(fd.name()); - if (name != NULL) + if (name != nullptr) java_lang_invoke_MemberName::set_name(mname_oop, name); - if (type != NULL) + if (type != nullptr) java_lang_invoke_MemberName::set_type(mname_oop, type); // Note: name and type can be lazily computed by resolve_MemberName, // if Java code needs them as resolved String and Class objects. @@ -386,7 +386,7 @@ oop MethodHandles::init_field_MemberName(Handle mname, fieldDescriptor& fd, bool // * It has a return type of Object for a polymorphic return type, otherwise a fixed return type. // * It has the ACC_VARARGS and ACC_NATIVE flags set. bool MethodHandles::is_method_handle_invoke_name(Klass* klass, Symbol* name) { - if (klass == NULL) + if (klass == nullptr) return false; // The following test will fail spuriously during bootstrap of MethodHandle itself: // if (klass != vmClasses::MethodHandle_klass()) @@ -400,7 +400,7 @@ bool MethodHandles::is_method_handle_invoke_name(Klass* klass, Symbol* name) { Symbol* poly_sig = vmSymbols::object_array_object_signature(); InstanceKlass* iklass = InstanceKlass::cast(klass); Method* m = iklass->find_method(name, poly_sig); - if (m != NULL) { + if (m != nullptr) { int required = JVM_ACC_NATIVE | JVM_ACC_VARARGS; int flags = m->access_flags().as_int(); if ((flags & required) == required) { @@ -485,13 +485,13 @@ vmIntrinsics::ID MethodHandles::signature_polymorphic_name_id(Symbol* name) { // Cover the case of invokeExact and any future variants of invokeFoo. Klass* mh_klass = vmClasses::klass_at(VM_CLASS_ID(MethodHandle_klass)); - if (mh_klass != NULL && is_method_handle_invoke_name(mh_klass, name)) { + if (mh_klass != nullptr && is_method_handle_invoke_name(mh_klass, name)) { return vmIntrinsics::_invokeGeneric; } // Cover the case of methods on VarHandle. Klass* vh_klass = vmClasses::klass_at(VM_CLASS_ID(VarHandle_klass)); - if (vh_klass != NULL && is_method_handle_invoke_name(vh_klass, name)) { + if (vh_klass != nullptr && is_method_handle_invoke_name(vh_klass, name)) { return vmIntrinsics::_invokeGeneric; } @@ -501,7 +501,7 @@ vmIntrinsics::ID MethodHandles::signature_polymorphic_name_id(Symbol* name) { } vmIntrinsics::ID MethodHandles::signature_polymorphic_name_id(Klass* klass, Symbol* name) { - if (klass != NULL && + if (klass != nullptr && (klass->name() == vmSymbols::java_lang_invoke_MethodHandle() || klass->name() == vmSymbols::java_lang_invoke_VarHandle())) { vmIntrinsics::ID iid = signature_polymorphic_name_id(name); @@ -545,7 +545,7 @@ Symbol* MethodHandles::lookup_signature(oop type_str, bool intern_if_not_found, return java_lang_String::as_symbol_or_null(type_str); } } else { - THROW_MSG_(vmSymbols::java_lang_InternalError(), "unrecognized type", NULL); + THROW_MSG_(vmSymbols::java_lang_InternalError(), "unrecognized type", nullptr); } } @@ -577,8 +577,8 @@ bool MethodHandles::is_basic_type_signature(Symbol* sig) { } Symbol* MethodHandles::lookup_basic_type_signature(Symbol* sig, bool keep_last_arg) { - Symbol* bsig = NULL; - if (sig == NULL) { + Symbol* bsig = nullptr; + if (sig == nullptr) { return sig; } else if (is_basic_type_signature(sig)) { sig->increment_refcount(); @@ -657,12 +657,12 @@ static oop object_java_mirror() { } oop MethodHandles::field_name_or_null(Symbol* s) { - if (s == NULL) return NULL; + if (s == nullptr) return nullptr; return StringTable::lookup(s); } oop MethodHandles::field_signature_type_or_null(Symbol* s) { - if (s == NULL) return NULL; + if (s == nullptr) return nullptr; BasicType bt = Signature::basic_type(s); if (is_java_primitive(bt)) { assert(s->utf8_length() == 1, ""); @@ -679,7 +679,7 @@ oop MethodHandles::field_signature_type_or_null(Symbol* s) { return vmClasses::String_klass()->java_mirror(); } } - return NULL; + return nullptr; } // An unresolved member name is a mere symbolic reference. @@ -690,7 +690,7 @@ Handle MethodHandles::resolve_MemberName(Handle mname, Klass* caller, int lookup Handle empty; assert(java_lang_invoke_MemberName::is_instance(mname()), ""); - if (java_lang_invoke_MemberName::vmtarget(mname()) != NULL) { + if (java_lang_invoke_MemberName::vmtarget(mname()) != nullptr) { // Already resolved. DEBUG_ONLY(int vmindex = java_lang_invoke_MemberName::vmindex(mname())); assert(vmindex >= Method::nonvirtual_vtable_index, ""); @@ -713,24 +713,24 @@ Handle MethodHandles::resolve_MemberName(Handle mname, Klass* caller, int lookup THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(), "nothing to resolve", empty); } - InstanceKlass* defc = NULL; + InstanceKlass* defc = nullptr; { Klass* defc_klass = java_lang_Class::as_Klass(defc_oop()); - if (defc_klass == NULL) return empty; // a primitive; no resolution possible + if (defc_klass == nullptr) return empty; // a primitive; no resolution possible if (!defc_klass->is_instance_klass()) { if (!defc_klass->is_array_klass()) return empty; defc_klass = vmClasses::Object_klass(); } defc = InstanceKlass::cast(defc_klass); } - if (defc == NULL) { + if (defc == nullptr) { THROW_MSG_(vmSymbols::java_lang_InternalError(), "primitive class", empty); } defc->link_class(CHECK_(empty)); // possible safepoint // convert the external string name to an internal symbol TempNewSymbol name = java_lang_String::as_symbol_or_null(name_str()); - if (name == NULL) return empty; // no such name + if (name == nullptr) return empty; // no such name if (name == vmSymbols::class_initializer_name()) return empty; // illegal name @@ -752,14 +752,14 @@ Handle MethodHandles::resolve_MemberName(Handle mname, Klass* caller, int lookup // convert the external string or reflective type to an internal signature TempNewSymbol type = lookup_signature(type_str(), (mh_invoke_id != vmIntrinsics::_none), CHECK_(empty)); - if (type == NULL) return empty; // no such signature exists in the VM + if (type == nullptr) return empty; // no such signature exists in the VM // skip access check if it's trusted lookup - LinkInfo::AccessCheck access_check = caller != NULL ? + LinkInfo::AccessCheck access_check = caller != nullptr ? LinkInfo::AccessCheck::required : LinkInfo::AccessCheck::skip; // skip loader constraints if it's trusted lookup or a public lookup - LinkInfo::LoaderConstraintCheck loader_constraint_check = (caller != NULL && (lookup_mode & LM_UNCONDITIONAL) == 0) ? + LinkInfo::LoaderConstraintCheck loader_constraint_check = (caller != nullptr && (lookup_mode & LM_UNCONDITIONAL) == 0) ? LinkInfo::LoaderConstraintCheck::required : LinkInfo::LoaderConstraintCheck::skip; @@ -860,9 +860,9 @@ Handle MethodHandles::resolve_MemberName(Handle mname, Klass* caller, int lookup void MethodHandles::expand_MemberName(Handle mname, int suppress, TRAPS) { assert(java_lang_invoke_MemberName::is_instance(mname()), ""); - bool have_defc = (java_lang_invoke_MemberName::clazz(mname()) != NULL); - bool have_name = (java_lang_invoke_MemberName::name(mname()) != NULL); - bool have_type = (java_lang_invoke_MemberName::type(mname()) != NULL); + bool have_defc = (java_lang_invoke_MemberName::clazz(mname()) != nullptr); + bool have_name = (java_lang_invoke_MemberName::name(mname()) != nullptr); + bool have_type = (java_lang_invoke_MemberName::type(mname()) != nullptr); int flags = java_lang_invoke_MemberName::flags(mname()); if (suppress != 0) { @@ -878,11 +878,11 @@ void MethodHandles::expand_MemberName(Handle mname, int suppress, TRAPS) { case IS_CONSTRUCTOR: { Method* vmtarget = java_lang_invoke_MemberName::vmtarget(mname()); - if (vmtarget == NULL) { + if (vmtarget == nullptr) { THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "nothing to expand"); } methodHandle m(THREAD, vmtarget); - DEBUG_ONLY(vmtarget = NULL); // safety + DEBUG_ONLY(vmtarget = nullptr); // safety if (!have_defc) { InstanceKlass* defc = m->method_holder(); java_lang_invoke_MemberName::set_clazz(mname(), defc->java_mirror()); @@ -901,11 +901,11 @@ void MethodHandles::expand_MemberName(Handle mname, int suppress, TRAPS) { case IS_FIELD: { oop clazz = java_lang_invoke_MemberName::clazz(mname()); - if (clazz == NULL) { + if (clazz == nullptr) { THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "nothing to expand (as field)"); } InstanceKlass* defc = InstanceKlass::cast(java_lang_Class::as_Klass(clazz)); - DEBUG_ONLY(clazz = NULL); // safety + DEBUG_ONLY(clazz = nullptr); // safety int vmindex = java_lang_invoke_MemberName::vmindex(mname()); bool is_static = ((flags & JVM_ACC_STATIC) != 0); fieldDescriptor fd; // find_field initializes fd if found @@ -1069,8 +1069,8 @@ JVM_END // void init(MemberName self, AccessibleObject ref) JVM_ENTRY(void, MHN_init_Mem(JNIEnv *env, jobject igcls, jobject mname_jh, jobject target_jh)) { - if (mname_jh == NULL) { THROW_MSG(vmSymbols::java_lang_InternalError(), "mname is null"); } - if (target_jh == NULL) { THROW_MSG(vmSymbols::java_lang_InternalError(), "target is null"); } + if (mname_jh == nullptr) { THROW_MSG(vmSymbols::java_lang_InternalError(), "mname is null"); } + if (target_jh == nullptr) { THROW_MSG(vmSymbols::java_lang_InternalError(), "target is null"); } Handle mname(THREAD, JNIHandles::resolve_non_null(mname_jh)); Handle target(THREAD, JNIHandles::resolve_non_null(target_jh)); MethodHandles::init_MemberName(mname, target, CHECK); @@ -1079,7 +1079,7 @@ JVM_END // void expand(MemberName self) JVM_ENTRY(void, MHN_expand_Mem(JNIEnv *env, jobject igcls, jobject mname_jh)) { - if (mname_jh == NULL) { THROW_MSG(vmSymbols::java_lang_InternalError(), "mname is null"); } + if (mname_jh == nullptr) { THROW_MSG(vmSymbols::java_lang_InternalError(), "mname is null"); } Handle mname(THREAD, JNIHandles::resolve_non_null(mname_jh)); MethodHandles::expand_MemberName(mname, 0, CHECK); } @@ -1088,7 +1088,7 @@ JVM_END // void resolve(MemberName self, Class caller) JVM_ENTRY(jobject, MHN_resolve_Mem(JNIEnv *env, jobject igcls, jobject mname_jh, jclass caller_jh, jint lookup_mode, jboolean speculative_resolve)) { - if (mname_jh == NULL) { THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), "mname is null"); } + if (mname_jh == nullptr) { THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), "mname is null"); } Handle mname(THREAD, JNIHandles::resolve_non_null(mname_jh)); // The trusted Java code that calls this method should already have performed @@ -1097,15 +1097,15 @@ JVM_ENTRY(jobject, MHN_resolve_Mem(JNIEnv *env, jobject igcls, jobject mname_jh, // verify the lookup context for a Lookup object teleported from one module // to another. Such Lookup object can only access the intersection of the set // of accessible classes from both lookup class and previous lookup class. - if (VerifyMethodHandles && (lookup_mode & LM_TRUSTED) == LM_TRUSTED && caller_jh != NULL && - java_lang_invoke_MemberName::clazz(mname()) != NULL) { + if (VerifyMethodHandles && (lookup_mode & LM_TRUSTED) == LM_TRUSTED && caller_jh != nullptr && + java_lang_invoke_MemberName::clazz(mname()) != nullptr) { Klass* reference_klass = java_lang_Class::as_Klass(java_lang_invoke_MemberName::clazz(mname())); - if (reference_klass != NULL && reference_klass->is_objArray_klass()) { + if (reference_klass != nullptr && reference_klass->is_objArray_klass()) { reference_klass = ObjArrayKlass::cast(reference_klass)->bottom_klass(); } // Reflection::verify_class_access can only handle instance classes. - if (reference_klass != NULL && reference_klass->is_instance_klass()) { + if (reference_klass != nullptr && reference_klass->is_instance_klass()) { // Emulate LinkResolver::check_klass_accessability. Klass* caller = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(caller_jh)); // access check on behalf of the caller if this is not a public lookup @@ -1123,7 +1123,7 @@ JVM_ENTRY(jobject, MHN_resolve_Mem(JNIEnv *env, jobject igcls, jobject mname_jh, } } - Klass* caller = caller_jh == NULL ? NULL : + Klass* caller = caller_jh == nullptr ? nullptr : java_lang_Class::as_Klass(JNIHandles::resolve_non_null(caller_jh)); Handle resolved = MethodHandles::resolve_MemberName(mname, caller, lookup_mode, speculative_resolve == JNI_TRUE, @@ -1137,7 +1137,7 @@ JVM_ENTRY(jobject, MHN_resolve_Mem(JNIEnv *env, jobject igcls, jobject mname_jh, } if (speculative_resolve) { assert(!HAS_PENDING_EXCEPTION, "No exceptions expected when resolving speculatively"); - return NULL; + return nullptr; } if ((flags & ALL_KINDS) == IS_FIELD) { THROW_MSG_NULL(vmSymbols::java_lang_NoSuchFieldError(), "field resolution failed"); @@ -1154,8 +1154,8 @@ JVM_ENTRY(jobject, MHN_resolve_Mem(JNIEnv *env, jobject igcls, jobject mname_jh, JVM_END static jlong find_member_field_offset(oop mname, bool must_be_static, TRAPS) { - if (mname == NULL || - java_lang_invoke_MemberName::clazz(mname) == NULL) { + if (mname == nullptr || + java_lang_invoke_MemberName::clazz(mname) == nullptr) { THROW_MSG_0(vmSymbols::java_lang_InternalError(), "mname not resolved"); } else { int flags = java_lang_invoke_MemberName::flags(mname); @@ -1191,7 +1191,7 @@ JVM_ENTRY(jobject, MHN_staticFieldBase(JNIEnv *env, jobject igcls, jobject mname JVM_END JVM_ENTRY(jobject, MHN_getMemberVMInfo(JNIEnv *env, jobject igcls, jobject mname_jh)) { - if (mname_jh == NULL) return NULL; + if (mname_jh == nullptr) return nullptr; Handle mname(THREAD, JNIHandles::resolve_non_null(mname_jh)); intptr_t vmindex = java_lang_invoke_MemberName::vmindex(mname()); objArrayHandle result = oopFactory::new_objArray_handle(vmClasses::Object_klass(), 2, CHECK_NULL); @@ -1204,7 +1204,7 @@ JVM_ENTRY(jobject, MHN_getMemberVMInfo(JNIEnv *env, jobject igcls, jobject mname x = java_lang_invoke_MemberName::clazz(mname()); } else { Method* vmtarget = java_lang_invoke_MemberName::vmtarget(mname()); - assert(vmtarget != NULL && vmtarget->is_method(), "vmtarget is only method"); + assert(vmtarget != nullptr && vmtarget->is_method(), "vmtarget is only method"); x = mname(); } result->obj_at_put(1, x); @@ -1242,12 +1242,12 @@ JVM_ENTRY(void, MHN_copyOutBootstrapArguments(JNIEnv* env, jobject igcls, jobjectArray buf_jh, jint pos, jboolean resolve, jobject ifna_jh)) { Klass* caller_k = java_lang_Class::as_Klass(JNIHandles::resolve(caller_jh)); - if (caller_k == NULL || !caller_k->is_instance_klass()) { + if (caller_k == nullptr || !caller_k->is_instance_klass()) { THROW_MSG(vmSymbols::java_lang_InternalError(), "bad caller"); } InstanceKlass* caller = InstanceKlass::cast(caller_k); typeArrayOop index_info_oop = (typeArrayOop) JNIHandles::resolve(index_info_jh); - if (index_info_oop == NULL || + if (index_info_oop == nullptr || index_info_oop->klass() != Universe::intArrayKlassObj() || typeArrayOop(index_info_oop)->length() < 2) { THROW_MSG(vmSymbols::java_lang_InternalError(), "bad index info (0)"); @@ -1266,7 +1266,7 @@ JVM_ENTRY(void, MHN_copyOutBootstrapArguments(JNIEnv* env, jobject igcls, for (int pseudo_index = -4; pseudo_index < 0; pseudo_index++) { if (start == pseudo_index) { if (start >= end || 0 > pos || pos >= buf->length()) break; - oop pseudo_arg = NULL; + oop pseudo_arg = nullptr; switch (pseudo_index) { case -4: // bootstrap method { @@ -1347,7 +1347,7 @@ JVM_END */ JVM_ENTRY(jobject, MH_invoke_UOE(JNIEnv* env, jobject mh, jobjectArray args)) { THROW_MSG_NULL(vmSymbols::java_lang_UnsupportedOperationException(), "MethodHandle.invoke cannot be invoked reflectively"); - return NULL; + return nullptr; } JVM_END @@ -1358,7 +1358,7 @@ JVM_END */ JVM_ENTRY(jobject, MH_invokeExact_UOE(JNIEnv* env, jobject mh, jobjectArray args)) { THROW_MSG_NULL(vmSymbols::java_lang_UnsupportedOperationException(), "MethodHandle.invokeExact cannot be invoked reflectively"); - return NULL; + return nullptr; } JVM_END @@ -1407,7 +1407,7 @@ static JNINativeMethod MH_methods[] = { */ JVM_ENTRY(void, JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass MHN_class)) { assert(!MethodHandles::enabled(), "must not be enabled"); - assert(vmClasses::MethodHandle_klass() != NULL, "should be present"); + assert(vmClasses::MethodHandle_klass() != nullptr, "should be present"); oop mirror = vmClasses::MethodHandle_klass()->java_mirror(); jclass MH_class = (jclass) JNIHandles::make_local(THREAD, mirror); diff --git a/src/hotspot/share/prims/nativeLookup.cpp b/src/hotspot/share/prims/nativeLookup.cpp index c74c8312888f3..cd25137964bdb 100644 --- a/src/hotspot/share/prims/nativeLookup.cpp +++ b/src/hotspot/share/prims/nativeLookup.cpp @@ -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 @@ -172,12 +172,12 @@ char* NativeLookup::pure_jni_name(const methodHandle& method) { st.print("Java_"); // Klass name if (!map_escaped_name_on(&st, method->klass_name())) { - return NULL; + return nullptr; } st.print("_"); // Method name if (!map_escaped_name_on(&st, method->name())) { - return NULL; + return nullptr; } return st.as_string(); } @@ -192,7 +192,7 @@ char* NativeLookup::long_jni_name(const methodHandle& method) { for (end = 0; end < signature->utf8_length() && signature->char_at(end) != JVM_SIGNATURE_ENDFUNC; end++); // skip first '(' if (!map_escaped_name_on(&st, signature, 1, end)) { - return NULL; + return nullptr; } return st.as_string(); @@ -217,34 +217,34 @@ extern "C" { #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f) static JNINativeMethod lookup_special_native_methods[] = { - { CC"Java_jdk_internal_misc_Unsafe_registerNatives", NULL, FN_PTR(JVM_RegisterJDKInternalMiscUnsafeMethods) }, - { CC"Java_java_lang_invoke_MethodHandleNatives_registerNatives", NULL, FN_PTR(JVM_RegisterMethodHandleMethods) }, - { CC"Java_jdk_internal_foreign_abi_UpcallStubs_registerNatives", NULL, FN_PTR(JVM_RegisterUpcallHandlerMethods) }, - { CC"Java_jdk_internal_foreign_abi_UpcallLinker_registerNatives", NULL, FN_PTR(JVM_RegisterUpcallLinkerMethods) }, - { CC"Java_jdk_internal_foreign_abi_NativeEntryPoint_registerNatives", NULL, FN_PTR(JVM_RegisterNativeEntryPointMethods) }, - { CC"Java_jdk_internal_perf_Perf_registerNatives", NULL, FN_PTR(JVM_RegisterPerfMethods) }, - { CC"Java_sun_hotspot_WhiteBox_registerNatives", NULL, FN_PTR(JVM_RegisterWhiteBoxMethods) }, - { CC"Java_jdk_test_whitebox_WhiteBox_registerNatives", NULL, FN_PTR(JVM_RegisterWhiteBoxMethods) }, - { CC"Java_jdk_internal_vm_vector_VectorSupport_registerNatives", NULL, FN_PTR(JVM_RegisterVectorSupportMethods)}, + { CC"Java_jdk_internal_misc_Unsafe_registerNatives", nullptr, FN_PTR(JVM_RegisterJDKInternalMiscUnsafeMethods) }, + { CC"Java_java_lang_invoke_MethodHandleNatives_registerNatives", nullptr, FN_PTR(JVM_RegisterMethodHandleMethods) }, + { CC"Java_jdk_internal_foreign_abi_UpcallStubs_registerNatives", nullptr, FN_PTR(JVM_RegisterUpcallHandlerMethods) }, + { CC"Java_jdk_internal_foreign_abi_UpcallLinker_registerNatives", nullptr, FN_PTR(JVM_RegisterUpcallLinkerMethods) }, + { CC"Java_jdk_internal_foreign_abi_NativeEntryPoint_registerNatives", nullptr, FN_PTR(JVM_RegisterNativeEntryPointMethods) }, + { CC"Java_jdk_internal_perf_Perf_registerNatives", nullptr, FN_PTR(JVM_RegisterPerfMethods) }, + { CC"Java_sun_hotspot_WhiteBox_registerNatives", nullptr, FN_PTR(JVM_RegisterWhiteBoxMethods) }, + { CC"Java_jdk_test_whitebox_WhiteBox_registerNatives", nullptr, FN_PTR(JVM_RegisterWhiteBoxMethods) }, + { CC"Java_jdk_internal_vm_vector_VectorSupport_registerNatives", nullptr, FN_PTR(JVM_RegisterVectorSupportMethods)}, #if INCLUDE_JVMCI - { CC"Java_jdk_vm_ci_runtime_JVMCI_initializeRuntime", NULL, FN_PTR(JVM_GetJVMCIRuntime) }, - { CC"Java_jdk_vm_ci_hotspot_CompilerToVM_registerNatives", NULL, FN_PTR(JVM_RegisterJVMCINatives) }, + { CC"Java_jdk_vm_ci_runtime_JVMCI_initializeRuntime", nullptr, FN_PTR(JVM_GetJVMCIRuntime) }, + { CC"Java_jdk_vm_ci_hotspot_CompilerToVM_registerNatives", nullptr, FN_PTR(JVM_RegisterJVMCINatives) }, #endif #if INCLUDE_JFR - { CC"Java_jdk_jfr_internal_JVM_registerNatives", NULL, FN_PTR(jfr_register_natives) }, + { CC"Java_jdk_jfr_internal_JVM_registerNatives", nullptr, FN_PTR(jfr_register_natives) }, #endif - { CC"Java_jdk_internal_misc_ScopedMemoryAccess_registerNatives", NULL, FN_PTR(JVM_RegisterJDKInternalMiscScopedMemoryAccessMethods) }, + { CC"Java_jdk_internal_misc_ScopedMemoryAccess_registerNatives", nullptr, FN_PTR(JVM_RegisterJDKInternalMiscScopedMemoryAccessMethods) }, }; static address lookup_special_native(const char* jni_name) { int count = sizeof(lookup_special_native_methods) / sizeof(JNINativeMethod); for (int i = 0; i < count; i++) { // NB: To ignore the jni prefix and jni postfix strstr is used matching. - if (strstr(jni_name, lookup_special_native_methods[i].name) != NULL) { + if (strstr(jni_name, lookup_special_native_methods[i].name) != nullptr) { return CAST_FROM_FN_PTR(address, lookup_special_native_methods[i].fnPtr); } } - return NULL; + return nullptr; } address NativeLookup::lookup_style(const methodHandle& method, char* pure_name, const char* long_name, int args_size, bool os_style, TRAPS) { @@ -260,10 +260,10 @@ address NativeLookup::lookup_style(const methodHandle& method, char* pure_name, Handle loader(THREAD, method->method_holder()->class_loader()); if (loader.is_null()) { entry = lookup_special_native(jni_name); - if (entry == NULL) { + if (entry == nullptr) { entry = (address) os::dll_lookup(os::native_java_library(), jni_name); } - if (entry != NULL) { + if (entry != nullptr) { return entry; } } @@ -283,12 +283,12 @@ address NativeLookup::lookup_style(const methodHandle& method, char* pure_name, CHECK_NULL); entry = (address) (intptr_t) result.get_jlong(); - if (entry == NULL) { + if (entry == nullptr) { // findNative didn't find it, if there are any agent libraries look in them AgentLibrary* agent; - for (agent = Arguments::agents(); agent != NULL; agent = agent->next()) { + for (agent = Arguments::agents(); agent != nullptr; agent = agent->next()) { entry = (address) os::dll_lookup(agent->os_lib(), jni_name); - if (entry != NULL) { + if (entry != nullptr) { return entry; } } @@ -315,13 +315,13 @@ const char* NativeLookup::compute_complete_jni_name(const char* pure_name, const // Check all the formats of native implementation name to see if there is one // for the specified method. address NativeLookup::lookup_entry(const methodHandle& method, TRAPS) { - address entry = NULL; + address entry = nullptr; // Compute pure name char* pure_name = pure_jni_name(method); - if (pure_name == NULL) { + if (pure_name == nullptr) { // JNI name mapping rejected this method so return - // NULL to indicate UnsatisfiedLinkError should be thrown. - return NULL; + // null to indicate UnsatisfiedLinkError should be thrown. + return nullptr; } // Compute argument size @@ -331,28 +331,28 @@ address NativeLookup::lookup_entry(const methodHandle& method, TRAPS) { // 1) Try JNI short style entry = lookup_style(method, pure_name, "", args_size, true, CHECK_NULL); - if (entry != NULL) return entry; + if (entry != nullptr) return entry; // Compute long name char* long_name = long_jni_name(method); - if (long_name == NULL) { + if (long_name == nullptr) { // JNI name mapping rejected this method so return - // NULL to indicate UnsatisfiedLinkError should be thrown. - return NULL; + // null to indicate UnsatisfiedLinkError should be thrown. + return nullptr; } // 2) Try JNI long style entry = lookup_style(method, pure_name, long_name, args_size, true, CHECK_NULL); - if (entry != NULL) return entry; + if (entry != nullptr) return entry; // 3) Try JNI short style without os prefix/suffix entry = lookup_style(method, pure_name, "", args_size, false, CHECK_NULL); - if (entry != NULL) return entry; + if (entry != nullptr) return entry; // 4) Try JNI long style without os prefix/suffix entry = lookup_style(method, pure_name, long_name, args_size, false, CHECK_NULL); - return entry; // NULL indicates not found + return entry; // null indicates not found } // Check if there are any JVM TI prefixes which have been applied to the native method name. @@ -380,10 +380,10 @@ address NativeLookup::lookup_entry_prefixed(const methodHandle& method, TRAPS) { // we have a name for a wrapping method int wrapper_name_len = (int)strlen(wrapper_name); TempNewSymbol wrapper_symbol = SymbolTable::probe(wrapper_name, wrapper_name_len); - if (wrapper_symbol != NULL) { + if (wrapper_symbol != nullptr) { Klass* k = method->method_holder(); Method* wrapper_method = k->lookup_method(wrapper_symbol, method->signature()); - if (wrapper_method != NULL && !wrapper_method->is_native()) { + if (wrapper_method != nullptr && !wrapper_method->is_native()) { // we found a wrapper method, use its native entry method->set_is_prefixed_native(); return lookup_entry(methodHandle(THREAD, wrapper_method), THREAD); @@ -391,20 +391,20 @@ address NativeLookup::lookup_entry_prefixed(const methodHandle& method, TRAPS) { } } #endif // INCLUDE_JVMTI - return NULL; + return nullptr; } address NativeLookup::lookup_base(const methodHandle& method, TRAPS) { - address entry = NULL; + address entry = nullptr; ResourceMark rm(THREAD); entry = lookup_entry(method, CHECK_NULL); - if (entry != NULL) return entry; + if (entry != nullptr) return entry; // standard native method resolution has failed. Check if there are any // JVM TI prefixes which have been applied to the native method name. entry = lookup_entry_prefixed(method, CHECK_NULL); - if (entry != NULL) return entry; + if (entry != nullptr) return entry; // Native function not found, throw UnsatisfiedLinkError stringStream ss; diff --git a/src/hotspot/share/prims/perf.cpp b/src/hotspot/share/prims/perf.cpp index 626fd2cfbf3b5..f10854b529459 100644 --- a/src/hotspot/share/prims/perf.cpp +++ b/src/hotspot/share/prims/perf.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2022, 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 @@ -47,9 +47,9 @@ static char* jstr_to_utf(JNIEnv *env, jstring str, TRAPS) { - char* utfstr = NULL; + char* utfstr = nullptr; - if (str == NULL) { + if (str == nullptr) { THROW_0(vmSymbols::java_lang_NullPointerException()); //throw_new(env,"NullPointerException"); } @@ -109,7 +109,7 @@ PERF_ENTRY(jobject, Perf_CreateLong(JNIEnv *env, jobject perf, jstring name, PerfWrapper("Perf_CreateLong"); - char* name_utf = NULL; + char* name_utf = nullptr; if (units <= 0 || units > PerfData::U_Last) { debug_only(warning("unexpected units argument, units = %d", units)); @@ -124,7 +124,7 @@ PERF_ENTRY(jobject, Perf_CreateLong(JNIEnv *env, jobject perf, jstring name, name_utf = jstr_to_utf(env, name, CHECK_NULL); } - PerfLong* pl = NULL; + PerfLong* pl = nullptr; // check that the PerfData name doesn't already exist if (PerfDataManager::exists(name_utf)) { @@ -173,7 +173,7 @@ PERF_ENTRY(jobject, Perf_CreateByteArray(JNIEnv *env, jobject perf, PerfWrapper("Perf_CreateByteArray"); // check for valid byte array objects - if (name == NULL || value == NULL) { + if (name == nullptr || value == nullptr) { THROW_0(vmSymbols::java_lang_NullPointerException()); } @@ -192,8 +192,8 @@ PERF_ENTRY(jobject, Perf_CreateByteArray(JNIEnv *env, jobject perf, } int value_length; - char* name_utf = NULL; - jbyte* value_local = NULL; + char* name_utf = nullptr; + jbyte* value_local = nullptr; ResourceMark rm; @@ -214,7 +214,7 @@ PERF_ENTRY(jobject, Perf_CreateByteArray(JNIEnv *env, jobject perf, THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "PerfByteArray name already exists"); } - PerfByteArray* pbv = NULL; + PerfByteArray* pbv = nullptr; if (units == PerfData::U_String) { diff --git a/src/hotspot/share/prims/resolvedMethodTable.cpp b/src/hotspot/share/prims/resolvedMethodTable.cpp index 215cf8e31ef81..fbcbd2b15907e 100644 --- a/src/hotspot/share/prims/resolvedMethodTable.cpp +++ b/src/hotspot/share/prims/resolvedMethodTable.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -71,7 +71,7 @@ class ResolvedMethodTableConfig : public AllStatic { static uintx get_hash(Value const& value, bool* is_dead) { oop val_oop = value.peek(); - if (val_oop == NULL) { + if (val_oop == nullptr) { *is_dead = true; return 0; } @@ -92,7 +92,7 @@ class ResolvedMethodTableConfig : public AllStatic { } }; -static ResolvedMethodTableHash* _local_table = NULL; +static ResolvedMethodTableHash* _local_table = nullptr; static size_t _current_size = (size_t)1 << ResolvedMethodTableSizeLog; volatile bool ResolvedMethodTable::_has_work = false; @@ -128,7 +128,7 @@ class ResolvedMethodTableLookup : StackObj { } bool equals(WeakHandle* value, bool* is_dead) { oop val_oop = value->peek(); - if (val_oop == NULL) { + if (val_oop == nullptr) { // dead oop, mark this hash dead for cleaning *is_dead = true; return false; @@ -152,7 +152,7 @@ class ResolvedMethodGet : public StackObj { ResolvedMethodGet(Thread* thread, const Method* method) : _thread(thread), _method(method) {} void operator()(WeakHandle* val) { oop result = val->resolve(); - assert(result != NULL, "Result should be reachable"); + assert(result != nullptr, "Result should be reachable"); _return = Handle(_thread, result); log_get(); } @@ -305,7 +305,7 @@ struct ResolvedMethodTableDeleteCheck : StackObj { bool operator()(WeakHandle* val) { ++_item; oop tmp = val->peek(); - if (tmp == NULL) { + if (tmp == nullptr) { ++_count; return true; } else { @@ -342,7 +342,7 @@ class AdjustMethodEntries : public StackObj { AdjustMethodEntries(bool* trace_name_printed) : _trace_name_printed(trace_name_printed) {}; bool operator()(WeakHandle* entry) { oop mem_name = entry->peek(); - if (mem_name == NULL) { + if (mem_name == nullptr) { // Removed return true; } @@ -384,7 +384,7 @@ class VerifyResolvedMethod : StackObj { public: bool operator()(WeakHandle* val) { oop obj = val->peek(); - if (obj != NULL) { + if (obj != nullptr) { Method* method = (Method*)java_lang_invoke_ResolvedMethodName::vmtarget(obj); guarantee(method->is_method(), "Must be"); guarantee(!method->is_old(), "Must be"); diff --git a/src/hotspot/share/prims/scopedMemoryAccess.cpp b/src/hotspot/share/prims/scopedMemoryAccess.cpp index 0908232f68691..76bfd3a5a976d 100644 --- a/src/hotspot/share/prims/scopedMemoryAccess.cpp +++ b/src/hotspot/share/prims/scopedMemoryAccess.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, 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 @@ -97,12 +97,12 @@ class CloseScopedMemoryClosure : public HandshakeClosure { } ResourceMark rm; - if (_deopt != NULL && last_frame.is_compiled_frame() && last_frame.can_be_deoptimized()) { + if (_deopt != nullptr && last_frame.is_compiled_frame() && last_frame.can_be_deoptimized()) { CloseScopedMemoryFindOopClosure cl(_deopt); CompiledMethod* cm = last_frame.cb()->as_compiled_method(); /* FIXME: this doesn't work if reachability fences are violated by C2 - last_frame.oops_do(&cl, NULL, ®ister_map); + last_frame.oops_do(&cl, nullptr, ®ister_map); if (cl.found()) { //Found the deopt oop in a compiled method; deoptimize. Deoptimization::deoptimize(jt, last_frame); diff --git a/src/hotspot/share/prims/stackwalk.cpp b/src/hotspot/share/prims/stackwalk.cpp index 9945099de8f2d..47f8a25af4c26 100644 --- a/src/hotspot/share/prims/stackwalk.cpp +++ b/src/hotspot/share/prims/stackwalk.cpp @@ -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 @@ -49,7 +49,7 @@ // setup and cleanup actions BaseFrameStream::BaseFrameStream(JavaThread* thread, Handle continuation) : _thread(thread), _continuation(continuation), _anchor(0L) { - assert(thread != NULL, ""); + assert(thread != nullptr, ""); } void BaseFrameStream::setup_magic_on_entry(objArrayHandle frames_array) { @@ -67,7 +67,7 @@ bool BaseFrameStream::check_magic(objArrayHandle frames_array) { bool BaseFrameStream::cleanup_magic_on_exit(objArrayHandle frames_array) { bool ok = check_magic(frames_array); - frames_array->obj_at_put(magic_pos, NULL); + frames_array->obj_at_put(magic_pos, nullptr); _anchor = 0L; return ok; } @@ -97,7 +97,7 @@ LiveFrameStream::LiveFrameStream(JavaThread* thread, RegisterMap* rm, Handle con _cont_entry = thread->last_continuation(); } else { _jvf = Continuation::last_java_vframe(cont, rm); - _cont_entry = NULL; + _cont_entry = nullptr; } } @@ -108,13 +108,13 @@ void JavaFrameStream::next() { } void LiveFrameStream::next() { - assert(_cont_scope.is_null() || cont() != (oop)NULL, "must be"); + assert(_cont_scope.is_null() || cont() != (oop)nullptr, "must be"); oop cont = this->cont(); - if (cont != (oop)NULL && Continuation::is_continuation_entry_frame(_jvf->fr(), _jvf->register_map())) { + if (cont != (oop)nullptr && Continuation::is_continuation_entry_frame(_jvf->fr(), _jvf->register_map())) { oop scope = jdk_internal_vm_Continuation::scope(cont); if (_cont_scope.not_null() && scope == _cont_scope()) { - _jvf = NULL; + _jvf = nullptr; return; } _cont_entry = _cont_entry->parent(); @@ -136,10 +136,10 @@ BaseFrameStream* BaseFrameStream::from_current(JavaThread* thread, jlong magic, objArrayHandle frames_array) { oop m1 = frames_array->obj_at(magic_pos); - if (m1 != thread->threadObj()) return NULL; - if (magic == 0L) return NULL; + if (m1 != thread->threadObj()) return nullptr; + if (magic == 0L) return nullptr; BaseFrameStream* stream = (BaseFrameStream*) (intptr_t) magic; - if (!stream->is_valid_in(thread, frames_array)) return NULL; + if (!stream->is_valid_in(thread, frames_array)) return nullptr; return stream; } @@ -173,10 +173,10 @@ int StackWalk::fill_in_frames(jlong mode, BaseFrameStream& stream, int frames_decoded = 0; for (; !stream.at_end(); stream.next()) { - assert(stream.continuation() == NULL || stream.continuation() == stream.reg_map()->cont(), ""); + assert(stream.continuation() == nullptr || stream.continuation() == stream.reg_map()->cont(), ""); Method* method = stream.method(); - if (method == NULL) continue; + if (method == nullptr) continue; // skip hidden frames for default StackWalker option (i.e. SHOW_HIDDEN_FRAMES // not set) and when StackWalker::getCallerClass is called @@ -223,7 +223,7 @@ int StackWalk::fill_in_frames(jlong mode, BaseFrameStream& stream, frames_decoded++; // We end a batch on continuation bottom to let the Java side skip top frames of the next one - if (stream.continuation() != NULL && method->intrinsic_id() == vmIntrinsics::_Continuation_enter) break; + if (stream.continuation() != nullptr && method->intrinsic_id() == vmIntrinsics::_Continuation_enter) break; if (frames_decoded >= max_nframes) break; } @@ -262,7 +262,7 @@ oop LiveFrameStream::create_primitive_slot_instance(StackValueCollection* values JavaValue result(T_OBJECT); JavaCallArguments args; - Symbol* signature = NULL; + Symbol* signature = nullptr; // ## TODO: type is only available in LocalVariable table, if present. // ## StackValue type is T_INT or T_OBJECT (or converted to T_LONG on 64-bit) @@ -283,7 +283,7 @@ oop LiveFrameStream::create_primitive_slot_instance(StackValueCollection* values case T_SHORT: case T_CHAR: case T_BOOLEAN: - THROW_MSG_(vmSymbols::java_lang_InternalError(), "Unexpected StackValue type", NULL); + THROW_MSG_(vmSymbols::java_lang_InternalError(), "Unexpected StackValue type", nullptr); case T_OBJECT: return values->obj_at(i)(); @@ -329,7 +329,7 @@ objArrayHandle LiveFrameStream::values_to_object_array(StackValueCollection* val } #endif oop obj = create_primitive_slot_instance(values, index, type, CHECK_(empty)); - if (obj != NULL) { + if (obj != nullptr) { array_h->obj_at_put(i, obj); } } @@ -357,7 +357,7 @@ void BaseFrameStream::fill_stackframe(Handle stackFrame, const methodHandle& met void LiveFrameStream::fill_live_stackframe(Handle stackFrame, const methodHandle& method, TRAPS) { fill_stackframe(stackFrame, method, CHECK); - if (_jvf != NULL) { + if (_jvf != nullptr) { ResourceMark rm(THREAD); HandleMark hm(THREAD); @@ -424,7 +424,7 @@ oop StackWalk::walk(Handle stackStream, jlong mode, int skip_frames, Handle cont } if (frames_array.is_null()) { - THROW_MSG_(vmSymbols::java_lang_NullPointerException(), "frames_array is NULL", NULL); + THROW_MSG_(vmSymbols::java_lang_NullPointerException(), "frames_array is null", nullptr); } // Setup traversal onto my stack. @@ -492,7 +492,7 @@ oop StackWalk::fetchFirstBatch(BaseFrameStream& stream, Handle stackStream, numFrames = fill_in_frames(mode, stream, frame_count, start_index, frames_array, end_index, CHECK_NULL); if (numFrames < 1) { - THROW_MSG_(vmSymbols::java_lang_InternalError(), "stack walk: decode failed", NULL); + THROW_MSG_(vmSymbols::java_lang_InternalError(), "stack walk: decode failed", nullptr); } } @@ -520,7 +520,7 @@ oop StackWalk::fetchFirstBatch(BaseFrameStream& stream, Handle stackStream, (void) (CHECK_NULL); if (!ok) { - THROW_MSG_(vmSymbols::java_lang_InternalError(), "doStackWalk: corrupted buffers on exit", NULL); + THROW_MSG_(vmSymbols::java_lang_InternalError(), "doStackWalk: corrupted buffers on exit", nullptr); } // Return normally @@ -546,12 +546,12 @@ jint StackWalk::fetchNextBatch(Handle stackStream, jlong mode, jlong magic, { JavaThread* jt = THREAD; BaseFrameStream* existing_stream = BaseFrameStream::from_current(jt, magic, frames_array); - if (existing_stream == NULL) { + if (existing_stream == nullptr) { THROW_MSG_(vmSymbols::java_lang_InternalError(), "doStackWalk: corrupted buffers", 0L); } if (frames_array.is_null()) { - THROW_MSG_(vmSymbols::java_lang_NullPointerException(), "frames_array is NULL", 0L); + THROW_MSG_(vmSymbols::java_lang_NullPointerException(), "frames_array is null", 0L); } log_debug(stackwalk)("StackWalk::fetchNextBatch frame_count %d existing_stream " @@ -589,11 +589,11 @@ void StackWalk::setContinuation(Handle stackStream, jlong magic, objArrayHandle JavaThread* jt = JavaThread::cast(THREAD); if (frames_array.is_null()) { - THROW_MSG(vmSymbols::java_lang_NullPointerException(), "frames_array is NULL"); + THROW_MSG(vmSymbols::java_lang_NullPointerException(), "frames_array is null"); } BaseFrameStream* existing_stream = BaseFrameStream::from_current(jt, magic, frames_array); - if (existing_stream == NULL) { + if (existing_stream == nullptr) { THROW_MSG(vmSymbols::java_lang_InternalError(), "doStackWalk: corrupted buffers"); } diff --git a/src/hotspot/share/prims/stackwalk.hpp b/src/hotspot/share/prims/stackwalk.hpp index ba81f4e978c9a..0af68127b4607 100644 --- a/src/hotspot/share/prims/stackwalk.hpp +++ b/src/hotspot/share/prims/stackwalk.hpp @@ -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 @@ -130,11 +130,11 @@ class LiveFrameStream : public BaseFrameStream { const RegisterMap* reg_map() override { return _map; }; void next() override; - bool at_end() override { return _jvf == NULL; } + bool at_end() override { return _jvf == nullptr; } Method* method() override { return _jvf->method(); } int bci() override { return _jvf->bci(); } - oop cont() override { return continuation() != NULL ? continuation(): ContinuationEntry::cont_oop_or_null(_cont_entry, _map->thread()); } + oop cont() override { return continuation() != nullptr ? continuation(): ContinuationEntry::cont_oop_or_null(_cont_entry, _map->thread()); } void fill_frame(int index, objArrayHandle frames_array, const methodHandle& method, TRAPS) override; diff --git a/src/hotspot/share/prims/unsafe.cpp b/src/hotspot/share/prims/unsafe.cpp index ac789cb46154b..2b4c432d20047 100644 --- a/src/hotspot/share/prims/unsafe.cpp +++ b/src/hotspot/share/prims/unsafe.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ static inline void assert_field_offset_sane(oop p, jlong field_offset) { #ifdef ASSERT jlong byte_offset = field_offset_to_byte_offset(field_offset); - if (p != NULL) { + if (p != nullptr) { assert(byte_offset >= 0 && byte_offset <= (jlong)MAX_OBJECT_SIZE, "sane offset"); if (byte_offset == (jint)byte_offset) { void* ptr_plus_disp = cast_from_oop
(p) + byte_offset; @@ -381,7 +381,7 @@ UNSAFE_ENTRY(void, Unsafe_CopyMemory0(JNIEnv *env, jobject unsafe, jobject srcOb void* dst = index_oop_from_field_offset_long(dstp, dstOffset); { GuardUnsafeAccess guard(thread); - if (StubRoutines::unsafe_arraycopy() != NULL) { + if (StubRoutines::unsafe_arraycopy() != nullptr) { MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXExec, thread)); StubRoutines::UnsafeArrayCopy_stub()(src, dst, sz); } else { @@ -398,7 +398,7 @@ UNSAFE_LEAF(void, Unsafe_CopySwapMemory0(JNIEnv *env, jobject unsafe, jobject sr size_t sz = (size_t)size; size_t esz = (size_t)elemSize; - if (srcObj == NULL && dstObj == NULL) { + if (srcObj == nullptr && dstObj == nullptr) { // Both src & dst are in native memory address src = (address)srcOffset; address dst = (address)dstOffset; @@ -435,14 +435,14 @@ UNSAFE_LEAF (void, Unsafe_WriteBack0(JNIEnv *env, jobject unsafe, jlong line)) { #endif MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXExec, Thread::current())); - assert(StubRoutines::data_cache_writeback() != NULL, "sanity"); + assert(StubRoutines::data_cache_writeback() != nullptr, "sanity"); (StubRoutines::DataCacheWriteback_stub())(addr_from_java(line)); } UNSAFE_END static void doWriteBackSync0(bool is_pre) { MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXExec, Thread::current())); - assert(StubRoutines::data_cache_writeback_sync() != NULL, "sanity"); + assert(StubRoutines::data_cache_writeback_sync() != nullptr, "sanity"); (StubRoutines::DataCacheWritebackSync_stub())(is_pre); } @@ -471,8 +471,8 @@ UNSAFE_LEAF (void, Unsafe_WriteBackPostSync0(JNIEnv *env, jobject unsafe)) { ////// Random queries static jlong find_field_offset(jclass clazz, jstring name, TRAPS) { - assert(clazz != NULL, "clazz must not be NULL"); - assert(name != NULL, "name must not be NULL"); + assert(clazz != nullptr, "clazz must not be null"); + assert(name != nullptr, "name must not be null"); ResourceMark rm(THREAD); char *utf_name = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name)); @@ -494,7 +494,7 @@ static jlong find_field_offset(jclass clazz, jstring name, TRAPS) { } static jlong find_field_offset(jobject field, int must_be_static, TRAPS) { - assert(field != NULL, "field must not be NULL"); + assert(field != nullptr, "field must not be null"); oop reflected = JNIHandles::resolve_non_null(field); oop mirror = java_lang_reflect_Field::clazz(reflected); @@ -526,14 +526,14 @@ UNSAFE_ENTRY(jlong, Unsafe_StaticFieldOffset0(JNIEnv *env, jobject unsafe, jobje } UNSAFE_END UNSAFE_ENTRY(jobject, Unsafe_StaticFieldBase0(JNIEnv *env, jobject unsafe, jobject field)) { - assert(field != NULL, "field must not be NULL"); + assert(field != nullptr, "field must not be null"); // Note: In this VM implementation, a field address is always a short // offset from the base of a klass metaobject. Thus, the full dynamic // range of the return type is never used. However, some implementations // might put the static field inside an array shared by many classes, // or even at a fixed address, in which case the address could be quite - // large. In that last case, this function would return NULL, since + // large. In that last case, this function would return null, since // the address would operate alone, without any base pointer. oop reflected = JNIHandles::resolve_non_null(field); @@ -548,12 +548,12 @@ UNSAFE_ENTRY(jobject, Unsafe_StaticFieldBase0(JNIEnv *env, jobject unsafe, jobje } UNSAFE_END UNSAFE_ENTRY(void, Unsafe_EnsureClassInitialized0(JNIEnv *env, jobject unsafe, jobject clazz)) { - assert(clazz != NULL, "clazz must not be NULL"); + assert(clazz != nullptr, "clazz must not be null"); oop mirror = JNIHandles::resolve_non_null(clazz); Klass* klass = java_lang_Class::as_Klass(mirror); - if (klass != NULL && klass->should_be_initialized()) { + if (klass != nullptr && klass->should_be_initialized()) { InstanceKlass* k = InstanceKlass::cast(klass); k->initialize(CHECK); } @@ -561,12 +561,12 @@ UNSAFE_ENTRY(void, Unsafe_EnsureClassInitialized0(JNIEnv *env, jobject unsafe, j UNSAFE_END UNSAFE_ENTRY(jboolean, Unsafe_ShouldBeInitialized0(JNIEnv *env, jobject unsafe, jobject clazz)) { - assert(clazz != NULL, "clazz must not be NULL"); + assert(clazz != nullptr, "clazz must not be null"); oop mirror = JNIHandles::resolve_non_null(clazz); Klass* klass = java_lang_Class::as_Klass(mirror); - if (klass != NULL && klass->should_be_initialized()) { + if (klass != nullptr && klass->should_be_initialized()) { return true; } @@ -575,12 +575,12 @@ UNSAFE_ENTRY(jboolean, Unsafe_ShouldBeInitialized0(JNIEnv *env, jobject unsafe, UNSAFE_END static void getBaseAndScale(int& base, int& scale, jclass clazz, TRAPS) { - assert(clazz != NULL, "clazz must not be NULL"); + assert(clazz != nullptr, "clazz must not be null"); oop mirror = JNIHandles::resolve_non_null(clazz); Klass* k = java_lang_Class::as_Klass(mirror); - if (k == NULL || !k->is_array_klass()) { + if (k == nullptr || !k->is_array_klass()) { THROW(vmSymbols::java_lang_InvalidClassException()); } else if (k->is_objArray_klass()) { base = arrayOopDesc::base_offset_in_bytes(T_OBJECT); @@ -633,18 +633,18 @@ static inline void throw_new(JNIEnv *env, const char *ename) { return; } - env->ThrowNew(cls, NULL); + env->ThrowNew(cls, nullptr); } static jclass Unsafe_DefineClass_impl(JNIEnv *env, jstring name, jbyteArray data, int offset, int length, jobject loader, jobject pd) { // Code lifted from JDK 1.3 ClassLoader.c jbyte *body; - char *utfName = NULL; + char *utfName = nullptr; jclass result = 0; char buf[128]; - assert(data != NULL, "Class bytes must not be NULL"); + assert(data != nullptr, "Class bytes must not be null"); assert(length >= 0, "length must not be negative: %d", length); if (UsePerfData) { @@ -652,7 +652,7 @@ static jclass Unsafe_DefineClass_impl(JNIEnv *env, jstring name, jbyteArray data } body = NEW_C_HEAP_ARRAY_RETURN_NULL(jbyte, length, mtInternal); - if (body == NULL) { + if (body == nullptr) { throw_new(env, "java/lang/OutOfMemoryError"); return 0; } @@ -662,13 +662,13 @@ static jclass Unsafe_DefineClass_impl(JNIEnv *env, jstring name, jbyteArray data goto free_body; } - if (name != NULL) { + if (name != nullptr) { uint len = env->GetStringUTFLength(name); int unicode_len = env->GetStringLength(name); if (len >= sizeof(buf)) { utfName = NEW_C_HEAP_ARRAY_RETURN_NULL(char, len + 1, mtInternal); - if (utfName == NULL) { + if (utfName == nullptr) { throw_new(env, "java/lang/OutOfMemoryError"); goto free_body; } @@ -752,11 +752,11 @@ UNSAFE_ENTRY(jboolean, Unsafe_CompareAndSetLong(JNIEnv *env, jobject unsafe, job } UNSAFE_END static void post_thread_park_event(EventThreadPark* event, const oop obj, jlong timeout_nanos, jlong until_epoch_millis) { - assert(event != NULL, "invariant"); - event->set_parkedClass((obj != NULL) ? obj->klass() : NULL); + assert(event != nullptr, "invariant"); + event->set_parkedClass((obj != nullptr) ? obj->klass() : nullptr); event->set_timeout(timeout_nanos); event->set_until(until_epoch_millis); - event->set_address((obj != NULL) ? (u8)cast_from_oop(obj) : 0); + event->set_address((obj != nullptr) ? (u8)cast_from_oop(obj) : 0); event->commit(); } @@ -782,14 +782,14 @@ UNSAFE_ENTRY(void, Unsafe_Park(JNIEnv *env, jobject unsafe, jboolean isAbsolute, } UNSAFE_END UNSAFE_ENTRY(void, Unsafe_Unpark(JNIEnv *env, jobject unsafe, jobject jthread)) { - if (jthread != NULL) { + if (jthread != nullptr) { ThreadsListHandle tlh; - JavaThread* thr = NULL; - oop java_thread = NULL; + JavaThread* thr = nullptr; + oop java_thread = nullptr; (void) tlh.cv_internal_thread_to_JavaThread(jthread, &thr, &java_thread); - if (java_thread != NULL) { + if (java_thread != nullptr) { // This is a valid oop. - if (thr != NULL) { + if (thr != nullptr) { // The JavaThread is alive. Parker* p = thr->parker(); HOTSPOT_THREAD_UNPARK((uintptr_t) p); diff --git a/src/hotspot/share/prims/upcallLinker.cpp b/src/hotspot/share/prims/upcallLinker.cpp index 7bb34888cdb79..13ae00fa027ea 100644 --- a/src/hotspot/share/prims/upcallLinker.cpp +++ b/src/hotspot/share/prims/upcallLinker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, 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 @@ struct UpcallContext { UpcallContext() {} // Explicit constructor to address XL C compiler bug. ~UpcallContext() { - if (attachedThread != NULL) { + if (attachedThread != nullptr) { JavaVM_ *vm = (JavaVM *)(&main_vm); vm->functions->DetachCurrentThread(vm); } @@ -97,7 +97,7 @@ JavaThread* UpcallLinker::on_entry(UpcallStub::FrameData* context) { context->old_handles = thread->active_handles(); // For the profiler, the last_Java_frame information in thread must always be in - // legal state. We have no last Java frame if last_Java_sp == NULL so + // legal state. We have no last Java frame if last_Java_sp == nullptr so // the valid transition is to clear _last_Java_sp and then reset the rest of // the (platform specific) state. diff --git a/src/hotspot/share/prims/vectorSupport.cpp b/src/hotspot/share/prims/vectorSupport.cpp index 92d0371806c84..4f2e78739ec9c 100644 --- a/src/hotspot/share/prims/vectorSupport.cpp +++ b/src/hotspot/share/prims/vectorSupport.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, 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 @@ -83,7 +83,7 @@ BasicType VectorSupport::klass2bt(InstanceKlass* ik) { // static final Class ETYPE; Klass* holder = ik->find_field(vmSymbols::ETYPE_name(), vmSymbols::class_signature(), &fd); - assert(holder != NULL, "sanity"); + assert(holder != nullptr, "sanity"); assert(fd.is_static(), ""); assert(fd.offset() > 0, ""); @@ -103,7 +103,7 @@ jint VectorSupport::klass2length(InstanceKlass* ik) { // static final int VLENGTH; Klass* holder = ik->find_field(vmSymbols::VLENGTH_name(), vmSymbols::int_signature(), &fd); - assert(holder != NULL, "sanity"); + assert(holder != nullptr, "sanity"); assert(fd.is_static(), ""); assert(fd.offset() > 0, ""); diff --git a/src/hotspot/share/prims/whitebox.cpp b/src/hotspot/share/prims/whitebox.cpp index 9b5949b9974ea..64db26d122352 100644 --- a/src/hotspot/share/prims/whitebox.cpp +++ b/src/hotspot/share/prims/whitebox.cpp @@ -190,7 +190,7 @@ class WBIsKlassAliveClosure : public LockedClassesDo { // NOTE: This will not work correctly if the original hidden class // name contains a '+'. char* plus_char = strchr(k_name, '+'); - if (plus_char != NULL) { + if (plus_char != nullptr) { *plus_char = 0; char* c_name = _name->as_C_string(); if (strcmp(c_name, k_name) == 0) { @@ -208,7 +208,7 @@ class WBIsKlassAliveClosure : public LockedClassesDo { WB_ENTRY(jint, WB_CountAliveClasses(JNIEnv* env, jobject target, jstring name)) oop h_name = JNIHandles::resolve(name); - if (h_name == NULL) { + if (h_name == nullptr) { return 0; } Symbol* sym = java_lang_String::as_symbol(h_name); @@ -223,7 +223,7 @@ WB_END WB_ENTRY(jint, WB_GetSymbolRefcount(JNIEnv* env, jobject unused, jstring name)) oop h_name = JNIHandles::resolve(name); - if (h_name == NULL) { + if (h_name == nullptr) { return 0; } Symbol* sym = java_lang_String::as_symbol(h_name); @@ -278,8 +278,8 @@ WB_ENTRY(void, WB_ReadFromNoaccessArea(JNIEnv* env, jobject o)) vs.initialize(rhs, 50 * granularity); // Check if constraints are complied - if (!( UseCompressedOops && rhs.base() != NULL && - CompressedOops::base() != NULL && + if (!( UseCompressedOops && rhs.base() != nullptr && + CompressedOops::base() != nullptr && CompressedOops::use_implicit_null_checks() )) { tty->print_cr("WB_ReadFromNoaccessArea method is useless:\n " "\tUseCompressedOops is %d\n" @@ -720,7 +720,7 @@ WB_ENTRY(void, WB_NMTArenaMalloc(JNIEnv* env, jobject o, jlong arena, jlong size WB_END static jmethodID reflected_method_to_jmid(JavaThread* thread, JNIEnv* env, jobject method) { - assert(method != NULL, "method should not be null"); + assert(method != nullptr, "method should not be null"); ThreadToNativeFromVM ttn(thread); return env->FromReflectedMethod(method); } @@ -744,7 +744,7 @@ class VM_WhiteBoxDeoptimizeFrames : public VM_WhiteBoxOperation { Deoptimization::deoptimize(t, *f); if (_make_not_entrant) { CompiledMethod* cm = CodeCache::find_compiled(f->pc()); - assert(cm != NULL, "sanity check"); + assert(cm != nullptr, "sanity check"); cm->make_not_entrant(); } ++_result; @@ -769,10 +769,10 @@ WB_ENTRY(jboolean, WB_IsFrameDeoptimized(JNIEnv* env, jobject o, jint depth)) RegisterMap::ProcessFrames::include, RegisterMap::WalkContinuation::skip); javaVFrame *jvf = thread->last_java_vframe(®_map); - for (jint d = 0; d < depth && jvf != NULL; d++) { + for (jint d = 0; d < depth && jvf != nullptr; d++) { jvf = jvf->java_sender(); } - result = jvf != NULL && jvf->fr().is_deoptimized_frame(); + result = jvf != nullptr && jvf->fr().is_deoptimized_frame(); } return result; WB_END @@ -790,7 +790,7 @@ WB_ENTRY(jint, WB_DeoptimizeMethod(JNIEnv* env, jobject o, jobject method, jbool methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); if (is_osr) { result += mh->mark_osr_nmethods(); - } else if (mh->code() != NULL) { + } else if (mh->code() != nullptr) { mh->code()->mark_for_deoptimization(); ++result; } @@ -807,14 +807,14 @@ WB_ENTRY(jboolean, WB_IsMethodCompiled(JNIEnv* env, jobject o, jobject method, j MutexLocker mu(Compile_lock); methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); CompiledMethod* code = is_osr ? mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false) : mh->code(); - if (code == NULL) { + if (code == nullptr) { return JNI_FALSE; } return !code->is_marked_for_deoptimization(); WB_END static bool is_excluded_for_compiler(AbstractCompiler* comp, methodHandle& mh) { - if (comp == NULL) { + if (comp == nullptr) { return true; } DirectiveSet* directive = DirectivesStack::getMatchingDirective(mh, comp); @@ -833,7 +833,7 @@ static bool can_be_compiled_at_level(methodHandle& mh, jboolean is_osr, int leve } WB_ENTRY(jboolean, WB_IsMethodCompilable(JNIEnv* env, jobject o, jobject method, jint comp_level, jboolean is_osr)) - if (method == NULL || comp_level > CompilationPolicy::highest_compile_level()) { + if (method == nullptr || comp_level > CompilationPolicy::highest_compile_level()) { return false; } jmethodID jmid = reflected_method_to_jmid(thread, env, method); @@ -887,14 +887,14 @@ WB_ENTRY(jboolean, WB_IsIntrinsicAvailable(JNIEnv* env, jobject o, jobject metho DirectiveSet* directive; AbstractCompiler* comp = CompileBroker::compiler((int)compLevel); - assert(comp != NULL, "compiler not available"); - if (compilation_context != NULL) { + assert(comp != nullptr, "compiler not available"); + if (compilation_context != nullptr) { compilation_context_id = reflected_method_to_jmid(thread, env, compilation_context); CHECK_JNI_EXCEPTION_(env, JNI_FALSE); methodHandle cch(THREAD, Method::checked_resolve_jmethod_id(compilation_context_id)); directive = DirectivesStack::getMatchingDirective(cch, comp); } else { - // Calling with NULL matches default directive + // Calling with null matches default directive directive = DirectivesStack::getDefaultDirective(comp); } bool result = comp->is_intrinsic_available(mh, directive); @@ -907,7 +907,7 @@ WB_ENTRY(jint, WB_GetMethodCompilationLevel(JNIEnv* env, jobject o, jobject meth CHECK_JNI_EXCEPTION_(env, CompLevel_none); methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); CompiledMethod* code = is_osr ? mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false) : mh->code(); - return (code != NULL ? code->comp_level() : CompLevel_none); + return (code != nullptr ? code->comp_level() : CompLevel_none); WB_END WB_ENTRY(void, WB_MakeMethodNotCompilable(JNIEnv* env, jobject o, jobject method, jint comp_level, jboolean is_osr)) @@ -927,7 +927,7 @@ WB_ENTRY(jint, WB_GetMethodDecompileCount(JNIEnv* env, jobject o, jobject method methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); uint cnt = 0; MethodData* mdo = mh->method_data(); - if (mdo != NULL) { + if (mdo != nullptr) { cnt = mdo->decompile_count(); } return cnt; @@ -935,7 +935,7 @@ WB_END // Get the trap count of a method for a specific reason. If the trap count for // that reason did overflow, this includes the overflow trap count of the method. -// If 'reason' is NULL, the sum of the traps for all reasons will be returned. +// If 'reason' is null, the sum of the traps for all reasons will be returned. // This number includes the overflow trap count if the trap count for any reason // did overflow. WB_ENTRY(jint, WB_GetMethodTrapCount(JNIEnv* env, jobject o, jobject method, jstring reason_obj)) @@ -944,20 +944,20 @@ WB_ENTRY(jint, WB_GetMethodTrapCount(JNIEnv* env, jobject o, jobject method, jst methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); uint cnt = 0; MethodData* mdo = mh->method_data(); - if (mdo != NULL) { + if (mdo != nullptr) { ResourceMark rm(THREAD); - char* reason_str = (reason_obj == NULL) ? - NULL : java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(reason_obj)); + char* reason_str = (reason_obj == nullptr) ? + nullptr : java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(reason_obj)); bool overflow = false; for (uint reason = 0; reason < mdo->trap_reason_limit(); reason++) { - if (reason_str != NULL && !strcmp(reason_str, Deoptimization::trap_reason_name(reason))) { + if (reason_str != nullptr && !strcmp(reason_str, Deoptimization::trap_reason_name(reason))) { cnt = mdo->trap_count(reason); // Count in the overflow trap count on overflow if (cnt == (uint)-1) { cnt = mdo->trap_count_limit() + mdo->overflow_trap_count(); } break; - } else if (reason_str == NULL) { + } else if (reason_str == nullptr) { uint c = mdo->trap_count(reason); if (c == (uint)-1) { c = mdo->trap_count_limit(); @@ -975,14 +975,14 @@ WB_ENTRY(jint, WB_GetMethodTrapCount(JNIEnv* env, jobject o, jobject method, jst WB_END WB_ENTRY(jint, WB_GetDeoptCount(JNIEnv* env, jobject o, jstring reason_obj, jstring action_obj)) - if (reason_obj == NULL && action_obj == NULL) { + if (reason_obj == nullptr && action_obj == nullptr) { return Deoptimization::total_deoptimization_count(); } ResourceMark rm(THREAD); - const char *reason_str = (reason_obj == NULL) ? - NULL : java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(reason_obj)); - const char *action_str = (action_obj == NULL) ? - NULL : java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(action_obj)); + const char *reason_str = (reason_obj == nullptr) ? + nullptr : java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(reason_obj)); + const char *action_str = (action_obj == nullptr) ? + nullptr : java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(action_obj)); return Deoptimization::deoptimization_count(reason_str, action_str); WB_END @@ -992,7 +992,7 @@ WB_ENTRY(jint, WB_GetMethodEntryBci(JNIEnv* env, jobject o, jobject method)) CHECK_JNI_EXCEPTION_(env, InvocationEntryBci); methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); CompiledMethod* code = mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false); - return (code != NULL && code->is_osr_method() ? code->osr_entry_bci() : InvocationEntryBci); + return (code != nullptr && code->is_osr_method() ? code->osr_entry_bci() : InvocationEntryBci); WB_END WB_ENTRY(jboolean, WB_TestSetDontInlineMethod(JNIEnv* env, jobject o, jobject method, jboolean value)) @@ -1037,15 +1037,15 @@ bool WhiteBox::validate_cgroup(const char* proc_cgroups, bool WhiteBox::compile_method(Method* method, int comp_level, int bci, JavaThread* THREAD) { // Screen for unavailable/bad comp level or null method AbstractCompiler* comp = CompileBroker::compiler(comp_level); - if (method == NULL) { - tty->print_cr("WB error: request to compile NULL method"); + if (method == nullptr) { + tty->print_cr("WB error: request to compile null method"); return false; } if (comp_level > CompilationPolicy::highest_compile_level()) { tty->print_cr("WB error: invalid compilation level %d", comp_level); return false; } - if (comp == NULL) { + if (comp == nullptr) { tty->print_cr("WB error: no compiler for requested compilation level %d", comp_level); return false; } @@ -1060,16 +1060,16 @@ bool WhiteBox::compile_method(Method* method, int comp_level, int bci, JavaThrea nmethod* nm = CompileBroker::compile_method(mh, bci, comp_level, mh, mh->invocation_count(), CompileTask::Reason_Whitebox, CHECK_false); MutexLocker mu(THREAD, Compile_lock); bool is_queued = mh->queued_for_compilation(); - if ((!is_blocking && is_queued) || nm != NULL) { + if ((!is_blocking && is_queued) || nm != nullptr) { return true; } // Check code again because compilation may be finished before Compile_lock is acquired. if (bci == InvocationEntryBci) { CompiledMethod* code = mh->code(); - if (code != NULL && code->as_nmethod_or_null() != NULL) { + if (code != nullptr && code->as_nmethod_or_null() != nullptr) { return true; } - } else if (mh->lookup_osr_nmethod_for(bci, comp_level, false) != NULL) { + } else if (mh->lookup_osr_nmethod_for(bci, comp_level, false) != nullptr) { return true; } tty->print("WB error: failed to %s compile at level %d method ", is_blocking ? "blocking" : "", comp_level); @@ -1090,7 +1090,7 @@ WB_END WB_ENTRY(jboolean, WB_EnqueueInitializerForCompilation(JNIEnv* env, jobject o, jclass klass, jint comp_level)) InstanceKlass* ik = InstanceKlass::cast(java_lang_Class::as_Klass(JNIHandles::resolve(klass))); Method* clinit = ik->class_initializer(); - if (clinit == NULL || clinit->method_holder()->is_not_initialized()) { + if (clinit == nullptr || clinit->method_holder()->is_not_initialized()) { return false; } return WhiteBox::compile_method(clinit, comp_level, InvocationEntryBci, THREAD); @@ -1115,12 +1115,12 @@ WB_ENTRY(jint, WB_MatchesInline(JNIEnv* env, jobject o, jobject method, jstring methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); ResourceMark rm(THREAD); - const char* error_msg = NULL; + const char* error_msg = nullptr; char* method_str = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(pattern)); InlineMatcher* m = InlineMatcher::parse_inline_pattern(method_str, error_msg); - if (m == NULL) { - assert(error_msg != NULL, "Always have an error message"); + if (m == nullptr) { + assert(error_msg != nullptr, "Always have an error message"); tty->print_cr("Got error: %s", error_msg); return -1; // Pattern failed } @@ -1147,11 +1147,11 @@ WB_ENTRY(jint, WB_MatchesMethod(JNIEnv* env, jobject o, jobject method, jstring ResourceMark rm; char* method_str = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(pattern)); - const char* error_msg = NULL; + const char* error_msg = nullptr; BasicMatcher* m = BasicMatcher::parse_method_pattern(method_str, error_msg, false); - if (m == NULL) { - assert(error_msg != NULL, "Must have error_msg"); + if (m == nullptr) { + assert(error_msg != nullptr, "Must have error_msg"); tty->print_cr("Got error: %s", error_msg); return -1; } @@ -1169,7 +1169,7 @@ WB_ENTRY(void, WB_MarkMethodProfiled(JNIEnv* env, jobject o, jobject method)) methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); MethodData* mdo = mh->method_data(); - if (mdo == NULL) { + if (mdo == nullptr) { Method::build_profiling_method_data(mh, CHECK_AND_CLEAR); mdo = mh->method_data(); } @@ -1189,7 +1189,7 @@ WB_ENTRY(void, WB_ClearMethodState(JNIEnv* env, jobject o, jobject method)) MethodData* mdo = mh->method_data(); MethodCounters* mcs = mh->method_counters(); - if (mdo != NULL) { + if (mdo != nullptr) { mdo->init(); ResourceMark rm(THREAD); int arg_count = mdo->method()->size_of_parameters(); @@ -1204,18 +1204,18 @@ WB_ENTRY(void, WB_ClearMethodState(JNIEnv* env, jobject o, jobject method)) mh->clear_not_c2_compilable(); mh->clear_not_c2_osr_compilable(); NOT_PRODUCT(mh->set_compiled_invocation_count(0)); - if (mcs != NULL) { + if (mcs != nullptr) { mcs->clear_counters(); } WB_END template static bool GetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T* value) { - if (name == NULL) { + if (name == nullptr) { return false; } ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI - const char* flag_name = env->GetStringUTFChars(name, NULL); + const char* flag_name = env->GetStringUTFChars(name, nullptr); CHECK_JNI_EXCEPTION_(env, false); const JVMFlag* flag = JVMFlag::find_declared_flag(flag_name); JVMFlag::Error result = JVMFlagAccess::get(flag, value); @@ -1225,11 +1225,11 @@ static bool GetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T* value) { template static bool SetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T* value) { - if (name == NULL) { + if (name == nullptr) { return false; } ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI - const char* flag_name = env->GetStringUTFChars(name, NULL); + const char* flag_name = env->GetStringUTFChars(name, nullptr); CHECK_JNI_EXCEPTION_(env, false); JVMFlag* flag = JVMFlag::find_flag(flag_name); JVMFlag::Error result = JVMFlagAccess::set(flag, value, JVMFlagOrigin::INTERNAL); @@ -1241,13 +1241,13 @@ template static jobject box(JavaThread* thread, JNIEnv* env, Symbol* name, Symbol* sig, T value) { ResourceMark rm(thread); jclass clazz = env->FindClass(name->as_C_string()); - CHECK_JNI_EXCEPTION_(env, NULL); + CHECK_JNI_EXCEPTION_(env, nullptr); jmethodID methodID = env->GetStaticMethodID(clazz, vmSymbols::valueOf_name()->as_C_string(), sig->as_C_string()); - CHECK_JNI_EXCEPTION_(env, NULL); + CHECK_JNI_EXCEPTION_(env, nullptr); jobject result = env->CallStaticObjectMethod(clazz, methodID, value); - CHECK_JNI_EXCEPTION_(env, NULL); + CHECK_JNI_EXCEPTION_(env, nullptr); return result; } @@ -1269,8 +1269,8 @@ static jobject doubleBox(JavaThread* thread, JNIEnv* env, jdouble value) { static const JVMFlag* getVMFlag(JavaThread* thread, JNIEnv* env, jstring name) { ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI - const char* flag_name = env->GetStringUTFChars(name, NULL); - CHECK_JNI_EXCEPTION_(env, NULL); + const char* flag_name = env->GetStringUTFChars(name, nullptr); + CHECK_JNI_EXCEPTION_(env, nullptr); const JVMFlag* result = JVMFlag::find_declared_flag(flag_name); env->ReleaseStringUTFChars(name, flag_name); return result; @@ -1278,12 +1278,12 @@ static const JVMFlag* getVMFlag(JavaThread* thread, JNIEnv* env, jstring name) { WB_ENTRY(jboolean, WB_IsConstantVMFlag(JNIEnv* env, jobject o, jstring name)) const JVMFlag* flag = getVMFlag(thread, env, name); - return (flag != NULL) && flag->is_constant_in_binary(); + return (flag != nullptr) && flag->is_constant_in_binary(); WB_END WB_ENTRY(jboolean, WB_IsLockedVMFlag(JNIEnv* env, jobject o, jstring name)) const JVMFlag* flag = getVMFlag(thread, env, name); - return (flag != NULL) && !(flag->is_unlocked() || flag->is_unlocker()); + return (flag != nullptr) && !(flag->is_unlocked() || flag->is_unlocker()); WB_END WB_ENTRY(jobject, WB_GetBooleanVMFlag(JNIEnv* env, jobject o, jstring name)) @@ -1292,7 +1292,7 @@ WB_ENTRY(jobject, WB_GetBooleanVMFlag(JNIEnv* env, jobject o, jstring name)) ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI return booleanBox(thread, env, result); } - return NULL; + return nullptr; WB_END template @@ -1302,7 +1302,7 @@ jobject GetVMFlag_longBox(JNIEnv* env, JavaThread* thread, jstring name) { ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI return longBox(thread, env, result); } - return NULL; + return nullptr; } WB_ENTRY(jobject, WB_GetIntVMFlag(JNIEnv* env, jobject o, jstring name)) @@ -1335,7 +1335,7 @@ WB_ENTRY(jobject, WB_GetDoubleVMFlag(JNIEnv* env, jobject o, jstring name)) ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI return doubleBox(thread, env, result); } - return NULL; + return nullptr; WB_END WB_ENTRY(jstring, WB_GetStringVMFlag(JNIEnv* env, jobject o, jstring name)) @@ -1343,10 +1343,10 @@ WB_ENTRY(jstring, WB_GetStringVMFlag(JNIEnv* env, jobject o, jstring name)) if (GetVMFlag (thread, env, name, &ccstrResult)) { ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI jstring result = env->NewStringUTF(ccstrResult); - CHECK_JNI_EXCEPTION_(env, NULL); + CHECK_JNI_EXCEPTION_(env, nullptr); return result; } - return NULL; + return nullptr; WB_END WB_ENTRY(void, WB_SetBooleanVMFlag(JNIEnv* env, jobject o, jstring name, jboolean value)) @@ -1392,21 +1392,21 @@ WB_END WB_ENTRY(void, WB_SetStringVMFlag(JNIEnv* env, jobject o, jstring name, jstring value)) ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI const char* ccstrValue; - if (value == NULL) { - ccstrValue = NULL; + if (value == nullptr) { + ccstrValue = nullptr; } else { - ccstrValue = env->GetStringUTFChars(value, NULL); + ccstrValue = env->GetStringUTFChars(value, nullptr); CHECK_JNI_EXCEPTION(env); } { ccstr param = ccstrValue; ThreadInVMfromNative ttvfn(thread); // back to VM if (SetVMFlag (thread, env, name, ¶m)) { - assert(param == NULL, "old value is freed automatically and not returned"); + assert(param == nullptr, "old value is freed automatically and not returned"); } } - if (value != NULL) { + if (value != nullptr) { env->ReleaseStringUTFChars(value, ccstrValue); } WB_END @@ -1425,7 +1425,7 @@ WB_ENTRY(jboolean, WB_IsInStringTable(JNIEnv* env, jobject o, jstring javaString ResourceMark rm(THREAD); int len; jchar* name = java_lang_String::as_unicode_string(JNIHandles::resolve(javaString), len, CHECK_false); - return (StringTable::lookup(name, len) != NULL); + return (StringTable::lookup(name, len) != nullptr); WB_END WB_ENTRY(void, WB_FullGC(JNIEnv* env, jobject o)) @@ -1450,7 +1450,7 @@ WB_ENTRY(void, WB_ReadReservedMemory(JNIEnv* env, jobject o)) static volatile char* p; p = os::reserve_memory(os::vm_allocation_granularity()); - if (p == NULL) { + if (p == nullptr) { THROW_MSG(vmSymbols::java_lang_OutOfMemoryError(), "Failed to reserve memory"); } @@ -1462,7 +1462,7 @@ WB_ENTRY(jstring, WB_GetCPUFeatures(JNIEnv* env, jobject o)) ThreadToNativeFromVM ttn(thread); jstring features_string = env->NewStringUTF(features); - CHECK_JNI_EXCEPTION_(env, NULL); + CHECK_JNI_EXCEPTION_(env, nullptr); return features_string; WB_END @@ -1493,23 +1493,23 @@ struct CodeBlobStub { static jobjectArray codeBlob2objectArray(JavaThread* thread, JNIEnv* env, CodeBlobStub* cb) { ResourceMark rm; jclass clazz = env->FindClass(vmSymbols::java_lang_Object()->as_C_string()); - CHECK_JNI_EXCEPTION_(env, NULL); - jobjectArray result = env->NewObjectArray(4, clazz, NULL); + CHECK_JNI_EXCEPTION_(env, nullptr); + jobjectArray result = env->NewObjectArray(4, clazz, nullptr); jstring name = env->NewStringUTF(cb->name); - CHECK_JNI_EXCEPTION_(env, NULL); + CHECK_JNI_EXCEPTION_(env, nullptr); env->SetObjectArrayElement(result, 0, name); jobject obj = integerBox(thread, env, cb->size); - CHECK_JNI_EXCEPTION_(env, NULL); + CHECK_JNI_EXCEPTION_(env, nullptr); env->SetObjectArrayElement(result, 1, obj); obj = integerBox(thread, env, cb->blob_type); - CHECK_JNI_EXCEPTION_(env, NULL); + CHECK_JNI_EXCEPTION_(env, nullptr); env->SetObjectArrayElement(result, 2, obj); obj = longBox(thread, env, cb->address); - CHECK_JNI_EXCEPTION_(env, NULL); + CHECK_JNI_EXCEPTION_(env, nullptr); env->SetObjectArrayElement(result, 3, obj); return result; @@ -1518,11 +1518,11 @@ static jobjectArray codeBlob2objectArray(JavaThread* thread, JNIEnv* env, CodeBl WB_ENTRY(jobjectArray, WB_GetNMethod(JNIEnv* env, jobject o, jobject method, jboolean is_osr)) ResourceMark rm(THREAD); jmethodID jmid = reflected_method_to_jmid(thread, env, method); - CHECK_JNI_EXCEPTION_(env, NULL); + CHECK_JNI_EXCEPTION_(env, nullptr); methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); CompiledMethod* code = is_osr ? mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false) : mh->code(); - jobjectArray result = NULL; - if (code == NULL) { + jobjectArray result = nullptr; + if (code == nullptr) { return result; } int comp_level = code->comp_level(); @@ -1530,32 +1530,32 @@ WB_ENTRY(jobjectArray, WB_GetNMethod(JNIEnv* env, jobject o, jobject method, jbo ThreadToNativeFromVM ttn(thread); jclass clazz = env->FindClass(vmSymbols::java_lang_Object()->as_C_string()); - CHECK_JNI_EXCEPTION_(env, NULL); - result = env->NewObjectArray(5, clazz, NULL); - if (result == NULL) { + CHECK_JNI_EXCEPTION_(env, nullptr); + result = env->NewObjectArray(5, clazz, nullptr); + if (result == nullptr) { return result; } CodeBlobStub stub(code); jobjectArray codeBlob = codeBlob2objectArray(thread, env, &stub); - CHECK_JNI_EXCEPTION_(env, NULL); + CHECK_JNI_EXCEPTION_(env, nullptr); env->SetObjectArrayElement(result, 0, codeBlob); jobject level = integerBox(thread, env, comp_level); - CHECK_JNI_EXCEPTION_(env, NULL); + CHECK_JNI_EXCEPTION_(env, nullptr); env->SetObjectArrayElement(result, 1, level); jbyteArray insts = env->NewByteArray(insts_size); - CHECK_JNI_EXCEPTION_(env, NULL); + CHECK_JNI_EXCEPTION_(env, nullptr); env->SetByteArrayRegion(insts, 0, insts_size, (jbyte*) code->insts_begin()); env->SetObjectArrayElement(result, 2, insts); jobject id = integerBox(thread, env, code->compile_id()); - CHECK_JNI_EXCEPTION_(env, NULL); + CHECK_JNI_EXCEPTION_(env, nullptr); env->SetObjectArrayElement(result, 3, id); jobject entry_point = longBox(thread, env, (jlong) code->entry_point()); - CHECK_JNI_EXCEPTION_(env, NULL); + CHECK_JNI_EXCEPTION_(env, nullptr); env->SetObjectArrayElement(result, 4, entry_point); return result; @@ -1571,7 +1571,7 @@ CodeBlob* WhiteBox::allocate_code_blob(int size, CodeBlobType blob_type) { { MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); blob = (BufferBlob*) CodeCache::allocate(full_size, blob_type); - if (blob != NULL) { + if (blob != nullptr) { ::new (blob) BufferBlob("WB::DummyBlob", full_size); } } @@ -1601,32 +1601,32 @@ WB_ENTRY(jobjectArray, WB_GetCodeHeapEntries(JNIEnv* env, jobject o, jint blob_t { MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); CodeHeap* heap = WhiteBox::get_code_heap(static_cast(blob_type)); - if (heap == NULL) { - return NULL; + if (heap == nullptr) { + return nullptr; } for (CodeBlob* cb = (CodeBlob*) heap->first(); - cb != NULL; cb = (CodeBlob*) heap->next(cb)) { + cb != nullptr; cb = (CodeBlob*) heap->next(cb)) { CodeBlobStub* stub = NEW_RESOURCE_OBJ(CodeBlobStub); new (stub) CodeBlobStub(cb); blobs.append(stub); } } ThreadToNativeFromVM ttn(thread); - jobjectArray result = NULL; + jobjectArray result = nullptr; jclass clazz = env->FindClass(vmSymbols::java_lang_Object()->as_C_string()); - CHECK_JNI_EXCEPTION_(env, NULL); - result = env->NewObjectArray(blobs.length(), clazz, NULL); - CHECK_JNI_EXCEPTION_(env, NULL); - if (result == NULL) { + CHECK_JNI_EXCEPTION_(env, nullptr); + result = env->NewObjectArray(blobs.length(), clazz, nullptr); + CHECK_JNI_EXCEPTION_(env, nullptr); + if (result == nullptr) { return result; } int i = 0; for (GrowableArrayIterator it = blobs.begin(); it != blobs.end(); ++it) { jobjectArray obj = codeBlob2objectArray(thread, env, *it); - CHECK_JNI_EXCEPTION_(env, NULL); + CHECK_JNI_EXCEPTION_(env, nullptr); env->SetObjectArrayElement(result, i, obj); - CHECK_JNI_EXCEPTION_(env, NULL); + CHECK_JNI_EXCEPTION_(env, nullptr); ++i; } return result; @@ -1733,7 +1733,7 @@ WB_ENTRY(jlong, WB_AllocateMetaspace(JNIEnv* env, jobject wb, jobject class_load } oop class_loader_oop = JNIHandles::resolve(class_loader); - ClassLoaderData* cld = class_loader_oop != NULL + ClassLoaderData* cld = class_loader_oop != nullptr ? java_lang_ClassLoader::loader_data_acquire(class_loader_oop) : ClassLoaderData::the_null_class_loader_data(); @@ -1840,7 +1840,7 @@ WB_END WB_ENTRY(jint, WB_GetConstantPoolCacheLength(JNIEnv* env, jobject wb, jclass klass)) InstanceKlass* ik = InstanceKlass::cast(java_lang_Class::as_Klass(JNIHandles::resolve(klass))); ConstantPool* cp = ik->constants(); - if (cp->cache() == NULL) { + if (cp->cache() == nullptr) { return -1; } return cp->cache()->length(); @@ -1849,7 +1849,7 @@ WB_END WB_ENTRY(jint, WB_ConstantPoolRemapInstructionOperandFromCache(JNIEnv* env, jobject wb, jclass klass, jint index)) InstanceKlass* ik = InstanceKlass::cast(java_lang_Class::as_Klass(JNIHandles::resolve(klass))); ConstantPool* cp = ik->constants(); - if (cp->cache() == NULL) { + if (cp->cache() == nullptr) { THROW_MSG_0(vmSymbols::java_lang_IllegalStateException(), "Constant pool does not have a cache"); } jint cpci = index; @@ -1872,8 +1872,8 @@ WB_END template static bool GetMethodOption(JavaThread* thread, JNIEnv* env, jobject method, jstring name, T* value) { - assert(value != NULL, "sanity"); - if (method == NULL || name == NULL) { + assert(value != nullptr, "sanity"); + if (method == nullptr || name == nullptr) { return false; } jmethodID jmid = reflected_method_to_jmid(thread, env, method); @@ -1881,7 +1881,7 @@ static bool GetMethodOption(JavaThread* thread, JNIEnv* env, jobject method, jst methodHandle mh(thread, Method::checked_resolve_jmethod_id(jmid)); // can't be in VM when we call JNI ThreadToNativeFromVM ttnfv(thread); - const char* flag_name = env->GetStringUTFChars(name, NULL); + const char* flag_name = env->GetStringUTFChars(name, nullptr); CHECK_JNI_EXCEPTION_(env, false); enum CompileCommand option = CompilerOracle::string_to_option(flag_name); env->ReleaseStringUTFChars(name, flag_name); @@ -1901,7 +1901,7 @@ WB_ENTRY(jobject, WB_GetMethodBooleaneOption(JNIEnv* env, jobject wb, jobject me ThreadToNativeFromVM ttnfv(thread); return booleanBox(thread, env, result); } - return NULL; + return nullptr; WB_END WB_ENTRY(jobject, WB_GetMethodIntxOption(JNIEnv* env, jobject wb, jobject method, jstring name)) @@ -1911,7 +1911,7 @@ WB_ENTRY(jobject, WB_GetMethodIntxOption(JNIEnv* env, jobject wb, jobject method ThreadToNativeFromVM ttnfv(thread); return longBox(thread, env, result); } - return NULL; + return nullptr; WB_END WB_ENTRY(jobject, WB_GetMethodUintxOption(JNIEnv* env, jobject wb, jobject method, jstring name)) @@ -1921,7 +1921,7 @@ WB_ENTRY(jobject, WB_GetMethodUintxOption(JNIEnv* env, jobject wb, jobject metho ThreadToNativeFromVM ttnfv(thread); return longBox(thread, env, result); } - return NULL; + return nullptr; WB_END WB_ENTRY(jobject, WB_GetMethodDoubleOption(JNIEnv* env, jobject wb, jobject method, jstring name)) @@ -1931,7 +1931,7 @@ WB_ENTRY(jobject, WB_GetMethodDoubleOption(JNIEnv* env, jobject wb, jobject meth ThreadToNativeFromVM ttnfv(thread); return doubleBox(thread, env, result); } - return NULL; + return nullptr; WB_END WB_ENTRY(jobject, WB_GetMethodStringOption(JNIEnv* env, jobject wb, jobject method, jstring name)) @@ -1940,10 +1940,10 @@ WB_ENTRY(jobject, WB_GetMethodStringOption(JNIEnv* env, jobject wb, jobject meth // can't be in VM when we call JNI ThreadToNativeFromVM ttnfv(thread); jstring result = env->NewStringUTF(ccstrResult); - CHECK_JNI_EXCEPTION_(env, NULL); + CHECK_JNI_EXCEPTION_(env, nullptr); return result; } - return NULL; + return nullptr; WB_END WB_ENTRY(jobject, WB_GetDefaultArchivePath(JNIEnv* env, jobject wb)) @@ -1951,7 +1951,7 @@ WB_ENTRY(jobject, WB_GetDefaultArchivePath(JNIEnv* env, jobject wb)) ThreadToNativeFromVM ttn(thread); jstring path_string = env->NewStringUTF(p); - CHECK_JNI_EXCEPTION_(env, NULL); + CHECK_JNI_EXCEPTION_(env, nullptr); return path_string; WB_END @@ -2011,7 +2011,7 @@ WB_ENTRY(jobject, WB_GetResolvedReferences(JNIEnv* env, jobject wb, jclass clazz objArrayOop refs = cp->resolved_references(); return (jobject)JNIHandles::make_local(THREAD, refs); } else { - return NULL; + return nullptr; } WB_END @@ -2108,16 +2108,16 @@ WB_ENTRY(jboolean, WB_HandshakeReadMonitors(JNIEnv* env, jobject wb, jobject thr RegisterMap::UpdateMap::include, RegisterMap::ProcessFrames::include, RegisterMap::WalkContinuation::skip); - for (javaVFrame* vf = jt->last_java_vframe(&rmap); vf != NULL; vf = vf->java_sender()) { + for (javaVFrame* vf = jt->last_java_vframe(&rmap); vf != nullptr; vf = vf->java_sender()) { GrowableArray *monitors = vf->monitors(); - if (monitors != NULL) { + if (monitors != nullptr) { int len = monitors->length(); // Walk monitors youngest to oldest for (int i = len - 1; i >= 0; i--) { MonitorInfo* mon_info = monitors->at(i); if (mon_info->eliminated()) continue; oop owner = mon_info->owner(); - if (owner != NULL) { + if (owner != nullptr) { info->append(mon_info); } } @@ -2132,10 +2132,10 @@ WB_ENTRY(jboolean, WB_HandshakeReadMonitors(JNIEnv* env, jobject wb, jobject thr }; ReadMonitorsClosure rmc; - if (thread_handle != NULL) { + if (thread_handle != nullptr) { ThreadsListHandle tlh; JavaThread* target = nullptr; - bool is_alive = tlh.cv_internal_thread_to_JavaThread(thread_handle, &target, NULL); + bool is_alive = tlh.cv_internal_thread_to_JavaThread(thread_handle, &target, nullptr); if (is_alive) { Handshake::execute(&rmc, &tlh, target); } @@ -2166,10 +2166,10 @@ WB_ENTRY(jint, WB_HandshakeWalkStack(JNIEnv* env, jobject wb, jobject thread_han if (all_threads) { Handshake::execute(&tsc); - } else if (thread_handle != NULL) { + } else if (thread_handle != nullptr) { ThreadsListHandle tlh; JavaThread* target = nullptr; - bool is_alive = tlh.cv_internal_thread_to_JavaThread(thread_handle, &target, NULL); + bool is_alive = tlh.cv_internal_thread_to_JavaThread(thread_handle, &target, nullptr); if (is_alive) { Handshake::execute(&tsc, &tlh, target); } @@ -2195,10 +2195,10 @@ WB_ENTRY(void, WB_AsyncHandshakeWalkStack(JNIEnv* env, jobject wb, jobject threa public: TraceSelfClosure(JavaThread* self_target) : AsyncHandshakeClosure("WB_TraceSelf"), _self(self_target) {} }; - if (thread_handle != NULL) { + if (thread_handle != nullptr) { ThreadsListHandle tlh; JavaThread* target = nullptr; - bool is_alive = tlh.cv_internal_thread_to_JavaThread(thread_handle, &target, NULL); + bool is_alive = tlh.cv_internal_thread_to_JavaThread(thread_handle, &target, nullptr); if (is_alive) { TraceSelfClosure* tsc = new TraceSelfClosure(target); Handshake::execute(tsc, target); @@ -2234,7 +2234,7 @@ WB_END // Some convenience methods to deal with objects from java int WhiteBox::offset_for_field(const char* field_name, oop object, Symbol* signature_symbol) { - assert(field_name != NULL && strlen(field_name) > 0, "Field name not valid"); + assert(field_name != nullptr && strlen(field_name) > 0, "Field name not valid"); //Get the class of our object Klass* arg_klass = object->klass(); @@ -2248,7 +2248,7 @@ int WhiteBox::offset_for_field(const char* field_name, oop object, fieldDescriptor fd; Klass* res = ik->find_field(name_symbol, signature_symbol, &fd); - if (res == NULL) { + if (res == nullptr) { tty->print_cr("Invalid layout of %s at %s", ik->external_name(), name_symbol->as_C_string()); vm_exit_during_initialization("Invalid layout of preloaded class: use -Xlog:class+load=info to see the origin of the problem class"); @@ -2265,8 +2265,8 @@ const char* WhiteBox::lookup_jstring(const char* field_name, oop object) { int offset = offset_for_field(field_name, object, vmSymbols::string_signature()); oop string = object->obj_field(offset); - if (string == NULL) { - return NULL; + if (string == nullptr) { + return nullptr; } const char* ret = java_lang_String::as_utf8_string(string); return ret; @@ -2291,10 +2291,10 @@ void WhiteBox::register_methods(JNIEnv* env, jclass wbclass, JavaThread* thread, CHECK_JNI_EXCEPTION(env); for (int i = 0, n = method_count; i < n; ++i) { // Skip dummy entries - if (method_array[i].fnPtr == NULL) continue; + if (method_array[i].fnPtr == nullptr) continue; if (env->RegisterNatives(wbclass, &method_array[i], 1) != 0) { jthrowable throwable_obj = env->ExceptionOccurred(); - if (throwable_obj != NULL) { + if (throwable_obj != nullptr) { env->ExceptionClear(); if (env->IsInstanceOf(throwable_obj, no_such_method_error_klass)) { // NoSuchMethodError is thrown when a method can't be found or a method is not native. @@ -2316,7 +2316,7 @@ void WhiteBox::register_methods(JNIEnv* env, jclass wbclass, JavaThread* thread, WB_ENTRY(jint, WB_AddCompilerDirective(JNIEnv* env, jobject o, jstring compDirect)) // can't be in VM when we call JNI ThreadToNativeFromVM ttnfv(thread); - const char* dir = env->GetStringUTFChars(compDirect, NULL); + const char* dir = env->GetStringUTFChars(compDirect, nullptr); CHECK_JNI_EXCEPTION_(env, 0); int ret; { @@ -2341,7 +2341,7 @@ WB_ENTRY(jboolean, WB_CheckLibSpecifiesNoexecstack(JNIEnv* env, jobject o, jstri #ifdef LINUX // Can't be in VM when we call JNI. ThreadToNativeFromVM ttnfv(thread); - const char* lf = env->GetStringUTFChars(libfile, NULL); + const char* lf = env->GetStringUTFChars(libfile, nullptr); CHECK_JNI_EXCEPTION_(env, 0); ret = (jboolean) ElfFile::specifies_noexecstack(lf); env->ReleaseStringUTFChars(libfile, lf); @@ -2374,11 +2374,11 @@ WB_ENTRY(jint, WB_ValidateCgroup(JNIEnv* env, jint ret = 0; #ifdef LINUX ThreadToNativeFromVM ttnfv(thread); - const char* p_cgroups = env->GetStringUTFChars(proc_cgroups, NULL); + const char* p_cgroups = env->GetStringUTFChars(proc_cgroups, nullptr); CHECK_JNI_EXCEPTION_(env, 0); - const char* p_s_cgroup = env->GetStringUTFChars(proc_self_cgroup, NULL); + const char* p_s_cgroup = env->GetStringUTFChars(proc_self_cgroup, nullptr); CHECK_JNI_EXCEPTION_(env, 0); - const char* p_s_mountinfo = env->GetStringUTFChars(proc_self_mountinfo, NULL); + const char* p_s_mountinfo = env->GetStringUTFChars(proc_self_mountinfo, nullptr); CHECK_JNI_EXCEPTION_(env, 0); u1 cg_type_flags = 0; // This sets cg_type_flags @@ -2429,7 +2429,7 @@ WB_ENTRY(void, WB_CheckThreadObjOfTerminatingThread(JNIEnv* env, jobject wb, job // Look up the target thread by tid to ensure it is present JavaThread* t = tlh.list()->find_JavaThread_from_java_tid(tid); - if (t == NULL) { + if (t == nullptr) { THROW_MSG(vmSymbols::java_lang_RuntimeException(), "Target thread not found in ThreadsList!"); } @@ -2476,7 +2476,7 @@ WB_ENTRY(void, WB_VerifyFrames(JNIEnv* env, jobject wb, jboolean log, jboolean u for (StackFrameStream fst(JavaThread::current(), update_map, true); !fst.is_done(); fst.next()) { frame* current_frame = fst.current(); if (log) { - current_frame->print_value_on(&st, NULL); + current_frame->print_value_on(&st, nullptr); } current_frame->verify(fst.register_map()); } @@ -2502,7 +2502,7 @@ WB_END WB_ENTRY(jstring, WB_GetLibcName(JNIEnv* env, jobject o)) ThreadToNativeFromVM ttn(thread); jstring info_string = env->NewStringUTF(XSTR(LIBC)); - CHECK_JNI_EXCEPTION_(env, NULL); + CHECK_JNI_EXCEPTION_(env, nullptr); return info_string; WB_END