diff --git a/.github/actions/do-build/action.yml b/.github/actions/do-build/action.yml index 3deb7f4b8f8..79eddf8c70f 100644 --- a/.github/actions/do-build/action.yml +++ b/.github/actions/do-build/action.yml @@ -66,7 +66,7 @@ runs: shell: bash - name: 'Upload build logs' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: failure-logs-${{ inputs.platform }}${{ inputs.debug-suffix }} path: failure-logs @@ -74,7 +74,7 @@ runs: # This is the best way I found to abort the job with an error message - name: 'Notify about build failures' - uses: actions/github-script@v6 + uses: actions/github-script@v7 with: script: core.setFailed('Build failed. See summary for details.') if: steps.check.outputs.failure == 'true' diff --git a/.github/actions/get-bootjdk/action.yml b/.github/actions/get-bootjdk/action.yml index 1e569dd47c5..25ee1d8dfa0 100644 --- a/.github/actions/get-bootjdk/action.yml +++ b/.github/actions/get-bootjdk/action.yml @@ -65,7 +65,7 @@ runs: - name: 'Check cache for BootJDK' id: get-cached-bootjdk - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: bootjdk/jdk key: boot-jdk-${{ inputs.platform }}-${{ steps.sha256.outputs.value }} diff --git a/.github/actions/get-bundles/action.yml b/.github/actions/get-bundles/action.yml index 956e1520cfb..0e52320a350 100644 --- a/.github/actions/get-bundles/action.yml +++ b/.github/actions/get-bundles/action.yml @@ -48,14 +48,14 @@ runs: steps: - name: 'Download bundles artifact' id: download-bundles - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: bundles-${{ inputs.platform }}${{ inputs.debug-suffix }} path: bundles continue-on-error: true - name: 'Download bundles artifact (retry)' - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: bundles-${{ inputs.platform }}${{ inputs.debug-suffix }} path: bundles diff --git a/.github/actions/get-jtreg/action.yml b/.github/actions/get-jtreg/action.yml index 3f5786b22d3..b0ef654dbed 100644 --- a/.github/actions/get-jtreg/action.yml +++ b/.github/actions/get-jtreg/action.yml @@ -41,7 +41,7 @@ runs: - name: 'Check cache for JTReg' id: get-cached-jtreg - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: jtreg/installed key: jtreg-${{ steps.version.outputs.value }} diff --git a/.github/actions/get-msys2/action.yml b/.github/actions/get-msys2/action.yml index d36957e3b37..82022a6e233 100644 --- a/.github/actions/get-msys2/action.yml +++ b/.github/actions/get-msys2/action.yml @@ -30,8 +30,7 @@ runs: using: composite steps: - name: 'Install MSYS2' - # use a specific release of msys2/setup-msys2 to prevent jtreg build failures on newer release - uses: msys2/setup-msys2@7efe20baefed56359985e327d329042cde2434ff + uses: msys2/setup-msys2@v2.22.0 with: install: 'autoconf tar unzip zip make' path-type: minimal diff --git a/.github/actions/upload-bundles/action.yml b/.github/actions/upload-bundles/action.yml index 6e36278eea4..a3ab7b47414 100644 --- a/.github/actions/upload-bundles/action.yml +++ b/.github/actions/upload-bundles/action.yml @@ -70,7 +70,7 @@ runs: shell: bash - name: 'Upload bundles artifact' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: bundles-${{ inputs.platform }}${{ inputs.debug-suffix }} path: bundles diff --git a/.github/scripts/gen-test-summary.sh b/.github/scripts/gen-test-summary.sh index d016cb38649..a612bed5527 100644 --- a/.github/scripts/gen-test-summary.sh +++ b/.github/scripts/gen-test-summary.sh @@ -42,6 +42,7 @@ error_count=$(echo $errors | wc -w || true) if [[ "$failures" = "" && "$errors" = "" ]]; then # We know something went wrong, but not what + echo 'failure=true' >> $GITHUB_OUTPUT echo 'error-message=Unspecified test suite failure. Please see log for job for details.' >> $GITHUB_OUTPUT exit 0 fi diff --git a/.github/workflows/build-cross-compile.yml b/.github/workflows/build-cross-compile.yml index 77620640f13..dbc6a11ea66 100644 --- a/.github/workflows/build-cross-compile.yml +++ b/.github/workflows/build-cross-compile.yml @@ -120,7 +120,7 @@ jobs: - name: 'Check cache for sysroot' id: get-cached-sysroot - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: sysroot key: sysroot-${{ matrix.debian-arch }}-${{ hashFiles('./.github/workflows/build-cross-compile.yml') }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0dba04e41b7..1ad984fce56 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -365,7 +365,7 @@ jobs: # Hack to get hold of the api environment variables that are only defined for actions - name: 'Get API configuration' id: api - uses: actions/github-script@v6 + uses: actions/github-script@v7 with: script: 'return { url: process.env["ACTIONS_RUNTIME_URL"], token: process.env["ACTIONS_RUNTIME_TOKEN"] }' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b3590166264..5c86ec4b4c4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -206,7 +206,7 @@ jobs: if: always() - name: 'Upload test results' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: path: results name: ${{ steps.package.outputs.artifact-name }} @@ -214,7 +214,7 @@ jobs: # This is the best way I found to abort the job with an error message - name: 'Notify about test failures' - uses: actions/github-script@v6 + uses: actions/github-script@v7 with: script: core.setFailed('${{ steps.run-tests.outputs.error-message }}') if: steps.run-tests.outputs.failure == 'true' diff --git a/make/conf/github-actions.conf b/make/conf/github-actions.conf index 05c6db9b032..50d5a887fdf 100644 --- a/make/conf/github-actions.conf +++ b/make/conf/github-actions.conf @@ -29,13 +29,13 @@ GTEST_VERSION=1.14.0 JTREG_VERSION=7.3.1+1 LINUX_X64_BOOT_JDK_EXT=tar.gz -LINUX_X64_BOOT_JDK_URL=https://github.com/SAP/SapMachine/releases/download/sapmachine-21.0.1/sapmachine-jdk-21.0.1_linux-x64_bin.tar.gz -LINUX_X64_BOOT_JDK_SHA256=450426abc41695696c49c02df437882e6763344522c70a46ae6b0b682ba370ff +LINUX_X64_BOOT_JDK_URL=https://github.com/SAP/SapMachine/releases/download/sapmachine-21.0.2/sapmachine-jdk-21.0.2_linux-x64_bin.tar.gz +LINUX_X64_BOOT_JDK_SHA256=3123189ec5b99eed78de0328e2fd49d7c13cc7d4524c341f1fe8fbd5165be31f MACOS_X64_BOOT_JDK_EXT=tar.gz -MACOS_X64_BOOT_JDK_URL=https://github.com/SAP/SapMachine/releases/download/sapmachine-21.0.1/sapmachine-jdk-21.0.1_macos-x64_bin.tar.gz -MACOS_X64_BOOT_JDK_SHA256=498bdb5635be4b784ccfe12f83dc4c83f6a5fb2f37666a4fec408a2fd4083afa +MACOS_X64_BOOT_JDK_URL=https://github.com/SAP/SapMachine/releases/download/sapmachine-21.0.2/sapmachine-jdk-21.0.2_macos-x64_bin.tar.gz +MACOS_X64_BOOT_JDK_SHA256=826fb6c8c5b4c24a1150ad3e393114a8be9072b9f9a65bc10ec8343971eb48fc WINDOWS_X64_BOOT_JDK_EXT=zip -WINDOWS_X64_BOOT_JDK_URL=https://github.com/SAP/SapMachine/releases/download/sapmachine-21.0.1/sapmachine-jdk-21.0.1_windows-x64_bin.zip -WINDOWS_X64_BOOT_JDK_SHA256=d200fc7b4e5c13293caf992aef3207dd627917353c3f189901e4d95fe23bdea5 +WINDOWS_X64_BOOT_JDK_URL=https://github.com/SAP/SapMachine/releases/download/sapmachine-21.0.2/sapmachine-jdk-21.0.2_windows-x64_bin.zip +WINDOWS_X64_BOOT_JDK_SHA256=8b2bc8007381240728ca50a23f020a3603ca84314308df707d4b3eff5b3bcfd5 diff --git a/make/modules/java.base/Java.gmk b/make/modules/java.base/Java.gmk index 8621ff945cc..349741c0310 100644 --- a/make/modules/java.base/Java.gmk +++ b/make/modules/java.base/Java.gmk @@ -37,7 +37,8 @@ EXCLUDE_FILES += \ EXCLUDES += java/lang/doc-files \ java/lang/classfile/snippet-files \ - java/lang/classfile/components/snippet-files + java/lang/classfile/components/snippet-files \ + java/lang/foreign/snippet-files # Exclude BreakIterator classes that are just used in compile process to generate # data files and shouldn't go in the product diff --git a/make/modules/java.desktop/lib/Awt2dLibraries.gmk b/make/modules/java.desktop/lib/Awt2dLibraries.gmk index 4d5ff751981..e274005e607 100644 --- a/make/modules/java.desktop/lib/Awt2dLibraries.gmk +++ b/make/modules/java.desktop/lib/Awt2dLibraries.gmk @@ -449,7 +449,6 @@ else LIBFREETYPE_LIBS := -lfreetype endif - # gcc_ftobjs.c := maybe-uninitialized required for GCC 7 builds. $(eval $(call SetupJdkLibrary, BUILD_LIBFREETYPE, \ NAME := freetype, \ OPTIMIZATION := HIGHEST, \ @@ -458,7 +457,6 @@ else EXTRA_HEADER_DIRS := $(BUILD_LIBFREETYPE_HEADER_DIRS), \ DISABLED_WARNINGS_microsoft := 4267 4244 4996, \ DISABLED_WARNINGS_gcc := dangling-pointer stringop-overflow, \ - DISABLED_WARNINGS_gcc_ftobjs.c := maybe-uninitialized, \ LDFLAGS := $(LDFLAGS_JDKLIB) \ $(call SET_SHARED_LIBRARY_ORIGIN), \ )) diff --git a/src/hotspot/cpu/aarch64/aarch64.ad b/src/hotspot/cpu/aarch64/aarch64.ad index f637648b227..10a5624f056 100644 --- a/src/hotspot/cpu/aarch64/aarch64.ad +++ b/src/hotspot/cpu/aarch64/aarch64.ad @@ -2377,7 +2377,7 @@ int Matcher::min_vector_size(const BasicType bt) { return MIN2(size, max_size); } -int Matcher::superword_max_vector_size(const BasicType bt) { +int Matcher::max_vector_size_auto_vectorization(const BasicType bt) { return Matcher::max_vector_size(bt); } @@ -8289,7 +8289,7 @@ instruct membar_acquire() %{ ins_cost(VOLATILE_REF_COST); format %{ "membar_acquire\n\t" - "dmb ish" %} + "dmb ishld" %} ins_encode %{ __ block_comment("membar_acquire"); @@ -8343,11 +8343,12 @@ instruct membar_release() %{ ins_cost(VOLATILE_REF_COST); format %{ "membar_release\n\t" - "dmb ish" %} + "dmb ishst\n\tdmb ishld" %} ins_encode %{ __ block_comment("membar_release"); - __ membar(Assembler::LoadStore|Assembler::StoreStore); + __ membar(Assembler::StoreStore); + __ membar(Assembler::LoadStore); %} ins_pipe(pipe_serial); %} diff --git a/src/hotspot/cpu/aarch64/aarch64_vector.ad b/src/hotspot/cpu/aarch64/aarch64_vector.ad index 210efa0b760..d611c14f403 100644 --- a/src/hotspot/cpu/aarch64/aarch64_vector.ad +++ b/src/hotspot/cpu/aarch64/aarch64_vector.ad @@ -1,5 +1,5 @@ // -// Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. // Copyright (c) 2020, 2023, Arm Limited. All rights reserved. // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. // @@ -126,7 +126,7 @@ source %{ } } - bool Matcher::match_rule_supported_superword(int opcode, int vlen, BasicType bt) { + bool Matcher::match_rule_supported_auto_vectorization(int opcode, int vlen, BasicType bt) { if (UseSVE == 0) { // These operations are not profitable to be vectorized on NEON, because no direct // NEON instructions support them. But the match rule support for them is profitable for diff --git a/src/hotspot/cpu/aarch64/aarch64_vector_ad.m4 b/src/hotspot/cpu/aarch64/aarch64_vector_ad.m4 index 3f4ed020f55..5c4e13d432f 100644 --- a/src/hotspot/cpu/aarch64/aarch64_vector_ad.m4 +++ b/src/hotspot/cpu/aarch64/aarch64_vector_ad.m4 @@ -1,5 +1,5 @@ // -// Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. // Copyright (c) 2020, 2023, Arm Limited. All rights reserved. // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. // @@ -116,7 +116,7 @@ source %{ } } - bool Matcher::match_rule_supported_superword(int opcode, int vlen, BasicType bt) { + bool Matcher::match_rule_supported_auto_vectorization(int opcode, int vlen, BasicType bt) { if (UseSVE == 0) { // These operations are not profitable to be vectorized on NEON, because no direct // NEON instructions support them. But the match rule support for them is profitable for diff --git a/src/hotspot/cpu/aarch64/assembler_aarch64.cpp b/src/hotspot/cpu/aarch64/assembler_aarch64.cpp index afeb19e906e..c7b867a4207 100644 --- a/src/hotspot/cpu/aarch64/assembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/assembler_aarch64.cpp @@ -187,6 +187,26 @@ void Address::lea(MacroAssembler *as, Register r) const { zrf(Rd, 0); } +// This encoding is similar (but not quite identical) to the encoding used +// by literal ld/st. see JDK-8324123. +// PRFM does not support writeback or pre/post index. +void Assembler::prfm(const Address &adr, prfop pfop) { + Address::mode mode = adr.getMode(); + // PRFM does not support pre/post index + guarantee((mode != Address::pre) && (mode != Address::post), "prfm does not support pre/post indexing"); + if (mode == Address::literal) { + starti; + f(0b11, 31, 30), f(0b011, 29, 27), f(0b000, 26, 24); + f(pfop, 4, 0); + int64_t offset = (adr.target() - pc()) >> 2; + sf(offset, 23, 5); + } else { + assert((mode == Address::base_plus_offset) + || (mode == Address::base_plus_offset_reg), "must be base_plus_offset/base_plus_offset_reg"); + ld_st2(as_Register(pfop), adr, 0b11, 0b10); + } +} + // An "all-purpose" add/subtract immediate, per ARM documentation: // A "programmer-friendly" assembler may accept a negative immediate // between -(2^24 -1) and -1 inclusive, causing it to convert a diff --git a/src/hotspot/cpu/aarch64/assembler_aarch64.hpp b/src/hotspot/cpu/aarch64/assembler_aarch64.hpp index 187c1209303..9c05c36706d 100644 --- a/src/hotspot/cpu/aarch64/assembler_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/assembler_aarch64.hpp @@ -797,6 +797,8 @@ class Assembler : public AbstractAssembler { void adrp(Register Rd, const Address &dest, uint64_t &offset) = delete; + void prfm(const Address &adr, prfop pfop = PLDL1KEEP); + #undef INSN void add_sub_immediate(Instruction_aarch64 ¤t_insn, Register Rd, Register Rn, @@ -1574,17 +1576,6 @@ class Assembler : public AbstractAssembler { #undef INSN -#define INSN(NAME, size, op) \ - void NAME(const Address &adr, prfop pfop = PLDL1KEEP) { \ - ld_st2(as_Register(pfop), adr, size, op); \ - } - - INSN(prfm, 0b11, 0b10); // FIXME: PRFM should not be used with - // writeback modes, but the assembler - // doesn't enfore that. - -#undef INSN - #define INSN(NAME, size, op) \ void NAME(FloatRegister Rt, const Address &adr) { \ ld_st2(as_Register(Rt), adr, size, op, 1); \ diff --git a/src/hotspot/cpu/aarch64/c1_LIRGenerator_aarch64.cpp b/src/hotspot/cpu/aarch64/c1_LIRGenerator_aarch64.cpp index 952e060ed21..fd31d2dde5b 100644 --- a/src/hotspot/cpu/aarch64/c1_LIRGenerator_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/c1_LIRGenerator_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -831,18 +831,12 @@ void LIRGenerator::do_LibmIntrinsic(Intrinsic* x) { } break; case vmIntrinsics::_dlog: - if (StubRoutines::dlog() != nullptr) { - __ call_runtime_leaf(StubRoutines::dlog(), getThreadTemp(), result_reg, cc->args()); - } else { - __ call_runtime_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dlog), getThreadTemp(), result_reg, cc->args()); - } + // Math.log intrinsic is not implemented on AArch64 (see JDK-8210858), + // but we can still call the shared runtime. + __ call_runtime_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dlog), getThreadTemp(), result_reg, cc->args()); break; case vmIntrinsics::_dlog10: - if (StubRoutines::dlog10() != nullptr) { - __ call_runtime_leaf(StubRoutines::dlog10(), getThreadTemp(), result_reg, cc->args()); - } else { - __ call_runtime_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dlog10), getThreadTemp(), result_reg, cc->args()); - } + __ call_runtime_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dlog10), getThreadTemp(), result_reg, cc->args()); break; case vmIntrinsics::_dpow: if (StubRoutines::dpow() != nullptr) { diff --git a/src/hotspot/cpu/aarch64/globals_aarch64.hpp b/src/hotspot/cpu/aarch64/globals_aarch64.hpp index b26eaa4bfcd..73fdbb387e5 100644 --- a/src/hotspot/cpu/aarch64/globals_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/globals_aarch64.hpp @@ -127,6 +127,8 @@ define_pd_global(intx, InlineSmallCode, 1000); range(1, 99) \ product(ccstr, UseBranchProtection, "none", \ "Branch Protection to use: none, standard, pac-ret") \ + product(bool, AlwaysMergeDMB, false, DIAGNOSTIC, \ + "Always merge DMB instructions in code emission") \ // end of ARCH_FLAGS diff --git a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp index a3c560b28d3..1c1e2e28942 100644 --- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp @@ -2066,14 +2066,21 @@ void MacroAssembler::membar(Membar_mask_bits order_constraint) { address last = code()->last_insn(); if (last != nullptr && nativeInstruction_at(last)->is_Membar() && prev == last) { NativeMembar *bar = NativeMembar_at(prev); - // We are merging two memory barrier instructions. On AArch64 we - // can do this simply by ORing them together. - bar->set_kind(bar->get_kind() | order_constraint); - BLOCK_COMMENT("merged membar"); - } else { - code()->set_last_insn(pc()); - dmb(Assembler::barrier(order_constraint)); + // Don't promote DMB ST|DMB LD to DMB (a full barrier) because + // doing so would introduce a StoreLoad which the caller did not + // intend + if (AlwaysMergeDMB || bar->get_kind() == order_constraint + || bar->get_kind() == AnyAny + || order_constraint == AnyAny) { + // We are merging two memory barrier instructions. On AArch64 we + // can do this simply by ORing them together. + bar->set_kind(bar->get_kind() | order_constraint); + BLOCK_COMMENT("merged membar"); + return; + } } + code()->set_last_insn(pc()); + dmb(Assembler::barrier(order_constraint)); } bool MacroAssembler::try_merge_ldst(Register rt, const Address &adr, size_t size_in_bytes, bool is_store) { diff --git a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp index 84931c409cf..d8915e24492 100644 --- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp @@ -1425,11 +1425,6 @@ class MacroAssembler: public Assembler { FloatRegister vtmp2, FloatRegister vtmp3, FloatRegister vtmp4, FloatRegister vtmp5); - void fast_log(FloatRegister vtmp0, FloatRegister vtmp1, FloatRegister vtmp2, - FloatRegister vtmp3, FloatRegister vtmp4, FloatRegister vtmp5, - FloatRegister tmpC1, FloatRegister tmpC2, FloatRegister tmpC3, - FloatRegister tmpC4, Register tmp1, Register tmp2, - Register tmp3, Register tmp4, Register tmp5); void generate_dsin_dcos(bool isCos, address npio2_hw, address two_over_pi, address pio2, address dsin_coef, address dcos_coef); private: diff --git a/src/hotspot/cpu/aarch64/macroAssembler_aarch64_log.cpp b/src/hotspot/cpu/aarch64/macroAssembler_aarch64_log.cpp deleted file mode 100644 index 45772ff1afd..00000000000 --- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64_log.cpp +++ /dev/null @@ -1,366 +0,0 @@ -/* Copyright (c) 2018, Cavium. All rights reserved. (By BELLSOFT) - * Copyright (c) 2016, 2021, Intel Corporation. All rights reserved. - * Intel Math Library (LIBM) Source Code - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "precompiled.hpp" -#include "asm/assembler.hpp" -#include "asm/assembler.inline.hpp" -#include "macroAssembler_aarch64.hpp" - -// Algorithm idea is taken from x86 hotspot intrinsic and adapted for AARCH64. -// -// For mathematical background please refer to the following literature: -// -// Tang, Ping-Tak Peter. -// Table-driven implementation of the logarithm function -// in IEEE floating-point arithmetic. -// ACM Transactions on Mathematical Software (TOMS) 16, no. 4, 1990: 378-400. - -/******************************************************************************/ -// ALGORITHM DESCRIPTION - LOG() -// --------------------- -// -// x=2^k * mx, mx in [1,2) -// -// Get B~1/mx based on the output of frecpe instruction (B0) -// B = int((B0*2^7+0.5))/2^7 -// -// Reduced argument: r=B*mx-1.0 (computed accurately in high and low parts) -// -// Result: k*log(2) - log(B) + p(r) if |x-1| >= small value (2^-6) and -// p(r) is a degree 7 polynomial -// -log(B) read from data table (high, low parts) -// Result is formed from high and low parts -// -// Special cases: -// 1. log(NaN) = quiet NaN -// 2. log(+INF) = that INF -// 3. log(0) = -INF -// 4. log(1) = +0 -// 5. log(x) = NaN if x < -0, including -INF -// -/******************************************************************************/ - -// Table with p(r) polynomial coefficients -// and table representation of logarithm values (hi and low parts) -ATTRIBUTE_ALIGNED(64) juint _L_tbl[] = -{ - // coefficients of p(r) polynomial: - // _coeff[] - 0x00000000UL, 0xbfd00000UL, // C1_0 = -0.25 - 0x92492492UL, 0x3fc24924UL, // C1_1 = 0.14285714285714285 - 0x55555555UL, 0x3fd55555UL, // C2_0 = 0.3333333333333333 - 0x3d6fb175UL, 0xbfc5555eUL, // C2_1 = -0.16666772842235003 - 0x00000000UL, 0xbfe00000UL, // C3_0 = -0.5 - 0x9999999aUL, 0x3fc99999UL, // C3_1 = 0.2 - // _log2[] - 0xfefa3800UL, 0x3fa62e42UL, // C4_0 = 0.043321698784993146 - 0x93c76730UL, 0x3ceef357UL, // C4_1 = 3.436201886692732e-15 - // _L_tbl[] with logarithm values (hi and low parts) - 0xfefa3800UL, 0x3fe62e42UL, 0x93c76730UL, 0x3d2ef357UL, 0xaa241800UL, - 0x3fe5ee82UL, 0x0cda46beUL, 0x3d220238UL, 0x5c364800UL, 0x3fe5af40UL, - 0xac10c9fbUL, 0x3d2dfa63UL, 0x26bb8c00UL, 0x3fe5707aUL, 0xff3303ddUL, - 0x3d09980bUL, 0x26867800UL, 0x3fe5322eUL, 0x5d257531UL, 0x3d05ccc4UL, - 0x835a5000UL, 0x3fe4f45aUL, 0x6d93b8fbUL, 0xbd2e6c51UL, 0x6f970c00UL, - 0x3fe4b6fdUL, 0xed4c541cUL, 0x3cef7115UL, 0x27e8a400UL, 0x3fe47a15UL, - 0xf94d60aaUL, 0xbd22cb6aUL, 0xf2f92400UL, 0x3fe43d9fUL, 0x481051f7UL, - 0xbcfd984fUL, 0x2125cc00UL, 0x3fe4019cUL, 0x30f0c74cUL, 0xbd26ce79UL, - 0x0c36c000UL, 0x3fe3c608UL, 0x7cfe13c2UL, 0xbd02b736UL, 0x17197800UL, - 0x3fe38ae2UL, 0xbb5569a4UL, 0xbd218b7aUL, 0xad9d8c00UL, 0x3fe35028UL, - 0x9527e6acUL, 0x3d10b83fUL, 0x44340800UL, 0x3fe315daUL, 0xc5a0ed9cUL, - 0xbd274e93UL, 0x57b0e000UL, 0x3fe2dbf5UL, 0x07b9dc11UL, 0xbd17a6e5UL, - 0x6d0ec000UL, 0x3fe2a278UL, 0xe797882dUL, 0x3d206d2bUL, 0x1134dc00UL, - 0x3fe26962UL, 0x05226250UL, 0xbd0b61f1UL, 0xd8bebc00UL, 0x3fe230b0UL, - 0x6e48667bUL, 0x3d12fc06UL, 0x5fc61800UL, 0x3fe1f863UL, 0xc9fe81d3UL, - 0xbd2a7242UL, 0x49ae6000UL, 0x3fe1c078UL, 0xed70e667UL, 0x3cccacdeUL, - 0x40f23c00UL, 0x3fe188eeUL, 0xf8ab4650UL, 0x3d14cc4eUL, 0xf6f29800UL, - 0x3fe151c3UL, 0xa293ae49UL, 0xbd2edd97UL, 0x23c75c00UL, 0x3fe11af8UL, - 0xbb9ddcb2UL, 0xbd258647UL, 0x8611cc00UL, 0x3fe0e489UL, 0x07801742UL, - 0x3d1c2998UL, 0xe2d05400UL, 0x3fe0ae76UL, 0x887e7e27UL, 0x3d1f486bUL, - 0x0533c400UL, 0x3fe078bfUL, 0x41edf5fdUL, 0x3d268122UL, 0xbe760400UL, - 0x3fe04360UL, 0xe79539e0UL, 0xbd04c45fUL, 0xe5b20800UL, 0x3fe00e5aUL, - 0xb1727b1cUL, 0xbd053ba3UL, 0xaf7a4800UL, 0x3fdfb358UL, 0x3c164935UL, - 0x3d0085faUL, 0xee031800UL, 0x3fdf4aa7UL, 0x6f014a8bUL, 0x3d12cde5UL, - 0x56b41000UL, 0x3fdee2a1UL, 0x5a470251UL, 0x3d2f27f4UL, 0xc3ddb000UL, - 0x3fde7b42UL, 0x5372bd08UL, 0xbd246550UL, 0x1a272800UL, 0x3fde148aUL, - 0x07322938UL, 0xbd1326b2UL, 0x484c9800UL, 0x3fddae75UL, 0x60dc616aUL, - 0xbd1ea42dUL, 0x46def800UL, 0x3fdd4902UL, 0xe9a767a8UL, 0x3d235bafUL, - 0x18064800UL, 0x3fdce42fUL, 0x3ec7a6b0UL, 0xbd0797c3UL, 0xc7455800UL, - 0x3fdc7ff9UL, 0xc15249aeUL, 0xbd29b6ddUL, 0x693fa000UL, 0x3fdc1c60UL, - 0x7fe8e180UL, 0x3d2cec80UL, 0x1b80e000UL, 0x3fdbb961UL, 0xf40a666dUL, - 0x3d27d85bUL, 0x04462800UL, 0x3fdb56faUL, 0x2d841995UL, 0x3d109525UL, - 0x5248d000UL, 0x3fdaf529UL, 0x52774458UL, 0xbd217cc5UL, 0x3c8ad800UL, - 0x3fda93edUL, 0xbea77a5dUL, 0x3d1e36f2UL, 0x0224f800UL, 0x3fda3344UL, - 0x7f9d79f5UL, 0x3d23c645UL, 0xea15f000UL, 0x3fd9d32bUL, 0x10d0c0b0UL, - 0xbd26279eUL, 0x43135800UL, 0x3fd973a3UL, 0xa502d9f0UL, 0xbd152313UL, - 0x635bf800UL, 0x3fd914a8UL, 0x2ee6307dUL, 0xbd1766b5UL, 0xa88b3000UL, - 0x3fd8b639UL, 0xe5e70470UL, 0xbd205ae1UL, 0x776dc800UL, 0x3fd85855UL, - 0x3333778aUL, 0x3d2fd56fUL, 0x3bd81800UL, 0x3fd7fafaUL, 0xc812566aUL, - 0xbd272090UL, 0x687cf800UL, 0x3fd79e26UL, 0x2efd1778UL, 0x3d29ec7dUL, - 0x76c67800UL, 0x3fd741d8UL, 0x49dc60b3UL, 0x3d2d8b09UL, 0xe6af1800UL, - 0x3fd6e60eUL, 0x7c222d87UL, 0x3d172165UL, 0x3e9c6800UL, 0x3fd68ac8UL, - 0x2756eba0UL, 0x3d20a0d3UL, 0x0b3ab000UL, 0x3fd63003UL, 0xe731ae00UL, - 0xbd2db623UL, 0xdf596000UL, 0x3fd5d5bdUL, 0x08a465dcUL, 0xbd0a0b2aUL, - 0x53c8d000UL, 0x3fd57bf7UL, 0xee5d40efUL, 0x3d1fadedUL, 0x0738a000UL, - 0x3fd522aeUL, 0x8164c759UL, 0x3d2ebe70UL, 0x9e173000UL, 0x3fd4c9e0UL, - 0x1b0ad8a4UL, 0xbd2e2089UL, 0xc271c800UL, 0x3fd4718dUL, 0x0967d675UL, - 0xbd2f27ceUL, 0x23d5e800UL, 0x3fd419b4UL, 0xec90e09dUL, 0x3d08e436UL, - 0x77333000UL, 0x3fd3c252UL, 0xb606bd5cUL, 0x3d183b54UL, 0x76be1000UL, - 0x3fd36b67UL, 0xb0f177c8UL, 0x3d116ecdUL, 0xe1d36000UL, 0x3fd314f1UL, - 0xd3213cb8UL, 0xbd28e27aUL, 0x7cdc9000UL, 0x3fd2bef0UL, 0x4a5004f4UL, - 0x3d2a9cfaUL, 0x1134d800UL, 0x3fd26962UL, 0xdf5bb3b6UL, 0x3d2c93c1UL, - 0x6d0eb800UL, 0x3fd21445UL, 0xba46baeaUL, 0x3d0a87deUL, 0x635a6800UL, - 0x3fd1bf99UL, 0x5147bdb7UL, 0x3d2ca6edUL, 0xcbacf800UL, 0x3fd16b5cUL, - 0xf7a51681UL, 0x3d2b9acdUL, 0x8227e800UL, 0x3fd1178eUL, 0x63a5f01cUL, - 0xbd2c210eUL, 0x67616000UL, 0x3fd0c42dUL, 0x163ceae9UL, 0x3d27188bUL, - 0x604d5800UL, 0x3fd07138UL, 0x16ed4e91UL, 0x3cf89cdbUL, 0x5626c800UL, - 0x3fd01eaeUL, 0x1485e94aUL, 0xbd16f08cUL, 0x6cb3b000UL, 0x3fcf991cUL, - 0xca0cdf30UL, 0x3d1bcbecUL, 0xe4dd0000UL, 0x3fcef5adUL, 0x65bb8e11UL, - 0xbcca2115UL, 0xffe71000UL, 0x3fce530eUL, 0x6041f430UL, 0x3cc21227UL, - 0xb0d49000UL, 0x3fcdb13dUL, 0xf715b035UL, 0xbd2aff2aUL, 0xf2656000UL, - 0x3fcd1037UL, 0x75b6f6e4UL, 0xbd084a7eUL, 0xc6f01000UL, 0x3fcc6ffbUL, - 0xc5962bd2UL, 0xbcf1ec72UL, 0x383be000UL, 0x3fcbd087UL, 0x595412b6UL, - 0xbd2d4bc4UL, 0x575bd000UL, 0x3fcb31d8UL, 0x4eace1aaUL, 0xbd0c358dUL, - 0x3c8ae000UL, 0x3fca93edUL, 0x50562169UL, 0xbd287243UL, 0x07089000UL, - 0x3fc9f6c4UL, 0x6865817aUL, 0x3d29904dUL, 0xdcf70000UL, 0x3fc95a5aUL, - 0x58a0ff6fUL, 0x3d07f228UL, 0xeb390000UL, 0x3fc8beafUL, 0xaae92cd1UL, - 0xbd073d54UL, 0x6551a000UL, 0x3fc823c1UL, 0x9a631e83UL, 0x3d1e0ddbUL, - 0x85445000UL, 0x3fc7898dUL, 0x70914305UL, 0xbd1c6610UL, 0x8b757000UL, - 0x3fc6f012UL, 0xe59c21e1UL, 0xbd25118dUL, 0xbe8c1000UL, 0x3fc6574eUL, - 0x2c3c2e78UL, 0x3d19cf8bUL, 0x6b544000UL, 0x3fc5bf40UL, 0xeb68981cUL, - 0xbd127023UL, 0xe4a1b000UL, 0x3fc527e5UL, 0xe5697dc7UL, 0x3d2633e8UL, - 0x8333b000UL, 0x3fc4913dUL, 0x54fdb678UL, 0x3d258379UL, 0xa5993000UL, - 0x3fc3fb45UL, 0x7e6a354dUL, 0xbd2cd1d8UL, 0xb0159000UL, 0x3fc365fcUL, - 0x234b7289UL, 0x3cc62fa8UL, 0x0c868000UL, 0x3fc2d161UL, 0xcb81b4a1UL, - 0x3d039d6cUL, 0x2a49c000UL, 0x3fc23d71UL, 0x8fd3df5cUL, 0x3d100d23UL, - 0x7e23f000UL, 0x3fc1aa2bUL, 0x44389934UL, 0x3d2ca78eUL, 0x8227e000UL, - 0x3fc1178eUL, 0xce2d07f2UL, 0x3d21ef78UL, 0xb59e4000UL, 0x3fc08598UL, - 0x7009902cUL, 0xbd27e5ddUL, 0x39dbe000UL, 0x3fbfe891UL, 0x4fa10afdUL, - 0xbd2534d6UL, 0x830a2000UL, 0x3fbec739UL, 0xafe645e0UL, 0xbd2dc068UL, - 0x63844000UL, 0x3fbda727UL, 0x1fa71733UL, 0x3d1a8940UL, 0x01bc4000UL, - 0x3fbc8858UL, 0xc65aacd3UL, 0x3d2646d1UL, 0x8dad6000UL, 0x3fbb6ac8UL, - 0x2bf768e5UL, 0xbd139080UL, 0x40b1c000UL, 0x3fba4e76UL, 0xb94407c8UL, - 0xbd0e42b6UL, 0x5d594000UL, 0x3fb9335eUL, 0x3abd47daUL, 0x3d23115cUL, - 0x2f40e000UL, 0x3fb8197eUL, 0xf96ffdf7UL, 0x3d0f80dcUL, 0x0aeac000UL, - 0x3fb700d3UL, 0xa99ded32UL, 0x3cec1e8dUL, 0x4d97a000UL, 0x3fb5e95aUL, - 0x3c5d1d1eUL, 0xbd2c6906UL, 0x5d208000UL, 0x3fb4d311UL, 0x82f4e1efUL, - 0xbcf53a25UL, 0xa7d1e000UL, 0x3fb3bdf5UL, 0xa5db4ed7UL, 0x3d2cc85eUL, - 0xa4472000UL, 0x3fb2aa04UL, 0xae9c697dUL, 0xbd20b6e8UL, 0xd1466000UL, - 0x3fb1973bUL, 0x560d9e9bUL, 0xbd25325dUL, 0xb59e4000UL, 0x3fb08598UL, - 0x7009902cUL, 0xbd17e5ddUL, 0xc006c000UL, 0x3faeea31UL, 0x4fc93b7bUL, - 0xbd0e113eUL, 0xcdddc000UL, 0x3faccb73UL, 0x47d82807UL, 0xbd1a68f2UL, - 0xd0fb0000UL, 0x3faaaef2UL, 0x353bb42eUL, 0x3d20fc1aUL, 0x149fc000UL, - 0x3fa894aaUL, 0xd05a267dUL, 0xbd197995UL, 0xf2d4c000UL, 0x3fa67c94UL, - 0xec19afa2UL, 0xbd029efbUL, 0xd42e0000UL, 0x3fa466aeUL, 0x75bdfd28UL, - 0xbd2c1673UL, 0x2f8d0000UL, 0x3fa252f3UL, 0xe021b67bUL, 0x3d283e9aUL, - 0x89e74000UL, 0x3fa0415dUL, 0x5cf1d753UL, 0x3d0111c0UL, 0xec148000UL, - 0x3f9c63d2UL, 0x3f9eb2f3UL, 0x3d2578c6UL, 0x28c90000UL, 0x3f984925UL, - 0x325a0c34UL, 0xbd2aa0baUL, 0x25980000UL, 0x3f9432a9UL, 0x928637feUL, - 0x3d098139UL, 0x58938000UL, 0x3f902056UL, 0x06e2f7d2UL, 0xbd23dc5bUL, - 0xa3890000UL, 0x3f882448UL, 0xda74f640UL, 0xbd275577UL, 0x75890000UL, - 0x3f801015UL, 0x999d2be8UL, 0xbd10c76bUL, 0x59580000UL, 0x3f700805UL, - 0xcb31c67bUL, 0x3d2166afUL, 0x00000000UL, 0x00000000UL, 0x00000000UL, - 0x80000000UL -}; - -// BEGIN dlog PSEUDO CODE: -// double dlog(double X) { -// // p(r) polynomial coefficients initialized from _L_tbl table -// double C1_0 = _L_tbl[0]; -// double C1_1 = _L_tbl[1]; -// double C2_0 = _L_tbl[2]; -// double C2_1 = _L_tbl[3]; -// double C3_0 = _L_tbl[4]; -// double C3_1 = _L_tbl[5]; -// double C4_0 = _L_tbl[6]; -// double C4_1 = _L_tbl[7]; -// // NOTE: operations with coefficients above are mostly vectorized in assembly -// // Check corner cases first -// if (X == 1.0d || AS_LONG_BITS(X) + 0x0010000000000000 <= 0x0010000000000000) { -// // NOTE: AS_LONG_BITS(X) + 0x0010000000000000 <= 0x0010000000000000 means -// // that X < 0 or X >= 0x7FF0000000000000 (0x7FF* is NaN or INF) -// if (X < 0 || X is NaN) return NaN; -// if (X == 1.0d) return 0.0d; -// if (X == 0.0d) return -INFINITY; -// if (X is INFINITY) return INFINITY; -// } -// // double representation is 2^exponent * mantissa -// // split X into two multipliers: 2^exponent and 1.0 * mantissa -// // pseudo function: zeroExponent(X) return value of X with exponent == 0 -// float vtmp5 = 1/(float)(zeroExponent(X)); // reciprocal estimate -// // pseudo function: HI16(X) returns high 16 bits of double value -// int hiWord = HI16(X); -// double vtmp1 = (double) 0x77F0 << 48 | mantissa(X); -// hiWord -= 16; -// if (AS_LONG_BITS(hiWord) > 0x8000) { -// // SMALL_VALUE branch -// vtmp0 = vtmp1 = vtmp0 * AS_DOUBLE_BITS(0x47F0000000000000); -// hiWord = HI16(vtmp1); -// vtmp0 = AS_DOUBLE_BITS(AS_LONG_BITS(vtmp0) |= 0x3FF0000000000000); -// vtmp5 = (double) (1/(float)vtmp0); -// vtmp1 <<= 12; -// vtmp1 >>= 12; -// } -// // MAIN branch -// double vtmp3 = AS_LONG_BITS(vtmp1) & 0xffffe00000000000; // hi part -// int intB0 = AS_INT_BITS(vtmp5) + 0x8000; -// double vtmp0 = AS_DOUBLE_BITS(0xffffe00000000000 & (intB0<<29)); -// int index = (intB0 >> 16) && 0xFF; -// double hiTableValue = _L_tbl[8+index]; // vtmp2[0] -// double lowTableValue = _L_tbl[16+index]; // vtmp2[1] -// vtmp5 = AS_DOUBLE_BITS(hiWord & 0x7FF0 - 0x3FE0); // 0x3FE = 1023 << 4 -// vtmp1 -= vtmp3; // low part -// vtmp3 = vtmp3*vtmp0 - 1.0; -// hiTableValue += C4_0 * vtmp5; -// lowTableValue += C4_1 * vtmp5; -// double r = vtmp1 * vtmp0 + vtmp3; // r = B*mx-1.0, computed in hi and low parts -// vtmp0 = hiTableValue + r; -// hiTableValue -= vtmp0; -// double r2 = r*r; -// double r3 = r2*r; -// double p7 = C3_0*r2 + C2_0*r3 + C1_0*r2*r2 + C3_1*r3*r2 + C2_1*r3*r3 -// + C1_1*r3*r2*r2; // degree 7 polynomial -// return p7 + (vtmp0 + ((r + hiTableValue) + lowTableValue)); -// } -// -// END dlog PSEUDO CODE - - -// Generate log(X). X passed in register v0. Return log(X) into v0. -// Generator parameters: 10 temporary FPU registers and temporary general -// purpose registers -void MacroAssembler::fast_log(FloatRegister vtmp0, FloatRegister vtmp1, - FloatRegister vtmp2, FloatRegister vtmp3, - FloatRegister vtmp4, FloatRegister vtmp5, - FloatRegister C1, FloatRegister C2, - FloatRegister C3, FloatRegister C4, - Register tmp1, Register tmp2, Register tmp3, - Register tmp4, Register tmp5) { - Label DONE, CHECK_CORNER_CASES, SMALL_VALUE, MAIN, - CHECKED_CORNER_CASES, RETURN_MINF_OR_NAN; - const int64_t INF_OR_NAN_PREFIX = 0x7FF0; - const int64_t MINF_OR_MNAN_PREFIX = 0xFFF0; - const int64_t ONE_PREFIX = 0x3FF0; - movz(tmp2, ONE_PREFIX, 48); - movz(tmp4, 0x0010, 48); - fmovd(rscratch1, v0); // rscratch1 = AS_LONG_BITS(X) - lea(rscratch2, ExternalAddress((address)_L_tbl)); - movz(tmp5, 0x7F); - add(tmp1, rscratch1, tmp4); - cmp(tmp2, rscratch1); - lsr(tmp3, rscratch1, 29); - ccmp(tmp1, tmp4, 0b1101 /* LE */, NE); - bfm(tmp3, tmp5, 41, 8); - fmovs(vtmp5, tmp3); - // Load coefficients from table. All coefficients are organized to be - // in specific order, because load below will load it in vectors to be used - // later in vector instructions. Load will be performed in parallel while - // branches are taken. C1 will contain vector of {C1_0, C1_1}, C2 = - // {C2_0, C2_1}, C3 = {C3_0, C3_1}, C4 = {C4_0, C4_1} - ld1(C1, C2, C3, C4, T2D, post(rscratch2, 64)); - br(LE, CHECK_CORNER_CASES); - bind(CHECKED_CORNER_CASES); - // all corner cases are handled - frecpe(vtmp5, vtmp5, S); // vtmp5 ~= 1/vtmp5 - lsr(tmp2, rscratch1, 48); - movz(tmp4, 0x77f0, 48); - fmovd(vtmp4, 1.0); - movz(tmp1, INF_OR_NAN_PREFIX, 48); - bfm(tmp4, rscratch1, 0, 51); // tmp4 = 0x77F0 << 48 | mantissa(X) - // vtmp1 = AS_DOUBLE_BITS(0x77F0 << 48 | mantissa(X)) == mx - fmovd(vtmp1, tmp4); - subw(tmp2, tmp2, 16); - subs(zr, tmp2, 0x8000); - br(GE, SMALL_VALUE); - bind(MAIN); - fmovs(tmp3, vtmp5); // int intB0 = AS_INT_BITS(B); - mov(tmp5, 0x3FE0); - uint64_t mask = UCONST64(0xffffe00000000000); - mov(rscratch1, mask); - andr(tmp2, tmp2, tmp1, LSR, 48); // hiWord & 0x7FF0 - sub(tmp2, tmp2, tmp5); // tmp2 = hiWord & 0x7FF0 - 0x3FE0 - scvtfwd(vtmp5, tmp2); // vtmp5 = (double)tmp2; - addw(tmp3, tmp3, 0x8000); // tmp3 = B - andr(tmp4, tmp4, rscratch1); // tmp4 == hi_part(mx) - andr(rscratch1, rscratch1, tmp3, LSL, 29); // rscratch1 = hi_part(B) - ubfm(tmp3, tmp3, 16, 23); // int index = (intB0 >> 16) && 0xFF - ldrq(vtmp2, Address(rscratch2, tmp3, Address::lsl(4))); // vtmp2 = _L_tbl[index] - // AS_LONG_BITS(vtmp1) & 0xffffe00000000000 // hi_part(mx) - fmovd(vtmp3, tmp4); - fmovd(vtmp0, rscratch1); // vtmp0 = hi_part(B) - fsubd(vtmp1, vtmp1, vtmp3); // vtmp1 -= vtmp3; // low_part(mx) - fnmsub(vtmp3, vtmp3, vtmp0, vtmp4); // vtmp3 = vtmp3*vtmp0 - vtmp4 - fmlavs(vtmp2, T2D, C4, vtmp5, 0); // vtmp2 += {C4} * vtmp5 - // vtmp1 = r = vtmp1 * vtmp0 + vtmp3 == low_part(mx) * hi_part(B) + (hi_part(mx)*hi_part(B) - 1.0) - fmaddd(vtmp1, vtmp1, vtmp0, vtmp3); - ins(vtmp5, D, vtmp2, 0, 1); // vtmp5 = vtmp2[1]; - faddd(vtmp0, vtmp2, vtmp1); // vtmp0 = vtmp2 + vtmp1 - fmlavs(C3, T2D, C2, vtmp1, 0); // {C3} += {C2}*vtmp1 - fsubd(vtmp2, vtmp2, vtmp0); // vtmp2 -= vtmp0 - fmuld(vtmp3, vtmp1, vtmp1); // vtmp3 = vtmp1*vtmp1 - faddd(C4, vtmp1, vtmp2); // C4[0] = vtmp1 + vtmp2 - fmlavs(C3, T2D, C1, vtmp3, 0); // {C3} += {C1}*vtmp3 - faddd(C4, C4, vtmp5); // C4 += vtmp5 - fmuld(vtmp4, vtmp3, vtmp1); // vtmp4 = vtmp3*vtmp1 - faddd(vtmp0, vtmp0, C4); // vtmp0 += C4 - fmlavs(C3, T2D, vtmp4, C3, 1); // {C3} += {vtmp4}*C3[1] - fmaddd(vtmp0, C3, vtmp3, vtmp0); // vtmp0 = C3 * vtmp3 + vtmp0 - ret(lr); - - block_comment("if (AS_LONG_BITS(hiWord) > 0x8000)"); { - bind(SMALL_VALUE); - movz(tmp2, 0x47F0, 48); - fmovd(vtmp1, tmp2); - fmuld(vtmp0, vtmp1, v0); - fmovd(vtmp1, vtmp0); - umov(tmp2, vtmp1, S, 3); - orr(vtmp0, T16B, vtmp0, vtmp4); - ushr(vtmp5, T2D, vtmp0, 27); - ushr(vtmp5, T4S, vtmp5, 2); - frecpe(vtmp5, vtmp5, S); - shl(vtmp1, T2D, vtmp1, 12); - ushr(vtmp1, T2D, vtmp1, 12); - b(MAIN); - } - - block_comment("Corner cases"); { - bind(RETURN_MINF_OR_NAN); - movz(tmp1, MINF_OR_MNAN_PREFIX, 48); - orr(rscratch1, rscratch1, tmp1); - fmovd(v0, rscratch1); - ret(lr); - bind(CHECK_CORNER_CASES); - movz(tmp1, INF_OR_NAN_PREFIX, 48); - cmp(rscratch1, zr); - br(LE, RETURN_MINF_OR_NAN); - cmp(rscratch1, tmp1); - br(GE, DONE); - cmp(rscratch1, tmp2); - br(NE, CHECKED_CORNER_CASES); - fmovd(v0, 0.0); - } - bind(DONE); - ret(lr); -} diff --git a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp index 97ca90ac764..dfdfa194c4e 100644 --- a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp @@ -5327,19 +5327,6 @@ class StubGenerator: public StubCodeGenerator { return start; } - address generate_dlog() { - __ align(CodeEntryAlignment); - StubCodeMark mark(this, "StubRoutines", "dlog"); - address entry = __ pc(); - FloatRegister vtmp0 = v0, vtmp1 = v1, vtmp2 = v2, vtmp3 = v3, vtmp4 = v4, - vtmp5 = v5, tmpC1 = v16, tmpC2 = v17, tmpC3 = v18, tmpC4 = v19; - Register tmp1 = r0, tmp2 = r1, tmp3 = r2, tmp4 = r3, tmp5 = r4; - __ fast_log(vtmp0, vtmp1, vtmp2, vtmp3, vtmp4, vtmp5, tmpC1, tmpC2, tmpC3, - tmpC4, tmp1, tmp2, tmp3, tmp4, tmp5); - return entry; - } - - // code for comparing 16 characters of strings with Latin1 and Utf16 encoding void compare_string_16_x_LU(Register tmpL, Register tmpU, Label &DIFF1, Label &DIFF2) { @@ -8333,11 +8320,6 @@ class StubGenerator: public StubCodeGenerator { StubRoutines::_updateBytesCRC32C = generate_updateBytesCRC32C(); } - // Disabled until JDK-8210858 is fixed - // if (vmIntrinsics::is_intrinsic_available(vmIntrinsics::_dlog)) { - // StubRoutines::_dlog = generate_dlog(); - // } - if (vmIntrinsics::is_intrinsic_available(vmIntrinsics::_dsin)) { StubRoutines::_dsin = generate_dsin_dcos(/* isCos = */ false); } diff --git a/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp b/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp index f7fe2f7dec8..baf8ba59476 100644 --- a/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp @@ -183,6 +183,9 @@ void VM_Version::initialize() { if (FLAG_IS_DEFAULT(UseSIMDForMemoryOps)) { FLAG_SET_DEFAULT(UseSIMDForMemoryOps, true); } + if (FLAG_IS_DEFAULT(AlwaysMergeDMB)) { + FLAG_SET_DEFAULT(AlwaysMergeDMB, true); + } } // Cortex A53 diff --git a/src/hotspot/cpu/arm/arm.ad b/src/hotspot/cpu/arm/arm.ad index e31ad91613a..01457aee7b6 100644 --- a/src/hotspot/cpu/arm/arm.ad +++ b/src/hotspot/cpu/arm/arm.ad @@ -1002,7 +1002,7 @@ bool Matcher::match_rule_supported(int opcode) { return true; // Per default match rules are supported. } -bool Matcher::match_rule_supported_superword(int opcode, int vlen, BasicType bt) { +bool Matcher::match_rule_supported_auto_vectorization(int opcode, int vlen, BasicType bt) { return match_rule_supported_vector(opcode, vlen, bt); } @@ -1074,7 +1074,7 @@ int Matcher::min_vector_size(const BasicType bt) { return 8/type2aelembytes(bt); } -int Matcher::superword_max_vector_size(const BasicType bt) { +int Matcher::max_vector_size_auto_vectorization(const BasicType bt) { return Matcher::max_vector_size(bt); } diff --git a/src/hotspot/cpu/ppc/ppc.ad b/src/hotspot/cpu/ppc/ppc.ad index be37ff1785b..c43f19be740 100644 --- a/src/hotspot/cpu/ppc/ppc.ad +++ b/src/hotspot/cpu/ppc/ppc.ad @@ -1,5 +1,5 @@ // -// Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. // Copyright (c) 2012, 2023 SAP SE. All rights reserved. // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. // @@ -2173,7 +2173,7 @@ bool Matcher::match_rule_supported(int opcode) { return true; // Per default match rules are supported. } -bool Matcher::match_rule_supported_superword(int opcode, int vlen, BasicType bt) { +bool Matcher::match_rule_supported_auto_vectorization(int opcode, int vlen, BasicType bt) { return match_rule_supported_vector(opcode, vlen, bt); } @@ -2242,7 +2242,7 @@ int Matcher::min_vector_size(const BasicType bt) { return max_vector_size(bt); // Same as max. } -int Matcher::superword_max_vector_size(const BasicType bt) { +int Matcher::max_vector_size_auto_vectorization(const BasicType bt) { return Matcher::max_vector_size(bt); } diff --git a/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp b/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp index 84ecfc4f934..86353aefb36 100644 --- a/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp +++ b/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2013, 2023 SAP SE. All rights reserved. + * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024 SAP SE. 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 @@ -3803,16 +3803,15 @@ void TemplateTable::_new() { __ sldi(Roffset, Rindex, LogBytesPerWord); __ load_resolved_klass_at_offset(Rcpool, Roffset, RinstanceKlass); - // Make sure klass is fully initialized and get instance_size. - __ lbz(Rscratch, in_bytes(InstanceKlass::init_state_offset()), RinstanceKlass); + // Make sure klass is initialized. + assert(VM_Version::supports_fast_class_init_checks(), "Optimization requires support for fast class initialization checks"); + __ clinit_barrier(RinstanceKlass, R16_thread, nullptr /*L_fast_path*/, &Lslow_case); + __ lwz(Rinstance_size, in_bytes(Klass::layout_helper_offset()), RinstanceKlass); - __ cmpdi(CCR1, Rscratch, InstanceKlass::fully_initialized); // Make sure klass does not have has_finalizer, or is abstract, or interface or java/lang/Class. __ andi_(R0, Rinstance_size, Klass::_lh_instance_slow_path_bit); // slow path bit equals 0? - - __ crnand(CCR0, Assembler::equal, CCR1, Assembler::equal); // slow path bit set or not fully initialized? - __ beq(CCR0, Lslow_case); + __ bne(CCR0, Lslow_case); // -------------------------------------------------------------------------- // Fast case: diff --git a/src/hotspot/cpu/riscv/riscv.ad b/src/hotspot/cpu/riscv/riscv.ad index 458e381b3b0..493606aa0b1 100644 --- a/src/hotspot/cpu/riscv/riscv.ad +++ b/src/hotspot/cpu/riscv/riscv.ad @@ -1,5 +1,5 @@ // -// Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. // Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved. // Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved. // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -2017,7 +2017,7 @@ int Matcher::min_vector_size(const BasicType bt) { return MIN2(size, max_size); } -int Matcher::superword_max_vector_size(const BasicType bt) { +int Matcher::max_vector_size_auto_vectorization(const BasicType bt) { return Matcher::max_vector_size(bt); } diff --git a/src/hotspot/cpu/riscv/riscv_v.ad b/src/hotspot/cpu/riscv/riscv_v.ad index c163325fc81..802a68caba7 100644 --- a/src/hotspot/cpu/riscv/riscv_v.ad +++ b/src/hotspot/cpu/riscv/riscv_v.ad @@ -1,5 +1,5 @@ // -// Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. // Copyright (c) 2020, 2023, Arm Limited. All rights reserved. // Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved. // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -46,7 +46,7 @@ source %{ } } - bool Matcher::match_rule_supported_superword(int opcode, int vlen, BasicType bt) { + bool Matcher::match_rule_supported_auto_vectorization(int opcode, int vlen, BasicType bt) { return match_rule_supported_vector(opcode, vlen, bt); } diff --git a/src/hotspot/cpu/riscv/templateTable_riscv.cpp b/src/hotspot/cpu/riscv/templateTable_riscv.cpp index 73b4d1e28cc..58f57f32b2f 100644 --- a/src/hotspot/cpu/riscv/templateTable_riscv.cpp +++ b/src/hotspot/cpu/riscv/templateTable_riscv.cpp @@ -3547,11 +3547,10 @@ void TemplateTable::_new() { // get InstanceKlass __ load_resolved_klass_at_offset(x14, x13, x14, t0); - // make sure klass is initialized & doesn't have finalizer - // make sure klass is fully initialized - __ lbu(t0, Address(x14, InstanceKlass::init_state_offset())); - __ sub(t1, t0, (u1)InstanceKlass::fully_initialized); - __ bnez(t1, slow_case); + // make sure klass is initialized + assert(VM_Version::supports_fast_class_init_checks(), + "Optimization requires support for fast class initialization checks"); + __ clinit_barrier(x14, t0, nullptr /*L_fast_path*/, &slow_case); // get instance_size in InstanceKlass (scaled to a count of bytes) __ lwu(x13, Address(x14, Klass::layout_helper_offset())); diff --git a/src/hotspot/cpu/s390/s390.ad b/src/hotspot/cpu/s390/s390.ad index 9f4e182a9e4..c28c5e4399a 100644 --- a/src/hotspot/cpu/s390/s390.ad +++ b/src/hotspot/cpu/s390/s390.ad @@ -1,5 +1,5 @@ // -// Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. // Copyright (c) 2017, 2022 SAP SE. All rights reserved. // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. // @@ -1513,7 +1513,7 @@ bool Matcher::match_rule_supported(int opcode) { return true; // Per default match rules are supported. } -bool Matcher::match_rule_supported_superword(int opcode, int vlen, BasicType bt) { +bool Matcher::match_rule_supported_auto_vectorization(int opcode, int vlen, BasicType bt) { return match_rule_supported_vector(opcode, vlen, bt); } @@ -1574,7 +1574,7 @@ int Matcher::min_vector_size(const BasicType bt) { return max_vector_size(bt); // Same as max. } -int Matcher::superword_max_vector_size(const BasicType bt) { +int Matcher::max_vector_size_auto_vectorization(const BasicType bt) { return Matcher::max_vector_size(bt); } diff --git a/src/hotspot/cpu/s390/templateTable_s390.cpp b/src/hotspot/cpu/s390/templateTable_s390.cpp index 1ab60959c0d..02b9405ad31 100644 --- a/src/hotspot/cpu/s390/templateTable_s390.cpp +++ b/src/hotspot/cpu/s390/templateTable_s390.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2016, 2023 SAP SE. All rights reserved. + * Copyright (c) 2016, 2024 SAP SE. 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 @@ -3914,20 +3914,15 @@ void TemplateTable::_new() { __ z_cli(0, tmp, JVM_CONSTANT_Class); __ z_brne(slow_case); - __ z_sllg(offset, offset, LogBytesPerWord); // Convert to to offset. + __ z_sllg(offset, offset, LogBytesPerWord); // Convert to offset. // Get InstanceKlass. Register iklass = cpool; __ load_resolved_klass_at_offset(cpool, offset, iklass); - // Make sure klass is initialized & doesn't have finalizer. - // Make sure klass is fully initialized. - const int state_offset = in_bytes(InstanceKlass::init_state_offset()); - if (Immediate::is_uimm12(state_offset)) { - __ z_cli(state_offset, iklass, InstanceKlass::fully_initialized); - } else { - __ z_cliy(state_offset, iklass, InstanceKlass::fully_initialized); - } - __ z_brne(slow_case); + // make sure klass is initialized + assert(VM_Version::supports_fast_class_init_checks(), + "Optimization requires support for fast class initialization checks"); + __ clinit_barrier(iklass, Z_thread, nullptr /*L_fast_path*/, &slow_case); // Get instance_size in InstanceKlass (scaled to a count of bytes). Register Rsize = offset; diff --git a/src/hotspot/cpu/x86/assembler_x86.cpp b/src/hotspot/cpu/x86/assembler_x86.cpp index 63d6ec9b00f..9482537d84f 100644 --- a/src/hotspot/cpu/x86/assembler_x86.cpp +++ b/src/hotspot/cpu/x86/assembler_x86.cpp @@ -1089,7 +1089,7 @@ address Assembler::locate_operand(address inst, WhichOperand which) { break; case 0x62: // EVEX_4bytes - assert(VM_Version::supports_evex(), "shouldn't have EVEX prefix"); + assert(VM_Version::cpu_supports_evex(), "shouldn't have EVEX prefix"); assert(ip == inst+1, "no prefixes allowed"); // no EVEX collisions, all instructions that have 0x62 opcodes // have EVEX versions and are subopcodes of 0x66 diff --git a/src/hotspot/cpu/x86/macroAssembler_x86.cpp b/src/hotspot/cpu/x86/macroAssembler_x86.cpp index 88296656485..ba4b089c7aa 100644 --- a/src/hotspot/cpu/x86/macroAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/macroAssembler_x86.cpp @@ -2568,7 +2568,9 @@ void MacroAssembler::movptr(Register dst, Address src) { // src should NEVER be a real pointer. Use AddressLiteral for true pointers void MacroAssembler::movptr(Register dst, intptr_t src) { #ifdef _LP64 - if (is_simm32(src)) { + if (is_uimm32(src)) { + movl(dst, checked_cast(src)); + } else if (is_simm32(src)) { movq(dst, checked_cast(src)); } else { mov64(dst, src); diff --git a/src/hotspot/cpu/x86/vm_version_x86.cpp b/src/hotspot/cpu/x86/vm_version_x86.cpp index df1ea6edd30..2412c053106 100644 --- a/src/hotspot/cpu/x86/vm_version_x86.cpp +++ b/src/hotspot/cpu/x86/vm_version_x86.cpp @@ -809,7 +809,8 @@ void VM_Version::get_processor_features() { _stepping = cpu_stepping(); if (cpu_family() > 4) { // it supports CPUID - _features = feature_flags(); + _features = feature_flags(); // These can be changed by VM settings + _cpu_features = _features; // Preserve features // Logical processors are only available on P4s and above, // and only if hyperthreading is available. _logical_processors_per_package = logical_processor_count(); diff --git a/src/hotspot/cpu/x86/vm_version_x86.hpp b/src/hotspot/cpu/x86/vm_version_x86.hpp index e521a6ee3bc..cfc16acabc6 100644 --- a/src/hotspot/cpu/x86/vm_version_x86.hpp +++ b/src/hotspot/cpu/x86/vm_version_x86.hpp @@ -640,7 +640,7 @@ class VM_Version : public Abstract_VM_Version { } // - // Feature identification + // Feature identification which can be affected by VM settings // static bool supports_cpuid() { return _features != 0; } static bool supports_cmov() { return (_features & CPU_CMOV) != 0; } @@ -703,6 +703,11 @@ class VM_Version : public Abstract_VM_Version { static bool supports_cet_ss() { return (_features & CPU_CET_SS) != 0; } static bool supports_cet_ibt() { return (_features & CPU_CET_IBT) != 0; } + // + // Feature identification not affected by VM flags + // + static bool cpu_supports_evex() { return (_cpu_features & CPU_AVX512F) != 0; } + // Intel features static bool is_intel_family_core() { return is_intel() && extended_cpu_family() == CPU_FAMILY_INTEL_CORE; } diff --git a/src/hotspot/cpu/x86/x86.ad b/src/hotspot/cpu/x86/x86.ad index 671d3f7d212..99bf789f5b2 100644 --- a/src/hotspot/cpu/x86/x86.ad +++ b/src/hotspot/cpu/x86/x86.ad @@ -1699,7 +1699,7 @@ static inline bool is_pop_count_instr_target(BasicType bt) { (is_non_subword_integral_type(bt) && VM_Version::supports_avx512_vpopcntdq()); } -bool Matcher::match_rule_supported_superword(int opcode, int vlen, BasicType bt) { +bool Matcher::match_rule_supported_auto_vectorization(int opcode, int vlen, BasicType bt) { return match_rule_supported_vector(opcode, vlen, bt); } @@ -2280,7 +2280,7 @@ int Matcher::min_vector_size(const BasicType bt) { return MIN2(size,max_size); } -int Matcher::superword_max_vector_size(const BasicType bt) { +int Matcher::max_vector_size_auto_vectorization(const BasicType bt) { // Limit the max vector size for auto vectorization to 256 bits (32 bytes) // by default on Cascade Lake if (VM_Version::is_default_intel_cascade_lake()) { diff --git a/src/hotspot/os/aix/os_aix.cpp b/src/hotspot/os/aix/os_aix.cpp index a4aa662744e..561ef77b18b 100644 --- a/src/hotspot/os/aix/os_aix.cpp +++ b/src/hotspot/os/aix/os_aix.cpp @@ -1886,6 +1886,10 @@ void os::pd_realign_memory(char *addr, size_t bytes, size_t alignment_hint) { void os::pd_free_memory(char *addr, size_t bytes, size_t alignment_hint) { } +size_t os::pd_pretouch_memory(void* first, void* last, size_t page_size) { + return page_size; +} + void os::numa_make_global(char *addr, size_t bytes) { } @@ -3027,4 +3031,3 @@ void os::print_memory_mappings(char* addr, size_t bytes, outputStream* st) {} void os::jfr_report_memory_info() {} #endif // INCLUDE_JFR - diff --git a/src/hotspot/os/bsd/os_bsd.cpp b/src/hotspot/os/bsd/os_bsd.cpp index 9baa3fe4b20..1f2094fba1f 100644 --- a/src/hotspot/os/bsd/os_bsd.cpp +++ b/src/hotspot/os/bsd/os_bsd.cpp @@ -1637,6 +1637,10 @@ void os::pd_free_memory(char *addr, size_t bytes, size_t alignment_hint) { ::madvise(addr, bytes, MADV_DONTNEED); } +size_t os::pd_pretouch_memory(void* first, void* last, size_t page_size) { + return page_size; +} + void os::numa_make_global(char *addr, size_t bytes) { } diff --git a/src/hotspot/os/linux/globals_linux.hpp b/src/hotspot/os/linux/globals_linux.hpp index 15a0f7e97c9..068fd53b62d 100644 --- a/src/hotspot/os/linux/globals_linux.hpp +++ b/src/hotspot/os/linux/globals_linux.hpp @@ -130,7 +130,9 @@ develop(bool, DelayThreadStartALot, false, \ "Artificially delay thread starts randomly for testing.") \ \ - + product(bool, UseMadvPopulateWrite, true, DIAGNOSTIC, \ + "Use MADV_POPULATE_WRITE in os::pd_pretouch_memory.") \ + \ // end of RUNTIME_OS_FLAGS diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index 04ddda597d9..e2bd55cd139 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -420,7 +420,7 @@ pid_t os::Linux::gettid() { julong os::Linux::host_swap() { struct sysinfo si; sysinfo(&si); - return (julong)si.totalswap; + return (julong)(si.totalswap * si.mem_unit); } // Most versions of linux have a bug where the number of processors are @@ -2985,6 +2985,15 @@ void os::pd_commit_memory_or_exit(char* addr, size_t size, bool exec, #define MADV_HUGEPAGE 14 #endif +// Define MADV_POPULATE_WRITE here so we can build HotSpot on old systems. +#define MADV_POPULATE_WRITE_value 23 +#ifndef MADV_POPULATE_WRITE + #define MADV_POPULATE_WRITE MADV_POPULATE_WRITE_value +#else + // Sanity-check our assumed default value if we build with a new enough libc. + static_assert(MADV_POPULATE_WRITE == MADV_POPULATE_WRITE_value); +#endif + // Note that the value for MAP_FIXED_NOREPLACE differs between architectures, but all architectures // supported by OpenJDK share the same flag value. #define MAP_FIXED_NOREPLACE_value 0x100000 @@ -3044,6 +3053,31 @@ void os::pd_free_memory(char *addr, size_t bytes, size_t alignment_hint) { } } +size_t os::pd_pretouch_memory(void* first, void* last, size_t page_size) { + const size_t len = pointer_delta(last, first, sizeof(char)) + page_size; + // Use madvise to pretouch on Linux when THP is used, and fallback to the + // common method if unsupported. THP can form right after madvise rather than + // being assembled later. + if (HugePages::thp_mode() == THPMode::always || UseTransparentHugePages) { + int err = 0; + if (UseMadvPopulateWrite && + ::madvise(first, len, MADV_POPULATE_WRITE) == -1) { + err = errno; + } + if (!UseMadvPopulateWrite || err == EINVAL) { // Not to use or not supported + // When using THP we need to always pre-touch using small pages as the + // OS will initially always use small pages. + return os::vm_page_size(); + } else if (err != 0) { + log_info(gc, os)("::madvise(" PTR_FORMAT ", " SIZE_FORMAT ", %d) failed; " + "error='%s' (errno=%d)", p2i(first), len, + MADV_POPULATE_WRITE, os::strerror(err), err); + } + return 0; + } + return page_size; +} + void os::numa_make_global(char *addr, size_t bytes) { Linux::numa_interleave_memory(addr, bytes); } @@ -4466,6 +4500,9 @@ void os::init(void) { check_pax(); + // Check the availability of MADV_POPULATE_WRITE. + FLAG_SET_DEFAULT(UseMadvPopulateWrite, (::madvise(0, 0, MADV_POPULATE_WRITE) == 0)); + os::Posix::init(); } diff --git a/src/hotspot/os/posix/os_posix.cpp b/src/hotspot/os/posix/os_posix.cpp index 6dc697a69ff..926045df259 100644 --- a/src/hotspot/os/posix/os_posix.cpp +++ b/src/hotspot/os/posix/os_posix.cpp @@ -753,11 +753,11 @@ void os::dll_unload(void *lib) { } jlong os::lseek(int fd, jlong offset, int whence) { - return (jlong) ::lseek(fd, offset, whence); + return (jlong) AIX_ONLY(::lseek64) NOT_AIX(::lseek)(fd, offset, whence); } int os::ftruncate(int fd, jlong length) { - return ::ftruncate(fd, length); + return AIX_ONLY(::ftruncate64) NOT_AIX(::ftruncate)(fd, length); } const char* os::get_current_directory(char *buf, size_t buflen) { diff --git a/src/hotspot/os/windows/os_windows.cpp b/src/hotspot/os/windows/os_windows.cpp index 1d1c3040526..c97630248ed 100644 --- a/src/hotspot/os/windows/os_windows.cpp +++ b/src/hotspot/os/windows/os_windows.cpp @@ -2469,9 +2469,9 @@ LONG Handle_IDiv_Exception(struct _EXCEPTION_POINTERS* exceptionInfo) { #elif defined(_M_AMD64) PCONTEXT ctx = exceptionInfo->ContextRecord; address pc = (address)ctx->Rip; - guarantee(pc[0] >= Assembler::REX && pc[0] <= Assembler::REX_WRXB && pc[1] == 0xF7 || pc[0] == 0xF7, + guarantee((pc[0] >= Assembler::REX && pc[0] <= Assembler::REX_WRXB && pc[1] == 0xF7) || pc[0] == 0xF7, "not an idiv opcode, pc[0] = 0x%x and pc[1] = 0x%x", pc[0], pc[1]); - guarantee(pc[0] >= Assembler::REX && pc[0] <= Assembler::REX_WRXB && (pc[2] & ~0x7) == 0xF8 || (pc[1] & ~0x7) == 0xF8, + guarantee((pc[0] >= Assembler::REX && pc[0] <= Assembler::REX_WRXB && (pc[2] & ~0x7) == 0xF8) || (pc[1] & ~0x7) == 0xF8, "cannot handle non-register operands, pc[0] = 0x%x, pc[1] = 0x%x and pc[2] = 0x%x", pc[0], pc[1], pc[2]); if (pc[0] == 0xF7) { // set correct result values and continue after idiv instruction @@ -3796,6 +3796,11 @@ bool os::unguard_memory(char* addr, size_t bytes) { void os::pd_realign_memory(char *addr, size_t bytes, size_t alignment_hint) { } void os::pd_free_memory(char *addr, size_t bytes, size_t alignment_hint) { } + +size_t os::pd_pretouch_memory(void* first, void* last, size_t page_size) { + return page_size; +} + void os::numa_make_global(char *addr, size_t bytes) { } void os::numa_make_local(char *addr, size_t bytes, int lgrp_hint) { } bool os::numa_topology_changed() { return false; } diff --git a/src/hotspot/os_cpu/linux_riscv/riscv_hwprobe.cpp b/src/hotspot/os_cpu/linux_riscv/riscv_hwprobe.cpp index b5f17810323..df4a2e347cc 100644 --- a/src/hotspot/os_cpu/linux_riscv/riscv_hwprobe.cpp +++ b/src/hotspot/os_cpu/linux_riscv/riscv_hwprobe.cpp @@ -49,7 +49,36 @@ #define RISCV_HWPROBE_EXT_ZBA (1 << 3) #define RISCV_HWPROBE_EXT_ZBB (1 << 4) #define RISCV_HWPROBE_EXT_ZBS (1 << 5) +#define RISCV_HWPROBE_EXT_ZICBOZ (1 << 6) +#define RISCV_HWPROBE_EXT_ZBC (1 << 7) +#define RISCV_HWPROBE_EXT_ZBKB (1 << 8) +#define RISCV_HWPROBE_EXT_ZBKC (1 << 9) +#define RISCV_HWPROBE_EXT_ZBKX (1 << 10) +#define RISCV_HWPROBE_EXT_ZKND (1 << 11) +#define RISCV_HWPROBE_EXT_ZKNE (1 << 12) +#define RISCV_HWPROBE_EXT_ZKNH (1 << 13) +#define RISCV_HWPROBE_EXT_ZKSED (1 << 14) +#define RISCV_HWPROBE_EXT_ZKSH (1 << 15) +#define RISCV_HWPROBE_EXT_ZKT (1 << 16) +#define RISCV_HWPROBE_EXT_ZVBB (1 << 17) +#define RISCV_HWPROBE_EXT_ZVBC (1 << 18) +#define RISCV_HWPROBE_EXT_ZVKB (1 << 19) +#define RISCV_HWPROBE_EXT_ZVKG (1 << 20) +#define RISCV_HWPROBE_EXT_ZVKNED (1 << 21) +#define RISCV_HWPROBE_EXT_ZVKNHA (1 << 22) +#define RISCV_HWPROBE_EXT_ZVKNHB (1 << 23) +#define RISCV_HWPROBE_EXT_ZVKSED (1 << 24) +#define RISCV_HWPROBE_EXT_ZVKSH (1 << 25) +#define RISCV_HWPROBE_EXT_ZVKT (1 << 26) #define RISCV_HWPROBE_EXT_ZFH (1 << 27) +#define RISCV_HWPROBE_EXT_ZFHMIN (1 << 28) +#define RISCV_HWPROBE_EXT_ZIHINTNTL (1 << 29) +#define RISCV_HWPROBE_EXT_ZVFH (1 << 30) +#define RISCV_HWPROBE_EXT_ZVFHMIN (1 << 31) +#define RISCV_HWPROBE_EXT_ZFA (1ULL << 32) +#define RISCV_HWPROBE_EXT_ZTSO (1ULL << 33) +#define RISCV_HWPROBE_EXT_ZACAS (1ULL << 34) +#define RISCV_HWPROBE_EXT_ZICOND (1ULL << 35) #define RISCV_HWPROBE_KEY_CPUPERF_0 5 #define RISCV_HWPROBE_MISALIGNED_UNKNOWN (0 << 0) diff --git a/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp b/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp index fdecb637c87..c7d61b33829 100644 --- a/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp +++ b/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp @@ -244,6 +244,8 @@ void VM_Version::rivos_features() { ext_Zfh.enable_feature(); + ext_Zacas.enable_feature(); + ext_Zicboz.enable_feature(); ext_Zicsr.enable_feature(); ext_Zifencei.enable_feature(); ext_Zic64b.enable_feature(); diff --git a/src/hotspot/share/asm/assembler.hpp b/src/hotspot/share/asm/assembler.hpp index 7b7dbd4ede7..a533b963844 100644 --- a/src/hotspot/share/asm/assembler.hpp +++ b/src/hotspot/share/asm/assembler.hpp @@ -359,6 +359,7 @@ class AbstractAssembler : public ResourceObj { } static bool is_uimm12(uint64_t x) { return is_uimm(x, 12); } + static bool is_uimm32(uint64_t x) { return is_uimm(x, 32); } // Accessors CodeSection* code_section() const { return _code_section; } diff --git a/src/hotspot/share/c1/c1_Canonicalizer.cpp b/src/hotspot/share/c1/c1_Canonicalizer.cpp index dab11d4f70e..0dbf29300d1 100644 --- a/src/hotspot/share/c1/c1_Canonicalizer.cpp +++ b/src/hotspot/share/c1/c1_Canonicalizer.cpp @@ -469,9 +469,11 @@ void Canonicalizer::do_CompareOp (CompareOp* x) { void Canonicalizer::do_IfOp(IfOp* x) { - // Caution: do not use do_Op2(x) here for now since - // we map the condition to the op for now! - move_const_to_right(x); + // Currently, Canonicalizer is only used by GraphBuilder, + // and IfOp is not created by GraphBuilder but only later + // when eliminating conditional expressions with CE_Eliminator, + // so this method will not be called. + ShouldNotReachHere(); } diff --git a/src/hotspot/share/ci/ciMethodData.cpp b/src/hotspot/share/ci/ciMethodData.cpp index dc7082c15ca..5abb342d031 100644 --- a/src/hotspot/share/ci/ciMethodData.cpp +++ b/src/hotspot/share/ci/ciMethodData.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, 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,6 +31,7 @@ #include "memory/allocation.inline.hpp" #include "memory/resourceArea.hpp" #include "oops/klass.inline.hpp" +#include "oops/methodData.inline.hpp" #include "runtime/deoptimization.hpp" #include "utilities/copy.hpp" @@ -87,8 +88,18 @@ class PrepareExtraDataClosure : public CleanExtraDataClosure { // Preparation finished iff all Methods* were already cached. return true; } - // Holding locks through safepoints is bad practice. - MutexUnlocker mu(_mdo->extra_data_lock()); + // We are currently holding the extra_data_lock and ensuring + // no safepoint breaks the lock. + _mdo->check_extra_data_locked(); + + // We now want to cache some method data. This could cause a safepoint. + // We temporarily release the lock and allow safepoints, and revert that + // at the end of the scope. This is safe, since we currently do not hold + // any extra_method_data: finish is called only after clean_extra_data, + // and the outer scope that first aquired the lock should not hold any + // extra_method_data while cleaning is performed, as the offsets can change. + MutexUnlocker mu(_mdo->extra_data_lock(), Mutex::_no_safepoint_check_flag); + for (int i = 0; i < _uncached_methods.length(); ++i) { if (has_safepointed()) { // The metadata in the growable array might contain stale @@ -123,7 +134,10 @@ void ciMethodData::prepare_metadata() { void ciMethodData::load_remaining_extra_data() { MethodData* mdo = get_MethodData(); - MutexLocker ml(mdo->extra_data_lock()); + + // Lock to read ProfileData, and ensure lock is not unintentionally broken by a safepoint + MutexLocker ml(mdo->extra_data_lock(), Mutex::_no_safepoint_check_flag); + // Deferred metadata cleaning due to concurrent class unloading. prepare_metadata(); // After metadata preparation, there is no stale metadata, @@ -562,6 +576,9 @@ void ciMethodData::set_argument_type(int bci, int i, ciKlass* k) { VM_ENTRY_MARK; MethodData* mdo = get_MethodData(); if (mdo != nullptr) { + // Lock to read ProfileData, and ensure lock is not broken by a safepoint + MutexLocker ml(mdo->extra_data_lock(), Mutex::_no_safepoint_check_flag); + ProfileData* data = mdo->bci_to_data(bci); if (data != nullptr) { if (data->is_CallTypeData()) { @@ -586,6 +603,9 @@ void ciMethodData::set_return_type(int bci, ciKlass* k) { VM_ENTRY_MARK; MethodData* mdo = get_MethodData(); if (mdo != nullptr) { + // Lock to read ProfileData, and ensure lock is not broken by a safepoint + MutexLocker ml(mdo->extra_data_lock(), Mutex::_no_safepoint_check_flag); + ProfileData* data = mdo->bci_to_data(bci); if (data != nullptr) { if (data->is_CallTypeData()) { diff --git a/src/hotspot/share/classfile/systemDictionary.cpp b/src/hotspot/share/classfile/systemDictionary.cpp index e635c825633..82c20a962ce 100644 --- a/src/hotspot/share/classfile/systemDictionary.cpp +++ b/src/hotspot/share/classfile/systemDictionary.cpp @@ -1111,14 +1111,13 @@ InstanceKlass* SystemDictionary::load_shared_lambda_proxy_class(InstanceKlass* i if (loaded_ik != nullptr) { assert(shared_nest_host->is_same_class_package(ik), "lambda proxy class and its nest host must be in the same package"); + // The lambda proxy class and its nest host have the same class loader and class loader data, + // as verified in SystemDictionaryShared::add_lambda_proxy_class() + assert(shared_nest_host->class_loader() == class_loader(), "mismatched class loader"); + assert(shared_nest_host->class_loader_data() == class_loader_data(class_loader), "mismatched class loader data"); + ik->set_nest_host(shared_nest_host); } - // The lambda proxy class and its nest host have the same class loader and class loader data, - // as verified in SystemDictionaryShared::add_lambda_proxy_class() - assert(shared_nest_host->class_loader() == class_loader(), "mismatched class loader"); - assert(shared_nest_host->class_loader_data() == class_loader_data(class_loader), "mismatched class loader data"); - ik->set_nest_host(shared_nest_host); - return loaded_ik; } diff --git a/src/hotspot/share/compiler/compilerDirectives.cpp b/src/hotspot/share/compiler/compilerDirectives.cpp index d7d4c5b60ed..a16e5f23ed9 100644 --- a/src/hotspot/share/compiler/compilerDirectives.cpp +++ b/src/hotspot/share/compiler/compilerDirectives.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, 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 @@ -32,6 +32,7 @@ #include "memory/allocation.inline.hpp" #include "memory/resourceArea.hpp" #include "opto/phasetype.hpp" +#include "opto/traceAutoVectorizationTag.hpp" #include "runtime/globals_extension.hpp" CompilerDirectives::CompilerDirectives() : _next(nullptr), _match(nullptr), _ref_count(0) { @@ -300,7 +301,8 @@ void DirectiveSet::init_control_intrinsic() { DirectiveSet::DirectiveSet(CompilerDirectives* d) : _inlinematchers(nullptr), _directive(d), - _ideal_phase_name_set(PHASE_NUM_TYPES, mtCompiler) + _ideal_phase_name_set(PHASE_NUM_TYPES, mtCompiler), + _trace_auto_vectorization_tags(TRACE_AUTO_VECTORIZATION_TAG_NUM, mtCompiler) { #define init_defaults_definition(name, type, dvalue, compiler) this->name##Option = dvalue; compilerdirectives_common_flags(init_defaults_definition) @@ -433,6 +435,16 @@ DirectiveSet* DirectiveSet::compilecommand_compatibility_init(const methodHandle // Parse PrintIdealPhaseName and create a lookup set #ifndef PRODUCT #ifdef COMPILER2 + if (!_modified[TraceAutoVectorizationIndex]) { + // Parse ccstr and create mask + ccstrlist option; + if (CompilerOracle::has_option_value(method, CompileCommand::TraceAutoVectorization, option)) { + TraceAutoVectorizationTagValidator validator(option, false); + if (validator.is_valid()) { + set.cloned()->set_trace_auto_vectorization_tags(validator.tags()); + } + } + } if (!_modified[PrintIdealPhaseIndex]) { // Parse ccstr and create set ccstrlist option; diff --git a/src/hotspot/share/compiler/compilerDirectives.hpp b/src/hotspot/share/compiler/compilerDirectives.hpp index 4c9b51724f9..747c8781817 100644 --- a/src/hotspot/share/compiler/compilerDirectives.hpp +++ b/src/hotspot/share/compiler/compilerDirectives.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, 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 @@ -87,10 +87,10 @@ NOT_PRODUCT(cflags(PrintIdeal, bool, PrintIdeal, PrintIdeal)) \ cflags(Vectorize, bool, false, Vectorize) \ cflags(CloneMapDebug, bool, false, CloneMapDebug) \ NOT_PRODUCT(cflags(IGVPrintLevel, intx, PrintIdealGraphLevel, IGVPrintLevel)) \ - cflags(VectorizeDebug, uintx, 0, VectorizeDebug) \ cflags(IncrementalInlineForceCleanup, bool, IncrementalInlineForceCleanup, IncrementalInlineForceCleanup) \ cflags(MaxNodeLimit, intx, MaxNodeLimit, MaxNodeLimit) #define compilerdirectives_c2_string_flags(cflags) \ +NOT_PRODUCT(cflags(TraceAutoVectorization, ccstrlist, "", TraceAutoVectorization)) \ NOT_PRODUCT(cflags(PrintIdealPhase, ccstrlist, "", PrintIdealPhase)) #else #define compilerdirectives_c2_other_flags(cflags) @@ -131,6 +131,7 @@ class DirectiveSet : public CHeapObj { CompilerDirectives* _directive; TriBoolArray<(size_t)vmIntrinsics::number_of_intrinsics(), int> _intrinsic_control_words; CHeapBitMap _ideal_phase_name_set; + CHeapBitMap _trace_auto_vectorization_tags; public: DirectiveSet(CompilerDirectives* directive); @@ -205,6 +206,12 @@ void set_##name(void* value) { \ bool should_print_phase(const CompilerPhaseType cpt) const { return _ideal_phase_name_set.at(cpt); }; + void set_trace_auto_vectorization_tags(const CHeapBitMap& tags) { + _trace_auto_vectorization_tags.set_from(tags); + }; + const CHeapBitMap& trace_auto_vectorization_tags() { + return _trace_auto_vectorization_tags; + }; void print_intx(outputStream* st, ccstr n, intx v, bool mod) { if (mod) { st->print("%s:" INTX_FORMAT " ", n, v); } } void print_uintx(outputStream* st, ccstr n, intx v, bool mod) { if (mod) { st->print("%s:" UINTX_FORMAT " ", n, v); } } diff --git a/src/hotspot/share/compiler/compilerOracle.cpp b/src/hotspot/share/compiler/compilerOracle.cpp index 66eea29fcc1..089fc5a4d99 100644 --- a/src/hotspot/share/compiler/compilerOracle.cpp +++ b/src/hotspot/share/compiler/compilerOracle.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, 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 @@ -35,6 +35,7 @@ #include "oops/method.inline.hpp" #include "oops/symbol.hpp" #include "opto/phasetype.hpp" +#include "opto/traceAutoVectorizationTag.hpp" #include "runtime/globals_extension.hpp" #include "runtime/handles.inline.hpp" #include "runtime/jniHandles.hpp" @@ -775,8 +776,14 @@ static void scan_value(enum OptionType type, char* line, int& total_bytes_read, jio_snprintf(errorbuf, buf_size, "Unrecognized intrinsic detected in %s: %s", option2name(option), validator.what()); } } -#ifndef PRODUCT - else if (option == CompileCommand::PrintIdealPhase) { +#if !defined(PRODUCT) && defined(COMPILER2) + else if (option == CompileCommand::TraceAutoVectorization) { + TraceAutoVectorizationTagValidator validator(value, true); + + if (!validator.is_valid()) { + jio_snprintf(errorbuf, buf_size, "Unrecognized tag name in %s: %s", option2name(option), validator.what()); + } + } else if (option == CompileCommand::PrintIdealPhase) { PhaseNameValidator validator(value); if (!validator.is_valid()) { diff --git a/src/hotspot/share/compiler/compilerOracle.hpp b/src/hotspot/share/compiler/compilerOracle.hpp index be1a270f3c9..192e292d35a 100644 --- a/src/hotspot/share/compiler/compilerOracle.hpp +++ b/src/hotspot/share/compiler/compilerOracle.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, 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 @@ -86,8 +86,8 @@ NOT_PRODUCT(option(TraceEscapeAnalysis, "TraceEscapeAnalysis", Bool)) \ NOT_PRODUCT(option(PrintIdeal, "PrintIdeal", Bool)) \ NOT_PRODUCT(option(PrintIdealPhase, "PrintIdealPhase", Ccstrlist)) \ NOT_PRODUCT(option(IGVPrintLevel, "IGVPrintLevel", Intx)) \ +NOT_PRODUCT(option(TraceAutoVectorization, "TraceAutoVectorization", Ccstrlist)) \ option(Vectorize, "Vectorize", Bool) \ - option(VectorizeDebug, "VectorizeDebug", Uintx) \ option(CloneMapDebug, "CloneMapDebug", Bool) \ option(IncrementalInlineForceCleanup, "IncrementalInlineForceCleanup", Bool) \ option(MaxNodeLimit, "MaxNodeLimit", Intx) \ diff --git a/src/hotspot/share/compiler/directivesParser.cpp b/src/hotspot/share/compiler/directivesParser.cpp index 60955615133..55014900283 100644 --- a/src/hotspot/share/compiler/directivesParser.cpp +++ b/src/hotspot/share/compiler/directivesParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, 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 @@ -28,6 +28,7 @@ #include "memory/allocation.inline.hpp" #include "memory/resourceArea.hpp" #include "opto/phasetype.hpp" +#include "opto/traceAutoVectorizationTag.hpp" #include "runtime/os.hpp" #include @@ -335,6 +336,17 @@ bool DirectivesParser::set_option_flag(JSON_TYPE t, JSON_VAL* v, const key* opti if (!valid) { error(VALUE_ERROR, "Unrecognized intrinsic detected in DisableIntrinsic: %s", validator.what()); } + } +#if !defined(PRODUCT) && defined(COMPILER2) + else if (strncmp(option_key->name, "TraceAutoVectorization", 22) == 0) { + TraceAutoVectorizationTagValidator validator(s, false); + + valid = validator.is_valid(); + if (valid) { + set->set_trace_auto_vectorization_tags(validator.tags()); + } else { + error(VALUE_ERROR, "Unrecognized tag name detected in TraceAutoVectorization: %s", validator.what()); + } } else if (strncmp(option_key->name, "PrintIdealPhase", 15) == 0) { PhaseNameValidator validator(s); @@ -345,6 +357,7 @@ bool DirectivesParser::set_option_flag(JSON_TYPE t, JSON_VAL* v, const key* opti error(VALUE_ERROR, "Unrecognized phase name detected in PrintIdealPhase: %s", validator.what()); } } +#endif if (!valid) { FREE_C_HEAP_ARRAY(char, s); diff --git a/src/hotspot/share/gc/g1/g1BarrierSet.cpp b/src/hotspot/share/gc/g1/g1BarrierSet.cpp index 3f2b27c2d06..c2bc7bf5425 100644 --- a/src/hotspot/share/gc/g1/g1BarrierSet.cpp +++ b/src/hotspot/share/gc/g1/g1BarrierSet.cpp @@ -27,6 +27,7 @@ #include "gc/g1/g1BarrierSetAssembler.hpp" #include "gc/g1/g1CardTable.inline.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" +#include "gc/g1/g1RegionPinCache.inline.hpp" #include "gc/g1/g1SATBMarkQueueSet.hpp" #include "gc/g1/g1ThreadLocalData.hpp" #include "gc/g1/heapRegion.hpp" @@ -171,4 +172,8 @@ void G1BarrierSet::on_thread_detach(Thread* thread) { qset.flush_queue(queue); qset.record_detached_refinement_stats(queue.refinement_stats()); } + { + G1RegionPinCache& cache = G1ThreadLocalData::pin_count_cache(thread); + cache.flush(); + } } diff --git a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp index 7a630c27f79..10e5b1d8b58 100644 --- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp +++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, 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 @@ -59,6 +59,7 @@ #include "gc/g1/g1PeriodicGCTask.hpp" #include "gc/g1/g1Policy.hpp" #include "gc/g1/g1RedirtyCardsQueue.hpp" +#include "gc/g1/g1RegionPinCache.inline.hpp" #include "gc/g1/g1RegionToSpaceMapper.hpp" #include "gc/g1/g1RemSet.hpp" #include "gc/g1/g1RootClosures.hpp" @@ -2471,6 +2472,12 @@ void G1CollectedHeap::retire_tlabs() { ensure_parsability(true); } +void G1CollectedHeap::flush_region_pin_cache() { + for (JavaThreadIteratorWithHandle jtiwh; JavaThread *thread = jtiwh.next(); ) { + G1ThreadLocalData::pin_count_cache(thread).flush(); + } +} + void G1CollectedHeap::do_collection_pause_at_safepoint_helper() { ResourceMark rm; diff --git a/src/hotspot/share/gc/g1/g1CollectedHeap.hpp b/src/hotspot/share/gc/g1/g1CollectedHeap.hpp index 58ac36a734f..4245fb1b0cb 100644 --- a/src/hotspot/share/gc/g1/g1CollectedHeap.hpp +++ b/src/hotspot/share/gc/g1/g1CollectedHeap.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, 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 @@ -775,6 +775,10 @@ class G1CollectedHeap : public CollectedHeap { void retire_tlabs(); + // Update all region's pin counts from the per-thread caches and resets them. + // Must be called before any decision based on pin counts. + void flush_region_pin_cache(); + void expand_heap_after_young_collection(); // Update object copying statistics. void record_obj_copy_mem_stats(); diff --git a/src/hotspot/share/gc/g1/g1CollectedHeap.inline.hpp b/src/hotspot/share/gc/g1/g1CollectedHeap.inline.hpp index 7b81a93abe1..537b6863fb9 100644 --- a/src/hotspot/share/gc/g1/g1CollectedHeap.inline.hpp +++ b/src/hotspot/share/gc/g1/g1CollectedHeap.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, 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 @@ -32,6 +32,7 @@ #include "gc/g1/g1ConcurrentMark.inline.hpp" #include "gc/g1/g1EvacFailureRegions.hpp" #include "gc/g1/g1Policy.hpp" +#include "gc/g1/g1RegionPinCache.inline.hpp" #include "gc/g1/g1RemSet.hpp" #include "gc/g1/heapRegion.inline.hpp" #include "gc/g1/heapRegionManager.inline.hpp" @@ -266,15 +267,17 @@ inline void G1CollectedHeap::pin_object(JavaThread* thread, oop obj) { assert(obj != nullptr, "obj must not be null"); assert(!is_gc_active(), "must not pin objects during a GC"); assert(obj->is_typeArray(), "must be typeArray"); - HeapRegion *r = heap_region_containing(obj); - r->increment_pinned_object_count(); + + uint obj_region_idx = heap_region_containing(obj)->hrm_index(); + G1ThreadLocalData::pin_count_cache(thread).inc_count(obj_region_idx); } inline void G1CollectedHeap::unpin_object(JavaThread* thread, oop obj) { assert(obj != nullptr, "obj must not be null"); assert(!is_gc_active(), "must not unpin objects during a GC"); - HeapRegion *r = heap_region_containing(obj); - r->decrement_pinned_object_count(); + + uint obj_region_idx = heap_region_containing(obj)->hrm_index(); + G1ThreadLocalData::pin_count_cache(thread).dec_count(obj_region_idx); } inline bool G1CollectedHeap::is_obj_dead(const oop obj) const { diff --git a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp index 533817f9724..cb7f90b0847 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, 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 diff --git a/src/hotspot/share/gc/g1/g1FullCollector.cpp b/src/hotspot/share/gc/g1/g1FullCollector.cpp index 7f8b4221cab..430d6f32788 100644 --- a/src/hotspot/share/gc/g1/g1FullCollector.cpp +++ b/src/hotspot/share/gc/g1/g1FullCollector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -191,6 +191,7 @@ void G1FullCollector::prepare_collection() { _heap->gc_prologue(true); _heap->retire_tlabs(); + _heap->flush_region_pin_cache(); _heap->prepare_heap_for_full_collection(); PrepareRegionsClosure cl(this); diff --git a/src/hotspot/share/gc/g1/g1RegionPinCache.hpp b/src/hotspot/share/gc/g1/g1RegionPinCache.hpp new file mode 100644 index 00000000000..6df1c1793c2 --- /dev/null +++ b/src/hotspot/share/gc/g1/g1RegionPinCache.hpp @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2024, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_GC_G1_G1REGIONPINCACHE_HPP +#define SHARE_GC_G1_G1REGIONPINCACHE_HPP + +#include "gc/g1/heapRegion.hpp" +#include "memory/allocation.hpp" +#include "utilities/globalDefinitions.hpp" + +// Holds (caches) the pending pinned object count adjustment for the region +// _region_idx on a per thread basis. +// Keeping such a cache avoids the expensive atomic operations when updating the +// pin count for the very common case that the application pins and unpins the +// same object without any interleaving by a garbage collection or pinning/unpinning +// to an object in another region. +class G1RegionPinCache : public StackObj { + uint _region_idx; + size_t _count; + + void flush_and_set(uint new_region_idx, size_t new_count); + +public: + G1RegionPinCache() : _region_idx(G1_NO_HRM_INDEX), _count(0) { } + +#ifdef ASSERT + size_t count() const { return _count; } +#endif + + void inc_count(uint region_idx); + void dec_count(uint region_idx); + + void flush(); +}; + +#endif /* SHARE_GC_G1_G1REGIONPINCACHE_HPP */ diff --git a/src/hotspot/share/gc/g1/g1RegionPinCache.inline.hpp b/src/hotspot/share/gc/g1/g1RegionPinCache.inline.hpp new file mode 100644 index 00000000000..7df81d208f1 --- /dev/null +++ b/src/hotspot/share/gc/g1/g1RegionPinCache.inline.hpp @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_GC_G1_G1REGIONPINCACHE_INLINE_HPP +#define SHARE_GC_G1_G1REGIONPINCACHE_INLINE_HPP + +#include "gc/g1/g1RegionPinCache.hpp" + +#include "gc/g1/g1CollectedHeap.inline.hpp" + +inline void G1RegionPinCache::inc_count(uint region_idx) { + if (region_idx == _region_idx) { + ++_count; + } else { + flush_and_set(region_idx, (size_t)1); + } +} + +inline void G1RegionPinCache::dec_count(uint region_idx) { + if (region_idx == _region_idx) { + --_count; + } else { + flush_and_set(region_idx, ~(size_t)0); + } +} + +inline void G1RegionPinCache::flush_and_set(uint new_region_idx, size_t new_count) { + if (_count != 0) { + G1CollectedHeap::heap()->region_at(_region_idx)->add_pinned_object_count(_count); + } + _region_idx = new_region_idx; + _count = new_count; +} + +inline void G1RegionPinCache::flush() { + flush_and_set(G1_NO_HRM_INDEX, 0); +} + +#endif /* SHARE_GC_G1_G1REGIONPINCACHE_INLINE_HPP */ diff --git a/src/hotspot/share/gc/g1/g1ThreadLocalData.hpp b/src/hotspot/share/gc/g1/g1ThreadLocalData.hpp index e17a8c7960a..d0dcb59d7f0 100644 --- a/src/hotspot/share/gc/g1/g1ThreadLocalData.hpp +++ b/src/hotspot/share/gc/g1/g1ThreadLocalData.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, 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 @@ -26,6 +26,7 @@ #include "gc/g1/g1BarrierSet.hpp" #include "gc/g1/g1DirtyCardQueue.hpp" +#include "gc/g1/g1RegionPinCache.hpp" #include "gc/shared/gc_globals.hpp" #include "gc/shared/satbMarkQueue.hpp" #include "runtime/javaThread.hpp" @@ -37,9 +38,15 @@ class G1ThreadLocalData { SATBMarkQueue _satb_mark_queue; G1DirtyCardQueue _dirty_card_queue; + // Per-thread cache of pinned object count to reduce atomic operation traffic + // due to region pinning. Holds the last region where the mutator pinned an + // object and the number of pin operations since the last change of the region. + G1RegionPinCache _pin_cache; + G1ThreadLocalData() : _satb_mark_queue(&G1BarrierSet::satb_mark_queue_set()), - _dirty_card_queue(&G1BarrierSet::dirty_card_queue_set()) {} + _dirty_card_queue(&G1BarrierSet::dirty_card_queue_set()), + _pin_cache() {} static G1ThreadLocalData* data(Thread* thread) { assert(UseG1GC, "Sanity"); @@ -90,6 +97,10 @@ class G1ThreadLocalData { static ByteSize dirty_card_queue_buffer_offset() { return dirty_card_queue_offset() + G1DirtyCardQueue::byte_offset_of_buf(); } + + static G1RegionPinCache& pin_count_cache(Thread* thread) { + return data(thread)->_pin_cache; + } }; #endif // SHARE_GC_G1_G1THREADLOCALDATA_HPP diff --git a/src/hotspot/share/gc/g1/g1YoungCollector.cpp b/src/hotspot/share/gc/g1/g1YoungCollector.cpp index b52bfdfbb08..4fa3b928763 100644 --- a/src/hotspot/share/gc/g1/g1YoungCollector.cpp +++ b/src/hotspot/share/gc/g1/g1YoungCollector.cpp @@ -41,6 +41,7 @@ #include "gc/g1/g1ParScanThreadState.inline.hpp" #include "gc/g1/g1Policy.hpp" #include "gc/g1/g1RedirtyCardsQueue.hpp" +#include "gc/g1/g1RegionPinCache.inline.hpp" #include "gc/g1/g1RemSet.hpp" #include "gc/g1/g1RootProcessor.hpp" #include "gc/g1/g1Trace.hpp" diff --git a/src/hotspot/share/gc/g1/g1YoungGCPreEvacuateTasks.cpp b/src/hotspot/share/gc/g1/g1YoungGCPreEvacuateTasks.cpp index d3a6436e432..d7460623669 100644 --- a/src/hotspot/share/gc/g1/g1YoungGCPreEvacuateTasks.cpp +++ b/src/hotspot/share/gc/g1/g1YoungGCPreEvacuateTasks.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, 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 @@ -28,6 +28,8 @@ #include "gc/g1/g1ConcurrentRefineStats.hpp" #include "gc/g1/g1DirtyCardQueue.hpp" #include "gc/g1/g1YoungGCPreEvacuateTasks.hpp" +#include "gc/g1/g1RegionPinCache.inline.hpp" +#include "gc/g1/g1ThreadLocalData.hpp" #include "gc/shared/barrierSet.inline.hpp" #include "gc/shared/threadLocalAllocBuffer.inline.hpp" #include "memory/allocation.inline.hpp" @@ -57,12 +59,15 @@ class G1PreEvacuateCollectionSetBatchTask::JavaThreadRetireTLABAndFlushLogs : pu assert(thread->is_Java_thread(), "must be"); // Flushes deferred card marks, so must precede concatenating logs. BarrierSet::barrier_set()->make_parsable((JavaThread*)thread); + // Retire TLABs. if (UseTLAB) { thread->tlab().retire(&_tlab_stats); } - + // Concatenate logs. G1DirtyCardQueueSet& qset = G1BarrierSet::dirty_card_queue_set(); _refinement_stats += qset.concatenate_log_and_stats(thread); + // Flush region pin count cache. + G1ThreadLocalData::pin_count_cache(thread).flush(); } }; @@ -132,6 +137,8 @@ class G1PreEvacuateCollectionSetBatchTask::NonJavaThreadFlushLogs : public G1Abs void do_thread(Thread* thread) override { G1DirtyCardQueueSet& qset = G1BarrierSet::dirty_card_queue_set(); _refinement_stats += qset.concatenate_log_and_stats(thread); + + assert(G1ThreadLocalData::pin_count_cache(thread).count() == 0, "NonJava thread has pinned Java objects"); } } _tc; diff --git a/src/hotspot/share/gc/g1/heapRegion.hpp b/src/hotspot/share/gc/g1/heapRegion.hpp index 725433215c4..85f4a9e5f9f 100644 --- a/src/hotspot/share/gc/g1/heapRegion.hpp +++ b/src/hotspot/share/gc/g1/heapRegion.hpp @@ -302,8 +302,9 @@ class HeapRegion : public CHeapObj { static uint LogOfHRGrainBytes; static uint LogCardsPerRegion; - inline void increment_pinned_object_count(); - inline void decrement_pinned_object_count(); + // Atomically adjust the pinned object count by the given value. Value must not + // be zero. + inline void add_pinned_object_count(size_t value); static size_t GrainBytes; static size_t GrainWords; diff --git a/src/hotspot/share/gc/g1/heapRegion.inline.hpp b/src/hotspot/share/gc/g1/heapRegion.inline.hpp index 4a42b922182..608cc2025a2 100644 --- a/src/hotspot/share/gc/g1/heapRegion.inline.hpp +++ b/src/hotspot/share/gc/g1/heapRegion.inline.hpp @@ -553,12 +553,10 @@ inline void HeapRegion::record_surv_words_in_group(size_t words_survived) { _surv_rate_group->record_surviving_words(age, words_survived); } -inline void HeapRegion::increment_pinned_object_count() { - Atomic::add(&_pinned_object_count, (size_t)1, memory_order_relaxed); -} - -inline void HeapRegion::decrement_pinned_object_count() { - Atomic::sub(&_pinned_object_count, (size_t)1, memory_order_relaxed); +inline void HeapRegion::add_pinned_object_count(size_t value) { + assert(value != 0, "wasted effort"); + assert(!is_free(), "trying to pin free region %u, adding %zu", hrm_index(), value); + Atomic::add(&_pinned_object_count, value, memory_order_relaxed); } #endif // SHARE_GC_G1_HEAPREGION_INLINE_HPP diff --git a/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp b/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp index 2531ecb2d5c..64d3a8d4a10 100644 --- a/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp +++ b/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp @@ -102,7 +102,6 @@ jint ParallelScavengeHeap::initialize() { assert(old_gen()->max_gen_size() == old_rs.size(), "Consistency check"); double max_gc_pause_sec = ((double) MaxGCPauseMillis)/1000.0; - double max_gc_minor_pause_sec = ((double) MaxGCMinorPauseMillis)/1000.0; const size_t eden_capacity = _young_gen->eden_space()->capacity_in_bytes(); const size_t old_capacity = _old_gen->capacity_in_bytes(); @@ -113,7 +112,6 @@ jint ParallelScavengeHeap::initialize() { young_gen()->to_space()->capacity_in_bytes(), GenAlignment, max_gc_pause_sec, - max_gc_minor_pause_sec, GCTimeRatio ); diff --git a/src/hotspot/share/gc/parallel/psAdaptiveSizePolicy.cpp b/src/hotspot/share/gc/parallel/psAdaptiveSizePolicy.cpp index 15287437cff..c8a15c2cb92 100644 --- a/src/hotspot/share/gc/parallel/psAdaptiveSizePolicy.cpp +++ b/src/hotspot/share/gc/parallel/psAdaptiveSizePolicy.cpp @@ -41,7 +41,6 @@ PSAdaptiveSizePolicy::PSAdaptiveSizePolicy(size_t init_eden_size, size_t init_survivor_size, size_t space_alignment, double gc_pause_goal_sec, - double gc_minor_pause_goal_sec, uint gc_cost_ratio) : AdaptiveSizePolicy(init_eden_size, init_promo_size, @@ -55,7 +54,6 @@ PSAdaptiveSizePolicy::PSAdaptiveSizePolicy(size_t init_eden_size, _major_pause_young_estimator(new LinearLeastSquareFit(AdaptiveSizePolicyWeight)), _latest_major_mutator_interval_seconds(0), _space_alignment(space_alignment), - _gc_minor_pause_goal_sec(gc_minor_pause_goal_sec), _live_at_last_full_gc(init_promo_size), _change_old_gen_for_min_pauses(0), _change_young_gen_for_maj_pauses(0), @@ -282,7 +280,7 @@ void PSAdaptiveSizePolicy::compute_eden_space_size( // at a time. adjust_eden_for_pause_time(&desired_eden_size); - } else if (_avg_minor_pause->padded_average() > gc_minor_pause_goal_sec()) { + } else if (_avg_minor_pause->padded_average() > gc_pause_goal_sec()) { // Adjust only for the minor pause time goal adjust_eden_for_minor_pause_time(&desired_eden_size); diff --git a/src/hotspot/share/gc/parallel/psAdaptiveSizePolicy.hpp b/src/hotspot/share/gc/parallel/psAdaptiveSizePolicy.hpp index f6d4be029fb..997a4784667 100644 --- a/src/hotspot/share/gc/parallel/psAdaptiveSizePolicy.hpp +++ b/src/hotspot/share/gc/parallel/psAdaptiveSizePolicy.hpp @@ -91,8 +91,6 @@ class PSAdaptiveSizePolicy : public AdaptiveSizePolicy { const size_t _space_alignment; // alignment for eden, survivors - const double _gc_minor_pause_goal_sec; // goal for maximum minor gc pause - // The amount of live data in the heap at the last full GC, used // as a baseline to help us determine when we need to perform the // next full GC. @@ -113,9 +111,6 @@ class PSAdaptiveSizePolicy : public AdaptiveSizePolicy { private: - // Accessors - double gc_minor_pause_goal_sec() const { return _gc_minor_pause_goal_sec; } - void adjust_eden_for_minor_pause_time(size_t* desired_eden_size_ptr); // Change the generation sizes to achieve a GC pause time goal // Returned sizes are not necessarily aligned. @@ -187,7 +182,6 @@ class PSAdaptiveSizePolicy : public AdaptiveSizePolicy { size_t init_survivor_size, size_t space_alignment, double gc_pause_goal_sec, - double gc_minor_pause_goal_sec, uint gc_time_ratio); // Methods indicating events of interest to the adaptive size policy, diff --git a/src/hotspot/share/gc/serial/cardTableRS.cpp b/src/hotspot/share/gc/serial/cardTableRS.cpp index c4af2c8edb1..96c77793230 100644 --- a/src/hotspot/share/gc/serial/cardTableRS.cpp +++ b/src/hotspot/share/gc/serial/cardTableRS.cpp @@ -27,6 +27,7 @@ #include "gc/serial/cardTableRS.hpp" #include "gc/serial/generation.hpp" #include "gc/serial/serialHeap.hpp" +#include "gc/serial/tenuredGeneration.hpp" #include "gc/shared/space.inline.hpp" #include "memory/iterator.inline.hpp" #include "utilities/align.hpp" @@ -54,9 +55,8 @@ void CardTableRS::verify_used_region_at_save_marks(Space* sp) const { } #endif -void CardTableRS::maintain_old_to_young_invariant(Generation* old_gen, bool is_young_gen_empty) { - assert(SerialHeap::heap()->is_old_gen(old_gen), "precondition"); - +void CardTableRS::maintain_old_to_young_invariant(TenuredGeneration* old_gen, + bool is_young_gen_empty) { if (is_young_gen_empty) { clear_MemRegion(old_gen->prev_used_region()); } else { diff --git a/src/hotspot/share/gc/serial/cardTableRS.hpp b/src/hotspot/share/gc/serial/cardTableRS.hpp index a4f333803a0..252d00e55e7 100644 --- a/src/hotspot/share/gc/serial/cardTableRS.hpp +++ b/src/hotspot/share/gc/serial/cardTableRS.hpp @@ -29,8 +29,8 @@ #include "memory/memRegion.hpp" #include "oops/oop.hpp" -class Generation; class Space; +class TenuredGeneration; class TenuredSpace; // This RemSet uses a card table both as shared data structure @@ -80,7 +80,7 @@ class CardTableRS : public CardTable { // the old generation card table completely if the young generation had been // completely evacuated, otherwise dirties the whole old generation to // conservatively not loose any old-to-young pointer. - void maintain_old_to_young_invariant(Generation* old_gen, bool is_young_gen_empty); + void maintain_old_to_young_invariant(TenuredGeneration* old_gen, bool is_young_gen_empty); // Iterate over the portion of the card-table which covers the given // region mr in the given space and apply cl to any dirty sub-regions diff --git a/src/hotspot/share/gc/serial/defNewGeneration.cpp b/src/hotspot/share/gc/serial/defNewGeneration.cpp index 964c7661d31..99c6310e886 100644 --- a/src/hotspot/share/gc/serial/defNewGeneration.cpp +++ b/src/hotspot/share/gc/serial/defNewGeneration.cpp @@ -649,6 +649,12 @@ size_t DefNewGeneration::max_capacity() const { return reserved_bytes - compute_survivor_size(reserved_bytes, SpaceAlignment); } +bool DefNewGeneration::is_in(const void* p) const { + return eden()->is_in(p) + || from()->is_in(p) + || to() ->is_in(p); +} + size_t DefNewGeneration::unsafe_max_alloc_nogc() const { return eden()->free(); } diff --git a/src/hotspot/share/gc/serial/defNewGeneration.hpp b/src/hotspot/share/gc/serial/defNewGeneration.hpp index d6ed965847e..ca16e003d94 100644 --- a/src/hotspot/share/gc/serial/defNewGeneration.hpp +++ b/src/hotspot/share/gc/serial/defNewGeneration.hpp @@ -174,7 +174,17 @@ class DefNewGeneration: public Generation { size_t free() const; size_t max_capacity() const; size_t capacity_before_gc() const; + + // Returns "TRUE" iff "p" points into the used areas in each space of young-gen. + bool is_in(const void* p) const; + + // Return an estimate of the maximum allocation that could be performed + // in the generation without triggering any collection or expansion + // activity. It is "unsafe" because no locks are taken; the result + // should be treated as an approximation, not a guarantee, for use in + // heuristic resizing decisions. size_t unsafe_max_alloc_nogc() const; + size_t contiguous_available() const; size_t max_eden_size() const { return _max_eden_size; } diff --git a/src/hotspot/share/gc/serial/generation.cpp b/src/hotspot/share/gc/serial/generation.cpp index 33910a2b380..149ad6fb210 100644 --- a/src/hotspot/share/gc/serial/generation.cpp +++ b/src/hotspot/share/gc/serial/generation.cpp @@ -83,26 +83,6 @@ void Generation::print_summary_info_on(outputStream* st) { sr->invocations > 0 ? time / sr->invocations : 0.0); } -// Utility iterator classes - -class GenerationIsInClosure : public SpaceClosure { - public: - const void* _p; - Space* sp; - virtual void do_space(Space* s) { - if (sp == nullptr) { - if (s->is_in(_p)) sp = s; - } - } - GenerationIsInClosure(const void* p) : _p(p), sp(nullptr) {} -}; - -bool Generation::is_in(const void* p) const { - GenerationIsInClosure blk(p); - ((Generation*)this)->space_iterate(&blk); - return blk.sp != nullptr; -} - size_t Generation::max_contiguous_available() const { // The largest number of contiguous free words in this or any higher generation. size_t avail = contiguous_available(); @@ -164,22 +144,3 @@ HeapWord* Generation::block_start(const void* p) const { ((Generation*)this)->space_iterate(&blk); return blk._start; } - -class GenerationBlockIsObjClosure : public SpaceClosure { - public: - const HeapWord* _p; - bool is_obj; - virtual void do_space(Space* s) { - if (!is_obj && s->is_in_reserved(_p)) { - is_obj |= s->block_is_obj(_p); - } - } - GenerationBlockIsObjClosure(const HeapWord* p) { _p = p; is_obj = false; } -}; - -bool Generation::block_is_obj(const HeapWord* p) const { - GenerationBlockIsObjClosure blk(p); - // Cast away const - ((Generation*)this)->space_iterate(&blk); - return blk.is_obj; -} diff --git a/src/hotspot/share/gc/serial/generation.hpp b/src/hotspot/share/gc/serial/generation.hpp index fbe1bff6c9b..265b1e1ea40 100644 --- a/src/hotspot/share/gc/serial/generation.hpp +++ b/src/hotspot/share/gc/serial/generation.hpp @@ -108,13 +108,6 @@ class Generation: public CHeapObj { // The largest number of contiguous free bytes in this or any higher generation. virtual size_t max_contiguous_available() const; - // Return an estimate of the maximum allocation that could be performed - // in the generation without triggering any collection or expansion - // activity. It is "unsafe" because no locks are taken; the result - // should be treated as an approximation, not a guarantee, for use in - // heuristic resizing decisions. - virtual size_t unsafe_max_alloc_nogc() const = 0; - // Returns true if this generation cannot be expanded further // without a GC. Override as appropriate. virtual bool is_maximal_no_gc() const { @@ -130,13 +123,6 @@ class Generation: public CHeapObj { MemRegion prev_used_region() const { return _prev_used_region; } virtual void save_used_region() { _prev_used_region = used_region(); } - // Returns "TRUE" iff "p" points into the committed areas in the generation. - // For some kinds of generations, this may be an expensive operation. - // To avoid performance problems stemming from its inadvertent use in - // product jvm's, we restrict its use to assertion checking or - // verification only. - virtual bool is_in(const void* p) const; - /* Returns "TRUE" iff "p" points into the reserved area of the generation. */ bool is_in_reserved(const void* p) const { return _reserved.contains(p); @@ -234,10 +220,6 @@ class Generation: public CHeapObj { // non-object. virtual HeapWord* block_start(const void* addr) const; - // Requires "addr" to be the start of a block, and returns "TRUE" iff - // the block is an object. - virtual bool block_is_obj(const HeapWord* addr) const; - virtual void print() const; virtual void print_on(outputStream* st) const; diff --git a/src/hotspot/share/gc/serial/serialHeap.cpp b/src/hotspot/share/gc/serial/serialHeap.cpp index 572fe8c2c65..a781c950aa9 100644 --- a/src/hotspot/share/gc/serial/serialHeap.cpp +++ b/src/hotspot/share/gc/serial/serialHeap.cpp @@ -924,12 +924,15 @@ HeapWord* SerialHeap::block_start(const void* addr) const { bool SerialHeap::block_is_obj(const HeapWord* addr) const { assert(is_in_reserved(addr), "block_is_obj of address outside of heap"); assert(block_start(addr) == addr, "addr must be a block start"); + if (_young_gen->is_in_reserved(addr)) { - return _young_gen->block_is_obj(addr); + return _young_gen->eden()->is_in(addr) + || _young_gen->from()->is_in(addr) + || _young_gen->to() ->is_in(addr); } - assert(_old_gen->is_in_reserved(addr), "Some generation should contain the address"); - return _old_gen->block_is_obj(addr); + assert(_old_gen->is_in_reserved(addr), "must be in old-gen"); + return addr < _old_gen->space()->top(); } size_t SerialHeap::tlab_capacity(Thread* thr) const { diff --git a/src/hotspot/share/gc/serial/tenuredGeneration.cpp b/src/hotspot/share/gc/serial/tenuredGeneration.cpp index 9e625bae531..d4430106db5 100644 --- a/src/hotspot/share/gc/serial/tenuredGeneration.cpp +++ b/src/hotspot/share/gc/serial/tenuredGeneration.cpp @@ -450,10 +450,6 @@ TenuredGeneration::expand_and_allocate(size_t word_size, bool is_tlab) { return _the_space->allocate(word_size); } -size_t TenuredGeneration::unsafe_max_alloc_nogc() const { - return _the_space->free(); -} - size_t TenuredGeneration::contiguous_available() const { return _the_space->free() + _virtual_space.uncommitted_size(); } diff --git a/src/hotspot/share/gc/serial/tenuredGeneration.hpp b/src/hotspot/share/gc/serial/tenuredGeneration.hpp index 55f07a717a3..329e531c1f3 100644 --- a/src/hotspot/share/gc/serial/tenuredGeneration.hpp +++ b/src/hotspot/share/gc/serial/tenuredGeneration.hpp @@ -111,7 +111,6 @@ class TenuredGeneration: public Generation { const char* name() const { return "tenured generation"; } const char* short_name() const { return "Tenured"; } - size_t unsafe_max_alloc_nogc() const; size_t contiguous_available() const; // Iteration @@ -129,8 +128,6 @@ class TenuredGeneration: public Generation { bool no_allocs_since_save_marks(); - inline bool block_is_obj(const HeapWord* addr) const; - virtual void collect(bool full, bool clear_all_soft_refs, size_t size, diff --git a/src/hotspot/share/gc/serial/tenuredGeneration.inline.hpp b/src/hotspot/share/gc/serial/tenuredGeneration.inline.hpp index 4f8b51c99ff..f27910357b1 100644 --- a/src/hotspot/share/gc/serial/tenuredGeneration.inline.hpp +++ b/src/hotspot/share/gc/serial/tenuredGeneration.inline.hpp @@ -61,10 +61,6 @@ HeapWord* TenuredGeneration::par_allocate(size_t word_size, return _the_space->par_allocate(word_size); } -bool TenuredGeneration::block_is_obj(const HeapWord* addr) const { - return addr < _the_space ->top(); -} - template void TenuredGeneration::oop_since_save_marks_iterate(OopClosureType* blk) { _the_space->oop_since_save_marks_iterate(blk); diff --git a/src/hotspot/share/gc/shared/gc_globals.hpp b/src/hotspot/share/gc/shared/gc_globals.hpp index ae8674c84a9..652153922d1 100644 --- a/src/hotspot/share/gc/shared/gc_globals.hpp +++ b/src/hotspot/share/gc/shared/gc_globals.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, 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 @@ -309,23 +309,6 @@ "MaxRAM * MaxRAMPercentage / 100") \ range(0, max_uintx) \ \ - product(uintx, MaxRAMFraction, 4, \ - "Maximum fraction (1/n) of real memory used for maximum heap " \ - "size. " \ - "Deprecated, use MaxRAMPercentage instead") \ - range(1, max_uintx) \ - \ - product(uintx, MinRAMFraction, 2, \ - "Minimum fraction (1/n) of real memory used for maximum heap " \ - "size on systems with small physical memory size. " \ - "Deprecated, use MinRAMPercentage instead") \ - range(1, max_uintx) \ - \ - product(uintx, InitialRAMFraction, 64, \ - "Fraction (1/n) of real memory used for initial heap size. " \ - "Deprecated, use InitialRAMPercentage instead") \ - range(1, max_uintx) \ - \ product(double, MaxRAMPercentage, 25.0, \ "Maximum percentage of real memory used for maximum heap size") \ range(0.0, 100.0) \ @@ -442,11 +425,6 @@ "Time slice for MMU specification") \ constraint(GCPauseIntervalMillisConstraintFunc,AfterErgo) \ \ - product(uintx, MaxGCMinorPauseMillis, max_uintx, \ - "Adaptive size policy maximum GC minor pause time goal " \ - "in millisecond") \ - range(0, max_uintx) \ - \ product(uint, GCTimeRatio, 99, \ "Adaptive size policy application time to GC time ratio") \ range(0, UINT_MAX) \ diff --git a/src/hotspot/share/gc/shared/pretouchTask.cpp b/src/hotspot/share/gc/shared/pretouchTask.cpp index 5e35baf03de..aba7a715fd3 100644 --- a/src/hotspot/share/gc/shared/pretouchTask.cpp +++ b/src/hotspot/share/gc/shared/pretouchTask.cpp @@ -68,12 +68,6 @@ void PretouchTask::pretouch(const char* task_name, char* start_address, char* en // Page-align the chunk size, so if start_address is also page-aligned (as // is common) then there won't be any pages shared by multiple chunks. size_t chunk_size = align_down_bounded(PretouchTask::chunk_size(), page_size); -#ifdef LINUX - // When using THP we need to always pre-touch using small pages as the OS will - // initially always use small pages. - page_size = UseTransparentHugePages ? (size_t)os::vm_page_size() : page_size; -#endif - PretouchTask task(task_name, start_address, end_address, page_size, chunk_size); size_t total_bytes = pointer_delta(end_address, start_address, sizeof(char)); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp b/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp index 22dfbecbc30..d1711a30c0f 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp @@ -84,11 +84,11 @@ void ShenandoahControlThread::run_service() { bool explicit_gc_requested = is_gc_requested && is_explicit_gc(requested_gc_cause); bool implicit_gc_requested = is_gc_requested && !is_explicit_gc(requested_gc_cause); - // This control loop iteration have seen this much allocations. + // This control loop iteration has seen this much allocation. size_t allocs_seen = Atomic::xchg(&_allocs_seen, (size_t)0, memory_order_relaxed); // Check if we have seen a new target for soft max heap size. - bool soft_max_changed = check_soft_max_changed(); + bool soft_max_changed = heap->check_soft_max_changed(); // Choose which GC mode to run in. The block below should select a single mode. GCMode mode = none; @@ -287,7 +287,7 @@ void ShenandoahControlThread::run_service() { heap->soft_max_capacity() : heap->min_capacity(); - service_uncommit(shrink_before, shrink_until); + heap->maybe_uncommit(shrink_before, shrink_until); heap->phase_timings()->flush_cycle_to_global(); last_shrink_time = current; } @@ -310,25 +310,6 @@ void ShenandoahControlThread::run_service() { } } -bool ShenandoahControlThread::check_soft_max_changed() const { - ShenandoahHeap* heap = ShenandoahHeap::heap(); - size_t new_soft_max = Atomic::load(&SoftMaxHeapSize); - size_t old_soft_max = heap->soft_max_capacity(); - if (new_soft_max != old_soft_max) { - new_soft_max = MAX2(heap->min_capacity(), new_soft_max); - new_soft_max = MIN2(heap->max_capacity(), new_soft_max); - if (new_soft_max != old_soft_max) { - log_info(gc)("Soft Max Heap Size: " SIZE_FORMAT "%s -> " SIZE_FORMAT "%s", - byte_size_in_proper_unit(old_soft_max), proper_unit_for_byte_size(old_soft_max), - byte_size_in_proper_unit(new_soft_max), proper_unit_for_byte_size(new_soft_max) - ); - heap->set_soft_max_capacity(new_soft_max); - return true; - } - } - return false; -} - void ShenandoahControlThread::service_concurrent_normal_cycle(GCCause::Cause cause) { // Normal cycle goes via all concurrent phases. If allocation failure (af) happens during // any of the concurrent phases, it first degrades to Degenerated GC and completes GC there. @@ -420,29 +401,6 @@ void ShenandoahControlThread::service_stw_degenerated_cycle(GCCause::Cause cause gc.collect(cause); } -void ShenandoahControlThread::service_uncommit(double shrink_before, size_t shrink_until) { - ShenandoahHeap* heap = ShenandoahHeap::heap(); - - // Determine if there is work to do. This avoids taking heap lock if there is - // no work available, avoids spamming logs with superfluous logging messages, - // and minimises the amount of work while locks are taken. - - if (heap->committed() <= shrink_until) return; - - bool has_work = false; - for (size_t i = 0; i < heap->num_regions(); i++) { - ShenandoahHeapRegion *r = heap->get_region(i); - if (r->is_empty_committed() && (r->empty_time() < shrink_before)) { - has_work = true; - break; - } - } - - if (has_work) { - heap->entry_uncommit(shrink_before, shrink_until); - } -} - bool ShenandoahControlThread::is_explicit_gc(GCCause::Cause cause) const { return GCCause::is_user_requested_gc(cause) || GCCause::is_serviceability_requested_gc(cause); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahControlThread.hpp b/src/hotspot/share/gc/shenandoah/shenandoahControlThread.hpp index 85755d7b3de..946e5a9e4aa 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahControlThread.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahControlThread.hpp @@ -72,7 +72,6 @@ class ShenandoahControlThread: public ConcurrentGCThread { void service_concurrent_normal_cycle(GCCause::Cause cause); void service_stw_full_cycle(GCCause::Cause cause); void service_stw_degenerated_cycle(GCCause::Cause cause, ShenandoahGC::ShenandoahDegenPoint point); - void service_uncommit(double shrink_before, size_t shrink_until); bool try_set_alloc_failure_gc(); void notify_alloc_failure_waiters(); @@ -90,8 +89,6 @@ class ShenandoahControlThread: public ConcurrentGCThread { bool is_explicit_gc(GCCause::Cause cause) const; - bool check_soft_max_changed() const; - public: // Constructor ShenandoahControlThread(); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp index 2f1a93bf137..7e1a3e54077 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp @@ -754,6 +754,33 @@ bool ShenandoahHeap::is_in(const void* p) const { return p >= heap_base && p < last_region_end; } +void ShenandoahHeap::maybe_uncommit(double shrink_before, size_t shrink_until) { + assert (ShenandoahUncommit, "should be enabled"); + + // Determine if there is work to do. This avoids taking heap lock if there is + // no work available, avoids spamming logs with superfluous logging messages, + // and minimises the amount of work while locks are taken. + + if (committed() <= shrink_until) return; + + bool has_work = false; + for (size_t i = 0; i < num_regions(); i++) { + ShenandoahHeapRegion* r = get_region(i); + if (r->is_empty_committed() && (r->empty_time() < shrink_before)) { + has_work = true; + break; + } + } + + if (has_work) { + static const char* msg = "Concurrent uncommit"; + ShenandoahConcurrentPhase gcPhase(msg, ShenandoahPhaseTimings::conc_uncommit, true /* log_heap_usage */); + EventMark em("%s", msg); + + op_uncommit(shrink_before, shrink_until); + } +} + void ShenandoahHeap::op_uncommit(double shrink_before, size_t shrink_until) { assert (ShenandoahUncommit, "should be enabled"); @@ -784,6 +811,24 @@ void ShenandoahHeap::op_uncommit(double shrink_before, size_t shrink_until) { } } +bool ShenandoahHeap::check_soft_max_changed() { + size_t new_soft_max = Atomic::load(&SoftMaxHeapSize); + size_t old_soft_max = soft_max_capacity(); + if (new_soft_max != old_soft_max) { + new_soft_max = MAX2(min_capacity(), new_soft_max); + new_soft_max = MIN2(max_capacity(), new_soft_max); + if (new_soft_max != old_soft_max) { + log_info(gc)("Soft Max Heap Size: " SIZE_FORMAT "%s -> " SIZE_FORMAT "%s", + byte_size_in_proper_unit(old_soft_max), proper_unit_for_byte_size(old_soft_max), + byte_size_in_proper_unit(new_soft_max), proper_unit_for_byte_size(new_soft_max) + ); + set_soft_max_capacity(new_soft_max); + return true; + } + } + return false; +} + void ShenandoahHeap::notify_heap_changed() { // Update monitoring counters when we took a new region. This amortizes the // update costs on slow path. @@ -2259,14 +2304,6 @@ void ShenandoahHeap::safepoint_synchronize_end() { SuspendibleThreadSet::desynchronize(); } -void ShenandoahHeap::entry_uncommit(double shrink_before, size_t shrink_until) { - static const char *msg = "Concurrent uncommit"; - ShenandoahConcurrentPhase gc_phase(msg, ShenandoahPhaseTimings::conc_uncommit, true /* log_heap_usage */); - EventMark em("%s", msg); - - op_uncommit(shrink_before, shrink_until); -} - void ShenandoahHeap::try_inject_alloc_failure() { if (ShenandoahAllocFailureALot && !cancelled_gc() && ((os::random() % 1000) > 950)) { _inject_alloc_failure.set(); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp index db5689df16b..21ec329c271 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp @@ -364,10 +364,14 @@ class ShenandoahHeap : public CollectedHeap, public ShenandoahSpaceInfo { void cancel_gc(GCCause::Cause cause); public: - // Elastic heap support - void entry_uncommit(double shrink_before, size_t shrink_until); + // These will uncommit empty regions if heap::committed > shrink_until + // and there exists at least one region which was made empty before shrink_before. + void maybe_uncommit(double shrink_before, size_t shrink_until); void op_uncommit(double shrink_before, size_t shrink_until); + // Returns true if the soft maximum heap has been changed using management APIs. + bool check_soft_max_changed(); + private: // GC support // Reset bitmap, prepare regions for new GC cycle diff --git a/src/hotspot/share/gc/z/zArguments.cpp b/src/hotspot/share/gc/z/zArguments.cpp index 192cad86e67..c71e59944f0 100644 --- a/src/hotspot/share/gc/z/zArguments.cpp +++ b/src/hotspot/share/gc/z/zArguments.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,6 @@ void ZArguments::initialize_alignments() { void ZArguments::initialize_heap_flags_and_sizes() { if (!FLAG_IS_CMDLINE(MaxHeapSize) && - !FLAG_IS_CMDLINE(MaxRAMFraction) && !FLAG_IS_CMDLINE(MaxRAMPercentage) && !FLAG_IS_CMDLINE(SoftMaxHeapSize)) { // We are really just guessing how much memory the program needs. diff --git a/src/hotspot/share/interpreter/bytecodeTracer.cpp b/src/hotspot/share/interpreter/bytecodeTracer.cpp index d49d095ffbb..624f2b621c1 100644 --- a/src/hotspot/share/interpreter/bytecodeTracer.cpp +++ b/src/hotspot/share/interpreter/bytecodeTracer.cpp @@ -592,6 +592,10 @@ void BytecodePrinter::print_attributes(int bci, outputStream* st) { void BytecodePrinter::bytecode_epilog(int bci, outputStream* st) { MethodData* mdo = method()->method_data(); if (mdo != nullptr) { + + // Lock to read ProfileData, and ensure lock is not broken by a safepoint + MutexLocker ml(mdo->extra_data_lock(), Mutex::_no_safepoint_check_flag); + ProfileData* data = mdo->bci_to_data(bci); if (data != nullptr) { st->print(" %d ", mdo->dp_to_di(data->dp())); diff --git a/src/hotspot/share/interpreter/interpreterRuntime.cpp b/src/hotspot/share/interpreter/interpreterRuntime.cpp index 70439459d35..ff7c453e01e 100644 --- a/src/hotspot/share/interpreter/interpreterRuntime.cpp +++ b/src/hotspot/share/interpreter/interpreterRuntime.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, 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 @@ -547,7 +547,12 @@ JRT_ENTRY(address, InterpreterRuntime::exception_handler_for_exception(JavaThrea #if INCLUDE_JVMCI if (EnableJVMCI && h_method->method_data() != nullptr) { ResourceMark rm(current); - ProfileData* pdata = h_method->method_data()->allocate_bci_to_data(current_bci, nullptr); + MethodData* mdo = h_method->method_data(); + + // Lock to read ProfileData, and ensure lock is not broken by a safepoint + MutexLocker ml(mdo->extra_data_lock(), Mutex::_no_safepoint_check_flag); + + ProfileData* pdata = mdo->allocate_bci_to_data(current_bci, nullptr); if (pdata != nullptr && pdata->is_BitData()) { BitData* bit_data = (BitData*) pdata; bit_data->set_exception_seen(); diff --git a/src/hotspot/share/jfr/support/jfrMethodData.cpp b/src/hotspot/share/jfr/support/jfrMethodData.cpp index a9213333204..4595f26f4aa 100644 --- a/src/hotspot/share/jfr/support/jfrMethodData.cpp +++ b/src/hotspot/share/jfr/support/jfrMethodData.cpp @@ -56,6 +56,10 @@ static bool mark_mdo(Method* method, int bci, JavaThread* jt) { assert(jt != nullptr, "invariant"); MethodData* const mdo = get_mdo(method, jt); assert(mdo != nullptr, "invariant"); + + // Lock to access ProfileData, and ensure lock is not broken by a safepoint + MutexLocker ml(mdo->extra_data_lock(), Mutex::_no_safepoint_check_flag); + // Get the datalayout for the invocation bci. BitData* const bit_data = get_bit_data(mdo, bci); // Returns true if this callsite is not yet linked and diff --git a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp index 1a1e0ba7fd6..069aa8394e9 100644 --- a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp +++ b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2024, 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 @@ -1889,7 +1889,10 @@ C2V_END C2V_VMENTRY_0(jint, methodDataExceptionSeen, (JNIEnv* env, jobject, jlong method_data_pointer, jint bci)) MethodData* mdo = (MethodData*) method_data_pointer; - MutexLocker mu(mdo->extra_data_lock()); + + // Lock to read ProfileData, and ensure lock is not broken by a safepoint + MutexLocker mu(mdo->extra_data_lock(), Mutex::_no_safepoint_check_flag); + DataLayout* data = mdo->extra_data_base(); DataLayout* end = mdo->args_data_limit(); for (;; data = mdo->next_extra(data)) { diff --git a/src/hotspot/share/oops/instanceKlass.cpp b/src/hotspot/share/oops/instanceKlass.cpp index 2178a506e5c..8026d10dc12 100644 --- a/src/hotspot/share/oops/instanceKlass.cpp +++ b/src/hotspot/share/oops/instanceKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, 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 @@ -2531,7 +2531,6 @@ void InstanceKlass::clean_method_data() { for (int m = 0; m < methods()->length(); m++) { MethodData* mdo = methods()->at(m)->method_data(); if (mdo != nullptr) { - ConditionalMutexLocker ml(mdo->extra_data_lock(), !SafepointSynchronize::is_at_safepoint()); mdo->clean_method_data(/*always_clean*/false); } } diff --git a/src/hotspot/share/oops/methodData.cpp b/src/hotspot/share/oops/methodData.cpp index 1107a53a8ed..008de899bdb 100644 --- a/src/hotspot/share/oops/methodData.cpp +++ b/src/hotspot/share/oops/methodData.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, 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 @@ -1218,7 +1218,7 @@ void MethodData::post_initialize(BytecodeStream* stream) { MethodData::MethodData(const methodHandle& method) : _method(method()), // Holds Compile_lock - _extra_data_lock(Mutex::safepoint-2, "MDOExtraData_lock"), + _extra_data_lock(Mutex::nosafepoint, "MDOExtraData_lock"), _compiler_counters(), _parameters_type_data_di(parameters_uninitialized) { initialize(); @@ -1379,6 +1379,8 @@ address MethodData::bci_to_dp(int bci) { // Translate a bci to its corresponding data, or null. ProfileData* MethodData::bci_to_data(int bci) { + check_extra_data_locked(); + DataLayout* data = data_layout_before(bci); for ( ; is_valid(data); data = next_data_layout(data)) { if (data->bci() == bci) { @@ -1429,7 +1431,9 @@ DataLayout* MethodData::next_extra(DataLayout* dp) { return (DataLayout*)((address)dp + DataLayout::compute_size_in_bytes(nb_cells)); } -ProfileData* MethodData::bci_to_extra_data_helper(int bci, Method* m, DataLayout*& dp, bool concurrent) { +ProfileData* MethodData::bci_to_extra_data_find(int bci, Method* m, DataLayout*& dp) { + check_extra_data_locked(); + DataLayout* end = args_data_limit(); for (;; dp = next_extra(dp)) { @@ -1450,14 +1454,9 @@ ProfileData* MethodData::bci_to_extra_data_helper(int bci, Method* m, DataLayout case DataLayout::speculative_trap_data_tag: if (m != nullptr) { SpeculativeTrapData* data = new SpeculativeTrapData(dp); - // data->method() may be null in case of a concurrent - // allocation. Maybe it's for the same method. Try to use that - // entry in that case. if (dp->bci() == bci) { - if (data->method() == nullptr) { - assert(concurrent, "impossible because no concurrent allocation"); - return nullptr; - } else if (data->method() == m) { + assert(data->method() != nullptr, "method must be set"); + if (data->method() == m) { return data; } } @@ -1473,6 +1472,8 @@ ProfileData* MethodData::bci_to_extra_data_helper(int bci, Method* m, DataLayout // Translate a bci to its corresponding extra data, or null. ProfileData* MethodData::bci_to_extra_data(int bci, Method* m, bool create_if_missing) { + check_extra_data_locked(); + // This code assumes an entry for a SpeculativeTrapData is 2 cells assert(2*DataLayout::compute_size_in_bytes(BitData::static_cell_count()) == DataLayout::compute_size_in_bytes(SpeculativeTrapData::static_cell_count()), @@ -1486,23 +1487,14 @@ ProfileData* MethodData::bci_to_extra_data(int bci, Method* m, bool create_if_mi DataLayout* dp = extra_data_base(); DataLayout* end = args_data_limit(); - // Allocation in the extra data space has to be atomic because not - // all entries have the same size and non atomic concurrent - // allocation would result in a corrupted extra data space. - ProfileData* result = bci_to_extra_data_helper(bci, m, dp, true); - if (result != nullptr) { + // Find if already exists + ProfileData* result = bci_to_extra_data_find(bci, m, dp); + if (result != nullptr || dp >= end) { return result; } - if (create_if_missing && dp < end) { - MutexLocker ml(&_extra_data_lock); - // Check again now that we have the lock. Another thread may - // have added extra data entries. - ProfileData* result = bci_to_extra_data_helper(bci, m, dp, false); - if (result != nullptr || dp >= end) { - return result; - } - + if (create_if_missing) { + // Not found -> Allocate assert(dp->tag() == DataLayout::no_tag || (dp->tag() == DataLayout::speculative_trap_data_tag && m != nullptr), "should be free"); assert(next_extra(dp)->tag() == DataLayout::no_tag || next_extra(dp)->tag() == DataLayout::arg_info_data_tag, "should be free or arg info"); u1 tag = m == nullptr ? DataLayout::bit_data_tag : DataLayout::speculative_trap_data_tag; @@ -1729,6 +1721,8 @@ void MethodData::metaspace_pointers_do(MetaspaceClosure* it) { } void MethodData::clean_extra_data_helper(DataLayout* dp, int shift, bool reset) { + check_extra_data_locked(); + if (shift == 0) { return; } @@ -1770,6 +1764,8 @@ class CleanExtraDataMethodClosure : public CleanExtraDataClosure { // Remove SpeculativeTrapData entries that reference an unloaded or // redefined method void MethodData::clean_extra_data(CleanExtraDataClosure* cl) { + check_extra_data_locked(); + DataLayout* dp = extra_data_base(); DataLayout* end = args_data_limit(); @@ -1814,6 +1810,8 @@ void MethodData::clean_extra_data(CleanExtraDataClosure* cl) { // Verify there's no unloaded or redefined method referenced by a // SpeculativeTrapData entry void MethodData::verify_extra_data_clean(CleanExtraDataClosure* cl) { + check_extra_data_locked(); + #ifdef ASSERT DataLayout* dp = extra_data_base(); DataLayout* end = args_data_limit(); @@ -1851,6 +1849,10 @@ void MethodData::clean_method_data(bool always_clean) { } CleanExtraDataKlassClosure cl(always_clean); + + // Lock to modify extra data, and prevent Safepoint from breaking the lock + MutexLocker ml(extra_data_lock(), Mutex::_no_safepoint_check_flag); + clean_extra_data(&cl); verify_extra_data_clean(&cl); } @@ -1860,6 +1862,10 @@ void MethodData::clean_method_data(bool always_clean) { void MethodData::clean_weak_method_links() { ResourceMark rm; CleanExtraDataMethodClosure cl; + + // Lock to modify extra data, and prevent Safepoint from breaking the lock + MutexLocker ml(extra_data_lock(), Mutex::_no_safepoint_check_flag); + clean_extra_data(&cl); verify_extra_data_clean(&cl); } @@ -1873,3 +1879,16 @@ void MethodData::release_C_heap_structures() { FailedSpeculation::free_failed_speculations(get_failed_speculations_address()); #endif } + +#ifdef ASSERT +void MethodData::check_extra_data_locked() const { + // Cast const away, just to be able to verify the lock + // Usually we only want non-const accesses on the lock, + // so this here is an exception. + MethodData* self = (MethodData*)this; + assert(self->extra_data_lock()->owned_by_self(), "must have lock"); + assert(!Thread::current()->is_Java_thread() || + JavaThread::current()->is_in_no_safepoint_scope(), + "JavaThread must have NoSafepointVerifier inside lock scope"); +} +#endif diff --git a/src/hotspot/share/oops/methodData.hpp b/src/hotspot/share/oops/methodData.hpp index bff0f619f4b..4fa42eec960 100644 --- a/src/hotspot/share/oops/methodData.hpp +++ b/src/hotspot/share/oops/methodData.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, 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 @@ -2168,7 +2168,7 @@ class MethodData : public Metadata { // What is the index of the first data entry? int first_di() const { return 0; } - ProfileData* bci_to_extra_data_helper(int bci, Method* m, DataLayout*& dp, bool concurrent); + ProfileData* bci_to_extra_data_find(int bci, Method* m, DataLayout*& dp); // Find or create an extra ProfileData: ProfileData* bci_to_extra_data(int bci, Method* m, bool create_if_missing); @@ -2310,20 +2310,12 @@ class MethodData : public Metadata { intx arg_local() { return _arg_local; } intx arg_stack() { return _arg_stack; } intx arg_returned() { return _arg_returned; } - uint arg_modified(int a) { ArgInfoData *aid = arg_info(); - assert(aid != nullptr, "arg_info must be not null"); - assert(a >= 0 && a < aid->number_of_args(), "valid argument number"); - return aid->arg_modified(a); } - + uint arg_modified(int a); void set_eflags(intx v) { _eflags = v; } void set_arg_local(intx v) { _arg_local = v; } void set_arg_stack(intx v) { _arg_stack = v; } void set_arg_returned(intx v) { _arg_returned = v; } - void set_arg_modified(int a, uint v) { ArgInfoData *aid = arg_info(); - assert(aid != nullptr, "arg_info must be not null"); - assert(a >= 0 && a < aid->number_of_args(), "valid argument number"); - aid->set_arg_modified(a, v); } - + void set_arg_modified(int a, uint v); void clear_escape_info() { _eflags = _arg_local = _arg_stack = _arg_returned = 0; } // Location and size of data area @@ -2371,6 +2363,8 @@ class MethodData : public Metadata { // Same, but try to create an extra_data record if one is needed: ProfileData* allocate_bci_to_data(int bci, Method* m) { + check_extra_data_locked(); + ProfileData* data = nullptr; // If m not null, try to allocate a SpeculativeTrapData entry if (m == nullptr) { @@ -2397,7 +2391,10 @@ class MethodData : public Metadata { // Add a handful of extra data records, for trap tracking. // Only valid after 'set_size' is called at the end of MethodData::initialize - DataLayout* extra_data_base() const { return limit_data_position(); } + DataLayout* extra_data_base() const { + check_extra_data_locked(); + return limit_data_position(); + } DataLayout* extra_data_limit() const { return (DataLayout*)((address)this + size_in_bytes()); } // pointers to sections in extra data DataLayout* args_data_limit() const { return parameters_data_base(); } @@ -2412,7 +2409,7 @@ class MethodData : public Metadata { DataLayout* exception_handler_data_base() const { return data_layout_at(_exception_handler_data_di); } DataLayout* exception_handler_data_limit() const { return extra_data_limit(); } - int extra_data_size() const { return (int)((address)extra_data_limit() - (address)extra_data_base()); } + int extra_data_size() const { return (int)((address)extra_data_limit() - (address)limit_data_position()); } static DataLayout* next_extra(DataLayout* dp); // Return (uint)-1 for overflow. @@ -2529,6 +2526,7 @@ class MethodData : public Metadata { void clean_method_data(bool always_clean); void clean_weak_method_links(); Mutex* extra_data_lock() { return &_extra_data_lock; } + void check_extra_data_locked() const NOT_DEBUG_RETURN; }; #endif // SHARE_OOPS_METHODDATA_HPP diff --git a/src/hotspot/share/oops/methodData.inline.hpp b/src/hotspot/share/oops/methodData.inline.hpp index e8084380a27..a59271431b5 100644 --- a/src/hotspot/share/oops/methodData.inline.hpp +++ b/src/hotspot/share/oops/methodData.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, 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 @@ -28,6 +28,7 @@ #include "oops/methodData.hpp" #include "runtime/atomic.hpp" +#include "runtime/mutexLocker.hpp" inline void DataLayout::release_set_cell_at(int index, intptr_t value) { Atomic::release_store(&_cells[index], value); @@ -53,4 +54,22 @@ inline void RetData::release_set_bci(uint row, int bci) { release_set_int_at(bci0_offset + row * ret_row_cell_count, bci); } +inline uint MethodData::arg_modified(int a) { + // Lock and avoid breaking lock with Safepoint + MutexLocker ml(extra_data_lock(), Mutex::_no_safepoint_check_flag); + ArgInfoData* aid = arg_info(); + assert(aid != nullptr, "arg_info must be not null"); + assert(a >= 0 && a < aid->number_of_args(), "valid argument number"); + return aid->arg_modified(a); +} + +inline void MethodData::set_arg_modified(int a, uint v) { + // Lock and avoid breaking lock with Safepoint + MutexLocker ml(extra_data_lock(), Mutex::_no_safepoint_check_flag); + ArgInfoData* aid = arg_info(); + assert(aid != nullptr, "arg_info must be not null"); + assert(a >= 0 && a < aid->number_of_args(), "valid argument number"); + aid->set_arg_modified(a, v); +} + #endif // SHARE_OOPS_METHODDATA_INLINE_HPP diff --git a/src/hotspot/share/oops/oopHandle.hpp b/src/hotspot/share/oops/oopHandle.hpp index ae631fd7d53..983ddf9ae5c 100644 --- a/src/hotspot/share/oops/oopHandle.hpp +++ b/src/hotspot/share/oops/oopHandle.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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,15 +75,4 @@ class OopHandle { oop* ptr_raw() const { return _obj; } }; -// Convert OopHandle to oop* - -template<> -struct PrimitiveConversions::Translate : public std::true_type { - typedef OopHandle Value; - typedef oop* Decayed; - - static Decayed decay(Value x) { return x.ptr_raw(); } - static Value recover(Decayed x) { return OopHandle(x); } -}; - #endif // SHARE_OOPS_OOPHANDLE_HPP diff --git a/src/hotspot/share/opto/c2_globals.hpp b/src/hotspot/share/opto/c2_globals.hpp index 885c0dd75a7..c8182653688 100644 --- a/src/hotspot/share/opto/c2_globals.hpp +++ b/src/hotspot/share/opto/c2_globals.hpp @@ -339,9 +339,6 @@ product(bool, UseSuperWord, true, \ "Transform scalar operations into superword operations") \ \ - develop(bool, SuperWordRTDepCheck, false, \ - "Enable runtime dependency checks.") \ - \ product(bool, SuperWordReductions, true, \ "Enable reductions support in superword.") \ \ diff --git a/src/hotspot/share/opto/graphKit.cpp b/src/hotspot/share/opto/graphKit.cpp index 23891215281..0c35b2145aa 100644 --- a/src/hotspot/share/opto/graphKit.cpp +++ b/src/hotspot/share/opto/graphKit.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, 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 @@ -3468,7 +3468,10 @@ FastLockNode* GraphKit::shared_lock(Node* obj) { assert(dead_locals_are_killed(), "should kill locals before sync. point"); // Box the stack location - Node* box = _gvn.transform(new BoxLockNode(next_monitor())); + Node* box = new BoxLockNode(next_monitor()); + // Check for bailout after new BoxLockNode + if (failing()) { return nullptr; } + box = _gvn.transform(box); Node* mem = reset_memory(); FastLockNode * flock = _gvn.transform(new FastLockNode(0, obj, box) )->as_FastLock(); diff --git a/src/hotspot/share/opto/locknode.cpp b/src/hotspot/share/opto/locknode.cpp index 6354df1ec59..d73150684a7 100644 --- a/src/hotspot/share/opto/locknode.cpp +++ b/src/hotspot/share/opto/locknode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,6 +44,10 @@ BoxLockNode::BoxLockNode( int slot ) : Node( Compile::current()->root() ), init_class_id(Class_BoxLock); init_flags(Flag_rematerialize); OptoReg::Name reg = OptoReg::stack2reg(_slot); + if (!RegMask::can_represent(reg, Compile::current()->sync_stack_slots())) { + Compile::current()->record_method_not_compilable("must be able to represent all monitor slots in reg mask"); + return; + } _inmask.Insert(reg); } diff --git a/src/hotspot/share/opto/matcher.hpp b/src/hotspot/share/opto/matcher.hpp index a4a20975e88..84e48086f92 100644 --- a/src/hotspot/share/opto/matcher.hpp +++ b/src/hotspot/share/opto/matcher.hpp @@ -331,7 +331,7 @@ class Matcher : public PhaseTransform { // Identify extra cases that we might want to vectorize automatically // And exclude cases which are not profitable to auto-vectorize. - static bool match_rule_supported_superword(int opcode, int vlen, BasicType bt); + static bool match_rule_supported_auto_vectorization(int opcode, int vlen, BasicType bt); // identify extra cases that we might want to provide match rules for // e.g. Op_ vector nodes and other intrinsics while guarding with vlen @@ -355,7 +355,7 @@ class Matcher : public PhaseTransform { Matcher::min_vector_size(bt) <= size); } // Limits on max vector size (number of elements) for auto-vectorization. - static int superword_max_vector_size(const BasicType bt); + static int max_vector_size_auto_vectorization(const BasicType bt); // Actual max scalable vector register length. static int scalable_vector_reg_size(const BasicType bt); diff --git a/src/hotspot/share/opto/parse.hpp b/src/hotspot/share/opto/parse.hpp index 40314ecc29d..d5f12c8bc81 100644 --- a/src/hotspot/share/opto/parse.hpp +++ b/src/hotspot/share/opto/parse.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, 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 @@ -564,7 +564,6 @@ class Parse : public GraphKit { float branch_prediction(float &cnt, BoolTest::mask btest, int target_bci, Node* test); bool seems_never_taken(float prob) const; bool path_is_suitable_for_uncommon_trap(float prob) const; - bool seems_stable_comparison() const; void do_ifnull(BoolTest::mask btest, Node* c); void do_if(BoolTest::mask btest, Node* c); diff --git a/src/hotspot/share/opto/parse1.cpp b/src/hotspot/share/opto/parse1.cpp index 8ee99ae9a65..7c0f5cadeeb 100644 --- a/src/hotspot/share/opto/parse1.cpp +++ b/src/hotspot/share/opto/parse1.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, 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 @@ -224,7 +224,10 @@ void Parse::load_interpreter_state(Node* osr_buf) { Node *monitors_addr = basic_plus_adr(osr_buf, osr_buf, (max_locals+mcnt*2-1)*wordSize); for (index = 0; index < mcnt; index++) { // Make a BoxLockNode for the monitor. - Node *box = _gvn.transform(new BoxLockNode(next_monitor())); + Node *box = new BoxLockNode(next_monitor()); + // Check for bailout after new BoxLockNode + if (failing()) { return; } + box = _gvn.transform(box); // Displaced headers and locked objects are interleaved in the @@ -1260,6 +1263,8 @@ void Parse::do_method_entry() { kill_dead_locals(); // Build the FastLockNode _synch_lock = shared_lock(lock_obj); + // Check for bailout in shared_lock + if (failing()) { return; } } // Feed profiling data for parameters to the type system so it can diff --git a/src/hotspot/share/opto/parse2.cpp b/src/hotspot/share/opto/parse2.cpp index 0c22409aeee..d43b8335ffd 100644 --- a/src/hotspot/share/opto/parse2.cpp +++ b/src/hotspot/share/opto/parse2.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, 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 @@ -1354,21 +1354,6 @@ bool Parse::seems_never_taken(float prob) const { return prob < PROB_MIN; } -// True if the comparison seems to be the kind that will not change its -// statistics from true to false. See comments in adjust_map_after_if. -// This question is only asked along paths which are already -// classified as untaken (by seems_never_taken), so really, -// if a path is never taken, its controlling comparison is -// already acting in a stable fashion. If the comparison -// seems stable, we will put an expensive uncommon trap -// on the untaken path. -bool Parse::seems_stable_comparison() const { - if (C->too_many_traps(method(), bci(), Deoptimization::Reason_unstable_if)) { - return false; - } - return true; -} - //-------------------------------repush_if_args-------------------------------- // Push arguments of an "if" bytecode back onto the stack by adjusting _sp. inline int Parse::repush_if_args() { @@ -1572,7 +1557,8 @@ bool Parse::path_is_suitable_for_uncommon_trap(float prob) const { if (!UseInterpreter) { return false; } - return (seems_never_taken(prob) && seems_stable_comparison()); + return seems_never_taken(prob) && + !C->too_many_traps(method(), bci(), Deoptimization::Reason_unstable_if); } void Parse::maybe_add_predicate_after_if(Block* path) { @@ -2778,6 +2764,7 @@ void Parse::do_one_bytecode() { } #ifndef PRODUCT + if (failing()) { return; } constexpr int perBytecode = 6; if (C->should_print_igv(perBytecode)) { IdealGraphPrinter* printer = C->igv_printer(); diff --git a/src/hotspot/share/opto/phasetype.hpp b/src/hotspot/share/opto/phasetype.hpp index 43a6491fee5..fc9a834e6f8 100644 --- a/src/hotspot/share/opto/phasetype.hpp +++ b/src/hotspot/share/opto/phasetype.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, 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 @@ -26,6 +26,7 @@ #define SHARE_OPTO_PHASETYPE_HPP #include "utilities/bitMap.inline.hpp" +#include "utilities/stringUtils.hpp" #define COMPILER_PHASES(flags) \ flags(BEFORE_STRINGOPTS, "Before StringOpts") \ @@ -139,47 +140,6 @@ static CompilerPhaseType find_phase(const char* str) { return PHASE_NONE; } -class PhaseNameIter { - private: - char* _token; - char* _saved_ptr; - char* _list; - - public: - PhaseNameIter(ccstrlist option) { - _list = (char*) canonicalize(option); - _saved_ptr = _list; - _token = strtok_r(_saved_ptr, ",", &_saved_ptr); - } - - ~PhaseNameIter() { - FREE_C_HEAP_ARRAY(char, _list); - } - - const char* operator*() const { return _token; } - - PhaseNameIter& operator++() { - _token = strtok_r(nullptr, ",", &_saved_ptr); - return *this; - } - - ccstrlist canonicalize(ccstrlist option_value) { - char* canonicalized_list = NEW_C_HEAP_ARRAY(char, strlen(option_value) + 1, mtCompiler); - int i = 0; - char current; - while ((current = option_value[i]) != '\0') { - if (current == '\n' || current == ' ') { - canonicalized_list[i] = ','; - } else { - canonicalized_list[i] = current; - } - i++; - } - canonicalized_list[i] = '\0'; - return canonicalized_list; - } -}; - class PhaseNameValidator { private: CHeapBitMap _phase_name_set; @@ -192,7 +152,7 @@ class PhaseNameValidator { _valid(true), _bad(nullptr) { - for (PhaseNameIter iter(option); *iter != nullptr && _valid; ++iter) { + for (StringUtils::CommaSeparatedStringIterator iter(option); *iter != nullptr && _valid; ++iter) { CompilerPhaseType cpt = find_phase(*iter); if (PHASE_NONE == cpt) { diff --git a/src/hotspot/share/opto/regmask.hpp b/src/hotspot/share/opto/regmask.hpp index 75b3b6aa5a2..f77c14e50ea 100644 --- a/src/hotspot/share/opto/regmask.hpp +++ b/src/hotspot/share/opto/regmask.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, 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 @@ -29,6 +29,7 @@ #include "opto/optoreg.hpp" #include "utilities/count_leading_zeros.hpp" #include "utilities/count_trailing_zeros.hpp" +#include "utilities/globalDefinitions.hpp" class LRG; @@ -359,16 +360,15 @@ class RegMask { static const RegMask Empty; // Common empty mask static const RegMask All; // Common all mask - static bool can_represent(OptoReg::Name reg) { - // NOTE: -1 in computation reflects the usage of the last - // bit of the regmask as an infinite stack flag and - // -7 is to keep mask aligned for largest value (VecZ). - return (int)reg < (int)(CHUNK_SIZE - 1); + static bool can_represent(OptoReg::Name reg, unsigned int size = 1) { + // NOTE: MAX2(1U,size) in computation reflects the usage of the last + // bit of the regmask as an infinite stack flag. + return (int)reg < (int)(CHUNK_SIZE - MAX2(1U,size)); } static bool can_represent_arg(OptoReg::Name reg) { - // NOTE: -SlotsPerVecZ in computation reflects the need + // NOTE: SlotsPerVecZ in computation reflects the need // to keep mask aligned for largest value (VecZ). - return (int)reg < (int)(CHUNK_SIZE - SlotsPerVecZ); + return can_represent(reg, SlotsPerVecZ); } }; diff --git a/src/hotspot/share/opto/superword.cpp b/src/hotspot/share/opto/superword.cpp index b1d1169f357..24e7dab2e28 100644 --- a/src/hotspot/share/opto/superword.cpp +++ b/src/hotspot/share/opto/superword.cpp @@ -56,13 +56,8 @@ SuperWord::SuperWord(PhaseIdealLoop* phase) : _node_info(arena(), 8, 0, SWNodeInfo::initial), // info needed per node _clone_map(phase->C->clone_map()), // map of nodes created in cloning _align_to_ref(nullptr), // memory reference to align vectors to - _disjoint_ptrs(arena(), 8, 0, OrderedPair::initial), // runtime disambiguated pointer pairs _dg(_arena), // dependence graph - _visited(arena()), // visited node set - _post_visited(arena()), // post visited node set - _n_idx_list(arena(), 8), // scratch list of (node,index) pairs _nlist(arena(), 8, 0, nullptr), // scratch list of nodes - _stk(arena(), 8, 0, nullptr), // scratch stack of nodes _lpt(nullptr), // loop tree node _lp(nullptr), // CountedLoopNode _loop_reductions(arena()), // reduction nodes in the current loop @@ -74,13 +69,6 @@ SuperWord::SuperWord(PhaseIdealLoop* phase) : _num_work_vecs(0), // amount of vector work we have _num_reductions(0) // amount of reduction work we have { -#ifndef PRODUCT - _vector_loop_debug = 0; - if (_phase->C->method() != nullptr) { - _vector_loop_debug = phase->C->directive()->VectorizeDebugOption; - } - -#endif } //------------------------------transform_loop--------------------------- @@ -120,7 +108,7 @@ bool SuperWord::transform_loop(IdealLoopTree* lpt, bool do_optimization) { Node *cl_exit = cl->loopexit(); if (cl->is_main_loop() && (cl_exit->in(0) != lpt->_head)) { #ifndef PRODUCT - if (TraceSuperWord) { + if (is_trace_superword_precondition()) { tty->print_cr("SuperWord::transform_loop: loop too complicated, cl_exit->in(0) != lpt->_head"); tty->print("cl_exit %d", cl_exit->_idx); cl_exit->dump(); tty->print("cl_exit->in(0) %d", cl_exit->in(0)->_idx); cl_exit->in(0)->dump(); @@ -182,14 +170,13 @@ void SuperWord::unrolling_analysis(int &local_loop_unroll_factor) { ignored_loop_nodes[i] = -1; } - int max_vector = Matcher::superword_max_vector_size(T_BYTE); + int max_vector = Matcher::max_vector_size_auto_vectorization(T_BYTE); // Process the loop, some/all of the stack entries will not be in order, ergo // need to preprocess the ignored initial state before we process the loop for (uint i = 0; i < lpt()->_body.size(); i++) { Node* n = lpt()->_body.at(i); if (n == cl->incr() || - is_marked_reduction(n) || n->is_AddP() || n->is_Cmp() || n->is_Bool() || @@ -296,15 +283,17 @@ void SuperWord::unrolling_analysis(int &local_loop_unroll_factor) { if (is_java_primitive(bt) == false) continue; - int cur_max_vector = Matcher::superword_max_vector_size(bt); + int cur_max_vector = Matcher::max_vector_size_auto_vectorization(bt); // If a max vector exists which is not larger than _local_loop_unroll_factor // stop looking, we already have the max vector to map to. if (cur_max_vector < local_loop_unroll_factor) { is_slp = false; +#ifndef PRODUCT if (TraceSuperWordLoopUnrollAnalysis) { tty->print_cr("slp analysis fails: unroll limit greater than max vector\n"); } +#endif break; } @@ -351,6 +340,11 @@ void SuperWord::unrolling_analysis(int &local_loop_unroll_factor) { } cl->mark_was_slp(); if (cl->is_main_loop()) { +#ifndef PRODUCT + if (TraceSuperWordLoopUnrollAnalysis) { + tty->print_cr("slp analysis: set max unroll to %d", local_loop_unroll_factor); + } +#endif cl->set_slp_max_unroll(local_loop_unroll_factor); } } @@ -524,19 +518,6 @@ void SuperWord::mark_reductions() { // extraction of scalar values from vectors. // bool SuperWord::SLP_extract() { - -#ifndef PRODUCT - if (_do_vector_loop && TraceSuperWord) { - tty->print("SuperWord::SLP_extract\n"); - tty->print("input loop\n"); - _lpt->dump_head(); - _lpt->dump(); - for (uint i = 0; i < _lpt->_body.size(); i++) { - _lpt->_body.at(i)->dump(); - } - } -#endif - CountedLoopNode* cl = lpt()->_head->as_CountedLoop(); assert(cl->is_main_loop(), "SLP should only work on main loops"); @@ -545,7 +526,7 @@ bool SuperWord::SLP_extract() { return false; // Exit if no interesting nodes or complex graph. } - // build _dg, _disjoint_ptrs + // build _dg dependence_graph(); // compute function depth(Node*) @@ -559,7 +540,7 @@ bool SuperWord::SLP_extract() { if (_packset.length() == 0) { #ifndef PRODUCT - if (TraceSuperWord) { + if (is_trace_superword_any()) { tty->print_cr("\nNo pair packs generated, abort SuperWord."); tty->cr(); } @@ -602,9 +583,11 @@ void SuperWord::find_adjacent_refs() { } } } - if (TraceSuperWord) { +#ifndef PRODUCT + if (is_trace_superword_adjacent_memops()) { tty->print_cr("\nfind_adjacent_refs found %d memops", memops.size()); } +#endif int max_idx; @@ -672,8 +655,8 @@ void SuperWord::find_adjacent_refs() { "packset empty or we find the alignment reference"); #ifndef PRODUCT - if (TraceSuperWord) { - tty->print_cr("\nAfter find_adjacent_refs"); + if (is_trace_superword_packset()) { + tty->print_cr("\nAfter Superword::find_adjacent_refs"); print_packset(); } #endif @@ -755,8 +738,8 @@ MemNode* SuperWord::find_align_to_ref(Node_List &memops, int &idx) { } } -#ifdef ASSERT - if (TraceSuperWord && Verbose) { +#ifndef PRODUCT + if (is_trace_superword_verbose()) { tty->print_cr("\nVector memops after find_align_to_ref"); for (uint i = 0; i < memops.size(); i++) { MemNode* s = memops.at(i)->as_Mem(); @@ -767,9 +750,9 @@ MemNode* SuperWord::find_align_to_ref(Node_List &memops, int &idx) { idx = max_idx; if (max_ct > 0) { -#ifdef ASSERT - if (TraceSuperWord) { - tty->print("\nVector align to node: "); +#ifndef PRODUCT + if (is_trace_superword_adjacent_memops()) { + tty->print("SuperWord::find_align_to_ref: "); memops.at(max_idx)->as_Mem()->dump(); } #endif @@ -794,13 +777,13 @@ int SuperWord::get_vw_bytes_special(MemNode* s) { } } if (should_combine_adjacent) { - vw = MIN2(Matcher::superword_max_vector_size(btype)*type2aelembytes(btype), vw * 2); + vw = MIN2(Matcher::max_vector_size_auto_vectorization(btype)*type2aelembytes(btype), vw * 2); } } // Check for special case where there is a type conversion between different data size. int vectsize = max_vector_size_in_def_use_chain(s); - if (vectsize < Matcher::superword_max_vector_size(btype)) { + if (vectsize < Matcher::max_vector_size_auto_vectorization(btype)) { vw = MIN2(vectsize * type2aelembytes(btype), vw); } @@ -830,7 +813,7 @@ int SuperWord::get_iv_adjustment(MemNode* mem_ref) { } #ifndef PRODUCT - if (TraceSuperWord) { + if (is_trace_superword_alignment()) { tty->print("SuperWord::get_iv_adjustment: n = %d, noffset = %d iv_adjust = %d elt_size = %d scale = %d iv_stride = %d vect_size %d: ", mem_ref->_idx, offset, iv_adjustment, elt_size, scale, iv_stride(), vw); mem_ref->dump(); @@ -863,14 +846,6 @@ void SuperWord::dependence_graph() { // Get slice in predecessor order (last is first) mem_slice_preds(n_tail, n, _nlist); -#ifndef PRODUCT - if(TraceSuperWord && Verbose) { - tty->print_cr("SuperWord::dependence_graph: built a new mem slice"); - for (int j = _nlist.length() - 1; j >= 0 ; j--) { - _nlist.at(j)->dump(); - } - } -#endif // Make the slice dependent on the root DepMem* slice = _dg.dep(n); _dg.make_edge(_dg.root(), slice); @@ -896,12 +871,6 @@ void SuperWord::dependence_graph() { VPointer p2(s2->as_Mem(), phase(), lpt(), nullptr, false); int cmp = p1.cmp(p2); - if (SuperWordRTDepCheck && - p1.base() != p2.base() && p1.valid() && p2.valid()) { - // Trace disjoint pointers - OrderedPair pp(p1.base(), p2.base()); - _disjoint_ptrs.append_if_missing(pp); - } if (!VPointer::not_equal(cmp)) { // Possibly same address _dg.make_edge(s1, s2); @@ -913,26 +882,18 @@ void SuperWord::dependence_graph() { } } - if (TraceSuperWord) { +#ifndef PRODUCT + if (is_trace_superword_dependence_graph()) { tty->print_cr("\nDependence graph for slice: %d", n->_idx); for (int q = 0; q < _nlist.length(); q++) { _dg.print(_nlist.at(q)); } tty->cr(); } +#endif _nlist.clear(); } - - if (TraceSuperWord) { - tty->print_cr("\ndisjoint_ptrs: %s", _disjoint_ptrs.length() > 0 ? "" : "NONE"); - for (int r = 0; r < _disjoint_ptrs.length(); r++) { - _disjoint_ptrs.at(r).print(); - tty->cr(); - } - tty->cr(); - } - } //---------------------------mem_slice_preds--------------------------- @@ -942,16 +903,12 @@ void SuperWord::mem_slice_preds(Node* start, Node* stop, GrowableArray &p Node* n = start; Node* prev = nullptr; while (true) { - NOT_PRODUCT( if(is_trace_mem_slice()) tty->print_cr("SuperWord::mem_slice_preds: n %d", n->_idx);) assert(in_bb(n), "must be in block"); for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) { Node* out = n->fast_out(i); if (out->is_Load()) { if (in_bb(out)) { preds.push(out); - if (TraceSuperWord && Verbose) { - tty->print_cr("SuperWord::mem_slice_preds: added pred(%d)", out->_idx); - } } } else { // FIXME @@ -970,13 +927,20 @@ void SuperWord::mem_slice_preds(Node* start, Node* stop, GrowableArray &p }//for if (n == stop) break; preds.push(n); - if (TraceSuperWord && Verbose) { - tty->print_cr("SuperWord::mem_slice_preds: added pred(%d)", n->_idx); - } prev = n; assert(n->is_Mem(), "unexpected node %s", n->Name()); n = n->in(MemNode::Memory); } + +#ifndef PRODUCT + if (is_trace_superword_memory_slices()) { + tty->print_cr("\nSuperWord::mem_slice_preds:"); + stop->dump(); + for (int j = preds.length() - 1; j >= 0 ; j--) { + preds.at(j)->dump(); + } + } +#endif } //------------------------------stmts_can_pack--------------------------- @@ -990,8 +954,8 @@ bool SuperWord::stmts_can_pack(Node* s1, Node* s2, int align) { if(!is_java_primitive(bt1) || !is_java_primitive(bt2)) return false; BasicType longer_bt = longer_type_for_conversion(s1); - if (Matcher::superword_max_vector_size(bt1) < 2 || - (longer_bt != T_ILLEGAL && Matcher::superword_max_vector_size(longer_bt) < 2)) { + if (Matcher::max_vector_size_auto_vectorization(bt1) < 2 || + (longer_bt != T_ILLEGAL && Matcher::max_vector_size_auto_vectorization(longer_bt) < 2)) { return false; // No vectors for this type } @@ -1077,54 +1041,71 @@ bool SuperWord::isomorphic(Node* s1, Node* s2) { //------------------------------independent--------------------------- // Is there no data path from s1 to s2 or s2 to s1? bool SuperWord::independent(Node* s1, Node* s2) { - // assert(s1->Opcode() == s2->Opcode(), "check isomorphic first"); int d1 = depth(s1); int d2 = depth(s2); - if (d1 == d2) return s1 != s2; + + if (d1 == d2) { + // Same depth: + // 1) same node -> dependent + // 2) different nodes -> same level implies there is no path + return s1 != s2; + } + + // Traversal starting at the deeper node to find the shallower one. Node* deep = d1 > d2 ? s1 : s2; Node* shallow = d1 > d2 ? s2 : s1; + int min_d = MIN2(d1, d2); // prune traversal at min_d - visited_clear(); - - return independent_path(shallow, deep); + ResourceMark rm; + Unique_Node_List worklist; + worklist.push(deep); + for (uint i = 0; i < worklist.size(); i++) { + Node* n = worklist.at(i); + for (DepPreds preds(n, _dg); !preds.done(); preds.next()) { + Node* pred = preds.current(); + if (in_bb(pred) && depth(pred) >= min_d) { + if (pred == shallow) { + return false; // found it -> dependent + } + worklist.push(pred); + } + } + } + return true; // not found -> independent } -//------------------------------find_dependence--------------------- -// Is any s1 in p dependent on any s2 in p? Yes: return such a s2. No: return nullptr. +// Are all nodes in nodes list mutually independent? // We could query independent(s1, s2) for all pairs, but that results -// in O(p.size * p.size) graph traversals. We can do it all in one BFS! -// Start the BFS traversal at all nodes from the pack. Traverse DepPreds -// recursively, for nodes that have at least depth min_d, which is the -// smallest depth of all nodes from the pack. Once we have traversed all -// those nodes, and have not found another node from the pack, we know -// that all nodes in the pack are independent. -Node* SuperWord::find_dependence(Node_List* p) { - if (is_marked_reduction(p->at(0))) { - return nullptr; // ignore reductions - } +// in O(size * size) graph traversals. We can do it all in one BFS! +// Start the BFS traversal at all nodes from the nodes list. Traverse +// Preds recursively, for nodes that have at least depth min_d, which +// is the smallest depth of all nodes from the nodes list. Once we have +// traversed all those nodes, and have not found another node from the +// nodes list, we know that all nodes in the nodes list are independent. +bool SuperWord::mutually_independent(Node_List* nodes) const { ResourceMark rm; - Unique_Node_List worklist; // traversal queue - int min_d = depth(p->at(0)); - visited_clear(); - for (uint k = 0; k < p->size(); k++) { - Node* n = p->at(k); + Unique_Node_List worklist; + VectorSet nodes_set; + int min_d = depth(nodes->at(0)); + for (uint k = 0; k < nodes->size(); k++) { + Node* n = nodes->at(k); min_d = MIN2(min_d, depth(n)); - worklist.push(n); // start traversal at all nodes in p - visited_set(n); // mark node + worklist.push(n); // start traversal at all nodes in nodes list + nodes_set.set(bb_idx(n)); } for (uint i = 0; i < worklist.size(); i++) { Node* n = worklist.at(i); for (DepPreds preds(n, _dg); !preds.done(); preds.next()) { Node* pred = preds.current(); if (in_bb(pred) && depth(pred) >= min_d) { - if (visited_test(pred)) { // marked as in p? - return pred; + if (nodes_set.test(bb_idx(pred))) { + return false; // found one -> dependent } worklist.push(pred); } } } - return nullptr; + return true; // not found -> independent } //--------------------------have_similar_inputs----------------------- @@ -1172,27 +1153,6 @@ bool SuperWord::reduction(Node* s1, Node* s2) { return retValue; } -//------------------------------independent_path------------------------------ -// Helper for independent -bool SuperWord::independent_path(Node* shallow, Node* deep, uint dp) { - if (dp >= 1000) return false; // stop deep recursion - visited_set(deep); - int shal_depth = depth(shallow); - assert(shal_depth <= depth(deep), "must be"); - for (DepPreds preds(deep, _dg); !preds.done(); preds.next()) { - Node* pred = preds.current(); - if (in_bb(pred) && !visited_test(pred)) { - if (shallow == pred) { - return false; - } - if (shal_depth < depth(pred) && !independent_path(shallow, pred, dp+1)) { - return false; - } - } - } - return true; -} - //------------------------------set_alignment--------------------------- void SuperWord::set_alignment(Node* s1, Node* s2, int align) { set_alignment(s1, align); @@ -1231,10 +1191,12 @@ void SuperWord::extend_packlist() { } } - if (TraceSuperWord) { - tty->print_cr("\nAfter extend_packlist"); +#ifndef PRODUCT + if (is_trace_superword_packset()) { + tty->print_cr("\nAfter Superword::extend_packlist"); print_packset(); } +#endif } //------------------------------adjust_alignment_for_type_conversion--------------------------------- @@ -1264,7 +1226,12 @@ bool SuperWord::follow_use_defs(Node_List* p) { if (s1->is_Load()) return false; - NOT_PRODUCT(if(is_trace_alignment()) tty->print_cr("SuperWord::follow_use_defs: s1 %d, align %d", s1->_idx, alignment(s1));) +#ifndef PRODUCT + if (is_trace_superword_alignment()) { + tty->print_cr("SuperWord::follow_use_defs: s1 %d, align %d", + s1->_idx, alignment(s1)); + } +#endif bool changed = false; int start = s1->is_Store() ? MemNode::ValueIn : 1; int end = s1->is_Store() ? MemNode::ValueIn+1 : s1->req(); @@ -1283,7 +1250,12 @@ bool SuperWord::follow_use_defs(Node_List* p) { pair->push(t1); pair->push(t2); _packset.append(pair); - NOT_PRODUCT(if(is_trace_alignment()) tty->print_cr("SuperWord::follow_use_defs: set_alignment(%d, %d, %d)", t1->_idx, t2->_idx, align);) +#ifndef PRODUCT + if (is_trace_superword_alignment()) { + tty->print_cr("SuperWord::follow_use_defs: set_alignment(%d, %d, %d)", + t1->_idx, t2->_idx, align); + } +#endif set_alignment(t1, t2, align); changed = true; } @@ -1305,7 +1277,12 @@ bool SuperWord::follow_def_uses(Node_List* p) { if (s1->is_Store()) return false; int align = alignment(s1); - NOT_PRODUCT(if(is_trace_alignment()) tty->print_cr("SuperWord::follow_def_uses: s1 %d, align %d", s1->_idx, align);) +#ifndef PRODUCT + if (is_trace_superword_alignment()) { + tty->print_cr("SuperWord::follow_def_uses: s1 %d, align %d", + s1->_idx, align); + } +#endif int savings = -1; int num_s1_uses = 0; Node* u1 = nullptr; @@ -1347,7 +1324,12 @@ bool SuperWord::follow_def_uses(Node_List* p) { pair->push(u1); pair->push(u2); _packset.append(pair); - NOT_PRODUCT(if(is_trace_alignment()) tty->print_cr("SuperWord::follow_def_uses: set_alignment(%d, %d, %d)", u1->_idx, u2->_idx, align);) +#ifndef PRODUCT + if (is_trace_superword_alignment()) { + tty->print_cr("SuperWord::follow_def_uses: set_alignment(%d, %d, %d)", + u1->_idx, u2->_idx, align); + } +#endif set_alignment(u1, u2, align); changed = true; } @@ -1538,7 +1520,7 @@ void SuperWord::combine_packs() { if (!is_power_of_2(psize)) { // We currently only support power-of-2 sizes for vectors. #ifndef PRODUCT - if (TraceSuperWord) { + if (is_trace_superword_rejections()) { tty->cr(); tty->print_cr("WARNING: Removed pack[%d] with size that is not a power of 2:", i); print_pack(p1); @@ -1585,13 +1567,13 @@ void SuperWord::combine_packs() { for (int i = 0; i < _packset.length(); i++) { Node_List* p = _packset.at(i); if (p != nullptr) { - Node* dependence = find_dependence(p); - if (dependence != nullptr) { + // reductions are trivially connected + if (!is_marked_reduction(p->at(0)) && + !mutually_independent(p)) { #ifndef PRODUCT - if (TraceSuperWord) { + if (is_trace_superword_rejections()) { tty->cr(); tty->print_cr("WARNING: Found dependency at distance greater than 1."); - dependence->dump(); tty->print_cr("In pack[%d]", i); print_pack(p); } @@ -1605,8 +1587,8 @@ void SuperWord::combine_packs() { compress_packset(); #ifndef PRODUCT - if (TraceSuperWord) { - tty->print_cr("\nAfter combine_packs"); + if (is_trace_superword_packset()) { + tty->print_cr("\nAfter Superword::combine_packs"); print_packset(); } #endif @@ -1646,8 +1628,8 @@ void SuperWord::filter_packs_for_alignment() { } #ifndef PRODUCT - if (TraceSuperWord || is_trace_align_vector()) { - tty->print_cr("\nfilter_packs_for_alignment:"); + if (is_trace_superword_info() || is_trace_align_vector()) { + tty->print_cr("\nSuperWord::filter_packs_for_alignment:"); } #endif @@ -1677,6 +1659,12 @@ void SuperWord::filter_packs_for_alignment() { if (intersect->is_empty()) { // Solution failed or is not compatible, remove pack i. +#ifndef PRODUCT + if (is_trace_superword_rejections() || is_trace_align_vector()) { + tty->print_cr("Rejected by AlignVector:"); + p->at(0)->dump(); + } +#endif _packset.at_put(i, nullptr); mem_ops_rejected++; } else { @@ -1688,7 +1676,7 @@ void SuperWord::filter_packs_for_alignment() { } #ifndef PRODUCT - if (TraceSuperWord || is_trace_align_vector()) { + if (is_trace_superword_info() || is_trace_align_vector()) { tty->print("\n final solution: "); current->print(); tty->print_cr(" rejected mem_ops packs: %d of %d", mem_ops_rejected, mem_ops_count); @@ -1705,6 +1693,13 @@ void SuperWord::filter_packs_for_alignment() { // Remove all nullptr from packset compress_packset(); + +#ifndef PRODUCT + if (is_trace_superword_packset() || is_trace_align_vector()) { + tty->print_cr("\nAfter Superword::filter_packs_for_alignment"); + print_packset(); + } +#endif } // Compress packset, such that it has no nullptr entries @@ -1750,7 +1745,7 @@ void SuperWord::filter_packs() { bool impl = implemented(pk); if (!impl) { #ifndef PRODUCT - if ((TraceSuperWord && Verbose) || _vector_loop_debug) { + if (is_trace_superword_rejections()) { tty->print_cr("Unimplemented"); pk->at(0)->dump(); } @@ -1774,7 +1769,7 @@ void SuperWord::filter_packs() { bool prof = profitable(pk); if (!prof) { #ifndef PRODUCT - if ((TraceSuperWord && Verbose) || _vector_loop_debug) { + if (is_trace_superword_rejections()) { tty->print_cr("Unprofitable"); pk->at(0)->dump(); } @@ -1786,8 +1781,8 @@ void SuperWord::filter_packs() { } while (changed); #ifndef PRODUCT - if (TraceSuperWord) { - tty->print_cr("\nAfter filter_packs"); + if (is_trace_superword_packset()) { + tty->print_cr("\nAfter Superword::filter_packs"); print_packset(); tty->cr(); } @@ -1974,24 +1969,16 @@ void SuperWord::verify_packs() { // Verify independence at pack level. for (int i = 0; i < _packset.length(); i++) { Node_List* p = _packset.at(i); - Node* dependence = find_dependence(p); - if (dependence != nullptr) { - tty->print_cr("Other nodes in pack have dependence on:"); - dependence->dump(); - tty->print_cr("The following nodes are not independent:"); - for (uint k = 0; k < p->size(); k++) { - Node* n = p->at(k); - if (!independent(n, dependence)) { - n->dump(); - } - } - tty->print_cr("They are all from pack[%d]", i); + if (!is_marked_reduction(p->at(0)) && + !mutually_independent(p)) { + tty->print_cr("FAILURE: nodes not mutually independent in pack[%d]", i); print_pack(p); + assert(false, "pack nodes not mutually independent"); } - assert(dependence == nullptr, "all nodes in pack must be mutually independent"); } // Verify all nodes in packset have my_pack set correctly. + ResourceMark rm; Unique_Node_List processed; for (int i = 0; i < _packset.length(); i++) { Node_List* p = _packset.at(i); @@ -2269,17 +2256,19 @@ void SuperWord::schedule() { // introduced a cycle. The SuperWord paper mentions the need for this // in "3.7 Scheduling". if (!graph.schedule_success()) { - if (TraceSuperWord) { +#ifndef PRODUCT + if (is_trace_superword_rejections()) { tty->print_cr("SuperWord::schedule found cycle in PacksetGraph:"); graph.print(true, false); tty->print_cr("removing all packs from packset."); } +#endif _packset.clear(); return; } #ifndef PRODUCT - if (TraceSuperWord) { + if (is_trace_superword_info()) { tty->print_cr("SuperWord::schedule: memops_schedule:"); memops_schedule.dump(); } @@ -2399,10 +2388,7 @@ bool SuperWord::output() { adjust_pre_loop_limit_to_align_main_loop_vectors(); - // Insert extract (unpack) operations for scalar uses - for (int i = 0; i < _packset.length(); i++) { - insert_extracts(_packset.at(i)); - } + DEBUG_ONLY(verify_no_extract()); uint max_vlen_in_bytes = 0; uint max_vlen = 0; @@ -2418,7 +2404,6 @@ bool SuperWord::output() { uint vlen = p->size(); uint vlen_in_bytes = 0; Node* vn = nullptr; - NOT_PRODUCT(if(is_trace_cmov()) {tty->print_cr("VPointer::output: %d executed first, %d executed last in pack", first->_idx, n->_idx); print_pack(p);}) int opc = n->Opcode(); if (n->is_Load()) { Node* ctl = n->in(MemNode::Control); @@ -2711,9 +2696,11 @@ bool SuperWord::output() { if (cl->has_passed_slp()) { uint slp_max_unroll_factor = cl->slp_max_unroll(); if (slp_max_unroll_factor == max_vlen) { +#ifndef PRODUCT if (TraceSuperWordLoopUnrollAnalysis) { tty->print_cr("vector loop(unroll=%d, len=%d)\n", max_vlen, max_vlen_in_bytes*BitsPerByte); } +#endif // For atomic unrolled loops which are vector mapped, instigate more unrolling cl->set_notpassed_slp(); // if vector resources are limited, do not allow additional unrolling @@ -2853,55 +2840,35 @@ Node* SuperWord::vector_opd(Node_List* p, int opd_idx) { return pk; } -//------------------------------insert_extracts--------------------------- -// If a use of pack p is not a vector use, then replace the -// use with an extract operation. -void SuperWord::insert_extracts(Node_List* p) { - if (p->at(0)->is_Store()) return; - assert(_n_idx_list.is_empty(), "empty (node,index) list"); +#ifdef ASSERT +// We check that every packset (name it p_def) only has vector uses (p_use), +// which are proper vector uses of def. +void SuperWord::verify_no_extract() { + for (int i = 0; i < _packset.length(); i++) { + Node_List* p_def = _packset.at(i); - // Inspect each use of each pack member. For each use that is - // not a vector use, replace the use with an extract operation. + // A vector store has no uses + if (p_def->at(0)->is_Store()) { continue; } - for (uint i = 0; i < p->size(); i++) { - Node* def = p->at(i); - for (DUIterator_Fast jmax, j = def->fast_outs(jmax); j < jmax; j++) { - Node* use = def->fast_out(j); - for (uint k = 0; k < use->req(); k++) { - Node* n = use->in(k); - if (def == n) { - Node_List* u_pk = my_pack(use); - if ((u_pk == nullptr || use->is_CMove()) && !is_vector_use(use, k)) { - _n_idx_list.push(use, k); + // for every def in p_def, and every use: + for (uint i = 0; i < p_def->size(); i++) { + Node* def = p_def->at(i); + for (DUIterator_Fast jmax, j = def->fast_outs(jmax); j < jmax; j++) { + Node* use = def->fast_out(j); + // find every use->def edge: + for (uint k = 0; k < use->req(); k++) { + Node* maybe_def = use->in(k); + if (def == maybe_def) { + Node_List* p_use = my_pack(use); + if (is_marked_reduction(def)) { continue; } + assert(p_use != nullptr && is_vector_use(use, k), "all uses must be vector uses"); } } } } } - - while (_n_idx_list.is_nonempty()) { - Node* use = _n_idx_list.node(); - int idx = _n_idx_list.index(); - _n_idx_list.pop(); - Node* def = use->in(idx); - - if (is_marked_reduction(def)) continue; - - // Insert extract operation - _igvn.hash_delete(def); - int def_pos = alignment(def) / data_size(def); - - ConINode* def_pos_con = _igvn.intcon(def_pos)->as_ConI(); - Node* ex = ExtractNode::make(def, def_pos_con, velt_basic_type(def)); - _igvn.register_new_node_with_optimizer(ex); - _phase->set_ctrl(ex, _phase->get_ctrl(def)); - _igvn.replace_input_of(use, idx, ex); - _igvn._worklist.push(def); - - bb_insert_after(ex, bb_idx(def)); - set_velt_type(ex, velt_type(def)); - } } +#endif //------------------------------is_vector_use--------------------------- // Is use->in(u_idx) a vector use? @@ -2985,7 +2952,6 @@ bool SuperWord::is_vector_use(Node* use, int u_idx) { bool SuperWord::construct_bb() { Node* entry = bb(); - assert(_stk.length() == 0, "stk is empty"); assert(_block.length() == 0, "block is empty"); assert(_data_entry.length() == 0, "data_entry is empty"); assert(_mem_slice_head.length() == 0, "mem_slice_head is empty"); @@ -3042,55 +3008,57 @@ bool SuperWord::construct_bb() { // Create an RPO list of nodes in block - visited_clear(); - post_visited_clear(); + ResourceMark rm; + GrowableArray stack; + VectorSet visited; + VectorSet post_visited; // Push all non-control nodes with no inputs from within block, then control entry for (int j = 0; j < _data_entry.length(); j++) { Node* n = _data_entry.at(j); - visited_set(n); - _stk.push(n); + visited.set(bb_idx(n)); + stack.push(n); } - visited_set(entry); - _stk.push(entry); + visited.set(bb_idx(entry)); + stack.push(entry); // Do a depth first walk over out edges int rpo_idx = bb_ct - 1; int size; int reduction_uses = 0; - while ((size = _stk.length()) > 0) { - Node* n = _stk.top(); // Leave node on stack - if (!visited_test_set(n)) { + while ((size = stack.length()) > 0) { + Node* n = stack.top(); // Leave node on stack + if (!visited.test_set(bb_idx(n))) { // forward arc in graph - } else if (!post_visited_test(n)) { + } else if (!post_visited.test(bb_idx(n))) { // cross or back arc for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) { Node *use = n->fast_out(i); - if (in_bb(use) && !visited_test(use) && + if (in_bb(use) && !visited.test(bb_idx(use)) && // Don't go around backedge (!use->is_Phi() || n == entry)) { if (is_marked_reduction(use)) { // First see if we can map the reduction on the given system we are on, then // make a data entry operation for each reduction we see. BasicType bt = use->bottom_type()->basic_type(); - if (ReductionNode::implemented(use->Opcode(), Matcher::superword_max_vector_size(bt), bt)) { + if (ReductionNode::implemented(use->Opcode(), Matcher::max_vector_size_auto_vectorization(bt), bt)) { reduction_uses++; } } - _stk.push(use); + stack.push(use); } } - if (_stk.length() == size) { + if (stack.length() == size) { // There were no additional uses, post visit node now - _stk.pop(); // Remove node from stack + stack.pop(); // Remove node from stack assert(rpo_idx >= 0, ""); _block.at_put_grow(rpo_idx, n); rpo_idx--; - post_visited_set(n); - assert(rpo_idx >= 0 || _stk.is_empty(), ""); + post_visited.set(bb_idx(n)); + assert(rpo_idx >= 0 || stack.is_empty(), ""); } } else { - _stk.pop(); // Remove post-visited node from stack + stack.pop(); // Remove post-visited node from stack } }//while @@ -3106,13 +3074,15 @@ bool SuperWord::construct_bb() { initialize_bb(); #ifndef PRODUCT - if (TraceSuperWord) { + if (is_trace_superword_info()) { print_bb(); tty->print_cr("\ndata entry nodes: %s", _data_entry.length() > 0 ? "" : "NONE"); for (int m = 0; m < _data_entry.length(); m++) { tty->print("%3d ", m); _data_entry.at(m)->dump(); } + } + if (is_trace_superword_memory_slices()) { tty->print_cr("\nmemory slices: %s", _mem_slice_head.length() > 0 ? "" : "NONE"); for (int m = 0; m < _mem_slice_head.length(); m++) { tty->print("%3d ", m); _mem_slice_head.at(m)->dump(); @@ -3179,9 +3149,11 @@ void SuperWord::compute_max_depth() { ct++; } while (again); - if (TraceSuperWord && Verbose) { +#ifndef PRODUCT + if (is_trace_superword_dependence_graph()) { tty->print_cr("compute_max_depth iterated: %d times", ct); } +#endif } BasicType SuperWord::longer_type_for_conversion(Node* n) { @@ -3227,10 +3199,10 @@ int SuperWord::max_vector_size_in_def_use_chain(Node* n) { vt = (newt == T_ILLEGAL) ? vt : newt; } - int max = Matcher::superword_max_vector_size(vt); + int max = Matcher::max_vector_size_auto_vectorization(vt); // If now there is no vectors for the longest type, the nodes with the longest // type in the def-use chain are not packed in SuperWord::stmts_can_pack. - return max < 2 ? Matcher::superword_max_vector_size(bt) : max; + return max < 2 ? Matcher::max_vector_size_auto_vectorization(bt) : max; } //-------------------------compute_vector_element_type----------------------- @@ -3241,9 +3213,11 @@ int SuperWord::max_vector_size_in_def_use_chain(Node* n) { // Normally the type of the add is integer, but for packed character // operations the type of the add needs to be char. void SuperWord::compute_vector_element_type() { - if (TraceSuperWord && Verbose) { +#ifndef PRODUCT + if (is_trace_superword_vector_element_type()) { tty->print_cr("\ncompute_velt_type:"); } +#endif // Initial type for (int i = 0; i < _block.length(); i++) { @@ -3319,7 +3293,7 @@ void SuperWord::compute_vector_element_type() { } } #ifndef PRODUCT - if (TraceSuperWord && Verbose) { + if (is_trace_superword_vector_element_type()) { for (int i = 0; i < _block.length(); i++) { Node* n = _block.at(i); velt_type(n)->dump(); @@ -3334,18 +3308,18 @@ void SuperWord::compute_vector_element_type() { // Alignment within a vector memory reference int SuperWord::memory_alignment(MemNode* s, int iv_adjust) { #ifndef PRODUCT - if ((TraceSuperWord && Verbose) || is_trace_alignment()) { + if (is_trace_superword_alignment()) { tty->print("SuperWord::memory_alignment within a vector memory reference for %d: ", s->_idx); s->dump(); } #endif VPointer p(s, phase(), lpt(), nullptr, false); if (!p.valid()) { - NOT_PRODUCT(if(is_trace_alignment()) tty->print_cr("VPointer::memory_alignment: VPointer p invalid, return bottom_align");) + NOT_PRODUCT(if(is_trace_superword_alignment()) tty->print_cr("SuperWord::memory_alignment: VPointer p invalid, return bottom_align");) return bottom_align; } int vw = get_vw_bytes_special(s); if (vw < 2) { - NOT_PRODUCT(if(is_trace_alignment()) tty->print_cr("VPointer::memory_alignment: vector_width_in_bytes < 2, return bottom_align");) + NOT_PRODUCT(if(is_trace_superword_alignment()) tty->print_cr("SuperWord::memory_alignment: vector_width_in_bytes < 2, return bottom_align");) return bottom_align; // No vectors for this type } int offset = p.offset_in_bytes(); @@ -3353,8 +3327,8 @@ int SuperWord::memory_alignment(MemNode* s, int iv_adjust) { int off_rem = offset % vw; int off_mod = off_rem >= 0 ? off_rem : off_rem + vw; #ifndef PRODUCT - if ((TraceSuperWord && Verbose) || is_trace_alignment()) { - tty->print_cr("VPointer::memory_alignment: off_rem = %d, off_mod = %d (offset = %d)", off_rem, off_mod, offset); + if (is_trace_superword_alignment()) { + tty->print_cr("SuperWord::memory_alignment: off_rem = %d, off_mod = %d (offset = %d)", off_rem, off_mod, offset); } #endif return off_mod; @@ -3801,7 +3775,6 @@ void SuperWord::adjust_pre_loop_limit_to_align_main_loop_vectors() { void SuperWord::init() { _dg.init(); _packset.clear(); - _disjoint_ptrs.clear(); _block.clear(); _data_entry.clear(); _mem_slice_head.clear(); @@ -3859,10 +3832,6 @@ void SuperWord::print_stmt(Node* s) { #endif } -// ========================= OrderedPair ===================== - -const OrderedPair OrderedPair::initial; - // ========================= SWNodeInfo ===================== const SWNodeInfo SWNodeInfo::initial; diff --git a/src/hotspot/share/opto/superword.hpp b/src/hotspot/share/opto/superword.hpp index db7101b26cb..c0a9c98858b 100644 --- a/src/hotspot/share/opto/superword.hpp +++ b/src/hotspot/share/opto/superword.hpp @@ -57,7 +57,6 @@ // second statement is considered the right element. class VPointer; -class OrderedPair; // ========================= Dependence Graph ===================== @@ -198,33 +197,6 @@ class SWNodeInfo { static const SWNodeInfo initial; }; -class SuperWord; - -// JVMCI: OrderedPair is moved up to deal with compilation issues on Windows -//------------------------------OrderedPair--------------------------- -// Ordered pair of Node*. -class OrderedPair { - protected: - Node* _p1; - Node* _p2; - public: - OrderedPair() : _p1(nullptr), _p2(nullptr) {} - OrderedPair(Node* p1, Node* p2) { - if (p1->_idx < p2->_idx) { - _p1 = p1; _p2 = p2; - } else { - _p1 = p2; _p2 = p1; - } - } - - bool operator==(const OrderedPair &rhs) { - return _p1 == rhs._p1 && _p2 == rhs._p2; - } - void print() { tty->print(" (%d, %d)", _p1->_idx, _p2->_idx); } - - static const OrderedPair initial; -}; - // -----------------------------SuperWord--------------------------------- // Transforms scalar operations into packed (superword) operations. class SuperWord : public ResourceObj { @@ -249,16 +221,10 @@ class SuperWord : public ResourceObj { CloneMap& _clone_map; // map of nodes created in cloning MemNode const* _align_to_ref; // Memory reference that pre-loop will align to - GrowableArray _disjoint_ptrs; // runtime disambiguated pointer pairs - DepGraph _dg; // Dependence graph // Scratch pads - VectorSet _visited; // Visited set - VectorSet _post_visited; // Post-visited set - Node_Stack _n_idx_list; // List of (node,index) pairs GrowableArray _nlist; // List of nodes - GrowableArray _stk; // Stack of nodes public: SuperWord(PhaseIdealLoop* phase); @@ -275,14 +241,78 @@ class SuperWord : public ResourceObj { bool early_return() const { return _early_return; } #ifndef PRODUCT - bool is_debug() { return _vector_loop_debug > 0; } - bool is_trace_alignment() { return (_vector_loop_debug & 2) > 0; } - bool is_trace_mem_slice() { return (_vector_loop_debug & 4) > 0; } - bool is_trace_loop() { return (_vector_loop_debug & 8) > 0; } - bool is_trace_adjacent() { return (_vector_loop_debug & 16) > 0; } - bool is_trace_cmov() { return (_vector_loop_debug & 32) > 0; } - bool is_trace_align_vector() { return (_vector_loop_debug & 128) > 0; } + // TraceAutoVectorization and TraceSuperWord + bool is_trace_superword_precondition() const { + return TraceSuperWord || + _vtrace.is_trace(TraceAutoVectorizationTag::SW_PRECONDITION); + } + + bool is_trace_superword_vector_element_type() const { + // Too verbose for TraceSuperWord + return _vtrace.is_trace(TraceAutoVectorizationTag::SW_TYPES); + } + + bool is_trace_superword_alignment() const { + // Too verbose for TraceSuperWord + return _vtrace.is_trace(TraceAutoVectorizationTag::SW_ALIGNMENT); + } + + bool is_trace_superword_memory_slices() const { + return TraceSuperWord || + _vtrace.is_trace(TraceAutoVectorizationTag::SW_MEMORY_SLICES); + } + + bool is_trace_superword_dependence_graph() const { + return TraceSuperWord || + _vtrace.is_trace(TraceAutoVectorizationTag::SW_DEPENDENCE_GRAPH); + } + + bool is_trace_superword_adjacent_memops() const { + return TraceSuperWord || + _vtrace.is_trace(TraceAutoVectorizationTag::SW_ADJACENT_MEMOPS); + } + + bool is_trace_superword_rejections() const { + return TraceSuperWord || + _vtrace.is_trace(TraceAutoVectorizationTag::SW_REJECTIONS); + } + + bool is_trace_superword_packset() const { + return TraceSuperWord || + _vtrace.is_trace(TraceAutoVectorizationTag::SW_PACKSET); + } + + bool is_trace_superword_info() const { + return TraceSuperWord || + _vtrace.is_trace(TraceAutoVectorizationTag::SW_INFO); + } + + bool is_trace_superword_verbose() const { + // Too verbose for TraceSuperWord + return _vtrace.is_trace(TraceAutoVectorizationTag::SW_VERBOSE); + } + + bool is_trace_superword_any() const { + return TraceSuperWord || + is_trace_align_vector() || + _vtrace.is_trace(TraceAutoVectorizationTag::SW_PRECONDITION) || + _vtrace.is_trace(TraceAutoVectorizationTag::SW_TYPES) || + _vtrace.is_trace(TraceAutoVectorizationTag::SW_ALIGNMENT) || + _vtrace.is_trace(TraceAutoVectorizationTag::SW_MEMORY_SLICES) || + _vtrace.is_trace(TraceAutoVectorizationTag::SW_DEPENDENCE_GRAPH) || + _vtrace.is_trace(TraceAutoVectorizationTag::SW_ADJACENT_MEMOPS) || + _vtrace.is_trace(TraceAutoVectorizationTag::SW_REJECTIONS) || + _vtrace.is_trace(TraceAutoVectorizationTag::SW_PACKSET) || + _vtrace.is_trace(TraceAutoVectorizationTag::SW_INFO) || + _vtrace.is_trace(TraceAutoVectorizationTag::SW_VERBOSE); + } + + bool is_trace_align_vector() const { + return _vtrace.is_trace(TraceAutoVectorizationTag::ALIGN_VECTOR) || + is_trace_superword_verbose(); + } #endif + bool do_vector_loop() { return _do_vector_loop; } const GrowableArray& packset() const { return _packset; } @@ -299,9 +329,7 @@ class SuperWord : public ResourceObj { bool _do_vector_loop; // whether to do vectorization/simd style int _num_work_vecs; // Number of non memory vector operations int _num_reductions; // Number of reduction expressions applied -#ifndef PRODUCT - uintx _vector_loop_debug; // provide more printing in debug mode -#endif + NOT_PRODUCT(VTrace _vtrace); // Accessors Arena* arena() { return _arena; } @@ -337,15 +365,6 @@ class SuperWord : public ResourceObj { private: void set_bb_idx(Node* n, int i) { _bb_idx.at_put_grow(n->_idx, i); } - // visited set accessors - void visited_clear() { _visited.clear(); } - void visited_set(Node* n) { return _visited.set(bb_idx(n)); } - int visited_test(Node* n) { return _visited.test(bb_idx(n)); } - int visited_test_set(Node* n) { return _visited.test_set(bb_idx(n)); } - void post_visited_clear() { _post_visited.clear(); } - void post_visited_set(Node* n) { return _post_visited.set(bb_idx(n)); } - int post_visited_test(Node* n) { return _post_visited.test(bb_idx(n)); } - // Ensure node_info contains element "i" void grow_node_info(int i) { if (i >= _node_info.length()) _node_info.at_put_grow(i, SWNodeInfo::initial); } @@ -357,7 +376,7 @@ class SuperWord : public ResourceObj { void set_alignment(Node* n, int a) { int i = bb_idx(n); grow_node_info(i); _node_info.adr_at(i)->_alignment = a; } // Max expression (DAG) depth from beginning of the block for each node - int depth(Node* n) { return _node_info.adr_at(bb_idx(n))->_depth; } + int depth(Node* n) const { return _node_info.adr_at(bb_idx(n))->_depth; } void set_depth(Node* n, int d) { int i = bb_idx(n); grow_node_info(i); _node_info.adr_at(i)->_depth = d; } // vector element type @@ -460,15 +479,13 @@ class SuperWord : public ResourceObj { bool isomorphic(Node* s1, Node* s2); // Is there no data path from s1 to s2 or s2 to s1? bool independent(Node* s1, Node* s2); - // Is any s1 in p dependent on any s2 in p? Yes: return such a s2. No: return nullptr. - Node* find_dependence(Node_List* p); + // Are all nodes in nodes list mutually independent? + bool mutually_independent(Node_List* nodes) const; // For a node pair (s1, s2) which is isomorphic and independent, // do s1 and s2 have similar input edges? bool have_similar_inputs(Node* s1, Node* s2); // Is there a data path between s1 and s2 and both are reductions? bool reduction(Node* s1, Node* s2); - // Helper for independent - bool independent_path(Node* shallow, Node* deep, uint dp=0); void set_alignment(Node* s1, Node* s2, int align); int data_size(Node* s); // Extend packset by following use->def and def->use links from pack members. @@ -513,8 +530,8 @@ class SuperWord : public ResourceObj { bool implemented(Node_List* p); // For pack p, are all operands and all uses (with in the block) vector? bool profitable(Node_List* p); - // If a use of pack p is not a vector use, then replace the use with an extract operation. - void insert_extracts(Node_List* p); + // Verify that all uses of packs are also packs, i.e. we do not need extract operations. + DEBUG_ONLY(void verify_no_extract();) // Is use->in(u_idx) a vector use? bool is_vector_use(Node* use, int u_idx); // Construct reverse postorder list of block members diff --git a/src/hotspot/share/opto/traceAutoVectorizationTag.hpp b/src/hotspot/share/opto/traceAutoVectorizationTag.hpp new file mode 100644 index 00000000000..61cb1fe4bf3 --- /dev/null +++ b/src/hotspot/share/opto/traceAutoVectorizationTag.hpp @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2024, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_OPTO_TRACEAUTOVECTORIZATIONTAG_HPP +#define SHARE_OPTO_TRACEAUTOVECTORIZATIONTAG_HPP + +#include "utilities/bitMap.inline.hpp" +#include "utilities/stringUtils.hpp" + +#define COMPILER_TRACE_AUTO_VECTORIZATION_TAG(flags) \ + flags(POINTER_ANALYSIS, "Trace VPointer") \ + flags(SW_PRECONDITION, "Trace SuperWord precondition") \ + flags(SW_TYPES, "Trace SuperWord::compute_vector_element_type") \ + flags(SW_ALIGNMENT, "Trace SuperWord alignment analysis") \ + flags(SW_MEMORY_SLICES, "Trace SuperWord memory slices") \ + flags(SW_DEPENDENCE_GRAPH, "Trace SuperWord::dependence_graph") \ + flags(SW_ADJACENT_MEMOPS, "Trace SuperWord::find_adjacent_refs") \ + flags(SW_REJECTIONS, "Trace SuperWord rejections (non vectorizations)") \ + flags(SW_PACKSET, "Trace SuperWord packset at different stages") \ + flags(SW_INFO, "Trace SuperWord info (equivalent to TraceSuperWord)") \ + flags(SW_VERBOSE, "Trace SuperWord verbose (all SW tags enabled)") \ + flags(ALIGN_VECTOR, "Trace AlignVector") \ + flags(ALL, "Trace everything (very verbose)") + +#define table_entry(name, description) name, +enum TraceAutoVectorizationTag { + COMPILER_TRACE_AUTO_VECTORIZATION_TAG(table_entry) + TRACE_AUTO_VECTORIZATION_TAG_NUM, + TRACE_AUTO_VECTORIZATION_TAG_NONE +}; +#undef table_entry + +static const char* tag_descriptions[] = { +#define array_of_labels(name, description) description, + COMPILER_TRACE_AUTO_VECTORIZATION_TAG(array_of_labels) +#undef array_of_labels +}; + +static const char* tag_names[] = { +#define array_of_labels(name, description) #name, + COMPILER_TRACE_AUTO_VECTORIZATION_TAG(array_of_labels) +#undef array_of_labels +}; + +static TraceAutoVectorizationTag find_tag(const char* str) { + for (int i = 0; i < TRACE_AUTO_VECTORIZATION_TAG_NUM; i++) { + if (strcmp(tag_names[i], str) == 0) { + return (TraceAutoVectorizationTag)i; + } + } + return TRACE_AUTO_VECTORIZATION_TAG_NONE; +} + +class TraceAutoVectorizationTagValidator { + private: + CHeapBitMap _tags; + bool _valid; + char* _bad; + bool _is_print_usage; + + public: + TraceAutoVectorizationTagValidator(ccstrlist option, bool is_print_usage) : + _tags(TRACE_AUTO_VECTORIZATION_TAG_NUM, mtCompiler), + _valid(true), + _bad(nullptr), + _is_print_usage(is_print_usage) + { + for (StringUtils::CommaSeparatedStringIterator iter(option); *iter != nullptr && _valid; ++iter) { + char const* tag_name = *iter; + if (strcmp("help", tag_name) == 0) { + if (_is_print_usage) { + print_help(); + } + continue; + } + bool set_bit = true; + // Check for "TAG" or "-TAG" + if (strncmp("-", tag_name, strlen("-")) == 0) { + tag_name++; + set_bit = false; + } + TraceAutoVectorizationTag tag = find_tag(tag_name); + if (TRACE_AUTO_VECTORIZATION_TAG_NONE == tag) { + // cap len to a value we know is enough for all tags + const size_t len = MIN2(strlen(*iter), 63) + 1; + _bad = NEW_C_HEAP_ARRAY(char, len, mtCompiler); + // strncpy always writes len characters. If the source string is + // shorter, the function fills the remaining bytes with nulls. + strncpy(_bad, *iter, len); + _valid = false; + } else if (ALL == tag) { + _tags.set_range(0, TRACE_AUTO_VECTORIZATION_TAG_NUM); + } else if (SW_VERBOSE == tag) { + _tags.at_put(SW_PRECONDITION, set_bit); + _tags.at_put(SW_TYPES, set_bit); + _tags.at_put(SW_ALIGNMENT, set_bit); + _tags.at_put(SW_MEMORY_SLICES, set_bit); + _tags.at_put(SW_DEPENDENCE_GRAPH, set_bit); + _tags.at_put(SW_ADJACENT_MEMOPS, set_bit); + _tags.at_put(SW_REJECTIONS, set_bit); + _tags.at_put(SW_PACKSET, set_bit); + _tags.at_put(SW_INFO, set_bit); + _tags.at_put(SW_VERBOSE, set_bit); + } else if (SW_INFO == tag) { + _tags.at_put(SW_PRECONDITION, set_bit); + _tags.at_put(SW_MEMORY_SLICES, set_bit); + _tags.at_put(SW_DEPENDENCE_GRAPH, set_bit); + _tags.at_put(SW_ADJACENT_MEMOPS, set_bit); + _tags.at_put(SW_REJECTIONS, set_bit); + _tags.at_put(SW_PACKSET, set_bit); + _tags.at_put(SW_INFO, set_bit); + } else { + assert(tag < TRACE_AUTO_VECTORIZATION_TAG_NUM, "out of bounds"); + _tags.at_put(tag, set_bit); + } + } + } + + ~TraceAutoVectorizationTagValidator() { + if (_bad != nullptr) { + FREE_C_HEAP_ARRAY(char, _bad); + } + } + + bool is_valid() const { return _valid; } + const char* what() const { return _bad; } + const CHeapBitMap& tags() const { + assert(is_valid(), "only read tags when valid"); + return _tags; + } + + static void print_help() { + tty->cr(); + tty->print_cr("Usage for CompileCommand TraceAutoVectorization:"); + tty->print_cr(" -XX:CompileCommand=TraceAutoVectorization,,"); + tty->print_cr(" %-22s %s", "tags", "descriptions"); + for (int i = 0; i < TRACE_AUTO_VECTORIZATION_TAG_NUM; i++) { + tty->print_cr(" %-22s %s", tag_names[i], tag_descriptions[i]); + } + tty->cr(); + } +}; + +#endif // SHARE_OPTO_TRACEAUTOVECTORIZATIONTAG_HPP diff --git a/src/hotspot/share/opto/vectorization.cpp b/src/hotspot/share/opto/vectorization.cpp index 4794140ab0e..5ff24750b9a 100644 --- a/src/hotspot/share/opto/vectorization.cpp +++ b/src/hotspot/share/opto/vectorization.cpp @@ -46,7 +46,7 @@ VPointer::VPointer(const MemNode* mem, #endif _nstack(nstack), _analyze_only(analyze_only), _stack_idx(0) #ifndef PRODUCT - , _tracer((phase->C->directive()->VectorizeDebugOption & 2) > 0) + , _tracer(phase->C->directive()->trace_auto_vectorization_tags().at(TraceAutoVectorizationTag::POINTER_ANALYSIS)) #endif { NOT_PRODUCT(_tracer.ctor_1(mem);) diff --git a/src/hotspot/share/opto/vectorization.hpp b/src/hotspot/share/opto/vectorization.hpp index 8e63b40d5ac..5cf5a31b48d 100644 --- a/src/hotspot/share/opto/vectorization.hpp +++ b/src/hotspot/share/opto/vectorization.hpp @@ -27,10 +27,27 @@ #include "opto/node.hpp" #include "opto/loopnode.hpp" +#include "opto/traceAutoVectorizationTag.hpp" // Code in this file and the vectorization.cpp contains shared logics and // utilities for C2's loop auto-vectorization. +#ifndef PRODUCT +// Access to TraceAutoVectorization tags +class VTrace : public StackObj { +private: + const CHeapBitMap &_trace_tags; + +public: + VTrace() : _trace_tags(Compile::current()->directive()->trace_auto_vectorization_tags()) {} + NONCOPYABLE(VTrace); + + bool is_trace(TraceAutoVectorizationTag tag) const { + return _trace_tags.at(tag); + } +}; +#endif + // A vectorization pointer (VPointer) has information about an address for // dependence checking and vector alignment. It's usually bound to a memory // operation in a counted loop for vectorizable analysis. diff --git a/src/hotspot/share/opto/vectornode.cpp b/src/hotspot/share/opto/vectornode.cpp index b07aa387712..f5fdae79e32 100644 --- a/src/hotspot/share/opto/vectornode.cpp +++ b/src/hotspot/share/opto/vectornode.cpp @@ -389,7 +389,7 @@ int VectorNode::scalar_opcode(int sopc, BasicType bt) { // Limits on vector size (number of elements) for auto-vectorization. bool VectorNode::vector_size_supported_superword(const BasicType bt, int size) { - return Matcher::superword_max_vector_size(bt) >= size && + return Matcher::max_vector_size_auto_vectorization(bt) >= size && Matcher::min_vector_size(bt) <= size; } @@ -409,7 +409,7 @@ bool VectorNode::implemented(int opc, uint vlen, BasicType bt) { if (VectorNode::is_vector_integral_negate(vopc)) { return is_vector_integral_negate_supported(vopc, vlen, bt, false); } - return vopc > 0 && Matcher::match_rule_supported_superword(vopc, vlen, bt); + return vopc > 0 && Matcher::match_rule_supported_auto_vectorization(vopc, vlen, bt); } return false; } @@ -1434,7 +1434,7 @@ bool VectorCastNode::implemented(int opc, uint vlen, BasicType src_type, BasicTy (vlen > 1) && is_power_of_2(vlen) && VectorNode::vector_size_supported_superword(dst_type, vlen)) { int vopc = VectorCastNode::opcode(opc, src_type); - return vopc > 0 && Matcher::match_rule_supported_superword(vopc, vlen, dst_type); + return vopc > 0 && Matcher::match_rule_supported_auto_vectorization(vopc, vlen, dst_type); } return false; } @@ -1528,7 +1528,7 @@ bool ReductionNode::implemented(int opc, uint vlen, BasicType bt) { (vlen > 1) && is_power_of_2(vlen) && VectorNode::vector_size_supported_superword(bt, vlen)) { int vopc = ReductionNode::opcode(opc, bt); - return vopc != opc && Matcher::match_rule_supported_superword(vopc, vlen, bt); + return vopc != opc && Matcher::match_rule_supported_auto_vectorization(vopc, vlen, bt); } return false; } diff --git a/src/hotspot/share/prims/jvmtiExport.hpp b/src/hotspot/share/prims/jvmtiExport.hpp index 263104f74f8..36df28f2716 100644 --- a/src/hotspot/share/prims/jvmtiExport.hpp +++ b/src/hotspot/share/prims/jvmtiExport.hpp @@ -149,7 +149,15 @@ class JvmtiExport : public AllStatic { JVMTI_ONLY(_can_access_local_variables = (on != 0);) } inline static void set_can_hotswap_or_post_breakpoint(bool on) { - JVMTI_ONLY(_can_hotswap_or_post_breakpoint = (on != 0);) +#if INCLUDE_JVMTI + // Check that _can_hotswap_or_post_breakpoint is not reset once it + // was set to true. When _can_hotswap_or_post_breakpoint is set to true + // _all_dependencies_are_recorded is also set to true and never + // reset so we have to ensure that evol dependencies are always + // recorded from that point on. + assert(!_can_hotswap_or_post_breakpoint || on, "sanity check"); + _can_hotswap_or_post_breakpoint = (on != 0); +#endif } inline static void set_can_walk_any_space(bool on) { JVMTI_ONLY(_can_walk_any_space = (on != 0);) diff --git a/src/hotspot/share/prims/jvmtiRedefineClasses.cpp b/src/hotspot/share/prims/jvmtiRedefineClasses.cpp index c03c4b48538..3dcb026e785 100644 --- a/src/hotspot/share/prims/jvmtiRedefineClasses.cpp +++ b/src/hotspot/share/prims/jvmtiRedefineClasses.cpp @@ -4060,21 +4060,22 @@ void VM_RedefineClasses::transfer_old_native_function_registrations(InstanceKlas // Deoptimize all compiled code that depends on the classes redefined. // // If the can_redefine_classes capability is obtained in the onload -// phase then the compiler has recorded all dependencies from startup. -// In that case we need only deoptimize and throw away all compiled code -// that depends on the class. +// phase or 'AlwaysRecordEvolDependencies' is true, then the compiler has +// recorded all dependencies from startup. In that case we need only +// deoptimize and throw away all compiled code that depends on the class. // -// If can_redefine_classes is obtained sometime after the onload -// phase then the dependency information may be incomplete. In that case -// the first call to RedefineClasses causes all compiled code to be -// thrown away. As can_redefine_classes has been obtained then -// all future compilations will record dependencies so second and -// subsequent calls to RedefineClasses need only throw away code -// that depends on the class. +// If can_redefine_classes is obtained sometime after the onload phase +// (and 'AlwaysRecordEvolDependencies' is false) then the dependency +// information may be incomplete. In that case the first call to +// RedefineClasses causes all compiled code to be thrown away. As +// can_redefine_classes has been obtained then all future compilations will +// record dependencies so second and subsequent calls to RedefineClasses +// need only throw away code that depends on the class. // void VM_RedefineClasses::flush_dependent_code() { assert(SafepointSynchronize::is_at_safepoint(), "sanity check"); + assert(JvmtiExport::all_dependencies_are_recorded() || !AlwaysRecordEvolDependencies, "sanity check"); DeoptimizationScope deopt_scope; diff --git a/src/hotspot/share/prims/whitebox.cpp b/src/hotspot/share/prims/whitebox.cpp index 92badfe0d8d..99ed98cdfac 100644 --- a/src/hotspot/share/prims/whitebox.cpp +++ b/src/hotspot/share/prims/whitebox.cpp @@ -63,6 +63,7 @@ #include "oops/constantPool.inline.hpp" #include "oops/klass.inline.hpp" #include "oops/method.inline.hpp" +#include "oops/methodData.inline.hpp" #include "oops/objArrayKlass.hpp" #include "oops/objArrayOop.inline.hpp" #include "oops/oop.inline.hpp" @@ -1226,7 +1227,6 @@ WB_ENTRY(void, WB_ClearMethodState(JNIEnv* env, jobject o, jobject method)) for (int i = 0; i < arg_count; i++) { mdo->set_arg_modified(i, 0); } - MutexLocker mu(THREAD, mdo->extra_data_lock()); mdo->clean_method_data(/*always_clean*/true); } diff --git a/src/hotspot/share/runtime/abstract_vm_version.cpp b/src/hotspot/share/runtime/abstract_vm_version.cpp index f1f8888653e..9fada531d0b 100644 --- a/src/hotspot/share/runtime/abstract_vm_version.cpp +++ b/src/hotspot/share/runtime/abstract_vm_version.cpp @@ -34,6 +34,7 @@ const char* Abstract_VM_Version::_s_internal_vm_info_string = Abstract_VM_Versio uint64_t Abstract_VM_Version::_features = 0; const char* Abstract_VM_Version::_features_string = ""; +uint64_t Abstract_VM_Version::_cpu_features = 0; #ifndef SUPPORTS_NATIVE_CX8 bool Abstract_VM_Version::_supports_cx8 = false; diff --git a/src/hotspot/share/runtime/abstract_vm_version.hpp b/src/hotspot/share/runtime/abstract_vm_version.hpp index d8ffca8de81..ec3b7177a66 100644 --- a/src/hotspot/share/runtime/abstract_vm_version.hpp +++ b/src/hotspot/share/runtime/abstract_vm_version.hpp @@ -54,10 +54,13 @@ class Abstract_VM_Version: AllStatic { static const char* _s_vm_release; static const char* _s_internal_vm_info_string; - // CPU feature flags. + // CPU feature flags, can be affected by VM settings. static uint64_t _features; static const char* _features_string; + // Original CPU feature flags, not affected by VM settings. + static uint64_t _cpu_features; + // These are set by machine-dependent initializations #ifndef SUPPORTS_NATIVE_CX8 static bool _supports_cx8; diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp index 522443398a0..8af578c1878 100644 --- a/src/hotspot/share/runtime/arguments.cpp +++ b/src/hotspot/share/runtime/arguments.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, 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 @@ -494,10 +494,6 @@ void Arguments::init_version_specific_system_properties() { static SpecialFlag const special_jvm_flags[] = { // -------------- Deprecated Flags -------------- // --- Non-alias flags - sorted by obsolete_in then expired_in: - { "MaxGCMinorPauseMillis", JDK_Version::jdk(8), JDK_Version::undefined(), JDK_Version::undefined() }, - { "MaxRAMFraction", JDK_Version::jdk(10), JDK_Version::undefined(), JDK_Version::undefined() }, - { "MinRAMFraction", JDK_Version::jdk(10), JDK_Version::undefined(), JDK_Version::undefined() }, - { "InitialRAMFraction", JDK_Version::jdk(10), JDK_Version::undefined(), JDK_Version::undefined() }, { "AllowRedefinitionToAddDeleteMethods", JDK_Version::jdk(13), JDK_Version::undefined(), JDK_Version::undefined() }, { "FlightRecorder", JDK_Version::jdk(13), JDK_Version::undefined(), JDK_Version::undefined() }, { "DumpSharedSpaces", JDK_Version::jdk(18), JDK_Version::jdk(19), JDK_Version::undefined() }, @@ -507,7 +503,6 @@ static SpecialFlag const special_jvm_flags[] = { { "RegisterFinalizersAtInit", JDK_Version::jdk(22), JDK_Version::jdk(23), JDK_Version::jdk(24) }, // --- Deprecated alias flags (see also aliased_jvm_flags) - sorted by obsolete_in then expired_in: - { "DefaultMaxRAMFraction", JDK_Version::jdk(8), JDK_Version::undefined(), JDK_Version::undefined() }, { "CreateMinidumpOnCrash", JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::undefined() }, { "TLABStats", JDK_Version::jdk(12), JDK_Version::undefined(), JDK_Version::undefined() }, @@ -526,6 +521,11 @@ static SpecialFlag const special_jvm_flags[] = { { "MetaspaceReclaimPolicy", JDK_Version::undefined(), JDK_Version::jdk(21), JDK_Version::undefined() }, { "AdaptiveSizePolicyCollectionCostMargin", JDK_Version::undefined(), JDK_Version::jdk(23), JDK_Version::jdk(24) }, + { "MaxGCMinorPauseMillis", JDK_Version::jdk(8), JDK_Version::jdk(23), JDK_Version::jdk(24) }, + { "MaxRAMFraction", JDK_Version::jdk(10), JDK_Version::jdk(23), JDK_Version::jdk(24) }, + { "MinRAMFraction", JDK_Version::jdk(10), JDK_Version::jdk(23), JDK_Version::jdk(24) }, + { "InitialRAMFraction", JDK_Version::jdk(10), JDK_Version::jdk(23), JDK_Version::jdk(24) }, + { "DefaultMaxRAMFraction", JDK_Version::jdk(8), JDK_Version::jdk(23), JDK_Version::jdk(24) }, #ifdef ASSERT { "DummyObsoleteTestFlag", JDK_Version::undefined(), JDK_Version::jdk(18), JDK_Version::undefined() }, #endif @@ -551,7 +551,6 @@ typedef struct { } AliasedFlag; static AliasedFlag const aliased_jvm_flags[] = { - { "DefaultMaxRAMFraction", "MaxRAMFraction" }, { "CreateMinidumpOnCrash", "CreateCoredumpOnCrash" }, { nullptr, nullptr} }; @@ -1479,11 +1478,8 @@ void Arguments::set_heap_size() { // available os physical memory, not our MaxRAM limit, // unless MaxRAM is also specified. bool override_coop_limit = (!FLAG_IS_DEFAULT(MaxRAMPercentage) || - !FLAG_IS_DEFAULT(MaxRAMFraction) || !FLAG_IS_DEFAULT(MinRAMPercentage) || - !FLAG_IS_DEFAULT(MinRAMFraction) || !FLAG_IS_DEFAULT(InitialRAMPercentage) || - !FLAG_IS_DEFAULT(InitialRAMFraction) || !FLAG_IS_DEFAULT(MaxRAM)); if (override_coop_limit) { if (FLAG_IS_DEFAULT(MaxRAM)) { @@ -1497,20 +1493,6 @@ void Arguments::set_heap_size() { : (julong)MaxRAM; } - - // Convert deprecated flags - if (FLAG_IS_DEFAULT(MaxRAMPercentage) && - !FLAG_IS_DEFAULT(MaxRAMFraction)) - MaxRAMPercentage = 100.0 / (double)MaxRAMFraction; - - if (FLAG_IS_DEFAULT(MinRAMPercentage) && - !FLAG_IS_DEFAULT(MinRAMFraction)) - MinRAMPercentage = 100.0 / (double)MinRAMFraction; - - if (FLAG_IS_DEFAULT(InitialRAMPercentage) && - !FLAG_IS_DEFAULT(InitialRAMFraction)) - InitialRAMPercentage = 100.0 / (double)InitialRAMFraction; - // If the maximum heap size has not been set with -Xmx, // then set it as fraction of the size of physical memory, // respecting the maximum and minimum sizes of the heap. diff --git a/src/hotspot/share/runtime/deoptimization.cpp b/src/hotspot/share/runtime/deoptimization.cpp index 87587944469..d1015248dc8 100644 --- a/src/hotspot/share/runtime/deoptimization.cpp +++ b/src/hotspot/share/runtime/deoptimization.cpp @@ -391,7 +391,8 @@ static void restore_eliminated_locks(JavaThread* thread, GrowableArraylength(); i++) { + // Start locking from outermost/oldest frame + for (int i = (chunk->length() - 1); i >= 0; i--) { compiledVFrame* cvf = chunk->at(i); assert (cvf->scope() != nullptr,"expect only compiled java frames"); GrowableArray* monitors = cvf->monitors(); @@ -1724,7 +1725,8 @@ void Deoptimization::pop_frames_failed_reallocs(JavaThread* thread, vframeArray* for (int i = 0; i < array->frames(); i++) { MonitorChunk* monitors = array->element(i)->monitors(); if (monitors != nullptr) { - for (int j = 0; j < monitors->number_of_monitors(); j++) { + // Unlock in reverse order starting from most nested monitor. + for (int j = (monitors->number_of_monitors() - 1); j >= 0; j--) { BasicObjectLock* src = monitors->at(j); if (src->obj() != nullptr) { ObjectSynchronizer::exit(src->obj(), src->lock(), thread); @@ -1801,6 +1803,9 @@ address Deoptimization::deoptimize_for_missing_exception_handler(CompiledMethod* ScopeDesc* imm_scope = cvf->scope(); MethodData* imm_mdo = get_method_data(thread, methodHandle(thread, imm_scope->method()), true); if (imm_mdo != nullptr) { + // Lock to read ProfileData, and ensure lock is not broken by a safepoint + MutexLocker ml(imm_mdo->extra_data_lock(), Mutex::_no_safepoint_check_flag); + ProfileData* pdata = imm_mdo->allocate_bci_to_data(imm_scope->bci(), nullptr); if (pdata != nullptr && pdata->is_BitData()) { BitData* bit_data = (BitData*) pdata; @@ -2106,7 +2111,14 @@ JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* current, jint tr // Print a bunch of diagnostics, if requested. if (TraceDeoptimization || LogCompilation || is_receiver_constraint_failure) { ResourceMark rm; + + // Lock to read ProfileData, and ensure lock is not broken by a safepoint + // We must do this already now, since we cannot acquire this lock while + // holding the tty lock (lock ordering by rank). + MutexLocker ml(trap_mdo->extra_data_lock(), Mutex::_no_safepoint_check_flag); + ttyLocker ttyl; + char buf[100]; if (xtty != nullptr) { xtty->begin_head("uncommon_trap thread='" UINTX_FORMAT "' %s", @@ -2141,6 +2153,9 @@ JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* current, jint tr int dcnt = trap_mdo->trap_count(reason); if (dcnt != 0) xtty->print(" count='%d'", dcnt); + + // We need to lock to read the ProfileData. But to keep the locks ordered, we need to + // lock extra_data_lock before the tty lock. ProfileData* pdata = trap_mdo->bci_to_data(trap_bci); int dos = (pdata == nullptr)? 0: pdata->trap_state(); if (dos != 0) { @@ -2316,12 +2331,18 @@ JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* current, jint tr // to use the MDO to detect hot deoptimization points and control // aggressive optimization. bool inc_recompile_count = false; + + // Lock to read ProfileData, and ensure lock is not broken by a safepoint + ConditionalMutexLocker ml((trap_mdo != nullptr) ? trap_mdo->extra_data_lock() : nullptr, + (trap_mdo != nullptr), + Mutex::_no_safepoint_check_flag); ProfileData* pdata = nullptr; if (ProfileTraps && CompilerConfig::is_c2_or_jvmci_compiler_enabled() && update_trap_state && trap_mdo != nullptr) { assert(trap_mdo == get_method_data(current, profiled_method, false), "sanity"); uint this_trap_count = 0; bool maybe_prior_trap = false; bool maybe_prior_recompile = false; + pdata = query_update_method_data(trap_mdo, trap_bci, reason, true, #if INCLUDE_JVMCI nm->is_compiled_by_jvmci() && nm->is_osr_method(), @@ -2477,6 +2498,8 @@ Deoptimization::query_update_method_data(MethodData* trap_mdo, uint& ret_this_trap_count, bool& ret_maybe_prior_trap, bool& ret_maybe_prior_recompile) { + trap_mdo->check_extra_data_locked(); + bool maybe_prior_trap = false; bool maybe_prior_recompile = false; uint this_trap_count = 0; @@ -2559,6 +2582,10 @@ Deoptimization::update_method_data_from_interpreter(MethodData* trap_mdo, int tr assert(!reason_is_speculate(reason), "reason speculate only used by compiler"); // JVMCI uses the total counts to determine if deoptimizations are happening too frequently -> do not adjust total counts bool update_total_counts = true JVMCI_ONLY( && !UseJVMCICompiler); + + // Lock to read ProfileData, and ensure lock is not broken by a safepoint + MutexLocker ml(trap_mdo->extra_data_lock(), Mutex::_no_safepoint_check_flag); + query_update_method_data(trap_mdo, trap_bci, (DeoptReason)reason, update_total_counts, diff --git a/src/hotspot/share/runtime/flags/jvmFlag.cpp b/src/hotspot/share/runtime/flags/jvmFlag.cpp index eb41f2ccb4b..395504f626f 100644 --- a/src/hotspot/share/runtime/flags/jvmFlag.cpp +++ b/src/hotspot/share/runtime/flags/jvmFlag.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, 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 @@ -275,7 +275,6 @@ void JVMFlag::print_on(outputStream* st, bool withComments, bool printRanges) co // // Sample output: // intx MinPassesBeforeFlush [ 0 ... 9223372036854775807 ] {diagnostic} {default} - // uintx MinRAMFraction [ 1 ... 18446744073709551615 ] {product} {default} // double MinRAMPercentage [ 0.000 ... 100.000 ] {product} {default} // uintx MinSurvivorRatio [ 3 ... 18446744073709551615 ] {product} {default} // size_t MinTLABSize [ 1 ... 9223372036854775807 ] {product} {default} diff --git a/src/hotspot/share/runtime/globals.hpp b/src/hotspot/share/runtime/globals.hpp index b5e16c7ec25..77099c2bc4a 100644 --- a/src/hotspot/share/runtime/globals.hpp +++ b/src/hotspot/share/runtime/globals.hpp @@ -2062,6 +2062,11 @@ const int ObjectAlignmentInBytes = 8; \ product(bool, ProfileExceptionHandlers, true, \ "Profile exception handlers") \ + \ + product(bool, AlwaysRecordEvolDependencies, true, EXPERIMENTAL, \ + "Unconditionally record nmethod dependencies on class " \ + "rewriting/transformation independently of the JVMTI " \ + "can_{retransform/redefine}_classes capabilities.") \ // end of RUNTIME_FLAGS diff --git a/src/hotspot/share/runtime/init.cpp b/src/hotspot/share/runtime/init.cpp index 3343521af62..aabe3afc53b 100644 --- a/src/hotspot/share/runtime/init.cpp +++ b/src/hotspot/share/runtime/init.cpp @@ -115,6 +115,12 @@ void vm_init_globals() { jint init_globals() { management_init(); JvmtiExport::initialize_oop_storage(); +#if INCLUDE_JVMTI + if (AlwaysRecordEvolDependencies) { + JvmtiExport::set_can_hotswap_or_post_breakpoint(true); + JvmtiExport::set_all_dependencies_are_recorded(true); + } +#endif bytecodes_init(); classLoader_init1(); compilationPolicy_init(); diff --git a/src/hotspot/share/runtime/javaThread.hpp b/src/hotspot/share/runtime/javaThread.hpp index fb1355b852a..51e3cc31a52 100644 --- a/src/hotspot/share/runtime/javaThread.hpp +++ b/src/hotspot/share/runtime/javaThread.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, Azul Systems, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -258,6 +258,7 @@ class JavaThread: public Thread { public: void inc_no_safepoint_count() { _no_safepoint_count++; } void dec_no_safepoint_count() { _no_safepoint_count--; } + bool is_in_no_safepoint_scope() { return _no_safepoint_count > 0; } #endif // ASSERT public: // These functions check conditions before possibly going to a safepoint. diff --git a/src/hotspot/share/runtime/os.cpp b/src/hotspot/share/runtime/os.cpp index dad10a7b9b4..f9bd773e370 100644 --- a/src/hotspot/share/runtime/os.cpp +++ b/src/hotspot/share/runtime/os.cpp @@ -2114,14 +2114,18 @@ void os::pretouch_memory(void* start, void* end, size_t page_size) { // We're doing concurrent-safe touch and memory state has page // granularity, so we can touch anywhere in a page. Touch at the // beginning of each page to simplify iteration. - char* cur = static_cast(align_down(start, page_size)); + void* first = align_down(start, page_size); void* last = align_down(static_cast(end) - 1, page_size); - assert(cur <= last, "invariant"); - // Iterate from first page through last (inclusive), being careful to - // avoid overflow if the last page abuts the end of the address range. - for ( ; true; cur += page_size) { - Atomic::add(reinterpret_cast(cur), 0, memory_order_relaxed); - if (cur >= last) break; + assert(first <= last, "invariant"); + const size_t pd_page_size = pd_pretouch_memory(first, last, page_size); + if (pd_page_size > 0) { + // Iterate from first page through last (inclusive), being careful to + // avoid overflow if the last page abuts the end of the address range. + last = align_down(static_cast(end) - 1, pd_page_size); + for (char* cur = static_cast(first); /* break */; cur += pd_page_size) { + Atomic::add(reinterpret_cast(cur), 0, memory_order_relaxed); + if (cur >= last) break; + } } } } diff --git a/src/hotspot/share/runtime/os.hpp b/src/hotspot/share/runtime/os.hpp index d93c8f0969d..67e1ef7dcf7 100644 --- a/src/hotspot/share/runtime/os.hpp +++ b/src/hotspot/share/runtime/os.hpp @@ -224,6 +224,10 @@ class os: AllStatic { static void pd_free_memory(char *addr, size_t bytes, size_t alignment_hint); static void pd_realign_memory(char *addr, size_t bytes, size_t alignment_hint); + // Returns 0 if pretouch is done via platform dependent method, or otherwise + // returns page_size that should be used for the common method. + static size_t pd_pretouch_memory(void* first, void* last, size_t page_size); + static char* pd_reserve_memory_special(size_t size, size_t alignment, size_t page_size, char* addr, bool executable); diff --git a/src/hotspot/share/runtime/sharedRuntime.cpp b/src/hotspot/share/runtime/sharedRuntime.cpp index 94d42622c81..e1d39225b4c 100644 --- a/src/hotspot/share/runtime/sharedRuntime.cpp +++ b/src/hotspot/share/runtime/sharedRuntime.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, 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 @@ -615,6 +615,10 @@ void SharedRuntime::throw_and_post_jvmti_exception(JavaThread* current, Handle h Bytecode_invoke call = Bytecode_invoke_check(method, bci); if (call.is_valid()) { ResourceMark rm(current); + + // Lock to read ProfileData, and ensure lock is not broken by a safepoint + MutexLocker ml(trap_mdo->extra_data_lock(), Mutex::_no_safepoint_check_flag); + ProfileData* pdata = trap_mdo->allocate_bci_to_data(bci, nullptr); if (pdata != nullptr && pdata->is_BitData()) { BitData* bit_data = (BitData*) pdata; diff --git a/src/hotspot/share/services/memoryManager.cpp b/src/hotspot/share/services/memoryManager.cpp index 4c92b6651e0..e4c6740e51d 100644 --- a/src/hotspot/share/services/memoryManager.cpp +++ b/src/hotspot/share/services/memoryManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,8 +41,13 @@ #include "services/gcNotifier.hpp" #include "utilities/dtrace.hpp" -MemoryManager::MemoryManager(const char* name) : - _num_pools(0), _name(name) {} +MemoryManager::MemoryManager(const char* name) + : _pools(), + _num_pools(0), + _name(name), + _memory_mgr_obj(), + _memory_mgr_obj_initialized(false) +{} int MemoryManager::add_pool(MemoryPool* pool) { int index = _num_pools; @@ -56,7 +61,11 @@ int MemoryManager::add_pool(MemoryPool* pool) { } bool MemoryManager::is_manager(instanceHandle mh) const { - return mh() == Atomic::load(&_memory_mgr_obj).resolve(); + if (Atomic::load_acquire(&_memory_mgr_obj_initialized)) { + return mh() == _memory_mgr_obj.resolve(); + } else { + return false; + } } MemoryManager* MemoryManager::get_code_cache_memory_manager() { @@ -68,10 +77,10 @@ MemoryManager* MemoryManager::get_metaspace_memory_manager() { } instanceOop MemoryManager::get_memory_manager_instance(TRAPS) { + // Lazily create the manager object. // Must do an acquire so as to force ordering of subsequent // loads from anything _memory_mgr_obj points to or implies. - oop mgr_obj = Atomic::load_acquire(&_memory_mgr_obj).resolve(); - if (mgr_obj == nullptr) { + if (!Atomic::load_acquire(&_memory_mgr_obj_initialized)) { // It's ok for more than one thread to execute the code up to the locked region. // Extra manager instances will just be gc'ed. Klass* k = Management::sun_management_ManagementFactoryHelper_klass(CHECK_NULL); @@ -114,34 +123,36 @@ instanceOop MemoryManager::get_memory_manager_instance(TRAPS) { &args, CHECK_NULL); - instanceOop m = (instanceOop) result.get_oop(); - instanceHandle mgr(THREAD, m); - - { - // Get lock before setting _memory_mgr_obj - // since another thread may have created the instance - MutexLocker ml(THREAD, Management_lock); - - // Check if another thread has created the management object. We reload - // _memory_mgr_obj here because some other thread may have initialized - // it while we were executing the code before the lock. - mgr_obj = Atomic::load(&_memory_mgr_obj).resolve(); - if (mgr_obj != nullptr) { - return (instanceOop)mgr_obj; - } - - // Get the address of the object we created via call_special. - mgr_obj = mgr(); - - // Use store barrier to make sure the memory accesses associated - // with creating the management object are visible before publishing - // its address. The unlock will publish the store to _memory_mgr_obj - // because it does a release first. - Atomic::release_store(&_memory_mgr_obj, OopHandle(Universe::vm_global(), mgr_obj)); + // Verify we didn't get a null manager. If that could happen then we'd + // need to return immediately rather than continuing on and recording the + // manager has been created. + oop m = result.get_oop(); + guarantee(m != nullptr, "Manager creation returned null"); + instanceHandle mgr(THREAD, (instanceOop)m); + + // Allocate global handle outside lock, to avoid any lock nesting issues + // with the Management_lock. + OopHandle mgr_handle(Universe::vm_global(), mgr()); + + // Get lock since another thread may have created and installed the instance. + MutexLocker ml(THREAD, Management_lock); + + if (Atomic::load(&_memory_mgr_obj_initialized)) { + // Some other thread won the race. Release the handle we allocated and + // use the other one. Relaxed load is sufficient because flag update is + // under the lock. + mgr_handle.release(Universe::vm_global()); + } else { + // Record the object we created via call_special. + assert(_memory_mgr_obj.is_empty(), "already set manager obj"); + _memory_mgr_obj = mgr_handle; + // Record manager has been created. Release matching unlocked acquire, + // to safely publish the manager object. + Atomic::release_store(&_memory_mgr_obj_initialized, true); } } - return (instanceOop)mgr_obj; + return (instanceOop)_memory_mgr_obj.resolve(); } GCStatInfo::GCStatInfo(int num_pools) { diff --git a/src/hotspot/share/services/memoryManager.hpp b/src/hotspot/share/services/memoryManager.hpp index 3e4e85a194e..38f7fa4dea2 100644 --- a/src/hotspot/share/services/memoryManager.hpp +++ b/src/hotspot/share/services/memoryManager.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,11 +57,12 @@ class MemoryManager : public CHeapObj { const char* _name; protected: - volatile OopHandle _memory_mgr_obj; + OopHandle _memory_mgr_obj; + volatile bool _memory_mgr_obj_initialized; -public: MemoryManager(const char* name); +public: int num_memory_pools() const { return _num_pools; } MemoryPool* get_memory_pool(int index) { assert(index >= 0 && index < _num_pools, "Invalid index"); diff --git a/src/hotspot/share/services/memoryPool.cpp b/src/hotspot/share/services/memoryPool.cpp index d5b8f93d929..4761f97e9e9 100644 --- a/src/hotspot/share/services/memoryPool.cpp +++ b/src/hotspot/share/services/memoryPool.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -63,11 +63,16 @@ MemoryPool::MemoryPool(const char* name, _gc_usage_threshold(new ThresholdSupport(support_gc_threshold, support_gc_threshold)), _usage_sensor(), _gc_usage_sensor(), - _memory_pool_obj() + _memory_pool_obj(), + _memory_pool_obj_initialized(false) {} bool MemoryPool::is_pool(instanceHandle pool) const { - return pool() == Atomic::load(&_memory_pool_obj).resolve(); + if (Atomic::load_acquire(&_memory_pool_obj_initialized)) { + return pool() == _memory_pool_obj.resolve(); + } else { + return false; + } } void MemoryPool::add_manager(MemoryManager* mgr) { @@ -83,10 +88,10 @@ void MemoryPool::add_manager(MemoryManager* mgr) { // It creates a MemoryPool instance when the first time // this function is called. instanceOop MemoryPool::get_memory_pool_instance(TRAPS) { + // Lazily create the pool object. // Must do an acquire so as to force ordering of subsequent // loads from anything _memory_pool_obj points to or implies. - oop pool_obj = Atomic::load_acquire(&_memory_pool_obj).resolve(); - if (pool_obj == nullptr) { + if (!Atomic::load_acquire(&_memory_pool_obj_initialized)) { // It's ok for more than one thread to execute the code up to the locked region. // Extra pool instances will just be gc'ed. InstanceKlass* ik = Management::sun_management_ManagementFactoryHelper_klass(CHECK_NULL); @@ -113,33 +118,36 @@ instanceOop MemoryPool::get_memory_pool_instance(TRAPS) { &args, CHECK_NULL); - instanceOop p = (instanceOop) result.get_oop(); - instanceHandle pool(THREAD, p); - - { - // Get lock since another thread may have create the instance - MutexLocker ml(THREAD, Management_lock); - - // Check if another thread has created the pool. We reload - // _memory_pool_obj here because some other thread may have - // initialized it while we were executing the code before the lock. - pool_obj = Atomic::load(&_memory_pool_obj).resolve(); - if (pool_obj != nullptr) { - return (instanceOop)pool_obj; - } - - // Get the address of the object we created via call_special. - pool_obj = pool(); - - // Use store barrier to make sure the memory accesses associated - // with creating the pool are visible before publishing its address. - // The unlock will publish the store to _memory_pool_obj because - // it does a release first. - Atomic::release_store(&_memory_pool_obj, OopHandle(Universe::vm_global(), pool_obj)); + // Verify we didn't get a null pool. If that could happen then we'd + // need to return immediately rather than continuing on and recording the + // pool has been created. + oop p = result.get_oop(); + guarantee(p != nullptr, "Pool creation returns null"); + instanceHandle pool(THREAD, (instanceOop)p); + + // Allocate global handle outside lock, to avoid any lock nesting issues + // with the Management_lock. + OopHandle pool_handle(Universe::vm_global(), pool()); + + // Get lock since another thread may have created and installed the instance. + MutexLocker ml(THREAD, Management_lock); + + if (Atomic::load(&_memory_pool_obj_initialized)) { + // Some other thread won the race. Release the handle we allocated and + // use the other one. Relaxed load is sufficient because flag update is + // under the lock. + pool_handle.release(Universe::vm_global()); + } else { + // Record the object we created via call_special. + assert(_memory_pool_obj.is_empty(), "already set pool obj"); + _memory_pool_obj = pool_handle; + // Record pool has been created. Release matching unlocked acquire, to + // safely publish the pool object. + Atomic::release_store(&_memory_pool_obj_initialized, true); } } - return (instanceOop)pool_obj; + return (instanceOop)_memory_pool_obj.resolve(); } inline static size_t get_max_value(size_t val1, size_t val2) { diff --git a/src/hotspot/share/services/memoryPool.hpp b/src/hotspot/share/services/memoryPool.hpp index 65316558496..a55c593ebed 100644 --- a/src/hotspot/share/services/memoryPool.hpp +++ b/src/hotspot/share/services/memoryPool.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -73,7 +73,8 @@ class MemoryPool : public CHeapObj { SensorInfo* _usage_sensor; SensorInfo* _gc_usage_sensor; - volatile OopHandle _memory_pool_obj; + OopHandle _memory_pool_obj; + volatile bool _memory_pool_obj_initialized; void add_manager(MemoryManager* mgr); diff --git a/src/hotspot/share/utilities/exceptions.cpp b/src/hotspot/share/utilities/exceptions.cpp index bca6837ee13..97dd88165e0 100644 --- a/src/hotspot/share/utilities/exceptions.cpp +++ b/src/hotspot/share/utilities/exceptions.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, 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 @@ -433,6 +433,7 @@ void Exceptions::wrap_dynamic_exception(bool is_indy, JavaThread* THREAD) { // Pass through an Error, including BootstrapMethodError, any other form // of linkage error, or say OutOfMemoryError if (ls != nullptr) { + ResourceMark rm(THREAD); ls->print_cr("bootstrap method invocation wraps BSME around " PTR_FORMAT, p2i(exception)); exception->print_on(ls); } @@ -441,6 +442,7 @@ void Exceptions::wrap_dynamic_exception(bool is_indy, JavaThread* THREAD) { // Otherwise wrap the exception in a BootstrapMethodError if (ls != nullptr) { + ResourceMark rm(THREAD); ls->print_cr("%s throws BSME for " PTR_FORMAT, is_indy ? "invokedynamic" : "dynamic constant", p2i(exception)); exception->print_on(ls); } diff --git a/src/hotspot/share/utilities/stringUtils.cpp b/src/hotspot/share/utilities/stringUtils.cpp index 3abebeec92a..83ccfe308a9 100644 --- a/src/hotspot/share/utilities/stringUtils.cpp +++ b/src/hotspot/share/utilities/stringUtils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2024, 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 @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "jvm_io.h" +#include "memory/allocation.hpp" #include "utilities/debug.hpp" #include "utilities/stringUtils.hpp" @@ -122,3 +123,23 @@ bool StringUtils::is_star_match(const char* star_pattern, const char* str) { } return true; // all parts of pattern matched } + +StringUtils::CommaSeparatedStringIterator::~CommaSeparatedStringIterator() { + FREE_C_HEAP_ARRAY(char, _list); +} + +ccstrlist StringUtils::CommaSeparatedStringIterator::canonicalize(ccstrlist option_value) { + char* canonicalized_list = NEW_C_HEAP_ARRAY(char, strlen(option_value) + 1, mtCompiler); + int i = 0; + char current; + while ((current = option_value[i]) != '\0') { + if (current == '\n' || current == ' ') { + canonicalized_list[i] = ','; + } else { + canonicalized_list[i] = current; + } + i++; + } + canonicalized_list[i] = '\0'; + return canonicalized_list; +} diff --git a/src/hotspot/share/utilities/stringUtils.hpp b/src/hotspot/share/utilities/stringUtils.hpp index febfb227ebb..f30c9c3ea78 100644 --- a/src/hotspot/share/utilities/stringUtils.hpp +++ b/src/hotspot/share/utilities/stringUtils.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2024, 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 @@ -27,6 +27,11 @@ #include "memory/allStatic.hpp" +#ifdef _WINDOWS + // strtok_s is the Windows thread-safe equivalent of POSIX strtok_r +# define strtok_r strtok_s +#endif + class StringUtils : AllStatic { public: // Replace the substring with another string . must be @@ -49,6 +54,33 @@ class StringUtils : AllStatic { // eg. str "_abc____def__" would match pattern "abc*def". // The matching is case insensitive. static bool is_star_match(const char* star_pattern, const char* str); + + class CommaSeparatedStringIterator { + private: + char* _token; + char* _saved_ptr; + char* _list; + + public: + CommaSeparatedStringIterator(ccstrlist option) { + // Immediately make a private copy of option, and + // replace spaces and newlines with comma. + _list = (char*) canonicalize(option); + _saved_ptr = _list; + _token = strtok_r(_saved_ptr, ",", &_saved_ptr); + } + + ~CommaSeparatedStringIterator(); + + const char* operator*() const { return _token; } + + CommaSeparatedStringIterator& operator++() { + _token = strtok_r(nullptr, ",", &_saved_ptr); + return *this; + } + + ccstrlist canonicalize(ccstrlist option_value); + }; }; #endif // SHARE_UTILITIES_STRINGUTILS_HPP diff --git a/src/java.base/linux/native/libjava/CgroupMetrics.c b/src/java.base/linux/native/libjava/CgroupMetrics.c index 4f7847edbde..a5e41167bc3 100644 --- a/src/java.base/linux/native/libjava/CgroupMetrics.c +++ b/src/java.base/linux/native/libjava/CgroupMetrics.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Red Hat, Inc. + * Copyright (c) 2020, 2024, Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,5 +54,5 @@ Java_jdk_internal_platform_CgroupMetrics_getTotalSwapSize0 if (retval < 0) { return 0; // syinfo failed, treat as no swap } - return (jlong)si.totalswap; + return (jlong)(si.totalswap * si.mem_unit); } diff --git a/src/java.base/share/classes/java/io/ObjectInputStream.java b/src/java.base/share/classes/java/io/ObjectInputStream.java index a803969df5a..2a61d3ab026 100644 --- a/src/java.base/share/classes/java/io/ObjectInputStream.java +++ b/src/java.base/share/classes/java/io/ObjectInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2024, 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 @@ -1987,9 +1987,8 @@ private ObjectStreamClass readProxyDesc(boolean unshared) resolveEx = ex; } catch (IllegalAccessError aie) { throw new InvalidClassException(aie.getMessage(), aie); - } catch (OutOfMemoryError memerr) { - throw new InvalidObjectException("Proxy interface limit exceeded: " + - Arrays.toString(ifaces), memerr); + } catch (OutOfMemoryError oome) { + throw genInvalidObjectException(oome, ifaces); } // Call filterCheck on the class before reading anything else @@ -2001,9 +2000,8 @@ private ObjectStreamClass readProxyDesc(boolean unshared) totalObjectRefs++; depth++; desc.initProxy(cl, resolveEx, readClassDesc(false)); - } catch (OutOfMemoryError memerr) { - throw new InvalidObjectException("Proxy interface limit exceeded: " + - Arrays.toString(ifaces), memerr); + } catch (OutOfMemoryError oome) { + throw genInvalidObjectException(oome, ifaces); } finally { depth--; } @@ -2013,6 +2011,14 @@ private ObjectStreamClass readProxyDesc(boolean unshared) return desc; } + // Generate an InvalidObjectException for an OutOfMemoryError + // Use String.concat() to avoid string formatting invoke dynamic + private static InvalidObjectException genInvalidObjectException(OutOfMemoryError oome, + String[] ifaces) { + return new InvalidObjectException("Proxy interface limit exceeded: " + .concat(Arrays.toString(ifaces)), oome); + } + /** * Reads in and returns class descriptor for a class that is not a dynamic * proxy class. Sets passHandle to class descriptor's assigned handle. If diff --git a/src/java.base/share/classes/java/lang/foreign/MemoryLayout.java b/src/java.base/share/classes/java/lang/foreign/MemoryLayout.java index 8a2b3b4df30..7cacfd39f62 100644 --- a/src/java.base/share/classes/java/lang/foreign/MemoryLayout.java +++ b/src/java.base/share/classes/java/lang/foreign/MemoryLayout.java @@ -864,7 +864,8 @@ sealed interface PathElement permits LayoutPath.PathElementImpl { static PathElement groupElement(String name) { Objects.requireNonNull(name); return new LayoutPath.PathElementImpl(PathKind.GROUP_ELEMENT, - path -> path.groupElement(name)); + path -> path.groupElement(name), + "groupElement(\"" + name + "\")"); } /** @@ -879,7 +880,8 @@ static PathElement groupElement(long index) { throw new IllegalArgumentException("Index < 0"); } return new LayoutPath.PathElementImpl(PathKind.GROUP_ELEMENT, - path -> path.groupElement(index)); + path -> path.groupElement(index), + "groupElement(" + index + ")"); } /** @@ -894,7 +896,8 @@ static PathElement sequenceElement(long index) { throw new IllegalArgumentException("Index must be positive: " + index); } return new LayoutPath.PathElementImpl(PathKind.SEQUENCE_ELEMENT_INDEX, - path -> path.sequenceElement(index)); + path -> path.sequenceElement(index), + "sequenceElement(" + index + ")"); } /** @@ -927,7 +930,8 @@ static PathElement sequenceElement(long start, long step) { throw new IllegalArgumentException("Step must be != 0: " + step); } return new LayoutPath.PathElementImpl(PathKind.SEQUENCE_RANGE, - path -> path.sequenceElement(start, step)); + path -> path.sequenceElement(start, step), + "sequenceElement(" + start + ", " + step + ")"); } /** @@ -940,7 +944,8 @@ static PathElement sequenceElement(long start, long step) { */ static PathElement sequenceElement() { return new LayoutPath.PathElementImpl(PathKind.SEQUENCE_ELEMENT, - LayoutPath::sequenceElement); + LayoutPath::sequenceElement, + "sequenceElement()"); } /** @@ -949,7 +954,8 @@ static PathElement sequenceElement() { */ static PathElement dereferenceElement() { return new LayoutPath.PathElementImpl(PathKind.DEREF_ELEMENT, - LayoutPath::derefElement); + LayoutPath::derefElement, + "dereferenceElement()"); } } diff --git a/src/java.base/share/classes/java/lang/runtime/ExactConversionsSupport.java b/src/java.base/share/classes/java/lang/runtime/ExactConversionsSupport.java new file mode 100644 index 00000000000..6e17a4b85a0 --- /dev/null +++ b/src/java.base/share/classes/java/lang/runtime/ExactConversionsSupport.java @@ -0,0 +1,296 @@ +/* + * Copyright (c) 2024, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package java.lang.runtime; + +/** + * A testing conversion of a value is exact if it yields a result without loss + * of information or throwing an exception. Otherwise, it is inexact. Some + * conversions are always exact regardless of the value. These conversions are + * said to be unconditionally exact. + *

+ * For example, a conversion from {@code int} to {@code byte} for the value 10 + * is exact because the result, 10, is the same as the original value. In + * contrast, if the {@code int} variable {@code i} stores the value 1000 then a + * narrowing primitive conversion to {@code byte} will yield the result -24. + * Loss of information has occurred: both the magnitude and the sign of the + * result are different than those of the original value. As such, a conversion + * from {@code int} to {@code byte} for the value 1000 is inexact. Finally a + * widening primitive conversion from {@code byte} to {@code int} is + * unconditionally exact because it will always succeed with no loss of + * information about the magnitude of the numeric value. + *

+ * The methods in this class provide the run-time support for the exactness + * checks of testing conversions from a primitive type to primitive type. These + * methods may be used, for example, by Java compiler implementations to + * implement checks for {@code instanceof} and pattern matching runtime + * implementations. Unconditionally exact testing conversions do not require a + * corresponding action at run time and, for this reason, methods corresponding + * to these exactness checks are omitted here. + *

+ * The run time conversion checks examine whether loss of information would + * occur if a testing conversion would be to be applied. In those cases where a + * floating-point primitive type is involved, and the value of the testing + * conversion is either signed zero, signed infinity or {@code NaN}, these + * methods comply with the following: + * + *

    + *
  • Converting a floating-point negative zero to an integer type is considered + * inexact.
  • + *
  • Converting a floating-point {@code NaN} or infinity to an integer type is + * considered inexact.
  • + *
  • Converting a floating-point {@code NaN} or infinity or signed zero to another + * floating-point type is considered exact.
  • + *
+ * + * @jls 5.7.1 Exact Testing Conversions + * @jls 5.7.2 Unconditionally Exact Testing Conversions + * @jls 15.20.2 The instanceof Operator + * + * @implNote Some exactness checks describe a test which can be redirected + * safely through one of the existing methods. Those are omitted too (i.e., + * {@code byte} to {@code char} can be redirected to + * {@link ExactConversionsSupport#isIntToCharExact(int)}, {@code short} to + * {@code byte} can be redirected to + * {@link ExactConversionsSupport#isIntToByteExact(int)} and similarly for + * {@code short} to {@code char}, {@code char} to {@code byte} and {@code char} + * to {@code short} to the corresponding methods that take an {@code int}). + * + * @since 23 + */ +public final class ExactConversionsSupport { + + private ExactConversionsSupport() { } + + /** + * Exactness method from int to byte + * @param n value + * @return true if and only if the passed value can be converted exactly to the target type + */ + public static boolean isIntToByteExact(int n) {return n == (int)(byte)n;} + + /** + * Exactness method from int to short + * @param n value + * @return true if and only if the passed value can be converted exactly to the target type + */ + public static boolean isIntToShortExact(int n) {return n == (int)(short)n;} + + /** + * Exactness method from int to char + * @param n value + * @return true if and only if the passed value can be converted exactly to the target type + */ + public static boolean isIntToCharExact(int n) {return n == (int)(char)n;} + + /** + * Exactness method from int to float + * @param n value + * @return true if and only if the passed value can be converted exactly to the target type + * + * @implSpec relies on the notion of representation equivalence defined in the + * specification of the {@linkplain Double} class. + */ + public static boolean isIntToFloatExact(int n) { + return n == (int)(float)n && n != Integer.MAX_VALUE; + } + /** + * Exactness method from long to byte + * @param n value + * @return true if and only if the passed value can be converted exactly to the target type + */ + public static boolean isLongToByteExact(long n) {return n == (long)(byte)n;} + + /** + * Exactness method from long to short + * @param n value + * @return true if and only if the passed value can be converted exactly to the target type + */ + public static boolean isLongToShortExact(long n) {return n == (long)(short)n;} + + /** + * Exactness method from long to char + * @param n value + * @return true if and only if the passed value can be converted exactly to the target type + */ + public static boolean isLongToCharExact(long n) {return n == (long)(char)n;} + + /** + * Exactness method from long to int + * @param n value + * @return true if and only if the passed value can be converted exactly to the target type + */ + public static boolean isLongToIntExact(long n) {return n == (long)(int)n;} + + /** + * Exactness method from long to float + * @param n value + * @return true if and only if the passed value can be converted exactly to the target type + * @implSpec relies on the notion of representation equivalence defined in the + * specification of the {@linkplain Double} class. + */ + public static boolean isLongToFloatExact(long n) { + return n == (long)(float)n && n != Long.MAX_VALUE; + } + + /** + * Exactness method from long to double + * @param n value + * @return true if and only if the passed value can be converted exactly to the target type + * @implSpec relies on the notion of representation equivalence defined in the + * specification of the {@linkplain Double} class. + */ + public static boolean isLongToDoubleExact(long n) { + return n == (long)(double)n && n != Long.MAX_VALUE; + } + + /** + * Exactness method from float to byte + * @param n value + * @return true if and only if the passed value can be converted exactly to the target type + * @implSpec relies on the notion of representation equivalence defined in the + * specification of the {@linkplain Double} class. + */ + public static boolean isFloatToByteExact(float n) { + return n == (float)(byte)n && !isNegativeZero(n); + } + + /** + * Exactness method from float to short + * @param n value + * @return true if and only if the passed value can be converted exactly to the target type + * @implSpec relies on the notion of representation equivalence defined in the + * specification of the {@linkplain Double} class. + */ + public static boolean isFloatToShortExact(float n) { + return n == (float)(short)n && !isNegativeZero(n); + } + + /** + * Exactness method from float to char + * @param n value + * @return true if and only if the passed value can be converted exactly to the target type + * @implSpec relies on the notion of representation equivalence defined in the + * specification of the {@linkplain Double} class. + */ + public static boolean isFloatToCharExact(float n) { + return n == (float)(char)n && !isNegativeZero(n); + } + + /** + * Exactness method from float to int + * @param n value + * @return true if and only if the passed value can be converted exactly to the target type + * @implSpec relies on the notion of representation equivalence defined in the + * specification of the {@linkplain Double} class. + */ + public static boolean isFloatToIntExact(float n) { + return n == (float)(int)n && n != 0x1p31f && !isNegativeZero(n); + } + + /** + * Exactness method from float to long + * @param n value + * @return true if and only if the passed value can be converted exactly to the target type + * @implSpec relies on the notion of representation equivalence defined in the + * specification of the {@linkplain Double} class. + */ + public static boolean isFloatToLongExact(float n) { + return n == (float)(long)n && n != 0x1p63f && !isNegativeZero(n); + } + + /** + * Exactness method from double to byte + * @param n value + * @return true if and only if the passed value can be converted exactly to the target type + * @implSpec relies on the notion of representation equivalence defined in the + * specification of the {@linkplain Double} class. + */ + public static boolean isDoubleToByteExact(double n) { + return n == (double)(byte)n && !isNegativeZero(n); + } + + /** + * Exactness method from double to short + * @param n value + * @return true if and only if the passed value can be converted exactly to the target type + * @implSpec relies on the notion of representation equivalence defined in the + * specification of the {@linkplain Double} class. + */ + public static boolean isDoubleToShortExact(double n){ + return n == (double)(short)n && !isNegativeZero(n); + } + + /** + * Exactness method from double to char + * @param n value + * @return true if and only if the passed value can be converted exactly to the target type + * @implSpec relies on the notion of representation equivalence defined in the + * specification of the {@linkplain Double} class. + */ + public static boolean isDoubleToCharExact(double n) { + return n == (double)(char)n && !isNegativeZero(n); + } + + /** + * Exactness method from double to int + * @param n value + * @return true if and only if the passed value can be converted exactly to the target type + * @implSpec relies on the notion of representation equivalence defined in the + * specification of the {@linkplain Double} class. + */ + public static boolean isDoubleToIntExact(double n) { + return n == (double)(int)n && !isNegativeZero(n); + } + + /** + * Exactness method from double to long + * @param n value + * @return true if and only if the passed value can be converted exactly to the target type + * @implSpec relies on the notion of representation equivalence defined in the + * specification of the {@linkplain Double} class. + */ + public static boolean isDoubleToLongExact(double n) { + return n == (double)(long)n && n != 0x1p63 && !isNegativeZero(n); + } + + /** + * Exactness method from double to float + * @param n value + * @return true if and only if the passed value can be converted exactly to the target type + * @implSpec relies on the notion of representation equivalence defined in the + * specification of the {@linkplain Double} class. + */ + public static boolean isDoubleToFloatExact(double n) { + return n == (double)(float)n || n != n; + } + + private static boolean isNegativeZero(float n) { + return Float.floatToRawIntBits(n) == Integer.MIN_VALUE; + } + + private static boolean isNegativeZero(double n) { + return Double.doubleToRawLongBits(n) == Long.MIN_VALUE; + } +} diff --git a/src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java b/src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java index 6d9bd457584..8cc67807450 100644 --- a/src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java +++ b/src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -26,7 +26,9 @@ package java.lang.runtime; import java.lang.Enum.EnumDesc; +import java.lang.classfile.CodeBuilder; import java.lang.constant.ClassDesc; +import java.lang.constant.ConstantDesc; import java.lang.constant.ConstantDescs; import java.lang.constant.MethodTypeDesc; import java.lang.invoke.CallSite; @@ -40,16 +42,21 @@ import java.util.Objects; import java.util.Optional; import java.util.function.BiPredicate; +import java.util.function.Consumer; import java.util.stream.Stream; import jdk.internal.access.SharedSecrets; import java.lang.classfile.ClassFile; import java.lang.classfile.Label; import java.lang.classfile.instruction.SwitchCase; +import jdk.internal.misc.PreviewFeatures; import jdk.internal.vm.annotation.Stable; import static java.lang.invoke.MethodHandles.Lookup.ClassOption.NESTMATE; import static java.lang.invoke.MethodHandles.Lookup.ClassOption.STRONG; +import java.util.HashMap; +import java.util.Map; import static java.util.Objects.requireNonNull; +import sun.invoke.util.Wrapper; /** * Bootstrap methods for linking {@code invokedynamic} call sites that implement @@ -65,6 +72,7 @@ private SwitchBootstraps() {} private static final Object SENTINEL = new Object(); private static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup(); + private static final boolean previewEnabled = PreviewFeatures.isEnabled(); private static final MethodHandle NULL_CHECK; private static final MethodHandle IS_ZERO; @@ -74,6 +82,8 @@ private SwitchBootstraps() {} private static final MethodTypeDesc TYPES_SWITCH_DESCRIPTOR = MethodTypeDesc.ofDescriptor("(Ljava/lang/Object;ILjava/util/function/BiPredicate;Ljava/util/List;)I"); + private static final Map typePairToName; + static { try { NULL_CHECK = LOOKUP.findStatic(Objects.class, "isNull", @@ -89,6 +99,7 @@ private SwitchBootstraps() {} catch (ReflectiveOperationException e) { throw new ExceptionInInitializerError(e); } + typePairToName = TypePairs.initialize(); } /** @@ -134,12 +145,15 @@ private SwitchBootstraps() {} * and {@code Class} and {@code EnumDesc} instances, in any combination * @return a {@code CallSite} returning the first matching element as described above * - * @throws NullPointerException if any argument is {@code null} - * @throws IllegalArgumentException if any element in the labels array is null, if the - * invocation type is not not a method type of first parameter of a reference type, - * second parameter of type {@code int} and with {@code int} as its return type, - * or if {@code labels} contains an element that is not of type {@code String}, - * {@code Integer}, {@code Class} or {@code EnumDesc}. + * @throws NullPointerException if any argument is {@code null} + * @throws IllegalArgumentException if any element in the labels array is null + * @throws IllegalArgumentException if the invocation type is not a method type of first parameter of a reference type, + * second parameter of type {@code int} and with {@code int} as its return type, + * @throws IllegalArgumentException if {@code labels} contains an element that is not of type {@code String}, + * {@code Integer}, {@code Long}, {@code Float}, {@code Double}, {@code Boolean}, + * {@code Class} or {@code EnumDesc}. + * @throws IllegalArgumentException if {@code labels} contains an element that is not of type {@code Boolean} + * when {@code target} is a {@code Boolean.class}. * @jvms 4.4.6 The CONSTANT_NameAndType_info Structure * @jvms 4.4.10 The CONSTANT_Dynamic_info and CONSTANT_InvokeDynamic_info Structures */ @@ -147,31 +161,39 @@ public static CallSite typeSwitch(MethodHandles.Lookup lookup, String invocationName, MethodType invocationType, Object... labels) { + Class selectorType = invocationType.parameterType(0); if (invocationType.parameterCount() != 2 || (!invocationType.returnType().equals(int.class)) - || invocationType.parameterType(0).isPrimitive() || !invocationType.parameterType(1).equals(int.class)) throw new IllegalArgumentException("Illegal invocation type " + invocationType); requireNonNull(labels); - labels = labels.clone(); - Stream.of(labels).forEach(SwitchBootstraps::verifyLabel); + Stream.of(labels).forEach(l -> verifyLabel(l, selectorType)); - MethodHandle target = generateInnerClass(lookup, labels); + MethodHandle target = generateTypeSwitch(lookup, selectorType, labels); target = withIndexCheck(target, labels.length); return new ConstantCallSite(target); } - private static void verifyLabel(Object label) { + private static void verifyLabel(Object label, Class selectorType) { if (label == null) { throw new IllegalArgumentException("null label found"); } Class labelClass = label.getClass(); + if (labelClass != Class.class && labelClass != String.class && labelClass != Integer.class && + + ((labelClass != Float.class && + labelClass != Long.class && + labelClass != Double.class && + labelClass != Boolean.class) || + ((selectorType.equals(boolean.class) || selectorType.equals(Boolean.class)) && labelClass != Boolean.class && labelClass != Class.class) || + !previewEnabled) && + labelClass != EnumDesc.class) { throw new IllegalArgumentException("label with illegal type found: " + label.getClass()); } @@ -266,11 +288,11 @@ public static CallSite enumSwitch(MethodHandles.Lookup lookup, MethodHandles.guardWithTest(MethodHandles.dropArguments(NULL_CHECK, 0, int.class), MethodHandles.dropArguments(MethodHandles.constant(int.class, -1), 0, int.class, Object.class), MethodHandles.guardWithTest(MethodHandles.dropArguments(IS_ZERO, 1, Object.class), - generateInnerClass(lookup, labels), + generateTypeSwitch(lookup, invocationType.parameterType(0), labels), MethodHandles.insertArguments(MAPPED_ENUM_LOOKUP, 1, lookup, enumClass, labels, new EnumMap()))); target = MethodHandles.permuteArguments(body, MethodType.methodType(int.class, Object.class, int.class), 1, 0); } else { - target = generateInnerClass(lookup, labels); + target = generateTypeSwitch(lookup, invocationType.parameterType(0), labels); } target = target.asType(invocationType); @@ -381,137 +403,233 @@ private static final class EnumMap { * ... * } */ - @SuppressWarnings("removal") - private static MethodHandle generateInnerClass(MethodHandles.Lookup caller, Object[] labels) { - List> enumDescs = new ArrayList<>(); - List> extraClassLabels = new ArrayList<>(); - - byte[] classBytes = ClassFile.of().build(ClassDesc.of(typeSwitchClassName(caller.lookupClass())), clb -> { - clb.withFlags(AccessFlag.FINAL, AccessFlag.SUPER, AccessFlag.SYNTHETIC) - .withMethodBody("typeSwitch", - TYPES_SWITCH_DESCRIPTOR, - ClassFile.ACC_FINAL | ClassFile.ACC_PUBLIC | ClassFile.ACC_STATIC, - cb -> { - cb.aload(0); - Label nonNullLabel = cb.newLabel(); - cb.if_nonnull(nonNullLabel); - cb.iconst_m1(); - cb.ireturn(); - cb.labelBinding(nonNullLabel); - if (labels.length == 0) { - cb.constantInstruction(0) - .ireturn(); - return ; - } - cb.iload(1); - Label dflt = cb.newLabel(); - record Element(Label target, Label next, Object caseLabel) {} - List cases = new ArrayList<>(); - List switchCases = new ArrayList<>(); - Object lastLabel = null; - for (int idx = labels.length - 1; idx >= 0; idx--) { - Object currentLabel = labels[idx]; - Label target = cb.newLabel(); - Label next; - if (lastLabel == null) { - next = dflt; - } else if (lastLabel.equals(currentLabel)) { - next = cases.getLast().next(); - } else { - next = cases.getLast().target(); - } - lastLabel = currentLabel; - cases.add(new Element(target, next, currentLabel)); - switchCases.add(SwitchCase.of(idx, target)); - } - cases = cases.reversed(); - switchCases = switchCases.reversed(); - cb.tableswitch(0, labels.length - 1, dflt, switchCases); - for (int idx = 0; idx < cases.size(); idx++) { - Element element = cases.get(idx); - Label next = element.next(); - cb.labelBinding(element.target()); - if (element.caseLabel() instanceof Class classLabel) { - Optional classLabelConstableOpt = classLabel.describeConstable(); - if (classLabelConstableOpt.isPresent()) { - cb.aload(0); - cb.instanceof_(classLabelConstableOpt.orElseThrow()); + private static Consumer generateTypeSwitchSkeleton(Class selectorType, Object[] labelConstants, List> enumDescs, List> extraClassLabels) { + int SELECTOR_OBJ = 0; + int RESTART_IDX = 1; + int ENUM_CACHE = 2; + int EXTRA_CLASS_LABELS = 3; + + return cb -> { + cb.aload(SELECTOR_OBJ); + Label nonNullLabel = cb.newLabel(); + cb.if_nonnull(nonNullLabel); + cb.iconst_m1(); + cb.ireturn(); + cb.labelBinding(nonNullLabel); + if (labelConstants.length == 0) { + cb.constantInstruction(0) + .ireturn(); + return; + } + cb.iload(RESTART_IDX); + Label dflt = cb.newLabel(); + record Element(Label target, Label next, Object caseLabel) { } + List cases = new ArrayList<>(); + List switchCases = new ArrayList<>(); + Object lastLabel = null; + for (int idx = labelConstants.length - 1; idx >= 0; idx--) { + Object currentLabel = labelConstants[idx]; + Label target = cb.newLabel(); + Label next; + if (lastLabel == null) { + next = dflt; + } else if (lastLabel.equals(currentLabel)) { + next = cases.getLast().next(); + } else { + next = cases.getLast().target(); + } + lastLabel = currentLabel; + cases.add(new Element(target, next, currentLabel)); + switchCases.add(SwitchCase.of(idx, target)); + } + cases = cases.reversed(); + switchCases = switchCases.reversed(); + cb.tableswitch(0, labelConstants.length - 1, dflt, switchCases); + for (int idx = 0; idx < cases.size(); idx++) { + Element element = cases.get(idx); + Label next = element.next(); + cb.labelBinding(element.target()); + if (element.caseLabel() instanceof Class classLabel) { + if (unconditionalExactnessCheck(selectorType, classLabel)) { + //nothing - unconditionally use this case + } else if (classLabel.isPrimitive()) { + if (!selectorType.isPrimitive() && !Wrapper.isWrapperNumericOrBooleanType(selectorType)) { + // Object o = ... + // o instanceof Wrapped(float) + cb.aload(SELECTOR_OBJ); + cb.instanceof_(Wrapper.forBasicType(classLabel) + .wrapperType() + .describeConstable() + .orElseThrow()); + cb.ifeq(next); + } else if (!unconditionalExactnessCheck(Wrapper.asPrimitiveType(selectorType), classLabel)) { + // Integer i = ... or int i = ... + // o instanceof float + Label notNumber = cb.newLabel(); + cb.aload(SELECTOR_OBJ); + cb.instanceof_(ConstantDescs.CD_Number); + if (selectorType == long.class || selectorType == float.class || selectorType == double.class) { cb.ifeq(next); } else { - cb.aload(3); - cb.constantInstruction(extraClassLabels.size()); - cb.invokeinterface(ConstantDescs.CD_List, - "get", - MethodTypeDesc.of(ConstantDescs.CD_Object, - ConstantDescs.CD_int)); - cb.checkcast(ConstantDescs.CD_Class); - cb.aload(0); - cb.invokevirtual(ConstantDescs.CD_Class, - "isInstance", - MethodTypeDesc.of(ConstantDescs.CD_boolean, - ConstantDescs.CD_Object)); + cb.ifeq(notNumber); + } + cb.aload(SELECTOR_OBJ); + cb.checkcast(ConstantDescs.CD_Number); + if (selectorType == long.class) { + cb.invokevirtual(ConstantDescs.CD_Number, + "longValue", + MethodTypeDesc.of(ConstantDescs.CD_long)); + } else if (selectorType == float.class) { + cb.invokevirtual(ConstantDescs.CD_Number, + "floatValue", + MethodTypeDesc.of(ConstantDescs.CD_float)); + } else if (selectorType == double.class) { + cb.invokevirtual(ConstantDescs.CD_Number, + "doubleValue", + MethodTypeDesc.of(ConstantDescs.CD_double)); + } else { + Label compare = cb.newLabel(); + cb.invokevirtual(ConstantDescs.CD_Number, + "intValue", + MethodTypeDesc.of(ConstantDescs.CD_int)); + cb.goto_(compare); + cb.labelBinding(notNumber); + cb.aload(SELECTOR_OBJ); + cb.instanceof_(ConstantDescs.CD_Character); cb.ifeq(next); - extraClassLabels.add(classLabel); + cb.aload(SELECTOR_OBJ); + cb.checkcast(ConstantDescs.CD_Character); + cb.invokevirtual(ConstantDescs.CD_Character, + "charValue", + MethodTypeDesc.of(ConstantDescs.CD_char)); + cb.labelBinding(compare); } - } else if (element.caseLabel() instanceof EnumDesc enumLabel) { - int enumIdx = enumDescs.size(); - enumDescs.add(enumLabel); - cb.aload(2); - cb.constantInstruction(enumIdx); - cb.invokestatic(ConstantDescs.CD_Integer, - "valueOf", - MethodTypeDesc.of(ConstantDescs.CD_Integer, - ConstantDescs.CD_int)); - cb.aload(0); - cb.invokeinterface(BiPredicate.class.describeConstable().orElseThrow(), - "test", - MethodTypeDesc.of(ConstantDescs.CD_boolean, - ConstantDescs.CD_Object, - ConstantDescs.CD_Object)); - cb.ifeq(next); - } else if (element.caseLabel() instanceof String stringLabel) { - cb.ldc(stringLabel); - cb.aload(0); - cb.invokevirtual(ConstantDescs.CD_Object, - "equals", - MethodTypeDesc.of(ConstantDescs.CD_boolean, - ConstantDescs.CD_Object)); + + TypePairs typePair = TypePairs.of(Wrapper.asPrimitiveType(selectorType), classLabel); + String methodName = typePairToName.get(typePair); + cb.invokestatic(ExactConversionsSupport.class.describeConstable().orElseThrow(), + methodName, + MethodTypeDesc.of(ConstantDescs.CD_boolean, typePair.from.describeConstable().orElseThrow())); cb.ifeq(next); - } else if (element.caseLabel() instanceof Integer integerLabel) { - Label compare = cb.newLabel(); - Label notNumber = cb.newLabel(); - cb.aload(0); - cb.instanceof_(ConstantDescs.CD_Number); - cb.ifeq(notNumber); - cb.aload(0); - cb.checkcast(ConstantDescs.CD_Number); - cb.invokevirtual(ConstantDescs.CD_Number, - "intValue", - MethodTypeDesc.of(ConstantDescs.CD_int)); - cb.goto_(compare); - cb.labelBinding(notNumber); - cb.aload(0); - cb.instanceof_(ConstantDescs.CD_Character); + } + } else { + Optional classLabelConstableOpt = classLabel.describeConstable(); + if (classLabelConstableOpt.isPresent()) { + cb.aload(SELECTOR_OBJ); + cb.instanceof_(classLabelConstableOpt.orElseThrow()); cb.ifeq(next); - cb.aload(0); - cb.checkcast(ConstantDescs.CD_Character); - cb.invokevirtual(ConstantDescs.CD_Character, - "charValue", - MethodTypeDesc.of(ConstantDescs.CD_char)); - cb.labelBinding(compare); - cb.ldc(integerLabel); - cb.if_icmpne(next); } else { - throw new InternalError("Unsupported label type: " + - element.caseLabel().getClass()); + cb.aload(EXTRA_CLASS_LABELS); + cb.constantInstruction(extraClassLabels.size()); + cb.invokeinterface(ConstantDescs.CD_List, + "get", + MethodTypeDesc.of(ConstantDescs.CD_Object, + ConstantDescs.CD_int)); + cb.checkcast(ConstantDescs.CD_Class); + cb.aload(SELECTOR_OBJ); + cb.invokevirtual(ConstantDescs.CD_Class, + "isInstance", + MethodTypeDesc.of(ConstantDescs.CD_boolean, + ConstantDescs.CD_Object)); + cb.ifeq(next); + extraClassLabels.add(classLabel); } - cb.constantInstruction(idx); - cb.ireturn(); } - cb.labelBinding(dflt); - cb.constantInstruction(cases.size()); - cb.ireturn(); - }); + } else if (element.caseLabel() instanceof EnumDesc enumLabel) { + int enumIdx = enumDescs.size(); + enumDescs.add(enumLabel); + cb.aload(ENUM_CACHE); + cb.constantInstruction(enumIdx); + cb.invokestatic(ConstantDescs.CD_Integer, + "valueOf", + MethodTypeDesc.of(ConstantDescs.CD_Integer, + ConstantDescs.CD_int)); + cb.aload(SELECTOR_OBJ); + cb.invokeinterface(BiPredicate.class.describeConstable().orElseThrow(), + "test", + MethodTypeDesc.of(ConstantDescs.CD_boolean, + ConstantDescs.CD_Object, + ConstantDescs.CD_Object)); + cb.ifeq(next); + } else if (element.caseLabel() instanceof String stringLabel) { + cb.ldc(stringLabel); + cb.aload(SELECTOR_OBJ); + cb.invokevirtual(ConstantDescs.CD_Object, + "equals", + MethodTypeDesc.of(ConstantDescs.CD_boolean, + ConstantDescs.CD_Object)); + cb.ifeq(next); + } else if (element.caseLabel() instanceof Integer integerLabel) { + Label compare = cb.newLabel(); + Label notNumber = cb.newLabel(); + cb.aload(SELECTOR_OBJ); + cb.instanceof_(ConstantDescs.CD_Number); + cb.ifeq(notNumber); + cb.aload(SELECTOR_OBJ); + cb.checkcast(ConstantDescs.CD_Number); + cb.invokevirtual(ConstantDescs.CD_Number, + "intValue", + MethodTypeDesc.of(ConstantDescs.CD_int)); + cb.goto_(compare); + cb.labelBinding(notNumber); + cb.aload(SELECTOR_OBJ); + cb.instanceof_(ConstantDescs.CD_Character); + cb.ifeq(next); + cb.aload(SELECTOR_OBJ); + cb.checkcast(ConstantDescs.CD_Character); + cb.invokevirtual(ConstantDescs.CD_Character, + "charValue", + MethodTypeDesc.of(ConstantDescs.CD_char)); + cb.labelBinding(compare); + + cb.ldc(integerLabel); + cb.if_icmpne(next); + } else if ((element.caseLabel() instanceof Long || + element.caseLabel() instanceof Float || + element.caseLabel() instanceof Double || + element.caseLabel() instanceof Boolean)) { + if (element.caseLabel() instanceof Boolean c) { + cb.constantInstruction(c ? 1 : 0); + } else { + cb.constantInstruction((ConstantDesc) element.caseLabel()); + } + cb.invokestatic(element.caseLabel().getClass().describeConstable().orElseThrow(), + "valueOf", + MethodTypeDesc.of(element.caseLabel().getClass().describeConstable().orElseThrow(), + Wrapper.asPrimitiveType(element.caseLabel().getClass()).describeConstable().orElseThrow())); + cb.aload(SELECTOR_OBJ); + cb.invokevirtual(ConstantDescs.CD_Object, + "equals", + MethodTypeDesc.of(ConstantDescs.CD_boolean, + ConstantDescs.CD_Object)); + cb.ifeq(next); + } else { + throw new InternalError("Unsupported label type: " + + element.caseLabel().getClass()); + } + cb.constantInstruction(idx); + cb.ireturn(); + } + cb.labelBinding(dflt); + cb.constantInstruction(cases.size()); + cb.ireturn(); + }; + } + + /* + * Construct the method handle that represents the method int typeSwitch(Object, int, BiPredicate, List) + */ + private static MethodHandle generateTypeSwitch(MethodHandles.Lookup caller, Class selectorType, Object[] labelConstants) { + List> enumDescs = new ArrayList<>(); + List> extraClassLabels = new ArrayList<>(); + + byte[] classBytes = ClassFile.of().build(ClassDesc.of(typeSwitchClassName(caller.lookupClass())), + clb -> { + clb.withFlags(AccessFlag.FINAL, AccessFlag.SUPER, AccessFlag.SYNTHETIC) + .withMethodBody("typeSwitch", + TYPES_SWITCH_DESCRIPTOR, + ClassFile.ACC_FINAL | ClassFile.ACC_PUBLIC | ClassFile.ACC_STATIC, + generateTypeSwitchSkeleton(selectorType, labelConstants, enumDescs, extraClassLabels)); }); try { @@ -525,8 +643,13 @@ record Element(Label target, Label next, Object caseLabel) {} int.class, BiPredicate.class, List.class)); - return MethodHandles.insertArguments(typeSwitch, 2, new ResolvedEnumLabels(caller, enumDescs.toArray(EnumDesc[]::new)), - List.copyOf(extraClassLabels)); + typeSwitch = MethodHandles.insertArguments(typeSwitch, 2, new ResolvedEnumLabels(caller, enumDescs.toArray(EnumDesc[]::new)), + List.copyOf(extraClassLabels)); + typeSwitch = MethodHandles.explicitCastArguments(typeSwitch, + MethodType.methodType(int.class, + selectorType, + int.class)); + return typeSwitch; } catch (Throwable t) { throw new IllegalArgumentException(t); } @@ -541,4 +664,61 @@ private static String typeSwitchClassName(Class targetClass) { } return name + "$$TypeSwitch"; } + + // this method should be in sync with com.sun.tools.javac.code.Types.checkUnconditionallyExactPrimitives + private static boolean unconditionalExactnessCheck(Class selectorType, Class targetType) { + Wrapper selectorWrapper = Wrapper.forBasicType(selectorType); + Wrapper targetWrapper = Wrapper.forBasicType(targetType); + if (selectorType.isPrimitive() && targetType.equals(selectorWrapper.wrapperType())) { + return true; + } + else if (selectorType.equals(targetType) || + ((selectorType.equals(byte.class) && !targetType.equals(char.class)) || + (selectorType.equals(short.class) && (selectorWrapper.isStrictSubRangeOf(targetWrapper))) || + (selectorType.equals(char.class) && (selectorWrapper.isStrictSubRangeOf(targetWrapper))) || + (selectorType.equals(int.class) && (targetType.equals(double.class) || targetType.equals(long.class))) || + (selectorType.equals(float.class) && (selectorWrapper.isStrictSubRangeOf(targetWrapper))))) return true; + return false; + } + + // TypePairs should be in sync with the corresponding record in Lower + record TypePairs(Class from, Class to) { + public static TypePairs of(Class from, Class to) { + if (from == byte.class || from == short.class || from == char.class) { + from = int.class; + } + return new TypePairs(from, to); + } + + public static Map initialize() { + Map typePairToName = new HashMap<>(); + typePairToName.put(new TypePairs(byte.class, char.class), "isIntToCharExact"); // redirected + typePairToName.put(new TypePairs(short.class, byte.class), "isIntToByteExact"); // redirected + typePairToName.put(new TypePairs(short.class, char.class), "isIntToCharExact"); // redirected + typePairToName.put(new TypePairs(char.class, byte.class), "isIntToByteExact"); // redirected + typePairToName.put(new TypePairs(char.class, short.class), "isIntToShortExact"); // redirected + typePairToName.put(new TypePairs(int.class, byte.class), "isIntToByteExact"); + typePairToName.put(new TypePairs(int.class, short.class), "isIntToShortExact"); + typePairToName.put(new TypePairs(int.class, char.class), "isIntToCharExact"); + typePairToName.put(new TypePairs(int.class, float.class), "isIntToFloatExact"); + typePairToName.put(new TypePairs(long.class, byte.class), "isLongToByteExact"); + typePairToName.put(new TypePairs(long.class, short.class), "isLongToShortExact"); + typePairToName.put(new TypePairs(long.class, char.class), "isLongToCharExact"); + typePairToName.put(new TypePairs(long.class, int.class), "isLongToIntExact"); + typePairToName.put(new TypePairs(long.class, float.class), "isLongToFloatExact"); + typePairToName.put(new TypePairs(long.class, double.class), "isLongToDoubleExact"); + typePairToName.put(new TypePairs(float.class, byte.class), "isFloatToByteExact"); + typePairToName.put(new TypePairs(float.class, short.class), "isFloatToShortExact"); + typePairToName.put(new TypePairs(float.class, char.class), "isFloatToCharExact"); + typePairToName.put(new TypePairs(float.class, int.class), "isFloatToIntExact"); + typePairToName.put(new TypePairs(float.class, long.class), "isFloatToLongExact"); + typePairToName.put(new TypePairs(double.class, byte.class), "isDoubleToByteExact"); + typePairToName.put(new TypePairs(double.class, short.class), "isDoubleToShortExact"); + typePairToName.put(new TypePairs(double.class, char.class), "isDoubleToCharExact"); + typePairToName.put(new TypePairs(double.class, int.class), "isDoubleToIntExact"); + typePairToName.put(new TypePairs(double.class, long.class), "isDoubleToLongExact"); + typePairToName.put(new TypePairs(double.class, float.class), "isDoubleToFloatExact"); + return typePairToName; + } + } } diff --git a/src/java.base/share/classes/jdk/internal/foreign/LayoutPath.java b/src/java.base/share/classes/jdk/internal/foreign/LayoutPath.java index 53d306e4bc6..d389519a514 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/LayoutPath.java +++ b/src/java.base/share/classes/jdk/internal/foreign/LayoutPath.java @@ -389,10 +389,14 @@ public String description() { final PathKind kind; final UnaryOperator pathOp; + final String stringRepresentation; - public PathElementImpl(PathKind kind, UnaryOperator pathOp) { + public PathElementImpl(PathKind kind, + UnaryOperator pathOp, + String stringRepresentation) { this.kind = kind; this.pathOp = pathOp; + this.stringRepresentation = stringRepresentation; } @Override @@ -403,5 +407,10 @@ public LayoutPath apply(LayoutPath layoutPath) { public PathKind kind() { return kind; } + + @Override + public String toString() { + return stringRepresentation; + } } } diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/AnnotationVisitor.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/AnnotationVisitor.java index 474d3b7f0d7..f62f724665f 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/AnnotationVisitor.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/AnnotationVisitor.java @@ -112,6 +112,17 @@ protected AnnotationVisitor(final int api, final AnnotationVisitor annotationVis this.av = annotationVisitor; } + /** + * The annotation visitor to which this visitor must delegate method calls. May be {@literal + * null}. + * + * @return the annotation visitor to which this visitor must delegate method calls, or {@literal + * null}. + */ + public AnnotationVisitor getDelegate() { + return av; + } + /** * Visits a primitive value of the annotation. * diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ByteVector.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ByteVector.java index 4c04bff410c..33a66b2c12e 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ByteVector.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ByteVector.java @@ -403,4 +403,3 @@ private void enlarge(final int size) { data = newData; } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassReader.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassReader.java index a3c70846902..93e11a05d81 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassReader.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassReader.java @@ -407,7 +407,7 @@ public String getClassName() { } /** - * Returns the internal of name of the super class (see {@link Type#getInternalName()}). For + * Returns the internal name of the super class (see {@link Type#getInternalName()}). For * interfaces, the super class is {@link Object}. * * @return the internal name of the super class, or {@literal null} for {@link Object} class. @@ -2082,6 +2082,7 @@ private void readCode( currentOffset = bytecodeStartOffset; while (currentOffset < bytecodeEndOffset) { final int currentBytecodeOffset = currentOffset - bytecodeStartOffset; + readBytecodeInstructionOffset(currentBytecodeOffset); // Visit the label and the line number(s) for this bytecode offset, if any. Label currentLabel = labels[currentBytecodeOffset]; @@ -2697,6 +2698,20 @@ private void readCode( methodVisitor.visitMaxs(maxStack, maxLocals); } + /** + * Handles the bytecode offset of the next instruction to be visited in {@link + * #accept(ClassVisitor,int)}. This method is called just before the instruction and before its + * associated label and stack map frame, if any. The default implementation of this method does + * nothing. Subclasses can override this method to store the argument in a mutable field, for + * instance, so that {@link MethodVisitor} instances can get the bytecode offset of each visited + * instruction (if so, the usual concurrency issues related to mutable data should be addressed). + * + * @param bytecodeOffset the bytecode offset of the next instruction to be visited. + */ + protected void readBytecodeInstructionOffset(final int bytecodeOffset) { + // Do nothing by default. + } + /** * Returns the label corresponding to the given bytecode offset. The default implementation of * this method creates a label for the given offset if it has not been already created. @@ -3882,4 +3897,3 @@ public Object readConst(final int constantPoolEntryIndex, final char[] charBuffe } } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassTooLargeException.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassTooLargeException.java index fe94f7446d4..c110ec34c74 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassTooLargeException.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassTooLargeException.java @@ -74,7 +74,8 @@ public final class ClassTooLargeException extends IndexOutOfBoundsException { /** * Constructs a new {@link ClassTooLargeException}. * - * @param className the internal name of the class. + * @param className the internal name of the class (see {@link + * jdk.internal.org.objectweb.asm.Type#getInternalName()}). * @param constantPoolCount the number of constant pool items of the class. */ public ClassTooLargeException(final String className, final int constantPoolCount) { @@ -84,7 +85,7 @@ public ClassTooLargeException(final String className, final int constantPoolCoun } /** - * Returns the internal name of the class. + * Returns the internal name of the class (see {@link jdk.internal.org.objectweb.asm.Type#getInternalName()}). * * @return the internal name of the class. */ @@ -101,4 +102,3 @@ public int getConstantPoolCount() { return constantPoolCount; } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassVisitor.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassVisitor.java index 1b4fa6daaeb..21a9c721766 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassVisitor.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassVisitor.java @@ -111,6 +111,15 @@ protected ClassVisitor(final int api, final ClassVisitor classVisitor) { this.cv = classVisitor; } + /** + * The class visitor to which this visitor must delegate method calls. May be {@literal null}. + * + * @return the class visitor to which this visitor must delegate method calls, or {@literal null}. + */ + public ClassVisitor getDelegate() { + return cv; + } + /** * Visits the header of the class. * @@ -185,7 +194,8 @@ public ModuleVisitor visitModule(final String name, final int access, final Stri * implicitly its own nest, so it's invalid to call this method with the visited class name as * argument. * - * @param nestHost the internal name of the host class of the nest. + * @param nestHost the internal name of the host class of the nest (see {@link + * Type#getInternalName()}). */ public void visitNestHost(final String nestHost) { if (api < Opcodes.ASM7) { @@ -197,14 +207,19 @@ public void visitNestHost(final String nestHost) { } /** - * Visits the enclosing class of the class. This method must be called only if the class has an - * enclosing class. + * Visits the enclosing class of the class. This method must be called only if this class is a + * local or anonymous class. See the JVMS 4.7.7 section for more details. * - * @param owner internal name of the enclosing class of the class. + * @param owner internal name of the enclosing class of the class (see {@link + * Type#getInternalName()}). * @param name the name of the method that contains the class, or {@literal null} if the class is - * not enclosed in a method of its enclosing class. + * not enclosed in a method or constructor of its enclosing class (e.g. if it is enclosed in + * an instance initializer, static initializer, instance variable initializer, or class + * variable initializer). * @param descriptor the descriptor of the method that contains the class, or {@literal null} if - * the class is not enclosed in a method of its enclosing class. + * the class is not enclosed in a method or constructor of its enclosing class (e.g. if it is + * enclosed in an instance initializer, static initializer, instance variable initializer, or + * class variable initializer). */ public void visitOuterClass(final String owner, final String name, final String descriptor) { if (cv != null) { @@ -271,7 +286,7 @@ public void visitAttribute(final Attribute attribute) { * the visited class is the host of a nest. A nest host is implicitly a member of its own nest, so * it's invalid to call this method with the visited class name as argument. * - * @param nestMember the internal name of a nest member. + * @param nestMember the internal name of a nest member (see {@link Type#getInternalName()}). */ public void visitNestMember(final String nestMember) { if (api < Opcodes.ASM7) { @@ -286,7 +301,8 @@ public void visitNestMember(final String nestMember) { * Visits a permitted subclasses. A permitted subclass is one of the allowed subclasses of the * current class. * - * @param permittedSubclass the internal name of a permitted subclass. + * @param permittedSubclass the internal name of a permitted subclass (see {@link + * Type#getInternalName()}). */ public void visitPermittedSubclass(final String permittedSubclass) { if (api < Opcodes.ASM9) { @@ -299,15 +315,18 @@ public void visitPermittedSubclass(final String permittedSubclass) { /** * Visits information about an inner class. This inner class is not necessarily a member of the - * class being visited. + * class being visited. More precisely, every class or interface C which is referenced by this + * class and which is not a package member must be visited with this method. This class must + * reference its nested class or interface members, and its enclosing class, if any. See the JVMS + * 4.7.6 section for more details. * - * @param name the internal name of an inner class (see {@link Type#getInternalName()}). - * @param outerName the internal name of the class to which the inner class belongs (see {@link - * Type#getInternalName()}). May be {@literal null} for not member classes. - * @param innerName the (simple) name of the inner class inside its enclosing class. May be - * {@literal null} for anonymous inner classes. - * @param access the access flags of the inner class as originally declared in the enclosing - * class. + * @param name the internal name of C (see {@link Type#getInternalName()}). + * @param outerName the internal name of the class or interface C is a member of (see {@link + * Type#getInternalName()}). Must be {@literal null} if C is not the member of a class or + * interface (e.g. for local or anonymous classes). + * @param innerName the (simple) name of C. Must be {@literal null} for anonymous inner classes. + * @param access the access flags of C originally declared in the source code from which this + * class was compiled. */ public void visitInnerClass( final String name, final String outerName, final String innerName, final int access) { @@ -405,4 +424,3 @@ public void visitEnd() { } } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassWriter.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassWriter.java index bb9f8e36a09..d868b61c965 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassWriter.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassWriter.java @@ -249,6 +249,7 @@ public class ClassWriter extends ClassVisitor { /** * Indicates what must be automatically computed in {@link MethodWriter}. Must be one of {@link * MethodWriter#COMPUTE_NOTHING}, {@link MethodWriter#COMPUTE_MAX_STACK_AND_LOCAL}, {@link + * MethodWriter#COMPUTE_MAX_STACK_AND_LOCAL_FROM_FRAMES}, {@link * MethodWriter#COMPUTE_INSERTED_FRAMES}, or {@link MethodWriter#COMPUTE_ALL_FRAMES}. */ private int compute; @@ -874,7 +875,7 @@ public int newUTF8(final String value) { * constant pool already contains a similar item. This method is intended for {@link Attribute} * sub classes, and is normally not needed by class generators or adapters. * - * @param value the internal name of the class. + * @param value the internal name of the class (see {@link Type#getInternalName()}). * @return the index of a new or already existing class reference item. */ public int newClass(final String value) { @@ -926,7 +927,8 @@ public int newPackage(final String packageName) { * Opcodes#H_GETSTATIC}, {@link Opcodes#H_PUTFIELD}, {@link Opcodes#H_PUTSTATIC}, {@link * Opcodes#H_INVOKEVIRTUAL}, {@link Opcodes#H_INVOKESTATIC}, {@link Opcodes#H_INVOKESPECIAL}, * {@link Opcodes#H_NEWINVOKESPECIAL} or {@link Opcodes#H_INVOKEINTERFACE}. - * @param owner the internal name of the field or method owner class. + * @param owner the internal name of the field or method owner class (see {@link + * Type#getInternalName()}). * @param name the name of the field or method. * @param descriptor the descriptor of the field or method. * @return the index of a new or already existing method type reference item. @@ -948,7 +950,8 @@ public int newHandle( * Opcodes#H_GETSTATIC}, {@link Opcodes#H_PUTFIELD}, {@link Opcodes#H_PUTSTATIC}, {@link * Opcodes#H_INVOKEVIRTUAL}, {@link Opcodes#H_INVOKESTATIC}, {@link Opcodes#H_INVOKESPECIAL}, * {@link Opcodes#H_NEWINVOKESPECIAL} or {@link Opcodes#H_INVOKEINTERFACE}. - * @param owner the internal name of the field or method owner class. + * @param owner the internal name of the field or method owner class (see {@link + * Type#getInternalName()}). * @param name the name of the field or method. * @param descriptor the descriptor of the field or method. * @param isInterface true if the owner is an interface. @@ -1010,7 +1013,7 @@ public int newInvokeDynamic( * constant pool already contains a similar item. This method is intended for {@link Attribute} * sub classes, and is normally not needed by class generators or adapters. * - * @param owner the internal name of the field's owner class. + * @param owner the internal name of the field's owner class (see {@link Type#getInternalName()}). * @param name the field's name. * @param descriptor the field's descriptor. * @return the index of a new or already existing field reference item. @@ -1024,7 +1027,8 @@ public int newField(final String owner, final String name, final String descript * constant pool already contains a similar item. This method is intended for {@link Attribute} * sub classes, and is normally not needed by class generators or adapters. * - * @param owner the internal name of the method's owner class. + * @param owner the internal name of the method's owner class (see {@link + * Type#getInternalName()}). * @param name the method's name. * @param descriptor the method's descriptor. * @param isInterface {@literal true} if {@code owner} is an interface. @@ -1060,9 +1064,10 @@ public int newNameType(final String name, final String descriptor) { * currently being generated by this ClassWriter, which can of course not be loaded since it is * under construction. * - * @param type1 the internal name of a class. - * @param type2 the internal name of another class. - * @return the internal name of the common super class of the two given classes. + * @param type1 the internal name of a class (see {@link Type#getInternalName()}). + * @param type2 the internal name of another class (see {@link Type#getInternalName()}). + * @return the internal name of the common super class of the two given classes (see {@link + * Type#getInternalName()}). */ protected String getCommonSuperClass(final String type1, final String type2) { ClassLoader classLoader = getClassLoader(); @@ -1105,4 +1110,3 @@ protected ClassLoader getClassLoader() { return getClass().getClassLoader(); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ConstantDynamic.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ConstantDynamic.java index 457bec9c94a..cb992f839ef 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ConstantDynamic.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ConstantDynamic.java @@ -208,4 +208,3 @@ public String toString() { + Arrays.toString(bootstrapMethodArguments); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Constants.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Constants.java index cc10a3cee72..0fc081fe391 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Constants.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Constants.java @@ -251,4 +251,3 @@ static void checkIsPreview(final InputStream classInputStream) { } } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Context.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Context.java index 9b64452a096..bec67f5333b 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Context.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Context.java @@ -166,4 +166,3 @@ final class Context { */ Object[] currentFrameStackTypes; } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/CurrentFrame.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/CurrentFrame.java index 32a4544dfd7..580b9a95415 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/CurrentFrame.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/CurrentFrame.java @@ -85,4 +85,3 @@ void execute( copyFrom(successor); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Edge.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Edge.java index 3da370335ff..59a7ee83fdb 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Edge.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Edge.java @@ -121,4 +121,3 @@ final class Edge { this.nextEdge = nextEdge; } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/FieldVisitor.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/FieldVisitor.java index 9cfe475150b..7d29f3d4ff7 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/FieldVisitor.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/FieldVisitor.java @@ -108,6 +108,15 @@ protected FieldVisitor(final int api, final FieldVisitor fieldVisitor) { this.fv = fieldVisitor; } + /** + * The field visitor to which this visitor must delegate method calls. May be {@literal null}. + * + * @return the field visitor to which this visitor must delegate method calls, or {@literal null}. + */ + public FieldVisitor getDelegate() { + return fv; + } + /** * Visits an annotation of the field. * @@ -168,4 +177,3 @@ public void visitEnd() { } } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/FieldWriter.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/FieldWriter.java index dd3b445056d..c3e78d04cd6 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/FieldWriter.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/FieldWriter.java @@ -314,4 +314,3 @@ final void collectAttributePrototypes(final Attribute.Set attributePrototypes) { attributePrototypes.addAttributes(firstAttribute); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Frame.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Frame.java index 53cef113943..cfb892e60b0 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Frame.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Frame.java @@ -96,8 +96,8 @@ * right shift of {@link #DIM_SHIFT}. *
  • the KIND field, stored in 4 bits, indicates the kind of VALUE used. These 4 bits can be * retrieved with {@link #KIND_MASK} and, without any shift, must be equal to {@link - * #CONSTANT_KIND}, {@link #REFERENCE_KIND}, {@link #UNINITIALIZED_KIND}, {@link #LOCAL_KIND} - * or {@link #STACK_KIND}. + * #CONSTANT_KIND}, {@link #REFERENCE_KIND}, {@link #UNINITIALIZED_KIND}, {@link + * #FORWARD_UNINITIALIZED_KIND},{@link #LOCAL_KIND} or {@link #STACK_KIND}. *
  • the FLAGS field, stored in 2 bits, contains up to 2 boolean flags. Currently only one flag * is defined, namely {@link #TOP_IF_LONG_OR_DOUBLE_FLAG}. *
  • the VALUE field, stored in the remaining 20 bits, contains either @@ -110,7 +110,10 @@ *
  • the index of a {@link Symbol#TYPE_TAG} {@link Symbol} in the type table of a {@link * SymbolTable}, if KIND is equal to {@link #REFERENCE_KIND}. *
  • the index of an {@link Symbol#UNINITIALIZED_TYPE_TAG} {@link Symbol} in the type - * table of a SymbolTable, if KIND is equal to {@link #UNINITIALIZED_KIND}. + * table of a {@link SymbolTable}, if KIND is equal to {@link #UNINITIALIZED_KIND}. + *
  • the index of a {@link Symbol#FORWARD_UNINITIALIZED_TYPE_TAG} {@link Symbol} in the + * type table of a {@link SymbolTable}, if KIND is equal to {@link + * #FORWARD_UNINITIALIZED_KIND}. *
  • the index of a local variable in the input stack frame, if KIND is equal to {@link * #LOCAL_KIND}. *
  • a position relatively to the top of the stack of the input stack frame, if KIND is @@ -120,10 +123,10 @@ * *

    Output frames can contain abstract types of any kind and with a positive or negative array * dimension (and even unassigned types, represented by 0 - which does not correspond to any valid - * abstract type value). Input frames can only contain CONSTANT_KIND, REFERENCE_KIND or - * UNINITIALIZED_KIND abstract types of positive or {@literal null} array dimension. In all cases - * the type table contains only internal type names (array type descriptors are forbidden - array - * dimensions must be represented through the DIM field). + * abstract type value). Input frames can only contain CONSTANT_KIND, REFERENCE_KIND, + * UNINITIALIZED_KIND or FORWARD_UNINITIALIZED_KIND abstract types of positive or {@literal null} + * array dimension. In all cases the type table contains only internal type names (array type + * descriptors are forbidden - array dimensions must be represented through the DIM field). * *

    The LONG and DOUBLE types are always represented by using two slots (LONG + TOP or DOUBLE + * TOP), for local variables as well as in the operand stack. This is necessary to be able to @@ -191,8 +194,9 @@ class Frame { private static final int CONSTANT_KIND = 1 << KIND_SHIFT; private static final int REFERENCE_KIND = 2 << KIND_SHIFT; private static final int UNINITIALIZED_KIND = 3 << KIND_SHIFT; - private static final int LOCAL_KIND = 4 << KIND_SHIFT; - private static final int STACK_KIND = 5 << KIND_SHIFT; + private static final int FORWARD_UNINITIALIZED_KIND = 4 << KIND_SHIFT; + private static final int LOCAL_KIND = 5 << KIND_SHIFT; + private static final int STACK_KIND = 6 << KIND_SHIFT; // Possible flags for the FLAGS field of an abstract type. @@ -252,13 +256,13 @@ class Frame { /** * The abstract types that are initialized in the basic block. A constructor invocation on an - * UNINITIALIZED or UNINITIALIZED_THIS abstract type must replace every occurrence of this - * type in the local variables and in the operand stack. This cannot be done during the first step - * of the algorithm since, during this step, the local variables and the operand stack types are - * still abstract. It is therefore necessary to store the abstract types of the constructors which - * are invoked in the basic block, in order to do this replacement during the second step of the - * algorithm, where the frames are fully computed. Note that this array can contain abstract types - * that are relative to the input locals or to the input stack. + * UNINITIALIZED, FORWARD_UNINITIALIZED or UNINITIALIZED_THIS abstract type must replace every + * occurrence of this type in the local variables and in the operand stack. This cannot be + * done during the first step of the algorithm since, during this step, the local variables and + * the operand stack types are still abstract. It is therefore necessary to store the abstract + * types of the constructors which are invoked in the basic block, in order to do this replacement + * during the second step of the algorithm, where the frames are fully computed. Note that this + * array can contain abstract types that are relative to the input locals or to the input stack. */ private int[] initializations; @@ -316,8 +320,12 @@ static int getAbstractTypeFromApiFormat(final SymbolTable symbolTable, final Obj String descriptor = Type.getObjectType((String) type).getDescriptor(); return getAbstractTypeFromDescriptor(symbolTable, descriptor, 0); } else { - return UNINITIALIZED_KIND - | symbolTable.addUninitializedType("", ((Label) type).bytecodeOffset); + Label label = (Label) type; + if ((label.flags & Label.FLAG_RESOLVED) != 0) { + return UNINITIALIZED_KIND | symbolTable.addUninitializedType("", label.bytecodeOffset); + } else { + return FORWARD_UNINITIALIZED_KIND | symbolTable.addForwardUninitializedType("", label); + } } } @@ -399,11 +407,12 @@ private static int getAbstractTypeFromDescriptor( typeValue = REFERENCE_KIND | symbolTable.addType(internalName); break; default: - throw new IllegalArgumentException(); + throw new IllegalArgumentException( + "Invalid descriptor fragment: " + buffer.substring(elementDescriptorOffset)); } return ((elementDescriptorOffset - offset) << DIM_SHIFT) | typeValue; default: - throw new IllegalArgumentException(); + throw new IllegalArgumentException("Invalid descriptor: " + buffer.substring(offset)); } } @@ -611,7 +620,7 @@ private int pop() { */ private void pop(final int elements) { if (outputStackTop >= elements) { - outputStackTop -= (short) elements; + outputStackTop -= (short)elements; } else { // If the number of elements to be popped is greater than the number of elements in the output // stack, clear it, and pop the remaining elements from the input stack. @@ -668,12 +677,14 @@ private void addInitializedType(final int abstractType) { * @param symbolTable the type table to use to lookup and store type {@link Symbol}. * @param abstractType an abstract type. * @return the REFERENCE_KIND abstract type corresponding to abstractType if it is - * UNINITIALIZED_THIS or an UNINITIALIZED_KIND abstract type for one of the types on which a - * constructor is invoked in the basic block. Otherwise returns abstractType. + * UNINITIALIZED_THIS or an UNINITIALIZED_KIND or FORWARD_UNINITIALIZED_KIND abstract type for + * one of the types on which a constructor is invoked in the basic block. Otherwise returns + * abstractType. */ private int getInitializedType(final SymbolTable symbolTable, final int abstractType) { if (abstractType == UNINITIALIZED_THIS - || (abstractType & (DIM_MASK | KIND_MASK)) == UNINITIALIZED_KIND) { + || (abstractType & (DIM_MASK | KIND_MASK)) == UNINITIALIZED_KIND + || (abstractType & (DIM_MASK | KIND_MASK)) == FORWARD_UNINITIALIZED_KIND) { for (int i = 0; i < initializationCount; ++i) { int initializedType = initializations[i]; int dim = initializedType & DIM_MASK; @@ -1284,11 +1295,12 @@ final boolean merge( * * @param symbolTable the type table to use to lookup and store type {@link Symbol}. * @param sourceType the abstract type with which the abstract type array element must be merged. - * This type should be of {@link #CONSTANT_KIND}, {@link #REFERENCE_KIND} or {@link - * #UNINITIALIZED_KIND} kind, with positive or {@literal null} array dimensions. + * This type should be of {@link #CONSTANT_KIND}, {@link #REFERENCE_KIND}, {@link + * #UNINITIALIZED_KIND} or {@link #FORWARD_UNINITIALIZED_KIND} kind, with positive or + * {@literal null} array dimensions. * @param dstTypes an array of abstract types. These types should be of {@link #CONSTANT_KIND}, - * {@link #REFERENCE_KIND} or {@link #UNINITIALIZED_KIND} kind, with positive or {@literal - * null} array dimensions. + * {@link #REFERENCE_KIND}, {@link #UNINITIALIZED_KIND} or {@link #FORWARD_UNINITIALIZED_KIND} + * kind, with positive or {@literal null} array dimensions. * @param dstIndex the index of the type that must be merged in dstTypes. * @return {@literal true} if the type array has been modified by this operation. */ @@ -1431,7 +1443,8 @@ final void accept(final MethodWriter methodWriter) { * * @param symbolTable the type table to use to lookup and store type {@link Symbol}. * @param abstractType an abstract type, restricted to {@link Frame#CONSTANT_KIND}, {@link - * Frame#REFERENCE_KIND} or {@link Frame#UNINITIALIZED_KIND} types. + * Frame#REFERENCE_KIND}, {@link Frame#UNINITIALIZED_KIND} or {@link + * Frame#FORWARD_UNINITIALIZED_KIND} types. * @param output where the abstract type must be put. * @see JVMS * 4.7.4 @@ -1453,6 +1466,10 @@ static void putAbstractType( case UNINITIALIZED_KIND: output.putByte(ITEM_UNINITIALIZED).putShort((int) symbolTable.getType(typeValue).data); break; + case FORWARD_UNINITIALIZED_KIND: + output.putByte(ITEM_UNINITIALIZED); + symbolTable.getForwardUninitializedLabel(typeValue).put(output); + break; default: throw new AssertionError(); } diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Handle.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Handle.java index 991fc6aabf5..7e5a9e1a3b3 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Handle.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Handle.java @@ -96,7 +96,7 @@ public final class Handle { * {@link Opcodes#H_INVOKESPECIAL}, {@link Opcodes#H_NEWINVOKESPECIAL} or {@link * Opcodes#H_INVOKEINTERFACE}. * @param owner the internal name of the class that owns the field or method designated by this - * handle. + * handle (see {@link Type#getInternalName()}). * @param name the name of the field or method designated by this handle. * @param descriptor the descriptor of the field or method designated by this handle. * @deprecated this constructor has been superseded by {@link #Handle(int, String, String, String, @@ -116,7 +116,7 @@ public Handle(final int tag, final String owner, final String name, final String * {@link Opcodes#H_INVOKESPECIAL}, {@link Opcodes#H_NEWINVOKESPECIAL} or {@link * Opcodes#H_INVOKEINTERFACE}. * @param owner the internal name of the class that owns the field or method designated by this - * handle. + * handle (see {@link Type#getInternalName()}). * @param name the name of the field or method designated by this handle. * @param descriptor the descriptor of the field or method designated by this handle. * @param isInterface whether the owner is an interface or not. @@ -149,7 +149,8 @@ public int getTag() { /** * Returns the internal name of the class that owns the field or method designated by this handle. * - * @return the internal name of the class that owns the field or method designated by this handle. + * @return the internal name of the class that owns the field or method designated by this handle + * (see {@link Type#getInternalName()}). */ public String getOwner() { return owner; @@ -218,4 +219,3 @@ public String toString() { return owner + '.' + name + descriptor + " (" + tag + (isInterface ? " itf" : "") + ')'; } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Handler.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Handler.java index 848a6d1e14c..3d86e222ab8 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Handler.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Handler.java @@ -228,4 +228,3 @@ static void putExceptionTable(final Handler firstHandler, final ByteVector outpu } } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Label.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Label.java index a24413f7663..c321fc8a200 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Label.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Label.java @@ -113,6 +113,9 @@ public class Label { /** A flag indicating that the basic block corresponding to a label is the end of a subroutine. */ static final int FLAG_SUBROUTINE_END = 64; + /** A flag indicating that this label has at least one associated line number. */ + static final int FLAG_LINE_NUMBER = 128; + /** * The number of elements to add to the {@link #otherLineNumbers} array when it needs to be * resized to store a new source line number. @@ -145,6 +148,13 @@ public class Label { */ static final int FORWARD_REFERENCE_TYPE_WIDE = 0x20000000; + /** + * The type of forward references stored in two bytes in the stack map table. This is the + * case of the labels of {@link Frame#ITEM_UNINITIALIZED} stack map frame elements, when the NEW + * instruction is after the <init> constructor call (in bytecode offset order). + */ + static final int FORWARD_REFERENCE_TYPE_STACK_MAP = 0x30000000; + /** * The bit mask to extract the 'handle' of a forward reference to this label. The extracted handle * is the bytecode offset where the forward reference value is stored (using either 2 or 4 bytes, @@ -177,9 +187,9 @@ public class Label { short flags; /** - * The source line number corresponding to this label, or 0. If there are several source line - * numbers corresponding to this label, the first one is stored in this field, and the remaining - * ones are stored in {@link #otherLineNumbers}. + * The source line number corresponding to this label, if {@link #FLAG_LINE_NUMBER} is set. If + * there are several source line numbers corresponding to this label, the first one is stored in + * this field, and the remaining ones are stored in {@link #otherLineNumbers}. */ private short lineNumber; @@ -364,7 +374,8 @@ final Label getCanonicalInstance() { * @param lineNumber a source line number (which should be strictly positive). */ final void addLineNumber(final int lineNumber) { - if (this.lineNumber == 0) { + if ((flags & FLAG_LINE_NUMBER) == 0) { + flags |= FLAG_LINE_NUMBER; this.lineNumber = (short) lineNumber; } else { if (otherLineNumbers == null) { @@ -388,7 +399,7 @@ final void addLineNumber(final int lineNumber) { */ final void accept(final MethodVisitor methodVisitor, final boolean visitLineNumbers) { methodVisitor.visitLabel(this); - if (visitLineNumbers && lineNumber != 0) { + if (visitLineNumbers && (flags & FLAG_LINE_NUMBER) != 0) { methodVisitor.visitLineNumber(lineNumber & 0xFFFF, this); if (otherLineNumbers != null) { for (int i = 1; i <= otherLineNumbers[0]; ++i) { @@ -432,6 +443,20 @@ final void put( } } + /** + * Puts a reference to this label in the stack map table of a method. If the bytecode + * offset of the label is known, it is written directly. Otherwise, a null relative offset is + * written and a new forward reference is declared for this label. + * + * @param stackMapTableEntries the stack map table where the label offset must be added. + */ + final void put(final ByteVector stackMapTableEntries) { + if ((flags & FLAG_RESOLVED) == 0) { + addForwardReference(0, FORWARD_REFERENCE_TYPE_STACK_MAP, stackMapTableEntries.length); + } + stackMapTableEntries.putShort(bytecodeOffset); + } + /** * Adds a forward reference to this label. This method must be called only for a true forward * reference, i.e. only if this label is not resolved yet. For backward references, the relative @@ -464,9 +489,12 @@ private void addForwardReference( * Sets the bytecode offset of this label to the given value and resolves the forward references * to this label, if any. This method must be called when this label is added to the bytecode of * the method, i.e. when its bytecode offset becomes known. This method fills in the blanks that - * where left in the bytecode by each forward reference previously added to this label. + * where left in the bytecode (and optionally in the stack map table) by each forward reference + * previously added to this label. * * @param code the bytecode of the method. + * @param stackMapTableEntries the 'entries' array of the StackMapTable code attribute of the + * method. Maybe {@literal null}. * @param bytecodeOffset the bytecode offset of this label. * @return {@literal true} if a blank that was left for this label was too small to store the * offset. In such a case the corresponding jump instruction is replaced with an equivalent @@ -474,7 +502,8 @@ private void addForwardReference( * instructions are later replaced with standard bytecode instructions with wider offsets (4 * bytes instead of 2), in ClassReader. */ - final boolean resolve(final byte[] code, final int bytecodeOffset) { + final boolean resolve( + final byte[] code, final ByteVector stackMapTableEntries, final int bytecodeOffset) { this.flags |= FLAG_RESOLVED; this.bytecodeOffset = bytecodeOffset; if (forwardReferences == null) { @@ -504,11 +533,14 @@ final boolean resolve(final byte[] code, final int bytecodeOffset) { } code[handle++] = (byte) (relativeOffset >>> 8); code[handle] = (byte) relativeOffset; - } else { + } else if ((reference & FORWARD_REFERENCE_TYPE_MASK) == FORWARD_REFERENCE_TYPE_WIDE) { code[handle++] = (byte) (relativeOffset >>> 24); code[handle++] = (byte) (relativeOffset >>> 16); code[handle++] = (byte) (relativeOffset >>> 8); code[handle] = (byte) relativeOffset; + } else { + stackMapTableEntries.data[handle++] = (byte) (bytecodeOffset >>> 8); + stackMapTableEntries.data[handle] = (byte) bytecodeOffset; } } return hasAsmInstructions; @@ -652,4 +684,3 @@ public String toString() { return "L" + System.identityHashCode(this); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/MethodTooLargeException.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/MethodTooLargeException.java index 6c7252e35fb..a2c9cee1836 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/MethodTooLargeException.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/MethodTooLargeException.java @@ -76,7 +76,7 @@ public final class MethodTooLargeException extends IndexOutOfBoundsException { /** * Constructs a new {@link MethodTooLargeException}. * - * @param className the internal name of the owner class. + * @param className the internal name of the owner class (see {@link Type#getInternalName()}). * @param methodName the name of the method. * @param descriptor the descriptor of the method. * @param codeSize the size of the method's Code attribute, in bytes. @@ -96,7 +96,7 @@ public MethodTooLargeException( /** * Returns the internal name of the owner class. * - * @return the internal name of the owner class. + * @return the internal name of the owner class (see {@link Type#getInternalName()}). */ public String getClassName() { return className; @@ -129,4 +129,3 @@ public int getCodeSize() { return codeSize; } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/MethodVisitor.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/MethodVisitor.java index 481592676e4..08c3adb2171 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/MethodVisitor.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/MethodVisitor.java @@ -62,7 +62,7 @@ /** * A visitor to visit a Java method. The methods of this class must be called in the following * order: ( {@code visitParameter} )* [ {@code visitAnnotationDefault} ] ( {@code visitAnnotation} | - * {@code visitAnnotableParameterCount} | {@code visitParameterAnnotation} {@code + * {@code visitAnnotableParameterCount} | {@code visitParameterAnnotation} | {@code * visitTypeAnnotation} | {@code visitAttribute} )* [ {@code visitCode} ( {@code visitFrame} | * {@code visitXInsn} | {@code visitLabel} | {@code visitInsnAnnotation} | {@code * visitTryCatchBlock} | {@code visitTryCatchAnnotation} | {@code visitLocalVariable} | {@code @@ -124,6 +124,16 @@ protected MethodVisitor(final int api, final MethodVisitor methodVisitor) { this.mv = methodVisitor; } + /** + * The method visitor to which this visitor must delegate method calls. May be {@literal null}. + * + * @return the method visitor to which this visitor must delegate method calls, or {@literal + * null}. + */ + public MethodVisitor getDelegate() { + return mv; + } + // ----------------------------------------------------------------------------------------------- // Parameters, annotations and non standard attributes // ----------------------------------------------------------------------------------------------- @@ -150,7 +160,7 @@ public void visitParameter(final String name, final int access) { * @return a visitor to the visit the actual default value of this annotation interface method, or * {@literal null} if this visitor is not interested in visiting this default value. The * 'name' parameters passed to the methods of this annotation visitor are ignored. Moreover, - * exacly one visit method must be called on this annotation visitor, followed by visitEnd. + * exactly one visit method must be called on this annotation visitor, followed by visitEnd. */ public AnnotationVisitor visitAnnotationDefault() { if (mv != null) { @@ -303,15 +313,17 @@ public void visitCode() { * @param type the type of this stack map frame. Must be {@link Opcodes#F_NEW} for expanded * frames, or {@link Opcodes#F_FULL}, {@link Opcodes#F_APPEND}, {@link Opcodes#F_CHOP}, {@link * Opcodes#F_SAME} or {@link Opcodes#F_APPEND}, {@link Opcodes#F_SAME1} for compressed frames. - * @param numLocal the number of local variables in the visited frame. + * @param numLocal the number of local variables in the visited frame. Long and double values + * count for one variable. * @param local the local variable types in this frame. This array must not be modified. Primitive * types are represented by {@link Opcodes#TOP}, {@link Opcodes#INTEGER}, {@link * Opcodes#FLOAT}, {@link Opcodes#LONG}, {@link Opcodes#DOUBLE}, {@link Opcodes#NULL} or * {@link Opcodes#UNINITIALIZED_THIS} (long and double are represented by a single element). - * Reference types are represented by String objects (representing internal names), and - * uninitialized types by Label objects (this label designates the NEW instruction that - * created this uninitialized value). - * @param numStack the number of operand stack elements in the visited frame. + * Reference types are represented by String objects (representing internal names, see {@link + * Type#getInternalName()}), and uninitialized types by Label objects (this label designates + * the NEW instruction that created this uninitialized value). + * @param numStack the number of operand stack elements in the visited frame. Long and double + * values count for one stack element. * @param stack the operand stack types in this frame. This array must not be modified. Its * content has the same format as the "local" array. * @throws IllegalStateException if a frame is visited just after another one, without any @@ -390,7 +402,7 @@ public void visitVarInsn(final int opcode, final int varIndex) { /** * Visits a type instruction. A type instruction is an instruction that takes the internal name of - * a class as parameter. + * a class as parameter (see {@link Type#getInternalName()}). * * @param opcode the opcode of the type instruction to be visited. This opcode is either NEW, * ANEWARRAY, CHECKCAST or INSTANCEOF. @@ -673,8 +685,9 @@ public AnnotationVisitor visitInsnAnnotation( * @param start the beginning of the exception handler's scope (inclusive). * @param end the end of the exception handler's scope (exclusive). * @param handler the beginning of the exception handler's code. - * @param type the internal name of the type of exceptions handled by the handler, or {@literal - * null} to catch any exceptions (for "finally" blocks). + * @param type the internal name of the type of exceptions handled by the handler (see {@link + * Type#getInternalName()}), or {@literal null} to catch any exceptions (for "finally" + * blocks). * @throws IllegalArgumentException if one of the labels has already been visited by this visitor * (by the {@link #visitLabel} method). */ @@ -812,4 +825,3 @@ public void visitEnd() { } } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/MethodWriter.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/MethodWriter.java index 4260b9ae515..efeffc7b1eb 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/MethodWriter.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/MethodWriter.java @@ -566,8 +566,9 @@ final class MethodWriter extends MethodVisitor { * the number of stack elements. The local variables start at index 3 and are followed by the * operand stack elements. In summary frame[0] = offset, frame[1] = numLocal, frame[2] = numStack. * Local variables and operand stack entries contain abstract types, as defined in {@link Frame}, - * but restricted to {@link Frame#CONSTANT_KIND}, {@link Frame#REFERENCE_KIND} or {@link - * Frame#UNINITIALIZED_KIND} abstract types. Long and double types use only one array entry. + * but restricted to {@link Frame#CONSTANT_KIND}, {@link Frame#REFERENCE_KIND}, {@link + * Frame#UNINITIALIZED_KIND} or {@link Frame#FORWARD_UNINITIALIZED_KIND} abstract types. Long and + * double types use only one array entry. */ private int[] currentFrame; @@ -725,7 +726,7 @@ public AnnotationVisitor visitParameterAnnotation( if (visible) { if (lastRuntimeVisibleParameterAnnotations == null) { lastRuntimeVisibleParameterAnnotations = - new AnnotationWriter[Type.getArgumentTypes(descriptor).length]; + new AnnotationWriter[Type.getArgumentCount(descriptor)]; } return lastRuntimeVisibleParameterAnnotations[parameter] = AnnotationWriter.create( @@ -733,7 +734,7 @@ public AnnotationVisitor visitParameterAnnotation( } else { if (lastRuntimeInvisibleParameterAnnotations == null) { lastRuntimeInvisibleParameterAnnotations = - new AnnotationWriter[Type.getArgumentTypes(descriptor).length]; + new AnnotationWriter[Type.getArgumentCount(descriptor)]; } return lastRuntimeInvisibleParameterAnnotations[parameter] = AnnotationWriter.create( @@ -1231,7 +1232,7 @@ public void visitJumpInsn(final int opcode, final Label label) { @Override public void visitLabel(final Label label) { // Resolve the forward references to this label, if any. - hasAsmInstructions |= label.resolve(code.data, code.length); + hasAsmInstructions |= label.resolve(code.data, stackMapTableEntries, code.length); // visitLabel starts a new basic block (except for debug only labels), so we need to update the // previous and current block references and list of successors. if ((label.flags & Label.FLAG_DEBUG_ONLY) != 0) { @@ -1244,7 +1245,7 @@ public void visitLabel(final Label label) { // one place, but this does not work for labels which have not been visited yet. // Therefore, when we detect here two labels having the same bytecode offset, we need to // - consolidate the state scattered in these two instances into the canonical instance: - currentBasicBlock.flags |= (short) (label.flags & Label.FLAG_JUMP_TARGET); + currentBasicBlock.flags |= (short)(label.flags & Label.FLAG_JUMP_TARGET); // - make sure the two instances share the same Frame instance (the implementation of // {@link Label#getCanonicalInstance} relies on this property; here label.frame should be // null): @@ -1260,7 +1261,7 @@ public void visitLabel(final Label label) { if (lastBasicBlock != null) { if (label.bytecodeOffset == lastBasicBlock.bytecodeOffset) { // Same comment as above. - lastBasicBlock.flags |= (short) (label.flags & Label.FLAG_JUMP_TARGET); + lastBasicBlock.flags |= (short)(label.flags & Label.FLAG_JUMP_TARGET); // Here label.frame should be null. label.frame = lastBasicBlock.frame; currentBasicBlock = lastBasicBlock; @@ -1827,7 +1828,7 @@ private void endCurrentBasicBlockWithNoSuccessor() { if (compute == COMPUTE_ALL_FRAMES) { Label nextBasicBlock = new Label(); nextBasicBlock.frame = new Frame(nextBasicBlock); - nextBasicBlock.resolve(code.data, code.length); + nextBasicBlock.resolve(code.data, stackMapTableEntries, code.length); lastBasicBlock.nextBasicBlock = nextBasicBlock; lastBasicBlock = nextBasicBlock; currentBasicBlock = null; @@ -2011,9 +2012,8 @@ private void putFrameType(final Object type) { .putByte(Frame.ITEM_OBJECT) .putShort(symbolTable.addConstantClass((String) type).index); } else { - stackMapTableEntries - .putByte(Frame.ITEM_UNINITIALIZED) - .putShort(((Label) type).bytecodeOffset); + stackMapTableEntries.putByte(Frame.ITEM_UNINITIALIZED); + ((Label) type).put(stackMapTableEntries); } } diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ModuleVisitor.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ModuleVisitor.java index 7a3cbf01614..0e8f484368b 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ModuleVisitor.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ModuleVisitor.java @@ -110,10 +110,21 @@ protected ModuleVisitor(final int api, final ModuleVisitor moduleVisitor) { this.mv = moduleVisitor; } + /** + * The module visitor to which this visitor must delegate method calls. May be {@literal null}. + * + * @return the module visitor to which this visitor must delegate method calls, or {@literal + * null}. + */ + public ModuleVisitor getDelegate() { + return mv; + } + /** * Visit the main class of the current module. * - * @param mainClass the internal name of the main class of the current module. + * @param mainClass the internal name of the main class of the current module (see {@link + * Type#getInternalName()}). */ public void visitMainClass(final String mainClass) { if (mv != null) { @@ -124,7 +135,7 @@ public void visitMainClass(final String mainClass) { /** * Visit a package of the current module. * - * @param packaze the internal name of a package. + * @param packaze the internal name of a package (see {@link Type#getInternalName()}). */ public void visitPackage(final String packaze) { if (mv != null) { @@ -149,7 +160,7 @@ public void visitRequire(final String module, final int access, final String ver /** * Visit an exported package of the current module. * - * @param packaze the internal name of the exported package. + * @param packaze the internal name of the exported package (see {@link Type#getInternalName()}). * @param access the access flag of the exported package, valid values are among {@code * ACC_SYNTHETIC} and {@code ACC_MANDATED}. * @param modules the fully qualified names (using dots) of the modules that can access the public @@ -164,7 +175,7 @@ public void visitExport(final String packaze, final int access, final String... /** * Visit an open package of the current module. * - * @param packaze the internal name of the opened package. + * @param packaze the internal name of the opened package (see {@link Type#getInternalName()}). * @param access the access flag of the opened package, valid values are among {@code * ACC_SYNTHETIC} and {@code ACC_MANDATED}. * @param modules the fully qualified names (using dots) of the modules that can use deep @@ -180,7 +191,7 @@ public void visitOpen(final String packaze, final int access, final String... mo * Visit a service used by the current module. The name must be the internal name of an interface * or a class. * - * @param service the internal name of the service. + * @param service the internal name of the service (see {@link Type#getInternalName()}). */ public void visitUse(final String service) { if (mv != null) { @@ -191,9 +202,9 @@ public void visitUse(final String service) { /** * Visit an implementation of a service. * - * @param service the internal name of the service. - * @param providers the internal names of the implementations of the service (there is at least - * one provider). + * @param service the internal name of the service (see {@link Type#getInternalName()}). + * @param providers the internal names (see {@link Type#getInternalName()}) of the implementations + * of the service (there is at least one provider). */ public void visitProvide(final String service, final String... providers) { if (mv != null) { @@ -211,4 +222,3 @@ public void visitEnd() { } } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ModuleWriter.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ModuleWriter.java index 8680488d7a0..18b1a22fb36 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ModuleWriter.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ModuleWriter.java @@ -283,4 +283,3 @@ void putAttributes(final ByteVector output) { } } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Opcodes.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Opcodes.java index edb118cfce4..8353b7872be 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Opcodes.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Opcodes.java @@ -588,4 +588,3 @@ public interface Opcodes { int IFNULL = 198; // visitJumpInsn int IFNONNULL = 199; // - } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/RecordComponentVisitor.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/RecordComponentVisitor.java index e0e55462f37..ad0aad6b0e6 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/RecordComponentVisitor.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/RecordComponentVisitor.java @@ -77,7 +77,7 @@ public abstract class RecordComponentVisitor { /** * The record visitor to which this visitor must delegate method calls. May be {@literal null}. */ - /*package-private*/ RecordComponentVisitor delegate; + protected RecordComponentVisitor delegate; /** * Constructs a new {@link RecordComponentVisitor}. @@ -113,7 +113,8 @@ protected RecordComponentVisitor( /** * The record visitor to which this visitor must delegate method calls. May be {@literal null}. * - * @return the record visitor to which this visitor must delegate method calls or {@literal null}. + * @return the record visitor to which this visitor must delegate method calls, or {@literal + * null}. */ public RecordComponentVisitor getDelegate() { return delegate; @@ -178,4 +179,3 @@ public void visitEnd() { } } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/RecordComponentWriter.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/RecordComponentWriter.java index 47a27debd65..3098cf70c8d 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/RecordComponentWriter.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/RecordComponentWriter.java @@ -255,4 +255,3 @@ final void collectAttributePrototypes(final Attribute.Set attributePrototypes) { attributePrototypes.addAttributes(firstAttribute); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Symbol.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Symbol.java index a6b17c650af..a45f75a0301 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Symbol.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Symbol.java @@ -135,12 +135,25 @@ abstract class Symbol { static final int TYPE_TAG = 128; /** - * The tag value of an {@link Frame#ITEM_UNINITIALIZED} type entry in the type table of a class. + * The tag value of an uninitialized type entry in the type table of a class. This type is used + * for the normal case where the NEW instruction is before the <init> constructor call (in + * bytecode offset order), i.e. when the label of the NEW instruction is resolved when the + * constructor call is visited. If the NEW instruction is after the constructor call, use the + * {@link #FORWARD_UNINITIALIZED_TYPE_TAG} tag value instead. */ static final int UNINITIALIZED_TYPE_TAG = 129; + /** + * The tag value of an uninitialized type entry in the type table of a class. This type is used + * for the unusual case where the NEW instruction is after the <init> constructor call (in + * bytecode offset order), i.e. when the label of the NEW instruction is not resolved when the + * constructor call is visited. If the NEW instruction is before the constructor call, use the + * {@link #UNINITIALIZED_TYPE_TAG} tag value instead. + */ + static final int FORWARD_UNINITIALIZED_TYPE_TAG = 130; + /** The tag value of a merged type entry in the (ASM specific) type table of a class. */ - static final int MERGED_TYPE_TAG = 130; + static final int MERGED_TYPE_TAG = 131; // Instance fields. @@ -183,8 +196,8 @@ abstract class Symbol { * #CONSTANT_INVOKE_DYNAMIC_TAG} symbols, *

  • an arbitrary string for {@link #CONSTANT_UTF8_TAG} and {@link #CONSTANT_STRING_TAG} * symbols, - *
  • an internal class name for {@link #CONSTANT_CLASS_TAG}, {@link #TYPE_TAG} and {@link - * #UNINITIALIZED_TYPE_TAG} symbols, + *
  • an internal class name for {@link #CONSTANT_CLASS_TAG}, {@link #TYPE_TAG}, {@link + * #UNINITIALIZED_TYPE_TAG} and {@link #FORWARD_UNINITIALIZED_TYPE_TAG} symbols, *
  • {@literal null} for the other types of symbol. * */ @@ -204,6 +217,9 @@ abstract class Symbol { * {@link #CONSTANT_DYNAMIC_TAG} or {@link #BOOTSTRAP_METHOD_TAG} symbols, *
  • the bytecode offset of the NEW instruction that created an {@link * Frame#ITEM_UNINITIALIZED} type for {@link #UNINITIALIZED_TYPE_TAG} symbols, + *
  • the index of the {@link Label} (in the {@link SymbolTable#labelTable} table) of the NEW + * instruction that created an {@link Frame#ITEM_UNINITIALIZED} type for {@link + * #FORWARD_UNINITIALIZED_TYPE_TAG} symbols, *
  • the indices (in the class' type table) of two {@link #TYPE_TAG} source types for {@link * #MERGED_TYPE_TAG} symbols, *
  • 0 for the other types of symbol. @@ -273,4 +289,3 @@ int getArgumentsAndReturnSizes() { return info; } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/SymbolTable.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/SymbolTable.java index 2ca923859f4..5fc629d6809 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/SymbolTable.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/SymbolTable.java @@ -140,11 +140,35 @@ final class SymbolTable { * An ASM specific type table used to temporarily store internal names that will not necessarily * be stored in the constant pool. This type table is used by the control flow and data flow * analysis algorithm used to compute stack map frames from scratch. This array stores {@link - * Symbol#TYPE_TAG} and {@link Symbol#UNINITIALIZED_TYPE_TAG}) Symbol. The type symbol at index - * {@code i} has its {@link Symbol#index} equal to {@code i} (and vice versa). + * Symbol#TYPE_TAG}, {@link Symbol#UNINITIALIZED_TYPE_TAG},{@link + * Symbol#FORWARD_UNINITIALIZED_TYPE_TAG} and {@link Symbol#MERGED_TYPE_TAG} entries. The type + * symbol at index {@code i} has its {@link Symbol#index} equal to {@code i} (and vice versa). */ private Entry[] typeTable; + /** + * The actual number of {@link LabelEntry} in {@link #labelTable}. These elements are stored from + * index 0 to labelCount (excluded). The other array entries are empty. These label entries are + * also stored in the {@link #labelEntries} hash set. + */ + private int labelCount; + + /** + * The labels corresponding to the "forward uninitialized" types in the ASM specific {@link + * typeTable} (see {@link Symbol#FORWARD_UNINITIALIZED_TYPE_TAG}). The label entry at index {@code + * i} has its {@link LabelEntry#index} equal to {@code i} (and vice versa). + */ + private LabelEntry[] labelTable; + + /** + * A hash set of all the {@link LabelEntry} elements in the {@link #labelTable}. Each {@link + * LabelEntry} instance is stored at the array index given by its hash code modulo the array size. + * If several entries must be stored at the same array index, they are linked together via their + * {@link LabelEntry#next} field. The {@link #getOrAddLabelEntry(Label)} method ensures that this + * table does not contain duplicated entries. + */ + private LabelEntry[] labelEntries; + /** * Constructs a new, empty SymbolTable for the given ClassWriter. * @@ -1161,6 +1185,18 @@ Symbol getType(final int typeIndex) { return typeTable[typeIndex]; } + /** + * Returns the label corresponding to the "forward uninitialized" type table element whose index + * is given. + * + * @param typeIndex the type table index of a "forward uninitialized" type table element. + * @return the label corresponding of the NEW instruction which created this "forward + * uninitialized" type. + */ + Label getForwardUninitializedLabel(final int typeIndex) { + return labelTable[(int) typeTable[typeIndex].data].label; + } + /** * Adds a type in the type table of this symbol table. Does nothing if the type table already * contains a similar type. @@ -1181,13 +1217,13 @@ int addType(final String value) { } /** - * Adds an {@link Frame#ITEM_UNINITIALIZED} type in the type table of this symbol table. Does - * nothing if the type table already contains a similar type. + * Adds an uninitialized type in the type table of this symbol table. Does nothing if the type + * table already contains a similar type. * * @param value an internal class name. - * @param bytecodeOffset the bytecode offset of the NEW instruction that created this {@link - * Frame#ITEM_UNINITIALIZED} type value. - * @return the index of a new or already existing type Symbol with the given value. + * @param bytecodeOffset the bytecode offset of the NEW instruction that created this + * uninitialized type value. + * @return the index of a new or already existing type #@link Symbol} with the given value. */ int addUninitializedType(final String value, final int bytecodeOffset) { int hashCode = hash(Symbol.UNINITIALIZED_TYPE_TAG, value, bytecodeOffset); @@ -1205,6 +1241,32 @@ int addUninitializedType(final String value, final int bytecodeOffset) { new Entry(typeCount, Symbol.UNINITIALIZED_TYPE_TAG, value, bytecodeOffset, hashCode)); } + /** + * Adds a "forward uninitialized" type in the type table of this symbol table. Does nothing if the + * type table already contains a similar type. + * + * @param value an internal class name. + * @param label the label of the NEW instruction that created this uninitialized type value. If + * the label is resolved, use the {@link #addUninitializedType} method instead. + * @return the index of a new or already existing type {@link Symbol} with the given value. + */ + int addForwardUninitializedType(final String value, final Label label) { + int labelIndex = getOrAddLabelEntry(label).index; + int hashCode = hash(Symbol.FORWARD_UNINITIALIZED_TYPE_TAG, value, labelIndex); + Entry entry = get(hashCode); + while (entry != null) { + if (entry.tag == Symbol.FORWARD_UNINITIALIZED_TYPE_TAG + && entry.hashCode == hashCode + && entry.data == labelIndex + && entry.value.equals(value)) { + return entry.index; + } + entry = entry.next; + } + return addTypeInternal( + new Entry(typeCount, Symbol.FORWARD_UNINITIALIZED_TYPE_TAG, value, labelIndex, hashCode)); + } + /** * Adds a merged type in the type table of this symbol table. Does nothing if the type table * already contains a similar type. @@ -1257,6 +1319,59 @@ private int addTypeInternal(final Entry entry) { return put(entry).index; } + /** + * Returns the {@link LabelEntry} corresponding to the given label. Creates a new one if there is + * no such entry. + * + * @param label the {@link Label} of a NEW instruction which created an uninitialized type, in the + * case where this NEW instruction is after the <init> constructor call (in bytecode + * offset order). See {@link Symbol#FORWARD_UNINITIALIZED_TYPE_TAG}. + * @return the {@link LabelEntry} corresponding to {@code label}. + */ + private LabelEntry getOrAddLabelEntry(final Label label) { + if (labelEntries == null) { + labelEntries = new LabelEntry[16]; + labelTable = new LabelEntry[16]; + } + int hashCode = System.identityHashCode(label); + LabelEntry labelEntry = labelEntries[hashCode % labelEntries.length]; + while (labelEntry != null && labelEntry.label != label) { + labelEntry = labelEntry.next; + } + if (labelEntry != null) { + return labelEntry; + } + + if (labelCount > (labelEntries.length * 3) / 4) { + int currentCapacity = labelEntries.length; + int newCapacity = currentCapacity * 2 + 1; + LabelEntry[] newLabelEntries = new LabelEntry[newCapacity]; + for (int i = currentCapacity - 1; i >= 0; --i) { + LabelEntry currentEntry = labelEntries[i]; + while (currentEntry != null) { + int newCurrentEntryIndex = System.identityHashCode(currentEntry.label) % newCapacity; + LabelEntry nextEntry = currentEntry.next; + currentEntry.next = newLabelEntries[newCurrentEntryIndex]; + newLabelEntries[newCurrentEntryIndex] = currentEntry; + currentEntry = nextEntry; + } + } + labelEntries = newLabelEntries; + } + if (labelCount == labelTable.length) { + LabelEntry[] newLabelTable = new LabelEntry[2 * labelTable.length]; + System.arraycopy(labelTable, 0, newLabelTable, 0, labelTable.length); + labelTable = newLabelTable; + } + + labelEntry = new LabelEntry(labelCount, label); + int index = hashCode % labelEntries.length; + labelEntry.next = labelEntries[index]; + labelEntries[index] = labelEntry; + labelTable[labelCount++] = labelEntry; + return labelEntry; + } + // ----------------------------------------------------------------------------------------------- // Static helper methods to compute hash codes. // ----------------------------------------------------------------------------------------------- @@ -1307,7 +1422,7 @@ private static int hash( * * @author Eric Bruneton */ - private static class Entry extends Symbol { + private static final class Entry extends Symbol { /** The hash code of this entry. */ final int hashCode; @@ -1351,5 +1466,30 @@ private static class Entry extends Symbol { this.hashCode = hashCode; } } -} + /** + * A label corresponding to a "forward uninitialized" type in the ASM specific {@link + * SymbolTable#typeTable} (see {@link Symbol#FORWARD_UNINITIALIZED_TYPE_TAG}). + * + * @author Eric Bruneton + */ + private static final class LabelEntry { + + /** The index of this label entry in the {@link SymbolTable#labelTable} array. */ + final int index; + + /** The value of this label entry. */ + final Label label; + + /** + * Another entry (and so on recursively) having the same hash code (modulo the size of {@link + * SymbolTable#labelEntries}}) as this one. + */ + LabelEntry next; + + LabelEntry(final int index, final Label label) { + this.index = index; + this.label = label; + } + } +} diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Type.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Type.java index 801b8803324..739b9444d2e 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Type.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Type.java @@ -277,7 +277,7 @@ public Type getElementType() { /** * Returns the {@link Type} corresponding to the given internal name. * - * @param internalName an internal name. + * @param internalName an internal name (see {@link Type#getInternalName()}). * @return the {@link Type} corresponding to the given internal name. */ public static Type getObjectType(final String internalName) { @@ -327,26 +327,12 @@ public Type[] getArgumentTypes() { */ public static Type[] getArgumentTypes(final String methodDescriptor) { // First step: compute the number of argument types in methodDescriptor. - int numArgumentTypes = 0; - // Skip the first character, which is always a '('. - int currentOffset = 1; - // Parse the argument types, one at a each loop iteration. - while (methodDescriptor.charAt(currentOffset) != ')') { - while (methodDescriptor.charAt(currentOffset) == '[') { - currentOffset++; - } - if (methodDescriptor.charAt(currentOffset++) == 'L') { - // Skip the argument descriptor content. - int semiColumnOffset = methodDescriptor.indexOf(';', currentOffset); - currentOffset = Math.max(currentOffset, semiColumnOffset + 1); - } - ++numArgumentTypes; - } + int numArgumentTypes = getArgumentCount(methodDescriptor); // Second step: create a Type instance for each argument type. Type[] argumentTypes = new Type[numArgumentTypes]; // Skip the first character, which is always a '('. - currentOffset = 1; + int currentOffset = 1; // Parse and create the argument types, one at each loop iteration. int currentArgumentTypeIndex = 0; while (methodDescriptor.charAt(currentOffset) != ')') { @@ -734,6 +720,43 @@ public int getSize() { } } + /** + * Returns the number of arguments of this method type. This method should only be used for method + * types. + * + * @return the number of arguments of this method type. Each argument counts for 1, even long and + * double ones. The implicit @literal{this} argument is not counted. + */ + public int getArgumentCount() { + return getArgumentCount(getDescriptor()); + } + + /** + * Returns the number of arguments in the given method descriptor. + * + * @param methodDescriptor a method descriptor. + * @return the number of arguments in the given method descriptor. Each argument counts for 1, + * even long and double ones. The implicit @literal{this} argument is not counted. + */ + public static int getArgumentCount(final String methodDescriptor) { + int argumentCount = 0; + // Skip the first character, which is always a '('. + int currentOffset = 1; + // Parse the argument types, one at a each loop iteration. + while (methodDescriptor.charAt(currentOffset) != ')') { + while (methodDescriptor.charAt(currentOffset) == '[') { + currentOffset++; + } + if (methodDescriptor.charAt(currentOffset++) == 'L') { + // Skip the argument descriptor content. + int semiColumnOffset = methodDescriptor.indexOf(';', currentOffset); + currentOffset = Math.max(currentOffset, semiColumnOffset + 1); + } + ++argumentCount; + } + return argumentCount; + } + /** * Returns the size of the arguments and of the return value of methods of this type. This method * should only be used for method types. @@ -741,7 +764,8 @@ public int getSize() { * @return the size of the arguments of the method (plus one for the implicit this argument), * argumentsSize, and the size of its return value, returnSize, packed into a single int i = * {@code (argumentsSize << 2) | returnSize} (argumentsSize is therefore equal to {@code - * i >> 2}, and returnSize to {@code i & 0x03}). + * i >> 2}, and returnSize to {@code i & 0x03}). Long and double values have size 2, + * the others have size 1. */ public int getArgumentsAndReturnSizes() { return getArgumentsAndReturnSizes(getDescriptor()); @@ -754,7 +778,8 @@ public int getArgumentsAndReturnSizes() { * @return the size of the arguments of the method (plus one for the implicit this argument), * argumentsSize, and the size of its return value, returnSize, packed into a single int i = * {@code (argumentsSize << 2) | returnSize} (argumentsSize is therefore equal to {@code - * i >> 2}, and returnSize to {@code i & 0x03}). + * i >> 2}, and returnSize to {@code i & 0x03}). Long and double values have size 2, + * the others have size 1. */ public static int getArgumentsAndReturnSizes(final String methodDescriptor) { int argumentsSize = 1; @@ -925,4 +950,3 @@ public String toString() { return getDescriptor(); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/TypePath.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/TypePath.java index 9725e5b0448..ea1025dd172 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/TypePath.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/TypePath.java @@ -230,4 +230,3 @@ static void put(final TypePath typePath, final ByteVector output) { } } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/TypeReference.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/TypeReference.java index 92a1c94eb0f..512dc8fc8ac 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/TypeReference.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/TypeReference.java @@ -465,4 +465,3 @@ static void putTarget(final int targetTypeAndInfo, final ByteVector output) { } } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/AdviceAdapter.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/AdviceAdapter.java index 8f321f2ec77..0d57c484f05 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/AdviceAdapter.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/AdviceAdapter.java @@ -700,4 +700,3 @@ protected void onMethodEnter() {} */ protected void onMethodExit(final int opcode) {} } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/AnalyzerAdapter.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/AnalyzerAdapter.java index 32d47d1a67c..36a5a06d441 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/AnalyzerAdapter.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/AnalyzerAdapter.java @@ -92,9 +92,10 @@ public class AnalyzerAdapter extends MethodVisitor { * {@link Opcodes#TOP}, {@link Opcodes#INTEGER}, {@link Opcodes#FLOAT}, {@link Opcodes#LONG}, * {@link Opcodes#DOUBLE},{@link Opcodes#NULL} or {@link Opcodes#UNINITIALIZED_THIS} (long and * double are represented by two elements, the second one being TOP). Reference types are - * represented by String objects (representing internal names), and uninitialized types by Label - * objects (this label designates the NEW instruction that created this uninitialized value). This - * field is {@literal null} for unreachable instructions. + * represented by String objects (representing internal names, see {@link + * Type#getInternalName()}), and uninitialized types by Label objects (this label designates the + * NEW instruction that created this uninitialized value). This field is {@literal null} for + * unreachable instructions. */ public List locals; @@ -103,9 +104,10 @@ public class AnalyzerAdapter extends MethodVisitor { * {@link Opcodes#TOP}, {@link Opcodes#INTEGER}, {@link Opcodes#FLOAT}, {@link Opcodes#LONG}, * {@link Opcodes#DOUBLE},{@link Opcodes#NULL} or {@link Opcodes#UNINITIALIZED_THIS} (long and * double are represented by two elements, the second one being TOP). Reference types are - * represented by String objects (representing internal names), and uninitialized types by Label - * objects (this label designates the NEW instruction that created this uninitialized value). This - * field is {@literal null} for unreachable instructions. + * represented by String objects (representing internal names, see {@link + * Type#getInternalName()}), and uninitialized types by Label objects (this label designates the + * NEW instruction that created this uninitialized value). This field is {@literal null} for + * unreachable instructions. */ public List stack; @@ -114,9 +116,9 @@ public class AnalyzerAdapter extends MethodVisitor { /** * The uninitialized types in the current execution frame. This map associates internal names to - * Label objects. Each label designates a NEW instruction that created the currently uninitialized - * types, and the associated internal name represents the NEW operand, i.e. the final, initialized - * type value. + * Label objects (see {@link Type#getInternalName()}). Each label designates a NEW instruction + * that created the currently uninitialized types, and the associated internal name represents the + * NEW operand, i.e. the final, initialized type value. */ public Map uninitializedTypes; @@ -338,7 +340,7 @@ public void visitMethodInsn( if (value == Opcodes.UNINITIALIZED_THIS) { initializedValue = this.owner; } else { - initializedValue = uninitializedTypes.get(value); + initializedValue = owner; } for (int i = 0; i < locals.size(); ++i) { if (locals.get(i) == value) { @@ -938,4 +940,3 @@ private void execute(final int opcode, final int intArg, final String stringArg) labels = null; } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/AnnotationRemapper.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/AnnotationRemapper.java index 68535046acf..4fdfbccc06b 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/AnnotationRemapper.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/AnnotationRemapper.java @@ -227,7 +227,7 @@ final AnnotationVisitor orDeprecatedValue(final AnnotationVisitor deprecatedAnno /** * Maps an annotation attribute name with the remapper. Returns the original name unchanged if the - * internal name of the annotation is {@literal null}. + * descriptor of the annotation is {@literal null}. * * @param name the name of the annotation attribute. * @return the new name of the annotation attribute. @@ -239,4 +239,3 @@ private String mapAnnotationAttributeName(final String name) { return remapper.mapAnnotationAttributeName(descriptor, name); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/ClassRemapper.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/ClassRemapper.java index 519f488b1bf..03a576189d4 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/ClassRemapper.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/ClassRemapper.java @@ -329,4 +329,3 @@ protected RecordComponentVisitor createRecordComponentRemapper( return new RecordComponentRemapper(api, recordComponentVisitor, remapper); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/CodeSizeEvaluator.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/CodeSizeEvaluator.java index 5d7bb2cc912..2392cdcd0be 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/CodeSizeEvaluator.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/CodeSizeEvaluator.java @@ -237,4 +237,3 @@ public void visitMultiANewArrayInsn(final String descriptor, final int numDimens super.visitMultiANewArrayInsn(descriptor, numDimensions); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/FieldRemapper.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/FieldRemapper.java index 2e8a1ad4deb..205f985d87e 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/FieldRemapper.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/FieldRemapper.java @@ -144,4 +144,3 @@ protected AnnotationVisitor createAnnotationRemapper( .orDeprecatedValue(createAnnotationRemapper(annotationVisitor)); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/GeneratorAdapter.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/GeneratorAdapter.java index 6dd35ba2a2c..ecf4ac10dfb 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/GeneratorAdapter.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/GeneratorAdapter.java @@ -308,7 +308,7 @@ public GeneratorAdapter( * Returns the internal names of the given types. * * @param types a set of types. - * @return the internal names of the given types. + * @return the internal names of the given types (see {@link Type#getInternalName()}). */ private static String[] getInternalNames(final Type[] types) { String[] names = new String[types.length]; @@ -1386,7 +1386,8 @@ public void endMethod() { * * @param start beginning of the exception handler's scope (inclusive). * @param end end of the exception handler's scope (exclusive). - * @param exception internal name of the type of exceptions handled by the handler. + * @param exception internal name of the type of exceptions handled by the handler (see {@link + * Type#getInternalName()}). */ public void catchException(final Label start, final Label end, final Type exception) { Label catchLabel = new Label(); @@ -1398,4 +1399,3 @@ public void catchException(final Label start, final Label end, final Type except mark(catchLabel); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/InstructionAdapter.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/InstructionAdapter.java index 033956f1c7e..e449c310b3b 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/InstructionAdapter.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/InstructionAdapter.java @@ -1094,7 +1094,8 @@ public void putfield(final String owner, final String name, final String descrip /** * Deprecated. * - * @param owner the internal name of the method's owner class. + * @param owner the internal name of the method's owner class (see {@link + * Type#getInternalName()}). * @param name the method's name. * @param descriptor the method's descriptor (see {@link Type}). * @deprecated use {@link #invokevirtual(String, String, String, boolean)} instead. @@ -1132,7 +1133,8 @@ public void invokevirtual( /** * Deprecated. * - * @param owner the internal name of the method's owner class. + * @param owner the internal name of the method's owner class (see {@link + * Type#getInternalName()}). * @param name the method's name. * @param descriptor the method's descriptor (see {@link Type}). * @deprecated use {@link #invokespecial(String, String, String, boolean)} instead. @@ -1170,7 +1172,8 @@ public void invokespecial( /** * Deprecated. * - * @param owner the internal name of the method's owner class. + * @param owner the internal name of the method's owner class (see {@link + * Type#getInternalName()}). * @param name the method's name. * @param descriptor the method's descriptor (see {@link Type}). * @deprecated use {@link #invokestatic(String, String, String, boolean)} instead. @@ -1329,4 +1332,3 @@ public void mark(final Label label) { mv.visitLabel(label); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/JSRInlinerAdapter.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/JSRInlinerAdapter.java index 2e2a42c3d7c..2f1565222ec 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/JSRInlinerAdapter.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/JSRInlinerAdapter.java @@ -120,7 +120,8 @@ public class JSRInlinerAdapter extends MethodNode implements Opcodes { * @param name the method's name. * @param descriptor the method's descriptor. * @param signature the method's signature. May be {@literal null}. - * @param exceptions the internal names of the method's exception classes. May be {@literal null}. + * @param exceptions the internal names of the method's exception classes (see {@link + * jdk.internal.org.objectweb.asm.Type#getInternalName()}). May be {@literal null}. * @throws IllegalStateException if a subclass calls this constructor. */ public JSRInlinerAdapter( @@ -155,7 +156,8 @@ public JSRInlinerAdapter( * @param name the method's name. * @param descriptor the method's descriptor. * @param signature the method's signature. May be {@literal null}. - * @param exceptions the internal names of the method's exception classes. May be {@literal null}. + * @param exceptions the internal names of the method's exception classes (see {@link + * jdk.internal.org.objectweb.asm.Type#getInternalName()}). May be {@literal null}. */ protected JSRInlinerAdapter( final int api, @@ -455,7 +457,7 @@ private void emitInstantiation( } /** An instantiation of a subroutine. */ - private class Instantiation extends AbstractMap { + private final class Instantiation extends AbstractMap { /** * The instantiation from which this one was created (or {@literal null} for the instantiation @@ -600,4 +602,3 @@ public int hashCode() { } } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/LocalVariablesSorter.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/LocalVariablesSorter.java index aadef755778..c4063340943 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/LocalVariablesSorter.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/LocalVariablesSorter.java @@ -381,4 +381,3 @@ protected int newLocalMapping(final Type type) { return local; } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/Method.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/Method.java index 1fcab96f181..96b1885308c 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/Method.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/Method.java @@ -292,4 +292,3 @@ public int hashCode() { return name.hashCode() ^ descriptor.hashCode(); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/MethodRemapper.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/MethodRemapper.java index 7b27a52e075..c2335077e8b 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/MethodRemapper.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/MethodRemapper.java @@ -319,4 +319,3 @@ protected AnnotationVisitor createAnnotationRemapper( .orDeprecatedValue(createAnnotationRemapper(annotationVisitor)); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/ModuleHashesAttribute.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/ModuleHashesAttribute.java index 5b4cc253c39..7bf0934ab2e 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/ModuleHashesAttribute.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/ModuleHashesAttribute.java @@ -168,4 +168,3 @@ protected ByteVector write( return byteVector; } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/ModuleRemapper.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/ModuleRemapper.java index 135ae6d31d6..d843a715451 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/ModuleRemapper.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/ModuleRemapper.java @@ -150,4 +150,3 @@ public void visitProvide(final String service, final String... providers) { super.visitProvide(remapper.mapType(service), remappedProviders); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/ModuleResolutionAttribute.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/ModuleResolutionAttribute.java index 8187ad30e0c..5ccee829a90 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/ModuleResolutionAttribute.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/ModuleResolutionAttribute.java @@ -142,4 +142,3 @@ protected ByteVector write( return byteVector; } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/ModuleTargetAttribute.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/ModuleTargetAttribute.java index 4d92734a972..8d61baadd2e 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/ModuleTargetAttribute.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/ModuleTargetAttribute.java @@ -116,4 +116,3 @@ protected ByteVector write( return byteVector; } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/RecordComponentRemapper.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/RecordComponentRemapper.java index 6974b05d71e..017f24a7440 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/RecordComponentRemapper.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/RecordComponentRemapper.java @@ -147,4 +147,3 @@ protected AnnotationVisitor createAnnotationRemapper( .orDeprecatedValue(createAnnotationRemapper(annotationVisitor)); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/Remapper.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/Remapper.java index 41fe75e4143..aba7f0f21ff 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/Remapper.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/Remapper.java @@ -80,7 +80,7 @@ public abstract class Remapper { * @param descriptor a type descriptor. * @return the given descriptor, with its [array element type] internal name remapped with {@link * #map(String)} (if the descriptor corresponds to an array or object type, otherwise the - * descriptor is returned as is). + * descriptor is returned as is). See {@link Type#getInternalName()}. */ public String mapDesc(final String descriptor) { return mapType(Type.getType(descriptor)).getDescriptor(); @@ -94,7 +94,7 @@ public String mapDesc(final String descriptor) { * @return the given type, with its [array element type] internal name remapped with {@link * #map(String)} (if the type is an array or object type, otherwise the type is returned as * is) or, of the type is a method type, with its descriptor remapped with {@link - * #mapMethodDesc(String)}. + * #mapMethodDesc(String)}. See {@link Type#getInternalName()}. */ private Type mapType(final Type type) { switch (type.getSort()) { @@ -118,8 +118,10 @@ private Type mapType(final Type type) { /** * Returns the given internal name, remapped with {@link #map(String)}. * - * @param internalName the internal name (or array type descriptor) of some (array) class. - * @return the given internal name, remapped with {@link #map(String)}. + * @param internalName the internal name (or array type descriptor) of some (array) class (see + * {@link Type#getInternalName()}). + * @return the given internal name, remapped with {@link #map(String)} (see {@link + * Type#getInternalName()}). */ public String mapType(final String internalName) { if (internalName == null) { @@ -131,8 +133,10 @@ public String mapType(final String internalName) { /** * Returns the given internal names, remapped with {@link #map(String)}. * - * @param internalNames the internal names (or array type descriptors) of some (array) classes. - * @return the given internal name, remapped with {@link #map(String)}. + * @param internalNames the internal names (or array type descriptors) of some (array) classes + * (see {@link Type#getInternalName()}). + * @return the given internal name, remapped with {@link #map(String)} (see {@link + * Type#getInternalName()}). */ public String[] mapTypes(final String[] internalNames) { String[] remappedInternalNames = null; @@ -286,14 +290,30 @@ public String mapAnnotationAttributeName(final String descriptor, final String n * strategy that will work for inner classes produced by Java, but not necessarily other * languages. Subclasses can override. * - * @param name the fully-qualified internal name of the inner class. - * @param ownerName the internal name of the owner class of the inner class. - * @param innerName the internal name of the inner class. + * @param name the fully-qualified internal name of the inner class (see {@link + * Type#getInternalName()}). + * @param ownerName the internal name of the owner class of the inner class (see {@link + * Type#getInternalName()}). + * @param innerName the internal name of the inner class (see {@link Type#getInternalName()}). * @return the new inner name of the inner class. */ public String mapInnerClassName( final String name, final String ownerName, final String innerName) { final String remappedInnerName = this.mapType(name); + + if (remappedInnerName.equals(name)) { + return innerName; + } else { + int originSplit = name.lastIndexOf('/'); + int remappedSplit = remappedInnerName.lastIndexOf('/'); + if (originSplit != -1 && remappedSplit != -1) { + if (name.substring(originSplit).equals(remappedInnerName.substring(remappedSplit))) { + // class name not changed + return innerName; + } + } + } + if (remappedInnerName.contains("$")) { int index = remappedInnerName.lastIndexOf('$') + 1; while (index < remappedInnerName.length() @@ -310,7 +330,8 @@ public String mapInnerClassName( * Maps a method name to its new name. The default implementation of this method returns the given * name, unchanged. Subclasses can override. * - * @param owner the internal name of the owner class of the method. + * @param owner the internal name of the owner class of the method (see {@link + * Type#getInternalName()}). * @param name the name of the method. * @param descriptor the descriptor of the method. * @return the new name of the method. @@ -335,7 +356,8 @@ public String mapInvokeDynamicMethodName(final String name, final String descrip * Maps a record component name to its new name. The default implementation of this method returns * the given name, unchanged. Subclasses can override. * - * @param owner the internal name of the owner class of the field. + * @param owner the internal name of the owner class of the field (see {@link + * Type#getInternalName()}). * @param name the name of the field. * @param descriptor the descriptor of the field. * @return the new name of the field. @@ -349,7 +371,8 @@ public String mapRecordComponentName( * Maps a field name to its new name. The default implementation of this method returns the given * name, unchanged. Subclasses can override. * - * @param owner the internal name of the owner class of the field. + * @param owner the internal name of the owner class of the field (see {@link + * Type#getInternalName()}). * @param name the name of the field. * @param descriptor the descriptor of the field. * @return the new name of the field. @@ -384,11 +407,10 @@ public String mapModuleName(final String name) { * Maps the internal name of a class to its new name. The default implementation of this method * returns the given name, unchanged. Subclasses can override. * - * @param internalName the internal name of a class. - * @return the new internal name. + * @param internalName the internal name of a class (see {@link Type#getInternalName()}). + * @return the new internal name (see {@link Type#getInternalName()}). */ public String map(final String internalName) { return internalName; } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/SerialVersionUIDAdder.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/SerialVersionUIDAdder.java index a453500143b..58173483b19 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/SerialVersionUIDAdder.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/SerialVersionUIDAdder.java @@ -522,4 +522,3 @@ public int hashCode() { } } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/SignatureRemapper.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/SignatureRemapper.java index 1d9d4d87f82..5fb41c84cca 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/SignatureRemapper.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/SignatureRemapper.java @@ -202,4 +202,3 @@ public void visitEnd() { classNames.remove(classNames.size() - 1); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/SimpleRemapper.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/SimpleRemapper.java index 314738e3b2e..9b298b15e39 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/SimpleRemapper.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/SimpleRemapper.java @@ -85,7 +85,7 @@ public class SimpleRemapper extends Remapper { * attribute (in the form <owner>.<name>), and the value is the new field * name. *
  • for internal names, the key is the old internal name, and the value is the new - * internal name. + * internal name (see {@link jdk.internal.org.objectweb.asm.Type#getInternalName()}). * */ public SimpleRemapper(final Map mapping) { @@ -97,7 +97,8 @@ public SimpleRemapper(final Map mapping) { * * @param oldName the key corresponding to a method, field or internal name (see {@link * #SimpleRemapper(Map)} for the format of these keys). - * @param newName the new method, field or internal name. + * @param newName the new method, field or internal name (see {@link + * jdk.internal.org.objectweb.asm.Type#getInternalName()}). */ public SimpleRemapper(final String oldName, final String newName) { this.mapping = Collections.singletonMap(oldName, newName); @@ -132,4 +133,3 @@ public String map(final String key) { return mapping.get(key); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/StaticInitMerger.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/StaticInitMerger.java index 25d4fbcb5d9..1a03a9e0923 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/StaticInitMerger.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/StaticInitMerger.java @@ -154,4 +154,3 @@ public void visitEnd() { super.visitEnd(); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/TableSwitchGenerator.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/TableSwitchGenerator.java index 69db3287c40..0f8ada93b39 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/TableSwitchGenerator.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/TableSwitchGenerator.java @@ -81,4 +81,3 @@ public interface TableSwitchGenerator { /** Generates the code for the default switch case. */ void generateDefault(); } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/TryCatchBlockSorter.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/TryCatchBlockSorter.java index f64766572d2..6cd6b1ec08b 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/TryCatchBlockSorter.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/TryCatchBlockSorter.java @@ -155,4 +155,3 @@ private int blockLength(final TryCatchBlockNode tryCatchBlockNode) { } } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/signature/SignatureReader.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/signature/SignatureReader.java index 9870ea5f72b..76901452a4c 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/signature/SignatureReader.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/signature/SignatureReader.java @@ -282,4 +282,3 @@ private static int parseType( } } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/signature/SignatureVisitor.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/signature/SignatureVisitor.java index 09b11f5f912..5be537ba307 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/signature/SignatureVisitor.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/signature/SignatureVisitor.java @@ -211,7 +211,8 @@ public SignatureVisitor visitArrayType() { /** * Starts the visit of a signature corresponding to a class or interface type. * - * @param name the internal name of the class or interface. + * @param name the internal name of the class or interface (see {@link + * jdk.internal.org.objectweb.asm.Type#getInternalName()}). */ public void visitClassType(final String name) {} @@ -238,4 +239,3 @@ public SignatureVisitor visitTypeArgument(final char wildcard) { /** Ends the visit of a signature corresponding to a class or interface type. */ public void visitEnd() {} } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/signature/SignatureWriter.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/signature/SignatureWriter.java index eceaaee424c..077a9292955 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/signature/SignatureWriter.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/signature/SignatureWriter.java @@ -73,7 +73,7 @@ public class SignatureWriter extends SignatureVisitor { /** The builder used to construct the visited signature. */ - private final StringBuilder stringBuilder = new StringBuilder(); + private final StringBuilder stringBuilder; /** Whether the visited signature contains formal type parameters. */ private boolean hasFormals; @@ -83,8 +83,9 @@ public class SignatureWriter extends SignatureVisitor { /** * The stack used to keep track of class types that have arguments. Each element of this stack is - * a boolean encoded in one bit. The top of the stack is the least significant bit. Pushing false - * = *2, pushing true = *2+1, popping = /2. + * a boolean encoded in one bit. The top of the stack is the least significant bit. The bottom of + * the stack is a sentinel element always equal to 1 (used to detect when the stack is full). + * Pushing false = {@code <<= 1}, pushing true = {@code ( <<= 1) | 1}, popping = {@code >>>= 1}. * *

    Class type arguments must be surrounded with '<' and '>' and, because * @@ -94,15 +95,20 @@ public class SignatureWriter extends SignatureVisitor { * SignatureWriter instances), * * - *

    we need a stack to properly balance these 'parentheses'. A new element is pushed on this - * stack for each new visited type, and popped when the visit of this type ends (either is + *

    we need a stack to properly balance these angle brackets. A new element is pushed on this + * stack for each new visited type, and popped when the visit of this type ends (either in * visitEnd, or because visitInnerClassType is called). */ - private int argumentStack; + private int argumentStack = 1; /** Constructs a new {@link SignatureWriter}. */ public SignatureWriter() { + this(new StringBuilder()); + } + + private SignatureWriter(final StringBuilder stringBuilder) { super(/* latest api =*/ Opcodes.ASM9); + this.stringBuilder = stringBuilder; } // ----------------------------------------------------------------------------------------------- @@ -191,7 +197,7 @@ public void visitClassType(final String name) { stringBuilder.append(name); // Pushes 'false' on the stack, meaning that this type does not have type arguments (as far as // we can tell at this point). - argumentStack *= 2; + argumentStack <<= 1; } @Override @@ -201,7 +207,7 @@ public void visitInnerClassType(final String name) { stringBuilder.append(name); // Pushes 'false' on the stack, meaning that this type does not have type arguments (as far as // we can tell at this point). - argumentStack *= 2; + argumentStack <<= 1; } @Override @@ -209,7 +215,7 @@ public void visitTypeArgument() { // If the top of the stack is 'false', this means we are visiting the first type argument of the // currently visited type. We therefore need to append a '<', and to replace the top stack // element with 'true' (meaning that the current type does have type arguments). - if (argumentStack % 2 == 0) { + if ((argumentStack & 1) == 0) { argumentStack |= 1; stringBuilder.append('<'); } @@ -221,14 +227,15 @@ public SignatureVisitor visitTypeArgument(final char wildcard) { // If the top of the stack is 'false', this means we are visiting the first type argument of the // currently visited type. We therefore need to append a '<', and to replace the top stack // element with 'true' (meaning that the current type does have type arguments). - if (argumentStack % 2 == 0) { + if ((argumentStack & 1) == 0) { argumentStack |= 1; stringBuilder.append('<'); } if (wildcard != '=') { stringBuilder.append(wildcard); } - return this; + // If the stack is full, start a nested one by returning a new SignatureWriter. + return (argumentStack & (1 << 31)) == 0 ? this : new SignatureWriter(stringBuilder); } @Override @@ -264,10 +271,9 @@ private void endArguments() { // If the top of the stack is 'true', this means that some type arguments have been visited for // the type whose visit is now ending. We therefore need to append a '>', and to pop one element // from the stack. - if (argumentStack % 2 == 1) { + if ((argumentStack & 1) == 1) { stringBuilder.append('>'); } - argumentStack /= 2; + argumentStack >>>= 1; } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/AbstractInsnNode.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/AbstractInsnNode.java index 28b17cecc2b..1b22e023abc 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/AbstractInsnNode.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/AbstractInsnNode.java @@ -120,7 +120,10 @@ public abstract class AbstractInsnNode { /** The type of {@link LineNumberNode} "instructions". */ public static final int LINE = 15; - /** The opcode of this instruction. */ + /** + * The opcode of this instruction, or -1 if this is not a JVM instruction (e.g. a label or a line + * number). + */ protected int opcode; /** @@ -163,7 +166,8 @@ protected AbstractInsnNode(final int opcode) { /** * Returns the opcode of this instruction. * - * @return the opcode of this instruction. + * @return the opcode of this instruction, or -1 if this is not a JVM instruction (e.g. a label or + * a line number). */ public int getOpcode() { return opcode; @@ -295,4 +299,3 @@ protected final AbstractInsnNode cloneAnnotations(final AbstractInsnNode insnNod return this; } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/AnnotationNode.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/AnnotationNode.java index e9c1e184c90..2ef0bcfb624 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/AnnotationNode.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/AnnotationNode.java @@ -260,4 +260,3 @@ static void accept( } } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/ClassNode.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/ClassNode.java index dd8d1070fc7..0e271d6a159 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/ClassNode.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/ClassNode.java @@ -90,14 +90,14 @@ public class ClassNode extends ClassVisitor { */ public int access; - /** The internal name of this class (see {@link jdk.internal.org.objectweb.asm.Type#getInternalName}). */ + /** The internal name of this class (see {@link jdk.internal.org.objectweb.asm.Type#getInternalName()}). */ public String name; /** The signature of this class. May be {@literal null}. */ public String signature; /** - * The internal of name of the super class (see {@link jdk.internal.org.objectweb.asm.Type#getInternalName}). + * The internal of name of the super class (see {@link jdk.internal.org.objectweb.asm.Type#getInternalName()}). * For interfaces, the super class is {@link Object}. May be {@literal null}, but only for the * {@link Object} class. */ @@ -105,7 +105,7 @@ public class ClassNode extends ClassVisitor { /** * The internal names of the interfaces directly implemented by this class (see {@link - * jdk.internal.org.objectweb.asm.Type#getInternalName}). + * jdk.internal.org.objectweb.asm.Type#getInternalName()}). */ public List interfaces; @@ -120,18 +120,26 @@ public class ClassNode extends ClassVisitor { /** The module stored in this class. May be {@literal null}. */ public ModuleNode module; - /** The internal name of the enclosing class of this class. May be {@literal null}. */ + /** + * The internal name of the enclosing class of this class (see {@link + * jdk.internal.org.objectweb.asm.Type#getInternalName()}). Must be {@literal null} if this class has no + * enclosing class, or if it is a local or anonymous class. + */ public String outerClass; /** - * The name of the method that contains this class, or {@literal null} if this class is not - * enclosed in a method. + * The name of the method that contains the class, or {@literal null} if the class has no + * enclosing class, or is not enclosed in a method or constructor of its enclosing class (e.g. if + * it is enclosed in an instance initializer, static initializer, instance variable initializer, + * or class variable initializer). */ public String outerMethod; /** - * The descriptor of the method that contains this class, or {@literal null} if this class is not - * enclosed in a method. + * The descriptor of the method that contains the class, or {@literal null} if the class has no + * enclosing class, or is not enclosed in a method or constructor of its enclosing class (e.g. if + * it is enclosed in an instance initializer, static initializer, instance variable initializer, + * or class variable initializer). */ public String outerMethodDesc; @@ -153,13 +161,22 @@ public class ClassNode extends ClassVisitor { /** The inner classes of this class. */ public List innerClasses; - /** The internal name of the nest host class of this class. May be {@literal null}. */ + /** + * The internal name of the nest host class of this class (see {@link + * jdk.internal.org.objectweb.asm.Type#getInternalName()}). May be {@literal null}. + */ public String nestHostClass; - /** The internal names of the nest members of this class. May be {@literal null}. */ + /** + * The internal names of the nest members of this class (see {@link + * jdk.internal.org.objectweb.asm.Type#getInternalName()}). May be {@literal null}. + */ public List nestMembers; - /** The internal names of the permitted subclasses of this class. May be {@literal null}. */ + /** + * The internal names of the permitted subclasses of this class (see {@link + * jdk.internal.org.objectweb.asm.Type#getInternalName()}). May be {@literal null}. + */ public List permittedSubclasses; /** The record components of this class. May be {@literal null}. */ @@ -485,4 +502,3 @@ public void accept(final ClassVisitor classVisitor) { classVisitor.visitEnd(); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/FieldInsnNode.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/FieldInsnNode.java index 8dd491246e8..ce450f9107b 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/FieldInsnNode.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/FieldInsnNode.java @@ -72,7 +72,7 @@ public class FieldInsnNode extends AbstractInsnNode { /** * The internal name of the field's owner class (see {@link - * jdk.internal.org.objectweb.asm.Type#getInternalName}). + * jdk.internal.org.objectweb.asm.Type#getInternalName()}). */ public String owner; @@ -88,7 +88,7 @@ public class FieldInsnNode extends AbstractInsnNode { * @param opcode the opcode of the type instruction to be constructed. This opcode must be * GETSTATIC, PUTSTATIC, GETFIELD or PUTFIELD. * @param owner the internal name of the field's owner class (see {@link - * jdk.internal.org.objectweb.asm.Type#getInternalName}). + * jdk.internal.org.objectweb.asm.Type#getInternalName()}). * @param name the field's name. * @param descriptor the field's descriptor (see {@link jdk.internal.org.objectweb.asm.Type}). */ @@ -126,4 +126,3 @@ public AbstractInsnNode clone(final Map clonedLabels) { return new FieldInsnNode(opcode, owner, name, desc).cloneAnnotations(this); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/FieldNode.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/FieldNode.java index b5bec8d5cc8..2bf3682b669 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/FieldNode.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/FieldNode.java @@ -274,4 +274,3 @@ public void accept(final ClassVisitor classVisitor) { fieldVisitor.visitEnd(); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/FrameNode.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/FrameNode.java index cd4cc5c57ad..cb8c8fb05ab 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/FrameNode.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/FrameNode.java @@ -111,14 +111,18 @@ private FrameNode() { * @param type the type of this frame. Must be {@link Opcodes#F_NEW} for expanded frames, or * {@link Opcodes#F_FULL}, {@link Opcodes#F_APPEND}, {@link Opcodes#F_CHOP}, {@link * Opcodes#F_SAME} or {@link Opcodes#F_APPEND}, {@link Opcodes#F_SAME1} for compressed frames. - * @param numLocal number of local variables of this stack map frame. + * @param numLocal number of local variables of this stack map frame. Long and double values count + * for one variable. * @param local the types of the local variables of this stack map frame. Elements of this list * can be Integer, String or LabelNode objects (for primitive, reference and uninitialized - * types respectively - see {@link MethodVisitor}). - * @param numStack number of operand stack elements of this stack map frame. + * types respectively - see {@link MethodVisitor}). Long and double values are represented by + * a single element. + * @param numStack number of operand stack elements of this stack map frame. Long and double + * values count for one stack element. * @param stack the types of the operand stack elements of this stack map frame. Elements of this * list can be Integer, String or LabelNode objects (for primitive, reference and - * uninitialized types respectively - see {@link MethodVisitor}). + * uninitialized types respectively - see {@link MethodVisitor}). Long and double values are + * represented by a single element. */ public FrameNode( final int type, @@ -218,4 +222,3 @@ private static Object[] asArray(final List list) { return array; } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/IincInsnNode.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/IincInsnNode.java index 71fe001c705..864d540cd8c 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/IincInsnNode.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/IincInsnNode.java @@ -104,4 +104,3 @@ public AbstractInsnNode clone(final Map clonedLabels) { return new IincInsnNode(var, incr).cloneAnnotations(this); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/InnerClassNode.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/InnerClassNode.java index 7ab29379ca8..a2e103ae6d2 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/InnerClassNode.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/InnerClassNode.java @@ -62,7 +62,11 @@ import jdk.internal.org.objectweb.asm.ClassVisitor; /** - * A node that represents an inner class. + * A node that represents an inner class. This inner class is not necessarily a member of the {@link + * ClassNode} containing this object. More precisely, every class or interface C which is referenced + * by a {@link ClassNode} and which is not a package member must be represented with an {@link + * InnerClassNode}. The {@link ClassNode} must reference its nested class or interface members, and + * its enclosing class, if any. See the JVMS 4.7.6 section for more details. * * @author Eric Bruneton */ @@ -78,25 +82,27 @@ public class InnerClassNode { public String outerName; /** - * The (simple) name of the inner class inside its enclosing class. May be {@literal null} for - * anonymous inner classes. + * The (simple) name of the inner class inside its enclosing class. Must be {@literal null} if the + * inner class is not the member of a class or interface (e.g. for local or anonymous classes). */ public String innerName; - /** The access flags of the inner class as originally declared in the enclosing class. */ + /** + * The access flags of the inner class as originally declared in the source code from which the + * class was compiled. + */ public int access; /** - * Constructs a new {@link InnerClassNode}. + * Constructs a new {@link InnerClassNode} for an inner class C. * - * @param name the internal name of an inner class (see {@link - * jdk.internal.org.objectweb.asm.Type#getInternalName()}). - * @param outerName the internal name of the class to which the inner class belongs (see {@link - * jdk.internal.org.objectweb.asm.Type#getInternalName()}). May be {@literal null}. - * @param innerName the (simple) name of the inner class inside its enclosing class. May be - * {@literal null} for anonymous inner classes. - * @param access the access flags of the inner class as originally declared in the enclosing - * class. + * @param name the internal name of C (see {@link jdk.internal.org.objectweb.asm.Type#getInternalName()}). + * @param outerName the internal name of the class or interface C is a member of (see {@link + * jdk.internal.org.objectweb.asm.Type#getInternalName()}). Must be {@literal null} if C is not the member + * of a class or interface (e.g. for local or anonymous classes). + * @param innerName the (simple) name of C. Must be {@literal null} for anonymous inner classes. + * @param access the access flags of C originally declared in the source code from which this + * class was compiled. */ public InnerClassNode( final String name, final String outerName, final String innerName, final int access) { @@ -115,4 +121,3 @@ public void accept(final ClassVisitor classVisitor) { classVisitor.visitInnerClass(name, outerName, innerName, access); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/InsnList.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/InsnList.java index a375eb0ce88..a63c80d7603 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/InsnList.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/InsnList.java @@ -634,4 +634,3 @@ public void set(final Object o) { } } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/InsnNode.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/InsnNode.java index 8fed9db1949..94e043ca9c4 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/InsnNode.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/InsnNode.java @@ -103,4 +103,3 @@ public AbstractInsnNode clone(final Map clonedLabels) { return new InsnNode(opcode).cloneAnnotations(this); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/IntInsnNode.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/IntInsnNode.java index 5da8824ea99..0c044886f90 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/IntInsnNode.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/IntInsnNode.java @@ -109,4 +109,3 @@ public AbstractInsnNode clone(final Map clonedLabels) { return new IntInsnNode(opcode, operand).cloneAnnotations(this); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/InvokeDynamicInsnNode.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/InvokeDynamicInsnNode.java index 0d934f2ab73..087d3f5acd4 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/InvokeDynamicInsnNode.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/InvokeDynamicInsnNode.java @@ -98,12 +98,12 @@ public InvokeDynamicInsnNode( final String name, final String descriptor, final Handle bootstrapMethodHandle, - final Object... bootstrapMethodArguments) { // NOPMD(ArrayIsStoredDirectly): public field. + final Object... bootstrapMethodArguments) { super(Opcodes.INVOKEDYNAMIC); this.name = name; this.desc = descriptor; this.bsm = bootstrapMethodHandle; - this.bsmArgs = bootstrapMethodArguments; + this.bsmArgs = bootstrapMethodArguments; // NOPMD(ArrayIsStoredDirectly): public field. } @Override @@ -122,4 +122,3 @@ public AbstractInsnNode clone(final Map clonedLabels) { return new InvokeDynamicInsnNode(name, desc, bsm, bsmArgs).cloneAnnotations(this); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/JumpInsnNode.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/JumpInsnNode.java index 8790ff32246..23891297e45 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/JumpInsnNode.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/JumpInsnNode.java @@ -117,4 +117,3 @@ public AbstractInsnNode clone(final Map clonedLabels) { return new JumpInsnNode(opcode, clone(label, clonedLabels)).cloneAnnotations(this); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/LabelNode.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/LabelNode.java index 6edcc0d99d1..935382ad543 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/LabelNode.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/LabelNode.java @@ -109,4 +109,3 @@ public void resetLabel() { value = null; } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/LdcInsnNode.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/LdcInsnNode.java index 20eafcaa656..1dac0b7aa85 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/LdcInsnNode.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/LdcInsnNode.java @@ -113,4 +113,3 @@ public AbstractInsnNode clone(final Map clonedLabels) { return new LdcInsnNode(cst).cloneAnnotations(this); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/LineNumberNode.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/LineNumberNode.java index ac882ed7783..4feb13072b5 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/LineNumberNode.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/LineNumberNode.java @@ -104,4 +104,3 @@ public AbstractInsnNode clone(final Map clonedLabels) { return new LineNumberNode(line, clone(start, clonedLabels)); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/LocalVariableAnnotationNode.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/LocalVariableAnnotationNode.java index 2753e06b06e..2a593ca1699 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/LocalVariableAnnotationNode.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/LocalVariableAnnotationNode.java @@ -169,4 +169,3 @@ public void accept(final MethodVisitor methodVisitor, final boolean visible) { typeRef, typePath, startLabels, endLabels, indices, desc, visible)); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/LocalVariableNode.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/LocalVariableNode.java index 142c5915a06..7bfb121b88a 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/LocalVariableNode.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/LocalVariableNode.java @@ -122,4 +122,3 @@ public void accept(final MethodVisitor methodVisitor) { name, desc, signature, start.getLabel(), end.getLabel(), index); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/LookupSwitchInsnNode.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/LookupSwitchInsnNode.java index 513f2c06cfa..31d3c79b162 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/LookupSwitchInsnNode.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/LookupSwitchInsnNode.java @@ -123,4 +123,3 @@ public AbstractInsnNode clone(final Map clonedLabels) { return clone.cloneAnnotations(this); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/MethodInsnNode.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/MethodInsnNode.java index 9c5f40d6517..77e720b69b9 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/MethodInsnNode.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/MethodInsnNode.java @@ -153,4 +153,3 @@ public AbstractInsnNode clone(final Map clonedLabels) { return new MethodInsnNode(opcode, owner, name, desc, itf).cloneAnnotations(this); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/MethodNode.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/MethodNode.java index 365ffa005c1..3ec2ac6d1fc 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/MethodNode.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/MethodNode.java @@ -326,14 +326,14 @@ public AnnotationVisitor visitParameterAnnotation( AnnotationNode annotation = new AnnotationNode(descriptor); if (visible) { if (visibleParameterAnnotations == null) { - int params = Type.getArgumentTypes(desc).length; + int params = Type.getArgumentCount(desc); visibleParameterAnnotations = (List[]) new List[params]; } visibleParameterAnnotations[parameter] = Util.add(visibleParameterAnnotations[parameter], annotation); } else { if (invisibleParameterAnnotations == null) { - int params = Type.getArgumentTypes(desc).length; + int params = Type.getArgumentCount(desc); invisibleParameterAnnotations = (List[]) new List[params]; } invisibleParameterAnnotations[parameter] = @@ -802,4 +802,3 @@ public void accept(final MethodVisitor methodVisitor) { methodVisitor.visitEnd(); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/ModuleExportNode.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/ModuleExportNode.java index 094c2e19300..b845ebe662e 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/ModuleExportNode.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/ModuleExportNode.java @@ -69,7 +69,10 @@ */ public class ModuleExportNode { - /** The internal name of the exported package. */ + /** + * The internal name of the exported package (see {@link + * jdk.internal.org.objectweb.asm.Type#getInternalName()}). + */ public String packaze; /** @@ -87,7 +90,8 @@ public class ModuleExportNode { /** * Constructs a new {@link ModuleExportNode}. * - * @param packaze the internal name of the exported package. + * @param packaze the internal name of the exported package (see {@link + * jdk.internal.org.objectweb.asm.Type#getInternalName()}). * @param access the package access flags, one or more of {@code ACC_SYNTHETIC} and {@code * ACC_MANDATED}. * @param modules a list of modules that can access this exported package, specified with fully @@ -109,4 +113,3 @@ public void accept(final ModuleVisitor moduleVisitor) { packaze, access, modules == null ? null : modules.toArray(new String[0])); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/ModuleNode.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/ModuleNode.java index fcb9db550f0..66baee92e1b 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/ModuleNode.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/ModuleNode.java @@ -84,10 +84,16 @@ public class ModuleNode extends ModuleVisitor { /** The version of this module. May be {@literal null}. */ public String version; - /** The internal name of the main class of this module. May be {@literal null}. */ + /** + * The internal name of the main class of this module (see {@link + * jdk.internal.org.objectweb.asm.Type#getInternalName()}). May be {@literal null}. + */ public String mainClass; - /** The internal name of the packages declared by this module. May be {@literal null}. */ + /** + * The internal name of the packages declared by this module (see {@link + * jdk.internal.org.objectweb.asm.Type#getInternalName()}). May be {@literal null}. + */ public List packages; /** The dependencies of this module. May be {@literal null}. */ @@ -99,7 +105,10 @@ public class ModuleNode extends ModuleVisitor { /** The packages opened by this module. May be {@literal null}. */ public List opens; - /** The internal names of the services used by this module. May be {@literal null}. */ + /** + * The internal names of the services used by this module (see {@link + * jdk.internal.org.objectweb.asm.Type#getInternalName()}). May be {@literal null}. + */ public List uses; /** The services provided by this module. May be {@literal null}. */ @@ -138,7 +147,8 @@ public ModuleNode(final String name, final int access, final String version) { * @param requires The dependencies of this module. May be {@literal null}. * @param exports The packages exported by this module. May be {@literal null}. * @param opens The packages opened by this module. May be {@literal null}. - * @param uses The internal names of the services used by this module. May be {@literal null}. + * @param uses The internal names of the services used by this module (see {@link + * jdk.internal.org.objectweb.asm.Type#getInternalName()}). May be {@literal null}. * @param provides The services provided by this module. May be {@literal null}. */ public ModuleNode( @@ -265,4 +275,3 @@ public void accept(final ClassVisitor classVisitor) { } } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/ModuleOpenNode.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/ModuleOpenNode.java index afc453ef3b1..abe48f598db 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/ModuleOpenNode.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/ModuleOpenNode.java @@ -69,7 +69,9 @@ */ public class ModuleOpenNode { - /** The internal name of the opened package. */ + /** + * The internal name of the opened package (see {@link jdk.internal.org.objectweb.asm.Type#getInternalName()}). + */ public String packaze; /** @@ -87,7 +89,8 @@ public class ModuleOpenNode { /** * Constructs a new {@link ModuleOpenNode}. * - * @param packaze the internal name of the opened package. + * @param packaze the internal name of the opened package (see {@link + * jdk.internal.org.objectweb.asm.Type#getInternalName()}). * @param access the access flag of the opened package, valid values are among {@code * ACC_SYNTHETIC} and {@code ACC_MANDATED}. * @param modules the fully qualified names (using dots) of the modules that can use deep @@ -109,4 +112,3 @@ public void accept(final ModuleVisitor moduleVisitor) { packaze, access, modules == null ? null : modules.toArray(new String[0])); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/ModuleProvideNode.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/ModuleProvideNode.java index 3370aafe5f2..d48239f55b2 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/ModuleProvideNode.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/ModuleProvideNode.java @@ -69,10 +69,13 @@ */ public class ModuleProvideNode { - /** The internal name of the service. */ + /** The internal name of the service (see {@link jdk.internal.org.objectweb.asm.Type#getInternalName()}). */ public String service; - /** The internal names of the implementations of the service (there is at least one provider). */ + /** + * The internal names of the implementations of the service (there is at least one provider). See + * {@link jdk.internal.org.objectweb.asm.Type#getInternalName()}. + */ public List providers; /** @@ -80,7 +83,7 @@ public class ModuleProvideNode { * * @param service the internal name of the service. * @param providers the internal names of the implementations of the service (there is at least - * one provider). + * one provider). See {@link jdk.internal.org.objectweb.asm.Type#getInternalName()}. */ public ModuleProvideNode(final String service, final List providers) { this.service = service; @@ -96,4 +99,3 @@ public void accept(final ModuleVisitor moduleVisitor) { moduleVisitor.visitProvide(service, providers.toArray(new String[0])); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/ModuleRequireNode.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/ModuleRequireNode.java index cec5ebcdbd2..319d7af23e3 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/ModuleRequireNode.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/ModuleRequireNode.java @@ -103,4 +103,3 @@ public void accept(final ModuleVisitor moduleVisitor) { moduleVisitor.visitRequire(module, access, version); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/MultiANewArrayInsnNode.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/MultiANewArrayInsnNode.java index 201fb7652d6..87a00b69021 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/MultiANewArrayInsnNode.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/MultiANewArrayInsnNode.java @@ -104,4 +104,3 @@ public AbstractInsnNode clone(final Map clonedLabels) { return new MultiANewArrayInsnNode(desc, dims).cloneAnnotations(this); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/ParameterNode.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/ParameterNode.java index cb90eb6db5e..a2223c8c367 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/ParameterNode.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/ParameterNode.java @@ -98,4 +98,3 @@ public void accept(final MethodVisitor methodVisitor) { methodVisitor.visitParameter(name, access); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/RecordComponentNode.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/RecordComponentNode.java index 7eb919b7bbb..7cc87a7776e 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/RecordComponentNode.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/RecordComponentNode.java @@ -234,4 +234,3 @@ public void accept(final ClassVisitor classVisitor) { recordComponentVisitor.visitEnd(); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/TableSwitchInsnNode.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/TableSwitchInsnNode.java index cabc1553c69..94287b55c1c 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/TableSwitchInsnNode.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/TableSwitchInsnNode.java @@ -123,4 +123,3 @@ public AbstractInsnNode clone(final Map clonedLabels) { .cloneAnnotations(this); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/TryCatchBlockNode.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/TryCatchBlockNode.java index fe033a5bc7c..2095218ab0b 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/TryCatchBlockNode.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/TryCatchBlockNode.java @@ -98,8 +98,9 @@ public class TryCatchBlockNode { * @param start the beginning of the exception handler's scope (inclusive). * @param end the end of the exception handler's scope (exclusive). * @param handler the beginning of the exception handler's code. - * @param type the internal name of the type of exceptions handled by the handler, or {@literal - * null} to catch any exceptions (for "finally" blocks). + * @param type the internal name of the type of exceptions handled by the handler (see {@link + * jdk.internal.org.objectweb.asm.Type#getInternalName()}), or {@literal null} to catch any exceptions (for + * "finally" blocks). */ public TryCatchBlockNode( final LabelNode start, final LabelNode end, final LabelNode handler, final String type) { @@ -156,4 +157,3 @@ public void accept(final MethodVisitor methodVisitor) { } } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/TypeAnnotationNode.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/TypeAnnotationNode.java index 938b977c7ba..7a6bbb201f3 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/TypeAnnotationNode.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/TypeAnnotationNode.java @@ -115,4 +115,3 @@ public TypeAnnotationNode( this.typePath = typePath; } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/TypeInsnNode.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/TypeInsnNode.java index 3ebdfab6cee..ba01f50efc1 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/TypeInsnNode.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/TypeInsnNode.java @@ -63,16 +63,16 @@ import jdk.internal.org.objectweb.asm.MethodVisitor; /** - * A node that represents a type instruction. A type instruction is an instruction that takes a type - * descriptor as parameter. + * A node that represents a type instruction. A type instruction is an instruction which takes an + * internal name as parameter (see {@link jdk.internal.org.objectweb.asm.Type#getInternalName()}). * * @author Eric Bruneton */ public class TypeInsnNode extends AbstractInsnNode { /** - * The operand of this instruction. This operand is an internal name (see {@link - * jdk.internal.org.objectweb.asm.Type}). + * The operand of this instruction. Despite its name (due to historical reasons), this operand is + * an internal name (see {@link jdk.internal.org.objectweb.asm.Type#getInternalName()}). */ public String desc; @@ -81,12 +81,12 @@ public class TypeInsnNode extends AbstractInsnNode { * * @param opcode the opcode of the type instruction to be constructed. This opcode must be NEW, * ANEWARRAY, CHECKCAST or INSTANCEOF. - * @param descriptor the operand of the instruction to be constructed. This operand is an internal - * name (see {@link jdk.internal.org.objectweb.asm.Type}). + * @param type the operand of the instruction to be constructed. This operand is an internal name + * (see {@link jdk.internal.org.objectweb.asm.Type#getInternalName()}). */ - public TypeInsnNode(final int opcode, final String descriptor) { + public TypeInsnNode(final int opcode, final String type) { super(opcode); - this.desc = descriptor; + this.desc = type; } /** @@ -115,4 +115,3 @@ public AbstractInsnNode clone(final Map clonedLabels) { return new TypeInsnNode(opcode, desc).cloneAnnotations(this); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/UnsupportedClassVersionException.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/UnsupportedClassVersionException.java index 17f9ebb2e35..ec9c9d04bb6 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/UnsupportedClassVersionException.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/UnsupportedClassVersionException.java @@ -70,4 +70,3 @@ public class UnsupportedClassVersionException extends RuntimeException { private static final long serialVersionUID = -3502347765891805831L; } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/Util.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/Util.java index ac747f4cec2..ae09e55a2d6 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/Util.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/Util.java @@ -193,4 +193,3 @@ static List asArrayList(final int length, final T[] array) { return list; } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/VarInsnNode.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/VarInsnNode.java index c04bda399a3..8e0ddfe8b40 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/VarInsnNode.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/VarInsnNode.java @@ -112,4 +112,3 @@ public AbstractInsnNode clone(final Map clonedLabels) { return new VarInsnNode(opcode, var).cloneAnnotations(this); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/Analyzer.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/Analyzer.java index 222965b8b2f..a3c277e69f1 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/Analyzer.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/Analyzer.java @@ -80,7 +80,7 @@ * A semantic bytecode analyzer. This class does not fully check that JSR and RET instructions * are valid. * - * @param type of the Value used for the analysis. + * @param type of the {@link Value} used for the analysis. * @author Eric Bruneton */ public class Analyzer implements Opcodes { @@ -124,7 +124,8 @@ public Analyzer(final Interpreter interpreter) { /** * Analyzes the given method. * - * @param owner the internal name of the class to which 'method' belongs. + * @param owner the internal name of the class to which 'method' belongs (see {@link + * Type#getInternalName()}). * @param method the method to be analyzed. The maxStack and maxLocals fields must have correct * values. * @return the symbolic state of the execution stack frame at each bytecode instruction of the @@ -154,7 +155,7 @@ public Frame[] analyze(final String owner, final MethodNode method) throws An TryCatchBlockNode tryCatchBlock = method.tryCatchBlocks.get(i); int startIndex = insnList.indexOf(tryCatchBlock.start); int endIndex = insnList.indexOf(tryCatchBlock.end); - for (int j = startIndex; j < endIndex; ++j) { + for (int j = startIndex; j <= endIndex; ++j) { List insnHandlers = handlers[j]; if (insnHandlers == null) { insnHandlers = new ArrayList<>(); @@ -164,37 +165,19 @@ public Frame[] analyze(final String owner, final MethodNode method) throws An } } - // For each instruction, compute the subroutine to which it belongs. - // Follow the main 'subroutine', and collect the jsr instructions to nested subroutines. - Subroutine main = new Subroutine(null, method.maxLocals, null); - List jsrInsns = new ArrayList<>(); - findSubroutine(0, main, jsrInsns); - // Follow the nested subroutines, and collect their own nested subroutines, until all - // subroutines are found. - Map jsrSubroutines = new HashMap<>(); - while (!jsrInsns.isEmpty()) { - JumpInsnNode jsrInsn = (JumpInsnNode) jsrInsns.remove(0); - Subroutine subroutine = jsrSubroutines.get(jsrInsn.label); - if (subroutine == null) { - subroutine = new Subroutine(jsrInsn.label, method.maxLocals, jsrInsn); - jsrSubroutines.put(jsrInsn.label, subroutine); - findSubroutine(insnList.indexOf(jsrInsn.label), subroutine, jsrInsns); - } else { - subroutine.callers.add(jsrInsn); - } - } - // Clear the main 'subroutine', which is not a real subroutine (and was used only as an - // intermediate step above to find the real ones). - for (int i = 0; i < insnListSize; ++i) { - if (subroutines[i] != null && subroutines[i].start == null) { - subroutines[i] = null; - } - } + // Finds the method's subroutines. + findSubroutines(method.maxLocals); // Initializes the data structures for the control flow analysis. - Frame currentFrame = computeInitialFrame(owner, method); - merge(0, currentFrame, null); - init(owner, method); + Frame currentFrame; + try { + currentFrame = computeInitialFrame(owner, method); + merge(0, currentFrame, null); + init(owner, method); + } catch (RuntimeException e) { + // DontCheck(IllegalCatch): can't be fixed, for backward compatibility. + throw new AnalyzerException(insnList.get(0), "Error at instruction 0: " + e.getMessage(), e); + } // Control flow analysis. while (numInstructionsToProcess > 0) { @@ -336,7 +319,8 @@ public Frame[] analyze(final String owner, final MethodNode method) throws An * Analyzes the given method and computes and sets its maximum stack size and maximum number of * local variables. * - * @param owner the internal name of the class to which 'method' belongs. + * @param owner the internal name of the class to which 'method' belongs (see {@link + * Type#getInternalName()}). * @param method the method to be analyzed. * @return the symbolic state of the execution stack frame at each bytecode instruction of the * method. The size of the returned array is equal to the number of instructions (and labels) @@ -361,6 +345,9 @@ public Frame[] analyzeAndComputeMaxs(final String owner, final MethodNode met */ private static int computeMaxLocals(final MethodNode method) { int maxLocals = Type.getArgumentsAndReturnSizes(method.desc) >> 2; + if ((method.access & Opcodes.ACC_STATIC) != 0) { + maxLocals -= 1; + } for (AbstractInsnNode insnNode : method.instructions) { if (insnNode instanceof VarInsnNode) { int local = ((VarInsnNode) insnNode).var; @@ -400,6 +387,42 @@ private static int computeMaxStack(final Frame[] frames) { return maxStack; } + /** + * Finds the subroutines of the currently analyzed method and stores them in {@link #subroutines}. + * + * @param maxLocals the maximum number of local variables of the currently analyzed method (long + * and double values count for two variables). + * @throws AnalyzerException if the control flow graph can fall off the end of the code. + */ + private void findSubroutines(final int maxLocals) throws AnalyzerException { + // For each instruction, compute the subroutine to which it belongs. + // Follow the main 'subroutine', and collect the jsr instructions to nested subroutines. + Subroutine main = new Subroutine(null, maxLocals, null); + List jsrInsns = new ArrayList<>(); + findSubroutine(0, main, jsrInsns); + // Follow the nested subroutines, and collect their own nested subroutines, until all + // subroutines are found. + Map jsrSubroutines = new HashMap<>(); + while (!jsrInsns.isEmpty()) { + JumpInsnNode jsrInsn = (JumpInsnNode) jsrInsns.remove(0); + Subroutine subroutine = jsrSubroutines.get(jsrInsn.label); + if (subroutine == null) { + subroutine = new Subroutine(jsrInsn.label, maxLocals, jsrInsn); + jsrSubroutines.put(jsrInsn.label, subroutine); + findSubroutine(insnList.indexOf(jsrInsn.label), subroutine, jsrInsns); + } else { + subroutine.callers.add(jsrInsn); + } + } + // Clear the main 'subroutine', which is not a real subroutine (and was used only as an + // intermediate step above to find the real ones). + for (int i = 0; i < insnListSize; ++i) { + if (subroutines[i] != null && subroutines[i].start == null) { + subroutines[i] = null; + } + } + } + /** * Follows the control flow graph of the currently analyzed method, starting at the given * instruction index, and stores a copy of the given subroutine in {@link #subroutines} for each @@ -485,7 +508,8 @@ private void findSubroutine( /** * Computes the initial execution stack frame of the given method. * - * @param owner the internal name of the class to which 'method' belongs. + * @param owner the internal name of the class to which 'method' belongs (see {@link + * Type#getInternalName()}). * @param method the method to be analyzed. * @return the initial execution stack frame of the 'method'. */ @@ -542,9 +566,10 @@ public List getHandlers(final int insnIndex) { /** * Initializes this analyzer. This method is called just before the execution of control flow - * analysis loop in #analyze. The default implementation of this method does nothing. + * analysis loop in {@link #analyze}. The default implementation of this method does nothing. * - * @param owner the internal name of the class to which the method belongs. + * @param owner the internal name of the class to which the method belongs (see {@link + * Type#getInternalName()}). * @param method the method to be analyzed. * @throws AnalyzerException if a problem occurs. */ @@ -702,4 +727,3 @@ private void merge( } } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/AnalyzerException.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/AnalyzerException.java index e3ea04720be..5101b2f534a 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/AnalyzerException.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/AnalyzerException.java @@ -119,4 +119,3 @@ public AnalyzerException( this.node = insn; } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/BasicInterpreter.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/BasicInterpreter.java index c725fd65499..7dee3af4405 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/BasicInterpreter.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/BasicInterpreter.java @@ -405,4 +405,3 @@ public BasicValue merge(final BasicValue value1, final BasicValue value2) { return value1; } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/BasicValue.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/BasicValue.java index 58b57120ebd..3d854f63686 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/BasicValue.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/BasicValue.java @@ -159,4 +159,3 @@ public String toString() { } } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/BasicVerifier.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/BasicVerifier.java index a9d08e022aa..ebe738fe420 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/BasicVerifier.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/BasicVerifier.java @@ -480,4 +480,3 @@ protected boolean isSubTypeOf(final BasicValue value, final BasicValue expected) return value.equals(expected); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/Frame.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/Frame.java index 6c8b222ef92..5940c9ed91a 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/Frame.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/Frame.java @@ -704,7 +704,7 @@ private void executeInvokeInsn( final AbstractInsnNode insn, final String methodDescriptor, final Interpreter interpreter) throws AnalyzerException { ArrayList valueList = new ArrayList<>(); - for (int i = Type.getArgumentTypes(methodDescriptor).length; i > 0; --i) { + for (int i = Type.getArgumentCount(methodDescriptor); i > 0; --i) { valueList.add(0, pop()); } if (insn.getOpcode() != Opcodes.INVOKESTATIC && insn.getOpcode() != Opcodes.INVOKEDYNAMIC) { @@ -782,4 +782,3 @@ public String toString() { return stringBuilder.toString(); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/Interpreter.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/Interpreter.java index 7b28e68a1ea..d2c6103b77e 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/Interpreter.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/Interpreter.java @@ -297,4 +297,3 @@ public abstract void returnOperation(AbstractInsnNode insn, V value, V expected) */ public abstract V merge(V value1, V value2); } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/SimpleVerifier.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/SimpleVerifier.java index 7f611cde57a..6f2f124ab31 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/SimpleVerifier.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/SimpleVerifier.java @@ -411,4 +411,3 @@ protected Class getClass(final Type type) { } } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/SmallSet.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/SmallSet.java index 099a7377944..3c85d565ef8 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/SmallSet.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/SmallSet.java @@ -228,4 +228,3 @@ public void remove() { } } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/SourceInterpreter.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/SourceInterpreter.java index 3078081e5a9..d92ffce0a59 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/SourceInterpreter.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/SourceInterpreter.java @@ -250,4 +250,3 @@ private static boolean containsAll(final Set self, final Set other) { return self.containsAll(other); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/SourceValue.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/SourceValue.java index 885ba47bcf0..5403130af8c 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/SourceValue.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/SourceValue.java @@ -149,4 +149,3 @@ public int hashCode() { return insns.hashCode(); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/Subroutine.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/Subroutine.java index f59644795d7..67267e0119e 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/Subroutine.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/Subroutine.java @@ -136,4 +136,3 @@ public boolean merge(final Subroutine subroutine) { return changed; } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/Value.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/Value.java index 450120c741a..7058c959783 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/Value.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/Value.java @@ -74,4 +74,3 @@ public interface Value { */ int getSize(); } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/ASMifier.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/ASMifier.java index a1563bee95b..074c8029fc2 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/ASMifier.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/ASMifier.java @@ -75,7 +75,7 @@ import jdk.internal.org.objectweb.asm.TypePath; /** - * A {@link Printer} that prints the ASM code to generate the classes if visits. + * A {@link Printer} that prints the ASM code to generate the classes it visits. * * @author Eric Bruneton */ @@ -141,6 +141,10 @@ public class ASMifier extends Printer { classVersions.put(Opcodes.V17, "V17"); classVersions.put(Opcodes.V18, "V18"); classVersions.put(Opcodes.V19, "V19"); + classVersions.put(Opcodes.V20, "V20"); + classVersions.put(Opcodes.V21, "V21"); + classVersions.put(Opcodes.V22, "V22"); + classVersions.put(Opcodes.V23, "V23"); CLASS_VERSIONS = Collections.unmodifiableMap(classVersions); } @@ -1641,4 +1645,3 @@ protected void appendLabel(final Label label) { stringBuilder.append(labelNames.get(label)); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/ASMifierSupport.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/ASMifierSupport.java index 956938394a4..b592281332f 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/ASMifierSupport.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/ASMifierSupport.java @@ -81,4 +81,3 @@ public interface ASMifierSupport { void asmify( StringBuilder outputBuilder, String visitorVariableName, Map labelNames); } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckAnnotationAdapter.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckAnnotationAdapter.java index b3d21f5ae99..1133c5ee361 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckAnnotationAdapter.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckAnnotationAdapter.java @@ -165,4 +165,3 @@ private void checkVisitEndNotCalled() { } } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckClassAdapter.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckClassAdapter.java index 3aa26bed646..49f4bc78387 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckClassAdapter.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckClassAdapter.java @@ -496,7 +496,8 @@ public MethodVisitor visitMethod( if (checkDataFlow) { if (cv instanceof ClassWriter) { methodVisitor = - new CheckMethodAdapter.MethodWriterWrapper(api, (ClassWriter) cv, methodVisitor); + new CheckMethodAdapter.MethodWriterWrapper( + api, version, (ClassWriter) cv, methodVisitor); } checkMethodAdapter = new CheckMethodAdapter(api, access, name, descriptor, methodVisitor, labelInsnIndices); @@ -1166,4 +1167,3 @@ private static String getUnqualifiedName(final String name) { } } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckFieldAdapter.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckFieldAdapter.java index 790faf1dde0..16b0ea8d7d6 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckFieldAdapter.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckFieldAdapter.java @@ -146,4 +146,3 @@ private void checkVisitEndNotCalled() { } } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckFrameAnalyzer.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckFrameAnalyzer.java new file mode 100644 index 00000000000..754f648ad9a --- /dev/null +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckFrameAnalyzer.java @@ -0,0 +1,513 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * This file is available under and governed by the GNU General Public + * License version 2 only, as published by the Free Software Foundation. + * However, the following notice accompanied the original version of this + * file: + * + * ASM: a very small and fast Java bytecode manipulation framework + * Copyright (c) 2000-2011 INRIA, France Telecom + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +package jdk.internal.org.objectweb.asm.util; + +import java.util.Collections; +import java.util.List; +import jdk.internal.org.objectweb.asm.Opcodes; +import jdk.internal.org.objectweb.asm.Type; +import jdk.internal.org.objectweb.asm.tree.AbstractInsnNode; +import jdk.internal.org.objectweb.asm.tree.FrameNode; +import jdk.internal.org.objectweb.asm.tree.InsnList; +import jdk.internal.org.objectweb.asm.tree.InsnNode; +import jdk.internal.org.objectweb.asm.tree.JumpInsnNode; +import jdk.internal.org.objectweb.asm.tree.LabelNode; +import jdk.internal.org.objectweb.asm.tree.LookupSwitchInsnNode; +import jdk.internal.org.objectweb.asm.tree.MethodNode; +import jdk.internal.org.objectweb.asm.tree.TableSwitchInsnNode; +import jdk.internal.org.objectweb.asm.tree.TryCatchBlockNode; +import jdk.internal.org.objectweb.asm.tree.TypeInsnNode; +import jdk.internal.org.objectweb.asm.tree.analysis.Analyzer; +import jdk.internal.org.objectweb.asm.tree.analysis.AnalyzerException; +import jdk.internal.org.objectweb.asm.tree.analysis.Frame; +import jdk.internal.org.objectweb.asm.tree.analysis.Interpreter; +import jdk.internal.org.objectweb.asm.tree.analysis.Value; + +/** + * An {@link Analyzer} subclass which checks that methods provide stack map frames where expected + * (i.e. at jump target and after instructions without immediate successor), and that these stack + * map frames are valid (for the provided interpreter; they may still be invalid for the JVM, if the + * {@link Interpreter} uses a simplified type system compared to the JVM verifier). This is done in + * two steps: + * + *
      + *
    • First, the stack map frames in {@link FrameNode}s are expanded, and stored at their + * respective instruction offsets. The expansion process uncompresses the APPEND, CHOP and + * SAME frames to FULL frames. It also converts the stack map frame verification types to + * {@link Value}s, via the provided {@link Interpreter}. The expansion is done in {@link + * #expandFrames}, by looking at each {@link FrameNode} in sequence (compressed frames are + * defined relatively to the previous {@link FrameNode}, or the implicit first frame). The + * actual decompression is done in {@link #expandFrame}, and the type conversion in {@link + * #newFrameValue}. + *
    • Next, the method instructions are checked in sequence. Starting from the implicit initial + * frame, the execution of each instruction i is simulated on the current stack map + * frame, with the {@link Frame#execute} method. This gives a new stack map frame f, + * representing the stack map frame state after the execution of i. Then: + *
        + *
      • If there is a next instruction and if the control flow cannot continue to it (e.g. if + * i is a RETURN or an ATHROW, for instance): an existing stack map frame + * f0 (coming from the first step) is expected after i. + *
      • If there is a next instruction and if the control flow can continue to it (e.g. if + * i is a ALOAD, for instance): either there an existing stack map frame + * f0 (coming from the first step) after i, or there is none. In the + * first case f and f0 must be compatible: the types in + * f must be sub types of the corresponding types in the existing frame + * f0 (otherwise an exception is thrown). In the second case, f0 is + * simply set to the value of f. + *
      • If the control flow can continue to some instruction j (e.g. if i + * is an IF_EQ, for instance): an existing stack map frame f0 (coming from the + * first step) is expected at j, which must be compatible with f (as + * defined previously). + *
      + * The sequential loop over the instructions is done in {@link #init}, which is called from + * the {@link Analyzer#analyze} method. Cases where the control flow cannot continue to the + * next instruction are handled in {@link #endControlFlow}. Cases where the control flow can + * continue to the next instruction, or jump to another instruction, are handled in {@link + * #checkFrame}. This method checks that an existing stack map frame is present when required, + * and checks the stack map frames compatibility with {@link #checkMerge}. + *
    + * + * @author Eric Bruneton + * @param type of the {@link Value} used for the analysis. + */ +class CheckFrameAnalyzer extends Analyzer { + + /** The interpreter to use to symbolically interpret the bytecode instructions. */ + private final Interpreter interpreter; + + /** The instructions of the currently analyzed method. */ + private InsnList insnList; + + /** + * The number of locals in the last stack map frame processed by {@link expandFrame}. Long and + * double values are represented with two elements. + */ + private int currentLocals; + + CheckFrameAnalyzer(final Interpreter interpreter) { + super(interpreter); + this.interpreter = interpreter; + } + + @Override + protected void init(final String owner, final MethodNode method) throws AnalyzerException { + insnList = method.instructions; + currentLocals = Type.getArgumentsAndReturnSizes(method.desc) >> 2; + if ((method.access & Opcodes.ACC_STATIC) != 0) { + currentLocals -= 1; + } + + Frame[] frames = getFrames(); + Frame currentFrame = frames[0]; + expandFrames(owner, method, currentFrame); + for (int insnIndex = 0; insnIndex < insnList.size(); ++insnIndex) { + Frame oldFrame = frames[insnIndex]; + + // Simulate the execution of this instruction. + AbstractInsnNode insnNode = null; + try { + insnNode = method.instructions.get(insnIndex); + int insnOpcode = insnNode.getOpcode(); + int insnType = insnNode.getType(); + + if (insnType == AbstractInsnNode.LABEL + || insnType == AbstractInsnNode.LINE + || insnType == AbstractInsnNode.FRAME) { + checkFrame(insnIndex + 1, oldFrame, /* requireFrame = */ false); + } else { + currentFrame.init(oldFrame).execute(insnNode, interpreter); + + if (insnNode instanceof JumpInsnNode) { + if (insnOpcode == JSR) { + throw new AnalyzerException(insnNode, "JSR instructions are unsupported"); + } + JumpInsnNode jumpInsn = (JumpInsnNode) insnNode; + int targetInsnIndex = insnList.indexOf(jumpInsn.label); + checkFrame(targetInsnIndex, currentFrame, /* requireFrame = */ true); + if (insnOpcode == GOTO) { + endControlFlow(insnIndex); + } else { + checkFrame(insnIndex + 1, currentFrame, /* requireFrame = */ false); + } + } else if (insnNode instanceof LookupSwitchInsnNode) { + LookupSwitchInsnNode lookupSwitchInsn = (LookupSwitchInsnNode) insnNode; + int targetInsnIndex = insnList.indexOf(lookupSwitchInsn.dflt); + checkFrame(targetInsnIndex, currentFrame, /* requireFrame = */ true); + for (int i = 0; i < lookupSwitchInsn.labels.size(); ++i) { + LabelNode label = lookupSwitchInsn.labels.get(i); + targetInsnIndex = insnList.indexOf(label); + currentFrame.initJumpTarget(insnOpcode, label); + checkFrame(targetInsnIndex, currentFrame, /* requireFrame = */ true); + } + endControlFlow(insnIndex); + } else if (insnNode instanceof TableSwitchInsnNode) { + TableSwitchInsnNode tableSwitchInsn = (TableSwitchInsnNode) insnNode; + int targetInsnIndex = insnList.indexOf(tableSwitchInsn.dflt); + currentFrame.initJumpTarget(insnOpcode, tableSwitchInsn.dflt); + checkFrame(targetInsnIndex, currentFrame, /* requireFrame = */ true); + newControlFlowEdge(insnIndex, targetInsnIndex); + for (int i = 0; i < tableSwitchInsn.labels.size(); ++i) { + LabelNode label = tableSwitchInsn.labels.get(i); + currentFrame.initJumpTarget(insnOpcode, label); + targetInsnIndex = insnList.indexOf(label); + checkFrame(targetInsnIndex, currentFrame, /* requireFrame = */ true); + } + endControlFlow(insnIndex); + } else if (insnOpcode == RET) { + throw new AnalyzerException(insnNode, "RET instructions are unsupported"); + } else if (insnOpcode != ATHROW && (insnOpcode < IRETURN || insnOpcode > RETURN)) { + checkFrame(insnIndex + 1, currentFrame, /* requireFrame = */ false); + } else { + endControlFlow(insnIndex); + } + } + + List insnHandlers = getHandlers(insnIndex); + if (insnHandlers != null) { + for (TryCatchBlockNode tryCatchBlock : insnHandlers) { + Type catchType; + if (tryCatchBlock.type == null) { + catchType = Type.getObjectType("java/lang/Throwable"); + } else { + catchType = Type.getObjectType(tryCatchBlock.type); + } + Frame handler = newFrame(oldFrame); + handler.clearStack(); + handler.push(interpreter.newExceptionValue(tryCatchBlock, handler, catchType)); + checkFrame(insnList.indexOf(tryCatchBlock.handler), handler, /* requireFrame = */ true); + } + } + + if (!hasNextJvmInsnOrFrame(insnIndex)) { + break; + } + } catch (AnalyzerException e) { + throw new AnalyzerException( + e.node, "Error at instruction " + insnIndex + ": " + e.getMessage(), e); + } catch (RuntimeException e) { + // DontCheck(IllegalCatch): can't be fixed, for backward compatibility. + throw new AnalyzerException( + insnNode, "Error at instruction " + insnIndex + ": " + e.getMessage(), e); + } + } + } + + /** + * Expands the {@link FrameNode} "instructions" of the given method into {@link Frame} objects and + * stores them at the corresponding indices of the {@link #frames} array. The expanded frames are + * also associated with the label and line number nodes immediately preceding each frame node. + * + * @param owner the internal name of the class to which 'method' belongs. + * @param method the method whose frames must be expanded. + * @param initialFrame the implicit initial frame of 'method'. + * @throws AnalyzerException if the stack map frames of 'method', i.e. its FrameNode + * "instructions", are invalid. + */ + private void expandFrames( + final String owner, final MethodNode method, final Frame initialFrame) + throws AnalyzerException { + int lastJvmOrFrameInsnIndex = -1; + Frame currentFrame = initialFrame; + int currentInsnIndex = 0; + for (AbstractInsnNode insnNode : method.instructions) { + if (insnNode instanceof FrameNode) { + try { + currentFrame = expandFrame(owner, currentFrame, (FrameNode) insnNode); + } catch (AnalyzerException e) { + throw new AnalyzerException( + e.node, "Error at instruction " + currentInsnIndex + ": " + e.getMessage(), e); + } + for (int index = lastJvmOrFrameInsnIndex + 1; index <= currentInsnIndex; ++index) { + getFrames()[index] = currentFrame; + } + } + if (isJvmInsnNode(insnNode) || insnNode instanceof FrameNode) { + lastJvmOrFrameInsnIndex = currentInsnIndex; + } + currentInsnIndex += 1; + } + } + + /** + * Returns the expanded representation of the given {@link FrameNode}. + * + * @param owner the internal name of the class to which 'frameNode' belongs. + * @param previousFrame the frame before 'frameNode', in expanded form. + * @param frameNode a possibly compressed stack map frame. + * @return the expanded version of 'frameNode'. + * @throws AnalyzerException if 'frameNode' is invalid. + */ + @SuppressWarnings("fallthrough") + private Frame expandFrame( + final String owner, final Frame previousFrame, final FrameNode frameNode) + throws AnalyzerException { + Frame frame = newFrame(previousFrame); + List locals = frameNode.local == null ? Collections.emptyList() : frameNode.local; + int currentLocal = currentLocals; + switch (frameNode.type) { + case Opcodes.F_NEW: + case Opcodes.F_FULL: + currentLocal = 0; + // fall through + case Opcodes.F_APPEND: + for (Object type : locals) { + V value = newFrameValue(owner, frameNode, type); + if (currentLocal + value.getSize() > frame.getLocals()) { + throw new AnalyzerException(frameNode, "Cannot append more locals than maxLocals"); + } + frame.setLocal(currentLocal++, value); + if (value.getSize() == 2) { + frame.setLocal(currentLocal++, interpreter.newValue(null)); + } + } + break; + case Opcodes.F_CHOP: + for (Object unusedType : locals) { + if (currentLocal <= 0) { + throw new AnalyzerException(frameNode, "Cannot chop more locals than defined"); + } + if (currentLocal > 1 && frame.getLocal(currentLocal - 2).getSize() == 2) { + currentLocal -= 2; + } else { + currentLocal -= 1; + } + } + break; + case Opcodes.F_SAME: + case Opcodes.F_SAME1: + break; + default: + throw new AnalyzerException(frameNode, "Illegal frame type " + frameNode.type); + } + currentLocals = currentLocal; + while (currentLocal < frame.getLocals()) { + frame.setLocal(currentLocal++, interpreter.newValue(null)); + } + + List stack = frameNode.stack == null ? Collections.emptyList() : frameNode.stack; + frame.clearStack(); + for (Object type : stack) { + frame.push(newFrameValue(owner, frameNode, type)); + } + return frame; + } + + /** + * Creates a new {@link Value} that represents the given stack map frame type. + * + * @param owner the internal name of the class to which 'frameNode' belongs. + * @param frameNode the stack map frame to which 'type' belongs. + * @param type an Integer, String or LabelNode object representing a primitive, reference or + * uninitialized a stack map frame type, respectively. See {@link FrameNode}. + * @return a value that represents the given type. + * @throws AnalyzerException if 'type' is an invalid stack map frame type. + */ + private V newFrameValue(final String owner, final FrameNode frameNode, final Object type) + throws AnalyzerException { + if (type == Opcodes.TOP) { + return interpreter.newValue(null); + } else if (type == Opcodes.INTEGER) { + return interpreter.newValue(Type.INT_TYPE); + } else if (type == Opcodes.FLOAT) { + return interpreter.newValue(Type.FLOAT_TYPE); + } else if (type == Opcodes.LONG) { + return interpreter.newValue(Type.LONG_TYPE); + } else if (type == Opcodes.DOUBLE) { + return interpreter.newValue(Type.DOUBLE_TYPE); + } else if (type == Opcodes.NULL) { + return interpreter.newOperation(new InsnNode(Opcodes.ACONST_NULL)); + } else if (type == Opcodes.UNINITIALIZED_THIS) { + return interpreter.newValue(Type.getObjectType(owner)); + } else if (type instanceof String) { + return interpreter.newValue(Type.getObjectType((String) type)); + } else if (type instanceof LabelNode) { + AbstractInsnNode referencedNode = (LabelNode) type; + while (referencedNode != null && !isJvmInsnNode(referencedNode)) { + referencedNode = referencedNode.getNext(); + } + if (referencedNode == null || referencedNode.getOpcode() != Opcodes.NEW) { + throw new AnalyzerException(frameNode, "LabelNode does not designate a NEW instruction"); + } + return interpreter.newValue(Type.getObjectType(((TypeInsnNode) referencedNode).desc)); + } + throw new AnalyzerException(frameNode, "Illegal stack map frame value " + type); + } + + /** + * Checks that the given frame is compatible with the frame at the given instruction index, if + * any. If there is no frame at this instruction index and none is required, the frame at + * 'insnIndex' is set to the given frame. Otherwise, if the merge of the two frames is not equal + * to the current frame at 'insnIndex', an exception is thrown. + * + * @param insnIndex an instruction index. + * @param frame a frame. This frame is left unchanged by this method. + * @param requireFrame whether a frame must already exist or not in {@link #frames} at + * 'insnIndex'. + * @throws AnalyzerException if the frames have incompatible sizes or if the frame at 'insnIndex' + * is missing (if required) or not compatible with 'frame'. + */ + private void checkFrame(final int insnIndex, final Frame frame, final boolean requireFrame) + throws AnalyzerException { + Frame oldFrame = getFrames()[insnIndex]; + if (oldFrame == null) { + if (requireFrame) { + throw new AnalyzerException(null, "Expected stack map frame at instruction " + insnIndex); + } + getFrames()[insnIndex] = newFrame(frame); + } else { + String error = checkMerge(frame, oldFrame); + if (error != null) { + throw new AnalyzerException( + null, + "Stack map frame incompatible with frame at instruction " + + insnIndex + + " (" + + error + + ")"); + } + } + } + + /** + * Checks that merging the two given frames would not produce any change, i.e. that the types in + * the source frame are sub types of the corresponding types in the destination frame. + * + * @param srcFrame a source frame. This frame is left unchanged by this method. + * @param dstFrame a destination frame. This frame is left unchanged by this method. + * @return an error message if the frames have incompatible sizes, or if a type in the source + * frame is not a sub type of the corresponding type in the destination frame. Returns + * {@literal null} otherwise. + */ + private String checkMerge(final Frame srcFrame, final Frame dstFrame) { + int numLocals = srcFrame.getLocals(); + if (numLocals != dstFrame.getLocals()) { + throw new AssertionError(); + } + for (int i = 0; i < numLocals; ++i) { + V v = interpreter.merge(srcFrame.getLocal(i), dstFrame.getLocal(i)); + if (!v.equals(dstFrame.getLocal(i))) { + return "incompatible types at local " + + i + + ": " + + srcFrame.getLocal(i) + + " and " + + dstFrame.getLocal(i); + } + } + int numStack = srcFrame.getStackSize(); + if (numStack != dstFrame.getStackSize()) { + return "incompatible stack heights"; + } + for (int i = 0; i < numStack; ++i) { + V v = interpreter.merge(srcFrame.getStack(i), dstFrame.getStack(i)); + if (!v.equals(dstFrame.getStack(i))) { + return "incompatible types at stack item " + + i + + ": " + + srcFrame.getStack(i) + + " and " + + dstFrame.getStack(i); + } + } + return null; + } + + /** + * Ends the control flow graph at the given instruction. This method checks that there is an + * existing frame for the next instruction, if any. + * + * @param insnIndex an instruction index. + * @throws AnalyzerException if 'insnIndex' is not the last instruction and there is no frame at + * 'insnIndex' + 1 in {@link #getFrames}. + */ + private void endControlFlow(final int insnIndex) throws AnalyzerException { + if (hasNextJvmInsnOrFrame(insnIndex) && getFrames()[insnIndex + 1] == null) { + throw new AnalyzerException( + null, "Expected stack map frame at instruction " + (insnIndex + 1)); + } + } + + /** + * Returns true if the given instruction is followed by a JVM instruction or a by stack map frame. + * + * @param insnIndex an instruction index. + * @return true if 'insnIndex' is followed by a JVM instruction or a by stack map frame. + */ + private boolean hasNextJvmInsnOrFrame(final int insnIndex) { + AbstractInsnNode insn = insnList.get(insnIndex).getNext(); + while (insn != null) { + if (isJvmInsnNode(insn) || insn instanceof FrameNode) { + return true; + } + insn = insn.getNext(); + } + return false; + } + + /** + * Returns true if the given instruction node corresponds to a real JVM instruction. + * + * @param insnNode an instruction node. + * @return true except for label, line number and stack map frame nodes. + */ + private static boolean isJvmInsnNode(final AbstractInsnNode insnNode) { + return insnNode.getOpcode() >= 0; + } +} diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckMethodAdapter.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckMethodAdapter.java index 6cc0a19e10a..59c41108628 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckMethodAdapter.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckMethodAdapter.java @@ -62,7 +62,6 @@ import java.io.PrintWriter; import java.io.StringWriter; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -479,16 +478,26 @@ protected CheckMethodAdapter( new MethodNode(api, access, name, descriptor, null, null) { @Override public void visitEnd() { - Analyzer analyzer = new Analyzer<>(new BasicVerifier()); - try { + int originalMaxLocals = maxLocals; + int originalMaxStack = maxStack; + boolean checkMaxStackAndLocals = false; + boolean checkFrames = false; + if (methodVisitor instanceof MethodWriterWrapper) { + MethodWriterWrapper methodWriter = (MethodWriterWrapper) methodVisitor; // If 'methodVisitor' is a MethodWriter of a ClassWriter with no flags to compute the // max stack and locals nor the stack map frames, we know that valid max stack and // locals must be provided. Otherwise we assume they are not needed at this stage. - // TODO(ebruneton): similarly, check that valid stack map frames are provided if the - // class writer has no flags to compute them, and the class version is V1_7 or more. - boolean checkMaxStackAndLocals = - (methodVisitor instanceof MethodWriterWrapper) - && !((MethodWriterWrapper) methodVisitor).computesMaxs(); + checkMaxStackAndLocals = !methodWriter.computesMaxs(); + // If 'methodVisitor' is a MethodWriter of a ClassWriter with no flags to compute the + // stack map frames, we know that valid frames must be provided. Otherwise we assume + // they are not needed at this stage. + checkFrames = methodWriter.requiresFrames() && !methodWriter.computesFrames(); + } + Analyzer analyzer = + checkFrames + ? new CheckFrameAnalyzer<>(new BasicVerifier()) + : new Analyzer<>(new BasicVerifier()); + try { if (checkMaxStackAndLocals) { analyzer.analyze("dummy", this); } else { @@ -498,6 +507,8 @@ public void visitEnd() { throwError(analyzer, e); } if (methodVisitor != null) { + maxLocals = originalMaxLocals; + maxStack = originalMaxStack; accept(methodVisitor); } } @@ -808,9 +819,8 @@ public void visitJumpInsn(final int opcode, final Label label) { checkVisitCodeCalled(); checkVisitMaxsNotCalled(); checkOpcodeMethod(opcode, Method.VISIT_JUMP_INSN); - checkLabel(label, false, "label"); + checkLabel(label, /* checkVisited = */ false, "label"); super.visitJumpInsn(opcode, label); - referencedLabels.add(label); ++insnCount; } @@ -818,7 +828,7 @@ public void visitJumpInsn(final int opcode, final Label label) { public void visitLabel(final Label label) { checkVisitCodeCalled(); checkVisitMaxsNotCalled(); - checkLabel(label, false, "label"); + checkLabel(label, /* checkVisited = */ false, "label"); if (labelInsnIndices.get(label) != null) { throw new IllegalStateException("Already visited label"); } @@ -854,15 +864,14 @@ public void visitTableSwitchInsn( throw new IllegalArgumentException( "Max = " + max + " must be greater than or equal to min = " + min); } - checkLabel(dflt, false, "default label"); + checkLabel(dflt, /* checkVisited = */ false, "default label"); if (labels == null || labels.length != max - min + 1) { throw new IllegalArgumentException("There must be max - min + 1 labels"); } for (int i = 0; i < labels.length; ++i) { - checkLabel(labels[i], false, "label at index " + i); + checkLabel(labels[i], /* checkVisited = */ false, "label at index " + i); } super.visitTableSwitchInsn(min, max, dflt, labels); - Collections.addAll(referencedLabels, labels); ++insnCount; } @@ -870,16 +879,14 @@ public void visitTableSwitchInsn( public void visitLookupSwitchInsn(final Label dflt, final int[] keys, final Label[] labels) { checkVisitMaxsNotCalled(); checkVisitCodeCalled(); - checkLabel(dflt, false, "default label"); + checkLabel(dflt, /* checkVisited = */ false, "default label"); if (keys == null || labels == null || keys.length != labels.length) { throw new IllegalArgumentException("There must be the same number of keys and labels"); } for (int i = 0; i < labels.length; ++i) { - checkLabel(labels[i], false, "label at index " + i); + checkLabel(labels[i], /* checkVisited = */ false, "label at index " + i); } super.visitLookupSwitchInsn(dflt, keys, labels); - referencedLabels.add(dflt); - Collections.addAll(referencedLabels, labels); ++insnCount; } @@ -933,9 +940,9 @@ public void visitTryCatchBlock( final Label start, final Label end, final Label handler, final String type) { checkVisitCodeCalled(); checkVisitMaxsNotCalled(); - checkLabel(start, false, START_LABEL); - checkLabel(end, false, END_LABEL); - checkLabel(handler, false, "handler label"); + checkLabel(start, /* checkVisited = */ false, START_LABEL); + checkLabel(end, /* checkVisited = */ false, END_LABEL); + checkLabel(handler, /* checkVisited = */ false, "handler label"); if (labelInsnIndices.get(start) != null || labelInsnIndices.get(end) != null || labelInsnIndices.get(handler) != null) { @@ -979,8 +986,8 @@ public void visitLocalVariable( if (signature != null) { CheckClassAdapter.checkFieldSignature(signature); } - checkLabel(start, true, START_LABEL); - checkLabel(end, true, END_LABEL); + checkLabel(start, /* checkVisited = */ true, START_LABEL); + checkLabel(end, /* checkVisited = */ true, END_LABEL); checkUnsignedShort(index, INVALID_LOCAL_VARIABLE_INDEX); int startInsnIndex = labelInsnIndices.get(start).intValue(); int endInsnIndex = labelInsnIndices.get(end).intValue(); @@ -1017,8 +1024,8 @@ public AnnotationVisitor visitLocalVariableAnnotation( "Invalid start, end and index arrays (must be non null and of identical length"); } for (int i = 0; i < start.length; ++i) { - checkLabel(start[i], true, START_LABEL); - checkLabel(end[i], true, END_LABEL); + checkLabel(start[i], /* checkVisited = */ true, START_LABEL); + checkLabel(end[i], /* checkVisited = */ true, END_LABEL); checkUnsignedShort(index[i], INVALID_LOCAL_VARIABLE_INDEX); int startInsnIndex = labelInsnIndices.get(start[i]).intValue(); int endInsnIndex = labelInsnIndices.get(end[i]).intValue(); @@ -1036,7 +1043,7 @@ public void visitLineNumber(final int line, final Label start) { checkVisitCodeCalled(); checkVisitMaxsNotCalled(); checkUnsignedShort(line, "Invalid line number"); - checkLabel(start, true, START_LABEL); + checkLabel(start, /* checkVisited = */ true, START_LABEL); super.visitLineNumber(line, start); } @@ -1053,11 +1060,8 @@ public void visitMaxs(final int maxStack, final int maxLocals) { for (int i = 0; i < handlers.size(); i += 2) { Integer startInsnIndex = labelInsnIndices.get(handlers.get(i)); Integer endInsnIndex = labelInsnIndices.get(handlers.get(i + 1)); - if (startInsnIndex == null || endInsnIndex == null) { - throw new IllegalStateException("Undefined try catch block labels"); - } if (endInsnIndex.intValue() <= startInsnIndex.intValue()) { - throw new IllegalStateException("Emty try catch block handler range"); + throw new IllegalStateException("Empty try catch block handler range"); } } checkUnsignedShort(maxStack, "Invalid max stack"); @@ -1116,7 +1120,7 @@ private void checkFrameValue(final Object value) { if (value instanceof String) { checkInternalName(version, (String) value, "Invalid stack frame value"); } else if (value instanceof Label) { - referencedLabels.add((Label) value); + checkLabel((Label) value, /* checkVisited = */ false, "label"); } else { throw new IllegalArgumentException("Invalid stack frame value: " + value); } @@ -1129,9 +1133,13 @@ private void checkFrameValue(final Object value) { * @param method the expected visit method. */ private static void checkOpcodeMethod(final int opcode, final Method method) { - if (opcode < Opcodes.NOP || opcode > Opcodes.IFNONNULL || OPCODE_METHODS[opcode] != method) { + if (opcode < Opcodes.NOP || opcode > Opcodes.IFNONNULL) { throw new IllegalArgumentException("Invalid opcode: " + opcode); } + if (OPCODE_METHODS[opcode] != method) { + throw new IllegalArgumentException( + "Invalid combination of opcode and method: " + opcode + ", " + method); + } } /** @@ -1476,20 +1484,36 @@ private void checkLabel(final Label label, final boolean checkVisited, final Str if (checkVisited && labelInsnIndices.get(label) == null) { throw new IllegalArgumentException(INVALID + message + " (must be visited first)"); } + referencedLabels.add(label); } static class MethodWriterWrapper extends MethodVisitor { + /** The class version number. */ + private final int version; + private final ClassWriter owner; - MethodWriterWrapper(final int api, final ClassWriter owner, final MethodVisitor methodWriter) { + MethodWriterWrapper( + final int api, + final int version, + final ClassWriter owner, + final MethodVisitor methodWriter) { super(api, methodWriter); + this.version = version; this.owner = owner; } boolean computesMaxs() { return owner.hasFlags(ClassWriter.COMPUTE_MAXS) || owner.hasFlags(ClassWriter.COMPUTE_FRAMES); } + + boolean computesFrames() { + return owner.hasFlags(ClassWriter.COMPUTE_FRAMES); + } + + boolean requiresFrames() { + return (version & 0xFFFF) >= Opcodes.V1_7; + } } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckModuleAdapter.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckModuleAdapter.java index b84545e3a5b..de94a1d32dd 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckModuleAdapter.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckModuleAdapter.java @@ -242,4 +242,3 @@ void checkNameNotAlreadyDeclared(final String name) { } } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckRecordComponentAdapter.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckRecordComponentAdapter.java index 98cbb9c4e42..850f1c8dc3e 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckRecordComponentAdapter.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckRecordComponentAdapter.java @@ -151,4 +151,3 @@ private void checkVisitEndNotCalled() { } } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckSignatureAdapter.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckSignatureAdapter.java index 5da63a1d551..19a3998f0a2 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckSignatureAdapter.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckSignatureAdapter.java @@ -389,4 +389,3 @@ private void checkIdentifier(final String name, final String message) { } } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/Printer.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/Printer.java index 53ec0ab6cb2..00378e8dcce 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/Printer.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/Printer.java @@ -370,15 +370,14 @@ protected Printer(final int api) { * and the major version in the 16 least significant bits. * @param access the class's access flags (see {@link Opcodes}). This parameter also indicates if * the class is deprecated. - * @param name the internal name of the class (see {@link - * jdk.internal.org.objectweb.asm.Type#getInternalName()}). + * @param name the internal name of the class (see {@link Type#getInternalName()}). * @param signature the signature of this class. May be {@literal null} if the class is not a * generic one, and does not extend or implement generic classes or interfaces. - * @param superName the internal of name of the super class (see {@link - * jdk.internal.org.objectweb.asm.Type#getInternalName()}). For interfaces, the super class is {@link - * Object}. May be {@literal null}, but only for the {@link Object} class. + * @param superName the internal of name of the super class (see {@link Type#getInternalName()}). + * For interfaces, the super class is {@link Object}. May be {@literal null}, but only for the + * {@link Object} class. * @param interfaces the internal names of the class's interfaces (see {@link - * jdk.internal.org.objectweb.asm.Type#getInternalName()}). May be {@literal null}. + * Type#getInternalName()}). May be {@literal null}. */ public abstract void visit( int version, @@ -419,7 +418,8 @@ public Printer visitModule(final String name, final int access, final String ver * implicitly its own nest, so it's invalid to call this method with the visited class name as * argument. * - * @param nestHost the internal name of the host class of the nest. + * @param nestHost the internal name of the host class of the nest (see {@link + * Type#getInternalName()}). */ public void visitNestHost(final String nestHost) { throw new UnsupportedOperationException(UNSUPPORTED_OPERATION); @@ -428,7 +428,8 @@ public void visitNestHost(final String nestHost) { /** * Class outer class. See {@link jdk.internal.org.objectweb.asm.ClassVisitor#visitOuterClass}. * - * @param owner internal name of the enclosing class of the class. + * @param owner internal name of the enclosing class of the class (see {@link + * Type#getInternalName()}). * @param name the name of the method that contains the class, or {@literal null} if the class is * not enclosed in a method of its enclosing class. * @param descriptor the descriptor of the method that contains the class, or {@literal null} if @@ -449,10 +450,9 @@ public void visitNestHost(final String nestHost) { * Class type annotation. See {@link jdk.internal.org.objectweb.asm.ClassVisitor#visitTypeAnnotation}. * * @param typeRef a reference to the annotated type. The sort of this type reference must be - * {@link jdk.internal.org.objectweb.asm.TypeReference#CLASS_TYPE_PARAMETER}, {@link - * jdk.internal.org.objectweb.asm.TypeReference#CLASS_TYPE_PARAMETER_BOUND} or {@link - * jdk.internal.org.objectweb.asm.TypeReference#CLASS_EXTENDS}. See {@link - * jdk.internal.org.objectweb.asm.TypeReference}. + * {@link TypeReference#CLASS_TYPE_PARAMETER}, {@link + * TypeReference#CLASS_TYPE_PARAMETER_BOUND} or {@link TypeReference#CLASS_EXTENDS}. See + * {@link TypeReference}. * @param typePath the path to the annotated type argument, wildcard bound, array element type, or * static inner type within 'typeRef'. May be {@literal null} if the annotation targets * 'typeRef' as a whole. @@ -479,7 +479,7 @@ public Printer visitClassTypeAnnotation( * the visited class is the host of a nest. A nest host is implicitly a member of its own nest, so * it's invalid to call this method with the visited class name as argument. * - * @param nestMember the internal name of a nest member. + * @param nestMember the internal name of a nest member (see {@link Type#getInternalName()}). */ public void visitNestMember(final String nestMember) { throw new UnsupportedOperationException(UNSUPPORTED_OPERATION); @@ -489,7 +489,8 @@ public void visitNestMember(final String nestMember) { * Visits a permitted subclasses. A permitted subclass is one of the allowed subclasses of the * current class. See {@link jdk.internal.org.objectweb.asm.ClassVisitor#visitPermittedSubclass(String)}. * - * @param permittedSubclass the internal name of a permitted subclass. + * @param permittedSubclass the internal name of a permitted subclass (see {@link + * Type#getInternalName()}). */ public void visitPermittedSubclass(final String permittedSubclass) { throw new UnsupportedOperationException(UNSUPPORTED_OPERATION); @@ -498,10 +499,9 @@ public void visitPermittedSubclass(final String permittedSubclass) { /** * Class inner name. See {@link jdk.internal.org.objectweb.asm.ClassVisitor#visitInnerClass}. * - * @param name the internal name of an inner class (see {@link - * jdk.internal.org.objectweb.asm.Type#getInternalName()}). + * @param name the internal name of an inner class (see {@link Type#getInternalName()}). * @param outerName the internal name of the class to which the inner class belongs (see {@link - * jdk.internal.org.objectweb.asm.Type#getInternalName()}). May be {@literal null} for not member classes. + * Type#getInternalName()}). May be {@literal null} for not member classes. * @param innerName the (simple) name of the inner class inside its enclosing class. May be * {@literal null} for anonymous inner classes. * @param access the access flags of the inner class as originally declared in the enclosing @@ -531,7 +531,7 @@ public Printer visitRecordComponent( * @param access the field's access flags (see {@link Opcodes}). This parameter also indicates if * the field is synthetic and/or deprecated. * @param name the field's name. - * @param descriptor the field's descriptor (see {@link jdk.internal.org.objectweb.asm.Type}). + * @param descriptor the field's descriptor (see {@link Type}). * @param signature the field's signature. May be {@literal null} if the field's type does not use * generic types. * @param value the field's initial value. This parameter, which may be {@literal null} if the @@ -551,11 +551,11 @@ public abstract Printer visitField( * @param access the method's access flags (see {@link Opcodes}). This parameter also indicates if * the method is synthetic and/or deprecated. * @param name the method's name. - * @param descriptor the method's descriptor (see {@link jdk.internal.org.objectweb.asm.Type}). + * @param descriptor the method's descriptor (see {@link Type}). * @param signature the method's signature. May be {@literal null} if the method parameters, * return type and exceptions do not use generic types. * @param exceptions the internal names of the method's exception classes (see {@link - * jdk.internal.org.objectweb.asm.Type#getInternalName()}). May be {@literal null}. + * Type#getInternalName()}). May be {@literal null}. * @return the printer. */ public abstract Printer visitMethod( @@ -571,7 +571,8 @@ public abstract Printer visitMethod( /** * Module main class. See {@link jdk.internal.org.objectweb.asm.ModuleVisitor#visitMainClass}. * - * @param mainClass the internal name of the main class of the current module. + * @param mainClass the internal name of the main class of the current module (see {@link + * Type#getInternalName()}). */ public void visitMainClass(final String mainClass) { throw new UnsupportedOperationException(UNSUPPORTED_OPERATION); @@ -580,7 +581,7 @@ public void visitMainClass(final String mainClass) { /** * Module package. See {@link jdk.internal.org.objectweb.asm.ModuleVisitor#visitPackage}. * - * @param packaze the internal name of a package. + * @param packaze the internal name of a package (see {@link Type#getInternalName()}). */ public void visitPackage(final String packaze) { throw new UnsupportedOperationException(UNSUPPORTED_OPERATION); @@ -601,7 +602,7 @@ public void visitRequire(final String module, final int access, final String ver /** * Module export. See {@link jdk.internal.org.objectweb.asm.ModuleVisitor#visitExport}. * - * @param packaze the internal name of the exported package. + * @param packaze the internal name of the exported package (see {@link Type#getInternalName()}). * @param access the access flag of the exported package, valid values are among {@code * ACC_SYNTHETIC} and {@code ACC_MANDATED}. * @param modules the fully qualified names (using dots) of the modules that can access the public @@ -614,7 +615,7 @@ public void visitExport(final String packaze, final int access, final String... /** * Module open. See {@link jdk.internal.org.objectweb.asm.ModuleVisitor#visitOpen}. * - * @param packaze the internal name of the opened package. + * @param packaze the internal name of the opened package (see {@link Type#getInternalName()}). * @param access the access flag of the opened package, valid values are among {@code * ACC_SYNTHETIC} and {@code ACC_MANDATED}. * @param modules the fully qualified names (using dots) of the modules that can use deep @@ -627,7 +628,7 @@ public void visitOpen(final String packaze, final int access, final String... mo /** * Module use. See {@link jdk.internal.org.objectweb.asm.ModuleVisitor#visitUse}. * - * @param service the internal name of the service. + * @param service the internal name of the service (see {@link Type#getInternalName()}). */ public void visitUse(final String service) { throw new UnsupportedOperationException(UNSUPPORTED_OPERATION); @@ -636,7 +637,7 @@ public void visitUse(final String service) { /** * Module provide. See {@link jdk.internal.org.objectweb.asm.ModuleVisitor#visitProvide}. * - * @param service the internal name of the service. + * @param service the internal name of the service (see {@link Type#getInternalName()}). * @param providers the internal names of the implementations of the service (there is at least * one provider). */ @@ -659,10 +660,10 @@ public void visitModuleEnd() { * @param name the value name. * @param value the actual value, whose type must be {@link Byte}, {@link Boolean}, {@link * Character}, {@link Short}, {@link Integer} , {@link Long}, {@link Float}, {@link Double}, - * {@link String} or {@link jdk.internal.org.objectweb.asm.Type} of {@link jdk.internal.org.objectweb.asm.Type#OBJECT} - * or {@link jdk.internal.org.objectweb.asm.Type#ARRAY} sort. This value can also be an array of byte, - * boolean, short, char, int, long, float or double values (this is equivalent to using {@link - * #visitArray} and visiting each array element in turn, but is more convenient). + * {@link String} or {@link Type} of {@link Type#OBJECT} or {@link Type#ARRAY} sort. This + * value can also be an array of byte, boolean, short, char, int, long, float or double values + * (this is equivalent to using {@link #visitArray} and visiting each array element in turn, + * but is more convenient). */ // DontCheck(OverloadMethodsDeclarationOrder): overloads are semantically different. public abstract void visit(String name, Object value); @@ -770,7 +771,7 @@ public void visitRecordComponentEnd() { * Field type annotation. See {@link jdk.internal.org.objectweb.asm.FieldVisitor#visitTypeAnnotation}. * * @param typeRef a reference to the annotated type. The sort of this type reference must be - * {@link jdk.internal.org.objectweb.asm.TypeReference#FIELD}. See {@link jdk.internal.org.objectweb.asm.TypeReference}. + * {@link TypeReference#FIELD}. See {@link TypeReference}. * @param typePath the path to the annotated type argument, wildcard bound, array element type, or * static inner type within 'typeRef'. May be {@literal null} if the annotation targets * 'typeRef' as a whole. @@ -828,12 +829,10 @@ public void visitParameter(final String name, final int access) { * Method type annotation. See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitTypeAnnotation}. * * @param typeRef a reference to the annotated type. The sort of this type reference must be - * {@link jdk.internal.org.objectweb.asm.TypeReference#METHOD_TYPE_PARAMETER}, {@link - * jdk.internal.org.objectweb.asm.TypeReference#METHOD_TYPE_PARAMETER_BOUND}, {@link - * jdk.internal.org.objectweb.asm.TypeReference#METHOD_RETURN}, {@link - * jdk.internal.org.objectweb.asm.TypeReference#METHOD_RECEIVER}, {@link - * jdk.internal.org.objectweb.asm.TypeReference#METHOD_FORMAL_PARAMETER} or {@link - * jdk.internal.org.objectweb.asm.TypeReference#THROWS}. See {@link jdk.internal.org.objectweb.asm.TypeReference}. + * {@link TypeReference#METHOD_TYPE_PARAMETER}, {@link + * TypeReference#METHOD_TYPE_PARAMETER_BOUND}, {@link TypeReference#METHOD_RETURN}, {@link + * TypeReference#METHOD_RECEIVER}, {@link TypeReference#METHOD_FORMAL_PARAMETER} or {@link + * TypeReference#THROWS}. See {@link TypeReference}. * @param typePath the path to the annotated type argument, wildcard bound, array element type, or * static inner type within 'typeRef'. May be {@literal null} if the annotation targets * 'typeRef' as a whole. @@ -902,9 +901,9 @@ public abstract Printer visitParameterAnnotation( * types are represented by {@link Opcodes#TOP}, {@link Opcodes#INTEGER}, {@link * Opcodes#FLOAT}, {@link Opcodes#LONG}, {@link Opcodes#DOUBLE}, {@link Opcodes#NULL} or * {@link Opcodes#UNINITIALIZED_THIS} (long and double are represented by a single element). - * Reference types are represented by String objects (representing internal names), and - * uninitialized types by Label objects (this label designates the NEW instruction that - * created this uninitialized value). + * Reference types are represented by String objects (representing internal names, see {@link + * Type#getInternalName()}), and uninitialized types by Label objects (this label designates + * the NEW instruction that created this uninitialized value). * @param numStack the number of operand stack elements in the visited frame. * @param stack the operand stack types in this frame. This array must not be modified. Its * content has the same format as the "local" array. @@ -960,7 +959,7 @@ public abstract void visitFrame( * @param opcode the opcode of the type instruction to be visited. This opcode is either NEW, * ANEWARRAY, CHECKCAST or INSTANCEOF. * @param type the operand of the instruction to be visited. This operand must be the internal - * name of an object or array class (see {@link jdk.internal.org.objectweb.asm.Type#getInternalName()}). + * name of an object or array class (see {@link Type#getInternalName()}). */ public abstract void visitTypeInsn(int opcode, String type); @@ -969,10 +968,9 @@ public abstract void visitFrame( * * @param opcode the opcode of the type instruction to be visited. This opcode is either * GETSTATIC, PUTSTATIC, GETFIELD or PUTFIELD. - * @param owner the internal name of the field's owner class (see {@link - * jdk.internal.org.objectweb.asm.Type#getInternalName()}). + * @param owner the internal name of the field's owner class (see {@link Type#getInternalName()}). * @param name the field's name. - * @param descriptor the field's descriptor (see {@link jdk.internal.org.objectweb.asm.Type}). + * @param descriptor the field's descriptor (see {@link Type}). */ public abstract void visitFieldInsn(int opcode, String owner, String name, String descriptor); @@ -982,9 +980,9 @@ public abstract void visitFrame( * @param opcode the opcode of the type instruction to be visited. This opcode is either * INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or INVOKEINTERFACE. * @param owner the internal name of the method's owner class (see {@link - * jdk.internal.org.objectweb.asm.Type#getInternalName()}). + * Type#getInternalName()}). * @param name the method's name. - * @param descriptor the method's descriptor (see {@link jdk.internal.org.objectweb.asm.Type}). + * @param descriptor the method's descriptor (see {@link Type}). * @deprecated use {@link #visitMethodInsn(int, String, String, String, boolean)} instead. */ @Deprecated @@ -1002,9 +1000,9 @@ public void visitMethodInsn( * @param opcode the opcode of the type instruction to be visited. This opcode is either * INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or INVOKEINTERFACE. * @param owner the internal name of the method's owner class (see {@link - * jdk.internal.org.objectweb.asm.Type#getInternalName()}). + * Type#getInternalName()}). * @param name the method's name. - * @param descriptor the method's descriptor (see {@link jdk.internal.org.objectweb.asm.Type}). + * @param descriptor the method's descriptor (see {@link Type}). * @param isInterface if the method's owner class is an interface. */ public void visitMethodInsn( @@ -1020,12 +1018,12 @@ public void visitMethodInsn( * Method instruction. See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitInvokeDynamicInsn}. * * @param name the method's name. - * @param descriptor the method's descriptor (see {@link jdk.internal.org.objectweb.asm.Type}). + * @param descriptor the method's descriptor (see {@link Type}). * @param bootstrapMethodHandle the bootstrap method. * @param bootstrapMethodArguments the bootstrap method constant arguments. Each argument must be * an {@link Integer}, {@link Float}, {@link Long}, {@link Double}, {@link String}, {@link - * jdk.internal.org.objectweb.asm.Type} or {@link Handle} value. This method is allowed to modify the - * content of the array so a caller should expect that this array may change. + * Type} or {@link Handle} value. This method is allowed to modify the content of the array so + * a caller should expect that this array may change. */ public abstract void visitInvokeDynamicInsn( String name, @@ -1095,7 +1093,7 @@ public abstract void visitInvokeDynamicInsn( /** * Method instruction. See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitMultiANewArrayInsn}. * - * @param descriptor an array type descriptor (see {@link jdk.internal.org.objectweb.asm.Type}). + * @param descriptor an array type descriptor (see {@link Type}). * @param numDimensions the number of dimensions of the array to allocate. */ public abstract void visitMultiANewArrayInsn(String descriptor, int numDimensions); @@ -1104,16 +1102,12 @@ public abstract void visitInvokeDynamicInsn( * Instruction type annotation. See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitInsnAnnotation}. * * @param typeRef a reference to the annotated type. The sort of this type reference must be - * {@link jdk.internal.org.objectweb.asm.TypeReference#INSTANCEOF}, {@link - * jdk.internal.org.objectweb.asm.TypeReference#NEW}, {@link - * jdk.internal.org.objectweb.asm.TypeReference#CONSTRUCTOR_REFERENCE}, {@link - * jdk.internal.org.objectweb.asm.TypeReference#METHOD_REFERENCE}, {@link - * jdk.internal.org.objectweb.asm.TypeReference#CAST}, {@link - * jdk.internal.org.objectweb.asm.TypeReference#CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT}, {@link - * jdk.internal.org.objectweb.asm.TypeReference#METHOD_INVOCATION_TYPE_ARGUMENT}, {@link - * jdk.internal.org.objectweb.asm.TypeReference#CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT}, or {@link - * jdk.internal.org.objectweb.asm.TypeReference#METHOD_REFERENCE_TYPE_ARGUMENT}. See {@link - * jdk.internal.org.objectweb.asm.TypeReference}. + * {@link TypeReference#INSTANCEOF}, {@link TypeReference#NEW}, {@link + * TypeReference#CONSTRUCTOR_REFERENCE}, {@link TypeReference#METHOD_REFERENCE}, {@link + * TypeReference#CAST}, {@link TypeReference#CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT}, {@link + * TypeReference#METHOD_INVOCATION_TYPE_ARGUMENT}, {@link + * TypeReference#CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT}, or {@link + * TypeReference#METHOD_REFERENCE_TYPE_ARGUMENT}. See {@link TypeReference}. * @param typePath the path to the annotated type argument, wildcard bound, array element type, or * static inner type within 'typeRef'. May be {@literal null} if the annotation targets * 'typeRef' as a whole. @@ -1132,8 +1126,9 @@ public Printer visitInsnAnnotation( * @param start the beginning of the exception handler's scope (inclusive). * @param end the end of the exception handler's scope (exclusive). * @param handler the beginning of the exception handler's code. - * @param type the internal name of the type of exceptions handled by the handler, or {@literal - * null} to catch any exceptions (for "finally" blocks). + * @param type the internal name of the type of exceptions handled by the handler (see {@link + * Type#getInternalName()}), or {@literal null} to catch any exceptions (for "finally" + * blocks). */ public abstract void visitTryCatchBlock(Label start, Label end, Label handler, String type); @@ -1142,8 +1137,7 @@ public Printer visitInsnAnnotation( * jdk.internal.org.objectweb.asm.MethodVisitor#visitTryCatchAnnotation}. * * @param typeRef a reference to the annotated type. The sort of this type reference must be - * {@link jdk.internal.org.objectweb.asm.TypeReference#EXCEPTION_PARAMETER}. See {@link - * jdk.internal.org.objectweb.asm.TypeReference}. + * {@link TypeReference#EXCEPTION_PARAMETER}. See {@link TypeReference}. * @param typePath the path to the annotated type argument, wildcard bound, array element type, or * static inner type within 'typeRef'. May be {@literal null} if the annotation targets * 'typeRef' as a whole. @@ -1176,9 +1170,8 @@ public abstract void visitLocalVariable( * jdk.internal.org.objectweb.asm.MethodVisitor#visitTryCatchAnnotation}. * * @param typeRef a reference to the annotated type. The sort of this type reference must be - * {@link jdk.internal.org.objectweb.asm.TypeReference#LOCAL_VARIABLE} or {@link - * jdk.internal.org.objectweb.asm.TypeReference#RESOURCE_VARIABLE}. See {@link - * jdk.internal.org.objectweb.asm.TypeReference}. + * {@link TypeReference#LOCAL_VARIABLE} or {@link TypeReference#RESOURCE_VARIABLE}. See {@link + * TypeReference}. * @param typePath the path to the annotated type argument, wildcard bound, array element type, or * static inner type within 'typeRef'. May be {@literal null} if the annotation targets * 'typeRef' as a whole. @@ -1347,4 +1340,3 @@ static void main( } } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/Textifier.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/Textifier.java index e6006a3cb48..fe8a9c8bf31 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/Textifier.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/Textifier.java @@ -87,7 +87,9 @@ public class Textifier extends Printer { "Prints a disassembled view of the given class.\n" + "Usage: Textifier [-nodebug] "; - /** The type of internal names. See {@link #appendDescriptor}. */ + /** + * The type of internal names (see {@link Type#getInternalName()}). See {@link #appendDescriptor}. + */ public static final int INTERNAL_NAME = 0; /** The type of field descriptors. See {@link #appendDescriptor}. */ @@ -1355,7 +1357,8 @@ private void appendRawAccess(final int accessFlags) { * @param type the type of 'value'. Must be one of {@link #INTERNAL_NAME}, {@link * #FIELD_DESCRIPTOR}, {@link #FIELD_SIGNATURE}, {@link #METHOD_DESCRIPTOR}, {@link * #METHOD_SIGNATURE}, {@link #CLASS_SIGNATURE} or {@link #HANDLE_DESCRIPTOR}. - * @param value an internal name, type descriptor or a type signature. May be {@literal null}. + * @param value an internal name (see {@link Type#getInternalName()}), type descriptor or a type + * signature. May be {@literal null}. */ protected void appendDescriptor(final int type, final String value) { if (type == CLASS_SIGNATURE || type == FIELD_SIGNATURE || type == METHOD_SIGNATURE) { @@ -1631,4 +1634,3 @@ protected Textifier createTextifier() { return new Textifier(api); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/TextifierSupport.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/TextifierSupport.java index edc3bf0351b..4ce8fe8031c 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/TextifierSupport.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/TextifierSupport.java @@ -77,4 +77,3 @@ public interface TextifierSupport { */ void textify(StringBuilder outputBuilder, Map labelNames); } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/TraceAnnotationVisitor.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/TraceAnnotationVisitor.java index 9133b45c563..f487c69ca64 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/TraceAnnotationVisitor.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/TraceAnnotationVisitor.java @@ -123,4 +123,3 @@ public void visitEnd() { super.visitEnd(); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/TraceClassVisitor.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/TraceClassVisitor.java index eade2bc9c47..a6e58402db9 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/TraceClassVisitor.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/TraceClassVisitor.java @@ -274,4 +274,3 @@ public void visitEnd() { super.visitEnd(); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/TraceFieldVisitor.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/TraceFieldVisitor.java index 62cc5939f11..1dd448c640f 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/TraceFieldVisitor.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/TraceFieldVisitor.java @@ -123,4 +123,3 @@ public void visitEnd() { super.visitEnd(); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/TraceMethodVisitor.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/TraceMethodVisitor.java index 6d8767ce4dd..06f96819d3e 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/TraceMethodVisitor.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/TraceMethodVisitor.java @@ -342,4 +342,3 @@ public void visitEnd() { super.visitEnd(); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/TraceRecordComponentVisitor.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/TraceRecordComponentVisitor.java index 2069f299d1a..e40ce8c79cd 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/TraceRecordComponentVisitor.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/TraceRecordComponentVisitor.java @@ -126,4 +126,3 @@ public void visitEnd() { super.visitEnd(); } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/TraceSignatureVisitor.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/TraceSignatureVisitor.java index a7ba0fb6a0f..ba8da75fdc4 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/TraceSignatureVisitor.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/TraceSignatureVisitor.java @@ -374,4 +374,3 @@ private void endType() { } } } - diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/version.txt b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/version.txt index d4db13119b1..2ffbbcafa5d 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/version.txt +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/version.txt @@ -1,2 +1,2 @@ -ASM_9_3 +ASM_9_6 origin http://gitlab.ow2.org/asm/asm.git (fetch) diff --git a/src/java.base/share/classes/sun/invoke/util/Wrapper.java b/src/java.base/share/classes/sun/invoke/util/Wrapper.java index bb3e617fcc3..76aede09487 100644 --- a/src/java.base/share/classes/sun/invoke/util/Wrapper.java +++ b/src/java.base/share/classes/sun/invoke/util/Wrapper.java @@ -25,23 +25,25 @@ package sun.invoke.util; +import java.util.Map; +import static sun.invoke.util.Wrapper.NumericClasses.*; import jdk.internal.vm.annotation.DontInline; public enum Wrapper { - // wrapperType simple primitiveType simple char emptyArray format - BOOLEAN( Boolean.class, "Boolean", boolean.class, "boolean", 'Z', new boolean[0], Format.unsigned( 1)), + // wrapperType simple primitiveType simple char emptyArray format numericClass superClass + BOOLEAN( Boolean.class, "Boolean", boolean.class, "boolean", 'Z', new boolean[0], Format.unsigned( 1), 0, 0), // These must be in the order defined for widening primitive conversions in JLS 5.1.2 // Avoid boxing integral types here to defer initialization of internal caches - BYTE ( Byte.class, "Byte", byte.class, "byte", 'B', new byte[0], Format.signed( 8)), - SHORT ( Short.class, "Short", short.class, "short", 'S', new short[0], Format.signed( 16)), - CHAR (Character.class, "Character", char.class, "char", 'C', new char[0], Format.unsigned(16)), - INT ( Integer.class, "Integer", int.class, "int", 'I', new int[0], Format.signed( 32)), - LONG ( Long.class, "Long", long.class, "long", 'J', new long[0], Format.signed( 64)), - FLOAT ( Float.class, "Float", float.class, "float", 'F', new float[0], Format.floating(32)), - DOUBLE ( Double.class, "Double", double.class, "double", 'D', new double[0], Format.floating(64)), - OBJECT ( Object.class, "Object", Object.class, "Object", 'L', new Object[0], Format.other( 1)), + BYTE ( Byte.class, "Byte", byte.class, "byte", 'B', new byte[0], Format.signed( 8), BYTE_CLASS, BYTE_SUPERCLASSES), + SHORT ( Short.class, "Short", short.class, "short", 'S', new short[0], Format.signed( 16), SHORT_CLASS, SHORT_SUPERCLASSES), + CHAR (Character.class, "Character", char.class, "char", 'C', new char[0], Format.unsigned(16), CHAR_CLASS, CHAR_SUPERCLASSES), + INT ( Integer.class, "Integer", int.class, "int", 'I', new int[0], Format.signed( 32), INT_CLASS, INT_SUPERCLASSES), + LONG ( Long.class, "Long", long.class, "long", 'J', new long[0], Format.signed( 64), LONG_CLASS, LONG_SUPERCLASSES), + FLOAT ( Float.class, "Float", float.class, "float", 'F', new float[0], Format.floating(32), FLOAT_CLASS, FLOAT_SUPERCLASSES), + DOUBLE ( Double.class, "Double", double.class, "double", 'D', new double[0], Format.floating(64), DOUBLE_CLASS, DOUBLE_CLASS), + OBJECT ( Object.class, "Object", Object.class, "Object", 'L', new Object[0], Format.other( 1), 0, 0), // VOID must be the last type, since it is "assignable" from any other type: - VOID ( Void.class, "Void", void.class, "void", 'V', null, Format.other( 0)), + VOID ( Void.class, "Void", void.class, "void", 'V', null, Format.other( 0), 0, 0), ; public static final int COUNT = 10; @@ -52,16 +54,20 @@ public enum Wrapper { private final String basicTypeString; private final Object emptyArray; private final int format; + private final int numericClass; + private final int superClasses; private final String wrapperSimpleName; private final String primitiveSimpleName; - private Wrapper(Class wtype, String wtypeName, Class ptype, String ptypeName, char tchar, Object emptyArray, int format) { + private Wrapper(Class wtype, String wtypeName, Class ptype, String ptypeName, char tchar, Object emptyArray, int format, int numericClass, int superClasses) { this.wrapperType = wtype; this.primitiveType = ptype; this.basicTypeChar = tchar; this.basicTypeString = String.valueOf(this.basicTypeChar); this.emptyArray = emptyArray; this.format = format; + this.numericClass = numericClass; + this.superClasses = superClasses; this.wrapperSimpleName = wtypeName; this.primitiveSimpleName = ptypeName; } @@ -424,6 +430,11 @@ public static boolean isWrapperType(Class type) { return findWrapperType(type) != null; } + /** Query: Is the given type a wrapper, such as {@code Integer}, {@code Byte}, etc excluding {@code Void} and {@code Object}? */ + public static boolean isWrapperNumericOrBooleanType(Class type) { + return isWrapperType(type) && findWrapperType(type) != VOID && findWrapperType(type) != OBJECT; + } + /** Query: Is the given type a primitive, such as {@code int} or {@code void}? */ public static boolean isPrimitiveType(Class type) { return type.isPrimitive(); @@ -628,4 +639,34 @@ public void copyArrayBoxing(Object a, int apos, Object[] values, int vpos, int l values[i+vpos] = value; } } + + // NumericClasses should be in sync with com.sun.tools.javac.code.TypeTag.NumericClasses + public static class NumericClasses { + public static final int BYTE_CLASS = 1; + public static final int CHAR_CLASS = 2; + public static final int SHORT_CLASS = 4; + public static final int INT_CLASS = 8; + public static final int LONG_CLASS = 16; + public static final int FLOAT_CLASS = 32; + public static final int DOUBLE_CLASS = 64; + + static final int BYTE_SUPERCLASSES = BYTE_CLASS | SHORT_CLASS | INT_CLASS | + LONG_CLASS | FLOAT_CLASS | DOUBLE_CLASS; + + static final int CHAR_SUPERCLASSES = CHAR_CLASS | INT_CLASS | + LONG_CLASS | FLOAT_CLASS | DOUBLE_CLASS; + + static final int SHORT_SUPERCLASSES = SHORT_CLASS | INT_CLASS | + LONG_CLASS | FLOAT_CLASS | DOUBLE_CLASS; + + static final int INT_SUPERCLASSES = INT_CLASS | LONG_CLASS | FLOAT_CLASS | DOUBLE_CLASS; + + static final int LONG_SUPERCLASSES = LONG_CLASS | FLOAT_CLASS | DOUBLE_CLASS; + + static final int FLOAT_SUPERCLASSES = FLOAT_CLASS | DOUBLE_CLASS; + } + + public boolean isStrictSubRangeOf(Wrapper target) { + return (this.superClasses & target.numericClass) != 0 && this != target; + } } diff --git a/src/java.base/share/legal/asm.md b/src/java.base/share/legal/asm.md index 0a5d1c9b151..40edc652e7c 100644 --- a/src/java.base/share/legal/asm.md +++ b/src/java.base/share/legal/asm.md @@ -1,4 +1,4 @@ -## ASM Bytecode Manipulation Framework v9.3 +## ASM Bytecode Manipulation Framework v9.6 ### ASM License
    diff --git a/src/java.base/share/native/libzip/zlib/ChangeLog b/src/java.base/share/native/libzip/zlib/ChangeLog
    index 8707988ac18..b801a1031ec 100644
    --- a/src/java.base/share/native/libzip/zlib/ChangeLog
    +++ b/src/java.base/share/native/libzip/zlib/ChangeLog
    @@ -1,6 +1,16 @@
     
                     ChangeLog file for zlib
     
    +Changes in 1.3.1 (22 Jan 2024)
    +- Reject overflows of zip header fields in minizip
    +- Fix bug in inflateSync() for data held in bit buffer
    +- Add LIT_MEM define to use more memory for a small deflate speedup
    +- Fix decision on the emission of Zip64 end records in minizip
    +- Add bounds checking to ERR_MSG() macro, used by zError()
    +- Neutralize zip file traversal attacks in miniunz
    +- Fix a bug in ZLIB_DEBUG compiles in check_match()
    +- Various portability and appearance improvements
    +
     Changes in 1.3 (18 Aug 2023)
     - Remove K&R function definitions and zlib2ansi
     - Fix bug in deflateBound() for level 0 and memLevel 9
    diff --git a/src/java.base/share/native/libzip/zlib/README b/src/java.base/share/native/libzip/zlib/README
    index e02fc5aa206..c5f917540b6 100644
    --- a/src/java.base/share/native/libzip/zlib/README
    +++ b/src/java.base/share/native/libzip/zlib/README
    @@ -1,6 +1,6 @@
     ZLIB DATA COMPRESSION LIBRARY
     
    -zlib 1.3 is a general purpose data compression library.  All the code is
    +zlib 1.3.1 is a general purpose data compression library.  All the code is
     thread safe.  The data format used by the zlib library is described by RFCs
     (Request for Comments) 1950 to 1952 in the files
     http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and
    @@ -31,7 +31,7 @@ Mark Nelson  wrote an article about zlib for the Jan.  1997
     issue of Dr.  Dobb's Journal; a copy of the article is available at
     https://marknelson.us/posts/1997/01/01/zlib-engine.html .
     
    -The changes made in version 1.3 are documented in the file ChangeLog.
    +The changes made in version 1.3.1 are documented in the file ChangeLog.
     
     Unsupported third party contributions are provided in directory contrib/ .
     
    @@ -83,7 +83,7 @@ Acknowledgments:
     
     Copyright notice:
     
    - (C) 1995-2023 Jean-loup Gailly and Mark Adler
    + (C) 1995-2024 Jean-loup Gailly and Mark Adler
     
       This software is provided 'as-is', without any express or implied
       warranty.  In no event will the authors be held liable for any damages
    diff --git a/src/java.base/share/native/libzip/zlib/deflate.c b/src/java.base/share/native/libzip/zlib/deflate.c
    index c701ce2836b..57fc6802bb8 100644
    --- a/src/java.base/share/native/libzip/zlib/deflate.c
    +++ b/src/java.base/share/native/libzip/zlib/deflate.c
    @@ -23,7 +23,7 @@
      */
     
     /* deflate.c -- compress data using the deflation algorithm
    - * Copyright (C) 1995-2023 Jean-loup Gailly and Mark Adler
    + * Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler
      * For conditions of distribution and use, see copyright notice in zlib.h
      */
     
    @@ -76,7 +76,7 @@
     #include "deflate.h"
     
     const char deflate_copyright[] =
    -   " deflate 1.3 Copyright 1995-2023 Jean-loup Gailly and Mark Adler ";
    +   " deflate 1.3.1 Copyright 1995-2024 Jean-loup Gailly and Mark Adler ";
     /*
       If you use the zlib library in a product, an acknowledgment is welcome
       in the documentation of your product. If for some reason you cannot
    @@ -517,7 +517,7 @@ int ZEXPORT deflateInit2_(z_streamp strm, int level, int method,
          * symbols from which it is being constructed.
          */
     
    -    s->pending_buf = (uchf *) ZALLOC(strm, s->lit_bufsize, 4);
    +    s->pending_buf = (uchf *) ZALLOC(strm, s->lit_bufsize, LIT_BUFS);
         s->pending_buf_size = (ulg)s->lit_bufsize * 4;
     
         if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
    @@ -527,8 +527,14 @@ int ZEXPORT deflateInit2_(z_streamp strm, int level, int method,
             deflateEnd (strm);
             return Z_MEM_ERROR;
         }
    +#ifdef LIT_MEM
    +    s->d_buf = (ushf *)(s->pending_buf + (s->lit_bufsize << 1));
    +    s->l_buf = s->pending_buf + (s->lit_bufsize << 2);
    +    s->sym_end = s->lit_bufsize - 1;
    +#else
         s->sym_buf = s->pending_buf + s->lit_bufsize;
         s->sym_end = (s->lit_bufsize - 1) * 3;
    +#endif
         /* We avoid equality with lit_bufsize*3 because of wraparound at 64K
          * on 16 bit machines and because stored blocks are restricted to
          * 64K-1 bytes.
    @@ -744,9 +750,15 @@ int ZEXPORT deflatePrime(z_streamp strm, int bits, int value) {
     
         if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
         s = strm->state;
    +#ifdef LIT_MEM
    +    if (bits < 0 || bits > 16 ||
    +        (uchf *)s->d_buf < s->pending_out + ((Buf_size + 7) >> 3))
    +        return Z_BUF_ERROR;
    +#else
         if (bits < 0 || bits > 16 ||
             s->sym_buf < s->pending_out + ((Buf_size + 7) >> 3))
             return Z_BUF_ERROR;
    +#endif
         do {
             put = Buf_size - s->bi_valid;
             if (put > bits)
    @@ -1318,7 +1330,7 @@ int ZEXPORT deflateCopy(z_streamp dest, z_streamp source) {
         ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
         ds->prev   = (Posf *)  ZALLOC(dest, ds->w_size, sizeof(Pos));
         ds->head   = (Posf *)  ZALLOC(dest, ds->hash_size, sizeof(Pos));
    -    ds->pending_buf = (uchf *) ZALLOC(dest, ds->lit_bufsize, 4);
    +    ds->pending_buf = (uchf *) ZALLOC(dest, ds->lit_bufsize, LIT_BUFS);
     
         if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
             ds->pending_buf == Z_NULL) {
    @@ -1329,10 +1341,15 @@ int ZEXPORT deflateCopy(z_streamp dest, z_streamp source) {
         zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
         zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos));
         zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos));
    -    zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);
    +    zmemcpy(ds->pending_buf, ss->pending_buf, ds->lit_bufsize * LIT_BUFS);
     
         ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
    +#ifdef LIT_MEM
    +    ds->d_buf = (ushf *)(ds->pending_buf + (ds->lit_bufsize << 1));
    +    ds->l_buf = ds->pending_buf + (ds->lit_bufsize << 2);
    +#else
         ds->sym_buf = ds->pending_buf + ds->lit_bufsize;
    +#endif
     
         ds->l_desc.dyn_tree = ds->dyn_ltree;
         ds->d_desc.dyn_tree = ds->dyn_dtree;
    @@ -1563,13 +1580,21 @@ local uInt longest_match(deflate_state *s, IPos cur_match) {
      */
     local void check_match(deflate_state *s, IPos start, IPos match, int length) {
         /* check that the match is indeed a match */
    -    if (zmemcmp(s->window + match,
    -                s->window + start, length) != EQUAL) {
    -        fprintf(stderr, " start %u, match %u, length %d\n",
    -                start, match, length);
    +    Bytef *back = s->window + (int)match, *here = s->window + start;
    +    IPos len = length;
    +    if (match == (IPos)-1) {
    +        /* match starts one byte before the current window -- just compare the
    +           subsequent length-1 bytes */
    +        back++;
    +        here++;
    +        len--;
    +    }
    +    if (zmemcmp(back, here, len) != EQUAL) {
    +        fprintf(stderr, " start %u, match %d, length %d\n",
    +                start, (int)match, length);
             do {
    -            fprintf(stderr, "%c%c", s->window[match++], s->window[start++]);
    -        } while (--length != 0);
    +            fprintf(stderr, "(%02x %02x)", *back++, *here++);
    +        } while (--len != 0);
             z_error("invalid match");
         }
         if (z_verbose > 1) {
    diff --git a/src/java.base/share/native/libzip/zlib/deflate.h b/src/java.base/share/native/libzip/zlib/deflate.h
    index 3bba1be7476..830d46b8894 100644
    --- a/src/java.base/share/native/libzip/zlib/deflate.h
    +++ b/src/java.base/share/native/libzip/zlib/deflate.h
    @@ -23,7 +23,7 @@
      */
     
     /* deflate.h -- internal compression state
    - * Copyright (C) 1995-2018 Jean-loup Gailly
    + * Copyright (C) 1995-2024 Jean-loup Gailly
      * For conditions of distribution and use, see copyright notice in zlib.h
      */
     
    @@ -47,6 +47,10 @@
     #  define GZIP
     #endif
     
    +/* define LIT_MEM to slightly increase the speed of deflate (order 1% to 2%) at
    +   the cost of a larger memory footprint */
    +/* #define LIT_MEM */
    +
     /* ===========================================================================
      * Internal compression state.
      */
    @@ -241,7 +245,14 @@ typedef struct internal_state {
         /* Depth of each subtree used as tie breaker for trees of equal frequency
          */
     
    +#ifdef LIT_MEM
    +#   define LIT_BUFS 5
    +    ushf *d_buf;          /* buffer for distances */
    +    uchf *l_buf;          /* buffer for literals/lengths */
    +#else
    +#   define LIT_BUFS 4
         uchf *sym_buf;        /* buffer for distances and literals/lengths */
    +#endif
     
         uInt  lit_bufsize;
         /* Size of match buffer for literals/lengths.  There are 4 reasons for
    @@ -263,7 +274,7 @@ typedef struct internal_state {
          *   - I can't count above 4
          */
     
    -    uInt sym_next;      /* running index in sym_buf */
    +    uInt sym_next;      /* running index in symbol buffer */
         uInt sym_end;       /* symbol table full when sym_next reaches this */
     
         ulg opt_len;        /* bit length of current block with optimal trees */
    @@ -342,6 +353,25 @@ void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf,
       extern const uch ZLIB_INTERNAL _dist_code[];
     #endif
     
    +#ifdef LIT_MEM
    +# define _tr_tally_lit(s, c, flush) \
    +  { uch cc = (c); \
    +    s->d_buf[s->sym_next] = 0; \
    +    s->l_buf[s->sym_next++] = cc; \
    +    s->dyn_ltree[cc].Freq++; \
    +    flush = (s->sym_next == s->sym_end); \
    +   }
    +# define _tr_tally_dist(s, distance, length, flush) \
    +  { uch len = (uch)(length); \
    +    ush dist = (ush)(distance); \
    +    s->d_buf[s->sym_next] = dist; \
    +    s->l_buf[s->sym_next++] = len; \
    +    dist--; \
    +    s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
    +    s->dyn_dtree[d_code(dist)].Freq++; \
    +    flush = (s->sym_next == s->sym_end); \
    +  }
    +#else
     # define _tr_tally_lit(s, c, flush) \
       { uch cc = (c); \
         s->sym_buf[s->sym_next++] = 0; \
    @@ -361,6 +391,7 @@ void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf,
         s->dyn_dtree[d_code(dist)].Freq++; \
         flush = (s->sym_next == s->sym_end); \
       }
    +#endif
     #else
     # define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
     # define _tr_tally_dist(s, distance, length, flush) \
    diff --git a/src/java.base/share/native/libzip/zlib/gzguts.h b/src/java.base/share/native/libzip/zlib/gzguts.h
    index ec8655c67fc..8cce2c69d24 100644
    --- a/src/java.base/share/native/libzip/zlib/gzguts.h
    +++ b/src/java.base/share/native/libzip/zlib/gzguts.h
    @@ -23,7 +23,7 @@
      */
     
     /* gzguts.h -- zlib internal header definitions for gz* operations
    - * Copyright (C) 2004-2019 Mark Adler
    + * Copyright (C) 2004-2024 Mark Adler
      * For conditions of distribution and use, see copyright notice in zlib.h
      */
     
    @@ -234,9 +234,5 @@ char ZLIB_INTERNAL *gz_strwinerror(DWORD error);
     /* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t
        value -- needed when comparing unsigned to z_off64_t, which is signed
        (possible z_off64_t types off_t, off64_t, and long are all signed) */
    -#ifdef INT_MAX
    -#  define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX)
    -#else
     unsigned ZLIB_INTERNAL gz_intmax(void);
    -#  define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
    -#endif
    +#define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
    diff --git a/src/java.base/share/native/libzip/zlib/gzlib.c b/src/java.base/share/native/libzip/zlib/gzlib.c
    index 2900e459f62..0f4dfae64a0 100644
    --- a/src/java.base/share/native/libzip/zlib/gzlib.c
    +++ b/src/java.base/share/native/libzip/zlib/gzlib.c
    @@ -23,7 +23,7 @@
      */
     
     /* gzlib.c -- zlib functions common to reading and writing gzip files
    - * Copyright (C) 2004-2019 Mark Adler
    + * Copyright (C) 2004-2024 Mark Adler
      * For conditions of distribution and use, see copyright notice in zlib.h
      */
     
    @@ -587,20 +587,20 @@ void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg) {
     #endif
     }
     
    -#ifndef INT_MAX
     /* portably return maximum value for an int (when limits.h presumed not
        available) -- we need to do this to cover cases where 2's complement not
        used, since C standard permits 1's complement and sign-bit representations,
        otherwise we could just use ((unsigned)-1) >> 1 */
     unsigned ZLIB_INTERNAL gz_intmax(void) {
    -    unsigned p, q;
    -
    -    p = 1;
    +#ifdef INT_MAX
    +    return INT_MAX;
    +#else
    +    unsigned p = 1, q;
         do {
             q = p;
             p <<= 1;
             p++;
         } while (p > q);
         return q >> 1;
    -}
     #endif
    +}
    diff --git a/src/java.base/share/native/libzip/zlib/inflate.c b/src/java.base/share/native/libzip/zlib/inflate.c
    index 2bbbabc0901..3370cfe9565 100644
    --- a/src/java.base/share/native/libzip/zlib/inflate.c
    +++ b/src/java.base/share/native/libzip/zlib/inflate.c
    @@ -1411,7 +1411,7 @@ int ZEXPORT inflateSync(z_streamp strm) {
         /* if first time, start search in bit buffer */
         if (state->mode != SYNC) {
             state->mode = SYNC;
    -        state->hold <<= state->bits & 7;
    +        state->hold >>= state->bits & 7;
             state->bits -= state->bits & 7;
             len = 0;
             while (state->bits >= 8) {
    diff --git a/src/java.base/share/native/libzip/zlib/inftrees.c b/src/java.base/share/native/libzip/zlib/inftrees.c
    index f5a99831c74..c4913bc4359 100644
    --- a/src/java.base/share/native/libzip/zlib/inftrees.c
    +++ b/src/java.base/share/native/libzip/zlib/inftrees.c
    @@ -23,7 +23,7 @@
      */
     
     /* inftrees.c -- generate Huffman trees for efficient decoding
    - * Copyright (C) 1995-2023 Mark Adler
    + * Copyright (C) 1995-2024 Mark Adler
      * For conditions of distribution and use, see copyright notice in zlib.h
      */
     
    @@ -33,7 +33,7 @@
     #define MAXBITS 15
     
     const char inflate_copyright[] =
    -   " inflate 1.3 Copyright 1995-2023 Mark Adler ";
    +   " inflate 1.3.1 Copyright 1995-2024 Mark Adler ";
     /*
       If you use the zlib library in a product, an acknowledgment is welcome
       in the documentation of your product. If for some reason you cannot
    @@ -81,7 +81,7 @@ int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
             35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
         static const unsigned short lext[31] = { /* Length codes 257..285 extra */
             16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
    -        19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 198, 203};
    +        19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 203, 77};
         static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
             1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
             257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
    diff --git a/src/java.base/share/native/libzip/zlib/inftrees.h b/src/java.base/share/native/libzip/zlib/inftrees.h
    index 21b6dbeb038..3e2e889301d 100644
    --- a/src/java.base/share/native/libzip/zlib/inftrees.h
    +++ b/src/java.base/share/native/libzip/zlib/inftrees.h
    @@ -65,8 +65,8 @@ typedef struct {
        examples/enough.c found in the zlib distribution.  The arguments to that
        program are the number of symbols, the initial root table size, and the
        maximum bit length of a code.  "enough 286 9 15" for literal/length codes
    -   returns returns 852, and "enough 30 6 15" for distance codes returns 592.
    -   The initial root table size (9 or 6) is found in the fifth argument of the
    +   returns 852, and "enough 30 6 15" for distance codes returns 592. The
    +   initial root table size (9 or 6) is found in the fifth argument of the
        inflate_table() calls in inflate.c and infback.c.  If the root table size is
        changed, then these maximum sizes would be need to be recalculated and
        updated. */
    diff --git a/src/java.base/share/native/libzip/zlib/patches/ChangeLog_java b/src/java.base/share/native/libzip/zlib/patches/ChangeLog_java
    index a5d9e98a7d4..3296c5f2fad 100644
    --- a/src/java.base/share/native/libzip/zlib/patches/ChangeLog_java
    +++ b/src/java.base/share/native/libzip/zlib/patches/ChangeLog_java
    @@ -1,4 +1,4 @@
    -Changes from zlib 1.3
    +Changes from zlib 1.3.1
     
     (1) renamed adler32.c -> zadler32.c, crc32c -> zcrc32.c
     
    diff --git a/src/java.base/share/native/libzip/zlib/trees.c b/src/java.base/share/native/libzip/zlib/trees.c
    index fb26d42babf..bbfa9deee5b 100644
    --- a/src/java.base/share/native/libzip/zlib/trees.c
    +++ b/src/java.base/share/native/libzip/zlib/trees.c
    @@ -23,7 +23,7 @@
      */
     
     /* trees.c -- output deflated data using Huffman coding
    - * Copyright (C) 1995-2021 Jean-loup Gailly
    + * Copyright (C) 1995-2024 Jean-loup Gailly
      * detect_data_type() function provided freely by Cosmin Truta, 2006
      * For conditions of distribution and use, see copyright notice in zlib.h
      */
    @@ -923,14 +923,19 @@ local void compress_block(deflate_state *s, const ct_data *ltree,
                               const ct_data *dtree) {
         unsigned dist;      /* distance of matched string */
         int lc;             /* match length or unmatched char (if dist == 0) */
    -    unsigned sx = 0;    /* running index in sym_buf */
    +    unsigned sx = 0;    /* running index in symbol buffers */
         unsigned code;      /* the code to send */
         int extra;          /* number of extra bits to send */
     
         if (s->sym_next != 0) do {
    +#ifdef LIT_MEM
    +        dist = s->d_buf[sx];
    +        lc = s->l_buf[sx++];
    +#else
             dist = s->sym_buf[sx++] & 0xff;
             dist += (unsigned)(s->sym_buf[sx++] & 0xff) << 8;
             lc = s->sym_buf[sx++];
    +#endif
             if (dist == 0) {
                 send_code(s, lc, ltree); /* send a literal byte */
                 Tracecv(isgraph(lc), (stderr," '%c' ", lc));
    @@ -955,8 +960,12 @@ local void compress_block(deflate_state *s, const ct_data *ltree,
                 }
             } /* literal or match pair ? */
     
    -        /* Check that the overlay between pending_buf and sym_buf is ok: */
    +        /* Check for no overlay of pending_buf on needed symbols */
    +#ifdef LIT_MEM
    +        Assert(s->pending < 2 * (s->lit_bufsize + sx), "pendingBuf overflow");
    +#else
             Assert(s->pending < s->lit_bufsize + sx, "pendingBuf overflow");
    +#endif
     
         } while (sx < s->sym_next);
     
    @@ -1106,9 +1115,14 @@ void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf,
      * the current block must be flushed.
      */
     int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc) {
    +#ifdef LIT_MEM
    +    s->d_buf[s->sym_next] = (ush)dist;
    +    s->l_buf[s->sym_next++] = (uch)lc;
    +#else
         s->sym_buf[s->sym_next++] = (uch)dist;
         s->sym_buf[s->sym_next++] = (uch)(dist >> 8);
         s->sym_buf[s->sym_next++] = (uch)lc;
    +#endif
         if (dist == 0) {
             /* lc is the unmatched char */
             s->dyn_ltree[lc].Freq++;
    diff --git a/src/java.base/share/native/libzip/zlib/zconf.h b/src/java.base/share/native/libzip/zlib/zconf.h
    index 2dc7e97efcc..46204222f5d 100644
    --- a/src/java.base/share/native/libzip/zlib/zconf.h
    +++ b/src/java.base/share/native/libzip/zlib/zconf.h
    @@ -23,7 +23,7 @@
      */
     
     /* zconf.h -- configuration of the zlib compression library
    - * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
    + * Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler
      * For conditions of distribution and use, see copyright notice in zlib.h
      */
     
    @@ -324,14 +324,6 @@
     #  endif
     #endif
     
    -#ifndef Z_ARG /* function prototypes for stdarg */
    -#  if defined(STDC) || defined(Z_HAVE_STDARG_H)
    -#    define Z_ARG(args)  args
    -#  else
    -#    define Z_ARG(args)  ()
    -#  endif
    -#endif
    -
     /* The following definitions for FAR are needed only for MSDOS mixed
      * model programming (small or medium model with some far allocations).
      * This was tested only with MSC; for other MSDOS compilers you may have
    diff --git a/src/java.base/share/native/libzip/zlib/zlib.h b/src/java.base/share/native/libzip/zlib/zlib.h
    index 89892a062a3..07496b5f981 100644
    --- a/src/java.base/share/native/libzip/zlib/zlib.h
    +++ b/src/java.base/share/native/libzip/zlib/zlib.h
    @@ -23,9 +23,9 @@
      */
     
     /* zlib.h -- interface of the 'zlib' general purpose compression library
    -  version 1.3, August 18th, 2023
    +  version 1.3.1, January 22nd, 2024
     
    -  Copyright (C) 1995-2023 Jean-loup Gailly and Mark Adler
    +  Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler
     
       This software is provided 'as-is', without any express or implied
       warranty.  In no event will the authors be held liable for any damages
    @@ -61,11 +61,11 @@
     extern "C" {
     #endif
     
    -#define ZLIB_VERSION "1.3"
    -#define ZLIB_VERNUM 0x1300
    +#define ZLIB_VERSION "1.3.1"
    +#define ZLIB_VERNUM 0x1310
     #define ZLIB_VER_MAJOR 1
     #define ZLIB_VER_MINOR 3
    -#define ZLIB_VER_REVISION 0
    +#define ZLIB_VER_REVISION 1
     #define ZLIB_VER_SUBREVISION 0
     
     /*
    @@ -960,10 +960,10 @@ ZEXTERN int ZEXPORT inflateSync(z_streamp strm);
          inflateSync returns Z_OK if a possible full flush point has been found,
        Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point
        has been found, or Z_STREAM_ERROR if the stream structure was inconsistent.
    -   In the success case, the application may save the current current value of
    -   total_in which indicates where valid compressed data was found.  In the
    -   error case, the application may repeatedly call inflateSync, providing more
    -   input each time, until success or end of the input data.
    +   In the success case, the application may save the current value of total_in
    +   which indicates where valid compressed data was found.  In the error case,
    +   the application may repeatedly call inflateSync, providing more input each
    +   time, until success or end of the input data.
     */
     
     ZEXTERN int ZEXPORT inflateCopy(z_streamp dest,
    @@ -1782,14 +1782,14 @@ ZEXTERN uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2);
        seq1 and seq2 with lengths len1 and len2, CRC-32 check values were
        calculated for each, crc1 and crc2.  crc32_combine() returns the CRC-32
        check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and
    -   len2.
    +   len2. len2 must be non-negative.
     */
     
     /*
     ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t len2);
     
          Return the operator corresponding to length len2, to be used with
    -   crc32_combine_op().
    +   crc32_combine_op(). len2 must be non-negative.
     */
     
     ZEXTERN uLong ZEXPORT crc32_combine_op(uLong crc1, uLong crc2, uLong op);
    diff --git a/src/java.base/share/native/libzip/zlib/zutil.h b/src/java.base/share/native/libzip/zlib/zutil.h
    index 03922185c96..2b7e697bef9 100644
    --- a/src/java.base/share/native/libzip/zlib/zutil.h
    +++ b/src/java.base/share/native/libzip/zlib/zutil.h
    @@ -23,7 +23,7 @@
      */
     
     /* zutil.h -- internal interface and configuration of the compression library
    - * Copyright (C) 1995-2022 Jean-loup Gailly, Mark Adler
    + * Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler
      * For conditions of distribution and use, see copyright notice in zlib.h
      */
     
    @@ -80,7 +80,7 @@ typedef unsigned long  ulg;
     extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
     /* (size given to avoid silly warnings with Visual C++) */
     
    -#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
    +#define ERR_MSG(err) z_errmsg[(err) < -6 || (err) > 2 ? 9 : 2 - (err)]
     
     #define ERR_RETURN(strm,err) \
       return (strm->msg = ERR_MSG(err), (err))
    @@ -161,17 +161,8 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
     #  endif
     #endif
     
    -#if defined(MACOS) || defined(TARGET_OS_MAC)
    +#if defined(MACOS)
     #  define OS_CODE  7
    -#  ifndef Z_SOLO
    -#    if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
    -#      include  /* for fdopen */
    -#    else
    -#      ifndef fdopen
    -#        define fdopen(fd,mode) NULL /* No fdopen() */
    -#      endif
    -#    endif
    -#  endif
     #endif
     
     #ifdef __acorn
    @@ -194,18 +185,6 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
     #  define OS_CODE 19
     #endif
     
    -#if defined(_BEOS_) || defined(RISCOS)
    -#  define fdopen(fd,mode) NULL /* No fdopen() */
    -#endif
    -
    -#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
    -#  if defined(_WIN32_WCE)
    -#    define fdopen(fd,mode) NULL /* No fdopen() */
    -#  else
    -#    define fdopen(fd,type)  _fdopen(fd,type)
    -#  endif
    -#endif
    -
     #if defined(__BORLANDC__) && !defined(MSDOS)
       #pragma warn -8004
       #pragma warn -8008
    diff --git a/src/java.compiler/share/classes/javax/lang/model/util/Elements.java b/src/java.compiler/share/classes/javax/lang/model/util/Elements.java
    index 2e2d7477a57..56c86fc3ce4 100644
    --- a/src/java.compiler/share/classes/javax/lang/model/util/Elements.java
    +++ b/src/java.compiler/share/classes/javax/lang/model/util/Elements.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2005, 2024, 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
    @@ -687,6 +687,24 @@ default TypeElement getOutermostTypeElement(Element e) {
          *          elements.getTypeElement("C")); }
          * 
          *
    +     * Consistent with the usage of the {@link Override @Override}
    +     * annotation, if an interface declares a method
    +     * override-equivalent to a {@code public} method of {@link Object
    +     * java.lang.Object}, such a method of the interface is regarded
    +     * as overriding the corresponding {@code Object} method; for
    +     * example:
    +     *
    +     * {@snippet lang=java :
    +     * interface I {
    +     *   @Override
    +     *   String toString();
    +     * }
    +     * ...
    +     * assert elements.overrides(elementForItoString,
    +     *                           elementForObjecttoString,
    +     *                           elements.getTypeElement("I"));
    +     * }
    +     *
          * @param overrider  the first method, possible overrider
          * @param overridden  the second method, possibly being overridden
          * @param type   the class or interface of which the first method is a member
    diff --git a/src/java.compiler/share/classes/javax/lang/model/util/Types.java b/src/java.compiler/share/classes/javax/lang/model/util/Types.java
    index 8c3cc7ba5d9..f6296050ca9 100644
    --- a/src/java.compiler/share/classes/javax/lang/model/util/Types.java
    +++ b/src/java.compiler/share/classes/javax/lang/model/util/Types.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2005, 2024, 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
    @@ -35,6 +35,21 @@
     /**
      * Utility methods for operating on types.
      *
    + * Most methods operate on {@linkplain PrimitiveType primitive types},
    + * {@linkplain ReferenceType reference types} (including {@linkplain
    + * ArrayType array types} and the {@linkplain NullType null type}),
    + * {@linkplain IntersectionType intersection types}, and the
    + * pseudo-type '{@link TypeKind#VOID void}'. {@linkplain
    + * ExecutableType Executable types} and the pseudo-types for
    + * {@linkplain TypeKind#PACKAGE packages} and {@linkplain
    + * TypeKind#MODULE modules} are generally out of scope for these
    + * methods. One or more out of scope arguments will typically result
    + * in a method throwing an {@link IllegalArgumentException}.
    + *
    + * 

    Where a method returns a type mirror or a collection of type + * mirrors, any type mirrors represent types with no type annotations, + * unless otherwise indicated. + * *

    Compatibility Note: Methods may be added to this interface * in future releases of the platform. * @@ -153,6 +168,8 @@ public interface Types { * the direct supertypes of a type mirror representing {@code * java.lang.Object}. * + * Annotations on the direct super types are preserved. + * * @param t the type being examined * @return the direct supertypes, or an empty list if none * @throws IllegalArgumentException if given a type for an executable, package, or module @@ -205,11 +222,13 @@ public interface Types { * * @param kind the kind of primitive type to return * @throws IllegalArgumentException if {@code kind} is not a primitive kind + * @jls 4.2 Primitive Types and Values */ PrimitiveType getPrimitiveType(TypeKind kind); /** * {@return the null type} This is the type of {@code null}. + * @jls 4.1 The Kinds of Types and Values */ NullType getNullType(); @@ -235,9 +254,12 @@ public interface Types { /** * {@return an array type with the specified component type} * + * Annotations on the component type are preserved. + * * @param componentType the component type * @throws IllegalArgumentException if the component type is not valid for - * an array + * an array, including executable, package, module, and wildcard types + * @jls 10.1 Array Types */ ArrayType getArrayType(TypeMirror componentType); @@ -245,9 +267,12 @@ public interface Types { * {@return a new wildcard type} Either of the wildcard's * bounds may be specified, or neither, but not both. * + * Annotations on the bounds are preserved. + * * @param extendsBound the extends (upper) bound, or {@code null} if none * @param superBound the super (lower) bound, or {@code null} if none * @throws IllegalArgumentException if bounds are not valid + * @jls 4.5.1 Type Arguments of Parameterized Types */ WildcardType getWildcardType(TypeMirror extendsBound, TypeMirror superBound); @@ -260,6 +285,8 @@ WildcardType getWildcardType(TypeMirror extendsBound, * for example, this method may be used to get the * parameterized type {@code Set}. * + * Annotations on the type arguments are preserved. + * *

    The number of type arguments must either equal the * number of the type element's formal type parameters, or must be * zero. If zero, and if the type element is generic, @@ -291,6 +318,8 @@ WildcardType getWildcardType(TypeMirror extendsBound, * to get the type {@code Outer}, and then invoking * this method. * + * Annotations on the type arguments are preserved. + * *

    If the containing type is a parameterized type, * the number of type arguments must equal the * number of {@code typeElem}'s formal type parameters. @@ -324,4 +353,29 @@ DeclaredType getDeclaredType(DeclaredType containing, * for the given type */ TypeMirror asMemberOf(DeclaredType containing, Element element); + + /** + * {@return a type mirror equivalent to the argument, but with no annotations} + * If the type mirror is a composite type, such as an array type + * or a wildcard type, any constitute types, such as the + * component type of an array and the type of the bounds of a + * wildcard type, also have no annotations, recursively. + * + *

    For most kinds of type mirrors, the result of + * {@snippet lang="java" : + * types.isSameType(typeMirror, types.stripAnnotations(typeMirror)) + * } + * is {@code true}. The predicate is {@code false} on wildcard + * types for {@linkplain #isSameType(TypeMirror, TypeMirror) + * reasons discussed elsewhere}. + * + * @param t the type mirror + * @param the specific type of type mirror + * @implSpec + * The default implementation throws {@code UnsupportedOperationException}. + * @since 23 + */ + default T stripAnnotations(T t) { + throw new UnsupportedOperationException(); + } } diff --git a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTableUI.java b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTableUI.java index 5ee66680a2b..2b8c9ae72ba 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTableUI.java +++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTableUI.java @@ -326,10 +326,7 @@ protected void paint(SynthContext context, Graphics g) { // into the table's bounds bounds.x = bounds.y = 0; - if (table.getRowCount() <= 0 || table.getColumnCount() <= 0 || - // this check prevents us from painting the entire table - // when the clip doesn't intersect our bounds at all - !bounds.intersects(clip)) { + if (table.getRowCount() <= 0 || table.getColumnCount() <= 0) { paintDropLines(context, g); return; diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Preview.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Preview.java index fa911b5c04a..32a7d068715 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Preview.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Preview.java @@ -210,6 +210,7 @@ public boolean isPreview(Feature feature) { case STRING_TEMPLATES -> true; case IMPLICIT_CLASSES -> true; case SUPER_INIT -> true; + case PRIMITIVE_PATTERNS -> true; //Note: this is a backdoor which allows to optionally treat all features as 'preview' (for testing). //When real preview features will be added, this method can be implemented to return 'true' //for those selected features, and 'false' for all the others. diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java index 870d6b1629a..54e5cfec32a 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2024, 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 @@ -254,6 +254,7 @@ public enum Feature { IMPLICIT_CLASSES(JDK21, Fragments.FeatureImplicitClasses, DiagKind.PLURAL), WARN_ON_ILLEGAL_UTF8(MIN, JDK21), UNNAMED_VARIABLES(JDK22, Fragments.FeatureUnnamedVariables, DiagKind.PLURAL), + PRIMITIVE_PATTERNS(JDK23, Fragments.FeaturePrimitivePatterns, DiagKind.PLURAL), SUPER_INIT(JDK22, Fragments.FeatureSuperInit, DiagKind.NORMAL), ; diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java index 8e270dec387..b1dd2186d7e 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java @@ -163,6 +163,7 @@ public static Symtab instance(Context context) { */ public final Type objectType; public final Type objectMethodsType; + public final Type exactConversionsSupportType; public final Type objectsType; public final Type classType; public final Type classLoaderType; @@ -545,6 +546,7 @@ public R accept(ElementVisitor v, P p) { // Enter predefined classes. All are assumed to be in the java.base module. objectType = enterClass("java.lang.Object"); objectMethodsType = enterClass("java.lang.runtime.ObjectMethods"); + exactConversionsSupportType = enterClass("java.lang.runtime.ExactConversionsSupport"); objectsType = enterClass("java.util.Objects"); classType = enterClass("java.lang.Class"); stringType = enterClass("java.lang.String"); diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java index 533d756d641..1715dfa1451 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java @@ -340,7 +340,7 @@ public Type baseType() { * it should not be used outside this class. */ protected Type typeNoMetadata() { - return metadata.isEmpty() ? this : baseType(); + return metadata.isEmpty() ? this : stripMetadata(); } /** @@ -426,25 +426,42 @@ public Type stripMetadata() { return accept(stripMetadata, null); } //where + /** + * Note: this visitor only needs to handle cases where + * 'contained' types can be annotated. These cases are + * described in JVMS 4.7.20.2 and are : classes (for type + * parameters and enclosing types), wildcards, and arrays. + */ private static final TypeMapping stripMetadata = new StructuralTypeMapping() { @Override public Type visitClassType(ClassType t, Void aVoid) { - return super.visitClassType((ClassType)t.typeNoMetadata(), aVoid); + return super.visitClassType((ClassType) dropMetadata(t), aVoid); } @Override public Type visitArrayType(ArrayType t, Void aVoid) { - return super.visitArrayType((ArrayType)t.typeNoMetadata(), aVoid); + return super.visitArrayType((ArrayType) dropMetadata(t), aVoid); } @Override - public Type visitTypeVar(TypeVar t, Void aVoid) { - return super.visitTypeVar((TypeVar)t.typeNoMetadata(), aVoid); + public Type visitWildcardType(WildcardType wt, Void aVoid) { + return super.visitWildcardType((WildcardType) dropMetadata(wt), aVoid); } @Override - public Type visitWildcardType(WildcardType wt, Void aVoid) { - return super.visitWildcardType((WildcardType)wt.typeNoMetadata(), aVoid); + public Type visitType(Type t, Void aVoid) { + return dropMetadata(t); + } + + private static Type dropMetadata(Type t) { + if (t.getMetadata().isEmpty()) { + return t; + } + Type baseType = t.baseType(); + if (baseType.getMetadata().isEmpty()) { + return baseType; + } + return baseType.cloneWithMetadata(List.nil()); } }; diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeTag.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeTag.java index 6dd1ea4b6b8..94449476071 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeTag.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeTag.java @@ -186,6 +186,10 @@ public boolean isSubRangeOf(TypeTag tag) { return (this.superClasses & tag.numericClass) != 0; } + public boolean isInSuperClassesOf(TypeTag tag) { + return (this.numericClass & tag.superClasses) != 0; + } + /** Returns the number of type tags. */ public static int getTypeTagCount() { diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java index 7af1193c6ce..4b2f32521a3 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java @@ -5024,6 +5024,52 @@ public Type visitCapturedType(CapturedType t, S s) { } // + // + /** Check unconditionality between any combination of reference or primitive types. + * + * Rules: + * an identity conversion + * a widening reference conversion + * a widening primitive conversion (delegates to `checkUnconditionallyExactPrimitives`) + * a boxing conversion + * a boxing conversion followed by a widening reference conversion + * + * @param source Source primitive or reference type + * @param target Target primitive or reference type + */ + public boolean isUnconditionallyExact(Type source, Type target) { + if (isSameType(source, target)) { + return true; + } + + return target.isPrimitive() + ? isUnconditionallyExactPrimitives(source, target) + : isSubtype(boxedTypeOrType(erasure(source)), target); + } + + /** Check unconditionality between primitive types. + * + * - widening from one integral type to another, + * - widening from one floating point type to another, + * - widening from byte, short, or char to a floating point type, + * - widening from int to double. + * + * @param selectorType Type of selector + * @param targetType Target type + */ + public boolean isUnconditionallyExactPrimitives(Type selectorType, Type targetType) { + if (isSameType(selectorType, targetType)) { + return true; + } + + return (selectorType.isPrimitive() && targetType.isPrimitive()) && + ((selectorType.hasTag(BYTE) && !targetType.hasTag(CHAR)) || + (selectorType.hasTag(SHORT) && (selectorType.getTag().isStrictSubRangeOf(targetType.getTag()))) || + (selectorType.hasTag(CHAR) && (selectorType.getTag().isStrictSubRangeOf(targetType.getTag()))) || + (selectorType.hasTag(INT) && (targetType.hasTag(DOUBLE) || targetType.hasTag(LONG))) || + (selectorType.hasTag(FLOAT) && (selectorType.getTag().isStrictSubRangeOf(targetType.getTag())))); + } + // // diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java index bcc16452935..f5a9d43162e 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java @@ -1682,18 +1682,19 @@ private void handleSwitch(JCTree switchTree, try { boolean enumSwitch = (seltype.tsym.flags() & Flags.ENUM) != 0; boolean stringSwitch = types.isSameType(seltype, syms.stringType); + boolean booleanSwitch = types.isSameType(types.unboxedTypeOrType(seltype), syms.booleanType); boolean errorEnumSwitch = TreeInfo.isErrorEnumSwitch(selector, cases); boolean intSwitch = types.isAssignable(seltype, syms.intType); - boolean errorPrimitiveSwitch = seltype.isPrimitive() && !intSwitch; boolean patternSwitch; + if (seltype.isPrimitive() && !intSwitch) { + preview.checkSourceLevel(selector.pos(), Feature.PRIMITIVE_PATTERNS); + patternSwitch = true; + } if (!enumSwitch && !stringSwitch && !errorEnumSwitch && - !intSwitch && !errorPrimitiveSwitch) { + !intSwitch) { preview.checkSourceLevel(selector.pos(), Feature.PATTERN_SWITCH); patternSwitch = true; } else { - if (errorPrimitiveSwitch) { - log.error(selector.pos(), Errors.SelectorTypeNotAllowed(seltype)); - } patternSwitch = cases.stream() .flatMap(c -> c.labels.stream()) .anyMatch(l -> l.hasTag(PATTERNCASELABEL) || @@ -1709,6 +1710,7 @@ private void handleSwitch(JCTree switchTree, boolean hasNullPattern = false; // Is there a null pattern? CaseTree.CaseKind caseKind = null; boolean wasError = false; + JCCaseLabel unconditionalCaseLabel = null; for (List l = cases; l.nonEmpty(); l = l.tail) { JCCase c = l.head; if (caseKind == null) { @@ -1776,10 +1778,15 @@ private void handleSwitch(JCTree switchTree, } else if (!constants.add(s)) { log.error(label.pos(), Errors.DuplicateCaseLabel); } - } else if (!stringSwitch && !intSwitch && !errorPrimitiveSwitch) { - log.error(label.pos(), Errors.ConstantLabelNotCompatible(pattype, seltype)); - } else if (!constants.add(pattype.constValue())) { - log.error(c.pos(), Errors.DuplicateCaseLabel); + } + else { + if (!stringSwitch && !intSwitch && + !((pattype.getTag().isInSuperClassesOf(LONG) || pattype.getTag().equals(BOOLEAN)) && + types.isSameType(types.unboxedTypeOrType(seltype), pattype))) { + log.error(label.pos(), Errors.ConstantLabelNotCompatible(pattype, seltype)); + } else if (!constants.add(pattype.constValue())) { + log.error(c.pos(), Errors.DuplicateCaseLabel); + } } } } @@ -1788,6 +1795,8 @@ private void handleSwitch(JCTree switchTree, log.error(label.pos(), Errors.DuplicateDefaultLabel); } else if (hasUnconditionalPattern) { log.error(label.pos(), Errors.UnconditionalPatternAndDefault); + } else if (booleanSwitch && constants.containsAll(Set.of(0, 1))) { + log.error(label.pos(), Errors.DefaultAndBothBooleanValues); } hasDefault = true; matchBindings = MatchBindingsComputer.EMPTY; @@ -1796,12 +1805,13 @@ private void handleSwitch(JCTree switchTree, JCPattern pat = patternlabel.pat; attribExpr(pat, switchEnv, seltype); Type primaryType = TreeInfo.primaryPatternType(pat); - if (!primaryType.hasTag(TYPEVAR)) { + + if (primaryType.isPrimitive()) { + preview.checkSourceLevel(pat.pos(), Feature.PRIMITIVE_PATTERNS); + } else if (!primaryType.hasTag(TYPEVAR)) { primaryType = chk.checkClassOrArrayType(pat.pos(), primaryType); } - if (!errorPrimitiveSwitch) { - checkCastablePattern(pat.pos(), seltype, primaryType); - } + checkCastablePattern(pat.pos(), seltype, primaryType); Type patternType = types.erasure(primaryType); JCExpression guard = c.guard; if (guardBindings == null && guard != null) { @@ -1824,15 +1834,17 @@ private void handleSwitch(JCTree switchTree, boolean unconditional = unguarded && !patternType.isErroneous() && - types.isSubtype(types.boxedTypeOrType(types.erasure(seltype)), - patternType); + types.isUnconditionallyExact(seltype, patternType); if (unconditional) { if (hasUnconditionalPattern) { log.error(pat.pos(), Errors.DuplicateUnconditionalPattern); } else if (hasDefault) { log.error(pat.pos(), Errors.UnconditionalPatternAndDefault); + } else if (booleanSwitch && constants.containsAll(Set.of(0, 1))) { + log.error(pat.pos(), Errors.UnconditionalPatternAndBothBooleanValues); } hasUnconditionalPattern = true; + unconditionalCaseLabel = label; } lastPatternErroneous = patternType.isErroneous(); } else { @@ -1859,7 +1871,7 @@ private void handleSwitch(JCTree switchTree, } if (patternSwitch) { chk.checkSwitchCaseStructure(cases); - chk.checkSwitchCaseLabelDominated(cases); + chk.checkSwitchCaseLabelDominated(unconditionalCaseLabel, cases); } if (switchTree.hasTag(SWITCH)) { ((JCSwitch) switchTree).hasUnconditionalPattern = @@ -4097,8 +4109,13 @@ public boolean compatible(Type found, Type req, Warner warn) { } public void visitTypeTest(JCInstanceOf tree) { - Type exprtype = chk.checkNullOrRefType( - tree.expr.pos(), attribExpr(tree.expr, env)); + Type exprtype = attribExpr(tree.expr, env); + if (exprtype.isPrimitive()) { + preview.checkSourceLevel(tree.expr.pos(), Feature.PRIMITIVE_PATTERNS); + } else { + exprtype = chk.checkNullOrRefType( + tree.expr.pos(), exprtype); + } Type clazztype; JCTree typeTree; if (tree.pattern.getTag() == BINDINGPATTERN || @@ -4119,20 +4136,24 @@ public void visitTypeTest(JCInstanceOf tree) { typeTree = tree.pattern; chk.validate(typeTree, env, false); } - if (!clazztype.hasTag(TYPEVAR)) { - clazztype = chk.checkClassOrArrayType(typeTree.pos(), clazztype); - } - if (!clazztype.isErroneous() && !types.isReifiable(clazztype)) { - boolean valid = false; - if (allowReifiableTypesInInstanceof) { - valid = checkCastablePattern(tree.expr.pos(), exprtype, clazztype); - } else { - log.error(DiagnosticFlag.SOURCE_LEVEL, tree.pos(), - Feature.REIFIABLE_TYPES_INSTANCEOF.error(this.sourceName)); - allowReifiableTypesInInstanceof = true; + if (clazztype.isPrimitive()) { + preview.checkSourceLevel(tree.pattern.pos(), Feature.PRIMITIVE_PATTERNS); + } else { + if (!clazztype.hasTag(TYPEVAR)) { + clazztype = chk.checkClassOrArrayType(typeTree.pos(), clazztype); } - if (!valid) { - clazztype = types.createErrorType(clazztype); + if (!clazztype.isErroneous() && !types.isReifiable(clazztype)) { + boolean valid = false; + if (allowReifiableTypesInInstanceof) { + valid = checkCastablePattern(tree.expr.pos(), exprtype, clazztype); + } else { + log.error(DiagnosticFlag.SOURCE_LEVEL, tree.pos(), + Feature.REIFIABLE_TYPES_INSTANCEOF.error(this.sourceName)); + allowReifiableTypesInInstanceof = true; + } + if (!valid) { + clazztype = types.createErrorType(clazztype); + } } } chk.checkCastable(tree.expr.pos(), exprtype, clazztype); @@ -4152,12 +4173,9 @@ private boolean checkCastablePattern(DiagnosticPosition pos, diags.fragment(Fragments.InconvertibleTypes(exprType, pattType))); return false; } else if ((exprType.isPrimitive() || pattType.isPrimitive()) && - (!exprType.isPrimitive() || - !pattType.isPrimitive() || - !types.isSameType(exprType, pattType))) { - chk.basicHandler.report(pos, - diags.fragment(Fragments.NotApplicableTypes(exprType, pattType))); - return false; + (!exprType.isPrimitive() || !pattType.isPrimitive() || !types.isSameType(exprType, pattType))) { + preview.checkSourceLevel(pos, Feature.PRIMITIVE_PATTERNS); + return true; } else if (warner.hasLint(LintCategory.UNCHECKED)) { log.error(pos, Errors.InstanceofReifiableNotSafe(exprType, pattType)); diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java index f9b228203d4..834d976a7c8 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java @@ -4800,11 +4800,13 @@ boolean hasStatements(List cases) { return false; } - void checkSwitchCaseLabelDominated(List cases) { + void checkSwitchCaseLabelDominated(JCCaseLabel unconditionalCaseLabel, List cases) { List> caseLabels = List.nil(); boolean seenDefault = false; boolean seenDefaultLabel = false; boolean warnDominatedByDefault = false; + boolean unconditionalFound = false; + for (List l = cases; l.nonEmpty(); l = l.tail) { JCCase c = l.head; for (JCCaseLabel label : c.labels) { @@ -4832,10 +4834,11 @@ void checkSwitchCaseLabelDominated(List cases) { JCCase testCase = caseAndLabel.fst; JCCaseLabel testCaseLabel = caseAndLabel.snd; Type testType = labelType(testCaseLabel); - if (types.isSubtype(currentType, testType) && + boolean dominated = false; + if (unconditionalCaseLabel == testCaseLabel) unconditionalFound = true; + if (types.isUnconditionallyExact(currentType, testType) && !currentType.hasTag(ERROR) && !testType.hasTag(ERROR)) { //the current label is potentially dominated by the existing (test) label, check: - boolean dominated = false; if (label instanceof JCConstantCaseLabel) { dominated |= !(testCaseLabel instanceof JCConstantCaseLabel) && TreeInfo.unguardedCase(testCase); @@ -4845,9 +4848,15 @@ void checkSwitchCaseLabelDominated(List cases) { dominated = patternDominated(testPatternCaseLabel.pat, patternCL.pat); } - if (dominated) { - log.error(label.pos(), Errors.PatternDominated); - } + } + + // Domination can occur even when we have not an unconditional pair between case labels. + if (unconditionalFound && unconditionalCaseLabel != label) { + dominated = true; + } + + if (dominated) { + log.error(label.pos(), Errors.PatternDominated); } } caseLabels = caseLabels.prepend(Pair.of(c, label)); @@ -4858,23 +4867,16 @@ void checkSwitchCaseLabelDominated(List cases) { private Type labelType(JCCaseLabel label) { return types.erasure(switch (label.getTag()) { case PATTERNCASELABEL -> ((JCPatternCaseLabel) label).pat.type; - case CONSTANTCASELABEL -> types.boxedTypeOrType(((JCConstantCaseLabel) label).expr.type); + case CONSTANTCASELABEL -> ((JCConstantCaseLabel) label).expr.type; default -> throw Assert.error("Unexpected tree kind: " + label.getTag()); }); } private boolean patternDominated(JCPattern existingPattern, JCPattern currentPattern) { Type existingPatternType = types.erasure(existingPattern.type); Type currentPatternType = types.erasure(currentPattern.type); - if (existingPatternType.isPrimitive() ^ currentPatternType.isPrimitive()) { + if (!types.isUnconditionallyExact(currentPatternType, existingPatternType)) { return false; } - if (existingPatternType.isPrimitive()) { - return types.isSameType(existingPatternType, currentPatternType); - } else { - if (!types.isSubtype(currentPatternType, existingPatternType)) { - return false; - } - } if (currentPattern instanceof JCBindingPattern || currentPattern instanceof JCAnyPattern) { return existingPattern instanceof JCBindingPattern || diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java index e1f5b6f38a0..9de7a6292db 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java @@ -757,9 +757,14 @@ public void visitSwitchExpression(JCSwitchExpression tree) { } } } - tree.isExhaustive = tree.hasUnconditionalPattern || - TreeInfo.isErrorEnumSwitch(tree.selector, tree.cases) || - exhausts(tree.selector, tree.cases); + + if (tree.hasUnconditionalPattern || + TreeInfo.isErrorEnumSwitch(tree.selector, tree.cases)) { + tree.isExhaustive = true; + } else { + tree.isExhaustive = exhausts(tree.selector, tree.cases); + } + if (!tree.isExhaustive) { log.error(tree, Errors.NotExhaustive); } @@ -770,6 +775,7 @@ public void visitSwitchExpression(JCSwitchExpression tree) { private boolean exhausts(JCExpression selector, List cases) { Set patternSet = new HashSet<>(); Map> enum2Constants = new HashMap<>(); + Set booleanLiterals = new HashSet<>(); for (JCCase c : cases) { if (!TreeInfo.unguardedCase(c)) continue; @@ -780,19 +786,29 @@ private boolean exhausts(JCExpression selector, List cases) { patternSet.add(makePatternDescription(component, patternLabel.pat)); } } else if (l instanceof JCConstantCaseLabel constantLabel) { - Symbol s = TreeInfo.symbol(constantLabel.expr); - if (s != null && s.isEnum()) { - enum2Constants.computeIfAbsent(s.owner, x -> { - Set result = new HashSet<>(); - s.owner.members() - .getSymbols(sym -> sym.kind == Kind.VAR && sym.isEnum()) - .forEach(result::add); - return result; - }).remove(s); + if (types.unboxedTypeOrType(selector.type).hasTag(TypeTag.BOOLEAN)) { + Object value = ((JCLiteral) constantLabel.expr).value; + booleanLiterals.add(value); + } else { + Symbol s = TreeInfo.symbol(constantLabel.expr); + if (s != null && s.isEnum()) { + enum2Constants.computeIfAbsent(s.owner, x -> { + Set result = new HashSet<>(); + s.owner.members() + .getSymbols(sym -> sym.kind == Kind.VAR && sym.isEnum()) + .forEach(result::add); + return result; + }).remove(s); + } } } } } + + if (types.unboxedTypeOrType(selector.type).hasTag(TypeTag.BOOLEAN) && booleanLiterals.size() == 2) { + return true; + } + for (Entry> e : enum2Constants.entrySet()) { if (e.getValue().isEmpty()) { patternSet.add(new BindingPattern(e.getKey().type)); @@ -823,8 +839,7 @@ private boolean exhausts(JCExpression selector, List cases) { private boolean checkCovered(Type seltype, Iterable patterns) { for (Type seltypeComponent : components(seltype)) { for (PatternDescription pd : patterns) { - if (pd instanceof BindingPattern bp && - types.isSubtype(seltypeComponent, types.erasure(bp.type))) { + if(isBpCovered(seltypeComponent, pd)) { return true; } } @@ -1104,8 +1119,7 @@ private PatternDescription reduceRecordPattern(PatternDescription pattern) { reducedNestedPatterns[i] = newNested; } - covered &= newNested instanceof BindingPattern bp && - types.isSubtype(types.erasure(componentType[i]), types.erasure(bp.type)); + covered &= isBpCovered(componentType[i], newNested); } if (covered) { return new BindingPattern(rpOne.recordType); @@ -1281,6 +1295,30 @@ public void analyzeTree(Env env, JCTree tree, TreeMaker make) { } } + private boolean isBpCovered(Type componentType, PatternDescription newNested) { + if (newNested instanceof BindingPattern bp) { + var seltype = types.erasure(componentType); + + if (seltype.isPrimitive()) { + if (types.isSameType(bp.type, types.boxedClass(seltype).type)) { + return true; + } + + // if the target is unconditionally exact to the pattern, target is covered + if (types.isUnconditionallyExact(seltype, bp.type)) { + return true; + } + } else if (seltype.isReference() && bp.type.isPrimitive() && types.isCastable(seltype, bp.type)) { + return true; + } else { + if (types.isSubtype(seltype, types.erasure(bp.type))) { + return true; + } + } + } + return false; + } + /** * This pass implements the second step of the dataflow analysis, namely * the exception analysis. This is to ensure that every checked exception that is @@ -3462,7 +3500,7 @@ public static Liveness from(boolean value) { sealed interface PatternDescription { } public PatternDescription makePatternDescription(Type selectorType, JCPattern pattern) { if (pattern instanceof JCBindingPattern binding) { - Type type = types.isSubtype(selectorType, binding.type) + Type type = !selectorType.isPrimitive() && types.isSubtype(selectorType, binding.type) ? selectorType : binding.type; return new BindingPattern(type); } else if (pattern instanceof JCRecordPattern record) { diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java index 39807aeaa5e..6e15f5acf5b 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java @@ -102,6 +102,7 @@ public static Lower instance(Context context) { private final PkgInfo pkginfoOpt; private final boolean optimizeOuterThis; private final boolean useMatchException; + private final HashMap typePairToName; @SuppressWarnings("this-escape") protected Lower(Context context) { @@ -133,6 +134,7 @@ protected Lower(Context context) { Preview preview = Preview.instance(context); useMatchException = Feature.PATTERN_SWITCH.allowedInSource(source) && (preview.isEnabled() || !preview.isPreview(Feature.PATTERN_SWITCH)); + typePairToName = TypePairs.initialize(syms); } /** The currently enclosing class. @@ -2921,6 +2923,178 @@ public void visitTypeCast(JCTypeCast tree) { result = tree; } + /** + * All the exactness checks between primitive types that require a run-time + * check are in {@code java.lang.runtime.ExactConversionsSupport}. Those methods + * are in the form {@code ExactConversionsSupport.isToExact} where both + * {@code S} and {@code T} are primitive types and correspond to the runtime + * action that will be executed to check whether a certain value (that is passed + * as a parameter) can be converted to {@code T} without loss of information. + * + * Rewrite {@code instanceof if expr : Object} and Type is primitive type: + * + * {@snippet : + * Object v = ... + * if (v instanceof float) + * => + * if (let tmp$123 = v; tmp$123 instanceof Float) + * } + * + * Rewrite {@code instanceof if expr : wrapper reference type} + * + * {@snippet : + * Integer v = ... + * if (v instanceof float) + * => + * if (let tmp$123 = v; tmp$123 != null && ExactConversionsSupport.intToFloatExact(tmp$123.intValue())) + * } + * + * Rewrite {@code instanceof if expr : primitive} + * + * {@snippet : + * int v = ... + * if (v instanceof float) + * => + * if (let tmp$123 = v; ExactConversionsSupport.intToFloatExact(tmp$123)) + * } + * + * More rewritings: + *
      + *
    • If the {@code instanceof} check is unconditionally exact rewrite to true.
    • + *
    • If expression type is {@code Byte}, {@code Short}, {@code Integer}, ..., an + * unboxing conversion followed by a widening primitive conversion.
    • + *
    • If expression type is a supertype: {@code Number}, a narrowing reference + * conversion followed by an unboxing conversion.
    • + *
    + */ + public void visitTypeTest(JCInstanceOf tree) { + if (tree.expr.type.isPrimitive() || tree.pattern.type.isPrimitive()) { + JCExpression exactnessCheck = null; + JCExpression instanceOfExpr = translate(tree.expr); + + // preserving the side effects of the value + VarSymbol dollar_s = new VarSymbol(FINAL | SYNTHETIC, + names.fromString("tmp" + tree.pos + this.target.syntheticNameChar()), + tree.expr.type, + currentMethodSym); + JCStatement var = make.at(tree.pos()) + .VarDef(dollar_s, instanceOfExpr).setType(dollar_s.type); + + if (types.isUnconditionallyExact(tree.expr.type, tree.pattern.type)) { + exactnessCheck = make + .LetExpr(List.of(var), make.Literal(BOOLEAN, 1).setType(syms.booleanType.constType(1))) + .setType(syms.booleanType); + } + else if (tree.expr.type.isReference()) { + JCExpression nullCheck = makeBinary(NE, + make.Ident(dollar_s), + makeNull()); + if (types.isUnconditionallyExact(types.unboxedType(tree.expr.type), tree.pattern.type)) { + exactnessCheck = make + .LetExpr(List.of(var), nullCheck) + .setType(syms.booleanType); + } else if (types.unboxedType(tree.expr.type).isPrimitive()) { + exactnessCheck = getExactnessCheck(tree, + boxIfNeeded(make.Ident(dollar_s), types.unboxedType(tree.expr.type))); + } else { + exactnessCheck = make.at(tree.pos()) + .TypeTest(tree.expr, make.Type(types.boxedClass(tree.pattern.type).type)) + .setType(syms.booleanType); + } + + exactnessCheck = make.LetExpr(List.of(var), makeBinary(AND, + nullCheck, + exactnessCheck)) + .setType(syms.booleanType); + } + else if (tree.expr.type.isPrimitive()) { + JCIdent argument = make.Ident(dollar_s); + + JCExpression exactnessCheckCall = + getExactnessCheck(tree, argument); + + exactnessCheck = make.LetExpr(List.of(var), exactnessCheckCall) + .setType(syms.booleanType); + } + + result = exactnessCheck; + } else { + tree.expr = translate(tree.expr); + tree.pattern = translate(tree.pattern); + result = tree; + } + } + + // TypePairs should be in sync with the corresponding record in SwitchBootstraps + record TypePairs(TypeSymbol from, TypeSymbol to) { + public static TypePairs of(Symtab syms, Type from, Type to) { + if (from == syms.byteType || from == syms.shortType || from == syms.charType) { + from = syms.intType; + } + return new TypePairs(from, to); + } + + public TypePairs(Type from, Type to) { + this(from.tsym, to.tsym); + } + + public static HashMap initialize(Symtab syms) { + HashMap typePairToName = new HashMap<>(); + typePairToName.put(new TypePairs(syms.byteType, syms.charType), "isIntToCharExact"); // redirected + typePairToName.put(new TypePairs(syms.shortType, syms.byteType), "isIntToByteExact"); // redirected + typePairToName.put(new TypePairs(syms.shortType, syms.charType), "isIntToCharExact"); // redirected + typePairToName.put(new TypePairs(syms.charType, syms.byteType), "isIntToByteExact"); // redirected + typePairToName.put(new TypePairs(syms.charType, syms.shortType), "isIntToShortExact"); // redirected + typePairToName.put(new TypePairs(syms.intType, syms.byteType), "isIntToByteExact"); + typePairToName.put(new TypePairs(syms.intType, syms.shortType), "isIntToShortExact"); + typePairToName.put(new TypePairs(syms.intType, syms.charType), "isIntToCharExact"); + typePairToName.put(new TypePairs(syms.intType, syms.floatType), "isIntToFloatExact"); + typePairToName.put(new TypePairs(syms.longType, syms.byteType), "isLongToByteExact"); + typePairToName.put(new TypePairs(syms.longType, syms.shortType), "isLongToShortExact"); + typePairToName.put(new TypePairs(syms.longType, syms.charType), "isLongToCharExact"); + typePairToName.put(new TypePairs(syms.longType, syms.intType), "isLongToIntExact"); + typePairToName.put(new TypePairs(syms.longType, syms.floatType), "isLongToFloatExact"); + typePairToName.put(new TypePairs(syms.longType, syms.doubleType), "isLongToDoubleExact"); + typePairToName.put(new TypePairs(syms.floatType, syms.byteType), "isFloatToByteExact"); + typePairToName.put(new TypePairs(syms.floatType, syms.shortType), "isFloatToShortExact"); + typePairToName.put(new TypePairs(syms.floatType, syms.charType), "isFloatToCharExact"); + typePairToName.put(new TypePairs(syms.floatType, syms.intType), "isFloatToIntExact"); + typePairToName.put(new TypePairs(syms.floatType, syms.longType), "isFloatToLongExact"); + typePairToName.put(new TypePairs(syms.doubleType, syms.byteType), "isDoubleToByteExact"); + typePairToName.put(new TypePairs(syms.doubleType, syms.shortType), "isDoubleToShortExact"); + typePairToName.put(new TypePairs(syms.doubleType, syms.charType), "isDoubleToCharExact"); + typePairToName.put(new TypePairs(syms.doubleType, syms.intType), "isDoubleToIntExact"); + typePairToName.put(new TypePairs(syms.doubleType, syms.longType), "isDoubleToLongExact"); + typePairToName.put(new TypePairs(syms.doubleType, syms.floatType), "isDoubleToFloatExact"); + return typePairToName; + } + } + + private JCExpression getExactnessCheck(JCInstanceOf tree, JCExpression argument) { + TypePairs pair = TypePairs.of(syms, types.unboxedTypeOrType(tree.expr.type), tree.pattern.type); + + Name exactnessFunction = names.fromString(typePairToName.get(pair)); + + // Resolve the exactness method + Symbol ecsym = lookupMethod(tree.pos(), + exactnessFunction, + syms.exactConversionsSupportType, + List.of(pair.from.type)); + + // Generate the method call ExactnessChecks.(); + JCFieldAccess select = make.Select( + make.QualIdent(syms.exactConversionsSupportType.tsym), + exactnessFunction); + select.sym = ecsym; + select.setType(syms.booleanType); + + JCExpression exactnessCheck = make.Apply(List.nil(), + select, + List.of(argument)); + exactnessCheck.setType(syms.booleanType); + return exactnessCheck; + } + public void visitNewClass(JCNewClass tree) { ClassSymbol c = (ClassSymbol)tree.constructor.owner; diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransPatterns.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransPatterns.java index aedafa20c3e..089d9236dec 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransPatterns.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransPatterns.java @@ -236,7 +236,7 @@ public void visitTypeTest(JCInstanceOf tree) { Type principalType = types.erasure(TreeInfo.primaryPatternType((pattern))); JCExpression resultExpression = (JCExpression) this.translate(pattern); - if (!tree.allowNull && !principalType.isPrimitive()) { + if (!tree.allowNull || !types.isSubtype(currentValue.type, principalType)) { resultExpression = makeBinary(Tag.AND, makeTypeTest(make.Ident(currentValue), make.Type(principalType)), @@ -496,12 +496,14 @@ private void handleSwitch(JCTree tree, .toArray(s -> new LoadableConstant[s]); boolean enumSelector = seltype.tsym.isEnum(); + boolean primitiveSelector = seltype.isPrimitive(); Name bootstrapName = enumSelector ? names.enumSwitch : names.typeSwitch; MethodSymbol bsm = rs.resolveInternalMethod(tree.pos(), env, syms.switchBootstrapsType, bootstrapName, staticArgTypes, List.nil()); + Type resolvedSelectorType = seltype; MethodType indyType = new MethodType( - List.of(enumSelector ? seltype : syms.objectType, syms.intType), + List.of(resolvedSelectorType, syms.intType), syms.intType, List.nil(), syms.methodClass @@ -735,6 +737,81 @@ void appendBreakIfNeeded(JCTree switchTree, List cases, JCCase c) { } } + private Symbol.DynamicVarSymbol makePrimitive(DiagnosticPosition pos, Type primitiveType) { + Assert.checkNonNull(currentClass); + + List bsm_staticArgs = List.of(syms.methodHandleLookupType, + syms.stringType, + new ClassType(syms.classType.getEnclosingType(), + List.of(syms.constantBootstrapsType), + syms.classType.tsym)); + + Name bootstrapName = names.fromString("primitiveClass"); + MethodSymbol bsm = rs.resolveInternalMethod(pos, env, syms.constantBootstrapsType, + bootstrapName, bsm_staticArgs, List.nil()); + + PrimitiveGenerator primitiveGenerator = new PrimitiveGenerator(); + primitiveGenerator.assembleSig(primitiveType); + return new Symbol.DynamicVarSymbol(names.fromString(primitiveGenerator.sb.toString()), + syms.noSymbol, + new Symbol.MethodHandleSymbol(bsm), + syms.classType, + new LoadableConstant[]{}); + } + + private Symbol.DynamicVarSymbol makeBooleanConstant(DiagnosticPosition pos, int constant) { + Assert.checkNonNull(currentClass); + + List bsm_staticArgs = List.of(syms.methodHandleLookupType, + syms.stringType, + new ClassType(syms.classType.getEnclosingType(), + List.of(syms.constantBootstrapsType), + syms.classType.tsym)); + + Name bootstrapName = names.fromString("getStaticFinal"); + MethodSymbol bsm = rs.resolveInternalMethod(pos, env, syms.constantBootstrapsType, + bootstrapName, bsm_staticArgs, List.nil()); + + return new Symbol.DynamicVarSymbol(constant == 0 ? names.fromString("FALSE") : names.fromString("TRUE"), + syms.noSymbol, + new Symbol.MethodHandleSymbol(bsm), + types.boxedTypeOrType(syms.booleanType), + new LoadableConstant[]{}); + } + + private class PrimitiveGenerator extends Types.SignatureGenerator { + + /** + * An output buffer for type signatures. + */ + StringBuilder sb = new StringBuilder(); + + PrimitiveGenerator() { + super(types); + } + + @Override + protected void append(char ch) { + sb.append(ch); + } + + @Override + protected void append(byte[] ba) { + sb.append(new String(ba)); + } + + @Override + protected void append(Name name) { + sb.append(name.toString()); + } + + @Override + public String toString() { + return sb.toString(); + } + } + + JCMethodInvocation makeApply(JCExpression selector, Name name, List args) { MethodSymbol method = rs.resolveInternalMethod( currentClassTree.pos(), env, @@ -823,7 +900,8 @@ public void resolve(VarSymbol commonBinding, } JCBindingPattern binding = (JCBindingPattern) instanceofCheck.pattern; hasUnconditional = - instanceofCheck.allowNull && + (!types.erasure(binding.type).isPrimitive() ? instanceofCheck.allowNull : + types.isUnconditionallyExact(commonNestedExpression.type, types.erasure(binding.type))) && accList.tail.isEmpty(); List newLabel; @@ -854,6 +932,7 @@ public void resolve(VarSymbol commonBinding, } JCSwitch newSwitch = make.Switch(commonNestedExpression, nestedCases.toList()); newSwitch.patternSwitch = true; + newSwitch.hasUnconditionalPattern = hasUnconditional; JCPatternCaseLabel leadingTest = (JCPatternCaseLabel) accummulator.first().labels.head; leadingTest.syntheticGuard = null; @@ -930,16 +1009,20 @@ public void resolve(VarSymbol commonBinding, } private Type principalType(JCTree p) { - return types.boxedTypeOrType(types.erasure(TreeInfo.primaryPatternType(p))); + return types.erasure(TreeInfo.primaryPatternType(p)); } private LoadableConstant toLoadableConstant(JCCaseLabel l, Type selector) { if (l.hasTag(Tag.PATTERNCASELABEL)) { Type principalType = principalType(((JCPatternCaseLabel) l).pat); - if (types.isSubtype(selector, principalType)) { - return (LoadableConstant) selector; + if (((JCPatternCaseLabel) l).pat.type.isReference()) { + if (types.isSubtype(selector, principalType)) { + return (LoadableConstant) selector; + } else { + return (LoadableConstant) principalType; + } } else { - return (LoadableConstant) principalType; + return makePrimitive(l.pos(), principalType); } } else if (l.hasTag(Tag.CONSTANTCASELABEL) && !TreeInfo.isNullCaseLabel(l)) { JCExpression expr = ((JCConstantCaseLabel) l).expr; @@ -954,8 +1037,11 @@ private LoadableConstant toLoadableConstant(JCCaseLabel l, Type selector) { Assert.checkNonNull(expr.type.constValue()); return switch (expr.type.getTag()) { - case BYTE, CHAR, - SHORT, INT -> LoadableConstant.Int((Integer) expr.type.constValue()); + case BOOLEAN -> makeBooleanConstant(l.pos(), (Integer) expr.type.constValue()); + case BYTE, CHAR, SHORT, INT -> LoadableConstant.Int((Integer) expr.type.constValue()); + case LONG -> LoadableConstant.Long((Long) expr.type.constValue()); + case FLOAT -> LoadableConstant.Float((Float) expr.type.constValue()); + case DOUBLE -> LoadableConstant.Double((Double) expr.type.constValue()); case CLASS -> LoadableConstant.String((String) expr.type.constValue()); default -> throw new AssertionError(); }; diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacTypes.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacTypes.java index 08d5e785a3c..1bc5de7f73a 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacTypes.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacTypes.java @@ -134,7 +134,7 @@ public TypeMirror erasure(TypeMirror t) { TypeKind kind = t.getKind(); if (kind == TypeKind.PACKAGE || kind == TypeKind.MODULE) throw new IllegalArgumentException(t.toString()); - return types.erasure((Type)t).stripMetadataIfNeeded(); + return types.erasure((Type)t).stripMetadata(); } @DefinedBy(Api.LANGUAGE_MODEL) @@ -155,7 +155,7 @@ public PrimitiveType unboxedType(TypeMirror t) { @DefinedBy(Api.LANGUAGE_MODEL) public TypeMirror capture(TypeMirror t) { validateTypeNotIn(t, EXEC_OR_PKG_OR_MOD); - return types.capture((Type)t).stripMetadataIfNeeded(); + return types.capture((Type)t).stripMetadata(); } @DefinedBy(Api.LANGUAGE_MODEL) @@ -304,6 +304,13 @@ public TypeMirror asMemberOf(DeclaredType containing, Element element) { } + @DefinedBy(Api.LANGUAGE_MODEL) + @SuppressWarnings("unchecked") + public T stripAnnotations(T t) { + return (T)((Type) t).stripMetadata(); + } + + private static final Set EXEC_OR_PKG_OR_MOD = EnumSet.of(TypeKind.EXECUTABLE, TypeKind.PACKAGE, TypeKind.MODULE); diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties index c4f00d9d46e..2a472b37181 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties @@ -549,6 +549,12 @@ compiler.err.duplicate.unconditional.pattern=\ compiler.err.unconditional.pattern.and.default=\ switch has both an unconditional pattern and a default label +compiler.err.unconditional.pattern.and.both.boolean.values=\ + switch has both boolean values and an unconditional pattern + +compiler.err.default.and.both.boolean.values=\ + switch has both boolean values and a default label + compiler.err.guard.not.allowed=\ guards are only allowed for case with a pattern @@ -563,10 +569,6 @@ compiler.err.cannot.assign.not.declared.guard=\ compiler.err.constant.label.not.compatible=\ constant label of type {0} is not compatible with switch selector type {1} -# 0: type -compiler.err.selector.type.not.allowed=\ - selector type {0} is not allowed - compiler.err.flows.through.to.pattern=\ illegal fall-through to a pattern @@ -2665,10 +2667,6 @@ compiler.warn.prob.found.req=\ compiler.misc.inconvertible.types=\ {0} cannot be converted to {1} -# 0: type, 1: type -compiler.misc.not.applicable.types=\ - pattern of type {1} is not applicable at {0} - # 0: type, 1: type compiler.misc.possible.loss.of.precision=\ possible lossy conversion from {0} to {1} @@ -3200,6 +3198,9 @@ compiler.misc.feature.deconstruction.patterns=\ compiler.misc.feature.unnamed.variables=\ unnamed variables +compiler.misc.feature.primitive.patterns=\ + primitive patterns + compiler.misc.feature.records=\ records diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCICompilerFactory.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCICompilerFactory.java deleted file mode 100644 index 94c2594a719..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCICompilerFactory.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2016, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.runtime.JVMCICompilerFactory; - -/** - * HotSpot extensions to {@link JVMCICompilerFactory}. - */ -public abstract class HotSpotJVMCICompilerFactory implements JVMCICompilerFactory { - - public enum CompilationLevelAdjustment { - /** - * No adjustment. - */ - None, - - /** - * Adjust based on declaring class of method. - */ - ByHolder, - - /** - * Adjust based on declaring class, name and signature of method. - */ - ByFullSignature - } - - /** - * Determines if this object may want to adjust the compilation level for a method that is being - * scheduled by the VM for compilation. - */ - public CompilationLevelAdjustment getCompilationLevelAdjustment() { - return CompilationLevelAdjustment.None; - } - - public enum CompilationLevel { - None, - Simple, - LimitedProfile, - FullProfile, - FullOptimization - } - - /** - * Potentially modifies the compilation level currently selected by the VM compilation policy - * for a method. - * - * @param declaringClass the class in which the method is declared. This value is either a - * {@code Class} instance or a {@code String} representing the - * {@link JavaType#toJavaName() name} of the class. - * @param name the name of the method or {@code null} depending on the value that was returned - * by {@link #getCompilationLevelAdjustment()} - * @param signature the signature of the method or {@code null} depending on the value that was - * returned by {@link #getCompilationLevelAdjustment()} - * @param isOsr specifies if the compilation being scheduled in an OSR compilation - * @param level the compilation level currently selected by the VM compilation policy - * @return the compilation level to use for the compilation being scheduled (must be a valid - * {@code CompLevel} enum value) - */ - public CompilationLevel adjustCompilationLevel(Object declaringClass, String name, String signature, boolean isOsr, CompilationLevel level) { - throw new InternalError(getClass().getName() + " must override adjustCompilationLevel(...) since it returned a value other than " + CompilationLevel.class.getName() + "." + - CompilationLevel.None + " from getCompilationLevelAdjustment()"); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java index aa4d48b720e..56c684b5e54 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java @@ -23,7 +23,6 @@ package jdk.vm.ci.hotspot; import static jdk.vm.ci.common.InitTimer.timer; -import static jdk.vm.ci.hotspot.HotSpotJVMCICompilerFactory.CompilationLevelAdjustment.None; import static jdk.vm.ci.services.Services.IS_BUILDING_NATIVE_IMAGE; import static jdk.vm.ci.services.Services.IS_IN_NATIVE_IMAGE; @@ -468,7 +467,6 @@ public static JavaKind getHostWordKind() { private final JVMCIBackend hostBackend; private final JVMCICompilerFactory compilerFactory; - private final HotSpotJVMCICompilerFactory hsCompilerFactory; private volatile JVMCICompiler compiler; protected final HotSpotJVMCIReflection reflection; @@ -572,18 +570,6 @@ private HotSpotJVMCIRuntime() { } compilerFactory = HotSpotJVMCICompilerConfig.getCompilerFactory(this); - if (compilerFactory instanceof HotSpotJVMCICompilerFactory) { - hsCompilerFactory = (HotSpotJVMCICompilerFactory) compilerFactory; - if (hsCompilerFactory.getCompilationLevelAdjustment() != None) { - String name = HotSpotJVMCICompilerFactory.class.getName(); - String msg = String.format("%s.getCompilationLevelAdjustment() is no longer supported. " + - "Use %s.excludeFromJVMCICompilation() instead.", name, name); - throw new UnsupportedOperationException(msg); - } - } else { - hsCompilerFactory = null; - } - if (config.getFlag("JVMCIPrintProperties", Boolean.class)) { if (vmLogStream == null) { vmLogStream = new PrintStream(getLogStream()); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets_de.properties b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets_de.properties index 0c3068cd666..242be92fc8c 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets_de.properties +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets_de.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2010, 2023, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2010, 2024, 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 @@ -222,8 +222,9 @@ doclet.Modifier=Modifizierer doclet.Type=Typ doclet.Modifier_and_Type=Modifizierer und Typ doclet.Implementation=Implementierung(en): -doclet.search=SEARCH +doclet.search=Suchen doclet.search_placeholder=Suchen +doclet.search_in_documentation=In Dokumentation suchen doclet.search_reset=Zurücksetzen doclet.Field=Feld doclet.Property=Eigenschaft @@ -237,9 +238,16 @@ doclet.Enum_Constant=Enum-Konstante doclet.Description=Beschreibung doclet.ConstantField=Konstantenfeld doclet.Value=Wert +doclet.table_of_contents=Inhaltsverzeichnis +doclet.hide_sidebar=Randleiste ausblenden +doclet.show_sidebar=Randleiste einblenden +doclet.filter_label=Filter +doclet.filter_table_of_contents=Inhaltsverzeichnis filtern +doclet.filter_reset=Zurücksetzen doclet.linkMismatch_PackagedLinkedtoModule=Der Code, der dokumentiert wird, verwendet Packages im unbenannten Modul, aber die in {0} definierten Packages befinden sich in benannten Modulen. doclet.linkMismatch_ModuleLinkedtoPackage=Der Code, der dokumentiert wird, verwendet Module, aber die in {0} definierten Packages befinden sich im unbenannten Modul. doclet.urlRedirected=URL {0} wurde umgeleitet an {1} - Aktualisieren Sie die Befehlszeilenoptionen, um diese Warnung zu unterdrücken. +doclet.unexpectedRedirect=Unerwartete Umleitung für URL {0} zu {1} doclet.duplicate.comment.for.property=Doppelter Kommentar für Eigenschaft.\nEntfernen Sie den Kommentar auf dem Eigenschaftsfeld oder in dieser Methode, um diese Warnung zu unterdrücken. #Documentation for Enums diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets_ja.properties b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets_ja.properties index cb4c5fa9b39..986d3affe1f 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets_ja.properties +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets_ja.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2010, 2023, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2010, 2024, 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 @@ -222,8 +222,9 @@ doclet.Modifier=修飾子 doclet.Type=タイプ doclet.Modifier_and_Type=修飾子とタイプ doclet.Implementation=実装: -doclet.search=SEARCH +doclet.search=検索 doclet.search_placeholder=検索 +doclet.search_in_documentation=ドキュメントで検索 doclet.search_reset=リセット doclet.Field=フィールド doclet.Property=プロパティ @@ -237,9 +238,16 @@ doclet.Enum_Constant=列挙型定数 doclet.Description=説明 doclet.ConstantField=定数フィールド doclet.Value=値 +doclet.table_of_contents=目次 +doclet.hide_sidebar=サイドバーの非表示 +doclet.show_sidebar=サイドバーの表示 +doclet.filter_label=フィルタ +doclet.filter_table_of_contents=目次のフィルタ +doclet.filter_reset=リセット doclet.linkMismatch_PackagedLinkedtoModule=ドキュメント化しようとしているコードでは名前のないモジュールのパッケージが使用されていますが、{0}で定義されているパッケージは名前のあるモジュールのものです。 doclet.linkMismatch_ModuleLinkedtoPackage=ドキュメント化しようとしているコードではモジュールが使用されていますが、{0}で定義されているパッケージは名前のないモジュールのものです。 doclet.urlRedirected=URL {0}は{1}にリダイレクトされました -- コマンドライン・オプションを更新してこの警告を表示しないようにしてください。 +doclet.unexpectedRedirect=URL {0}から{1}への予期しないリダイレクト doclet.duplicate.comment.for.property=プロパティのコメントが重複して\nいます。プロパティ・フィールドまたはこのメソッドのコメントを削除してこの警告を出さないようにしてください。 #Documentation for Enums diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets_zh_CN.properties b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets_zh_CN.properties index 9618d8f12b7..99a31b3eec5 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets_zh_CN.properties +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets_zh_CN.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2010, 2023, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2010, 2024, 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 @@ -222,8 +222,9 @@ doclet.Modifier=限定符 doclet.Type=类型 doclet.Modifier_and_Type=修饰符和类型 doclet.Implementation=实现: -doclet.search=SEARCH +doclet.search=搜索 doclet.search_placeholder=搜索 +doclet.search_in_documentation=在文档中搜索 doclet.search_reset=重置 doclet.Field=字段 doclet.Property=属性 @@ -237,9 +238,16 @@ doclet.Enum_Constant=枚举常量 doclet.Description=说明 doclet.ConstantField=常量字段 doclet.Value=值 +doclet.table_of_contents=目录 +doclet.hide_sidebar=隐藏子工具栏 +doclet.show_sidebar=显示子工具栏 +doclet.filter_label=筛选器 +doclet.filter_table_of_contents=筛选目录 +doclet.filter_reset=重置 doclet.linkMismatch_PackagedLinkedtoModule=进行文档化的代码使用了未命名模块中的程序包,但在 {0} 中定义的程序包在命名模块中。 doclet.linkMismatch_ModuleLinkedtoPackage=进行文档化的代码使用了模块,但在 {0} 中定义的程序包在未命名模块中。 doclet.urlRedirected=URL {0} 已重定向到 {1} — 更新命令行选项以隐藏此警告。 +doclet.unexpectedRedirect=URL {0} 意外重定向到 {1} doclet.duplicate.comment.for.property=属性注释重复。\n删除属性字段或此方法的注释以隐藏此警告。 #Documentation for Enums diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolEnvironment.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolEnvironment.java index 4b1e1c66258..5eed7cd9268 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolEnvironment.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolEnvironment.java @@ -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 @@ -31,6 +31,7 @@ import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; import javax.lang.model.util.Elements; +import javax.lang.model.type.TypeKind; import javax.tools.JavaFileManager; import javax.tools.JavaFileObject; import javax.tools.JavaFileObject.Kind; @@ -181,6 +182,8 @@ void setElementToTreePath(Element e, TreePath tree) { } public Kind getFileKind(TypeElement te) { + if (te.asType().getKind() == TypeKind.ERROR) + return Kind.OTHER; JavaFileObject jfo = ((ClassSymbol)te).outermostClass().classfile; return jfo == null ? Kind.SOURCE : jfo.getKind(); } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc_de.properties b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc_de.properties index 5604ec0d81b..f8c3c086390 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc_de.properties +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc_de.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2024, 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 @@ -32,6 +32,12 @@ main.warning={0} Warnung main.usage=Verwendung:\n javadoc [options] [packagenames] [sourcefiles] [@files]\nmit folgenden Optionen: +main.did-you-mean=Meinten Sie: {0} + +main.did-you-mean-one-of=Meinten Sie eine der folgenden Optionen: {0} + +main.for-more-details-see-usage=Weitere Einzelheiten zu den verfügbaren Optionen finden Sie mit "--help" oder "--help-extra" + main.opt.at.arg= main.opt.at.desc=Liest Optionen und Dateinamen aus Datei diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc_ja.properties b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc_ja.properties index a6599cc3e7e..725497fecab 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc_ja.properties +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc_ja.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2024, 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 @@ -32,6 +32,12 @@ main.warning=警告{0}個 main.usage=使用方法:\n javadoc [options] [packagenames] [sourcefiles] [@files]\nオプションは次のとおりです: +main.did-you-mean=もしかして: {0} + +main.did-you-mean-one-of=もしかして次のいずれかですか: {0} + +main.for-more-details-see-usage=使用可能なオプションの詳細を確認するには、--helpまたは--help-extraを使用してください + main.opt.at.arg= main.opt.at.desc=ファイルからの読取りオプションおよびファイル名 diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc_zh_CN.properties b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc_zh_CN.properties index ab38afe183b..41d065f5b1c 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc_zh_CN.properties +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc_zh_CN.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2024, 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 @@ -32,6 +32,12 @@ main.warning={0} 个警告 main.usage=用法:\n javadoc [options] [packagenames] [sourcefiles] [@files]\n其中, 选项包括: +main.did-you-mean=您要查找的是:{0} + +main.did-you-mean-one-of=您要查找的是以下项之一:{0} + +main.for-more-details-see-usage=有关可用选项的更多详细信息,请使用 --help 或 --help-extra + main.opt.at.arg= main.opt.at.desc=从文件读取选项和文件名 diff --git a/src/jdk.jshell/share/classes/jdk/jshell/CompletenessAnalyzer.java b/src/jdk.jshell/share/classes/jdk/jshell/CompletenessAnalyzer.java index 663ca164a3d..e2a5446393b 100644 --- a/src/jdk.jshell/share/classes/jdk/jshell/CompletenessAnalyzer.java +++ b/src/jdk.jshell/share/classes/jdk/jshell/CompletenessAnalyzer.java @@ -209,14 +209,14 @@ static enum TK { THROWS(TokenKind.THROWS, XDECL|XBRACESNEEDED), // throws // Primarive type names - BOOLEAN(TokenKind.BOOLEAN, XEXPR1|XDECL1), // boolean - BYTE(TokenKind.BYTE, XEXPR1|XDECL1), // byte - CHAR(TokenKind.CHAR, XEXPR1|XDECL1), // char - DOUBLE(TokenKind.DOUBLE, XEXPR1|XDECL1), // double - FLOAT(TokenKind.FLOAT, XEXPR1|XDECL1), // float - INT(TokenKind.INT, XEXPR1|XDECL1), // int - LONG(TokenKind.LONG, XEXPR1|XDECL1), // long - SHORT(TokenKind.SHORT, XEXPR1|XDECL1), // short + BOOLEAN(TokenKind.BOOLEAN, XEXPR1|XDECL1|XTERM), // boolean + BYTE(TokenKind.BYTE, XEXPR1|XDECL1|XTERM), // byte + CHAR(TokenKind.CHAR, XEXPR1|XDECL1|XTERM), // char + DOUBLE(TokenKind.DOUBLE, XEXPR1|XDECL1|XTERM), // double + FLOAT(TokenKind.FLOAT, XEXPR1|XDECL1|XTERM), // float + INT(TokenKind.INT, XEXPR1|XDECL1|XTERM), // int + LONG(TokenKind.LONG, XEXPR1|XDECL1|XTERM), // long + SHORT(TokenKind.SHORT, XEXPR1|XDECL1|XTERM), // short VOID(TokenKind.VOID, XEXPR1|XDECL1), // void // Modifiers keywords @@ -805,8 +805,24 @@ public Completeness parseExpressionOptionalSemi() { } public Completeness parseExpression() { - while (token.kind.isExpression()) + while (token.kind.isExpression()) { + CT prevToken = in.prevCT; nextToken(); + // primitive types can only appear in the end of an `instanceof` expression + switch (token.kind) { + case EOF: + switch (in.prevCT.kind) { + case BYTE, SHORT, CHAR, INT, LONG, FLOAT, DOUBLE, BOOLEAN: + switch (prevToken.kind) { + case INSTANCEOF: + return Completeness.COMPLETE; + default: + return Completeness.DEFINITELY_INCOMPLETE; + } + } + } + } + return Completeness.COMPLETE; } diff --git a/src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c b/src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c index 3183d8ef9a1..5b978ba38e1 100644 --- a/src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c +++ b/src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -105,6 +105,12 @@ static jlong get_total_or_available_swap_space_size(JNIEnv* env, jboolean availa throw_internal_error(env, "sysctlbyname failed"); } return available ? (jlong)vmusage.xsu_avail : (jlong)vmusage.xsu_total; +#elif defined(_AIX) + perfstat_memory_total_t memory_info; + if (perfstat_memory_total(NULL, &memory_info, sizeof(perfstat_memory_total_t), 1) == -1) { + throw_internal_error(env, "perfstat_memory_total failed"); + } + return available ? (jlong)(memory_info.pgsp_free * 4L * 1024L) : (jlong)(memory_info.pgsp_total * 4L * 1024L); #else /* _ALLBSD_SOURCE */ /* * XXXBSD: there's no way available to get swap info in diff --git a/test/hotspot/gtest/compiler/test_directivesParser.cpp b/test/hotspot/gtest/compiler/test_directivesParser.cpp index 12180e7d643..2e36e09ccc1 100644 --- a/test/hotspot/gtest/compiler/test_directivesParser.cpp +++ b/test/hotspot/gtest/compiler/test_directivesParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, 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 @@ -35,7 +35,7 @@ class DirectivesParserTest : public ::testing::Test{ ResourceMark rm; stringStream stream; // These tests require the "C" locale to correctly parse decimal values - DirectivesParserTest() : _locale(setlocale(LC_NUMERIC, NULL)) { + DirectivesParserTest() : _locale(setlocale(LC_NUMERIC, nullptr)) { setlocale(LC_NUMERIC, "C"); } ~DirectivesParserTest() { diff --git a/test/hotspot/gtest/gc/g1/test_freeRegionList.cpp b/test/hotspot/gtest/gc/g1/test_freeRegionList.cpp index a32fcdea938..1ad21b0d9a0 100644 --- a/test/hotspot/gtest/gc/g1/test_freeRegionList.cpp +++ b/test/hotspot/gtest/gc/g1/test_freeRegionList.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ TEST_VM(FreeRegionList, length) { // Create a fake heap. It does not need to be valid, as the HeapRegion constructor // does not access it. - MemRegion heap(NULL, num_regions_in_test * HeapRegion::GrainWords); + MemRegion heap(nullptr, num_regions_in_test * HeapRegion::GrainWords); // Allocate a fake BOT because the HeapRegion constructor initializes // the BOT. diff --git a/test/hotspot/gtest/gc/g1/test_g1CardSet.cpp b/test/hotspot/gtest/gc/g1/test_g1CardSet.cpp index f788ba996da..c455deacb26 100644 --- a/test/hotspot/gtest/gc/g1/test_g1CardSet.cpp +++ b/test/hotspot/gtest/gc/g1/test_g1CardSet.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, 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 @@ -50,7 +50,7 @@ class G1CardSetTest : public ::testing::Test { static uint _max_workers; static WorkerThreads* workers() { - if (_workers == NULL) { + if (_workers == nullptr) { _max_workers = os::processor_count(); _workers = new WorkerThreads("G1CardSetTest Workers", _max_workers); _workers->initialize_workers(); @@ -87,7 +87,7 @@ class G1CardSetTest : public ::testing::Test { static void iterate_cards(G1CardSet* card_set, G1CardSet::CardClosure* cl); }; -WorkerThreads* G1CardSetTest::_workers = NULL; +WorkerThreads* G1CardSetTest::_workers = nullptr; uint G1CardSetTest::_max_workers = 0; void G1CardSetTest::add_cards(G1CardSet* card_set, uint cards_per_region, uint* cards, uint num_cards, G1AddCardResult* results) { @@ -97,7 +97,7 @@ void G1CardSetTest::add_cards(G1CardSet* card_set, uint cards_per_region, uint* uint card_idx = cards[i] % cards_per_region; G1AddCardResult res = card_set->add_card(region_idx, card_idx); - if (results != NULL) { + if (results != nullptr) { ASSERT_TRUE(res == results[i]); } } @@ -269,7 +269,7 @@ void G1CardSetTest::cardset_basic_test() { translate_cards(CardsPerRegion, 100, &cards1[0], 4); translate_cards(CardsPerRegion, 990, &cards1[4], 4); - add_cards(&card_set, CardsPerRegion, cards1, ARRAY_SIZE(cards1), NULL); + add_cards(&card_set, CardsPerRegion, cards1, ARRAY_SIZE(cards1), nullptr); contains_cards(&card_set, CardsPerRegion, cards1, ARRAY_SIZE(cards1)); ASSERT_TRUE(card_set.occupied() == ARRAY_SIZE(cards1)); @@ -291,7 +291,7 @@ void G1CardSetTest::cardset_basic_test() { cards1[i] = i + 3; translate_cards(CardsPerRegion, i, &cards1[i], 1); } - add_cards(&card_set, CardsPerRegion, cards1, ARRAY_SIZE(cards1), NULL); + add_cards(&card_set, CardsPerRegion, cards1, ARRAY_SIZE(cards1), nullptr); contains_cards(&card_set, CardsPerRegion, cards1, ARRAY_SIZE(cards1)); ASSERT_TRUE(card_set.num_containers() == ARRAY_SIZE(cards1)); diff --git a/test/hotspot/gtest/gc/g1/test_stressCommitUncommit.cpp b/test/hotspot/gtest/gc/g1/test_stressCommitUncommit.cpp index 1366ec0c34c..8ce98827ab2 100644 --- a/test/hotspot/gtest/gc/g1/test_stressCommitUncommit.cpp +++ b/test/hotspot/gtest/gc/g1/test_stressCommitUncommit.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ class G1MapperWorkers : AllStatic { static WorkerThreads* _workers; static WorkerThreads* workers() { - if (_workers == NULL) { + if (_workers == nullptr) { _workers = new WorkerThreads("G1 Small Workers", MaxWorkers); _workers->initialize_workers(); _workers->set_active_workers(MaxWorkers); @@ -48,7 +48,7 @@ class G1MapperWorkers : AllStatic { workers()->run_task(task); } }; -WorkerThreads* G1MapperWorkers::_workers = NULL; +WorkerThreads* G1MapperWorkers::_workers = nullptr; class G1TestCommitUncommit : public WorkerTask { G1RegionToSpaceMapper* _mapper; diff --git a/test/hotspot/gtest/gc/shared/test_bufferNodeAllocator.cpp b/test/hotspot/gtest/gc/shared/test_bufferNodeAllocator.cpp index 752aef02d5a..cc5254554dc 100644 --- a/test/hotspot/gtest/gc/shared/test_bufferNodeAllocator.cpp +++ b/test/hotspot/gtest/gc/shared/test_bufferNodeAllocator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, 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 @@ -62,7 +62,7 @@ TEST_VM(BufferNodeAllocatorTest, test) { for (size_t i = 0; i < node_count; ++i) { ASSERT_EQ(0u, allocator.free_count()); nodes[i] = allocator.allocate(); - ASSERT_EQ((BufferNode*)NULL, nodes[i]->next()); + ASSERT_EQ(nullptr, nodes[i]->next()); } // Release the nodes, adding them to the allocator's free list. @@ -102,7 +102,7 @@ class BufferNode::TestSupport::CompletedList { } void push(BufferNode* node) { - assert(node != NULL, "precondition"); + assert(node != nullptr, "precondition"); _completed_list.push(*node); } @@ -169,7 +169,7 @@ class BufferNode::TestSupport::ProcessorThread : public JavaTestThread { bool shutdown_requested = false; while (true) { BufferNode* node = _cbl->pop(); - if (node != NULL) { + if (node != nullptr) { _allocator->release(node); } else if (shutdown_requested) { return; diff --git a/test/hotspot/gtest/gc/shared/test_collectedHeap.cpp b/test/hotspot/gtest/gc/shared/test_collectedHeap.cpp index a308907a0a4..081eb351fc6 100644 --- a/test/hotspot/gtest/gc/shared/test_collectedHeap.cpp +++ b/test/hotspot/gtest/gc/shared/test_collectedHeap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, 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 @@ -32,8 +32,8 @@ TEST_VM(CollectedHeap, is_in) { uintptr_t epsilon = (uintptr_t) MinObjAlignment; uintptr_t outside_heap = (uintptr_t) ε - // Test that NULL is not in the heap. - ASSERT_FALSE(heap->is_in(NULL)) << "NULL is unexpectedly in the heap"; + // Test that nullptr is not in the heap. + ASSERT_FALSE(heap->is_in(nullptr)) << "null is unexpectedly in the heap"; // Test that a pointer to outside the heap start is reported as outside the heap. ASSERT_FALSE(heap->is_in((void*)outside_heap)) << "outside_heap: " << outside_heap diff --git a/test/hotspot/gtest/gc/shared/test_collectorPolicy.cpp b/test/hotspot/gtest/gc/shared/test_collectorPolicy.cpp index dfe096248c7..58ff433083c 100644 --- a/test/hotspot/gtest/gc/shared/test_collectorPolicy.cpp +++ b/test/hotspot/gtest/gc/shared/test_collectorPolicy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -73,14 +73,14 @@ class TestGenCollectorPolicy { ASSERT_NO_FATAL_FAILURE(setter1->execute()); - if (setter2 != NULL) { + if (setter2 != nullptr) { ASSERT_NO_FATAL_FAILURE(setter2->execute()); } ASSERT_NO_FATAL_FAILURE(checker->execute()); } static void test(Executor* setter, Executor* checker) { - test(setter, NULL, checker); + test(setter, nullptr, checker); } }; diff --git a/test/hotspot/gtest/gc/shared/test_oopStorage.cpp b/test/hotspot/gtest/gc/shared/test_oopStorage.cpp index 30e39888e0a..6758c61325a 100644 --- a/test/hotspot/gtest/gc/shared/test_oopStorage.cpp +++ b/test/hotspot/gtest/gc/shared/test_oopStorage.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -104,13 +104,13 @@ typedef TestAccess::Block OopBlock; typedef TestAccess::AllocationList AllocationList; typedef TestAccess::ActiveArray ActiveArray; -// Using EXPECT_EQ can't use NULL directly. Otherwise AIX build breaks. -const OopBlock* const NULL_BLOCK = NULL; +// Using EXPECT_EQ can't use nullptr directly. Otherwise AIX build breaks. +const OopBlock* const NULL_BLOCK = nullptr; static size_t list_length(const AllocationList& list) { size_t result = 0; for (const OopBlock* block = list.chead(); - block != NULL; + block != nullptr; block = list.next(*block)) { ++result; } @@ -119,14 +119,14 @@ static size_t list_length(const AllocationList& list) { static void clear_list(AllocationList& list) { OopBlock* next; - for (OopBlock* block = list.head(); block != NULL; block = next) { + for (OopBlock* block = list.head(); block != nullptr; block = next) { next = list.next(*block); list.unlink(*block); } } static bool is_list_empty(const AllocationList& list) { - return list.chead() == NULL; + return list.chead() == nullptr; } static bool process_deferred_updates(OopStorage& storage) { @@ -139,7 +139,7 @@ static bool process_deferred_updates(OopStorage& storage) { } static void release_entry(OopStorage& storage, oop* entry, bool process_deferred = true) { - *entry = NULL; + *entry = nullptr; storage.release(entry); if (process_deferred) { process_deferred_updates(storage); @@ -150,7 +150,7 @@ static size_t empty_block_count(const OopStorage& storage) { const AllocationList& list = TestAccess::allocation_list(storage); size_t count = 0; for (const OopBlock* block = list.ctail(); - (block != NULL) && block->is_empty(); + (block != nullptr) && block->is_empty(); ++count, block = list.prev(*block)) {} return count; @@ -164,7 +164,7 @@ static OopBlock* active_head(const OopStorage& storage) { ActiveArray& ba = TestAccess::active_array(storage); size_t count = ba.block_count(); if (count == 0) { - return NULL; + return nullptr; } else { return ba.at(count - 1); } @@ -203,7 +203,7 @@ class OopStorageTestWithAllocation : public OopStorageTest { OopStorageTestWithAllocation::OopStorageTestWithAllocation() { for (size_t i = 0; i < _max_entries; ++i) { _entries[i] = storage().allocate(); - EXPECT_TRUE(_entries[i] != NULL); + EXPECT_TRUE(_entries[i] != nullptr); EXPECT_EQ(i + 1, storage().allocation_count()); } }; @@ -215,8 +215,8 @@ static bool is_allocation_list_sorted(const OopStorage& storage) { // blocks are segregated to the end of the list. const AllocationList& list = TestAccess::allocation_list(storage); const OopBlock* block = list.ctail(); - for ( ; (block != NULL) && block->is_empty(); block = list.prev(*block)) {} - for ( ; block != NULL; block = list.prev(*block)) { + for ( ; (block != nullptr) && block->is_empty(); block = list.prev(*block)) {} + for ( ; block != nullptr; block = list.prev(*block)) { if (block->is_empty()) { return false; } @@ -239,7 +239,7 @@ TEST_VM_F(OopStorageTest, allocate_one) { EXPECT_TRUE(is_list_empty(TestAccess::allocation_list(storage()))); oop* ptr = storage().allocate(); - EXPECT_TRUE(ptr != NULL); + EXPECT_TRUE(ptr != nullptr); EXPECT_EQ(1u, storage().allocation_count()); EXPECT_EQ(1u, active_count(storage())); @@ -249,7 +249,7 @@ TEST_VM_F(OopStorageTest, allocate_one) { EXPECT_EQ(0u, empty_block_count(storage())); const OopBlock* block = TestAccess::allocation_list(storage()).chead(); - EXPECT_NE(block, (OopBlock*)NULL); + EXPECT_NE(block, (OopBlock*)nullptr); EXPECT_EQ(block, active_head(storage())); EXPECT_FALSE(TestAccess::block_is_empty(*block)); EXPECT_FALSE(TestAccess::block_is_full(*block)); @@ -326,7 +326,7 @@ TEST_VM_F(OopStorageTest, allocate_many) { EXPECT_EQ(0u, empty_block_count(storage())); entries[0] = storage().allocate(); - ASSERT_TRUE(entries[0] != NULL); + ASSERT_TRUE(entries[0] != nullptr); EXPECT_EQ(1u, active_count(storage())); EXPECT_EQ(1u, storage().block_count()); EXPECT_EQ(1u, list_length(allocation_list)); @@ -339,10 +339,10 @@ TEST_VM_F(OopStorageTest, allocate_many) { for (size_t i = 1; i < max_entries; ++i) { entries[i] = storage().allocate(); EXPECT_EQ(i + 1, storage().allocation_count()); - ASSERT_TRUE(entries[i] != NULL); + ASSERT_TRUE(entries[i] != nullptr); EXPECT_EQ(0u, empty_block_count(storage())); - if (block == NULL) { + if (block == nullptr) { ASSERT_FALSE(is_list_empty(allocation_list)); EXPECT_EQ(1u, list_length(allocation_list)); block = allocation_list.chead(); @@ -350,7 +350,7 @@ TEST_VM_F(OopStorageTest, allocate_many) { EXPECT_EQ(block, active_head(storage())); } else if (TestAccess::block_is_full(*block)) { EXPECT_TRUE(is_list_empty(allocation_list)); - block = NULL; + block = nullptr; } else { EXPECT_FALSE(is_list_empty(allocation_list)); EXPECT_EQ(block, allocation_list.chead()); @@ -358,7 +358,7 @@ TEST_VM_F(OopStorageTest, allocate_many) { } } - if (block != NULL) { + if (block != nullptr) { EXPECT_NE(0u, TestAccess::block_allocation_count(*block)); EXPECT_FALSE(is_list_empty(allocation_list)); EXPECT_EQ(block, allocation_list.chead()); @@ -375,7 +375,7 @@ TEST_VM_F(OopStorageTest, allocate_many) { EXPECT_EQ(active_count(storage()), storage().block_count()); EXPECT_EQ(active_count(storage()), empty_block_count(storage())); for (const OopBlock* block = allocation_list.chead(); - block != NULL; + block != nullptr; block = allocation_list.next(*block)) { EXPECT_TRUE(TestAccess::block_is_empty(*block)); } @@ -395,9 +395,9 @@ TEST_VM_F(OopStorageTestWithAllocation, random_release) { // Release all entries in "random" order. size_t released = 0; for (size_t i = 0; released < _max_entries; i = (i + step) % _max_entries) { - if (_entries[i] != NULL) { + if (_entries[i] != nullptr) { release_entry(storage(), _entries[i]); - _entries[i] = NULL; + _entries[i] = nullptr; ++released; EXPECT_EQ(_max_entries - released, total_allocation_count(storage())); EXPECT_TRUE(is_allocation_list_sorted(storage())); @@ -427,9 +427,9 @@ TEST_VM_F(OopStorageTestWithAllocation, random_allocate_release) { size_t released = 0; size_t total_released = 0; for (size_t i = 0; released < _max_entries; i = (i + release_step) % _max_entries) { - if (_entries[i] != NULL) { + if (_entries[i] != nullptr) { release_entry(storage(), _entries[i]); - _entries[i] = NULL; + _entries[i] = nullptr; ++released; ++total_released; EXPECT_EQ(_max_entries - released, total_allocation_count(storage())); @@ -458,7 +458,7 @@ class OopStorageTestBlockRelease : public OopStorageTestWithAllocation { for (size_t i = 0; i < nrelease; ++i) { to_release[i] = _entries[2 * i]; - *to_release[i] = NULL; + *to_release[i] = nullptr; } if (sorted) { QuickSort::sort(to_release, nrelease, PointerCompare(), false); @@ -509,7 +509,7 @@ TEST_VM_F(OopStorageTest, bulk_allocation) { EXPECT_EQ(OopStorage::ALLOCATED_ENTRY, storage().allocation_status(entries[i])); } for (size_t i = allocated; i < max_entries; ++i) { - EXPECT_EQ(NULL, entries[i]); + EXPECT_EQ(nullptr, entries[i]); } storage().release(entries, allocated); EXPECT_EQ(0u, storage().allocation_count()); @@ -546,14 +546,14 @@ class OopStorageTest::CountingIterateClosure { void do_oop(const oop* ptr) { ++_const_count; - if (*ptr != NULL) { + if (*ptr != nullptr) { ++_const_non_null; } } void do_oop(oop* ptr) { ++_non_const_count; - if (*ptr != NULL) { + if (*ptr != nullptr) { ++_non_const_non_null; } } @@ -595,7 +595,7 @@ TEST_VM_F(OopStorageTest, simple_iterate) { for (size_t i = 0; i < max_entries; i += 10) { for ( ; allocated < i; ++allocated) { entries[allocated] = storage().allocate(); - ASSERT_TRUE(entries[allocated] != NULL); + ASSERT_TRUE(entries[allocated] != nullptr); if ((allocated % 3) != 0) { *entries[allocated] = dummy_oop; ++entries_with_values; @@ -872,10 +872,10 @@ class OopStorageTestParIteration : public OopStorageTestIteration { static WorkerThreads* _workers; }; -WorkerThreads* OopStorageTestParIteration::_workers = NULL; +WorkerThreads* OopStorageTestParIteration::_workers = nullptr; WorkerThreads* OopStorageTestParIteration::workers() { - if (_workers == NULL) { + if (_workers == nullptr) { _workers = new WorkerThreads("OopStorageTestParIteration workers", _max_workers); _workers->initialize_workers(); _workers->set_active_workers(_max_workers); @@ -1074,7 +1074,7 @@ TEST_VM_F(OopStorageTest, usage_info) { while (storage().block_count() == this_count) { ASSERT_GT(ARRAY_SIZE(entries), allocated); entries[allocated] = storage().allocate(); - ASSERT_TRUE(entries[allocated] != NULL); + ASSERT_TRUE(entries[allocated] != nullptr); ++allocated; } EXPECT_NE(0u, storage().block_count()); @@ -1092,13 +1092,13 @@ TEST_VM_F(OopStorageTestWithAllocation, print_storage) { for (size_t i = 0; i < (_max_entries / 2); ++i) { // Deferred updates don't affect print output. release_entry(storage(), _entries[i], false); - _entries[i] = NULL; + _entries[i] = nullptr; } // Release every other remaining for (size_t i = _max_entries / 2; i < _max_entries; i += 2) { // Deferred updates don't affect print output. release_entry(storage(), _entries[i], false); - _entries[i] = NULL; + _entries[i] = nullptr; } size_t expected_entries = _max_entries / 4; diff --git a/test/hotspot/gtest/gc/shared/test_oopStorage_parperf.cpp b/test/hotspot/gtest/gc/shared/test_oopStorage_parperf.cpp index 905859af80b..8df179eaac3 100644 --- a/test/hotspot/gtest/gc/shared/test_oopStorage_parperf.cpp +++ b/test/hotspot/gtest/gc/shared/test_oopStorage_parperf.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, 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 @@ -74,10 +74,10 @@ class OopStorageParIterPerf : public ::testing::Test { oop* _entries[_storage_entries]; }; -WorkerThreads* OopStorageParIterPerf::_workers = NULL; +WorkerThreads* OopStorageParIterPerf::_workers = nullptr; WorkerThreads* OopStorageParIterPerf::workers() const { - if (_workers == NULL) { + if (_workers == nullptr) { WorkerThreads* wg = new WorkerThreads("OopStorageParIterPerf workers", _num_workers); wg->initialize_workers(); wg->set_active_workers(_num_workers); @@ -126,7 +126,7 @@ class OopStorageParIterPerf::Task : public WorkerTask { public: Task(OopStorage* storage, OopClosure* closure, uint nthreads) : WorkerTask("OopStorageParIterPerf::Task"), - _worker_times(NULL), + _worker_times(nullptr), _state(storage, nthreads), _closure(closure) { @@ -152,7 +152,7 @@ class OopStorageParIterPerf::Task : public WorkerTask { class OopStorageParIterPerf::Closure : public OopClosure { public: - virtual void do_oop(oop* p) { guarantee(*p == NULL, "expected NULL"); } + virtual void do_oop(oop* p) { guarantee(*p == nullptr, "expected null"); } virtual void do_oop(narrowOop* p) { ShouldNotReachHere(); } }; diff --git a/test/hotspot/gtest/gc/shared/test_workerDataArray.cpp b/test/hotspot/gtest/gc/shared/test_workerDataArray.cpp index 6f612b56da7..02995e3c6ac 100644 --- a/test/hotspot/gtest/gc/shared/test_workerDataArray.cpp +++ b/test/hotspot/gtest/gc/shared/test_workerDataArray.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ class WorkerDataArrayTest : public ::testing::Test { protected: WorkerDataArrayTest() : title("Test array"), - array(NULL, title, 3), + array(nullptr, title, 3), sub_item_title("Sub item array") { array.create_thread_work_items(sub_item_title); diff --git a/test/hotspot/gtest/gc/x/test_xAddress.cpp b/test/hotspot/gtest/gc/x/test_xAddress.cpp index 4307cc53b3b..3f769dc7eea 100644 --- a/test/hotspot/gtest/gc/x/test_xAddress.cpp +++ b/test/hotspot/gtest/gc/x/test_xAddress.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, 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 @@ -123,7 +123,7 @@ TEST_F(XAddressTest, is_weak_good_or_null) { << " is_remaped: " << XAddress::is_remapped(value) \ << " is_good_or_null_or_remapped: " << XAddress::is_weak_good_or_null(value) - check_is_weak_good_or_null((uintptr_t)NULL); + check_is_weak_good_or_null((uintptr_t)nullptr); check_is_weak_good_or_null(XAddressMetadataMarked0); check_is_weak_good_or_null(XAddressMetadataMarked1); check_is_weak_good_or_null(XAddressMetadataRemapped); diff --git a/test/hotspot/gtest/gtestMain.cpp b/test/hotspot/gtest/gtestMain.cpp index 248ffdaa3ac..bc8ca29f72d 100644 --- a/test/hotspot/gtest/gtestMain.cpp +++ b/test/hotspot/gtest/gtestMain.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, 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,7 +130,7 @@ class JVMInitializerListener : public ::testing::EmptyTestEventListener { } void destroy_jvm() { - if (_jvm != NULL) { + if (_jvm != nullptr) { int ret = _jvm->DestroyJavaVM(); if (ret != 0) { fprintf(stderr, "Warning: DestroyJavaVM error %d\n", ret); @@ -151,7 +151,7 @@ static char* get_java_home_arg(int argc, char** argv) { return argv[i] + strlen("-jdk:"); } } - return NULL; + return nullptr; } static bool get_spawn_new_main_thread_arg(int argc, char** argv) { @@ -244,7 +244,7 @@ static void runUnitTestsInner(int argc, char** argv) { } char* java_home = get_java_home_arg(argc, argv); - if (java_home == NULL) { + if (java_home == nullptr) { fprintf(stderr, "ERROR: You must specify a JDK (-jdk , --jdk= or -jdk:) to use for running the unit tests.\n"); os::exit(1); } @@ -270,10 +270,10 @@ static void runUnitTestsInner(int argc, char** argv) { argv = remove_test_runner_arguments(&argc, argv); - JVMInitializerListener* jvm_listener = NULL; + JVMInitializerListener* jvm_listener = nullptr; if (is_vmassert_test || is_othervm_test) { - JavaVM* jvm = NULL; + JavaVM* jvm = nullptr; // both vmassert and other vm tests require inited jvm // but only vmassert tests disable hs_err and core file generation int ret; @@ -300,7 +300,7 @@ static void runUnitTestsInner(int argc, char** argv) { os::exit(2); } - if (jvm_listener != NULL) { + if (jvm_listener != nullptr) { jvm_listener->destroy_jvm(); } } @@ -323,8 +323,8 @@ static DWORD WINAPI thread_wrapper(void* p) { static void run_in_new_thread(const args_t* args) { HANDLE hdl; - hdl = CreateThread(NULL, STACK_SIZE, thread_wrapper, (void*)args, 0, NULL); - if (hdl == NULL) { + hdl = CreateThread(nullptr, STACK_SIZE, thread_wrapper, (void*)args, 0, nullptr); + if (hdl == nullptr) { fprintf(stderr, "Failed to create main thread\n"); os::exit(2); } @@ -351,7 +351,7 @@ static void run_in_new_thread(const args_t* args) { os::exit(2); } - if (pthread_join(tid, NULL) != 0) { + if (pthread_join(tid, nullptr) != 0) { fprintf(stderr, "Failed to join main thread\n"); os::exit(2); } diff --git a/test/hotspot/gtest/jfr/test_adaptiveSampler.cpp b/test/hotspot/gtest/jfr/test_adaptiveSampler.cpp index 0af0513bc2a..10c1c4fa65a 100644 --- a/test/hotspot/gtest/jfr/test_adaptiveSampler.cpp +++ b/test/hotspot/gtest/jfr/test_adaptiveSampler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, Datadog, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -200,7 +200,7 @@ class JfrGTestAdaptiveSampling : public ::testing::Test { }; void JfrGTestAdaptiveSampling::test(JfrGTestAdaptiveSampling::incoming inc, size_t sample_points_per_window, double error_factor, const char* const description) { - assert(description != NULL, "invariant"); + assert(description != nullptr, "invariant"); char output[1024] = "Adaptive sampling: "; strcat(output, description); fprintf(stdout, "=== %s\n", output); diff --git a/test/hotspot/gtest/jfr/test_networkUtilization.cpp b/test/hotspot/gtest/jfr/test_networkUtilization.cpp index 1fcfcf351a6..f4d8c81b3fd 100644 --- a/test/hotspot/gtest/jfr/test_networkUtilization.cpp +++ b/test/hotspot/gtest/jfr/test_networkUtilization.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, 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 @@ -123,7 +123,7 @@ namespace { public: MockJfrOSInterface() {} static int network_utilization(NetworkInterface** network_interfaces) { - *network_interfaces = NULL; + *network_interfaces = nullptr; for (std::list::const_iterator i = _interfaces.begin(); i != _interfaces.end(); ++i) { diff --git a/test/hotspot/gtest/jfr/test_threadCpuLoad.cpp b/test/hotspot/gtest/jfr/test_threadCpuLoad.cpp index b8bad0d699b..65b16270a4c 100644 --- a/test/hotspot/gtest/jfr/test_threadCpuLoad.cpp +++ b/test/hotspot/gtest/jfr/test_threadCpuLoad.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -82,14 +82,14 @@ namespace { class MockJfrJavaThreadIterator { public: - MockJavaThread* next() { return NULL; } + MockJavaThread* next() { return nullptr; } bool has_next() const { return false; } }; class MockJfrJavaThreadIteratorAdapter { public: - MockJavaThread* next() { return NULL; } + MockJavaThread* next() { return nullptr; } bool has_next() const { return false; } }; diff --git a/test/hotspot/gtest/logging/logTestFixture.cpp b/test/hotspot/gtest/logging/logTestFixture.cpp index 843e13144b9..ce64e6936e9 100644 --- a/test/hotspot/gtest/logging/logTestFixture.cpp +++ b/test/hotspot/gtest/logging/logTestFixture.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, 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 @@ -32,7 +32,7 @@ #include "unittest.hpp" #include "utilities/ostream.hpp" -LogTestFixture::LogTestFixture() : _n_snapshots(0), _configuration_snapshot(NULL) { +LogTestFixture::LogTestFixture() : _n_snapshots(0), _configuration_snapshot(nullptr) { // Set up TestLogFileName to include temp_dir, PID, testcase name and test name. const testing::TestInfo* test_info = ::testing::UnitTest::GetInstance()->current_test_info(); @@ -98,19 +98,19 @@ void LogTestFixture::restore_config() { char* decorators = str; str = strchr(str, ' '); - if (str != NULL) { + if (str != nullptr) { // This output has options. However, UL doesn't allow the options of any // output to be changed, so they cannot be modified by the tests, // and also we cannot change them here. So just mark the end of the // decorators. *str++ = '\0'; } - set_log_config(name, selection, decorators, /* options = */ NULL); + set_log_config(name, selection, decorators, /* options = */ nullptr); } } void LogTestFixture::clear_snapshot() { - if (_configuration_snapshot == NULL) { + if (_configuration_snapshot == nullptr) { return; } ASSERT_GT(_n_snapshots, size_t(0)) << "non-null array should have at least 1 element"; @@ -118,6 +118,6 @@ void LogTestFixture::clear_snapshot() { os::free(_configuration_snapshot[i]); } FREE_C_HEAP_ARRAY(char*, _configuration_snapshot); - _configuration_snapshot = NULL; + _configuration_snapshot = nullptr; _n_snapshots = 0; } diff --git a/test/hotspot/gtest/logging/logTestUtils.inline.hpp b/test/hotspot/gtest/logging/logTestUtils.inline.hpp index 7b36b80f46e..93cace9c689 100644 --- a/test/hotspot/gtest/logging/logTestUtils.inline.hpp +++ b/test/hotspot/gtest/logging/logTestUtils.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ static const char* invalid_selection_substr[] = { }; static inline bool string_contains_substring(const char* haystack, const char* needle) { - return strstr(haystack, needle) != NULL; + return strstr(haystack, needle) != nullptr; } static inline bool file_exists(const char* filename) { @@ -60,7 +60,7 @@ static inline void create_directory(const char* name) { ASSERT_FALSE(file_exists(name)) << "can't create directory: " << name << " already exists"; bool failed; #ifdef _WINDOWS - failed = !CreateDirectory(name, NULL); + failed = !CreateDirectory(name, nullptr); #else failed = mkdir(name, 0777); #endif @@ -115,16 +115,16 @@ static inline char* prepend_prefix_temp_dir(const char* prefix, const char* file } // Read a complete line from fp and return it as a resource allocated string. -// Returns NULL on EOF. +// Returns nullptr on EOF. static inline char* read_line(FILE* fp) { - assert(fp != NULL, "invalid fp"); + assert(fp != nullptr, "invalid fp"); int buflen = 512; char* buf = NEW_RESOURCE_ARRAY(char, buflen); long pos = ftell(fp); - if (pos < 0) return NULL; + if (pos < 0) return nullptr; char* ret = fgets(buf, buflen, fp); - while (ret != NULL && buf[strlen(buf) - 1] != '\n' && !feof(fp)) { + while (ret != nullptr && buf[strlen(buf) - 1] != '\n' && !feof(fp)) { // retry with a larger buffer buf = REALLOC_RESOURCE_ARRAY(char, buf, buflen, buflen * 2); buflen *= 2; @@ -139,19 +139,19 @@ static inline char* read_line(FILE* fp) { static bool file_contains_substrings_in_order(const char* filename, const char* substrs[]) { AsyncLogWriter::flush(); FILE* fp = os::fopen(filename, "r"); - assert(fp != NULL, "error opening file %s: %s", filename, os::strerror(errno)); + assert(fp != nullptr, "error opening file %s: %s", filename, os::strerror(errno)); size_t idx = 0; - while (substrs[idx] != NULL) { + while (substrs[idx] != nullptr) { ResourceMark rm; char* line = read_line(fp); - if (line == NULL) { + if (line == nullptr) { break; } - for (char* match = strstr(line, substrs[idx]); match != NULL;) { + for (char* match = strstr(line, substrs[idx]); match != nullptr;) { size_t match_len = strlen(substrs[idx]); idx++; - if (substrs[idx] == NULL) { + if (substrs[idx] == nullptr) { break; } match = strstr(match + match_len, substrs[idx]); @@ -159,10 +159,10 @@ static bool file_contains_substrings_in_order(const char* filename, const char* } fclose(fp); - return substrs[idx] == NULL; + return substrs[idx] == nullptr; } static inline bool file_contains_substring(const char* filename, const char* substr) { - const char* strs[] = {substr, NULL}; + const char* strs[] = {substr, nullptr}; return file_contains_substrings_in_order(filename, strs); } diff --git a/test/hotspot/gtest/logging/test_asynclog.cpp b/test/hotspot/gtest/logging/test_asynclog.cpp index 8573d93cdf1..fdacdbb2547 100644 --- a/test/hotspot/gtest/logging/test_asynclog.cpp +++ b/test/hotspot/gtest/logging/test_asynclog.cpp @@ -1,6 +1,6 @@ /* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, 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 @@ LOG_LEVEL_LIST bool write_to_file(const std::string& output) { FILE* f = os::fopen(TestLogFileName, "w"); - if (f != NULL) { + if (f != nullptr) { size_t sz = output.size(); size_t written = fwrite(output.c_str(), sizeof(char), output.size(), f); return fclose(f) == 0 && sz == written; @@ -146,7 +146,7 @@ TEST_VM_F(AsyncLogTest, logMessage) { ResourceMark rm; LogMessageBuffer buffer; const char* strs[MULTI_LINES + 1]; - strs[MULTI_LINES] = NULL; + strs[MULTI_LINES] = nullptr; for (int i = 0; i < MULTI_LINES; ++i) { stringStream ss; ss.print_cr("nonbreakable log message line-%02d", i); diff --git a/test/hotspot/gtest/logging/test_gcTraceTime.cpp b/test/hotspot/gtest/logging/test_gcTraceTime.cpp index 3493ff82180..1b4c76a4987 100644 --- a/test/hotspot/gtest/logging/test_gcTraceTime.cpp +++ b/test/hotspot/gtest/logging/test_gcTraceTime.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, 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 @@ -45,13 +45,13 @@ TEST_VM_F(GCTraceTimeTest, full) { { ThreadInVMfromNative tvn(JavaThread::current()); MutexLocker lock(Heap_lock); // Needed to read heap usage - GCTraceTime(Debug, gc) timer("Test GC", NULL, GCCause::_allocation_failure, true); + GCTraceTime(Debug, gc) timer("Test GC", nullptr, GCCause::_allocation_failure, true); } const char* expected[] = { "[gc,start", "] Test GC (Allocation Failure)", "[gc", "] Test GC (Allocation Failure) ", "M) ", "ms", - NULL + nullptr }; EXPECT_TRUE(file_contains_substrings_in_order(TestLogFileName, expected)); } @@ -68,13 +68,13 @@ TEST_VM_F(GCTraceTimeTest, full_multitag) { { ThreadInVMfromNative tvn(JavaThread::current()); MutexLocker lock(Heap_lock); // Needed to read heap usage - GCTraceTime(Debug, gc, ref) timer("Test GC", NULL, GCCause::_allocation_failure, true); + GCTraceTime(Debug, gc, ref) timer("Test GC", nullptr, GCCause::_allocation_failure, true); } const char* expected[] = { "[gc,ref,start", "] Test GC (Allocation Failure)", "[gc,ref", "] Test GC (Allocation Failure) ", "M) ", "ms", - NULL + nullptr }; EXPECT_TRUE(file_contains_substrings_in_order(TestLogFileName, expected)); } @@ -89,7 +89,7 @@ TEST_VM_F(GCTraceTimeTest, no_heap) { EXPECT_TRUE(gc_start_debug.is_enabled()); { - GCTraceTime(Debug, gc) timer("Test GC", NULL, GCCause::_allocation_failure, false); + GCTraceTime(Debug, gc) timer("Test GC", nullptr, GCCause::_allocation_failure, false); } const char* expected[] = { @@ -97,7 +97,7 @@ TEST_VM_F(GCTraceTimeTest, no_heap) { "[gc,start", "] Test GC (Allocation Failure)", // [2.975s][debug][gc ] Test GC (Allocation Failure) 0.026ms "[gc", "] Test GC (Allocation Failure) ", "ms", - NULL + nullptr }; EXPECT_TRUE(file_contains_substrings_in_order(TestLogFileName, expected)); @@ -120,7 +120,7 @@ TEST_VM_F(GCTraceTimeTest, no_cause) { { ThreadInVMfromNative tvn(JavaThread::current()); MutexLocker lock(Heap_lock); // Needed to read heap usage - GCTraceTime(Debug, gc) timer("Test GC", NULL, GCCause::_no_gc, true); + GCTraceTime(Debug, gc) timer("Test GC", nullptr, GCCause::_no_gc, true); } const char* expected[] = { @@ -128,7 +128,7 @@ TEST_VM_F(GCTraceTimeTest, no_cause) { "[gc,start", "] Test GC", // [2.975s][debug][gc ] Test GC 59M->59M(502M) 0.026ms "[gc", "] Test GC ", "M) ", "ms", - NULL + nullptr }; EXPECT_TRUE(file_contains_substrings_in_order(TestLogFileName, expected)); } @@ -143,7 +143,7 @@ TEST_VM_F(GCTraceTimeTest, no_heap_no_cause) { EXPECT_TRUE(gc_start_debug.is_enabled()); { - GCTraceTime(Debug, gc) timer("Test GC", NULL, GCCause::_no_gc, false); + GCTraceTime(Debug, gc) timer("Test GC", nullptr, GCCause::_no_gc, false); } const char* expected[] = { @@ -151,7 +151,7 @@ TEST_VM_F(GCTraceTimeTest, no_heap_no_cause) { "[gc,start", "] Test GC", // [2.975s][debug][gc ] Test GC 0.026ms "[gc", "] Test GC ", "ms", - NULL + nullptr }; EXPECT_TRUE(file_contains_substrings_in_order(TestLogFileName, expected)); diff --git a/test/hotspot/gtest/logging/test_log.cpp b/test/hotspot/gtest/logging/test_log.cpp index 2b534fd7f33..d05254f10f7 100644 --- a/test/hotspot/gtest/logging/test_log.cpp +++ b/test/hotspot/gtest/logging/test_log.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, 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 @@ -61,7 +61,7 @@ TEST_VM_F(LogTest, large_message) { AsyncLogWriter::flush(); ResourceMark rm; FILE* fp = os::fopen(TestLogFileName, "r"); - ASSERT_NE((void*)NULL, fp); + ASSERT_NE(nullptr, fp); char* output = read_line(fp); fclose(fp); @@ -91,7 +91,7 @@ TEST_VM_F(LogTest, disabled_logtarget) { // Try to log, but expect this to be filtered out. log.print(LOG_TEST_STRING_LITERAL); - // Log a dummy line so that fgets doesn't return NULL because the file is empty. + // Log a dummy line so that fgets doesn't return nullptr because the file is empty. log_info(gc)("Dummy line"); EXPECT_FALSE(file_contains_substring(TestLogFileName, LOG_TEST_STRING_LITERAL)); @@ -122,7 +122,7 @@ TEST_VM_F(LogTest, disabled_loghandle) { // Try to log through a LogHandle. log_handle.debug("%d workers", 3); - // Log a dummy line so that fgets doesn't return NULL because the file is empty. + // Log a dummy line so that fgets doesn't return nullptr because the file is empty. log_info(gc)("Dummy line"); EXPECT_FALSE(file_contains_substring(TestLogFileName, "3 workers")); @@ -153,7 +153,7 @@ TEST_VM_F(LogTest, disabled_logtargethandle) { // Try to log through a LogHandle. log_handle.print("%d workers", 3); - // Log a dummy line so that fgets doesn't return NULL because the file is empty. + // Log a dummy line so that fgets doesn't return nullptr because the file is empty. log_info(gc)("Dummy line"); EXPECT_FALSE(file_contains_substring(TestLogFileName, "3 workers")); diff --git a/test/hotspot/gtest/logging/test_logConfiguration.cpp b/test/hotspot/gtest/logging/test_logConfiguration.cpp index 907cfcb78c2..0e54aba07be 100644 --- a/test/hotspot/gtest/logging/test_logConfiguration.cpp +++ b/test/hotspot/gtest/logging/test_logConfiguration.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, 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 @@ -132,7 +132,7 @@ TEST_VM_F(LogConfigurationTest, update_output) { // Verify by iterating over tagsets LogOutput* o = LogConfiguration::StdoutLog; - for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) { + for (LogTagSet* ts = LogTagSet::first(); ts != nullptr; ts = ts->next()) { EXPECT_TRUE(ts->has_output(o)); EXPECT_TRUE(ts->is_level(LogLevel::Info)); EXPECT_FALSE(ts->is_level(LogLevel::Debug)); @@ -140,7 +140,7 @@ TEST_VM_F(LogConfigurationTest, update_output) { // Now change the level and verify the change propagated set_log_config(test_outputs[i], "all=debug"); - for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) { + for (LogTagSet* ts = LogTagSet::first(); ts != nullptr; ts = ts->next()) { EXPECT_TRUE(ts->has_output(o)); EXPECT_TRUE(ts->is_level(LogLevel::Debug)); EXPECT_FALSE(ts->is_level(LogLevel::Trace)); @@ -160,7 +160,7 @@ TEST_VM_F(LogConfigurationTest, add_new_output) { EXPECT_TRUE(is_described("all=trace")); // Also verify by iterating over tagsets, checking levels on tagsets - for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) { + for (LogTagSet* ts = LogTagSet::first(); ts != nullptr; ts = ts->next()) { EXPECT_TRUE(ts->is_level(LogLevel::Trace)); } } @@ -182,7 +182,7 @@ TEST_VM_F(LogConfigurationTest, disable_logging) { delete_file(other_file_name); // Verify that no tagset has logging enabled - for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) { + for (LogTagSet* ts = LogTagSet::first(); ts != nullptr; ts = ts->next()) { EXPECT_FALSE(ts->has_output(LogConfiguration::StdoutLog)); EXPECT_FALSE(ts->has_output(LogConfiguration::StderrLog)); EXPECT_FALSE(ts->is_level(LogLevel::Error)); @@ -199,7 +199,7 @@ TEST_VM_F(LogConfigurationTest, disable_output) { // Verify by iterating over tagsets LogOutput* o = LogConfiguration::StdoutLog; - for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) { + for (LogTagSet* ts = LogTagSet::first(); ts != nullptr; ts = ts->next()) { EXPECT_FALSE(ts->has_output(o)); EXPECT_FALSE(ts->is_level(LogLevel::Error)); } @@ -212,7 +212,7 @@ TEST_VM_F(LogConfigurationTest, disable_output) { // Now disable it, verifying it is removed completely set_log_config(TestLogFileName, "all=off"); EXPECT_FALSE(is_described(TestLogFileName)); - for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) { + for (LogTagSet* ts = LogTagSet::first(); ts != nullptr; ts = ts->next()) { EXPECT_FALSE(ts->is_level(LogLevel::Error)); } } @@ -337,7 +337,7 @@ TEST_VM_F(LogConfigurationTest, parse_empty_command_line_arguments) { const char* cmdline = empty_variations[i]; bool ret = LogConfiguration::parse_command_line_arguments(cmdline); EXPECT_TRUE(ret) << "Error parsing command line arguments '" << cmdline << "'"; - for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) { + for (LogTagSet* ts = LogTagSet::first(); ts != nullptr; ts = ts->next()) { EXPECT_EQ(LogLevel::Unspecified, ts->level_for(LogConfiguration::StdoutLog)); } } @@ -427,7 +427,7 @@ TEST_VM_F(LogConfigurationTest, configure_stdout) { EXPECT_TRUE(log_is_enabled(Debug, gc)); EXPECT_TRUE(log_is_enabled(Info, logging)); EXPECT_FALSE(log_is_enabled(Debug, gc, heap)); - for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) { + for (LogTagSet* ts = LogTagSet::first(); ts != nullptr; ts = ts->next()) { if (ts->contains(PREFIX_LOG_TAG(gc))) { if (ts->ntags() == 1) { EXPECT_EQ(LogLevel::Debug, ts->level_for(LogConfiguration::StdoutLog)); @@ -441,7 +441,7 @@ TEST_VM_F(LogConfigurationTest, configure_stdout) { LogConfiguration::configure_stdout(LogLevel::Trace, false, LOG_TAGS(gc)); EXPECT_TRUE(log_is_enabled(Trace, gc)); EXPECT_TRUE(log_is_enabled(Trace, gc, heap)); - for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) { + for (LogTagSet* ts = LogTagSet::first(); ts != nullptr; ts = ts->next()) { if (ts->contains(PREFIX_LOG_TAG(gc))) { EXPECT_EQ(LogLevel::Trace, ts->level_for(LogConfiguration::StdoutLog)); } else if (ts == logging_ts) { @@ -458,7 +458,7 @@ TEST_VM_F(LogConfigurationTest, configure_stdout) { LogConfiguration::configure_stdout(LogLevel::Off, false, LOG_TAGS(gc)); EXPECT_FALSE(log_is_enabled(Error, gc)); EXPECT_FALSE(log_is_enabled(Error, gc, heap)); - for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) { + for (LogTagSet* ts = LogTagSet::first(); ts != nullptr; ts = ts->next()) { EXPECT_EQ(LogLevel::Off, ts->level_for(LogConfiguration::StdoutLog)); } } @@ -476,7 +476,7 @@ TEST_VM_F(LogConfigurationTest, subscribe) { LogConfiguration::register_update_listener(&Test_logconfiguration_subscribe_helper); LogStream ls(log.error()); - LogConfiguration::parse_log_arguments("stdout", "logging=trace", NULL, NULL, &ls); + LogConfiguration::parse_log_arguments("stdout", "logging=trace", nullptr, nullptr, &ls); ASSERT_EQ(1, Test_logconfiguration_subscribe_triggered); LogConfiguration::configure_stdout(LogLevel::Debug, true, LOG_TAGS(gc)); @@ -492,7 +492,7 @@ TEST_VM_F(LogConfigurationTest, parse_invalid_tagset) { // Make sure warning is produced if one or more configured tagsets are invalid ResourceMark rm; stringStream ss; - bool success = LogConfiguration::parse_log_arguments("stdout", invalid_tagset, NULL, NULL, &ss); + bool success = LogConfiguration::parse_log_arguments("stdout", invalid_tagset, nullptr, nullptr, &ss); const char* msg = ss.as_string(); EXPECT_TRUE(success) << "Should only cause a warning, not an error"; EXPECT_THAT(msg, HasSubstr("No tag set matches selection:")); @@ -527,7 +527,7 @@ TEST_VM_F(LogConfigurationTest, output_name_normalization) { static size_t count_occurrences(const char* haystack, const char* needle) { size_t count = 0; - for (const char* p = strstr(haystack, needle); p != NULL; p = strstr(p + 1, needle)) { + for (const char* p = strstr(haystack, needle); p != nullptr; p = strstr(p + 1, needle)) { count++; } return count; @@ -539,7 +539,7 @@ TEST_OTHER_VM(LogConfiguration, output_reconfigured) { EXPECT_FALSE(is_described("(reconfigured)")); - bool success = LogConfiguration::parse_log_arguments("#1", "all=warning", NULL, NULL, &ss); + bool success = LogConfiguration::parse_log_arguments("#1", "all=warning", nullptr, nullptr, &ss); ASSERT_TRUE(success); EXPECT_EQ(0u, ss.size()); @@ -557,7 +557,7 @@ TEST_VM_F(LogConfigurationTest, suggest_similar_selection) { ResourceMark rm; stringStream ss; - LogConfiguration::parse_log_arguments("stdout", nonexisting_tagset, NULL, NULL, &ss); + LogConfiguration::parse_log_arguments("stdout", nonexisting_tagset, nullptr, nullptr, &ss); const char* suggestion = ss.as_string(); SCOPED_TRACE(suggestion); diff --git a/test/hotspot/gtest/logging/test_logDecorations.cpp b/test/hotspot/gtest/logging/test_logDecorations.cpp index f2aa35df1b6..9dc962da1cb 100644 --- a/test/hotspot/gtest/logging/test_logDecorations.cpp +++ b/test/hotspot/gtest/logging/test_logDecorations.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, 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 @@ TEST_VM(LogDecorations, uptime) { for (int i = 0; i < 3; i++) { os::naked_short_sleep(10); LogDecorations d(LogLevel::Info, tagset, default_decorators); - double cur = strtod(d.decoration(LogDecorators::uptime_decorator, buf, sizeof(buf)), NULL); + double cur = strtod(d.decoration(LogDecorators::uptime_decorator, buf, sizeof(buf)), nullptr); ASSERT_LT(prev, cur); prev = cur; } @@ -123,7 +123,7 @@ TEST_VM(LogDecorations, timestamps) { // at 15-16ms, so we use 20. os::naked_short_sleep(20); LogDecorations d(LogLevel::Info, tagset, decorator_selection); - julong val = strtoull(d.decoration(decorator, buf, sizeof(buf)), NULL, 10); + julong val = strtoull(d.decoration(decorator, buf, sizeof(buf)), nullptr, 10); tty->print_cr("Read value: " UINT64_FORMAT, val); ASSERT_LT(prev, val); prev = val; @@ -139,7 +139,7 @@ TEST(LogDecorations, iso8601_time) { LogDecorations decorations(LogLevel::Info, tagset, decorator_selection); const char *timestr = decorations.decoration(LogDecorators::time_decorator, buf, sizeof(buf)); - time_t expected_ts = time(NULL); + time_t expected_ts = time(nullptr); // Verify format int y, M, d, h, m, s, ms; @@ -174,7 +174,7 @@ TEST(LogDecorations, iso8601_utctime) { LogDecorations decorations(LogLevel::Info, tagset, decorator_selection); const char *timestr = decorations.decoration(LogDecorators::utctime_decorator, buf, sizeof(buf)); - time_t expected_ts = time(NULL); + time_t expected_ts = time(nullptr); // Verify format char trailing_character; @@ -234,6 +234,6 @@ TEST(LogDecorations, identifiers) { EXPECT_EQ('\0', *str) << "Should only contain digits"; // Verify value - EXPECT_EQ(ids[i].expected, strtol(reported, NULL, 10)); + EXPECT_EQ(ids[i].expected, strtol(reported, nullptr, 10)); } } diff --git a/test/hotspot/gtest/logging/test_logMessageTest.cpp b/test/hotspot/gtest/logging/test_logMessageTest.cpp index d71a528e2ed..962cca8786f 100644 --- a/test/hotspot/gtest/logging/test_logMessageTest.cpp +++ b/test/hotspot/gtest/logging/test_logMessageTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ class LogMessageTest : public LogTestFixture { Log(logging) LogMessageTest::_log; const char* LogMessageTest::_level_filename[] = { - NULL, // LogLevel::Off + nullptr, // LogLevel::Off #define LOG_LEVEL(name, printname) "multiline-" #printname ".log", LOG_LEVEL_LIST #undef LOG_LEVEL @@ -132,7 +132,7 @@ TEST_VM_F(LogMessageTest, line_order) { _log.write(msg); const char* expected[] = { "info line", "error line", "trace line", - "another error", "warning line", "debug line", NULL }; + "another error", "warning line", "debug line", nullptr }; EXPECT_TRUE(file_contains_substrings_in_order(_level_filename[LogLevel::Trace], expected)) << "output missing or in incorrect order"; } @@ -156,7 +156,7 @@ TEST_VM_F(LogMessageTest, long_message) { msg.trace("%s", data); // Adds a newline, making the message exactly 10K in length. _log.write(msg); - const char* expected[] = { start_marker, "0123456789", end_marker, NULL }; + const char* expected[] = { start_marker, "0123456789", end_marker, nullptr }; EXPECT_TRUE(file_contains_substrings_in_order(_level_filename[LogLevel::Trace], expected)) << "unable to print long line"; FREE_C_HEAP_ARRAY(char, data); @@ -178,7 +178,7 @@ TEST_VM_F(LogMessageTest, message_with_many_lines) { jio_snprintf(&expected_lines_data[i][0], line_length, "Line #" SIZE_FORMAT, i); expected_lines[i] = expected_lines_data[i]; } - expected_lines[lines] = NULL; + expected_lines[lines] = nullptr; EXPECT_TRUE(file_contains_substrings_in_order(_level_filename[LogLevel::Trace], expected_lines)) << "couldn't find all lines in multiline message"; @@ -201,7 +201,7 @@ TEST_VM_F(LogMessageTest, prefixing) { for (int i = 0; i < 3; i++) { msg.info("test %d", i); } - msg.set_prefix(NULL); + msg.set_prefix(nullptr); msg.info("test 3"); _log.write(msg); @@ -210,7 +210,7 @@ TEST_VM_F(LogMessageTest, prefixing) { "] some prefix: test 1", "] some prefix: test 2", "] test 3", - NULL + nullptr }; EXPECT_TRUE(file_contains_substrings_in_order(_level_filename[LogLevel::Trace], expected)) << "error in prefixed output"; @@ -238,7 +238,7 @@ TEST_VM_F(LogMessageTest, scoped_flushing) { EXPECT_TRUE(file_contains_substring(_level_filename[LogLevel::Info], "manual flush info")) << "missing output from manually flushed scoped log message"; } - const char* tmp[] = {"manual flush info", "manual flush info", NULL}; + const char* tmp[] = {"manual flush info", "manual flush info", nullptr}; EXPECT_FALSE(file_contains_substrings_in_order(_level_filename[LogLevel::Info], tmp)) << "log file contains duplicate lines from single scoped log message"; } diff --git a/test/hotspot/gtest/logging/test_logSelectionList.cpp b/test/hotspot/gtest/logging/test_logSelectionList.cpp index cce4ffaccec..2a16a4ae98d 100644 --- a/test/hotspot/gtest/logging/test_logSelectionList.cpp +++ b/test/hotspot/gtest/logging/test_logSelectionList.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,11 +30,13 @@ #include "logTestUtils.inline.hpp" #include "unittest.hpp" -TEST(LogSelectionList, combination_limit) { - size_t max_combinations = LogSelectionList::MaxSelections; - EXPECT_GT(max_combinations, LogTagSet::ntagsets()) - << "Combination limit not sufficient for configuring all available tag sets"; -} +// SapMachine 2024-02-08 +// temporary disable this test since it is failing in SapMachine. Opened JDK-8325508 to clarify. +// TEST(LogSelectionList, combination_limit) { +// size_t max_combinations = LogSelectionList::MaxSelections; +// EXPECT_GT(max_combinations, LogTagSet::ntagsets()) +// << "Combination limit not sufficient for configuring all available tag sets"; +// } TEST(LogSelectionList, parse) { char buf[256]; @@ -83,7 +85,7 @@ TEST(LogSelectionList, level_for_empty) { LogSelectionList emptyexpr; ASSERT_TRUE(emptyexpr.parse("")); // All tagsets should be unspecified since the expression doesn't involve any tagset - for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) { + for (LogTagSet* ts = LogTagSet::first(); ts != nullptr; ts = ts->next()) { EXPECT_EQ(LogLevel::Unspecified, emptyexpr.level_for(*ts)); } } @@ -93,7 +95,7 @@ TEST(LogSelectionList, level_for_overlap) { LogSelectionList overlapexpr; // The all=warning will be overridden with gc=info and/or logging+safepoint*=trace ASSERT_TRUE(overlapexpr.parse("all=warning,gc=info,logging+safepoint*=trace")); - for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) { + for (LogTagSet* ts = LogTagSet::first(); ts != nullptr; ts = ts->next()) { if (ts->contains(PREFIX_LOG_TAG(gc)) && ts->ntags() == 1) { EXPECT_EQ(LogLevel::Info, overlapexpr.level_for(*ts)); } else if (ts->contains(PREFIX_LOG_TAG(logging)) && ts->contains(PREFIX_LOG_TAG(safepoint))) { diff --git a/test/hotspot/gtest/logging/test_logStream.cpp b/test/hotspot/gtest/logging/test_logStream.cpp index 0782af67679..d153601fc9c 100644 --- a/test/hotspot/gtest/logging/test_logStream.cpp +++ b/test/hotspot/gtest/logging/test_logStream.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, 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 @@ -96,7 +96,7 @@ TEST_VM_F(LogStreamTest, TestLineBufferAllocation) { // Compare this to NonInterLeavingLogStreamTest_NonInterleavingStream TEST_VM_F(LogStreamTest, InterleavingStream) { set_log_config(TestLogFileName, "gc=info"); - const char* message_order[] = {"1", "I am one line", "2", "but", "3", "I am not", NULL}; + const char* message_order[] = {"1", "I am one line", "2", "but", "3", "I am not", nullptr}; { LogStream foo(Log(gc)::info()); if (foo.is_enabled()) { @@ -116,7 +116,7 @@ TEST_VM_F(LogStreamTest, InterleavingStream) { // Compare this to LogStreamTest_InterleavingStream TEST_VM_F(LogStreamTest, NonInterleavingStream) { set_log_config(TestLogFileName, "gc=info"); - const char* message_order[] = {"1", "2" , "3", "I am one line", "but", "I am not", NULL}; + const char* message_order[] = {"1", "2" , "3", "I am one line", "but", "I am not", nullptr}; { LogMessage(gc) lm ; NonInterleavingLogStream foo{LogLevelType::Info, lm}; diff --git a/test/hotspot/gtest/logging/test_logTag.cpp b/test/hotspot/gtest/logging/test_logTag.cpp index 79d2745c35e..9d610ca7072 100644 --- a/test/hotspot/gtest/logging/test_logTag.cpp +++ b/test/hotspot/gtest/logging/test_logTag.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -72,16 +72,16 @@ TEST(LogTag, list_tags) { bool listed_tags[LogTag::Count] = { false }; - char* last_tag = NULL; + char* last_tag = nullptr; for (char* tag = buf; *tag != '\0';) { char* end = strpbrk(tag, ",\n"); - ASSERT_TRUE(end != NULL) << "line should end with newline"; + ASSERT_TRUE(end != nullptr) << "line should end with newline"; *end = '\0'; if (*tag == ' ') { tag++; } - EXPECT_TRUE(last_tag == NULL || strcmp(last_tag, tag) < 0) << tag << " should be listed before " << last_tag; + EXPECT_TRUE(last_tag == nullptr || strcmp(last_tag, tag) < 0) << tag << " should be listed before " << last_tag; listed_tags[LogTag::from_string(tag)] = true; last_tag = tag; diff --git a/test/hotspot/gtest/logging/test_logTagSet.cpp b/test/hotspot/gtest/logging/test_logTagSet.cpp index 2243762365b..8a57dea8cdd 100644 --- a/test/hotspot/gtest/logging/test_logTagSet.cpp +++ b/test/hotspot/gtest/logging/test_logTagSet.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ // Test the default level for each tagset TEST_VM(LogTagSet, defaults) { - for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) { + for (LogTagSet* ts = LogTagSet::first(); ts != nullptr; ts = ts->next()) { char buf[256]; ts->label(buf, sizeof(buf)); SCOPED_TRACE(buf); @@ -49,7 +49,7 @@ TEST_VM(LogTagSet, has_output) { LogTagSet& ts = LogTagSetMapping::tagset(); ts.set_output_level(LogConfiguration::StderrLog, LogLevel::Trace); EXPECT_TRUE(ts.has_output(LogConfiguration::StderrLog)); - EXPECT_FALSE(ts.has_output(NULL)); + EXPECT_FALSE(ts.has_output(nullptr)); ts.set_output_level(LogConfiguration::StderrLog, LogLevel::Off); EXPECT_FALSE(ts.has_output(LogConfiguration::StderrLog)); } @@ -140,7 +140,7 @@ TEST_VM(LogTagSet, label) { } TEST_VM(LogTagSet, duplicates) { - for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) { + for (LogTagSet* ts = LogTagSet::first(); ts != nullptr; ts = ts->next()) { char ts_name[512]; ts->label(ts_name, sizeof(ts_name), ","); @@ -155,7 +155,7 @@ TEST_VM(LogTagSet, duplicates) { } // verify that there are no duplicate tagsets (same tags in different order) - for (LogTagSet* other = ts->next(); other != NULL; other = other->next()) { + for (LogTagSet* other = ts->next(); other != nullptr; other = other->next()) { if (ts->ntags() != other->ntags()) { continue; } diff --git a/test/hotspot/gtest/logging/test_logTagSetDescriptions.cpp b/test/hotspot/gtest/logging/test_logTagSetDescriptions.cpp index 069e6877e32..5cedddef73b 100644 --- a/test/hotspot/gtest/logging/test_logTagSetDescriptions.cpp +++ b/test/hotspot/gtest/logging/test_logTagSetDescriptions.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, 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 @@ -32,7 +32,7 @@ #include "utilities/ostream.hpp" TEST_VM(LogTagSetDescriptions, describe) { - for (LogTagSetDescription* d = tagset_descriptions; d->tagset != NULL; d++) { + for (LogTagSetDescription* d = tagset_descriptions; d->tagset != nullptr; d++) { char expected[1 * K]; d->tagset->label(expected, sizeof(expected), "+"); jio_snprintf(expected + strlen(expected), @@ -51,12 +51,12 @@ TEST_VM(LogTagSetDescriptions, command_line_help) { ResourceMark rm; const char* filename = prepend_temp_dir("logtagset_descriptions"); FILE* fp = os::fopen(filename, "w+"); - ASSERT_NE((void*)NULL, fp); + ASSERT_NE((void*)nullptr, fp); fileStream stream(fp); LogConfiguration::print_command_line_help(&stream); fclose(fp); - for (LogTagSetDescription* d = tagset_descriptions; d->tagset != NULL; d++) { + for (LogTagSetDescription* d = tagset_descriptions; d->tagset != nullptr; d++) { char expected[1 * K]; d->tagset->label(expected, sizeof(expected), "+"); jio_snprintf(expected + strlen(expected), diff --git a/test/hotspot/gtest/memory/test_arena.cpp b/test/hotspot/gtest/memory/test_arena.cpp index be8bac46861..b95a820103f 100644 --- a/test/hotspot/gtest/memory/test_arena.cpp +++ b/test/hotspot/gtest/memory/test_arena.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021 SAP SE. All rights reserved. * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -94,15 +94,15 @@ TEST_VM(Arena, realloc_same_size) { ASSERT_RANGE_IS_MARKED(p2, 0x200); } -// Test behavior for Afree(NULL) and Arealloc(NULL, x) +// Test behavior for Afree(nullptr) and Arealloc(nullptr, x) TEST_VM(Arena, free_null) { Arena ar(mtTest); - ar.Afree(NULL, 10); // should just be ignored + ar.Afree(nullptr, 10); // should just be ignored } TEST_VM(Arena, realloc_null) { Arena ar(mtTest); - void* p = ar.Arealloc(NULL, 0, 20); // equivalent to Amalloc(20) + void* p = ar.Arealloc(nullptr, 0, 20); // equivalent to Amalloc(20) ASSERT_AMALLOC(ar, p); } @@ -238,7 +238,7 @@ TEST_VM(Arena, random_allocs) { for (int i = 0; i < num_allocs; i ++) { size_t size = os::random() % (avg_alloc_size * 2); // Note: size==0 is okay; we want to test that too size_t alignment = 0; - void* p = NULL; + void* p = nullptr; if (os::random() % 2) { // randomly switch between Amalloc and AmallocWords p = ar.Amalloc(size); alignment = BytesPerLong; @@ -297,7 +297,7 @@ TEST_VM(Arena, random_allocs) { ar.Afree(ptrs[i], sizes[i]); // In debug builds the freed space should be filled the space with badResourceValue DEBUG_ONLY(ASSERT_RANGE_IS_MARKED_WITH(ptrs[i], sizes[i], badResourceValue)); - ptrs[i] = NULL; + ptrs[i] = nullptr; } } diff --git a/test/hotspot/gtest/memory/test_guardedMemory.cpp b/test/hotspot/gtest/memory/test_guardedMemory.cpp index 9e1d1754d3e..a86982db15f 100644 --- a/test/hotspot/gtest/memory/test_guardedMemory.cpp +++ b/test/hotspot/gtest/memory/test_guardedMemory.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,7 @@ #define GEN_PURPOSE_TAG ((void *) ((uintptr_t)0xf000f000)) static void guarded_memory_test_check(void* p, size_t sz, void* tag) { - ASSERT_TRUE(p != NULL) << "NULL pointer given to check"; + ASSERT_TRUE(p != nullptr) << "nullptr pointer given to check"; u_char* c = (u_char*) p; GuardedMemory guarded(c); EXPECT_EQ(guarded.get_tag(), tag) << "Tag is not the same as supplied"; @@ -130,19 +130,19 @@ TEST(GuardedMemory, buffer_overrun_tail) { // Test wrap_copy/wrap_free TEST(GuardedMemory, wrap) { - EXPECT_TRUE(GuardedMemory::free_copy(NULL)) << "Expected free NULL to be OK"; + EXPECT_TRUE(GuardedMemory::free_copy(nullptr)) << "Expected free nullptr to be OK"; const char* str = "Check my bounds out"; size_t str_sz = strlen(str) + 1; char* str_copy = (char*) GuardedMemory::wrap_copy(str, str_sz); - guarded_memory_test_check(str_copy, str_sz, NULL); + guarded_memory_test_check(str_copy, str_sz, nullptr); if (HasFatalFailure()) { return; } EXPECT_STREQ(str, str_copy) << "Not identical copy"; EXPECT_TRUE(GuardedMemory::free_copy(str_copy)) << "Free copy failed to verify"; - void* no_data = NULL; + void* no_data = nullptr; void* no_data_copy = GuardedMemory::wrap_copy(no_data, 0); EXPECT_TRUE(GuardedMemory::free_copy(no_data_copy)) << "Expected valid guards even for no data copy"; diff --git a/test/hotspot/gtest/memory/test_virtualspace.cpp b/test/hotspot/gtest/memory/test_virtualspace.cpp index 2391ff00df4..2240f0f4cb3 100644 --- a/test/hotspot/gtest/memory/test_virtualspace.cpp +++ b/test/hotspot/gtest/memory/test_virtualspace.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -67,7 +67,7 @@ namespace { ReservedSpace rs(size); MemoryReleaser releaser(&rs); - EXPECT_TRUE(rs.base() != NULL) << "rs.special: " << rs.special(); + EXPECT_TRUE(rs.base() != nullptr) << "rs.special: " << rs.special(); EXPECT_EQ(size, rs.size()) << "rs.special: " << rs.special(); if (rs.special()) { @@ -78,9 +78,9 @@ namespace { static void test_reserved_size_alignment(size_t size, size_t alignment) { ASSERT_PRED2(is_size_aligned, size, alignment) << "Incorrect input parameters"; size_t page_size = UseLargePages ? os::large_page_size() : os::vm_page_size(); - ReservedSpace rs(size, alignment, page_size, (char *) NULL); + ReservedSpace rs(size, alignment, page_size, (char *) nullptr); - ASSERT_TRUE(rs.base() != NULL) << "rs.special = " << rs.special(); + ASSERT_TRUE(rs.base() != nullptr) << "rs.special = " << rs.special(); ASSERT_EQ(size, rs.size()) << "rs.special = " << rs.special(); EXPECT_PRED2(is_ptr_aligned, rs.base(), alignment) @@ -109,7 +109,7 @@ namespace { ReservedSpace rs(size, alignment, page_size); MemoryReleaser releaser(&rs); - EXPECT_TRUE(rs.base() != NULL) << "rs.special: " << rs.special(); + EXPECT_TRUE(rs.base() != nullptr) << "rs.special: " << rs.special(); EXPECT_EQ(size, rs.size()) << "rs.special: " << rs.special(); if (rs.special()) { @@ -369,9 +369,9 @@ class TestReservedSpace : AllStatic { ReservedSpace rs(size, // size alignment, // alignment page_size, // page size - (char *)NULL); // requested_address + (char *)nullptr); // requested_address - EXPECT_TRUE(rs.base() != NULL); + EXPECT_TRUE(rs.base() != nullptr); EXPECT_EQ(rs.size(), size) << "rs.size: " << rs.size(); EXPECT_TRUE(is_aligned(rs.base(), alignment)) << "aligned sizes should always give aligned addresses"; @@ -389,7 +389,7 @@ class TestReservedSpace : AllStatic { ReservedSpace rs(size); - EXPECT_TRUE(rs.base() != NULL); + EXPECT_TRUE(rs.base() != nullptr); EXPECT_EQ(rs.size(), size) << "rs.size: " << rs.size(); if (rs.special()) { @@ -414,7 +414,7 @@ class TestReservedSpace : AllStatic { ReservedSpace rs(size, alignment, page_size); - EXPECT_TRUE(rs.base() != NULL); + EXPECT_TRUE(rs.base() != nullptr); EXPECT_EQ(rs.size(), size) << "rs.size: " << rs.size(); if (rs.special()) { diff --git a/test/hotspot/gtest/metaspace/metaspaceGtestCommon.cpp b/test/hotspot/gtest/metaspace/metaspaceGtestCommon.cpp index f39ce2c1d13..fe3964562b4 100644 --- a/test/hotspot/gtest/metaspace/metaspaceGtestCommon.cpp +++ b/test/hotspot/gtest/metaspace/metaspaceGtestCommon.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, 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. * @@ -54,14 +54,14 @@ void check_marked_address(const MetaWord* p, uintx pattern) { // The filled range can be checked with check_range_for_pattern. One also can only check // a sub range of the original range. void fill_range_with_pattern(MetaWord* p, size_t word_size, uintx pattern) { - assert(word_size > 0 && p != NULL, "sanity"); + assert(word_size > 0 && p != nullptr, "sanity"); for (MetaWord* p2 = p; p2 < p + word_size; p2++) { mark_address(p2, pattern); } } void check_range_for_pattern(const MetaWord* p, size_t word_size, uintx pattern) { - assert(p != NULL, "sanity"); + assert(p != nullptr, "sanity"); const MetaWord* p2 = p; while (p2 < p + word_size) { check_marked_address(p2, pattern); @@ -74,19 +74,19 @@ void check_range_for_pattern(const MetaWord* p, size_t word_size, uintx pattern) // Use check_marked_range to check the range. In contrast to check_range_for_pattern, only the original // range can be checked. void mark_range(MetaWord* p, size_t word_size, uintx pattern) { - assert(word_size > 0 && p != NULL, "sanity"); + assert(word_size > 0 && p != nullptr, "sanity"); mark_address(p, pattern); mark_address(p + word_size - 1, pattern); } void check_marked_range(const MetaWord* p, size_t word_size, uintx pattern) { - assert(word_size > 0 && p != NULL, "sanity"); + assert(word_size > 0 && p != nullptr, "sanity"); check_marked_address(p, pattern); check_marked_address(p + word_size - 1, pattern); } void mark_range(MetaWord* p, size_t word_size) { - assert(word_size > 0 && p != NULL, "sanity"); + assert(word_size > 0 && p != nullptr, "sanity"); uintx pattern = (uintx)p2i(p); mark_range(p, word_size, pattern); } diff --git a/test/hotspot/gtest/metaspace/metaspaceGtestCommon.hpp b/test/hotspot/gtest/metaspace/metaspaceGtestCommon.hpp index 26c5d51e9c6..4c9bf67997b 100644 --- a/test/hotspot/gtest/metaspace/metaspaceGtestCommon.hpp +++ b/test/hotspot/gtest/metaspace/metaspaceGtestCommon.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, 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. * @@ -38,7 +38,7 @@ class TestMap { const size_t _len; char* _arr; public: - TestMap(size_t len) : _len(len), _arr(NULL) { + TestMap(size_t len) : _len(len), _arr(nullptr) { _arr = NEW_C_HEAP_ARRAY(char, len, mtInternal); memset(_arr, 0, _len); } @@ -145,12 +145,12 @@ void mark_range(MetaWord* p, size_t word_size); void check_marked_range(const MetaWord* p, size_t word_size); ////////////////////////////////////////////////////////// -// Some helpers to avoid typing out those annoying casts for NULL +// Some helpers to avoid typing out those annoying casts for nullptr -#define ASSERT_NOT_NULL(ptr) ASSERT_NE((void*)NULL, (void*)ptr) -#define ASSERT_NULL(ptr) ASSERT_EQ((void*)NULL, (void*)ptr) -#define EXPECT_NOT_NULL(ptr) EXPECT_NE((void*)NULL, (void*)ptr) -#define EXPECT_NULL(ptr) EXPECT_EQ((void*)NULL, (void*)ptr) +#define ASSERT_NOT_NULL(ptr) ASSERT_NE(nullptr, (void*)ptr) +#define ASSERT_NULL(ptr) ASSERT_EQ(nullptr, (void*)ptr) +#define EXPECT_NOT_NULL(ptr) EXPECT_NE(nullptr, (void*)ptr) +#define EXPECT_NULL(ptr) EXPECT_EQ(nullptr, (void*)ptr) #define ASSERT_0(v) ASSERT_EQ((intptr_t)0, (intptr_t)v) #define ASSERT_NOT_0(v) ASSERT_NE((intptr_t)0, (intptr_t)v) @@ -188,7 +188,7 @@ class FeederBuffer { public: - FeederBuffer(size_t size) : _buf(NULL), _cap(size), _used(0) { + FeederBuffer(size_t size) : _buf(nullptr), _cap(size), _used(0) { _buf = NEW_C_HEAP_ARRAY(MetaWord, _cap, mtInternal); } @@ -198,7 +198,7 @@ class FeederBuffer { MetaWord* get(size_t word_size) { if (_used + word_size > _cap) { - return NULL; + return nullptr; } MetaWord* p = _buf + _used; _used += word_size; diff --git a/test/hotspot/gtest/metaspace/metaspaceGtestContexts.cpp b/test/hotspot/gtest/metaspace/metaspaceGtestContexts.cpp index f3801f591a2..3e9ef4c46d7 100644 --- a/test/hotspot/gtest/metaspace/metaspaceGtestContexts.cpp +++ b/test/hotspot/gtest/metaspace/metaspaceGtestContexts.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2023 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -34,11 +34,11 @@ using metaspace::Settings; void ChunkGtestContext::checked_alloc_chunk_0(Metachunk** p_return_value, chunklevel_t preferred_level, chunklevel_t max_level, size_t min_committed_size) { - *p_return_value = NULL; + *p_return_value = nullptr; Metachunk* c = cm().get_chunk(preferred_level, max_level, min_committed_size); - if (c != NULL) { + if (c != nullptr) { ASSERT_LE(c->level(), max_level); ASSERT_GE(c->level(), preferred_level); diff --git a/test/hotspot/gtest/metaspace/metaspaceGtestContexts.hpp b/test/hotspot/gtest/metaspace/metaspaceGtestContexts.hpp index 7d2f0074fcc..f1a3ac0141a 100644 --- a/test/hotspot/gtest/metaspace/metaspaceGtestContexts.hpp +++ b/test/hotspot/gtest/metaspace/metaspaceGtestContexts.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, 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. * @@ -89,7 +89,7 @@ class ChunkGtestContext : public MetaspaceGtestContext { // Allocate a chunk but expect it to fail. void alloc_chunk_expect_failure(chunklevel_t preferred_level, chunklevel_t max_level, size_t min_committed_size) { - Metachunk* c = NULL; + Metachunk* c = nullptr; checked_alloc_chunk_0(&c, preferred_level, max_level, min_committed_size); ASSERT_NULL(c); } diff --git a/test/hotspot/gtest/metaspace/metaspaceGtestSparseArray.hpp b/test/hotspot/gtest/metaspace/metaspaceGtestSparseArray.hpp index 4c8ad944d45..6ca6b68baa3 100644 --- a/test/hotspot/gtest/metaspace/metaspaceGtestSparseArray.hpp +++ b/test/hotspot/gtest/metaspace/metaspaceGtestSparseArray.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, 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. * @@ -68,8 +68,8 @@ class SparseArray : public StackObj { // Helper for next_matching_slot bool slot_matches(int slot, condition_t c) const { switch(c) { - case cond_null: return _slots[slot] == NULL; - case cond_non_null: return _slots[slot] != NULL; + case cond_null: return _slots[slot] == nullptr; + case cond_non_null: return _slots[slot] != nullptr; case cond_dontcare: return true; } ShouldNotReachHere(); @@ -95,7 +95,7 @@ class SparseArray : public StackObj { _index_range(num) { for (int i = 0; i < _num; i++) { - _slots[i] = NULL; + _slots[i] = nullptr; } } @@ -109,7 +109,7 @@ class SparseArray : public StackObj { int size() const { return _num; } - bool slot_is_null(int i) const { check_index(i); return _slots[i] == NULL; } + bool slot_is_null(int i) const { check_index(i); return _slots[i] == nullptr; } DEBUG_ONLY(void check_slot_is_null(int i) const { assert(slot_is_null(i), "Slot %d is not null", i); }) DEBUG_ONLY(void check_slot_is_not_null(int i) const { assert(!slot_is_null(i), "Slot %d is null", i); }) diff --git a/test/hotspot/gtest/metaspace/test_binlist.cpp b/test/hotspot/gtest/metaspace/test_binlist.cpp index fd211a2eb8d..dd26d858e24 100644 --- a/test/hotspot/gtest/metaspace/test_binlist.cpp +++ b/test/hotspot/gtest/metaspace/test_binlist.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, 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. * @@ -61,7 +61,7 @@ struct BinListBasicTest { // Try to get a block from an empty list. size_t real_size = 4711; MetaWord* p = bl.remove_block(innocous_size, &real_size); - EXPECT_EQ(p, (MetaWord*)NULL); + EXPECT_EQ(p, (MetaWord*)nullptr); EXPECT_EQ((size_t)0, real_size); // Add a block... @@ -102,7 +102,7 @@ struct BinListBasicTest { CHECK_BL_CONTENT(bl, 0, 0); DEBUG_ONLY(bl.verify();) } else { - EXPECT_EQ(p, (MetaWord*)NULL); + EXPECT_EQ(p, (MetaWord*)nullptr); EXPECT_EQ((size_t)0, real_size); CHECK_BL_CONTENT(bl, 1, s1); DEBUG_ONLY(bl.verify();) @@ -135,7 +135,7 @@ struct BinListBasicTest { for (;;) { size_t s = rgen.get(); MetaWord* p = fb.get(s); - if (p != NULL) { + if (p != nullptr) { bl[which].add_block(p, s); cnt[which].add(s); which = which == 0 ? 1 : 0; @@ -156,7 +156,7 @@ struct BinListBasicTest { size_t real_size = 4711; MetaWord* p = bl[giver].remove_block(s, &real_size); - if (p != NULL) { + if (p != nullptr) { ASSERT_TRUE(fb.is_valid_range(p, real_size)); ASSERT_GE(real_size, s); @@ -166,7 +166,7 @@ struct BinListBasicTest { cnt[taker].add(real_size); } else { - ASSERT_EQ(real_size, (size_t)NULL); + ASSERT_EQ(real_size, (size_t)nullptr); } CHECK_COUNTERS; @@ -185,7 +185,7 @@ struct BinListBasicTest { size_t real_size = 4711; MetaWord* p = bl[which].remove_block(1, &real_size); - ASSERT_NE(p, (MetaWord*) NULL); + ASSERT_NE(p, (MetaWord*) nullptr); ASSERT_GE(real_size, (size_t)1); ASSERT_TRUE(fb.is_valid_range(p, real_size)); diff --git a/test/hotspot/gtest/metaspace/test_blocktree.cpp b/test/hotspot/gtest/metaspace/test_blocktree.cpp index e149e9777fe..50ec021ec11 100644 --- a/test/hotspot/gtest/metaspace/test_blocktree.cpp +++ b/test/hotspot/gtest/metaspace/test_blocktree.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, 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. * @@ -59,7 +59,7 @@ TEST_VM(metaspace, BlockTree_basic) { CHECK_BT_CONTENT(bt, 0, 0); size_t real_size = 0; - MetaWord* p = NULL; + MetaWord* p = nullptr; MetaWord arr[10000]; ASSERT_LE(BlockTree::MinWordSize, (size_t)6); // Sanity check. Adjust if Node is changed. @@ -278,7 +278,7 @@ class BlockTreeTest { // Feed the whole feeder buffer to the trees, according to feeding_pattern. void feed_all(feeding_pattern_t feeding_pattern) { - MetaWord* p = NULL; + MetaWord* p = nullptr; unsigned added = 0; // If we feed in small graining, we cap the number of blocks to limit test duration. @@ -306,14 +306,14 @@ class BlockTreeTest { // Get a block from the feeder buffer; feed it alternatingly to either tree. p = _fb.get(s); - if (p != NULL) { + if (p != nullptr) { int which = added % 2; added++; _bt[which].add_block(p, s); _cnt[which].add(s); CHECK_COUNTERS } - } while (p != NULL && added < max_blocks); + } while (p != nullptr && added < max_blocks); DEBUG_ONLY(verify_trees();) @@ -335,7 +335,7 @@ class BlockTreeTest { size_t s =_rgen.get(); size_t real_size = 0; MetaWord* p = _bt[giver].remove_block(s, &real_size); - if (p != NULL) { + if (p != nullptr) { ASSERT_TRUE(_fb.is_valid_range(p, real_size)); ASSERT_GE(real_size, s); _bt[taker].add_block(p, real_size); diff --git a/test/hotspot/gtest/metaspace/test_chunkManager_stress.cpp b/test/hotspot/gtest/metaspace/test_chunkManager_stress.cpp index 2ccc4ebc09e..b8ccdbf3947 100644 --- a/test/hotspot/gtest/metaspace/test_chunkManager_stress.cpp +++ b/test/hotspot/gtest/metaspace/test_chunkManager_stress.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2020, 2023 SAP SE. All rights reserved. - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, 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,9 +116,9 @@ class ChunkManagerRandomChunkAllocTest { const chunklevel_t max_level = r.highest(); const size_t min_committed = random_committed_words(max_level, _commit_factor); - Metachunk* c = NULL; + Metachunk* c = nullptr; _context.alloc_chunk(&c, r.lowest(), r.highest(), min_committed); - if (c == NULL) { + if (c == nullptr) { EXPECT_TRUE(could_be_reserve_error() || could_be_commit_error(min_committed)); LOG("Alloc chunk at %d failed.", slot); @@ -162,7 +162,7 @@ class ChunkManagerRandomChunkAllocTest { Metachunk* c = _chunks.at(slot); LOG("Returning chunk at %d: " METACHUNK_FORMAT ".", slot, METACHUNK_FORMAT_ARGS(c)); _context.return_chunk(c); - _chunks.set_at(slot, NULL); + _chunks.set_at(slot, nullptr); } // return a random number of chunks (at most a quarter of the full slot range) diff --git a/test/hotspot/gtest/metaspace/test_chunkheaderpool.cpp b/test/hotspot/gtest/metaspace/test_chunkheaderpool.cpp index 226df7e1029..c6c0a773aed 100644 --- a/test/hotspot/gtest/metaspace/test_chunkheaderpool.cpp +++ b/test/hotspot/gtest/metaspace/test_chunkheaderpool.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, 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. * @@ -48,12 +48,12 @@ class ChunkHeaderPoolTest { LOG("attempt_free_at " SIZE_FORMAT ".", index); - if (_elems[index] == NULL) { + if (_elems[index] == nullptr) { return; } _pool.return_chunk_header(_elems[index]); - _elems[index] = NULL; + _elems[index] = nullptr; _num_allocated.decrement(); DEBUG_ONLY(_num_allocated.check(_pool.used());) @@ -66,7 +66,7 @@ class ChunkHeaderPoolTest { LOG("attempt_allocate_at " SIZE_FORMAT ".", index); - if (_elems[index] != NULL) { + if (_elems[index] != nullptr) { return; } @@ -82,7 +82,7 @@ class ChunkHeaderPoolTest { } void attempt_allocate_or_free_at(size_t index) { - if (_elems[index] == NULL) { + if (_elems[index] == nullptr) { attempt_allocate_at(index); } else { attempt_free_at(index); diff --git a/test/hotspot/gtest/metaspace/test_freeblocks.cpp b/test/hotspot/gtest/metaspace/test_freeblocks.cpp index 6ca5fb8b05f..fbf2e822c11 100644 --- a/test/hotspot/gtest/metaspace/test_freeblocks.cpp +++ b/test/hotspot/gtest/metaspace/test_freeblocks.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, 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. * @@ -72,7 +72,7 @@ class FreeBlocksTest { bool feed_some() { size_t word_size = _rgen_feeding.get(); MetaWord* p = _fb.get(word_size); - if (p != NULL) { + if (p != nullptr) { _freeblocks.add_block(p, word_size); return true; } @@ -82,7 +82,7 @@ class FreeBlocksTest { bool deallocate_top() { allocation_t* a = _allocations; - if (a != NULL) { + if (a != nullptr) { _allocations = a->next; check_marked_range(a->p, a->word_size); _freeblocks.add_block(a->p, a->word_size); @@ -101,7 +101,7 @@ class FreeBlocksTest { size_t word_size = MAX2(_rgen_allocations.get(), _freeblocks.MinWordSize); MetaWord* p = _freeblocks.remove_block(word_size); - if (p != NULL) { + if (p != nullptr) { _allocated_words.increment_by(word_size); allocation_t* a = new allocation_t; a->p = p; a->word_size = word_size; @@ -115,7 +115,7 @@ class FreeBlocksTest { } void test_all_marked_ranges() { - for (allocation_t* a = _allocations; a != NULL; a = a->next) { + for (allocation_t* a = _allocations; a != nullptr; a = a->next) { check_marked_range(a->p, a->word_size); } } @@ -177,7 +177,7 @@ class FreeBlocksTest { _fb(512 * K), _freeblocks(), _rgen_feeding(128, 4096), _rgen_allocations(avg_alloc_size / 4, avg_alloc_size * 2, 0.01f, avg_alloc_size / 3, avg_alloc_size * 30), - _allocations(NULL), + _allocations(nullptr), _num_allocs(0), _num_deallocs(0), _num_feeds(0) diff --git a/test/hotspot/gtest/metaspace/test_is_metaspace_obj.cpp b/test/hotspot/gtest/metaspace/test_is_metaspace_obj.cpp index 820ad1fd3d1..0304cca7374 100644 --- a/test/hotspot/gtest/metaspace/test_is_metaspace_obj.cpp +++ b/test/hotspot/gtest/metaspace/test_is_metaspace_obj.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, 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. * @@ -42,7 +42,7 @@ class MetaspaceIsMetaspaceObjTest { public: - MetaspaceIsMetaspaceObjTest() : _lock(NULL), _ms(NULL) {} + MetaspaceIsMetaspaceObjTest() : _lock(nullptr), _ms(nullptr) {} ~MetaspaceIsMetaspaceObjTest() { delete _ms; delete _lock; @@ -75,7 +75,7 @@ class MetaspaceIsMetaspaceObjTest { ASSERT_TRUE(vslist->contains((MetaWord*)((address)p) + 1)); // Now for some bogus values - ASSERT_FALSE(MetaspaceObj::is_valid((MetaspaceObj*)NULL)); + ASSERT_FALSE(MetaspaceObj::is_valid((MetaspaceObj*)nullptr)); // Should exercise various paths in MetaspaceObj::is_valid() ASSERT_FALSE(MetaspaceObj::is_valid((MetaspaceObj*)1024)); @@ -93,9 +93,9 @@ class MetaspaceIsMetaspaceObjTest { ASSERT_TRUE(Metaspace::contains_non_shared(p)); delete _ms; - _ms = NULL; + _ms = nullptr; delete _lock; - _lock = NULL; + _lock = nullptr; } }; diff --git a/test/hotspot/gtest/metaspace/test_metachunk.cpp b/test/hotspot/gtest/metaspace/test_metachunk.cpp index 5e6a8c1c1b2..d60bdab7bfa 100644 --- a/test/hotspot/gtest/metaspace/test_metachunk.cpp +++ b/test/hotspot/gtest/metaspace/test_metachunk.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2020, 2023 SAP SE. All rights reserved. - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ using namespace metaspace::chunklevel; TEST_VM(metaspace, get_chunk) { ChunkGtestContext context(8 * M); - Metachunk* c = NULL; + Metachunk* c = nullptr; for (chunklevel_t pref_lvl = LOWEST_CHUNK_LEVEL; pref_lvl <= HIGHEST_CHUNK_LEVEL; pref_lvl++) { @@ -70,7 +70,7 @@ TEST_VM(metaspace, get_chunk_with_commit_limit) { commit_limit_words < MAX_CHUNK_WORD_SIZE * 2; commit_limit_words *= 2) { ChunkGtestContext context(commit_limit_words); - Metachunk* c = NULL; + Metachunk* c = nullptr; for (chunklevel_t pref_lvl = LOWEST_CHUNK_LEVEL; pref_lvl <= HIGHEST_CHUNK_LEVEL; pref_lvl++) { @@ -103,7 +103,7 @@ TEST_VM(metaspace, get_chunk_with_commit_limit) { TEST_VM(metaspace, get_chunk_recommit) { ChunkGtestContext context; - Metachunk* c = NULL; + Metachunk* c = nullptr; context.alloc_chunk_expect_success(&c, ROOT_CHUNK_LEVEL, ROOT_CHUNK_LEVEL, 0); context.uncommit_chunk_with_test(c); @@ -136,7 +136,7 @@ TEST_VM(metaspace, get_chunk_with_reserve_limit) { // root chunk. // Cause allocation of the firstone root chunk, should still work: - Metachunk* c = NULL; + Metachunk* c = nullptr; context.alloc_chunk_expect_success(&c, HIGHEST_CHUNK_LEVEL); // and this should need a new root chunk and hence fail: @@ -152,7 +152,7 @@ TEST_VM(metaspace, chunk_allocate_full) { ChunkGtestContext context; for (chunklevel_t lvl = LOWEST_CHUNK_LEVEL; lvl <= HIGHEST_CHUNK_LEVEL; lvl++) { - Metachunk* c = NULL; + Metachunk* c = nullptr; context.alloc_chunk_expect_success(&c, lvl); context.allocate_from_chunk(c, c->word_size()); context.return_chunk(c); @@ -167,7 +167,7 @@ TEST_VM(metaspace, chunk_allocate_random) { for (chunklevel_t lvl = LOWEST_CHUNK_LEVEL; lvl <= HIGHEST_CHUNK_LEVEL; lvl++) { - Metachunk* c = NULL; + Metachunk* c = nullptr; context.alloc_chunk_expect_success(&c, lvl); context.uncommit_chunk_with_test(c); // start out fully uncommitted @@ -202,11 +202,11 @@ TEST_VM(metaspace, chunk_buddy_stuff) { // (Note: strictly speaking the ChunkManager does not promise any placement but // we know how the placement works so these tests make sense). - Metachunk* c1 = NULL; + Metachunk* c1 = nullptr; context.alloc_chunk(&c1, CHUNK_LEVEL_1K); EXPECT_TRUE(c1->is_leader()); - Metachunk* c2 = NULL; + Metachunk* c2 = nullptr; context.alloc_chunk(&c2, CHUNK_LEVEL_1K); EXPECT_FALSE(c2->is_leader()); @@ -234,7 +234,7 @@ TEST_VM(metaspace, chunk_allocate_with_commit_limit) { ChunkGtestContext context(commit_limit); // A big chunk, but uncommitted. - Metachunk* c = NULL; + Metachunk* c = nullptr; context.alloc_chunk_expect_success(&c, ROOT_CHUNK_LEVEL, ROOT_CHUNK_LEVEL, 0); context.uncommit_chunk_with_test(c); // ... just to make sure. @@ -310,7 +310,7 @@ TEST_VM(metaspace, chunk_split_and_merge) { // Split a fully committed chunk. The resulting chunk should be fully // committed as well, and have its content preserved. - Metachunk* c = NULL; + Metachunk* c = nullptr; context.alloc_chunk_expect_success(&c, orig_lvl); // We allocate from this chunk to be able to completely paint the payload. @@ -387,7 +387,7 @@ TEST_VM(metaspace, chunk_enlarge_in_place) { // Starting with the smallest chunk size, attempt to enlarge the chunk in place until we arrive // at root chunk size. Since the state is clean, this should work. - Metachunk* c = NULL; + Metachunk* c = nullptr; context.alloc_chunk_expect_success(&c, HIGHEST_CHUNK_LEVEL); chunklevel_t l = c->level(); diff --git a/test/hotspot/gtest/metaspace/test_metachunklist.cpp b/test/hotspot/gtest/metaspace/test_metachunklist.cpp index ef4cb17e432..59f0959c997 100644 --- a/test/hotspot/gtest/metaspace/test_metachunklist.cpp +++ b/test/hotspot/gtest/metaspace/test_metachunklist.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2020, 2023 SAP SE. All rights reserved. - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, 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 @@ TEST_VM(metaspace, metachunklist) { size_t total_size = 0; for (int i = 0; i < 10; i++) { - Metachunk* c = NULL; + Metachunk* c = nullptr; context.alloc_chunk_expect_success(&c, ChunkLevelRanges::all_chunks().random_value()); chunks[i] = c; total_size += c->committed_words(); @@ -95,7 +95,7 @@ TEST_VM(metaspace, freechunklist) { // Make every other chunk randomly uncommitted, and later we check that committed chunks are sorted in at the front // of the lists. for (int i = 0; i < 100; i++) { - Metachunk* c = NULL; + Metachunk* c = nullptr; context.alloc_chunk_expect_success(&c, ChunkLevelRanges::all_chunks().random_value()); bool uncommitted_chunk = i % 3; if (uncommitted_chunk) { @@ -122,7 +122,7 @@ TEST_VM(metaspace, freechunklist) { for (chunklevel_t lvl = LOWEST_CHUNK_LEVEL; lvl <= HIGHEST_CHUNK_LEVEL; lvl++) { Metachunk* c = lst.remove_first(lvl); bool found_uncommitted = false; - while (c != NULL) { + while (c != nullptr) { LOG("<-" METACHUNK_FULL_FORMAT, METACHUNK_FULL_FORMAT_ARGS(c)); @@ -153,7 +153,7 @@ TEST_VM(metaspace, freechunklist_retrieval) { ChunkGtestContext context; FreeChunkList fcl; - Metachunk* c = NULL; + Metachunk* c = nullptr; // For a chunk level which allows us to have partially committed chunks... const size_t chunk_word_size = Settings::commit_granule_words() * 4; @@ -162,19 +162,19 @@ TEST_VM(metaspace, freechunklist_retrieval) { // get some chunks: // ...a completely uncommitted one ... - Metachunk* c_0 = NULL; + Metachunk* c_0 = nullptr; context.alloc_chunk_expect_success(&c_0, lvl, lvl, 0); // ... a fully committed one ... - Metachunk* c_full = NULL; + Metachunk* c_full = nullptr; context.alloc_chunk_expect_success(&c_full, lvl); // ... a chunk with one commit granule committed ... - Metachunk* c_1g = NULL; + Metachunk* c_1g = nullptr; context.alloc_chunk_expect_success(&c_1g, lvl, lvl, Settings::commit_granule_words()); // ... a chunk with two commit granules committed. - Metachunk* c_2g = NULL; + Metachunk* c_2g = nullptr; context.alloc_chunk_expect_success(&c_2g, lvl, lvl, Settings::commit_granule_words() * 2); LOG("c_0: " METACHUNK_FULL_FORMAT, METACHUNK_FULL_FORMAT_ARGS(c_0)); diff --git a/test/hotspot/gtest/metaspace/test_metaspacearena.cpp b/test/hotspot/gtest/metaspace/test_metaspacearena.cpp index 79643ab2925..f7474da22c0 100644 --- a/test/hotspot/gtest/metaspace/test_metaspacearena.cpp +++ b/test/hotspot/gtest/metaspace/test_metaspacearena.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2023 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -96,12 +96,12 @@ class MetaspaceArenaTestHelper { // in non-void returning tests. void delete_arena_with_tests() { - if (_arena != NULL) { + if (_arena != nullptr) { size_t used_words_before = _used_words_counter.get(); size_t committed_words_before = limiter().committed_words(); DEBUG_ONLY(_arena->verify()); delete _arena; - _arena = NULL; + _arena = nullptr; size_t used_words_after = _used_words_counter.get(); size_t committed_words_after = limiter().committed_words(); ASSERT_0(used_words_after); @@ -111,14 +111,14 @@ class MetaspaceArenaTestHelper { void usage_numbers_with_test(size_t* p_used, size_t* p_committed, size_t* p_capacity) const { _arena->usage_numbers(p_used, p_committed, p_capacity); - if (p_used != NULL) { - if (p_committed != NULL) { + if (p_used != nullptr) { + if (p_committed != nullptr) { ASSERT_GE(*p_committed, *p_used); } // Since we own the used words counter, it should reflect our usage number 1:1 ASSERT_EQ(_used_words_counter.get(), *p_used); } - if (p_committed != NULL && p_capacity != NULL) { + if (p_committed != nullptr && p_capacity != nullptr) { ASSERT_GE(*p_capacity, *p_committed); } } @@ -131,13 +131,13 @@ class MetaspaceArenaTestHelper { // Allocate; caller expects success but is not interested in return value void allocate_from_arena_with_tests_expect_success(size_t word_size) { - MetaWord* dummy = NULL; + MetaWord* dummy = nullptr; allocate_from_arena_with_tests_expect_success(&dummy, word_size); } // Allocate; caller expects failure void allocate_from_arena_with_tests_expect_failure(size_t word_size) { - MetaWord* dummy = NULL; + MetaWord* dummy = nullptr; allocate_from_arena_with_tests(&dummy, word_size); ASSERT_NULL(dummy); } @@ -158,7 +158,7 @@ class MetaspaceArenaTestHelper { size_t used2 = 0, committed2 = 0, capacity2 = 0; usage_numbers_with_test(&used2, &committed2, &capacity2); - if (p == NULL) { + if (p == nullptr) { // Allocation failed. ASSERT_LT(possible_expansion, word_size); ASSERT_EQ(used, used2); @@ -181,7 +181,7 @@ class MetaspaceArenaTestHelper { // Allocate; it may or may not work; but caller does not care for the result value void allocate_from_arena_with_tests(size_t word_size) { - MetaWord* dummy = NULL; + MetaWord* dummy = nullptr; allocate_from_arena_with_tests(&dummy, word_size); } @@ -406,25 +406,25 @@ TEST_VM(metaspace, MetaspaceArena_deallocate) { MetaspaceGtestContext context; MetaspaceArenaTestHelper helper(context, Metaspace::StandardMetaspaceType, false); - MetaWord* p1 = NULL; + MetaWord* p1 = nullptr; helper.allocate_from_arena_with_tests_expect_success(&p1, s); size_t used1 = 0, capacity1 = 0; - helper.usage_numbers_with_test(&used1, NULL, &capacity1); + helper.usage_numbers_with_test(&used1, nullptr, &capacity1); ASSERT_EQ(used1, s); helper.deallocate_with_tests(p1, s); size_t used2 = 0, capacity2 = 0; - helper.usage_numbers_with_test(&used2, NULL, &capacity2); + helper.usage_numbers_with_test(&used2, nullptr, &capacity2); ASSERT_EQ(used1, used2); ASSERT_EQ(capacity2, capacity2); - MetaWord* p2 = NULL; + MetaWord* p2 = nullptr; helper.allocate_from_arena_with_tests_expect_success(&p2, s); size_t used3 = 0, capacity3 = 0; - helper.usage_numbers_with_test(&used3, NULL, &capacity3); + helper.usage_numbers_with_test(&used3, nullptr, &capacity3); ASSERT_EQ(used3, used2); ASSERT_EQ(capacity3, capacity2); @@ -471,8 +471,8 @@ static void test_recover_from_commit_limit_hit() { // Now, allocating from helper3, creep up on the limit size_t allocated_from_3 = 0; - MetaWord* p = NULL; - while ( (helper3.allocate_from_arena_with_tests(&p, 1), p != NULL) && + MetaWord* p = nullptr; + while ( (helper3.allocate_from_arena_with_tests(&p, 1), p != nullptr) && ++allocated_from_3 < Settings::commit_granule_words() * 2); EXPECT_LE(allocated_from_3, Settings::commit_granule_words() * 2); @@ -732,7 +732,7 @@ static void test_repeatedly_allocate_and_deallocate(bool is_topmost) { // Test various sizes, including (important) the max. possible block size = 1 root chunk for (size_t blocksize = Metaspace::max_allocation_word_size(); blocksize >= 1; blocksize /= 2) { size_t used1 = 0, used2 = 0, committed1 = 0, committed2 = 0; - MetaWord* p = NULL, *p2 = NULL; + MetaWord* p = nullptr, *p2 = nullptr; MetaspaceGtestContext context; MetaspaceArenaTestHelper helper(context, Metaspace::StandardMetaspaceType, false); @@ -745,7 +745,7 @@ static void test_repeatedly_allocate_and_deallocate(bool is_topmost) { } // Measure - helper.usage_numbers_with_test(&used1, &committed1, NULL); + helper.usage_numbers_with_test(&used1, &committed1, nullptr); // Dealloc, alloc several times with the same size. for (int i = 0; i < 5; i ++) { @@ -756,7 +756,7 @@ static void test_repeatedly_allocate_and_deallocate(bool is_topmost) { } // Measure again - helper.usage_numbers_with_test(&used2, &committed2, NULL); + helper.usage_numbers_with_test(&used2, &committed2, nullptr); EXPECT_EQ(used2, used1); EXPECT_EQ(committed1, committed2); } diff --git a/test/hotspot/gtest/metaspace/test_metaspacearena_stress.cpp b/test/hotspot/gtest/metaspace/test_metaspacearena_stress.cpp index 2481ae04e4b..7d3df079802 100644 --- a/test/hotspot/gtest/metaspace/test_metaspacearena_stress.cpp +++ b/test/hotspot/gtest/metaspace/test_metaspacearena_stress.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, 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. * @@ -66,13 +66,13 @@ class MetaspaceArenaTestBed : public CHeapObj { // later check for overwriters. struct allocation_t { allocation_t* next; - MetaWord* p; // NULL if deallocated + MetaWord* p; // nullptr if deallocated size_t word_size; void mark() { mark_range(p, word_size); } void verify() const { - if (p != NULL) { + if (p != nullptr) { check_marked_range(p, word_size); } } @@ -128,10 +128,10 @@ class MetaspaceArenaTestBed : public CHeapObj { MetaspaceArenaTestBed(ChunkManager* cm, const ArenaGrowthPolicy* alloc_sequence, SizeAtomicCounter* used_words_counter, SizeRange allocation_range) : - _arena(NULL), + _arena(nullptr), _allocation_range(allocation_range), _size_of_last_failed_allocation(0), - _allocations(NULL), + _allocations(nullptr), _alloc_count(), _dealloc_count() { @@ -143,7 +143,7 @@ class MetaspaceArenaTestBed : public CHeapObj { verify_arena_statistics(); allocation_t* a = _allocations; - while (a != NULL) { + while (a != nullptr) { allocation_t* b = a->next; a->verify(); FREE_C_HEAP_OBJ(a); @@ -166,7 +166,7 @@ class MetaspaceArenaTestBed : public CHeapObj { bool checked_random_allocate() { size_t word_size = 1 + _allocation_range.random_value(); MetaWord* p = _arena->allocate(word_size); - if (p != NULL) { + if (p != nullptr) { EXPECT_TRUE(is_aligned(p, AllocationAlignmentByteSize)); allocation_t* a = NEW_C_HEAP_OBJ(allocation_t, mtInternal); @@ -190,14 +190,14 @@ class MetaspaceArenaTestBed : public CHeapObj { // Deallocate a random allocation void checked_random_deallocate() { allocation_t* a = _allocations; - while (a && a->p != NULL && os::random() % 10 != 0) { + while (a && a->p != nullptr && os::random() % 10 != 0) { a = a->next; } - if (a != NULL && a->p != NULL) { + if (a != nullptr && a->p != nullptr) { a->verify(); _arena->deallocate(a->p, a->word_size); _dealloc_count.add(a->word_size); - a->p = NULL; a->word_size = 0; + a->p = nullptr; a->word_size = 0; if ((_dealloc_count.count() % 20) == 0) { verify_arena_statistics(); DEBUG_ONLY(_arena->verify();) @@ -257,7 +257,7 @@ class MetaspaceArenaTest { DEBUG_ONLY(_testbeds.check_slot_is_not_null(slotindex)); MetaspaceArenaTestBed* bed = _testbeds.at(slotindex); delete bed; // This will return all its memory to the chunk manager - _testbeds.set_at(slotindex, NULL); + _testbeds.set_at(slotindex, nullptr); _num_beds.decrement(); } diff --git a/test/hotspot/gtest/metaspace/test_virtualspacenode.cpp b/test/hotspot/gtest/metaspace/test_virtualspacenode.cpp index 74e0aaa6124..b2a969c1371 100644 --- a/test/hotspot/gtest/metaspace/test_virtualspacenode.cpp +++ b/test/hotspot/gtest/metaspace/test_virtualspacenode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2021 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -91,7 +91,7 @@ class VirtualSpaceNodeTest { verify(); const bool node_is_full = _node->used_words() == _node->word_size(); - Metachunk* c = NULL; + Metachunk* c = nullptr; { MutexLocker fcl(Metaspace_lock, Mutex::_no_safepoint_check_flag); c = _node->allocate_root_chunk(); @@ -258,7 +258,7 @@ class VirtualSpaceNodeTest { //freelist->print_on(tty); - Metachunk* result = NULL; + Metachunk* result = nullptr; { MutexLocker fcl(Metaspace_lock, Mutex::_no_safepoint_check_flag); result = _node->merge(c, freelist); @@ -293,7 +293,7 @@ class VirtualSpaceNodeTest { _counter_reserved_words(), _counter_committed_words(), _commit_limiter(commit_limit), - _node(NULL), + _node(nullptr), _vs_word_size(vs_word_size), _commit_limit(commit_limit) { @@ -327,14 +327,14 @@ class VirtualSpaceNodeTest { } void test_exhaust_node() { - Metachunk* c = NULL; + Metachunk* c = nullptr; bool rc = true; do { c = alloc_root_chunk(); - if (c != NULL) { + if (c != nullptr) { rc = commit_root_chunk(c, c->word_size()); } - } while (c != NULL && rc); + } while (c != nullptr && rc); } void test_arbitrary_commits() { diff --git a/test/hotspot/gtest/nmt/test_nmt_buffer_overflow_detection.cpp b/test/hotspot/gtest/nmt/test_nmt_buffer_overflow_detection.cpp index d293f59367c..1d7d28d5079 100644 --- a/test/hotspot/gtest/nmt/test_nmt_buffer_overflow_detection.cpp +++ b/test/hotspot/gtest/nmt/test_nmt_buffer_overflow_detection.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2022 SAP SE. All rights reserved. - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, 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 @@ -109,7 +109,7 @@ DEFINE_TEST(test_double_free, "header canary") /////// static void test_invalid_block_address() { - // very low, like the result of an overflow or of accessing a NULL this pointer + // very low, like the result of an overflow or of accessing a null this pointer os::free((void*)0x100); } DEFINE_TEST(test_invalid_block_address, "invalid block address") diff --git a/test/hotspot/gtest/nmt/test_nmtpreinit.cpp b/test/hotspot/gtest/nmt/test_nmtpreinit.cpp index 745e4ac3476..a84e3aabd4d 100644 --- a/test/hotspot/gtest/nmt/test_nmtpreinit.cpp +++ b/test/hotspot/gtest/nmt/test_nmtpreinit.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2021, 2022 SAP SE. All rights reserved. - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, 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 @@ -84,11 +84,11 @@ class TestAllocations { os::free(os_malloc(0)); // 0-sized allocation, should be free-able p2 = os_realloc(os_malloc(10), 20); // realloc, growing p3 = os_realloc(os_malloc(20), 10); // realloc, shrinking - p4 = os_realloc(NULL, 10); // realloc with NULL pointer + p4 = os_realloc(nullptr, 10); // realloc with null pointer os_realloc(os_realloc(os_malloc(20), 0), 30); // realloc to size 0 and back up again os::free(os_malloc(20)); // malloc, free os::free(os_realloc(os_malloc(20), 30)); // malloc, realloc, free - os::free(NULL); // free(null) + os::free(nullptr); // free(null) DEBUG_ONLY(NMTPreInit::verify();) // This should result in a fatal native oom error from NMT preinit with a clear error message. diff --git a/test/hotspot/gtest/nmt/test_nmtpreinitmap.cpp b/test/hotspot/gtest/nmt/test_nmtpreinitmap.cpp index f0802e25a44..46cabc04575 100644 --- a/test/hotspot/gtest/nmt/test_nmtpreinitmap.cpp +++ b/test/hotspot/gtest/nmt/test_nmtpreinitmap.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2021, 2022 SAP SE. All rights reserved. - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, 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 @@ -106,7 +106,7 @@ TEST_VM(NMTPreInit, stress_test_map) { NMTPreInitAllocation* a = table.find_and_remove(allocations[i]->payload); ASSERT_EQ(a, allocations[i]); NMTPreInitAllocation::do_free(a); - allocations[i] = NULL; + allocations[i] = nullptr; } print_and_check_table(table, 0); diff --git a/test/hotspot/gtest/runtime/test_ThreadsListHandle.cpp b/test/hotspot/gtest/runtime/test_ThreadsListHandle.cpp index 7802c5c2d21..5caa19fae95 100644 --- a/test/hotspot/gtest/runtime/test_ThreadsListHandle.cpp +++ b/test/hotspot/gtest/runtime/test_ThreadsListHandle.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, 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,10 +83,10 @@ TEST_VM(ThreadsListHandle, sanity) { // // Verify the current thread refers to no ThreadsListHandle: - EXPECT_EQ(ThreadsListHandleTest::get_Thread_threads_hazard_ptr(thr), (ThreadsList*)NULL) - << "thr->_threads_hazard_ptr must be NULL"; - EXPECT_EQ(ThreadsListHandleTest::get_Thread_threads_list_ptr(thr), (SafeThreadsListPtr*) NULL) - << "thr->_threads_list_ptr must be NULL"; + EXPECT_EQ(ThreadsListHandleTest::get_Thread_threads_hazard_ptr(thr), (ThreadsList*)nullptr) + << "thr->_threads_hazard_ptr must be null"; + EXPECT_EQ(ThreadsListHandleTest::get_Thread_threads_list_ptr(thr), (SafeThreadsListPtr*) nullptr) + << "thr->_threads_list_ptr must be null"; EXPECT_EQ(ThreadsListHandleTest::get_Thread_nested_threads_hazard_ptr_cnt(thr), (uint)0) << "thr->_nested_threads_hazard_ptr_cnt must be 0"; @@ -105,8 +105,8 @@ TEST_VM(ThreadsListHandle, sanity) { << "thr->_nested_threads_hazard_ptr_cnt must be 0"; // Verify tlh1 has the right field values: - EXPECT_EQ(list_ptr1->previous(), (SafeThreadsListPtr*)NULL) - << "list_ptr1->previous() must be NULL"; + EXPECT_EQ(list_ptr1->previous(), (SafeThreadsListPtr*)nullptr) + << "list_ptr1->previous() must be null"; EXPECT_EQ(ThreadsListHandleTest::get_STLP_thread(list_ptr1), thr) << "list_ptr1->_thread must match current thread"; EXPECT_EQ(list_ptr1->list(), tlh1.list()) @@ -125,10 +125,10 @@ TEST_VM(ThreadsListHandle, sanity) { // // Verify the current thread refers to no ThreadsListHandle: - EXPECT_EQ(ThreadsListHandleTest::get_Thread_threads_hazard_ptr(thr), (ThreadsList*)NULL) - << "thr->_threads_hazard_ptr must match be NULL"; - EXPECT_EQ(ThreadsListHandleTest::get_Thread_threads_list_ptr(thr), (SafeThreadsListPtr*) NULL) - << "thr->_threads_list_ptr must be NULL"; + EXPECT_EQ(ThreadsListHandleTest::get_Thread_threads_hazard_ptr(thr), (ThreadsList*)nullptr) + << "thr->_threads_hazard_ptr must match be null"; + EXPECT_EQ(ThreadsListHandleTest::get_Thread_threads_list_ptr(thr), (SafeThreadsListPtr*) nullptr) + << "thr->_threads_list_ptr must be null"; EXPECT_EQ(ThreadsListHandleTest::get_Thread_nested_threads_hazard_ptr_cnt(thr), (uint)0) << "thr->_nested_threads_hazard_ptr_cnt must be 0"; @@ -147,8 +147,8 @@ TEST_VM(ThreadsListHandle, sanity) { << "thr->_nested_threads_hazard_ptr_cnt must be 0"; // Verify tlh1 has the right field values: - EXPECT_EQ(list_ptr1->previous(), (SafeThreadsListPtr*)NULL) - << "list_ptr1->previous() must be NULL"; + EXPECT_EQ(list_ptr1->previous(), (SafeThreadsListPtr*)nullptr) + << "list_ptr1->previous() must be null"; EXPECT_EQ(ThreadsListHandleTest::get_STLP_thread(list_ptr1), thr) << "list_ptr1->_thread must match current thread"; EXPECT_EQ(list_ptr1->list(), tlh1.list()) @@ -193,8 +193,8 @@ TEST_VM(ThreadsListHandle, sanity) { << "list_ptr2->_needs_release must be true"; // Verify tlh1 has the right field values: - EXPECT_EQ(list_ptr1->previous(), (SafeThreadsListPtr*)NULL) - << "list_ptr1->previous() must be NULL"; + EXPECT_EQ(list_ptr1->previous(), (SafeThreadsListPtr*)nullptr) + << "list_ptr1->previous() must be null"; EXPECT_EQ(ThreadsListHandleTest::get_STLP_thread(list_ptr1), thr) << "list_ptr1->_thread must match current thread"; EXPECT_EQ(list_ptr1->list(), tlh1.list()) @@ -213,9 +213,9 @@ TEST_VM(ThreadsListHandle, sanity) { // Test case: after first nested ThreadsListHandle (tlh2) has been destroyed - // Verify the current thread's hazard ptr is NULL: - EXPECT_EQ(ThreadsListHandleTest::get_Thread_threads_hazard_ptr(thr), (ThreadsList*)NULL) - << "thr->_threads_hazard_ptr must be NULL"; + // Verify the current thread's hazard ptr is null: + EXPECT_EQ(ThreadsListHandleTest::get_Thread_threads_hazard_ptr(thr), (ThreadsList*)nullptr) + << "thr->_threads_hazard_ptr must be null"; // Verify the current thread's threads list ptr refers to tlh1: EXPECT_EQ(ThreadsListHandleTest::get_Thread_threads_list_ptr(thr), list_ptr1) << "thr->_threads_list_ptr must match list_ptr1"; @@ -223,8 +223,8 @@ TEST_VM(ThreadsListHandle, sanity) { << "thr->_nested_threads_hazard_ptr_cnt must be 0"; // Verify tlh1 has the right field values: - EXPECT_EQ(list_ptr1->previous(), (SafeThreadsListPtr*)NULL) - << "list_ptr1->previous() must be NULL"; + EXPECT_EQ(list_ptr1->previous(), (SafeThreadsListPtr*)nullptr) + << "list_ptr1->previous() must be null"; EXPECT_EQ(ThreadsListHandleTest::get_STLP_thread(list_ptr1), thr) << "list_ptr1->_thread must match current thread"; EXPECT_EQ(list_ptr1->list(), tlh1.list()) @@ -245,10 +245,10 @@ TEST_VM(ThreadsListHandle, sanity) { // // Verify the current thread refers to no ThreadsListHandle: - EXPECT_EQ(ThreadsListHandleTest::get_Thread_threads_hazard_ptr(thr), (ThreadsList*)NULL) - << "thr->_threads_hazard_ptr must match be NULL"; - EXPECT_EQ(ThreadsListHandleTest::get_Thread_threads_list_ptr(thr), (SafeThreadsListPtr*) NULL) - << "thr->_threads_list_ptr must be NULL"; + EXPECT_EQ(ThreadsListHandleTest::get_Thread_threads_hazard_ptr(thr), (ThreadsList*)nullptr) + << "thr->_threads_hazard_ptr must match be null"; + EXPECT_EQ(ThreadsListHandleTest::get_Thread_threads_list_ptr(thr), (SafeThreadsListPtr*) nullptr) + << "thr->_threads_list_ptr must be null"; EXPECT_EQ(ThreadsListHandleTest::get_Thread_nested_threads_hazard_ptr_cnt(thr), (uint)0) << "thr->_nested_threads_hazard_ptr_cnt must be 0"; @@ -267,8 +267,8 @@ TEST_VM(ThreadsListHandle, sanity) { << "thr->_nested_threads_hazard_ptr_cnt must be 0"; // Verify tlh1 has the right field values: - EXPECT_EQ(list_ptr1->previous(), (SafeThreadsListPtr*)NULL) - << "list_ptr1->previous() must be NULL"; + EXPECT_EQ(list_ptr1->previous(), (SafeThreadsListPtr*)nullptr) + << "list_ptr1->previous() must be null"; EXPECT_EQ(ThreadsListHandleTest::get_STLP_thread(list_ptr1), thr) << "list_ptr1->_thread must match current thread"; EXPECT_EQ(list_ptr1->list(), tlh1.list()) @@ -313,8 +313,8 @@ TEST_VM(ThreadsListHandle, sanity) { << "list_ptr2->_needs_release must be true"; // Verify tlh1 has the right field values: - EXPECT_EQ(list_ptr1->previous(), (SafeThreadsListPtr*)NULL) - << "list_ptr1->previous() must be NULL"; + EXPECT_EQ(list_ptr1->previous(), (SafeThreadsListPtr*)nullptr) + << "list_ptr1->previous() must be null"; EXPECT_EQ(ThreadsListHandleTest::get_STLP_thread(list_ptr1), thr) << "list_ptr1->_thread must match current thread"; EXPECT_EQ(list_ptr1->list(), tlh1.list()) @@ -377,8 +377,8 @@ TEST_VM(ThreadsListHandle, sanity) { << "list_ptr2->_needs_release must be true"; // Verify tlh1 has the right field values: - EXPECT_EQ(list_ptr1->previous(), (SafeThreadsListPtr*)NULL) - << "list_ptr1->previous() must be NULL"; + EXPECT_EQ(list_ptr1->previous(), (SafeThreadsListPtr*)nullptr) + << "list_ptr1->previous() must be null"; EXPECT_EQ(ThreadsListHandleTest::get_STLP_thread(list_ptr1), thr) << "list_ptr1->_thread must match current thread"; EXPECT_EQ(list_ptr1->list(), tlh1.list()) @@ -397,9 +397,9 @@ TEST_VM(ThreadsListHandle, sanity) { // Test case: after double nested ThreadsListHandle (tlh3) has been destroyed - // Verify the current thread's hazard ptr is NULL: - EXPECT_EQ(ThreadsListHandleTest::get_Thread_threads_hazard_ptr(thr), (ThreadsList*)NULL) - << "thr->_threads_hazard_ptr must be NULL"; + // Verify the current thread's hazard ptr is null: + EXPECT_EQ(ThreadsListHandleTest::get_Thread_threads_hazard_ptr(thr), (ThreadsList*)nullptr) + << "thr->_threads_hazard_ptr must be null"; // Verify the current thread's threads list ptr refers to tlh2: EXPECT_EQ(tlh1.list(), tlh2.list()) << "tlh1.list() must match tlh2.list()"; @@ -425,8 +425,8 @@ TEST_VM(ThreadsListHandle, sanity) { << "list_ptr2->_needs_release must be true"; // Verify tlh1 has the right field values: - EXPECT_EQ(list_ptr1->previous(), (SafeThreadsListPtr*)NULL) - << "list_ptr1->previous() must be NULL"; + EXPECT_EQ(list_ptr1->previous(), (SafeThreadsListPtr*)nullptr) + << "list_ptr1->previous() must be null"; EXPECT_EQ(ThreadsListHandleTest::get_STLP_thread(list_ptr1), thr) << "list_ptr1->_thread must match current thread"; EXPECT_EQ(list_ptr1->list(), tlh1.list()) @@ -445,9 +445,9 @@ TEST_VM(ThreadsListHandle, sanity) { // Test case: after first nested ThreadsListHandle (tlh2) has been destroyed - // Verify the current thread's hazard ptr is NULL: - EXPECT_EQ(ThreadsListHandleTest::get_Thread_threads_hazard_ptr(thr), (ThreadsList*)NULL) - << "thr->_threads_hazard_ptr must be NULL"; + // Verify the current thread's hazard ptr is null: + EXPECT_EQ(ThreadsListHandleTest::get_Thread_threads_hazard_ptr(thr), (ThreadsList*)nullptr) + << "thr->_threads_hazard_ptr must be null"; // Verify the current thread's threads list ptr refers to tlh1: EXPECT_EQ(ThreadsListHandleTest::get_Thread_threads_list_ptr(thr), list_ptr1) << "thr->_threads_list_ptr must match list_ptr1"; @@ -455,8 +455,8 @@ TEST_VM(ThreadsListHandle, sanity) { << "thr->_nested_threads_hazard_ptr_cnt must be 0"; // Verify tlh1 has the right field values: - EXPECT_EQ(list_ptr1->previous(), (SafeThreadsListPtr*)NULL) - << "list_ptr1->previous() must be NULL"; + EXPECT_EQ(list_ptr1->previous(), (SafeThreadsListPtr*)nullptr) + << "list_ptr1->previous() must be null"; EXPECT_EQ(ThreadsListHandleTest::get_STLP_thread(list_ptr1), thr) << "list_ptr1->_thread must match current thread"; EXPECT_EQ(list_ptr1->list(), tlh1.list()) @@ -477,10 +477,10 @@ TEST_VM(ThreadsListHandle, sanity) { // // Verify the current thread refers to no ThreadsListHandle: - EXPECT_EQ(ThreadsListHandleTest::get_Thread_threads_hazard_ptr(thr), (ThreadsList*)NULL) - << "thr->_threads_hazard_ptr must match be NULL"; - EXPECT_EQ(ThreadsListHandleTest::get_Thread_threads_list_ptr(thr), (SafeThreadsListPtr*) NULL) - << "thr->_threads_list_ptr must be NULL"; + EXPECT_EQ(ThreadsListHandleTest::get_Thread_threads_hazard_ptr(thr), (ThreadsList*)nullptr) + << "thr->_threads_hazard_ptr must match be null"; + EXPECT_EQ(ThreadsListHandleTest::get_Thread_threads_list_ptr(thr), (SafeThreadsListPtr*) nullptr) + << "thr->_threads_list_ptr must be null"; EXPECT_EQ(ThreadsListHandleTest::get_Thread_nested_threads_hazard_ptr_cnt(thr), (uint)0) << "thr->_nested_threads_hazard_ptr_cnt must be 0"; @@ -499,8 +499,8 @@ TEST_VM(ThreadsListHandle, sanity) { << "thr->_nested_threads_hazard_ptr_cnt must be 0"; // Verify tlh1 has the right field values: - EXPECT_EQ(list_ptr1->previous(), (SafeThreadsListPtr*)NULL) - << "list_ptr1->previous() must be NULL"; + EXPECT_EQ(list_ptr1->previous(), (SafeThreadsListPtr*)nullptr) + << "list_ptr1->previous() must be null"; EXPECT_EQ(ThreadsListHandleTest::get_STLP_thread(list_ptr1), thr) << "list_ptr1->_thread must match current thread"; EXPECT_EQ(list_ptr1->list(), tlh1.list()) @@ -545,8 +545,8 @@ TEST_VM(ThreadsListHandle, sanity) { << "list_ptr2a->_needs_release must be true"; // Verify tlh1 has the right field values: - EXPECT_EQ(list_ptr1->previous(), (SafeThreadsListPtr*)NULL) - << "list_ptr1->previous() must be NULL"; + EXPECT_EQ(list_ptr1->previous(), (SafeThreadsListPtr*)nullptr) + << "list_ptr1->previous() must be null"; EXPECT_EQ(ThreadsListHandleTest::get_STLP_thread(list_ptr1), thr) << "list_ptr1->_thread must match current thread"; EXPECT_EQ(list_ptr1->list(), tlh1.list()) @@ -565,9 +565,9 @@ TEST_VM(ThreadsListHandle, sanity) { // Test case: after first back-to-back nested ThreadsListHandle (tlh2a) has been destroyed - // Verify the current thread's hazard ptr is NULL: - EXPECT_EQ(ThreadsListHandleTest::get_Thread_threads_hazard_ptr(thr), (ThreadsList*)NULL) - << "thr->_threads_hazard_ptr must be NULL"; + // Verify the current thread's hazard ptr is null: + EXPECT_EQ(ThreadsListHandleTest::get_Thread_threads_hazard_ptr(thr), (ThreadsList*)nullptr) + << "thr->_threads_hazard_ptr must be null"; // Verify the current thread's threads list ptr refers to tlh1: EXPECT_EQ(ThreadsListHandleTest::get_Thread_threads_list_ptr(thr), list_ptr1) << "thr->_threads_list_ptr must match list_ptr1"; @@ -575,8 +575,8 @@ TEST_VM(ThreadsListHandle, sanity) { << "thr->_nested_threads_hazard_ptr_cnt must be 0"; // Verify tlh1 has the right field values: - EXPECT_EQ(list_ptr1->previous(), (SafeThreadsListPtr*)NULL) - << "list_ptr1->previous() must be NULL"; + EXPECT_EQ(list_ptr1->previous(), (SafeThreadsListPtr*)nullptr) + << "list_ptr1->previous() must be null"; EXPECT_EQ(ThreadsListHandleTest::get_STLP_thread(list_ptr1), thr) << "list_ptr1->_thread must match current thread"; EXPECT_EQ(list_ptr1->list(), tlh1.list()) @@ -623,8 +623,8 @@ TEST_VM(ThreadsListHandle, sanity) { << "list_ptr2b->_needs_release must be true"; // Verify tlh1 has the right field values: - EXPECT_EQ(list_ptr1->previous(), (SafeThreadsListPtr*)NULL) - << "list_ptr1->previous() must be NULL"; + EXPECT_EQ(list_ptr1->previous(), (SafeThreadsListPtr*)nullptr) + << "list_ptr1->previous() must be null"; EXPECT_EQ(ThreadsListHandleTest::get_STLP_thread(list_ptr1), thr) << "list_ptr1->_thread must match current thread"; EXPECT_EQ(list_ptr1->list(), tlh1.list()) @@ -643,9 +643,9 @@ TEST_VM(ThreadsListHandle, sanity) { // Test case: after second back-to-back nested ThreadsListHandle (tlh2b) has been destroyed - // Verify the current thread's hazard ptr is NULL: - EXPECT_EQ(ThreadsListHandleTest::get_Thread_threads_hazard_ptr(thr), (ThreadsList*)NULL) - << "thr->_threads_hazard_ptr must be NULL"; + // Verify the current thread's hazard ptr is null: + EXPECT_EQ(ThreadsListHandleTest::get_Thread_threads_hazard_ptr(thr), (ThreadsList*)nullptr) + << "thr->_threads_hazard_ptr must be null"; // Verify the current thread's threads list ptr refers to tlh1: EXPECT_EQ(ThreadsListHandleTest::get_Thread_threads_list_ptr(thr), list_ptr1) << "thr->_threads_list_ptr must match list_ptr1"; @@ -653,8 +653,8 @@ TEST_VM(ThreadsListHandle, sanity) { << "thr->_nested_threads_hazard_ptr_cnt must be 0"; // Verify tlh1 has the right field values: - EXPECT_EQ(list_ptr1->previous(), (SafeThreadsListPtr*)NULL) - << "list_ptr1->previous() must be NULL"; + EXPECT_EQ(list_ptr1->previous(), (SafeThreadsListPtr*)nullptr) + << "list_ptr1->previous() must be null"; EXPECT_EQ(ThreadsListHandleTest::get_STLP_thread(list_ptr1), thr) << "list_ptr1->_thread must match current thread"; EXPECT_EQ(list_ptr1->list(), tlh1.list()) @@ -675,10 +675,10 @@ TEST_VM(ThreadsListHandle, sanity) { // // Verify the current thread refers to no ThreadsListHandle: - EXPECT_EQ(ThreadsListHandleTest::get_Thread_threads_hazard_ptr(thr), (ThreadsList*)NULL) - << "thr->_threads_hazard_ptr must match be NULL"; - EXPECT_EQ(ThreadsListHandleTest::get_Thread_threads_list_ptr(thr), (SafeThreadsListPtr*) NULL) - << "thr->_threads_list_ptr must be NULL"; + EXPECT_EQ(ThreadsListHandleTest::get_Thread_threads_hazard_ptr(thr), (ThreadsList*)nullptr) + << "thr->_threads_hazard_ptr must match be null"; + EXPECT_EQ(ThreadsListHandleTest::get_Thread_threads_list_ptr(thr), (SafeThreadsListPtr*) nullptr) + << "thr->_threads_list_ptr must be null"; EXPECT_EQ(ThreadsListHandleTest::get_Thread_nested_threads_hazard_ptr_cnt(thr), (uint)0) << "thr->_nested_threads_hazard_ptr_cnt must be 0"; diff --git a/test/hotspot/gtest/runtime/test_arguments.cpp b/test/hotspot/gtest/runtime/test_arguments.cpp index 8d312d4c913..a85183f3a5e 100644 --- a/test/hotspot/gtest/runtime/test_arguments.cpp +++ b/test/hotspot/gtest/runtime/test_arguments.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, 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 @@ -154,7 +154,7 @@ static const intx no_value = 4711; inline intx ArgumentsTest::parse_xss_inner_annotated(const char* str, jint expected_err, const char* file, int line_number) { intx value = no_value; - jint err = parse_xss(NULL /* Silence error messages */, str, &value); + jint err = parse_xss(nullptr /* Silence error messages */, str, &value); EXPECT_EQ(err, expected_err) << "Failure from: " << file << ":" << line_number; return value; } @@ -231,7 +231,7 @@ struct NumericArgument { static void check_invalid_numeric_string(JVMFlag* flag, const char** invalid_strings) { for (uint i = 0; ; i++) { const char* str = invalid_strings[i]; - if (str == NULL) { + if (str == nullptr) { return; } ASSERT_FALSE(ArgumentsTest::parse_argument(flag->name(), str)) @@ -273,7 +273,7 @@ void check_numeric_flag(JVMFlag* flag, T getvalue(JVMFlag* flag), "0x800000000000m", "0x800000000000000k", "-0x8000000t", "-0x800000000g", "-0x800000000000m", "-0x800000000000000k", - NULL, + nullptr, }; check_invalid_numeric_string(flag, invalid_strings); } @@ -283,7 +283,7 @@ void check_numeric_flag(JVMFlag* flag, T getvalue(JVMFlag* flag), "INF", "Inf", "Infinity", "INFINITY", "-INF", "-Inf", "-Infinity", "-INFINITY", "nan", "NAN", "NaN", - NULL, + nullptr, }; check_invalid_numeric_string(flag, invalid_strings_for_double); } else { @@ -293,7 +293,7 @@ void check_numeric_flag(JVMFlag* flag, T getvalue(JVMFlag* flag), "0x10000000000000000", "18446744073709551616", "-0x10000000000000000", "-18446744073709551616", "-0x8000000000000001", "-9223372036854775809", - NULL, + nullptr, }; check_invalid_numeric_string(flag, invalid_strings_for_integers); } @@ -449,7 +449,7 @@ void check_numeric_flag(JVMFlag* flag, T getvalue(JVMFlag* flag), template ::value), ENABLE_IF(sizeof(T) == 4)> void check_flag(const char* f, T getvalue(JVMFlag* flag)) { JVMFlag* flag = JVMFlag::find_flag(f); - if (flag == NULL) { // not available in product builds + if (flag == nullptr) { // not available in product builds return; } @@ -464,7 +464,7 @@ void check_flag(const char* f, T getvalue(JVMFlag* flag)) { template ::value), ENABLE_IF(sizeof(T) == 4)> void check_flag(const char* f, T getvalue(JVMFlag* flag)) { JVMFlag* flag = JVMFlag::find_flag(f); - if (flag == NULL) { // not available in product builds + if (flag == nullptr) { // not available in product builds return; } @@ -479,7 +479,7 @@ void check_flag(const char* f, T getvalue(JVMFlag* flag)) { template ::value), ENABLE_IF(sizeof(T) == 8)> void check_flag(const char* f, T getvalue(JVMFlag* flag)) { JVMFlag* flag = JVMFlag::find_flag(f); - if (flag == NULL) { // not available in product builds + if (flag == nullptr) { // not available in product builds return; } @@ -495,7 +495,7 @@ void check_flag(const char* f, T getvalue(JVMFlag* flag)) { template ::value), ENABLE_IF(sizeof(T) == 8)> void check_flag(const char* f, T getvalue(JVMFlag* flag)) { JVMFlag* flag = JVMFlag::find_flag(f); - if (flag == NULL) { // not available in product builds + if (flag == nullptr) { // not available in product builds return; } @@ -555,7 +555,7 @@ TEST_VM_F(ArgumentsTest, set_numeric_flag_size_t) { TEST_VM_F(ArgumentsTest, set_numeric_flag_double) { JVMFlag* flag = JVMFlag::find_flag("TestFlagFor_double"); - if (flag == NULL) { // not available in product builds + if (flag == nullptr) { // not available in product builds return; } @@ -597,7 +597,7 @@ TEST_VM_F(ArgumentsTest, set_numeric_flag_double) { char* end; errno = 0; double expected = strtod(str, &end); - if (errno == 0 && end != NULL && *end == '\0') { + if (errno == 0 && end != nullptr && *end == '\0') { ASSERT_TRUE(ArgumentsTest::parse_argument(flag->name(), str)) << "Test string '" << str << "' did not parse for type " << flag->type_string() << ". (Expected value = " << expected << ")"; diff --git a/test/hotspot/gtest/runtime/test_classLoader.cpp b/test/hotspot/gtest/runtime/test_classLoader.cpp index b25358ab045..856a561ade2 100644 --- a/test/hotspot/gtest/runtime/test_classLoader.cpp +++ b/test/hotspot/gtest/runtime/test_classLoader.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,16 +30,16 @@ // Tests ClassLoader::package_from_class_name() TEST_VM(ClassLoader, null_class_name) { bool bad_class_name = false; - TempNewSymbol retval = ClassLoader::package_from_class_name(NULL, &bad_class_name); - ASSERT_TRUE(bad_class_name) << "Function did not set bad_class_name with NULL class name"; - ASSERT_TRUE(retval == NULL) << "Wrong package for NULL class name pointer"; + TempNewSymbol retval = ClassLoader::package_from_class_name(nullptr, &bad_class_name); + ASSERT_TRUE(bad_class_name) << "Function did not set bad_class_name with null class name"; + ASSERT_TRUE(retval == nullptr) << "Wrong package for null class name pointer"; } TEST_VM(ClassLoader, empty_class_name) { bool bad_class_name = false; TempNewSymbol name = SymbolTable::new_symbol(""); TempNewSymbol retval = ClassLoader::package_from_class_name(name, &bad_class_name); - ASSERT_TRUE(retval == NULL) << "Wrong package for empty string"; + ASSERT_TRUE(retval == nullptr) << "Wrong package for empty string"; } TEST_VM(ClassLoader, no_slash) { @@ -47,7 +47,7 @@ TEST_VM(ClassLoader, no_slash) { TempNewSymbol name = SymbolTable::new_symbol("L"); TempNewSymbol retval = ClassLoader::package_from_class_name(name, &bad_class_name); ASSERT_FALSE(bad_class_name) << "Function set bad_class_name with empty package"; - ASSERT_TRUE(retval == NULL) << "Wrong package for class with no slashes"; + ASSERT_TRUE(retval == nullptr) << "Wrong package for class with no slashes"; } TEST_VM(ClassLoader, just_slash) { @@ -55,7 +55,7 @@ TEST_VM(ClassLoader, just_slash) { TempNewSymbol name = SymbolTable::new_symbol("/"); TempNewSymbol retval = ClassLoader::package_from_class_name(name, &bad_class_name); ASSERT_TRUE(bad_class_name) << "Function did not set bad_class_name with package of length 0"; - ASSERT_TRUE(retval == NULL) << "Wrong package for class with just slash"; + ASSERT_TRUE(retval == nullptr) << "Wrong package for class with just slash"; } TEST_VM(ClassLoader, multiple_slashes) { @@ -103,5 +103,5 @@ TEST_VM(ClassLoader, class_object_array) { TempNewSymbol name = SymbolTable::new_symbol("[Lpackage/class"); TempNewSymbol retval = ClassLoader::package_from_class_name(name, &bad_class_name); ASSERT_TRUE(bad_class_name) << "Function did not set bad_class_name with array of class objects"; - ASSERT_TRUE(retval == NULL) << "Wrong package for class with leading '[L'"; + ASSERT_TRUE(retval == nullptr) << "Wrong package for class with leading '[L'"; } diff --git a/test/hotspot/gtest/runtime/test_committed_virtualmemory.cpp b/test/hotspot/gtest/runtime/test_committed_virtualmemory.cpp index 40d12a6145c..d4959cfa008 100644 --- a/test/hotspot/gtest/runtime/test_committed_virtualmemory.cpp +++ b/test/hotspot/gtest/runtime/test_committed_virtualmemory.cpp @@ -44,7 +44,7 @@ class CommittedVirtualMemoryTest { VirtualMemoryTracker::snapshot_thread_stacks(); ReservedMemoryRegion* rmr = VirtualMemoryTracker::_reserved_regions->find(ReservedMemoryRegion(stack_end, stack_size)); - ASSERT_TRUE(rmr != NULL); + ASSERT_TRUE(rmr != nullptr); ASSERT_EQ(rmr->base(), stack_end); ASSERT_EQ(rmr->size(), stack_size); @@ -58,7 +58,7 @@ class CommittedVirtualMemoryTest { address stack_top = stack_end + stack_size; bool found_stack_top = false; - for (const CommittedMemoryRegion* region = iter.next(); region != NULL; region = iter.next()) { + for (const CommittedMemoryRegion* region = iter.next(); region != nullptr; region = iter.next()) { if (region->base() + region->size() == stack_top) { ASSERT_TRUE(region->size() <= stack_size); found_stack_top = true; @@ -95,7 +95,7 @@ class CommittedVirtualMemoryTest { char* base = os::reserve_memory(size, !ExecMem, mtThreadStack); bool result = os::commit_memory(base, size, !ExecMem); size_t index; - ASSERT_NE(base, (char*)NULL); + ASSERT_NE(base, (char*)nullptr); for (index = 0; index < touch_pages; index ++) { char* touch_addr = base + page_sz * page_num[index]; *touch_addr = 'a'; @@ -109,14 +109,14 @@ class CommittedVirtualMemoryTest { VirtualMemoryTracker::snapshot_thread_stacks(); ReservedMemoryRegion* rmr = VirtualMemoryTracker::_reserved_regions->find(ReservedMemoryRegion((address)base, size)); - ASSERT_TRUE(rmr != NULL); + ASSERT_TRUE(rmr != nullptr); bool precise_tracking_supported = false; CommittedRegionIterator iter = rmr->iterate_committed_regions(); - for (const CommittedMemoryRegion* region = iter.next(); region != NULL; region = iter.next()) { + for (const CommittedMemoryRegion* region = iter.next(); region != nullptr; region = iter.next()) { if (region->size() == size) { // platforms that do not support precise tracking. - ASSERT_TRUE(iter.next() == NULL); + ASSERT_TRUE(iter.next() == nullptr); break; } else { precise_tracking_supported = true; @@ -136,7 +136,7 @@ class CommittedVirtualMemoryTest { VirtualMemoryTracker::remove_released_region((address)base, size); rmr = VirtualMemoryTracker::_reserved_regions->find(ReservedMemoryRegion((address)base, size)); - ASSERT_TRUE(rmr == NULL); + ASSERT_TRUE(rmr == nullptr); } static void test_committed_region() { @@ -161,7 +161,7 @@ class CommittedVirtualMemoryTest { const size_t num_pages = 4; const size_t size = num_pages * page_sz; char* base = os::reserve_memory(size, !ExecMem, mtTest); - ASSERT_NE(base, (char*)NULL); + ASSERT_NE(base, (char*)nullptr); result = os::commit_memory(base, size, !ExecMem); ASSERT_TRUE(result); diff --git a/test/hotspot/gtest/runtime/test_globals.cpp b/test/hotspot/gtest/runtime/test_globals.cpp index 1b0d58f8fb4..7ee2f940d1b 100644 --- a/test/hotspot/gtest/runtime/test_globals.cpp +++ b/test/hotspot/gtest/runtime/test_globals.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -94,14 +94,14 @@ TEST_VM(FlagAccess, ccstr_flag) { template static JVMFlag::Error get_flag(const char* name) { - JVMFlag* flag = (name == NULL) ? NULL : JVMFlag::find_flag(name); + JVMFlag* flag = (name == nullptr) ? nullptr : JVMFlag::find_flag(name); T val; return JVMFlagAccess::get(flag, &val); } TEST_VM(FlagAccess, wrong_format) { - ASSERT_EQ((get_flag(NULL)), JVMFlag::INVALID_FLAG); + ASSERT_EQ((get_flag(nullptr)), JVMFlag::INVALID_FLAG); // MaxRAMPercentage is a double flag ASSERT_EQ((get_flag ("MaxRAMPercentage")), JVMFlag::WRONG_FORMAT); diff --git a/test/hotspot/gtest/runtime/test_os.cpp b/test/hotspot/gtest/runtime/test_os.cpp index 470f3e7e1d4..990845c1ce7 100644 --- a/test/hotspot/gtest/runtime/test_os.cpp +++ b/test/hotspot/gtest/runtime/test_os.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, 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 @@ -313,8 +313,8 @@ static void test_snprintf(PrintFn pf, bool expect_count) { } // Special case of 0-length buffer with empty (except for terminator) output. - check_snprintf_result(0, 0, pf(NULL, 0, "%s", ""), expect_count); - check_snprintf_result(0, 0, pf(NULL, 0, ""), expect_count); + check_snprintf_result(0, 0, pf(nullptr, 0, "%s", ""), expect_count); + check_snprintf_result(0, 0, pf(nullptr, 0, ""), expect_count); } // This is probably equivalent to os::snprintf, but we're being @@ -368,7 +368,7 @@ static inline bool can_reserve_executable_memory(void) { bool executable = true; size_t len = 128; char* p = os::reserve_memory(len, executable); - bool exec_supported = (p != NULL); + bool exec_supported = (p != nullptr); if (exec_supported) { os::release_memory(p, len); } @@ -401,12 +401,12 @@ static address reserve_multiple(int num_stripes, size_t stripe_len) { const bool exec_supported = can_reserve_executable_memory(); #endif - address p = NULL; - for (int tries = 0; tries < 256 && p == NULL; tries ++) { + address p = nullptr; + for (int tries = 0; tries < 256 && p == nullptr; tries ++) { size_t total_range_len = num_stripes * stripe_len; // Reserve a large contiguous area to get the address space... p = (address)os::reserve_memory(total_range_len); - EXPECT_NE(p, (address)NULL); + EXPECT_NE(p, (address)nullptr); // .. release it... EXPECT_TRUE(os::release_memory((char*)p, total_range_len)); // ... re-reserve in the same spot multiple areas... @@ -420,11 +420,11 @@ static address reserve_multiple(int num_stripes, size_t stripe_len) { const bool executable = stripe % 2 == 0; #endif q = (address)os::attempt_reserve_memory_at((char*)q, stripe_len, executable); - if (q == NULL) { + if (q == nullptr) { // Someone grabbed that area concurrently. Cleanup, then retry. tty->print_cr("reserve_multiple: retry (%d)...", stripe); carefully_release_multiple(p, stripe, stripe_len); - p = NULL; + p = nullptr; } else { EXPECT_TRUE(os::commit_memory((char*)q, stripe_len, executable)); } @@ -440,7 +440,7 @@ static address reserve_one_commit_multiple(int num_stripes, size_t stripe_len) { assert(is_aligned(stripe_len, os::vm_allocation_granularity()), "Sanity"); size_t total_range_len = num_stripes * stripe_len; address p = (address)os::reserve_memory(total_range_len); - EXPECT_NE(p, (address)NULL); + EXPECT_NE(p, (address)nullptr); for (int stripe = 0; stripe < num_stripes; stripe++) { address q = p + (stripe * stripe_len); if (stripe % 2 == 0) { @@ -491,7 +491,7 @@ TEST_VM(os, release_multi_mappings) { // reserve address space... address p = reserve_multiple(num_stripes, stripe_len); - ASSERT_NE(p, (address)NULL); + ASSERT_NE(p, (address)nullptr); PRINT_MAPPINGS("A"); // .. release the middle stripes... @@ -530,7 +530,7 @@ TEST_VM_ASSERT_MSG(os, release_bad_ranges, ".*bad release") { TEST_VM(os, release_bad_ranges) { #endif char* p = os::reserve_memory(4 * M); - ASSERT_NE(p, (char*)NULL); + ASSERT_NE(p, (char*)nullptr); // Release part of range ASSERT_FALSE(os::release_memory(p, M)); // Release part of range @@ -624,13 +624,13 @@ TEST_VM(os, find_mapping_simple) { os::win32::mapping_info_t mapping_info; // Some obvious negatives - ASSERT_FALSE(os::win32::find_mapping((address)NULL, &mapping_info)); + ASSERT_FALSE(os::win32::find_mapping((address)nullptr, &mapping_info)); ASSERT_FALSE(os::win32::find_mapping((address)4711, &mapping_info)); // A simple allocation { address p = (address)os::reserve_memory(total_range_len); - ASSERT_NE(p, (address)NULL); + ASSERT_NE(p, (address)nullptr); PRINT_MAPPINGS("A"); for (size_t offset = 0; offset < total_range_len; offset += 4711) { ASSERT_TRUE(os::win32::find_mapping(p + offset, &mapping_info)); @@ -659,7 +659,7 @@ TEST_VM(os, find_mapping_2) { const size_t stripe_len = total_range_len / 4; address p = reserve_one_commit_multiple(4, stripe_len); - ASSERT_NE(p, (address)NULL); + ASSERT_NE(p, (address)nullptr); PRINT_MAPPINGS("A"); for (size_t offset = 0; offset < total_range_len; offset += 4711) { ASSERT_TRUE(os::win32::find_mapping(p + offset, &mapping_info)); @@ -688,7 +688,7 @@ TEST_VM(os, find_mapping_3) { { const size_t stripe_len = total_range_len / 4; address p = reserve_multiple(4, stripe_len); - ASSERT_NE(p, (address)NULL); + ASSERT_NE(p, (address)nullptr); PRINT_MAPPINGS("E"); for (int stripe = 0; stripe < 4; stripe++) { ASSERT_TRUE(os::win32::find_mapping(p + (stripe * stripe_len), &mapping_info)); @@ -795,8 +795,8 @@ TEST_VM(os, dll_address_to_function_and_library_name) { LOG("os::print_function_and_library_name(st, -1) expects FALSE."); address addr = (address)(intptr_t)-1; EXPECT_FALSE(os::print_function_and_library_name(&st, addr)); - LOG("os::print_function_and_library_name(st, NULL) expects FALSE."); - addr = NULL; + LOG("os::print_function_and_library_name(st, nullptr) expects FALSE."); + addr = nullptr; EXPECT_FALSE(os::print_function_and_library_name(&st, addr)); // Valid addresses @@ -813,7 +813,7 @@ TEST_VM(os, dll_address_to_function_and_library_name) { addr = CAST_FROM_FN_PTR(address, Threads::create_vm); st.reset(); EXPECT_TRUE(os::print_function_and_library_name(&st, addr, - provide_scratch_buffer ? tmp : NULL, + provide_scratch_buffer ? tmp : nullptr, sizeof(tmp), shorten_paths, demangle, strip_arguments)); @@ -859,7 +859,7 @@ static bool very_simple_string_matcher(const char* pattern, const char* s) { TEST_VM(os, iso8601_time) { char buffer[os::iso8601_timestamp_size + 1]; // + space for canary buffer[os::iso8601_timestamp_size] = 'X'; // canary - const char* result = NULL; + const char* result = nullptr; // YYYY-MM-DDThh:mm:ss.mmm+zzzz const char* const pattern_utc = "dddd-dd-dd.dd:dd:dd.ddd.0000"; const char* const pattern_local = "dddd-dd-dd.dd:dd:dd.ddd.dddd"; diff --git a/test/hotspot/gtest/runtime/test_os_linux.cpp b/test/hotspot/gtest/runtime/test_os_linux.cpp index 8be3ac56244..3499815f1dd 100644 --- a/test/hotspot/gtest/runtime/test_os_linux.cpp +++ b/test/hotspot/gtest/runtime/test_os_linux.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,7 +58,7 @@ namespace { } HugeTlbfsMemory(char* const ptr, size_t size) : _ptr(ptr), _size(size) { } ~HugeTlbfsMemory() { - if (_ptr != NULL) { + if (_ptr != nullptr) { os::release_memory_special(_ptr, _size); } } @@ -81,9 +81,9 @@ TEST_VM(os_linux, reserve_memory_special_huge_tlbfs_size_aligned) { size_t lp = os::large_page_size(); for (size_t size = lp; size <= lp * 10; size += lp) { - char* addr = HugeTlbfsMemory::reserve_memory_special_huge_tlbfs(size, lp, lp, NULL, false); + char* addr = HugeTlbfsMemory::reserve_memory_special_huge_tlbfs(size, lp, lp, nullptr, false); - if (addr != NULL) { + if (addr != nullptr) { HugeTlbfsMemory mr(addr, size); small_page_write(addr, size); } @@ -107,8 +107,8 @@ TEST_VM(os_linux, reserve_memory_special_huge_tlbfs_size_not_aligned_without_add for (int i = 0; i < num_sizes; i++) { const size_t size = sizes[i]; for (size_t alignment = ag; is_size_aligned(size, alignment); alignment *= 2) { - char* p = HugeTlbfsMemory::reserve_memory_special_huge_tlbfs(size, alignment, lp, NULL, false); - if (p != NULL) { + char* p = HugeTlbfsMemory::reserve_memory_special_huge_tlbfs(size, alignment, lp, nullptr, false); + if (p != nullptr) { HugeTlbfsMemory mr(p, size); EXPECT_PRED2(is_ptr_aligned, p, alignment) << " size = " << size; small_page_write(p, size); @@ -135,7 +135,7 @@ TEST_VM(os_linux, reserve_memory_special_huge_tlbfs_size_not_aligned_with_good_r // Pre-allocate an area as large as the largest allocation // and aligned to the largest alignment we will be testing. const size_t mapping_size = sizes[num_sizes - 1] * 2; - char* const mapping = (char*) ::mmap(NULL, mapping_size, + char* const mapping = (char*) ::mmap(nullptr, mapping_size, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0); ASSERT_TRUE(mapping != MAP_FAILED) << " mmap failed, mapping_size = " << mapping_size; @@ -148,7 +148,7 @@ TEST_VM(os_linux, reserve_memory_special_huge_tlbfs_size_not_aligned_with_good_r // req_addr must be at least large page aligned. char* const req_addr = align_up(mapping, MAX2(alignment, lp)); char* p = HugeTlbfsMemory::reserve_memory_special_huge_tlbfs(size, alignment, lp, req_addr, false); - if (p != NULL) { + if (p != nullptr) { HugeTlbfsMemory mr(p, size); ASSERT_EQ(req_addr, p) << " size = " << size << ", alignment = " << alignment; small_page_write(p, size); @@ -176,7 +176,7 @@ TEST_VM(os_linux, reserve_memory_special_huge_tlbfs_size_not_aligned_with_bad_re // Pre-allocate an area as large as the largest allocation // and aligned to the largest alignment we will be testing. const size_t mapping_size = sizes[num_sizes - 1] * 2; - char* const mapping = (char*) ::mmap(NULL, mapping_size, + char* const mapping = (char*) ::mmap(nullptr, mapping_size, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0); ASSERT_TRUE(mapping != MAP_FAILED) << " mmap failed, mapping_size = " << mapping_size; @@ -200,8 +200,8 @@ TEST_VM(os_linux, reserve_memory_special_huge_tlbfs_size_not_aligned_with_bad_re char* p = HugeTlbfsMemory::reserve_memory_special_huge_tlbfs(size, alignment, lp, req_addr, false); HugeTlbfsMemory mr(p, size); // as the area around req_addr contains already existing mappings, the API should always - // return NULL (as per contract, it cannot return another address) - EXPECT_TRUE(p == NULL) << " size = " << size + // return null (as per contract, it cannot return another address) + EXPECT_TRUE(p == nullptr) << " size = " << size << ", alignment = " << alignment << ", req_addr = " << req_addr << ", p = " << p; @@ -224,8 +224,8 @@ class TestReserveMemorySpecial : AllStatic { if (!using_static_hugepages()) { return; } - char* addr = os::reserve_memory_special(size, alignment, page_size, NULL, false); - if (addr != NULL) { + char* addr = os::reserve_memory_special(size, alignment, page_size, nullptr, false); + if (addr != nullptr) { small_page_write(addr, size); os::release_memory_special(addr, size); } @@ -254,7 +254,7 @@ class TestReserveMemorySpecial : AllStatic { const int num_sizes = sizeof(sizes) / sizeof(size_t); // For each size/alignment combination, we test three scenarios: - // 1) with req_addr == NULL + // 1) with req_addr == nullptr // 2) with a non-null req_addr at which we expect to successfully allocate // 3) with a non-null req_addr which contains a pre-existing mapping, at which we // expect the allocation to either fail or to ignore req_addr @@ -262,12 +262,12 @@ class TestReserveMemorySpecial : AllStatic { // Pre-allocate two areas; they shall be as large as the largest allocation // and aligned to the largest alignment we will be testing. const size_t mapping_size = sizes[num_sizes - 1] * 2; - char* const mapping1 = (char*) ::mmap(NULL, mapping_size, + char* const mapping1 = (char*) ::mmap(nullptr, mapping_size, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0); EXPECT_NE(mapping1, MAP_FAILED); - char* const mapping2 = (char*) ::mmap(NULL, mapping_size, + char* const mapping2 = (char*) ::mmap(nullptr, mapping_size, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0); EXPECT_NE(mapping2, MAP_FAILED); @@ -281,8 +281,8 @@ class TestReserveMemorySpecial : AllStatic { for (int i = 0; i < num_sizes; i++) { const size_t size = sizes[i]; for (size_t alignment = ag; is_aligned(size, alignment); alignment *= 2) { - char* p = os::reserve_memory_special(size, alignment, lp, NULL, false); - if (p != NULL) { + char* p = os::reserve_memory_special(size, alignment, lp, nullptr, false); + if (p != nullptr) { EXPECT_TRUE(is_aligned(p, alignment)); small_page_write(p, size); os::release_memory_special(p, size); @@ -297,7 +297,7 @@ class TestReserveMemorySpecial : AllStatic { // req_addr must be at least large page aligned. char* const req_addr = align_up(mapping1, MAX2(alignment, lp)); char* p = os::reserve_memory_special(size, alignment, lp, req_addr, false); - if (p != NULL) { + if (p != nullptr) { EXPECT_EQ(p, req_addr); small_page_write(p, size); os::release_memory_special(p, size); @@ -313,8 +313,8 @@ class TestReserveMemorySpecial : AllStatic { char* const req_addr = align_up(mapping2, MAX2(alignment, lp)); char* p = os::reserve_memory_special(size, alignment, lp, req_addr, false); // as the area around req_addr contains already existing mappings, the API should always - // return NULL (as per contract, it cannot return another address) - EXPECT_TRUE(p == NULL); + // return nullptr (as per contract, it cannot return another address) + EXPECT_TRUE(p == nullptr); } } @@ -350,6 +350,40 @@ TEST_VM(os_linux, reserve_memory_special_concurrent) { } } +TEST_VM(os_linux, pretouch_thp_and_use_concurrent) { + // Explicitly enable thp to test cocurrent system calls. + const size_t size = 1 * G; + const bool useThp = UseTransparentHugePages; + UseTransparentHugePages = true; + char* const heap = os::reserve_memory(size, false, mtInternal); + EXPECT_NE(heap, (char*)NULL); + EXPECT_TRUE(os::commit_memory(heap, size, false)); + + { + auto pretouch = [heap, size](Thread*, int) { + os::pretouch_memory(heap, heap + size, os::vm_page_size()); + }; + auto useMemory = [heap, size](Thread*, int) { + int* iptr = reinterpret_cast(heap); + for (int i = 0; i < 1000; i++) *iptr++ = i; + }; + TestThreadGroup pretouchThreads{pretouch, 4}; + TestThreadGroup useMemoryThreads{useMemory, 4}; + useMemoryThreads.doit(); + pretouchThreads.doit(); + useMemoryThreads.join(); + pretouchThreads.join(); + } + + int* iptr = reinterpret_cast(heap); + for (int i = 0; i < 1000; i++) + EXPECT_EQ(*iptr++, i); + + EXPECT_TRUE(os::uncommit_memory(heap, size, false)); + EXPECT_TRUE(os::release_memory(heap, size)); + UseTransparentHugePages = useThp; +} + // Check that method JNI_CreateJavaVM is found. TEST(os_linux, addr_to_function_valid) { char buf[128] = ""; diff --git a/test/hotspot/gtest/runtime/test_os_linux_cgroups.cpp b/test/hotspot/gtest/runtime/test_os_linux_cgroups.cpp index 917dd8bc40c..21e0152a43d 100644 --- a/test/hotspot/gtest/runtime/test_os_linux_cgroups.cpp +++ b/test/hotspot/gtest/runtime/test_os_linux_cgroups.cpp @@ -63,13 +63,13 @@ TEST(cgroupTest, set_cgroupv1_subsystem_path) { TEST(cgroupTest, set_cgroupv2_subsystem_path) { TestCase at_mount_root = { "/sys/fs/cgroup", // mount_path - NULL, // root_path, ignored + nullptr, // root_path, ignored "/", // cgroup_path "/sys/fs/cgroup" // expected_path }; TestCase sub_path = { "/sys/fs/cgroup", // mount_path - NULL, // root_path, ignored + nullptr, // root_path, ignored "/foobar", // cgroup_path "/sys/fs/cgroup/foobar" // expected_path }; diff --git a/test/hotspot/gtest/runtime/test_os_windows.cpp b/test/hotspot/gtest/runtime/test_os_windows.cpp index 3d7f9c5c84c..8c6f003de6f 100644 --- a/test/hotspot/gtest/runtime/test_os_windows.cpp +++ b/test/hotspot/gtest/runtime/test_os_windows.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ namespace { public: MemoryReleaser(char* ptr, size_t size) : _ptr(ptr), _size(size) { } ~MemoryReleaser() { - if (_ptr != NULL) { + if (_ptr != nullptr) { os::release_memory_special(_ptr, _size); } } @@ -53,7 +53,7 @@ namespace { // This is of course only some dodgy assumption, there is no guarantee that the vicinity of // the previously allocated memory is available for allocation. The only actual failure // that is reported is when the test tries to allocate at a particular location but gets a -// different valid one. A NULL return value at this point is not considered an error but may +// different valid one. A nullptr return value at this point is not considered an error but may // be legitimate. void TestReserveMemorySpecial_test() { if (!UseLargePages) { @@ -67,8 +67,8 @@ void TestReserveMemorySpecial_test() { FLAG_SET_CMDLINE(UseNUMAInterleaving, false); const size_t large_allocation_size = os::large_page_size() * 4; - char* result = os::reserve_memory_special(large_allocation_size, os::large_page_size(), os::large_page_size(), NULL, false); - if (result == NULL) { + char* result = os::reserve_memory_special(large_allocation_size, os::large_page_size(), os::large_page_size(), nullptr, false); + if (result == nullptr) { // failed to allocate memory, skipping the test return; } @@ -78,20 +78,20 @@ void TestReserveMemorySpecial_test() { const size_t expected_allocation_size = os::large_page_size(); char* expected_location = result + os::large_page_size(); char* actual_location = os::reserve_memory_special(expected_allocation_size, os::large_page_size(), os::large_page_size(), expected_location, false); - EXPECT_TRUE(actual_location == NULL) << "Should not be allowed to reserve within present reservation"; + EXPECT_TRUE(actual_location == nullptr) << "Should not be allowed to reserve within present reservation"; // Instead try reserving after the first reservation. expected_location = result + large_allocation_size; actual_location = os::reserve_memory_special(expected_allocation_size, os::large_page_size(), os::large_page_size(), expected_location, false); - EXPECT_TRUE(actual_location != NULL) << "Unexpected reservation failure, can’t verify correct location"; + EXPECT_TRUE(actual_location != nullptr) << "Unexpected reservation failure, can’t verify correct location"; EXPECT_TRUE(actual_location == expected_location) << "Reservation must be at requested location"; MemoryReleaser m2(actual_location, os::large_page_size()); // Now try to do a reservation with a larger alignment. const size_t alignment = os::large_page_size() * 2; const size_t new_large_size = alignment * 4; - char* aligned_request = os::reserve_memory_special(new_large_size, alignment, os::large_page_size(), NULL, false); - EXPECT_TRUE(aligned_request != NULL) << "Unexpected reservation failure, can’t verify correct alignment"; + char* aligned_request = os::reserve_memory_special(new_large_size, alignment, os::large_page_size(), nullptr, false); + EXPECT_TRUE(aligned_request != nullptr) << "Unexpected reservation failure, can’t verify correct alignment"; EXPECT_TRUE(is_aligned(aligned_request, alignment)) << "Returned address must be aligned"; MemoryReleaser m3(aligned_request, new_large_size); } @@ -139,7 +139,7 @@ static bool file_exists_w(const wchar_t* path) { static void create_rel_directory_w(const wchar_t* path) { WITH_ABS_PATH(path); EXPECT_FALSE(file_exists_w(abs_path)) << "Can't create directory: \"" << path << "\" already exists"; - BOOL result = CreateDirectoryW(abs_path, NULL); + BOOL result = CreateDirectoryW(abs_path, nullptr); EXPECT_TRUE(result) << "Failed to create directory \"" << path << "\" " << GetLastError(); } @@ -165,7 +165,7 @@ static void delete_empty_rel_directory_w(const wchar_t* path) { static void create_rel_file_w(const wchar_t* path) { WITH_ABS_PATH(path); EXPECT_FALSE(file_exists_w(abs_path)) << "Can't create file: \"" << path << "\" already exists"; - HANDLE h = CreateFileW(abs_path, 0, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE h = CreateFileW(abs_path, 0, 0, nullptr, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr); EXPECT_NE(h, INVALID_HANDLE_VALUE) << "Failed to create file \"" << path << "\": " << GetLastError(); CloseHandle(h); } @@ -218,7 +218,7 @@ static bool unnormalize_path(wchar_t* result, size_t size, bool is_dir, const wc } else if (wcsncmp(src, L"\\\\", 2) == 0) { path_start = wcschr(src + 2, L'?'); - if (path_start == NULL) { + if (path_start == nullptr) { path_start = wcschr(src + 2, L'\\'); } else { path_start = wcschr(path_start, L'\\'); @@ -245,7 +245,7 @@ static bool unnormalize_path(wchar_t* result, size_t size, bool is_dir, const wc const wchar_t* replacement = sep_replacements[i]; dest = my_wcscpy_s(dest - 1, size, result, replacement); } - } else if (path_start != NULL) { + } else if (path_start != nullptr) { if (allow_dotdot_change && (src > path_start + 1) && ((os::random() & 7) == 7)) { wchar_t const* last_sep = src - 2; @@ -397,7 +397,7 @@ static void bench_path(wchar_t* path) { size_t buf_len = strlen(buf); wchar_t* w_path = (wchar_t*) os::malloc(sizeof(wchar_t) * (buf_len + 1), mtInternal); - if (w_path != NULL) { + if (w_path != nullptr) { size_t converted_chars; if (::mbstowcs_s(&converted_chars, w_path, buf_len + 1, buf, buf_len) == ERROR_SUCCESS) { if (t == 1) { @@ -417,7 +417,7 @@ static void bench_path(wchar_t* path) { } succ = false; } - HANDLE h = ::CreateFileW(w_path, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); + HANDLE h = ::CreateFileW(w_path, 0, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr); if (h != INVALID_HANDLE_VALUE) { ::CloseHandle(h); @@ -439,7 +439,7 @@ static void bench_path(wchar_t* path) { jlong ctime = os::javaTimeNanos(); for (int i = 0; i < reps; ++i) { - HANDLE h = ::CreateFileA(buf, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); + HANDLE h = ::CreateFileA(buf, 0, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr); if (h == INVALID_HANDLE_VALUE) { return; diff --git a/test/hotspot/gtest/runtime/test_perfdata.cpp b/test/hotspot/gtest/runtime/test_perfdata.cpp index d1a5db39e9c..781964a39b4 100644 --- a/test/hotspot/gtest/runtime/test_perfdata.cpp +++ b/test/hotspot/gtest/runtime/test_perfdata.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 PerfMemoryTest : public ::testing::Test { TEST_VM_F(PerfMemoryTest, destroy) { PerfMemory::destroy(); - ASSERT_NE(PerfMemory::start(), (char*)NULL) << "PerfMemory::_start should not be NULL"; - ASSERT_NE(PerfMemory::end(), (char*)NULL) << "PerfMemory::_end should not be NULL"; - ASSERT_NE(PerfMemoryTest::top(), (char*)NULL) << "PerfMemory::_top should not be NULL"; - ASSERT_NE(PerfMemoryTest::prologue(), (PerfDataPrologue*)NULL) << "PerfMemory::_prologue should not be NULL"; + ASSERT_NE(PerfMemory::start(), (char*)nullptr) << "PerfMemory::_start should not be null"; + ASSERT_NE(PerfMemory::end(), (char*)nullptr) << "PerfMemory::_end should not be null"; + ASSERT_NE(PerfMemoryTest::top(), (char*)nullptr) << "PerfMemory::_top should not be null"; + ASSERT_NE(PerfMemoryTest::prologue(), (PerfDataPrologue*)nullptr) << "PerfMemory::_prologue should not be null"; ASSERT_NE(PerfMemory::capacity(), (size_t)0) << "PerfMemory::_capacity should not be 0"; } diff --git a/test/hotspot/gtest/runtime/test_safefetch.cpp b/test/hotspot/gtest/runtime/test_safefetch.cpp index 6d7b3f2feb1..3e217cc63da 100644 --- a/test/hotspot/gtest/runtime/test_safefetch.cpp +++ b/test/hotspot/gtest/runtime/test_safefetch.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, 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. * @@ -64,11 +64,11 @@ static void test_safefetchN_negative() { ASSERT_EQ(-1, a); a = SafeFetchN(bad_addressN, ~patternN); ASSERT_EQ(~patternN, a); - // Also test NULL, but not on AIX, where NULL is readable + // Also test nullptr, but not on AIX, where nullptr is readable #ifndef AIX - a = SafeFetchN(NULL, 0); + a = SafeFetchN(nullptr, 0); ASSERT_EQ(0, a); - a = SafeFetchN(NULL, ~patternN); + a = SafeFetchN(nullptr, ~patternN); ASSERT_EQ(~patternN, a); #endif } @@ -80,11 +80,11 @@ static void test_safefetch32_negative() { ASSERT_EQ(-1, a); a = SafeFetch32(bad_address32, ~pattern32); ASSERT_EQ(~pattern32, a); - // Also test NULL, but not on AIX, where NULL is readable + // Also test nullptr, but not on AIX, where nullptr is readable #ifndef AIX - a = SafeFetch32(NULL, 0); + a = SafeFetch32(nullptr, 0); ASSERT_EQ(0, a); - a = SafeFetch32(NULL, ~pattern32); + a = SafeFetch32(nullptr, ~pattern32); ASSERT_EQ(~pattern32, a); #endif } @@ -105,7 +105,7 @@ TEST_VM(os, safefetch32_negative) { test_safefetch32_negative(); } -// Try with Thread::current being NULL. SafeFetch should work then too. +// Try with Thread::current being nullptr. SafeFetch should work then too. // See JDK-8282475 class ThreadCurrentNullMark : public StackObj { diff --git a/test/hotspot/gtest/runtime/test_threads.cpp b/test/hotspot/gtest/runtime/test_threads.cpp index 8e62a4502a8..75890334646 100644 --- a/test/hotspot/gtest/runtime/test_threads.cpp +++ b/test/hotspot/gtest/runtime/test_threads.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, 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 @@ -185,7 +185,7 @@ TEST_VM(ThreadsTest, fast_jni_in_vm) { // DirectByteBuffer is an easy way to trigger GetIntField, // see JDK-8262896 jlong capacity = 0x10000; - jobject buffer = env->NewDirectByteBuffer(NULL, (jlong)capacity); - ASSERT_NE((void*)NULL, buffer); + jobject buffer = env->NewDirectByteBuffer(nullptr, (jlong)capacity); + ASSERT_NE((void*)nullptr, buffer); ASSERT_EQ(capacity, env->GetDirectBufferCapacity(buffer)); } diff --git a/test/hotspot/gtest/runtime/test_virtualMemoryTracker.cpp b/test/hotspot/gtest/runtime/test_virtualMemoryTracker.cpp index 596934e39a8..b098416456d 100644 --- a/test/hotspot/gtest/runtime/test_virtualMemoryTracker.cpp +++ b/test/hotspot/gtest/runtime/test_virtualMemoryTracker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, 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 @@ -55,13 +55,13 @@ namespace { #define check_empty(rmr) \ do { \ - check_inner((rmr), NULL, 0, __FILE__, __LINE__); \ + check_inner((rmr), nullptr, 0, __FILE__, __LINE__); \ } while (false) static void diagnostic_print(ReservedMemoryRegion* rmr) { CommittedRegionIterator iter = rmr->iterate_committed_regions(); LOG("In reserved region " PTR_FORMAT ", size " SIZE_FORMAT_HEX ":", p2i(rmr->base()), rmr->size()); - for (const CommittedMemoryRegion* region = iter.next(); region != NULL; region = iter.next()) { + for (const CommittedMemoryRegion* region = iter.next(); region != nullptr; region = iter.next()) { LOG(" committed region: " PTR_FORMAT ", size " SIZE_FORMAT_HEX, p2i(region->base()), region->size()); } } @@ -76,7 +76,7 @@ static void check_inner(ReservedMemoryRegion* rmr, R* regions, size_t regions_si #define WHERE " from " << file << ":" << line - for (const CommittedMemoryRegion* region = iter.next(); region != NULL; region = iter.next()) { + for (const CommittedMemoryRegion* region = iter.next(); region != nullptr; region = iter.next()) { EXPECT_LT(i, regions_size) << WHERE; EXPECT_EQ(region->base(), regions[i]._addr) << WHERE; EXPECT_EQ(region->size(), regions[i]._size) << WHERE; diff --git a/test/hotspot/gtest/runtime/test_vmStructs.cpp b/test/hotspot/gtest/runtime/test_vmStructs.cpp index de9182e5f4d..8339318cfec 100644 --- a/test/hotspot/gtest/runtime/test_vmStructs.cpp +++ b/test/hotspot/gtest/runtime/test_vmStructs.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, 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 @@ -55,8 +55,8 @@ TEST(VMStructs, last_entries) { TEST(VMStructs, VMTypes_duplicates) { // Check for duplicate entries in type array - for (int i = 0; VMStructs::localHotSpotVMTypes[i].typeName != NULL; i++) { - for (int j = i + 1; VMStructs::localHotSpotVMTypes[j].typeName != NULL; j++) { + for (int i = 0; VMStructs::localHotSpotVMTypes[i].typeName != nullptr; i++) { + for (int j = i + 1; VMStructs::localHotSpotVMTypes[j].typeName != nullptr; j++) { EXPECT_STRNE(VMStructs::localHotSpotVMTypes[i].typeName, VMStructs::localHotSpotVMTypes[j].typeName) << "Duplicate entries on indexes " << i << " and " << j << " : " << VMStructs::localHotSpotVMTypes[i].typeName; } diff --git a/test/hotspot/gtest/testutils.cpp b/test/hotspot/gtest/testutils.cpp index cefa33b08dd..1da4bd2534d 100644 --- a/test/hotspot/gtest/testutils.cpp +++ b/test/hotspot/gtest/testutils.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2021, 2023 SAP SE. All rights reserved. - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, 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 @@ -35,17 +35,17 @@ // Note: these could be made more suitable for covering large ranges (e.g. just mark one byte per page). void GtestUtils::mark_range_with(void* p, size_t s, uint8_t mark) { - if (p != NULL && s > 0) { + if (p != nullptr && s > 0) { ::memset(p, mark, s); } } bool GtestUtils::is_range_marked(const void* p, size_t s, uint8_t expected) { - if (p == NULL || s == 0) { + if (p == nullptr || s == 0) { return true; } - const char* first_wrong = NULL; + const char* first_wrong = nullptr; char* p2 = (char*)p; const char* const end = p2 + s; while (p2 < end) { @@ -56,7 +56,7 @@ bool GtestUtils::is_range_marked(const void* p, size_t s, uint8_t expected) { p2 ++; } - if (first_wrong != NULL) { + if (first_wrong != nullptr) { tty->print_cr("check_range [" PTR_FORMAT ".." PTR_FORMAT "), 0x%X, : wrong pattern around " PTR_FORMAT, p2i(p), p2i(p) + s, expected, p2i(first_wrong)); // Note: We deliberately print the surroundings too without bounds check. Might be interesting, @@ -65,5 +65,5 @@ bool GtestUtils::is_range_marked(const void* p, size_t s, uint8_t expected) { (address)(align_up(end, 0x10) + 0x10), 1); } - return first_wrong == NULL; + return first_wrong == nullptr; } diff --git a/test/hotspot/gtest/testutils.hpp b/test/hotspot/gtest/testutils.hpp index c4c093fff23..01a49fba550 100644 --- a/test/hotspot/gtest/testutils.hpp +++ b/test/hotspot/gtest/testutils.hpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2021, 2023 SAP SE. All rights reserved. - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,12 +33,12 @@ class GtestUtils : public AllStatic { public: // Fill range with a byte mark. - // Tolerates p == NULL or s == 0. + // Tolerates p == nullptr or s == 0. static void mark_range_with(void* p, size_t s, uint8_t mark); // Given a memory range, check that the whole range is filled with the expected byte. // If not, hex dump around first non-matching address and return false. - // If p == NULL or size == 0, returns true. + // If p == nullptr or size == 0, returns true. static bool is_range_marked(const void* p, size_t s, uint8_t expected); // Convenience method with a predefined byte mark. @@ -53,8 +53,8 @@ class GtestUtils : public AllStatic { #define EXPECT_RANGE_IS_MARKED(p, size) EXPECT_TRUE(GtestUtils::is_range_marked(p, size)) // Mimicking the official ASSERT_xx and EXPECT_xx counterparts of the googletest suite. -// (ASSERT|EXPECT)_NOT_NULL: check that the given pointer is not NULL -// (ASSERT|EXPECT)_NULL: check that the given pointer is NULL +// (ASSERT|EXPECT)_NOT_NULL: check that the given pointer is not null +// (ASSERT|EXPECT)_NULL: check that the given pointer is null #define ASSERT_NOT_NULL(p) ASSERT_NE(p2i(p), 0) #define ASSERT_NULL(p) ASSERT_EQ(p2i(p), 0) #define EXPECT_NOT_NULL(p) EXPECT_NE(p2i(p), 0) diff --git a/test/hotspot/gtest/utilities/test_concurrentHashtable.cpp b/test/hotspot/gtest/utilities/test_concurrentHashtable.cpp index 277b2c37b61..426e8cb9bfd 100644 --- a/test/hotspot/gtest/utilities/test_concurrentHashtable.cpp +++ b/test/hotspot/gtest/utilities/test_concurrentHashtable.cpp @@ -105,7 +105,7 @@ struct SimpleTestLookup { uintptr_t _val; SimpleTestLookup(uintptr_t val) : _val(val) {} uintx get_hash() { - return Pointer::get_hash(_val, NULL); + return Pointer::get_hash(_val, nullptr); } bool equals(const uintptr_t* value) { return _val == *value; @@ -119,7 +119,7 @@ struct ValueGet { uintptr_t _return; ValueGet() : _return(0) {} void operator()(uintptr_t* value) { - EXPECT_NE(value, (uintptr_t*)NULL) << "expected valid value"; + EXPECT_NE(value, (uintptr_t*)nullptr) << "expected valid value"; _return = *value; } uintptr_t get_value() const { @@ -562,7 +562,7 @@ struct TestLookup { uintptr_t _val; TestLookup(uintptr_t val) : _val(val) {} uintx get_hash() { - return TestInterface::get_hash(_val, NULL); + return TestInterface::get_hash(_val, nullptr); } bool equals(const uintptr_t* value) { return _val == *value; @@ -684,7 +684,7 @@ class RunnerSimpleInserterThread : public CHTTestThread { public: Semaphore _done; - RunnerSimpleInserterThread(Semaphore* post) : CHTTestThread(0, 0, NULL, post) { + RunnerSimpleInserterThread(Semaphore* post) : CHTTestThread(0, 0, nullptr, post) { _cht = new TestTable(SIZE_32, SIZE_32); }; virtual ~RunnerSimpleInserterThread(){} @@ -768,7 +768,7 @@ class RunnerDeleteInserterThread : public CHTTestThread { public: Semaphore _done; - RunnerDeleteInserterThread(Semaphore* post) : CHTTestThread(0, 0, NULL, post) { + RunnerDeleteInserterThread(Semaphore* post) : CHTTestThread(0, 0, nullptr, post) { _cht = new TestTable(SIZE_32, SIZE_32); }; virtual ~RunnerDeleteInserterThread(){} @@ -795,7 +795,7 @@ class RunnerDeleteInserterThread : public CHTTestThread { TestLookup tl(v); TestGetHandle value_handle(this, _cht); uintptr_t* tmp = value_handle.get(tl); - tv = tmp != NULL ? *tmp : 0; + tv = tmp != nullptr ? *tmp : 0; } EXPECT_TRUE(tv == 0 || tv == v) << "Got unknown value."; } @@ -894,7 +894,7 @@ class RunnerGSInserterThread : public CHTTestThread { uintptr_t _range; Semaphore _done; - RunnerGSInserterThread(Semaphore* post) : CHTTestThread(0, 0, NULL, post) { + RunnerGSInserterThread(Semaphore* post) : CHTTestThread(0, 0, nullptr, post) { _cht = new TestTable(START_SIZE, END_SIZE, 2); }; virtual ~RunnerGSInserterThread(){} @@ -1036,7 +1036,7 @@ class RunnerGI_BD_InserterThread : public CHTTestThread { Semaphore _done; uintptr_t _start; uintptr_t _range; - RunnerGI_BD_InserterThread(Semaphore* post) : CHTTestThread(0, 0, NULL, post) { + RunnerGI_BD_InserterThread(Semaphore* post) : CHTTestThread(0, 0, nullptr, post) { _cht = new TestTable(GI_BD_GI_BD_START_SIZE, GI_BD_END_SIZE, 2); }; virtual ~RunnerGI_BD_InserterThread(){} diff --git a/test/hotspot/gtest/utilities/test_linkedlist.cpp b/test/hotspot/gtest/utilities/test_linkedlist.cpp index 702ab9f6bb3..38bdcb342ef 100644 --- a/test/hotspot/gtest/utilities/test_linkedlist.cpp +++ b/test/hotspot/gtest/utilities/test_linkedlist.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2024, 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 @@ -50,7 +50,7 @@ class Integer : public StackObj { static void check_list_values(const int* expected, const LinkedList* list) { LinkedListNode* head = list->head(); int index = 0; - while (head != NULL) { + while (head != nullptr) { ASSERT_EQ(expected[index], head->peek()->value()) << "Unexpected value at index " << index; head = head->next(); @@ -70,14 +70,14 @@ TEST(LinkedList, simple) { ASSERT_TRUE(!ll.is_empty()) << "Should not be empty"; Integer* i = ll.find(six); - ASSERT_TRUE(i != NULL) << "Should find it"; + ASSERT_TRUE(i != nullptr) << "Should find it"; ASSERT_EQ(six.value(), i->value()) << "Should be 6"; i = ll.find(three); - ASSERT_TRUE(i == NULL) << "Not in the list"; + ASSERT_TRUE(i == nullptr) << "Not in the list"; LinkedListNode* node = ll.find_node(six); - ASSERT_TRUE(node != NULL) << "6 is in the list"; + ASSERT_TRUE(node != nullptr) << "6 is in the list"; ll.insert_after(three, node); ll.insert_before(one, node); @@ -136,7 +136,7 @@ TEST(LinkedList, generic) { LinkedListIterator it2(dummy.head()); EXPECT_TRUE(it2.is_empty()); - EXPECT_EQ(it2.next(), (Integer* )NULL); + EXPECT_EQ(it2.next(), (Integer* )nullptr); } TEST(LinkedList, algorithm) { @@ -145,7 +145,7 @@ TEST(LinkedList, algorithm) { il.add(2); il.add(3); EXPECT_EQ(*il.find(1), 1); - EXPECT_EQ(il.find(404), (int* )NULL); + EXPECT_EQ(il.find(404), (int* )nullptr); EXPECT_TRUE(il.remove(1)); EXPECT_FALSE(il.remove(404)); @@ -189,7 +189,7 @@ TEST(SortedLinkedList, simple) { } LinkedListNode* node = sl.find_node(four); - ASSERT_TRUE(node != NULL) << "4 is in the list"; + ASSERT_TRUE(node != nullptr) << "4 is in the list"; sl.remove_before(node); sl.remove_after(node); int remains[] = {1, 2, 4, 6}; diff --git a/test/hotspot/gtest/utilities/test_lockFreeStack.cpp b/test/hotspot/gtest/utilities/test_lockFreeStack.cpp index d19c078e3e6..50a61657f87 100644 --- a/test/hotspot/gtest/utilities/test_lockFreeStack.cpp +++ b/test/hotspot/gtest/utilities/test_lockFreeStack.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, 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 @@ -82,8 +82,8 @@ LockFreeStackTestBasics::LockFreeStackTestBasics() : stack() { void LockFreeStackTestBasics::initialize() { ASSERT_TRUE(stack.empty()); ASSERT_EQ(0u, stack.length()); - ASSERT_TRUE(stack.pop() == NULL); - ASSERT_TRUE(stack.top() == NULL); + ASSERT_TRUE(stack.pop() == nullptr); + ASSERT_TRUE(stack.top() == nullptr); for (size_t id = 0; id < nelements; ++id) { ASSERT_EQ(id, stack.length()); @@ -101,48 +101,48 @@ TEST_F(LockFreeStackTestBasics, push_pop) { ASSERT_EQ(i, stack.length()); --i; Element* e = stack.pop(); - ASSERT_TRUE(e != NULL); + ASSERT_TRUE(e != nullptr); ASSERT_EQ(&elements[i], e); ASSERT_EQ(i, e->id()); } ASSERT_TRUE(stack.empty()); ASSERT_EQ(0u, stack.length()); - ASSERT_TRUE(stack.pop() == NULL); + ASSERT_TRUE(stack.pop() == nullptr); } TEST_F(LockFreeStackTestBasics, prepend_one) { TestStack other_stack; ASSERT_TRUE(other_stack.empty()); - ASSERT_TRUE(other_stack.pop() == NULL); + ASSERT_TRUE(other_stack.pop() == nullptr); ASSERT_EQ(0u, other_stack.length()); - ASSERT_TRUE(other_stack.top() == NULL); - ASSERT_TRUE(other_stack.pop() == NULL); + ASSERT_TRUE(other_stack.top() == nullptr); + ASSERT_TRUE(other_stack.pop() == nullptr); other_stack.prepend(*stack.pop_all()); ASSERT_EQ(nelements, other_stack.length()); ASSERT_TRUE(stack.empty()); ASSERT_EQ(0u, stack.length()); - ASSERT_TRUE(stack.pop() == NULL); - ASSERT_TRUE(stack.top() == NULL); + ASSERT_TRUE(stack.pop() == nullptr); + ASSERT_TRUE(stack.top() == nullptr); for (size_t i = nelements; i > 0; ) { ASSERT_EQ(i, other_stack.length()); --i; Element* e = other_stack.pop(); - ASSERT_TRUE(e != NULL); + ASSERT_TRUE(e != nullptr); ASSERT_EQ(&elements[i], e); ASSERT_EQ(i, e->id()); } ASSERT_EQ(0u, other_stack.length()); - ASSERT_TRUE(other_stack.pop() == NULL); + ASSERT_TRUE(other_stack.pop() == nullptr); } TEST_F(LockFreeStackTestBasics, prepend_two) { TestStack other_stack; ASSERT_TRUE(other_stack.empty()); ASSERT_EQ(0u, other_stack.length()); - ASSERT_TRUE(other_stack.top() == NULL); - ASSERT_TRUE(other_stack.pop() == NULL); + ASSERT_TRUE(other_stack.top() == nullptr); + ASSERT_TRUE(other_stack.pop() == nullptr); Element* top = stack.pop_all(); ASSERT_EQ(top, &elements[nelements - 1]); @@ -152,17 +152,17 @@ TEST_F(LockFreeStackTestBasics, prepend_two) { ASSERT_EQ(i, other_stack.length()); --i; Element* e = other_stack.pop(); - ASSERT_TRUE(e != NULL); + ASSERT_TRUE(e != nullptr); ASSERT_EQ(&elements[i], e); ASSERT_EQ(i, e->id()); } ASSERT_EQ(0u, other_stack.length()); - ASSERT_TRUE(other_stack.pop() == NULL); + ASSERT_TRUE(other_stack.pop() == nullptr); } TEST_F(LockFreeStackTestBasics, two_stacks) { TestStack1 stack1; - ASSERT_TRUE(stack1.pop() == NULL); + ASSERT_TRUE(stack1.pop() == nullptr); for (size_t id = 0; id < nelements; ++id) { stack1.push(elements[id]); @@ -172,7 +172,7 @@ TEST_F(LockFreeStackTestBasics, two_stacks) { Element* e1 = stack1.top(); while (true) { ASSERT_EQ(e0, e1); - if (e0 == NULL) break; + if (e0 == nullptr) break; e0 = stack.next(*e0); e1 = stack1.next(*e1); } @@ -182,12 +182,12 @@ TEST_F(LockFreeStackTestBasics, two_stacks) { ASSERT_EQ(i, stack1.length()); --i; Element* e = stack.pop(); - ASSERT_TRUE(e != NULL); + ASSERT_TRUE(e != nullptr); ASSERT_EQ(&elements[i], e); ASSERT_EQ(i, e->id()); Element* e1 = stack1.pop(); - ASSERT_TRUE(e1 != NULL); + ASSERT_TRUE(e1 != nullptr); ASSERT_EQ(&elements[i], e1); ASSERT_EQ(i, e1->id()); @@ -195,8 +195,8 @@ TEST_F(LockFreeStackTestBasics, two_stacks) { } ASSERT_EQ(0u, stack.length()); ASSERT_EQ(0u, stack1.length()); - ASSERT_TRUE(stack.pop() == NULL); - ASSERT_TRUE(stack1.pop() == NULL); + ASSERT_TRUE(stack.pop() == nullptr); + ASSERT_TRUE(stack1.pop() == nullptr); } class LockFreeStackTestThread : public JavaTestThread { @@ -229,7 +229,7 @@ class LockFreeStackTestThread : public JavaTestThread { Atomic::release_store_fence(&_ready, true); while (true) { Element* e = _from->pop(); - if (e != NULL) { + if (e != nullptr) { _to->push(*e); Atomic::inc(_processed); ++_local_processed; @@ -300,7 +300,7 @@ TEST_VM(LockFreeStackTest, stress) { ASSERT_EQ(0u, start_stack.length()); ASSERT_EQ(0u, middle_stack.length()); ASSERT_EQ(nelements, final_stack.length()); - while (final_stack.pop() != NULL) {} + while (final_stack.pop() != nullptr) {} FREE_C_HEAP_ARRAY(Element, elements); } diff --git a/test/hotspot/gtest/utilities/test_metaspaceClosure.cpp b/test/hotspot/gtest/utilities/test_metaspaceClosure.cpp index 7760c3cfe12..f5230898760 100644 --- a/test/hotspot/gtest/utilities/test_metaspaceClosure.cpp +++ b/test/hotspot/gtest/utilities/test_metaspaceClosure.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, 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 @@ -35,7 +35,7 @@ class MyMetaData : public MetaspaceObj { MyMetaData* _a; MyMetaData* _b; - MyMetaData() : _a(NULL), _b(NULL) {} + MyMetaData() : _a(nullptr), _b(nullptr) {} MetaspaceObj::Type type() const { return MetaspaceObj::SymbolType; // Just lie. It doesn't matter in this test @@ -64,7 +64,7 @@ class MyUniqueMetaspaceClosure : public MetaspaceClosure { public: MyUniqueMetaspaceClosure() { for (int i = 0; i < SIZE; i++) { - _visited[i] = NULL; + _visited[i] = nullptr; } _count = 0; } @@ -92,7 +92,7 @@ TEST_VM(MetaspaceClosure, MSOPointerArrayRef) { ClassLoaderData* cld = ClassLoaderData::the_null_class_loader_data(); Array* array = MetadataFactory::new_array(cld, 4, THREAD); for (int i = 0; i < array->length(); i++) { - EXPECT_TRUE(array->at(i) == NULL) << "should be initialized to null"; + EXPECT_TRUE(array->at(i) == nullptr) << "should be initialized to null"; } MyMetaData x; @@ -117,8 +117,8 @@ TEST_VM(MetaspaceClosure, MSOArrayRef) { ClassLoaderData* cld = ClassLoaderData::the_null_class_loader_data(); Array* array = MetadataFactory::new_array(cld, 4, THREAD); for (int i = 0; i < array->length(); i++) { - EXPECT_TRUE(array->at(i)._a == NULL) << "should be initialized to null"; - EXPECT_TRUE(array->at(i)._b == NULL) << "should be initialized to null"; + EXPECT_TRUE(array->at(i)._a == nullptr) << "should be initialized to null"; + EXPECT_TRUE(array->at(i)._b == nullptr) << "should be initialized to null"; } MyMetaData x; diff --git a/test/hotspot/gtest/utilities/test_nonblockingQueue.cpp b/test/hotspot/gtest/utilities/test_nonblockingQueue.cpp index 367c57318cc..3aac1a7d273 100644 --- a/test/hotspot/gtest/utilities/test_nonblockingQueue.cpp +++ b/test/hotspot/gtest/utilities/test_nonblockingQueue.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, 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,7 +64,7 @@ static void initialize(Element* elements, size_t size, TestQueue* queue) { ASSERT_TRUE(queue->empty()); ASSERT_EQ(0u, queue->length()); ASSERT_TRUE(queue->is_end(queue->first())); - ASSERT_TRUE(queue->pop() == NULL); + ASSERT_TRUE(queue->pop() == nullptr); for (size_t id = 0; id < size; ++id) { ASSERT_EQ(id, queue->length()); @@ -97,13 +97,13 @@ TEST_F(NonblockingQueueTestBasics, pop) { ASSERT_FALSE(queue.empty()); ASSERT_EQ(nelements - i, queue.length()); Element* e = queue.pop(); - ASSERT_TRUE(e != NULL); + ASSERT_TRUE(e != nullptr); ASSERT_EQ(&elements[i], e); ASSERT_EQ(i, e->id()); } ASSERT_TRUE(queue.empty()); ASSERT_EQ(0u, queue.length()); - ASSERT_TRUE(queue.pop() == NULL); + ASSERT_TRUE(queue.pop() == nullptr); } TEST_F(NonblockingQueueTestBasics, append) { @@ -111,7 +111,7 @@ TEST_F(NonblockingQueueTestBasics, append) { ASSERT_TRUE(other_queue.empty()); ASSERT_EQ(0u, other_queue.length()); ASSERT_TRUE(other_queue.is_end(other_queue.first())); - ASSERT_TRUE(other_queue.pop() == NULL); + ASSERT_TRUE(other_queue.pop() == nullptr); Pair pair = queue.take_all(); other_queue.append(*pair.first, *pair.second); @@ -119,22 +119,22 @@ TEST_F(NonblockingQueueTestBasics, append) { ASSERT_TRUE(queue.empty()); ASSERT_EQ(0u, queue.length()); ASSERT_TRUE(queue.is_end(queue.first())); - ASSERT_TRUE(queue.pop() == NULL); + ASSERT_TRUE(queue.pop() == nullptr); for (size_t i = 0; i < nelements; ++i) { ASSERT_EQ(nelements - i, other_queue.length()); Element* e = other_queue.pop(); - ASSERT_TRUE(e != NULL); + ASSERT_TRUE(e != nullptr); ASSERT_EQ(&elements[i], e); ASSERT_EQ(i, e->id()); } ASSERT_EQ(0u, other_queue.length()); - ASSERT_TRUE(other_queue.pop() == NULL); + ASSERT_TRUE(other_queue.pop() == nullptr); } TEST_F(NonblockingQueueTestBasics, two_queues) { TestQueue1 queue1; - ASSERT_TRUE(queue1.pop() == NULL); + ASSERT_TRUE(queue1.pop() == nullptr); for (size_t id = 0; id < nelements; ++id) { queue1.push(elements[id]); @@ -142,8 +142,8 @@ TEST_F(NonblockingQueueTestBasics, two_queues) { ASSERT_EQ(nelements, queue1.length()); Element* e0 = queue.first(); Element* e1 = queue1.first(); - ASSERT_TRUE(e0 != NULL); - ASSERT_TRUE(e1 != NULL); + ASSERT_TRUE(e0 != nullptr); + ASSERT_TRUE(e1 != nullptr); ASSERT_FALSE(queue.is_end(e0)); ASSERT_FALSE(queue1.is_end(e1)); while (!queue.is_end(e0) && !queue1.is_end(e1)) { @@ -159,12 +159,12 @@ TEST_F(NonblockingQueueTestBasics, two_queues) { ASSERT_EQ(nelements - i, queue1.length()); Element* e = queue.pop(); - ASSERT_TRUE(e != NULL); + ASSERT_TRUE(e != nullptr); ASSERT_EQ(&elements[i], e); ASSERT_EQ(i, e->id()); Element* e1 = queue1.pop(); - ASSERT_TRUE(e1 != NULL); + ASSERT_TRUE(e1 != nullptr); ASSERT_EQ(&elements[i], e1); ASSERT_EQ(i, e1->id()); @@ -172,8 +172,8 @@ TEST_F(NonblockingQueueTestBasics, two_queues) { } ASSERT_EQ(0u, queue.length()); ASSERT_EQ(0u, queue1.length()); - ASSERT_TRUE(queue.pop() == NULL); - ASSERT_TRUE(queue1.pop() == NULL); + ASSERT_TRUE(queue.pop() == nullptr); + ASSERT_TRUE(queue1.pop() == nullptr); } class NonblockingQueueTestThread : public JavaTestThread { @@ -206,7 +206,7 @@ class NonblockingQueueTestThread : public JavaTestThread { Atomic::release_store_fence(&_ready, true); while (true) { Element* e = _from->pop(); - if (e != NULL) { + if (e != nullptr) { _to->push(*e); Atomic::inc(_processed); ++_local_processed; @@ -278,7 +278,7 @@ TEST_VM(NonblockingQueueTest, stress) { ASSERT_EQ(0u, start_queue.length()); ASSERT_EQ(0u, middle_queue.length()); ASSERT_EQ(nelements, final_queue.length()); - while (final_queue.pop() != NULL) {} + while (final_queue.pop() != nullptr) {} FREE_C_HEAP_ARRAY(Element, elements); } diff --git a/test/hotspot/gtest/utilities/test_objectBitSet.cpp b/test/hotspot/gtest/utilities/test_objectBitSet.cpp index a3425e4bfda..8b954ad2a75 100644 --- a/test/hotspot/gtest/utilities/test_objectBitSet.cpp +++ b/test/hotspot/gtest/utilities/test_objectBitSet.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, 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 @@ -32,15 +32,15 @@ TEST_VM(ObjectBitSet, empty) { ASSERT_FALSE(obs.is_marked(&obj1)); } -// NOTE: This is a little weird. NULL is not treated any special: ObjectBitSet will happily -// allocate a fragement for the memory range starting at 0 and mark the first bit when passing NULL. +// NOTE: This is a little weird. nullptr is not treated any special: ObjectBitSet will happily +// allocate a fragement for the memory range starting at 0 and mark the first bit when passing nullptr. // In the absense of any error handling, I am not sure what would possibly be a reasonable better // way to do it, though. TEST_VM(ObjectBitSet, null) { ObjectBitSet obs; - ASSERT_FALSE(obs.is_marked((oop)NULL)); - obs.mark_obj((oop) NULL); - ASSERT_TRUE(obs.is_marked((oop)NULL)); + ASSERT_FALSE(obs.is_marked((oop)nullptr)); + obs.mark_obj((oop) nullptr); + ASSERT_TRUE(obs.is_marked((oop)nullptr)); } TEST_VM(ObjectBitSet, mark_single) { diff --git a/test/hotspot/gtest/utilities/test_quicksort.cpp b/test/hotspot/gtest/utilities/test_quicksort.cpp index 5e909b73531..2ce18486e3e 100644 --- a/test/hotspot/gtest/utilities/test_quicksort.cpp +++ b/test/hotspot/gtest/utilities/test_quicksort.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2024, 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,8 +81,8 @@ extern "C" { TEST(QuickSort, quicksort) { { - int* test_array = NULL; - int* expected_array = NULL; + int* test_array = nullptr; + int* expected_array = nullptr; EXPECT_TRUE(sort_and_compare(test_array, expected_array, 0, test_comparator)); } { diff --git a/test/hotspot/gtest/utilities/test_vmerror.cpp b/test/hotspot/gtest/utilities/test_vmerror.cpp index 46d475dd5b6..5c00fe407f0 100644 --- a/test/hotspot/gtest/utilities/test_vmerror.cpp +++ b/test/hotspot/gtest/utilities/test_vmerror.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, 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,8 +43,8 @@ TEST_VM_ASSERT_MSG(vmErrorTest, resourceMark, const char* const str = "hello"; const size_t num = 500; -TEST_VM_ASSERT_MSG(vmErrorTest, assert1, "assert.str == NULL. failed: expected null") { - vmassert(str == NULL, "expected null"); +TEST_VM_ASSERT_MSG(vmErrorTest, assert1, "assert.str == nullptr. failed: expected null") { + vmassert(str == nullptr, "expected null"); } TEST_VM_ASSERT_MSG(vmErrorTest, assert2, "assert.num == 1023 && .str == 'X'. failed: num=500 str=\"hello\"") { @@ -52,8 +52,8 @@ TEST_VM_ASSERT_MSG(vmErrorTest, assert2, "assert.num == 1023 && .str == 'X'. fai "num=" SIZE_FORMAT " str=\"%s\"", num, str); } -TEST_VM_ASSERT_MSG(vmErrorTest, guarantee1, "guarantee.str == NULL. failed: expected null") { - guarantee(str == NULL, "expected null"); +TEST_VM_ASSERT_MSG(vmErrorTest, guarantee1, "guarantee.str == nullptr. failed: expected null") { + guarantee(str == nullptr, "expected null"); } TEST_VM_ASSERT_MSG(vmErrorTest, guarantee2, "guarantee.num == 1023 && .str == 'X'. failed: num=500 str=\"hello\"") { diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt index 28159a06881..53a4bddd499 100644 --- a/test/hotspot/jtreg/ProblemList.txt +++ b/test/hotspot/jtreg/ProblemList.txt @@ -111,6 +111,8 @@ runtime/StackGuardPages/TestStackGuardPagesNative.java 8303612 linux-all runtime/ErrorHandling/TestDwarf.java#checkDecoder 8305489 linux-all runtime/ErrorHandling/MachCodeFramesInErrorFile.java 8313315 linux-ppc64le runtime/cds/appcds/customLoader/HelloCustom_JFR.java 8241075 linux-all,windows-x64 +runtime/os/TestTransparentHugePageUsage.java 8324776 linux-all +runtime/Thread/TestAlwaysPreTouchStacks.java 8324781 linux-all applications/jcstress/copy.java 8229852 linux-all diff --git a/test/hotspot/jtreg/TEST.ROOT b/test/hotspot/jtreg/TEST.ROOT index 1795e14a6a2..4c9a28a3076 100644 --- a/test/hotspot/jtreg/TEST.ROOT +++ b/test/hotspot/jtreg/TEST.ROOT @@ -33,7 +33,8 @@ # randomness: test uses randomness, test cases differ from run to run # cgroups: test uses cgroups # flag-sensitive: test is sensitive to certain flags and might fail when flags are passed using -vmoptions and -javaoptions -keys=stress headful intermittent randomness cgroups flag-sensitive +# external-dep: test requires external dependencies to work +keys=stress headful intermittent randomness cgroups flag-sensitive external-dep groups=TEST.groups TEST.quick-groups diff --git a/test/hotspot/jtreg/applications/jcstress/TestGenerator.java b/test/hotspot/jtreg/applications/jcstress/TestGenerator.java index 1b8ff81c48a..81d8da356d6 100644 --- a/test/hotspot/jtreg/applications/jcstress/TestGenerator.java +++ b/test/hotspot/jtreg/applications/jcstress/TestGenerator.java @@ -96,6 +96,7 @@ public class TestGenerator { public static String DESC_FORMAT = "\n" + "/**\n" + " * @test %1$s\n" + + " * @key external-dep\n" + " * @library /test/lib /\n" + " * @run driver/timeout=21600 " + JcstressRunner.class.getName() // verbose output diff --git a/test/hotspot/jtreg/applications/jcstress/accessAtomic.java b/test/hotspot/jtreg/applications/jcstress/accessAtomic.java index cfeb8ff0ea7..45311747023 100644 --- a/test/hotspot/jtreg/applications/jcstress/accessAtomic.java +++ b/test/hotspot/jtreg/applications/jcstress/accessAtomic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test accessAtomic + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.accessAtomic\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/acqrel.java b/test/hotspot/jtreg/applications/jcstress/acqrel.java index 0dd102221b5..8313278053e 100644 --- a/test/hotspot/jtreg/applications/jcstress/acqrel.java +++ b/test/hotspot/jtreg/applications/jcstress/acqrel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test acqrel + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.acqrel\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/atomicity.java b/test/hotspot/jtreg/applications/jcstress/atomicity.java index c6c4263aeb0..abffd4fb3dd 100644 --- a/test/hotspot/jtreg/applications/jcstress/atomicity.java +++ b/test/hotspot/jtreg/applications/jcstress/atomicity.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test atomicity + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.atomicity\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/atomics.java b/test/hotspot/jtreg/applications/jcstress/atomics.java index 3527fad666d..449b051efa6 100644 --- a/test/hotspot/jtreg/applications/jcstress/atomics.java +++ b/test/hotspot/jtreg/applications/jcstress/atomics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test atomics + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.atomics\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/causality.java b/test/hotspot/jtreg/applications/jcstress/causality.java index 05ca0dc654a..8cda7d61ade 100644 --- a/test/hotspot/jtreg/applications/jcstress/causality.java +++ b/test/hotspot/jtreg/applications/jcstress/causality.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test causality + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.causality\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/coherence.java b/test/hotspot/jtreg/applications/jcstress/coherence.java index f8368834ac4..c2630c2dd66 100644 --- a/test/hotspot/jtreg/applications/jcstress/coherence.java +++ b/test/hotspot/jtreg/applications/jcstress/coherence.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test coherence + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.coherence\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/collections.java b/test/hotspot/jtreg/applications/jcstress/collections.java index 176f004495b..b1363b25168 100644 --- a/test/hotspot/jtreg/applications/jcstress/collections.java +++ b/test/hotspot/jtreg/applications/jcstress/collections.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test collections + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.collections\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/copy.java b/test/hotspot/jtreg/applications/jcstress/copy.java index b291dbe7cde..a2d0d6f099f 100644 --- a/test/hotspot/jtreg/applications/jcstress/copy.java +++ b/test/hotspot/jtreg/applications/jcstress/copy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test copy + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.copy\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/countdownlatch.java b/test/hotspot/jtreg/applications/jcstress/countdownlatch.java index 290ec80cc8c..cee4f917c6f 100644 --- a/test/hotspot/jtreg/applications/jcstress/countdownlatch.java +++ b/test/hotspot/jtreg/applications/jcstress/countdownlatch.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test countdownlatch + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.countdownlatch\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/defaultValues.java b/test/hotspot/jtreg/applications/jcstress/defaultValues.java index c86529491b9..8fce07d8063 100644 --- a/test/hotspot/jtreg/applications/jcstress/defaultValues.java +++ b/test/hotspot/jtreg/applications/jcstress/defaultValues.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test defaultValues + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.defaultValues\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/executors.java b/test/hotspot/jtreg/applications/jcstress/executors.java index b29bbb6507c..f2f50978404 100644 --- a/test/hotspot/jtreg/applications/jcstress/executors.java +++ b/test/hotspot/jtreg/applications/jcstress/executors.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test executors + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.executors\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/fences.java b/test/hotspot/jtreg/applications/jcstress/fences.java index 5bca0257717..d2925a0a101 100644 --- a/test/hotspot/jtreg/applications/jcstress/fences.java +++ b/test/hotspot/jtreg/applications/jcstress/fences.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test fences + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.fences\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/future.java b/test/hotspot/jtreg/applications/jcstress/future.java index eea5b7de64c..5bc760fe2f5 100644 --- a/test/hotspot/jtreg/applications/jcstress/future.java +++ b/test/hotspot/jtreg/applications/jcstress/future.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test future + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.future\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/init.java b/test/hotspot/jtreg/applications/jcstress/init.java index 625037b8f94..087956881d3 100644 --- a/test/hotspot/jtreg/applications/jcstress/init.java +++ b/test/hotspot/jtreg/applications/jcstress/init.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test init + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.init\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/initClass.java b/test/hotspot/jtreg/applications/jcstress/initClass.java index 5a0e70f19ac..5b936ce46cd 100644 --- a/test/hotspot/jtreg/applications/jcstress/initClass.java +++ b/test/hotspot/jtreg/applications/jcstress/initClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test initClass + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.initClass\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/initLen.java b/test/hotspot/jtreg/applications/jcstress/initLen.java index 4cb040bf878..01ef04b8a13 100644 --- a/test/hotspot/jtreg/applications/jcstress/initLen.java +++ b/test/hotspot/jtreg/applications/jcstress/initLen.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test initLen + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.initLen\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/interrupt.java b/test/hotspot/jtreg/applications/jcstress/interrupt.java index 8e4d2ad0fba..1a9ecc357d4 100644 --- a/test/hotspot/jtreg/applications/jcstress/interrupt.java +++ b/test/hotspot/jtreg/applications/jcstress/interrupt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test interrupt + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.interrupt\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/locks.java b/test/hotspot/jtreg/applications/jcstress/locks.java index 7450e295094..e3e11633323 100644 --- a/test/hotspot/jtreg/applications/jcstress/locks.java +++ b/test/hotspot/jtreg/applications/jcstress/locks.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test locks + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.locks\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/memeffects.java b/test/hotspot/jtreg/applications/jcstress/memeffects.java index d4e1b0e26ce..6be6d180939 100644 --- a/test/hotspot/jtreg/applications/jcstress/memeffects.java +++ b/test/hotspot/jtreg/applications/jcstress/memeffects.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test memeffects + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.memeffects\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/mxbeans.java b/test/hotspot/jtreg/applications/jcstress/mxbeans.java index 64f5e760f95..4714b335bdd 100644 --- a/test/hotspot/jtreg/applications/jcstress/mxbeans.java +++ b/test/hotspot/jtreg/applications/jcstress/mxbeans.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test mxbeans + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.mxbeans\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/oota.java b/test/hotspot/jtreg/applications/jcstress/oota.java index c558006cc9d..6c21e76a7e9 100644 --- a/test/hotspot/jtreg/applications/jcstress/oota.java +++ b/test/hotspot/jtreg/applications/jcstress/oota.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test oota + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.oota\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/seqcst.java b/test/hotspot/jtreg/applications/jcstress/seqcst.java index 7b0bae61855..def96932d7e 100644 --- a/test/hotspot/jtreg/applications/jcstress/seqcst.java +++ b/test/hotspot/jtreg/applications/jcstress/seqcst.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test seqcst + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.seqcst\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/singletons.java b/test/hotspot/jtreg/applications/jcstress/singletons.java index 1ddaaff4c68..9714dc0ea1d 100644 --- a/test/hotspot/jtreg/applications/jcstress/singletons.java +++ b/test/hotspot/jtreg/applications/jcstress/singletons.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test singletons + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.singletons\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/strings.java b/test/hotspot/jtreg/applications/jcstress/strings.java index 76ed85ab65f..caacea9bcc7 100644 --- a/test/hotspot/jtreg/applications/jcstress/strings.java +++ b/test/hotspot/jtreg/applications/jcstress/strings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test strings + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.strings\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/tearing.java b/test/hotspot/jtreg/applications/jcstress/tearing.java index 3b9c96351c1..a55d43964b7 100644 --- a/test/hotspot/jtreg/applications/jcstress/tearing.java +++ b/test/hotspot/jtreg/applications/jcstress/tearing.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test tearing + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.tearing\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/threadlocal.java b/test/hotspot/jtreg/applications/jcstress/threadlocal.java index 4abc459224f..9103b90594a 100644 --- a/test/hotspot/jtreg/applications/jcstress/threadlocal.java +++ b/test/hotspot/jtreg/applications/jcstress/threadlocal.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test threadlocal + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.threadlocal\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/unsafe.java b/test/hotspot/jtreg/applications/jcstress/unsafe.java index 2983d4e8e04..8be919b0c3b 100644 --- a/test/hotspot/jtreg/applications/jcstress/unsafe.java +++ b/test/hotspot/jtreg/applications/jcstress/unsafe.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test unsafe + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.unsafe\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/varhandles.java b/test/hotspot/jtreg/applications/jcstress/varhandles.java index 389714c32a8..af9b4271157 100644 --- a/test/hotspot/jtreg/applications/jcstress/varhandles.java +++ b/test/hotspot/jtreg/applications/jcstress/varhandles.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test varhandles + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.varhandles\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/volatiles.java b/test/hotspot/jtreg/applications/jcstress/volatiles.java index 085289fad24..2f1f015b8d5 100644 --- a/test/hotspot/jtreg/applications/jcstress/volatiles.java +++ b/test/hotspot/jtreg/applications/jcstress/volatiles.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test volatiles + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.volatiles\. */ diff --git a/test/hotspot/jtreg/applications/scimark/Scimark.java b/test/hotspot/jtreg/applications/scimark/Scimark.java index 29f8f555f3b..2b0afb6acbf 100644 --- a/test/hotspot/jtreg/applications/scimark/Scimark.java +++ b/test/hotspot/jtreg/applications/scimark/Scimark.java @@ -23,6 +23,7 @@ /* * @test + * @key external-dep * @library /test/lib * @run driver Scimark */ diff --git a/test/hotspot/jtreg/compiler/ciReplay/TestInliningProtectionDomain.java b/test/hotspot/jtreg/compiler/ciReplay/TestInliningProtectionDomain.java index f2cad243325..31e05ba7ecf 100644 --- a/test/hotspot/jtreg/compiler/ciReplay/TestInliningProtectionDomain.java +++ b/test/hotspot/jtreg/compiler/ciReplay/TestInliningProtectionDomain.java @@ -61,7 +61,7 @@ public void testAction() { boolean inlineFails = testClass == ProtectionDomainTestNoOtherCompilationPrivate.class; int inlineeCount = inlineFails ? 1 : 5; - List inlineesNormal = parseLogFile(LOG_FILE_NORMAL, entryString, "compile_id='" + getCompileIdFromFile(getReplayFileName()), inlineeCount); + List inlineesNormal = parseLogFile(LOG_FILE_NORMAL, entryString, "compile_id='" + getCompileIdFromFile(getReplayFileName()) + "'", inlineeCount); List inlineesReplay = parseLogFile(LOG_FILE_REPLAY, entryString, "test ()V", inlineeCount); verifyLists(inlineesNormal, inlineesReplay, inlineeCount); diff --git a/test/hotspot/jtreg/compiler/escapeAnalysis/TestNestedRelockAtDeopt.java b/test/hotspot/jtreg/compiler/escapeAnalysis/TestNestedRelockAtDeopt.java new file mode 100644 index 00000000000..45bd97b7bc6 --- /dev/null +++ b/test/hotspot/jtreg/compiler/escapeAnalysis/TestNestedRelockAtDeopt.java @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2024, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8324174 + * @summary During deoptimization locking and unlocking for nested locks are executed in incorrect order. + * @requires vm.compMode != "Xint" + * @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation -Xmx128M + * -XX:CompileCommand=exclude,TestNestedRelockAtDeopt::main TestNestedRelockAtDeopt + */ + +import java.util.ArrayList; +public class TestNestedRelockAtDeopt { + + static final int CHUNK = 1000; + static ArrayList arr = null; + + public static void main(String[] args) { + arr = new ArrayList<>(); + try { + while (true) { + test1(); + } + } catch (OutOfMemoryError oom) { + arr = null; // Free memory + System.out.println("OOM caught in test1"); + } + arr = new ArrayList<>(); + try { + while (true) { + test2(); + } + } catch (OutOfMemoryError oom) { + arr = null; // Free memory + System.out.println("OOM caught in test2"); + } + arr = new ArrayList<>(); + TestNestedRelockAtDeopt obj = new TestNestedRelockAtDeopt(); + try { + while (true) { + test3(obj); + } + } catch (OutOfMemoryError oom) { + arr = null; // Free memory + System.out.println("OOM caught in test3"); + } + arr = new ArrayList<>(); + try { + while (true) { + test4(obj); + } + } catch (OutOfMemoryError oom) { + arr = null; // Free memory + System.out.println("OOM caught in test4"); + } + } + + // Nested locks in one method + static void test1() { // Nested lock in one method + synchronized (TestNestedRelockAtDeopt.class) { + synchronized (new TestNestedRelockAtDeopt()) { // lock eliminated - not escaped allocation + synchronized (TestNestedRelockAtDeopt.class) { // nested lock eliminated + synchronized (new TestNestedRelockAtDeopt()) { // lock eliminated - not escaped allocation + synchronized (TestNestedRelockAtDeopt.class) { // nested lock eliminated + arr.add(new byte[CHUNK]); + } + } + } + } + } + } + + // Nested locks in inlined method + static void foo() { + synchronized (new TestNestedRelockAtDeopt()) { // lock eliminated - not escaped allocation + synchronized (TestNestedRelockAtDeopt.class) { // nested lock eliminated when inlined + arr.add(new byte[CHUNK]); + } + } + } + + static void test2() { + synchronized (TestNestedRelockAtDeopt.class) { + synchronized (new TestNestedRelockAtDeopt()) { // lock eliminated - not escaped allocation + synchronized (TestNestedRelockAtDeopt.class) { // nested lock eliminated + foo(); // Inline + } + } + } + } + + // Nested locks in one method + static void test3(TestNestedRelockAtDeopt obj) { + synchronized (TestNestedRelockAtDeopt.class) { + synchronized (obj) { // lock not eliminated - external object + synchronized (TestNestedRelockAtDeopt.class) { // nested lock eliminated + synchronized (obj) { // nested lock eliminated + synchronized (TestNestedRelockAtDeopt.class) { // nested lock eliminated + arr.add(new byte[CHUNK]); + } + } + } + } + } + } + + // Nested locks with different objects in inlined method + static void bar(TestNestedRelockAtDeopt obj) { + synchronized (obj) { // nested lock eliminated when inlined + synchronized (TestNestedRelockAtDeopt.class) { // nested lock eliminated when inlined + arr.add(new byte[CHUNK]); + } + } + } + + static void test4(TestNestedRelockAtDeopt obj) { + synchronized (TestNestedRelockAtDeopt.class) { + synchronized (obj) { // lock not eliminated - external object + synchronized (TestNestedRelockAtDeopt.class) { // nested lock eliminated + bar(obj); // Inline + } + } + } + } +} diff --git a/test/hotspot/jtreg/compiler/locks/TestNestedSynchronize.java b/test/hotspot/jtreg/compiler/locks/TestNestedSynchronize.java new file mode 100644 index 00000000000..874d56fc93b --- /dev/null +++ b/test/hotspot/jtreg/compiler/locks/TestNestedSynchronize.java @@ -0,0 +1,238 @@ +/* + * Copyright (c) 2024, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8322996 + * @summary Ensure no assert error in C2 with deeply nested synchronize + * statements. + * @run main/othervm -XX:CompileCommand=compileonly,compiler.locks.TestNestedSynchronize::test + * -Xcomp + * compiler.locks.TestNestedSynchronize + */ + +package compiler.locks; + +public class TestNestedSynchronize { + + public static void main(String[] args) { + test(); + } + + public static void test() { + + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + synchronized (TestNestedSynchronize.class) { + + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} diff --git a/test/hotspot/jtreg/compiler/loopopts/superword/TestUnorderedReductionPartialVectorization.java b/test/hotspot/jtreg/compiler/loopopts/superword/TestUnorderedReductionPartialVectorization.java index 431bbe9ac4f..666ddaac441 100644 --- a/test/hotspot/jtreg/compiler/loopopts/superword/TestUnorderedReductionPartialVectorization.java +++ b/test/hotspot/jtreg/compiler/loopopts/superword/TestUnorderedReductionPartialVectorization.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, 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,7 +64,7 @@ public void runTests() throws Exception { IRNode.OR_REDUCTION_V, "> 0",}, applyIfCPUFeatureOr = {"avx2", "true"}) static long test1(int[] data, long sum) { - for (int i = 0; i < data.length; i++) { + for (int i = 0; i < data.length; i+=2) { // Mixing int and long ops means we only end up allowing half of the int // loads in one pack, and we have two int packs. The first pack has one // of the pairs missing because of the store, which creates a dependency. @@ -77,6 +77,17 @@ static long test1(int[] data, long sum) { int v = data[i]; // int read data[0] = 0; // ruin the first pack sum |= v; // long reduction (and implicit cast from int to long) + + // This example used to rely on that reductions were ignored in SuperWord::unrolling_analysis, + // and hence the largest data type in the loop was the ints. This would then unroll the doubles + // for twice the vector length, and this resulted in us having twice as many packs. Because of + // the store "data[0] = 0", the first packs were destroyed, since they do not have power of 2 + // size. + // Now, we no longer ignore reductions, and now we unroll half as much before SuperWord. This + // means we would only get one pack per operation, and that one would get ruined, and we have + // no vectorization. We now ensure there are again 2 packs per operation with a 2x hand unroll. + int v2 = data[i + 1]; + sum |= v2; } return sum; } diff --git a/test/hotspot/jtreg/compiler/oracle/TestInvalidCompileCommand.java b/test/hotspot/jtreg/compiler/oracle/TestInvalidCompileCommand.java index 6e23aa5d6e0..a20a9359111 100644 --- a/test/hotspot/jtreg/compiler/oracle/TestInvalidCompileCommand.java +++ b/test/hotspot/jtreg/compiler/oracle/TestInvalidCompileCommand.java @@ -52,7 +52,7 @@ public class TestInvalidCompileCommand { "-version" }, { - "-XX:CompileCommand=option,Test::test,VectorizeDebug,3", + "-XX:CompileCommand=option,Test::test,MemStat,3", "-version" }, { @@ -72,7 +72,7 @@ public class TestInvalidCompileCommand { "Missing type 'intx' before option 'RepeatCompilation'" }, { - "Missing type 'uintx' before option 'VectorizeDebug'" + "Missing type 'uintx' before option 'MemStat'" }, { "Missing type 'ccstrlist' before option 'ControlIntrinsic'" diff --git a/test/hotspot/jtreg/runtime/CommandLine/VMAliasOptions.java b/test/hotspot/jtreg/runtime/CommandLine/VMAliasOptions.java index d7262a8b8d6..b11d6ea1d3b 100644 --- a/test/hotspot/jtreg/runtime/CommandLine/VMAliasOptions.java +++ b/test/hotspot/jtreg/runtime/CommandLine/VMAliasOptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,6 @@ public class VMAliasOptions { * (true/false/n/string)}. */ public static final String[][] ALIAS_OPTIONS = { - {"DefaultMaxRAMFraction", "MaxRAMFraction", "1032"}, {"CreateMinidumpOnCrash", "CreateCoredumpOnCrash", "false" }, }; diff --git a/test/hotspot/jtreg/runtime/CommandLine/VMDeprecatedOptions.java b/test/hotspot/jtreg/runtime/CommandLine/VMDeprecatedOptions.java index 95dd88c7223..49399ca2135 100644 --- a/test/hotspot/jtreg/runtime/CommandLine/VMDeprecatedOptions.java +++ b/test/hotspot/jtreg/runtime/CommandLine/VMDeprecatedOptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, 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,15 +56,10 @@ public class VMDeprecatedOptions { ArrayList deprecated = new ArrayList( Arrays.asList(new String[][] { // deprecated non-alias flags: - {"MaxGCMinorPauseMillis", "1032"}, - {"MaxRAMFraction", "8"}, - {"MinRAMFraction", "2"}, - {"InitialRAMFraction", "64"}, {"TLABStats", "false"}, {"AllowRedefinitionToAddDeleteMethods", "true"}, // deprecated alias flags (see also aliased_jvm_flags): - {"DefaultMaxRAMFraction", "4"}, {"CreateMinidumpOnCrash", "false"} } )); diff --git a/test/hotspot/jtreg/runtime/Thread/libAsyncExceptionOnMonitorEnter.cpp b/test/hotspot/jtreg/runtime/Thread/libAsyncExceptionOnMonitorEnter.cpp index 1b5833d8042..0249235bc18 100644 --- a/test/hotspot/jtreg/runtime/Thread/libAsyncExceptionOnMonitorEnter.cpp +++ b/test/hotspot/jtreg/runtime/Thread/libAsyncExceptionOnMonitorEnter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, 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 @@ -26,7 +26,7 @@ extern "C" { -static jvmtiEnv* jvmti = NULL; +static jvmtiEnv* jvmti = nullptr; static jrawMonitorID monitor; JNIEXPORT jint JNICALL diff --git a/test/hotspot/jtreg/runtime/Thread/libStopAtExit.cpp b/test/hotspot/jtreg/runtime/Thread/libStopAtExit.cpp index 1204915050b..8432912876b 100644 --- a/test/hotspot/jtreg/runtime/Thread/libStopAtExit.cpp +++ b/test/hotspot/jtreg/runtime/Thread/libStopAtExit.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, 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 @@ -26,7 +26,7 @@ extern "C" { -static jvmtiEnv* jvmti = NULL; +static jvmtiEnv* jvmti = nullptr; #define LOG(...) \ do { \ diff --git a/test/hotspot/jtreg/runtime/Thread/libSuspendAtExit.cpp b/test/hotspot/jtreg/runtime/Thread/libSuspendAtExit.cpp index 2a64e1a249f..b49cbf2c924 100644 --- a/test/hotspot/jtreg/runtime/Thread/libSuspendAtExit.cpp +++ b/test/hotspot/jtreg/runtime/Thread/libSuspendAtExit.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, 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 @@ -26,7 +26,7 @@ extern "C" { -static jvmtiEnv* jvmti = NULL; +static jvmtiEnv* jvmti = nullptr; #define LOG(...) \ do { \ diff --git a/test/hotspot/jtreg/runtime/cds/appcds/TransformInterfaceOfLambda.java b/test/hotspot/jtreg/runtime/cds/appcds/TransformInterfaceOfLambda.java new file mode 100644 index 00000000000..8bbc713fa6f --- /dev/null +++ b/test/hotspot/jtreg/runtime/cds/appcds/TransformInterfaceOfLambda.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2024, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +/* + * @test + * @bug 8323950 + * @summary Transforming an interface of an archived lambda proxy class should not + * crash the VM. The lambda proxy class should be regenerated during runtime. + * @requires vm.cds + * @requires vm.jvmti + * @requires vm.flagless + * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds/test-classes + * @compile test-classes/SimpleTest.java + * @compile test-classes/TransformBootClass.java + * @run driver TransformInterfaceOfLambda + */ + +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.helpers.ClassFileInstaller; + +public class TransformInterfaceOfLambda { + + public static String agentClasses[] = { + TransformBootClass.class.getName(), + }; + + public static void main(String[] args) throws Exception { + String mainClass = SimpleTest.class.getName(); + String namePrefix = "transform-interface-of-lambda"; + JarBuilder.build(namePrefix, mainClass); + + String appJar = TestCommon.getTestJar(namePrefix + ".jar"); + + String agentJar = + ClassFileInstaller.writeJar("TransformBootClass.jar", + ClassFileInstaller.Manifest.fromSourceFile("test-classes/TransformBootClass.mf"), + agentClasses); + String useJavaAgent = "-javaagent:" + agentJar + "=java/util/function/IntFunction"; + + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( + "-cp", appJar, "-Xlog:class+load,cds=debug", + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+AllowArchivingWithJavaAgent", + useJavaAgent, + mainClass); + OutputAnalyzer out = new OutputAnalyzer(pb.start()); + System.out.println(out.getStdout()); + out.shouldHaveExitValue(0) + // the class loaded by the SimpleTest should be from the archive + .shouldContain("[class,load] java.text.SimpleDateFormat source: shared objects file") + // the IntFunction is the interface which is being transformed. The + // interface is a super type of the following lambda proxy class. + .shouldContain("Transforming class java/util/function/IntFunction") + // the lambda proxy class should be regenerated + .shouldMatch(".class.load.*sun.util.locale.provider.LocaleProviderAdapter[$][$]Lambda/0x.*source:.*sun.util.locale.provider.LocaleProviderAdapter"); + } +} diff --git a/test/hotspot/jtreg/runtime/cds/appcds/test-classes/SimpleTest.java b/test/hotspot/jtreg/runtime/cds/appcds/test-classes/SimpleTest.java new file mode 100644 index 00000000000..7d6ecb73047 --- /dev/null +++ b/test/hotspot/jtreg/runtime/cds/appcds/test-classes/SimpleTest.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +/* + * Loading the java.text.SimpleDateFormat class will in turn load the + * sun.util.locale.provider.LocaleProviderAdapter$$Lambda/0x... lambda proxy class + * which will also load its interface java.util.function.IntFunction. + * By default, all of the above classes should be in the default CDS archive. + */ +public class SimpleTest { + public static void main(String[] args) throws Exception { + new java.text.SimpleDateFormat(); + } +} diff --git a/test/hotspot/jtreg/runtime/clinit/libClassInitBarrier.cpp b/test/hotspot/jtreg/runtime/clinit/libClassInitBarrier.cpp index 521c51ce6af..dce5c1057a8 100644 --- a/test/hotspot/jtreg/runtime/clinit/libClassInitBarrier.cpp +++ b/test/hotspot/jtreg/runtime/clinit/libClassInitBarrier.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,38 +39,38 @@ static jfieldID test_A_f_id; extern "C" { JNIEXPORT jboolean JNICALL Java_ClassInitBarrier_init(JNIEnv* env, jclass cls) { jclass runnable = env->FindClass("java/lang/Runnable"); - if (runnable == NULL) return JNI_FALSE; + if (runnable == nullptr) return JNI_FALSE; methodId = env->GetMethodID(runnable, "run", "()V"); - if (methodId == NULL) return JNI_FALSE; + if (methodId == nullptr) return JNI_FALSE; return JNI_TRUE; } JNIEXPORT jboolean JNICALL Java_ClassInitBarrier_00024Test_00024A_init(JNIEnv* env, jclass cls, jclass arg1) { test_class_A = (jclass)env->NewGlobalRef(cls); - if (test_class_A == NULL) return JNI_FALSE; + if (test_class_A == nullptr) return JNI_FALSE; test_class_B = (jclass)env->NewGlobalRef(arg1); - if (test_class_B == NULL) return JNI_FALSE; + if (test_class_B == nullptr) return JNI_FALSE; test_staticM_id = env->GetStaticMethodID(test_class_A, "staticM", "(Ljava/lang/Runnable;)V"); - if (test_staticM_id == NULL) return JNI_FALSE; + if (test_staticM_id == nullptr) return JNI_FALSE; test_staticS_id = env->GetStaticMethodID(test_class_A, "staticS", "(Ljava/lang/Runnable;)V"); - if (test_staticS_id == NULL) return JNI_FALSE; + if (test_staticS_id == nullptr) return JNI_FALSE; test_staticN_id = env->GetStaticMethodID(test_class_A, "staticN", "(Ljava/lang/Runnable;)V"); - if (test_staticN_id == NULL) return JNI_FALSE; + if (test_staticN_id == nullptr) return JNI_FALSE; test_A_m_id = env->GetMethodID(test_class_A, "m", "()V"); - if (test_A_m_id == NULL) return JNI_FALSE; + if (test_A_m_id == nullptr) return JNI_FALSE; test_staticF_id = env->GetStaticFieldID(test_class_A, "staticF", "I"); - if (test_staticF_id == NULL) return JNI_FALSE; + if (test_staticF_id == nullptr) return JNI_FALSE; test_A_f_id = env->GetFieldID(test_class_A, "f", "I"); - if (test_A_f_id == NULL) return JNI_FALSE; + if (test_A_f_id == nullptr) return JNI_FALSE; return JNI_TRUE; } @@ -105,11 +105,11 @@ extern "C" { JNIEXPORT jobject JNICALL Java_ClassInitBarrier_00024Test_testNewInstanceAJNI(JNIEnv* env, jclass cls, jobject action) { jobject obj = env->AllocObject(test_class_A); // A obj = new A(); if (env->ExceptionOccurred()) { - return NULL; - } else if (obj == NULL) { + return nullptr; + } else if (obj == nullptr) { jclass errorClass = env->FindClass("java/lang/AssertionError"); int ret = env->ThrowNew(errorClass, "JNI: AllocObject: allocation failed, but no exception thrown"); - return NULL; + return nullptr; } env->CallVoidMethod(action, methodId); // action.run(); return obj; @@ -118,11 +118,11 @@ extern "C" { JNIEXPORT jobject JNICALL Java_ClassInitBarrier_00024Test_testNewInstanceBJNI(JNIEnv* env, jclass cls, jobject action) { jobject obj = env->AllocObject(test_class_B); // B obj = new B(); if (env->ExceptionOccurred()) { - return NULL; - } else if (obj == NULL) { + return nullptr; + } else if (obj == nullptr) { jclass errorClass = env->FindClass("java/lang/AssertionError"); int ret = env->ThrowNew(errorClass, "JNI: AllocObject: allocation failed, but no exception thrown"); - return NULL; + return nullptr; } env->CallVoidMethod(action, methodId); // action.run(); return obj; diff --git a/test/hotspot/jtreg/runtime/os/TestTransparentHugePageUsage.java b/test/hotspot/jtreg/runtime/os/TestTransparentHugePageUsage.java new file mode 100644 index 00000000000..2b054fd6f4b --- /dev/null +++ b/test/hotspot/jtreg/runtime/os/TestTransparentHugePageUsage.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) Ampere Computing 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test TestTransparentHugePageUsage + * @bug 8315923 + * @library /test/lib + * @requires vm.gc.Serial & os.family == "linux" & os.maxMemory > 2G + * @summary Check that a pretouched java heap appears to use THPs by checking + * AnonHugePages in smaps + * @comment Use SerialGC to increase the time window for pretouching + * @run driver runtime.os.TestTransparentHugePageUsage + */ + +package runtime.os; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.InputStreamReader; +import java.util.AbstractMap.SimpleEntry; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Optional; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import jdk.test.lib.process.ProcessTools; + +public class TestTransparentHugePageUsage { + private static final String[] fixedCmdLine = { + "-XX:+UseTransparentHugePages", "-XX:+AlwaysPreTouch", + "-Xlog:startuptime,pagesize,gc+heap=debug", + "-XX:+UseSerialGC", "-Xms1G", "-Xmx1G", + }; + + public static void main(String[] args) throws Exception { + ArrayList cmdLine = new ArrayList<>(Arrays.asList(fixedCmdLine)); + cmdLine.add("runtime.os.TestTransparentHugePageUsage$CatSmaps"); + ProcessBuilder builder = ProcessTools.createTestJavaProcessBuilder(cmdLine); + checkUsage(new BufferedReader(new InputStreamReader(builder.start().getInputStream()))); + } + + private static void checkUsage(BufferedReader reader) throws Exception { + final Pattern useThp = Pattern.compile(".*\\[info\\]\\[pagesize\\].+UseTransparentHugePages=1.*"); + // Ensure THP is not disabled by OS. + if (reader.lines().filter(line -> useThp.matcher(line).matches()).findFirst().isPresent()) { + final Pattern heapAddr = Pattern.compile(".*\\sHeap:\\s.+base=0x0*(\\p{XDigit}+).*"); + final Optional addr = reader.lines() + .map(line -> new SimpleEntry(line, heapAddr.matcher(line))) + .filter(e -> e.getValue().matches()) + .findFirst() + .map(e -> Long.valueOf(e.getKey().substring(e.getValue().start(1), e.getValue().end(1)), 16)); + if (!addr.isPresent()) throw new RuntimeException("Heap base was not found in smaps."); + // Match the start of a mapping, for example: + // 200000000-800000000 rw-p 00000000 00:00 0 + final Pattern mapping = Pattern.compile("^(\\p{XDigit}+)-\\p{XDigit}+.*"); + reader.lines() + .filter(line -> { + Matcher matcher = mapping.matcher(line); + if (matcher.matches()) { + Long mappingAddr = Long.valueOf(line.substring(matcher.start(1), matcher.end(1)), 16); + if (mappingAddr.equals(addr.get())) return true; + } + return false; + }) + .findFirst(); + final Pattern thpUsage = Pattern.compile("^AnonHugePages:\\s+(\\d+)\\skB"); + final Optional usage = reader.lines() + .map(line -> new SimpleEntry(line, thpUsage.matcher(line))) + .filter(e -> e.getValue().matches()) + .findFirst() + .map(e -> Long.valueOf(e.getKey().substring(e.getValue().start(1), e.getValue().end(1)))); + if (!usage.isPresent()) throw new RuntimeException("The usage of THP was not found."); + // Even with MADV_POPULATE_WRITE, the usage of THP is still one page less than the whole heap. + if (usage.get() < 524288) throw new RuntimeException("The usage of THP is not enough."); + } + } + + public static class CatSmaps { + public static void main(String[] args) throws Exception { + new BufferedReader(new FileReader("/proc/self/smaps")) + .lines() + .forEach(line -> System.out.println(line)); + } + } +} diff --git a/test/hotspot/jtreg/serviceability/AsyncGetCallTrace/libAsyncGetCallTraceTest.cpp b/test/hotspot/jtreg/serviceability/AsyncGetCallTrace/libAsyncGetCallTraceTest.cpp index e8886f4bb67..ccdaf985d57 100644 --- a/test/hotspot/jtreg/serviceability/AsyncGetCallTrace/libAsyncGetCallTraceTest.cpp +++ b/test/hotspot/jtreg/serviceability/AsyncGetCallTrace/libAsyncGetCallTraceTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, Google and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -35,7 +35,7 @@ template class JvmtiDeallocator { public: JvmtiDeallocator() { - elem_ = NULL; + elem_ = nullptr; } ~JvmtiDeallocator() { @@ -100,7 +100,7 @@ extern "C" { static jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { fprintf(stderr, "Error: wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -129,13 +129,13 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, nullptr); if (err != JVMTI_ERROR_NONE) { fprintf(stderr, "AgentInitialize: Error in SetEventNotificationMode for CLASS_LOAD: %d\n", err); return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_PREPARE, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_PREPARE, nullptr); if (err != JVMTI_ERROR_NONE) { fprintf(stderr, "AgentInitialize: Error in SetEventNotificationMode for CLASS_PREPARE: %d\n", @@ -143,7 +143,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, nullptr); if (err != JVMTI_ERROR_NONE) { fprintf( stderr, "AgentInitialize: Error in SetEventNotificationMode for VM_INIT: %d\n", @@ -194,12 +194,12 @@ Java_MyPackage_ASGCTBaseTest_checkAsyncGetCallTraceCall(JNIEnv* env, jclass cls) trace.env_id = env; trace.num_frames = 0; - if (agct == NULL) { + if (agct == nullptr) { fprintf(stderr, "AsyncGetCallTrace not found.\n"); return false; } - agct(&trace, MAX_DEPTH, NULL); + agct(&trace, MAX_DEPTH, nullptr); // For now, just check that the first frame is (-3, checkAsyncGetCallTraceCall). if (trace.num_frames <= 0) { @@ -214,19 +214,19 @@ Java_MyPackage_ASGCTBaseTest_checkAsyncGetCallTraceCall(JNIEnv* env, jclass cls) } JvmtiDeallocator name; - if (trace.frames[0].method_id == NULL) { - fprintf(stderr, "First frame method_id is NULL\n"); + if (trace.frames[0].method_id == nullptr) { + fprintf(stderr, "First frame method_id is null\n"); return false; } - jvmtiError err = jvmti->GetMethodName(trace.frames[0].method_id, name.get_addr(), NULL, NULL); + jvmtiError err = jvmti->GetMethodName(trace.frames[0].method_id, name.get_addr(), nullptr, nullptr); if (err != JVMTI_ERROR_NONE) { fprintf(stderr, "checkAsyncGetCallTrace: Error in GetMethodName: %d\n", err); return false; } - if (name.get() == NULL) { - fprintf(stderr, "Name is NULL\n"); + if (name.get() == nullptr) { + fprintf(stderr, "Name is null\n"); return false; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/CompiledMethodLoad/libCompiledZombie.cpp b/test/hotspot/jtreg/serviceability/jvmti/CompiledMethodLoad/libCompiledZombie.cpp index fbff3c847f1..3bf2988dd0f 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/CompiledMethodLoad/libCompiledZombie.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/CompiledMethodLoad/libCompiledZombie.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, 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 @@ -45,7 +45,7 @@ void JNICALL CompiledMethodLoad(jvmtiEnv* jvmti, jmethodID method, // Continuously generate CompiledMethodLoad events for all currently compiled methods void JNICALL GenerateEventsThread(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_LOAD, NULL); + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_LOAD, nullptr); int count = 0; while (true) { @@ -64,7 +64,7 @@ void JNICALL VMInit(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { jmethodID thread_constructor = jni->GetMethodID(thread_class, "", "()V"); jthread agent_thread = jni->NewObject(thread_class, thread_constructor); - jvmti->RunAgentThread(agent_thread, GenerateEventsThread, NULL, JVMTI_THREAD_NORM_PRIORITY); + jvmti->RunAgentThread(agent_thread, GenerateEventsThread, nullptr, JVMTI_THREAD_NORM_PRIORITY); } JNIEXPORT @@ -83,7 +83,7 @@ jint JNICALL Agent_OnLoad(JavaVM* vm, char* options, void* reserved) { callbacks.VMInit = VMInit; callbacks.CompiledMethodLoad = CompiledMethodLoad; jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks)); - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL); + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, nullptr); return 0; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/DynamicCodeGenerated/libDynamicCodeGenerated.cpp b/test/hotspot/jtreg/serviceability/jvmti/DynamicCodeGenerated/libDynamicCodeGenerated.cpp index 6ede1fe2eb9..f13ba00aa41 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/DynamicCodeGenerated/libDynamicCodeGenerated.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/DynamicCodeGenerated/libDynamicCodeGenerated.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, 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 @@ -25,7 +25,7 @@ #include #include "jvmti_common.h" -static jvmtiEnv* jvmti = NULL; +static jvmtiEnv* jvmti = nullptr; #ifdef __cplusplus extern "C" { @@ -34,8 +34,8 @@ extern "C" { JNIEXPORT void JNICALL Java_DynamicCodeGeneratedTest_changeEventNotificationMode(JNIEnv* jni, jclass cls) { while (true) { - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_DYNAMIC_CODE_GENERATED, NULL); - jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_DYNAMIC_CODE_GENERATED, NULL); + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_DYNAMIC_CODE_GENERATED, nullptr); + jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_DYNAMIC_CODE_GENERATED, nullptr); } } diff --git a/test/hotspot/jtreg/serviceability/jvmti/GenerateEvents/libGenerateEvents1.cpp b/test/hotspot/jtreg/serviceability/jvmti/GenerateEvents/libGenerateEvents1.cpp index 846ba45d274..fa60c07f8db 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/GenerateEvents/libGenerateEvents1.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/GenerateEvents/libGenerateEvents1.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, 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 @@ -28,9 +28,9 @@ extern "C" { #define AGENT_NAME "agent1" -static JavaVM *java_vm = NULL; -static jthread exp_thread = NULL; -static jvmtiEnv *jvmti1 = NULL; +static JavaVM *java_vm = nullptr; +static jthread exp_thread = nullptr; +static jvmtiEnv *jvmti1 = nullptr; static jint agent1_event_count = 0; static bool fail_status = false; @@ -48,10 +48,10 @@ CompiledMethodLoad(jvmtiEnv* jvmti, jmethodID method, jint code_size, const void* code_addr, jint map_length, const jvmtiAddrLocationMap* map, const void* compile_info) { - JNIEnv* env = NULL; - jthread thread = NULL; - char* name = NULL; - char* sign = NULL; + JNIEnv* env = nullptr; + jthread thread = nullptr; + char* name = nullptr; + char* sign = nullptr; jvmtiError err; // Posted on JavaThread's, so it is legal to obtain JNIEnv* @@ -67,7 +67,7 @@ CompiledMethodLoad(jvmtiEnv* jvmti, jmethodID method, } agent1_event_count++; - err = jvmti->GetMethodName(method, &name, &sign, NULL); + err = jvmti->GetMethodName(method, &name, &sign, nullptr); check_jvmti_status(env, err, "CompiledMethodLoad: Error in JVMTI GetMethodName"); printf("%s: CompiledMethodLoad: %s%s\n", AGENT_NAME, name, sign); @@ -111,7 +111,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { JNIEXPORT void JNICALL Java_MyPackage_GenerateEventsTest_agent1GenerateEvents(JNIEnv *env, jclass cls) { - jthread thread = NULL; + jthread thread = nullptr; jvmtiError err; err = jvmti1->GetCurrentThread(&thread); @@ -119,13 +119,13 @@ Java_MyPackage_GenerateEventsTest_agent1GenerateEvents(JNIEnv *env, jclass cls) exp_thread = (jthread)env->NewGlobalRef(thread); - err = jvmti1->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_LOAD, NULL); + err = jvmti1->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_LOAD, nullptr); check_jvmti_status(env, err, "generateEvents1: Error in JVMTI SetEventNotificationMode: JVMTI_ENABLE"); err = jvmti1->GenerateEvents(JVMTI_EVENT_COMPILED_METHOD_LOAD); check_jvmti_status(env, err, "generateEvents1: Error in JVMTI GenerateEvents"); - err = jvmti1->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_COMPILED_METHOD_LOAD, NULL); + err = jvmti1->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_COMPILED_METHOD_LOAD, nullptr); check_jvmti_status(env, err, "generateEvents1: Error in JVMTI SetEventNotificationMode: JVMTI_DISABLE"); } diff --git a/test/hotspot/jtreg/serviceability/jvmti/GenerateEvents/libGenerateEvents2.cpp b/test/hotspot/jtreg/serviceability/jvmti/GenerateEvents/libGenerateEvents2.cpp index 7cec9624cf3..7af061196a1 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/GenerateEvents/libGenerateEvents2.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/GenerateEvents/libGenerateEvents2.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, 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 @@ -28,9 +28,9 @@ extern "C" { #define AGENT_NAME "agent2" -static JavaVM *java_vm = NULL; -static jthread exp_thread = NULL; -static jvmtiEnv *jvmti2 = NULL; +static JavaVM *java_vm = nullptr; +static jthread exp_thread = nullptr; +static jvmtiEnv *jvmti2 = nullptr; static jint agent2_event_count = 0; static bool fail_status = false; @@ -48,10 +48,10 @@ CompiledMethodLoad(jvmtiEnv* jvmti, jmethodID method, jint code_size, const void* code_addr, jint map_length, const jvmtiAddrLocationMap* map, const void* compile_info) { - JNIEnv* env = NULL; - jthread thread = NULL; - char* name = NULL; - char* sign = NULL; + JNIEnv* env = nullptr; + jthread thread = nullptr; + char* name = nullptr; + char* sign = nullptr; jvmtiError err; // Posted on JavaThread's, so it is legal to obtain JNIEnv* @@ -67,7 +67,7 @@ CompiledMethodLoad(jvmtiEnv* jvmti, jmethodID method, } agent2_event_count++; - err = jvmti->GetMethodName(method, &name, &sign, NULL); + err = jvmti->GetMethodName(method, &name, &sign, nullptr); check_jvmti_status(env, err, "CompiledMethodLoad: Error in JVMTI GetMethodName"); printf("%s: CompiledMethodLoad: %s%s\n", AGENT_NAME, name, sign); @@ -113,7 +113,7 @@ Java_MyPackage_GenerateEventsTest_agent2SetThread(JNIEnv *env, jclass cls, jthre exp_thread = (jthread)env->NewGlobalRef(thread); - err = jvmti2->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_LOAD, NULL); + err = jvmti2->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_LOAD, nullptr); check_jvmti_status(env, err, "setThread2: Error in JVMTI SetEventNotificationMode: JVMTI_ENABLE"); } @@ -121,7 +121,7 @@ JNIEXPORT jboolean JNICALL Java_MyPackage_GenerateEventsTest_agent2FailStatus(JNIEnv *env, jclass cls) { jvmtiError err; - err = jvmti2->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_COMPILED_METHOD_LOAD, NULL); + err = jvmti2->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_COMPILED_METHOD_LOAD, nullptr); check_jvmti_status(env, err, "check2: Error in JVMTI SetEventNotificationMode: JVMTI_DISABLE"); printf("\n"); diff --git a/test/hotspot/jtreg/serviceability/jvmti/GetClassFields/FilteredFields/libFilteredFieldsTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/GetClassFields/FilteredFields/libFilteredFieldsTest.cpp index 521242a1c29..24c36444ac2 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/GetClassFields/FilteredFields/libFilteredFieldsTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/GetClassFields/FilteredFields/libFilteredFieldsTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, 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 @@ -28,12 +28,12 @@ extern "C" { -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res = jvm->GetEnv((void **)&jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); fflush(0); return JNI_ERR; @@ -51,7 +51,7 @@ JNIEXPORT jint JNICALL Agent_OnAttach(JavaVM *jvm, char *options, void *reserved JNIEXPORT jint JNICALL Java_FilteredFieldsTest_getJVMTIFieldCount(JNIEnv *env, jclass cls, jclass clazz) { - if (jvmti == NULL) { + if (jvmti == nullptr) { env->FatalError("JVMTI agent was not properly loaded"); } diff --git a/test/hotspot/jtreg/serviceability/jvmti/GetClassMethods/libOverpassMethods.cpp b/test/hotspot/jtreg/serviceability/jvmti/GetClassMethods/libOverpassMethods.cpp index 17025c1b9aa..414c3149298 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/GetClassMethods/libOverpassMethods.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/GetClassMethods/libOverpassMethods.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, 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 @@ extern "C" { #define ACC_STATIC 0x0008 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) { @@ -41,7 +41,7 @@ jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) { JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *vm, char *options, void *reserved) { vm->GetEnv((void **)&jvmti, JVMTI_VERSION_11); - if (options != NULL && strcmp(options, "maintain_original_method_order") == 0) { + if (options != nullptr && strcmp(options, "maintain_original_method_order") == 0) { printf("Enabled capability: maintain_original_method_order\n"); jvmtiCapabilities caps; memset(&caps, 0, sizeof(caps)); @@ -58,22 +58,22 @@ JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *vm, char *options, void *reserved) { JNIEXPORT jobjectArray JNICALL Java_OverpassMethods_getJVMTIDeclaredMethods(JNIEnv *env, jclass static_klass, jclass klass) { jint method_count = 0; - jmethodID* methods = NULL; + jmethodID* methods = nullptr; jvmtiError err = jvmti->GetClassMethods(klass, &method_count, &methods); if (err != JVMTI_ERROR_NONE) { printf("GetClassMethods failed with error: %d\n", err); - return NULL; + return nullptr; } jclass method_cls = env->FindClass("java/lang/reflect/Method"); - if (method_cls == NULL) { + if (method_cls == nullptr) { printf("FindClass (Method) failed\n"); - return NULL; + return nullptr; } - jobjectArray array = env->NewObjectArray(method_count, method_cls, NULL); - if (array == NULL) { + jobjectArray array = env->NewObjectArray(method_count, method_cls, nullptr); + if (array == nullptr) { printf("NewObjectArray failed\n"); - return NULL; + return nullptr; } for (int i = 0; i < method_count; i++) { @@ -81,13 +81,13 @@ JNIEXPORT jobjectArray JNICALL Java_OverpassMethods_getJVMTIDeclaredMethods(JNIE err = jvmti->GetMethodModifiers(methods[i], &modifiers); if (err != JVMTI_ERROR_NONE) { printf("GetMethodModifiers failed with error: %d\n", err); - return NULL; + return nullptr; } jobject m = env->ToReflectedMethod(klass, methods[i], (modifiers & ACC_STATIC) == ACC_STATIC); - if (array == NULL) { + if (array == nullptr) { printf("ToReflectedMethod failed\n"); - return NULL; + return nullptr; } env->SetObjectArrayElement(array, i, m); diff --git a/test/hotspot/jtreg/serviceability/jvmti/GetLocalVariable/libGetLocalVars.cpp b/test/hotspot/jtreg/serviceability/jvmti/GetLocalVariable/libGetLocalVars.cpp index 08a61427dde..e0c3e0664d0 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/GetLocalVariable/libGetLocalVars.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/GetLocalVariable/libGetLocalVars.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ extern "C" { #define TranslateError(err) "JVMTI error" static jint result = STATUS_PASSED; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; #define DECL_TEST_FUNC(type, Type) \ static void \ @@ -167,7 +167,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { static jvmtiCapabilities caps; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_9); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -223,16 +223,16 @@ Java_GetLocalVars_testLocals(JNIEnv *env, jclass cls, jobject thread) { static const int IntSlot = 4; static const int InvalidSlot = 5; - jmethodID mid = NULL; + jmethodID mid = nullptr; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; } mid = env->GetStaticMethodID(cls, METHOD_NAME, METHOD_SIGN); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot find Method ID for %s%s\n", METHOD_NAME, METHOD_SIGN); result = STATUS_FAILED; return; diff --git a/test/hotspot/jtreg/serviceability/jvmti/GetLocalVariable/libGetSetLocalUnsuspended.cpp b/test/hotspot/jtreg/serviceability/jvmti/GetLocalVariable/libGetSetLocalUnsuspended.cpp index 3cb048bda98..9ae5005ee6c 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/GetLocalVariable/libGetSetLocalUnsuspended.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/GetLocalVariable/libGetSetLocalUnsuspended.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, 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 @@ -40,7 +40,7 @@ enum Slots { SlotDouble = 6, }; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static void check_jvmti_error_not_suspended(JNIEnv* jni, const char* func_name, jvmtiError err) { @@ -55,7 +55,7 @@ test_GetLocal(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread) { jvmtiError err; const int depth = 0; - jobject msg = NULL; + jobject msg = nullptr; jint ii = 0; jlong ll = 0L; jfloat ff = 0.0; @@ -101,7 +101,7 @@ test_SetLocal(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread) { jvmtiError err; const int depth = 0; - const jobject msg = NULL; + const jobject msg = nullptr; const jint ii = 0; const jlong ll = 0L; const jfloat ff = 0.0; @@ -163,7 +163,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { JNIEXPORT void JNICALL Java_GetSetLocalUnsuspended_testUnsuspendedThread(JNIEnv *jni, jclass klass, jthread thread) { char* tname = get_thread_name(jvmti, jni, thread); - jmethodID method = NULL; + jmethodID method = nullptr; jlocation location = 0; LOG("\ntestUnsuspendedThread: started for thread: %s\n", tname); diff --git a/test/hotspot/jtreg/serviceability/jvmti/GetThreadListStackTraces/libOneGetThreadListStackTraces.cpp b/test/hotspot/jtreg/serviceability/jvmti/GetThreadListStackTraces/libOneGetThreadListStackTraces.cpp index 2c5ec19e93c..56db0b74797 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/GetThreadListStackTraces/libOneGetThreadListStackTraces.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/GetThreadListStackTraces/libOneGetThreadListStackTraces.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, NTT DATA. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -35,7 +35,7 @@ extern "C" { #endif -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { return jvm->GetEnv(reinterpret_cast(&jvmti), JVMTI_VERSION_11); @@ -103,7 +103,7 @@ JNIEXPORT void JNICALL Java_OneGetThreadListStackTraces_checkCallStacks(JNIEnv * /* Find jvmtiStackInfo for `thread` (in arguments) */ jboolean is_same; - target_info = NULL; + target_info = nullptr; for (jint i = 0; i < num_threads; i++) { is_same = env->IsSameObject(stack_info[i].thread, thread); if (env->ExceptionOccurred()) { @@ -115,7 +115,7 @@ JNIEXPORT void JNICALL Java_OneGetThreadListStackTraces_checkCallStacks(JNIEnv * break; } } - if (target_info == NULL) { + if (target_info == nullptr) { env->FatalError("Target thread not found"); } diff --git a/test/hotspot/jtreg/serviceability/jvmti/Heap/libIterateHeapWithEscapeAnalysisEnabled.cpp b/test/hotspot/jtreg/serviceability/jvmti/Heap/libIterateHeapWithEscapeAnalysisEnabled.cpp index e090bf29709..9cddba2e89a 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/Heap/libIterateHeapWithEscapeAnalysisEnabled.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/Heap/libIterateHeapWithEscapeAnalysisEnabled.cpp @@ -64,7 +64,7 @@ JNI_OnLoad(JavaVM *jvm, void *reserved) { JNIEnv *env; res = jvm->GetEnv((void **) &env, JNI_VERSION_9); - if (res != JNI_OK || env == NULL) { + if (res != JNI_OK || env == nullptr) { fprintf(stderr, "Error: GetEnv call failed(%d)!\n", res); return JNI_ERR; } @@ -79,7 +79,7 @@ Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { printf("Agent_OnLoad started\n"); res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_9); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { fprintf(stderr, "Error: wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -257,9 +257,9 @@ Java_IterateHeapWithEscapeAnalysisEnabled_countAndTagInstancesOfClass(JNIEnv *en if (env->IsSameObject(method, method_IterateOverReachableObjects)) { method_found = JNI_TRUE; - err = jvmti->IterateOverReachableObjects(NULL /*jvmtiHeapRootCallback*/, + err = jvmti->IterateOverReachableObjects(nullptr /*jvmtiHeapRootCallback*/, __stackReferenceCallback, - NULL /* jvmtiObjectReferenceCallback */, + nullptr /* jvmtiObjectReferenceCallback */, &data); if (err != JVMTI_ERROR_NONE) { ShowErrorMessage(jvmti, err, @@ -294,8 +294,8 @@ Java_IterateHeapWithEscapeAnalysisEnabled_countAndTagInstancesOfClass(JNIEnv *en method_found = JNI_TRUE; callbacks.heap_reference_callback = __jvmtiHeapReferenceCallback; err = jvmti->FollowReferences(0 /* filter nothing */, - NULL /* no class filter */, - NULL /* no initial object, follow roots */, + nullptr /* no class filter */, + nullptr /* no initial object, follow roots */, &callbacks, &data); if (err != JVMTI_ERROR_NONE) { @@ -308,7 +308,7 @@ Java_IterateHeapWithEscapeAnalysisEnabled_countAndTagInstancesOfClass(JNIEnv *en method_found = JNI_TRUE; callbacks.heap_iteration_callback = __jvmtiHeapIterationCallback; err = jvmti->IterateThroughHeap(0 /* filter nothing */, - NULL /* no class filter */, + nullptr /* no class filter */, &callbacks, &data); if (err != JVMTI_ERROR_NONE) { diff --git a/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/libHeapMonitorTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/libHeapMonitorTest.cpp index f672a143144..035aaef827e 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/libHeapMonitorTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/libHeapMonitorTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, Google and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -34,8 +34,8 @@ extern "C" { #define FALSE 0 #define PRINT_OUT 0 -static jvmtiEnv *jvmti = NULL; -static jvmtiEnv *second_jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; +static jvmtiEnv *second_jvmti = nullptr; typedef struct _ObjectTrace{ jweak object; @@ -138,7 +138,7 @@ static void print_out_frames(JNIEnv* env, ObjectTrace* trace) { // Get basic information out of the trace. jlocation bci = frames[i].location; jmethodID methodid = frames[i].method; - char *name = NULL, *signature = NULL, *file_name = NULL; + char *name = nullptr, *signature = nullptr, *file_name = nullptr; jclass declaring_class; int line_number; jvmtiError err; @@ -166,18 +166,18 @@ static void print_out_frames(JNIEnv* env, ObjectTrace* trace) { continue; } - // Compare now, none should be NULL. - if (name == NULL) { + // Compare now, none should be null. + if (name == nullptr) { fprintf(stderr, "\tUnknown name\n"); continue; } - if (file_name == NULL) { + if (file_name == nullptr) { fprintf(stderr, "\tUnknown file\n"); continue; } - if (signature == NULL) { + if (signature == nullptr) { fprintf(stderr, "\tUnknown signature\n"); continue; } @@ -204,7 +204,7 @@ static jboolean check_sample_content(JNIEnv* env, // Get basic information out of the trace. jlocation bci = frames[i].location; jmethodID methodid = frames[i].method; - char *name = NULL, *signature = NULL, *file_name = NULL; + char *name = nullptr, *signature = nullptr, *file_name = nullptr; jclass declaring_class; int line_number; jboolean differ; @@ -227,16 +227,16 @@ static jboolean check_sample_content(JNIEnv* env, return FALSE; } - // Compare now, none should be NULL. - if (name == NULL) { + // Compare now, none should be null. + if (name == nullptr) { return FALSE; } - if (file_name == NULL) { + if (file_name == nullptr) { return FALSE; } - if (signature == NULL) { + if (signature == nullptr) { return FALSE; } @@ -267,14 +267,14 @@ static int fill_native_frames(JNIEnv* env, jobjectArray frames, ExpectedContentFrame* native_frames, size_t size) { size_t i; for (i = 0; i < size; i++) { - jclass frame_class = NULL; + jclass frame_class = nullptr; jfieldID line_number_field_id = 0; int line_number = 0; jfieldID string_id = 0; - jstring string_object = NULL; - const char* method = NULL; - const char* file_name = NULL; - const char* signature = NULL; + jstring string_object = nullptr; + const char* method = nullptr; + const char* file_name = nullptr; + const char* signature = nullptr; jobject obj = env->GetObjectArrayElement(frames, (jsize) i); @@ -410,7 +410,7 @@ static void event_storage_add_garbage_collected_object(EventStorage* storage, ObjectTrace* object) { int idx = storage->garbage_history_index; ObjectTrace* old_object = storage->garbage_collected_objects[idx]; - if (old_object != NULL) { + if (old_object != nullptr) { free(old_object->frames); free(storage->garbage_collected_objects[idx]); } @@ -496,7 +496,7 @@ static jboolean event_storage_garbage_contains(JNIEnv* env, for (i = 0; i < storage->garbage_history_size; i++) { ObjectTrace* trace = storage->garbage_collected_objects[i]; - if (trace == NULL) { + if (trace == nullptr) { continue; } @@ -587,14 +587,14 @@ static void event_storage_compact(EventStorage* storage, JNIEnv* jni) { ObjectTrace* live_object = live_objects[i]; jweak object = live_object->object; - if (!jni->IsSameObject(object, NULL)) { + if (!jni->IsSameObject(object, nullptr)) { if (dest != i) { live_objects[dest] = live_object; dest++; } } else { jni->DeleteWeakGlobalRef(object); - live_object->object = NULL; + live_object->object = nullptr; event_storage_add_garbage_collected_object(storage, live_object); } @@ -607,7 +607,7 @@ static void event_storage_compact(EventStorage* storage, JNIEnv* jni) { static void event_storage_free_objects(ObjectTrace** array, int max) { int i; for (i = 0; i < max; i++) { - free(array[i]), array[i] = NULL; + free(array[i]), array[i] = nullptr; } } @@ -620,7 +620,7 @@ static void event_storage_reset(EventStorage* storage) { storage->live_object_additions = 0; storage->live_object_size = 0; storage->live_object_count = 0; - free(storage->live_objects), storage->live_objects = NULL; + free(storage->live_objects), storage->live_objects = nullptr; event_storage_free_objects(storage->garbage_collected_objects, storage->garbage_history_size); @@ -799,13 +799,13 @@ void JNICALL GarbageCollectionFinish(jvmtiEnv *jvmti_env) { static int enable_notifications() { if (check_error(jvmti->SetEventNotificationMode( - JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_FINISH, NULL), + JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_FINISH, nullptr), "Set event notifications")) { return 1; } return check_error(jvmti->SetEventNotificationMode( - JVMTI_ENABLE, JVMTI_EVENT_SAMPLED_OBJECT_ALLOC, NULL), + JVMTI_ENABLE, JVMTI_EVENT_SAMPLED_OBJECT_ALLOC, nullptr), "Set event notifications"); } @@ -816,14 +816,14 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiCapabilities caps; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { fprintf(stderr, "Error: wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } // Get second jvmti environment. res = jvm->GetEnv((void **) &second_jvmti, JVMTI_VERSION); - if (res != JNI_OK || second_jvmti == NULL) { + if (res != JNI_OK || second_jvmti == nullptr) { fprintf(stderr, "Error: wrong result of a valid second call to GetEnv!\n"); return JNI_ERR; } @@ -893,11 +893,11 @@ Java_MyPackage_HeapMonitor_enableSamplingEvents(JNIEnv* env, jclass cls) { JNIEXPORT void JNICALL Java_MyPackage_HeapMonitor_disableSamplingEvents(JNIEnv* env, jclass cls) { check_error(jvmti->SetEventNotificationMode( - JVMTI_DISABLE, JVMTI_EVENT_SAMPLED_OBJECT_ALLOC, NULL), + JVMTI_DISABLE, JVMTI_EVENT_SAMPLED_OBJECT_ALLOC, nullptr), "Set event notifications"); check_error(jvmti->SetEventNotificationMode( - JVMTI_DISABLE, JVMTI_EVENT_GARBAGE_COLLECTION_FINISH, NULL), + JVMTI_DISABLE, JVMTI_EVENT_GARBAGE_COLLECTION_FINISH, nullptr), "Garbage Collection Finish"); } @@ -912,8 +912,8 @@ static ExpectedContentFrame *get_native_frames(JNIEnv* env, jclass cls, native_frames = reinterpret_cast (malloc(size * sizeof(*native_frames))); - if (native_frames == NULL) { - env->FatalError("Error in get_native_frames: malloc returned NULL\n"); + if (native_frames == nullptr) { + env->FatalError("Error in get_native_frames: malloc returned null\n"); } if (fill_native_frames(env, frames, native_frames, size) != 0) { @@ -934,7 +934,7 @@ Java_MyPackage_HeapMonitor_obtainedEvents(JNIEnv* env, jclass cls, result = event_storage_contains(env, &global_event_storage, native_frames, size, check_lines); - free(native_frames), native_frames = NULL; + free(native_frames), native_frames = nullptr; return result; } @@ -949,7 +949,7 @@ Java_MyPackage_HeapMonitor_garbageContains(JNIEnv* env, jclass cls, result = event_storage_garbage_contains(env, &global_event_storage, native_frames, size, check_lines); - free(native_frames), native_frames = NULL; + free(native_frames), native_frames = nullptr; return result; } @@ -964,7 +964,7 @@ Java_MyPackage_HeapMonitor_getSize(JNIEnv* env, jclass cls, result = event_storage_get_size(env, &global_event_storage, native_frames, size, check_lines); - free(native_frames), native_frames = NULL; + free(native_frames), native_frames = nullptr; return result; } @@ -1083,7 +1083,7 @@ Java_MyPackage_HeapMonitorTwoAgentsTest_enablingSamplingInSecondaryAgent( JNIEXPORT void JNICALL Java_MyPackage_HeapMonitor_enableVMEvents(JNIEnv* env, jclass cls) { check_error(jvmti->SetEventNotificationMode( - JVMTI_ENABLE, JVMTI_EVENT_VM_OBJECT_ALLOC, NULL), + JVMTI_ENABLE, JVMTI_EVENT_VM_OBJECT_ALLOC, nullptr), "Set vm event notifications"); } @@ -1103,19 +1103,19 @@ static jobject allocate_object(JNIEnv* env) { jmethodID constructor; jobject result; - if (env->ExceptionOccurred() || cls == NULL) { + if (env->ExceptionOccurred() || cls == nullptr) { env->FatalError("Error in jni FindClass: Cannot find Object class\n"); } constructor = env->GetMethodID(cls, "", "()V"); - if (env->ExceptionOccurred() || constructor == NULL) { + if (env->ExceptionOccurred() || constructor == nullptr) { env->FatalError("Error in jni GetMethodID: Cannot find Object class constructor\n"); } // Call back constructor to allocate a new instance, with an int argument result = env->NewObject(cls, constructor); - if (env->ExceptionOccurred() || result == NULL) { + if (env->ExceptionOccurred() || result == nullptr) { env->FatalError("Error in jni NewObject: Cannot allocate an object\n"); } return result; @@ -1135,8 +1135,8 @@ void JNICALL RecursiveSampledObjectAlloc(jvmtiEnv *jvmti_env, // infinite recursion here. int i; for (i = 0; i < 1000; i++) { - if (allocate_object(jni_env) == NULL) { - jni_env->FatalError("allocate_object returned NULL\n"); + if (allocate_object(jni_env) == nullptr) { + jni_env->FatalError("allocate_object returned null\n"); } } diff --git a/test/hotspot/jtreg/serviceability/jvmti/HiddenClass/libHiddenClassSigTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/HiddenClass/libHiddenClassSigTest.cpp index 5d94a3879fe..ad9da9e5301 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/HiddenClass/libHiddenClassSigTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/HiddenClass/libHiddenClassSigTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, 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 @@ static const char* SIG_START = "LP/Q/HiddenClassSig"; static const size_t SIG_START_LEN = strlen(SIG_START); static const int ACC_INTERFACE = 0x0200; // Interface class modifiers bit -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint class_load_count = 0; static jint class_prep_count = 0; static bool failed = false; @@ -50,18 +50,18 @@ static bool failed = false; /* Return the jmethodID of j.l.Class.isHidden() method. */ static jmethodID is_hidden_mid(JNIEnv* jni) { - char* csig = NULL; + char* csig = nullptr; jint count = 0; - jmethodID *methods = NULL; + jmethodID *methods = nullptr; jclass clazz = jni->FindClass("java/lang/Class"); - if (clazz == NULL) { - jni->FatalError("is_hidden_mid: Error: FindClass returned NULL for java/lang/Class\n"); - return NULL; + if (clazz == nullptr) { + jni->FatalError("is_hidden_mid: Error: FindClass returned null for java/lang/Class\n"); + return nullptr; } // find the jmethodID of j.l.Class.isHidden() method jmethodID mid = jni->GetMethodID(clazz, "isHidden", "()Z"); - if (mid == NULL) { + if (mid == nullptr) { jni->FatalError("is_hidden_mid: Error in jni GetMethodID: Cannot find j.l.Class.isHidden method\n"); } return mid; @@ -70,9 +70,9 @@ is_hidden_mid(JNIEnv* jni) { /* Return true if the klass is hidden. */ static bool is_hidden(JNIEnv* jni, jclass klass) { - static jmethodID is_hid_mid = NULL; + static jmethodID is_hid_mid = nullptr; - if (is_hid_mid == NULL) { + if (is_hid_mid == nullptr) { is_hid_mid = is_hidden_mid(jni); } // invoke j.l.Class.isHidden() method @@ -88,8 +88,8 @@ is_hidden(JNIEnv* jni, jclass klass) { static void check_class_signature(jvmtiEnv* jvmti, JNIEnv* jni, jclass klass, bool is_hidden, const char* exp_sig) { jint class_modifiers = 0; - char* sig = NULL; - char* gsig = NULL; + char* sig = nullptr; + char* gsig = nullptr; jvmtiError err; // get class signature @@ -103,8 +103,8 @@ check_class_signature(jvmtiEnv* jvmti, JNIEnv* jni, jclass klass, bool is_hidden LOG2("check_class_signature: FAIL: Hidden class signature %s does not match expected: %s\n", sig, exp_sig); failed = true; } - if (is_hidden && gsig == NULL) { - LOG0("check_class_signature: FAIL: unexpected NULL generic signature for hidden class\n"); + if (is_hidden && gsig == nullptr) { + LOG0("check_class_signature: FAIL: unexpected null generic signature for hidden class\n"); failed = true; } } @@ -152,8 +152,8 @@ check_hidden_class_flags(jvmtiEnv* jvmti, JNIEnv* jni, jclass klass) { static void check_hidden_class_loader(jvmtiEnv* jvmti, JNIEnv* jni, jclass klass) { jint count = 0; - jobject loader = NULL; - jclass* loader_classes = NULL; + jobject loader = nullptr; + jclass* loader_classes = nullptr; jboolean found = false; jvmtiError err; @@ -166,7 +166,7 @@ check_hidden_class_loader(jvmtiEnv* jvmti, JNIEnv* jni, jclass klass) { CHECK_JVMTI_ERROR(jni, err, "check_hidden_class_loader: Error in JVMTI GetClassLoaderClasses"); for (int idx = 0; idx < count; idx++) { - char* sig = NULL; + char* sig = nullptr; jclass kls = loader_classes[idx]; // GetClassLoaderClasses should not return any hidden classes @@ -174,7 +174,7 @@ check_hidden_class_loader(jvmtiEnv* jvmti, JNIEnv* jni, jclass klass) { continue; } // get class signature - err = jvmti->GetClassSignature(kls, &sig, NULL); + err = jvmti->GetClassSignature(kls, &sig, nullptr); CHECK_JVMTI_ERROR(jni, err, "check_hidden_class_loader: Error in JVMTI GetClassSignature"); LOG1("check_hidden_class_loader: FAIL: JVMTI GetClassLoaderClasses returned hidden class: %s\n", sig); @@ -187,9 +187,9 @@ check_hidden_class_loader(jvmtiEnv* jvmti, JNIEnv* jni, jclass klass) { /* Test the hidden class implements expected interface. */ static void check_hidden_class_impl_interf(jvmtiEnv* jvmti, JNIEnv* jni, jclass klass) { - char* sig = NULL; + char* sig = nullptr; jint count = 0; - jclass* interfaces = NULL; + jclass* interfaces = nullptr; jvmtiError err; // check that hidden class implements just one interface @@ -201,7 +201,7 @@ check_hidden_class_impl_interf(jvmtiEnv* jvmti, JNIEnv* jni, jclass klass) { return; } // get interface signature - err = jvmti->GetClassSignature(interfaces[0], &sig, NULL); + err = jvmti->GetClassSignature(interfaces[0], &sig, nullptr); CHECK_JVMTI_ERROR(jni, err, "check_hidden_class_impl_interf: Error in JVMTI GetClassSignature for implemented interface"); // check the interface signature is matching the expected @@ -215,7 +215,7 @@ check_hidden_class_impl_interf(jvmtiEnv* jvmti, JNIEnv* jni, jclass klass) { /* Test hidden class. */ static void check_hidden_class(jvmtiEnv* jvmti, JNIEnv* jni, jclass klass, const char* exp_sig) { - char* source_file_name = NULL; + char* source_file_name = nullptr; LOG1("\n### Native agent: check_hidden_class started: class: %s\n", exp_sig); @@ -237,7 +237,7 @@ check_hidden_class(jvmtiEnv* jvmti, JNIEnv* jni, jclass klass, const char* exp_s /* Test hidden class array. */ static void check_hidden_class_array(jvmtiEnv* jvmti, JNIEnv* jni, jclass klass_array, const char* exp_sig) { - char* source_file_name = NULL; + char* source_file_name = nullptr; LOG1("\n### Native agent: check_hidden_class_array started: array: %s\n", exp_sig); @@ -250,8 +250,8 @@ check_hidden_class_array(jvmtiEnv* jvmti, JNIEnv* jni, jclass klass_array, const /* Process a CLASS_LOAD or aClassPrepare event. */ static void process_class_event(jvmtiEnv* jvmti, JNIEnv* jni, jclass klass, jint* event_count_ptr, const char* event_name) { - char* sig = NULL; - char* gsig = NULL; + char* sig = nullptr; + char* gsig = nullptr; jvmtiError err; // get class signature @@ -263,8 +263,8 @@ static void process_class_event(jvmtiEnv* jvmti, JNIEnv* jni, jclass klass, strncmp(sig, SIG_START, SIG_START_LEN) == 0 && is_hidden(jni, klass)) { (*event_count_ptr)++; - if (gsig == NULL) { - LOG1("%s event: FAIL: GetClassSignature returned NULL generic signature for hidden class\n", event_name); + if (gsig == nullptr) { + LOG1("%s event: FAIL: GetClassSignature returned null generic signature for hidden class\n", event_name); failed = true; } LOG2("%s event: hidden class with sig: %s\n", event_name, sig); @@ -293,11 +293,11 @@ VMInit(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { fflush(stdout); // enable ClassLoad event notification mode - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, nullptr); CHECK_JVMTI_ERROR(jni, err, "VMInit event: Error in enabling ClassLoad events notification"); // enable ClassPrepare event notification mode - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_PREPARE, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_PREPARE, nullptr); CHECK_JVMTI_ERROR(jni, err, "VMInit event: Error in enabling ClassPrepare events notification"); } @@ -327,7 +327,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { } // enable VM_INIT event notification mode - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, nullptr); if (err != JVMTI_ERROR_NONE) { LOG1("Agent_OnLoad: Error in JVMTI SetEventNotificationMode: %d\n", err); failed = true; @@ -341,10 +341,10 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { /* Native method: checkHiddenClass(). */ JNIEXPORT void JNICALL Java_P_Q_HiddenClassSigTest_checkHiddenClass(JNIEnv *jni, jclass klass, jclass hidden_klass, jstring exp_sig_str) { - const char* exp_sig = jni->GetStringUTFChars(exp_sig_str, NULL); + const char* exp_sig = jni->GetStringUTFChars(exp_sig_str, nullptr); - if (exp_sig == NULL) { - jni->FatalError("check_hidden_class: Error: JNI GetStringChars returned NULL for jstring\n"); + if (exp_sig == nullptr) { + jni->FatalError("check_hidden_class: Error: JNI GetStringChars returned null for jstring\n"); return; } check_hidden_class(jvmti, jni, hidden_klass, exp_sig); @@ -355,10 +355,10 @@ Java_P_Q_HiddenClassSigTest_checkHiddenClass(JNIEnv *jni, jclass klass, jclass h /* Native method: checkHiddenClassArray(). */ JNIEXPORT void JNICALL Java_P_Q_HiddenClassSigTest_checkHiddenClassArray(JNIEnv *jni, jclass klass, jclass hidden_klass_array, jstring exp_sig_str) { - const char* exp_sig = jni->GetStringUTFChars(exp_sig_str, NULL); + const char* exp_sig = jni->GetStringUTFChars(exp_sig_str, nullptr); - if (exp_sig == NULL) { - jni->FatalError("check_hidden_class_array: Error: JNI GetStringChars returned NULL for jstring\n"); + if (exp_sig == nullptr) { + jni->FatalError("check_hidden_class_array: Error: JNI GetStringChars returned null for jstring\n"); return; } check_hidden_class_array(jvmti, jni, hidden_klass_array, exp_sig); diff --git a/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/MissedStackMapFrames/libMissedStackMapFrames.cpp b/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/MissedStackMapFrames/libMissedStackMapFrames.cpp index 18d4a2e5d1d..5cebf608c34 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/MissedStackMapFrames/libMissedStackMapFrames.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/MissedStackMapFrames/libMissedStackMapFrames.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, 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 @@ -62,7 +62,7 @@ struct SavedClassBytes { jbyteArray get(JNIEnv *env) { if (bytes == nullptr) { - _log("SavedClassBytes: NULL\n"); + _log("SavedClassBytes: null\n"); return nullptr; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/RedefineRetransform/libRedefineRetransform.cpp b/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/RedefineRetransform/libRedefineRetransform.cpp index 9ac4f0dfc26..518e147c942 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/RedefineRetransform/libRedefineRetransform.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/RedefineRetransform/libRedefineRetransform.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, 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 @@ -152,7 +152,7 @@ class ClassFileLoadHookHelper { jbyteArray getSavedHookClassBytes() { if (savedClassBytes == nullptr) { - _log("%s: savedClassBytes is NULL\n", mode); + _log("%s: savedClassBytes is null\n", mode); return nullptr; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/SetBreakpoint/libTestManyBreakpoints.cpp b/test/hotspot/jtreg/serviceability/jvmti/SetBreakpoint/libTestManyBreakpoints.cpp index dcb8f87ddd7..b9520cc0e1c 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/SetBreakpoint/libTestManyBreakpoints.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/SetBreakpoint/libTestManyBreakpoints.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, 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 @@ -28,7 +28,7 @@ #define TARGET_CLASS_NAME "LTarget;" -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static void check_jvmti_status(JNIEnv* jni, jvmtiError err, const char* msg) { @@ -42,7 +42,7 @@ void JNICALL classprepare(jvmtiEnv* jvmti_env, JNIEnv* jni_env, jthread thread, char* buf; jvmtiError err; - err = jvmti->GetClassSignature(klass, &buf, NULL); + err = jvmti->GetClassSignature(klass, &buf, nullptr); check_jvmti_status(jni_env, err, "classprepare: GetClassSignature error"); if (strncmp(buf, TARGET_CLASS_NAME, strlen(TARGET_CLASS_NAME)) == 0) { @@ -95,13 +95,13 @@ JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM* vm, char* options, void* reserved) { return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_PREPARE, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_PREPARE, nullptr); if (err != JNI_OK) { printf("Agent_OnLoad: SetEventNotificationMode CLASS_PREPARE error\n"); return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, nullptr); if (err != JNI_OK) { printf("Agent_OnLoad: SetEventNotificationMode BREAKPOINT error\n"); return JNI_ERR; diff --git a/test/hotspot/jtreg/serviceability/jvmti/SetTag/libTagMapTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/SetTag/libTagMapTest.cpp index cb23df82485..488d6a05fed 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/SetTag/libTagMapTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/SetTag/libTagMapTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, 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 @@ -27,7 +27,7 @@ namespace { jlong nextTag = 1; - jvmtiEnv *jvmti = NULL; + jvmtiEnv *jvmti = nullptr; void checkJvmti(int code, const char* message) { if (code != JVMTI_ERROR_NONE) { @@ -55,7 +55,7 @@ extern "C" JNIEXPORT jlong JNICALL Java_TagMapTest_getTag(JNIEnv* jni_env, jclas } extern "C" JNIEXPORT void JNICALL Java_TagMapTest_iterate(JNIEnv* jni_env, jclass clazz, jboolean tagged) { - checkJvmti(jvmti->IterateOverHeap(tagged ? JVMTI_HEAP_OBJECT_TAGGED : JVMTI_HEAP_OBJECT_EITHER, &heapObjectCallback, NULL), "could not iterate"); + checkJvmti(jvmti->IterateOverHeap(tagged ? JVMTI_HEAP_OBJECT_TAGGED : JVMTI_HEAP_OBJECT_EITHER, &heapObjectCallback, nullptr), "could not iterate"); } extern "C" JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *vm, char *options, void *reserved) { diff --git a/test/hotspot/jtreg/serviceability/jvmti/SuspendWithCurrentThread/libSuspendWithCurrentThread.cpp b/test/hotspot/jtreg/serviceability/jvmti/SuspendWithCurrentThread/libSuspendWithCurrentThread.cpp index f6dfe86a8e9..61d41a33835 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/SuspendWithCurrentThread/libSuspendWithCurrentThread.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/SuspendWithCurrentThread/libSuspendWithCurrentThread.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, 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 @@ -28,8 +28,8 @@ extern "C" { -static jvmtiEnv* jvmti = NULL; -static jthread* threads = NULL; +static jvmtiEnv* jvmti = nullptr; +static jthread* threads = nullptr; static jsize threads_count = 0; JNIEXPORT void JNICALL @@ -51,9 +51,9 @@ Java_SuspendWithCurrentThread_registerTestedThreads(JNIEnv *jni, jclass cls, job /* This function is executed on the suspender thread which is not Main thread */ JNIEXPORT void JNICALL Java_ThreadToSuspend_suspendTestedThreads(JNIEnv *jni, jclass cls) { - jvmtiError* results = NULL; + jvmtiError* results = nullptr; jvmtiError err; - const char* tname = get_thread_name(jvmti, jni, NULL); // current thread name + const char* tname = get_thread_name(jvmti, jni, nullptr); // current thread name LOG("\nsuspendTestedThreads: started by thread: %s\n", tname); err = jvmti->Allocate((threads_count * sizeof(jvmtiError)), @@ -105,7 +105,7 @@ Java_SuspendWithCurrentThread_checkTestedThreadsSuspended(JNIEnv *jni, jclass cl JNIEXPORT void JNICALL Java_SuspendWithCurrentThread_resumeTestedThreads(JNIEnv *jni, jclass cls) { - jvmtiError* results = NULL; + jvmtiError* results = nullptr; jvmtiError err; LOG("\nresumeTestedThreads: started\n"); @@ -135,7 +135,7 @@ Java_SuspendWithCurrentThread_releaseTestedThreadsInfo(JNIEnv *jni, jclass cls) LOG("\nreleaseTestedThreadsInfo: started\n"); for (int i = 0; i < threads_count; i++) { - if (threads[i] != NULL) { + if (threads[i] != nullptr) { jni->DeleteGlobalRef(threads[i]); } } diff --git a/test/hotspot/jtreg/serviceability/jvmti/SuspendWithObjectMonitorEnter/libSuspendWithObjectMonitorEnter.cpp b/test/hotspot/jtreg/serviceability/jvmti/SuspendWithObjectMonitorEnter/libSuspendWithObjectMonitorEnter.cpp index cfdbed1c6e1..f449a4e6b92 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/SuspendWithObjectMonitorEnter/libSuspendWithObjectMonitorEnter.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/SuspendWithObjectMonitorEnter/libSuspendWithObjectMonitorEnter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, 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 @@ -26,7 +26,7 @@ extern "C" { -static jvmtiEnv* jvmti = NULL; +static jvmtiEnv* jvmti = nullptr; #define LOG(...) \ do { \ diff --git a/test/hotspot/jtreg/serviceability/jvmti/SuspendWithObjectMonitorWait/libSuspendWithObjectMonitorWait.cpp b/test/hotspot/jtreg/serviceability/jvmti/SuspendWithObjectMonitorWait/libSuspendWithObjectMonitorWait.cpp index 926f0619b59..3706cba76dc 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/SuspendWithObjectMonitorWait/libSuspendWithObjectMonitorWait.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/SuspendWithObjectMonitorWait/libSuspendWithObjectMonitorWait.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, 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 @@ -26,7 +26,7 @@ extern "C" { -static jvmtiEnv* jvmti = NULL; +static jvmtiEnv* jvmti = nullptr; #define LOG(...) \ do { \ diff --git a/test/hotspot/jtreg/serviceability/jvmti/SuspendWithRawMonitorEnter/libSuspendWithRawMonitorEnter.cpp b/test/hotspot/jtreg/serviceability/jvmti/SuspendWithRawMonitorEnter/libSuspendWithRawMonitorEnter.cpp index 476d8d67a15..9b7562d70d4 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/SuspendWithRawMonitorEnter/libSuspendWithRawMonitorEnter.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/SuspendWithRawMonitorEnter/libSuspendWithRawMonitorEnter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, 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 @@ -26,8 +26,8 @@ extern "C" { -static jvmtiEnv* jvmti = NULL; -static jrawMonitorID threadLock = NULL; +static jvmtiEnv* jvmti = nullptr; +static jrawMonitorID threadLock = nullptr; static char threadLockName[] = "threadLock"; #define LOG(...) \ diff --git a/test/hotspot/jtreg/serviceability/jvmti/VMObjectAlloc/libVMObjectAlloc.cpp b/test/hotspot/jtreg/serviceability/jvmti/VMObjectAlloc/libVMObjectAlloc.cpp index fc5113f1aad..20b06c6648e 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/VMObjectAlloc/libVMObjectAlloc.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/VMObjectAlloc/libVMObjectAlloc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, 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 @@ -35,8 +35,8 @@ VMObjectAlloc(jvmtiEnv *jvmti, jobject object, jclass cls, jlong size) { - char *signature = NULL; - jvmtiError err = jvmti->GetClassSignature(cls, &signature, NULL); + char *signature = nullptr; + jvmtiError err = jvmti->GetClassSignature(cls, &signature, nullptr); if (err != JVMTI_ERROR_NONE) { jni->FatalError("Failed during the GetClassSignature call"); } @@ -80,7 +80,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_OBJECT_ALLOC , NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_OBJECT_ALLOC , nullptr); if (err != JVMTI_ERROR_NONE) { return JNI_ERR; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/Breakpoint/breakpoint01/libbreakpoint01.cpp b/test/hotspot/jtreg/serviceability/jvmti/events/Breakpoint/breakpoint01/libbreakpoint01.cpp index 38f0bbd2075..2f4917c13f9 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/Breakpoint/breakpoint01/libbreakpoint01.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/events/Breakpoint/breakpoint01/libbreakpoint01.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ static const char *THREAD_NAME = "breakpoint01Thr"; static volatile int bpEvents[METH_NUM]; static volatile jint result = PASSED; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static volatile int callbacksEnabled = JNI_TRUE; @@ -92,7 +92,7 @@ ClassLoad(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread, jclass klass) { jni->FatalError("failed to obtain a class signature\n"); } - if (sig != NULL && (strcmp(sig, CLASS_SIG) == 0)) { + if (sig != nullptr && (strcmp(sig, CLASS_SIG) == 0)) { LOG("ClassLoad event received for the class %s setting breakpoints ...\n", sig); setBP(jvmti, jni, klass); } @@ -116,10 +116,10 @@ Breakpoint(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread, jmethodID method, jloca return; } - const char* thr_name = thr_info.name == NULL ? "NULL" : thr_info.name; + const char* thr_name = thr_info.name == nullptr ? "null" : thr_info.name; const char* thr_virtual_tag = jni->IsVirtualThread(thread) == JNI_TRUE ? "virtual" : "platform"; const char* thr_daemon_tag = thr_info.is_daemon == JNI_TRUE ? "deamon" : "user"; - if (thr_info.name == NULL || strcmp(thr_info.name, THREAD_NAME) != 0) { + if (thr_info.name == nullptr || strcmp(thr_info.name, THREAD_NAME) != 0) { result = checkStatus = STATUS_FAILED; LOG("TEST FAILED: Breakpoint event with unexpected thread info:\n"); LOG("\tname: \"%s\"\ttype: %s %s thread\n\n", thr_name, thr_virtual_tag, thr_daemon_tag); @@ -148,14 +148,14 @@ Breakpoint(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread, jmethodID method, jloca LOG("TEST FAILED: unable to obtain a class signature during Breakpoint callback\n\n"); return; } - if (clsSig == NULL || strcmp(clsSig, CLASS_SIG) != 0) { + if (clsSig == nullptr || strcmp(clsSig, CLASS_SIG) != 0) { result = checkStatus = STATUS_FAILED; - LOG("TEST FAILED: Breakpoint event with unexpected class signature: %s\n\n", (clsSig == NULL) ? "NULL" : clsSig); + LOG("TEST FAILED: Breakpoint event with unexpected class signature: %s\n\n", (clsSig == nullptr) ? "null" : clsSig); } else { LOG("CHECK PASSED: class signature: \"%s\"\n", clsSig); } - err = jvmti->GetMethodName(method, &methNam, &methSig, NULL); + err = jvmti->GetMethodName(method, &methNam, &methSig, nullptr); if (err != JVMTI_ERROR_NONE) { result = checkStatus = STATUS_FAILED; LOG("TEST FAILED: unable to get method name during Breakpoint callback\n\n"); @@ -230,7 +230,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_9); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -268,22 +268,22 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { LOG("setting event callbacks done\nenabling JVMTI events ...\n"); - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_START, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_START, nullptr); if (err != JVMTI_ERROR_NONE) return JNI_ERR; - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, nullptr); if (err != JVMTI_ERROR_NONE) return JNI_ERR; - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, nullptr); if (err != JVMTI_ERROR_NONE) return JNI_ERR; - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, nullptr); if (err != JVMTI_ERROR_NONE) return JNI_ERR; LOG("enabling the events done\n\n"); agent_lock = create_raw_monitor(jvmti, "agent_lock"); - if (agent_lock == NULL) + if (agent_lock == nullptr) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/ClassLoad/classload01/libclassload01.cpp b/test/hotspot/jtreg/serviceability/jvmti/events/ClassLoad/classload01/libclassload01.cpp index 6cff11b9dda..8766b2047a9 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/ClassLoad/classload01/libclassload01.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/events/ClassLoad/classload01/libclassload01.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, 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 @@ static volatile int clsEvents[EXP_SIG_NUM]; static volatile int primClsEvents[UNEXP_SIG_NUM]; static jint result = PASSED; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jrawMonitorID counter_lock; @@ -91,7 +91,7 @@ static void initCounters() { static int findSig(char *sig, int expected) { for (unsigned int i = 0; i < ((expected == 1) ? EXP_SIG_NUM : UNEXP_SIG_NUM); i++) { - if (sig != NULL && + if (sig != nullptr && strcmp(((expected == 1) ? expSigs[i] : unexpSigs[i]), sig) == 0) { return i; /* the signature found, return index */ } @@ -160,7 +160,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_9); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -197,7 +197,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } LOG("setting event callbacks done\nenabling ClassLoad event ...\n"); - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("Error in SetEventNotificationMode: %d\n", err); return JNI_ERR; diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/ClassPrepare/classprep01/libclassprep01.cpp b/test/hotspot/jtreg/serviceability/jvmti/events/ClassPrepare/classprep01/libclassprep01.cpp index 0933fec1d00..607b1d2792f 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/ClassPrepare/classprep01/libclassprep01.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/events/ClassPrepare/classprep01/libclassprep01.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -45,7 +45,7 @@ typedef struct { jint icount; } class_info; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jint result = PASSED; static size_t eventsCount = 0; @@ -158,7 +158,7 @@ void JNICALL ClassPrepare(jvmtiEnv *jvmti, JNIEnv *jni, jthread thr, jclass cls) LOG(">>> %d methods:", inf.mcount); for (int i = 0; i < inf.mcount; i++) { if (i > 0) LOG(","); - if (methods[i] == NULL) { + if (methods[i] == nullptr) { LOG(" null"); } else { err = jvmti->GetMethodName(methods[i], &name, &sig, &generic); @@ -173,7 +173,7 @@ void JNICALL ClassPrepare(jvmtiEnv *jvmti, JNIEnv *jni, jthread thr, jclass cls) LOG(">>> %d fields:", inf.fcount); for (int i = 0; i < inf.fcount; i++) { if (i > 0) LOG(","); - if (fields[i] == NULL) { + if (fields[i] == nullptr) { LOG(" null"); } else { err = jvmti->GetFieldName(cls, fields[i], &name, &sig, &generic); @@ -188,7 +188,7 @@ void JNICALL ClassPrepare(jvmtiEnv *jvmti, JNIEnv *jni, jthread thr, jclass cls) LOG(">>> %d interfaces:", inf.icount); for (int i = 0; i < inf.icount; i++) { if (i > 0) LOG(","); - if (interfaces[i] == NULL) { + if (interfaces[i] == nullptr) { LOG(" null"); } else { err = jvmti->GetClassSignature(interfaces[i], &sig, &generic); @@ -226,7 +226,7 @@ void JNICALL ClassPrepare(jvmtiEnv *jvmti, JNIEnv *jni, jthread thr, jclass cls) return; } - if (inf.sig == NULL || strcmp(inf.sig, classes[eventsCount].sig) != 0) { + if (inf.sig == nullptr || strcmp(inf.sig, classes[eventsCount].sig) != 0) { LOG("(#%" PRIuPTR ") wrong class: \"%s\"", eventsCount, inf.sig); LOG(", expected: \"%s\"\n", classes[eventsCount].sig); result = STATUS_FAILED; @@ -262,7 +262,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -299,7 +299,7 @@ JNIEXPORT void JNICALL Java_classprep01_getReady(JNIEnv *jni, jclass cls, jthread thread) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { LOG("JVMTI client was not properly loaded!\n"); return; } @@ -327,7 +327,7 @@ JNIEXPORT jint JNICALL Java_classprep01_check(JNIEnv *jni, jclass cls, jthread thread) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { LOG("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/Exception/exception01/libexception01.cpp b/test/hotspot/jtreg/serviceability/jvmti/events/Exception/exception01/libexception01.cpp index a044bc4387b..ebb086adcaa 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/Exception/exception01/libexception01.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/events/Exception/exception01/libexception01.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,7 +56,7 @@ typedef struct { jlocation c_loc; } exceptionInfo; -static jvmtiEnv *jvmti_env = NULL; +static jvmtiEnv *jvmti_env = nullptr; static jvmtiEventCallbacks callbacks; static jint result = PASSED; static exceptionInfo exs[] = { @@ -139,13 +139,13 @@ Exception(jvmtiEnv *jvmti, JNIEnv *jni, jthread thr, bool found = false; for (size_t i = 0; i < sizeof(exs)/sizeof(exceptionInfo); i++) { - if (ex.name != NULL && strcmp(ex.name, exs[i].name) == 0 - && ex.t_cls != NULL && strcmp(ex.t_cls, exs[i].t_cls) == 0 - && ex.t_name != NULL && strcmp(ex.t_name, exs[i].t_name) == 0 - && ex.t_sig != NULL && strcmp(ex.t_sig, exs[i].t_sig) == 0 - && ex.c_cls != NULL && strcmp(ex.c_cls, exs[i].c_cls) == 0 - && ex.c_name != NULL && strcmp(ex.c_name, exs[i].c_name) == 0 - && ex.c_sig != NULL && strcmp(ex.c_sig, exs[i].c_sig) == 0 + if (ex.name != nullptr && strcmp(ex.name, exs[i].name) == 0 + && ex.t_cls != nullptr && strcmp(ex.t_cls, exs[i].t_cls) == 0 + && ex.t_name != nullptr && strcmp(ex.t_name, exs[i].t_name) == 0 + && ex.t_sig != nullptr && strcmp(ex.t_sig, exs[i].t_sig) == 0 + && ex.c_cls != nullptr && strcmp(ex.c_cls, exs[i].c_cls) == 0 + && ex.c_name != nullptr && strcmp(ex.c_name, exs[i].c_name) == 0 + && ex.c_sig != nullptr && strcmp(ex.c_sig, exs[i].c_sig) == 0 && ex.t_loc == exs[i].t_loc && ex.c_loc == exs[i].c_loc) { jboolean isVirtual = jni->IsVirtualThread(thr); if (isVirtualExpected != isVirtual) { @@ -175,7 +175,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiCapabilities caps; res = jvm->GetEnv((void **) &jvmti_env, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti_env == NULL) { + if (res != JNI_OK || jvmti_env == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -217,27 +217,27 @@ Java_exception01_check(JNIEnv *jni, jclass cls) { jclass clz; jmethodID mid; - if (jvmti_env == NULL) { + if (jvmti_env == nullptr) { LOG("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } clz = jni->FindClass("exception01c"); - if (clz == NULL) { + if (clz == nullptr) { LOG("Cannot find exception01c class!\n"); return STATUS_FAILED; } clz = jni->FindClass("exception01b"); - if (clz == NULL) { + if (clz == nullptr) { LOG("Cannot find exception01b class!\n"); return STATUS_FAILED; } clz = jni->FindClass("exception01a"); - if (clz == NULL) { + if (clz == nullptr) { LOG("Cannot find exception01a class!\n"); return STATUS_FAILED; } mid = jni->GetStaticMethodID(clz, "run", "()V"); - if (mid == NULL) { + if (mid == nullptr) { LOG("Cannot find method run!\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/ExceptionCatch/excatch01/libexcatch01.cpp b/test/hotspot/jtreg/serviceability/jvmti/events/ExceptionCatch/excatch01/libexcatch01.cpp index bd9d263c1b2..f7d74e6f2bf 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/ExceptionCatch/excatch01/libexcatch01.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/events/ExceptionCatch/excatch01/libexcatch01.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -48,7 +48,7 @@ typedef struct { jlocation c_loc; } exceptionInfo; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; static jint result = PASSED; @@ -107,10 +107,10 @@ ExceptionCatch(jvmtiEnv *jvmti, JNIEnv *jni, jthread thr, jmethodID method, jloc bool found = false; for (size_t i = 0; i < sizeof(exs)/sizeof(exceptionInfo); i++) { - if (ex.name != NULL && strcmp(ex.name, exs[i].name) == 0 - && ex.c_cls != NULL && strcmp(ex.c_cls, exs[i].c_cls) == 0 - && ex.c_name != NULL && strcmp(ex.c_name, exs[i].c_name) == 0 - && ex.c_sig != NULL && strcmp(ex.c_sig, exs[i].c_sig) == 0 + if (ex.name != nullptr && strcmp(ex.name, exs[i].name) == 0 + && ex.c_cls != nullptr && strcmp(ex.c_cls, exs[i].c_cls) == 0 + && ex.c_name != nullptr && strcmp(ex.c_name, exs[i].c_name) == 0 + && ex.c_sig != nullptr && strcmp(ex.c_sig, exs[i].c_sig) == 0 && ex.c_loc == exs[i].c_loc) { jboolean isVirtual = jni->IsVirtualThread(thr); if (isVirtualExpected != isVirtual) { @@ -138,7 +138,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -180,28 +180,28 @@ Java_excatch01_check(JNIEnv *jni, jclass cls) { jmethodID mid; jthread thread; - if (jvmti == NULL) { + if (jvmti == nullptr) { LOG("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } clz = jni->FindClass("excatch01c"); - if (clz == NULL) { + if (clz == nullptr) { LOG("Cannot find excatch01c class!\n"); return STATUS_FAILED; } clz = jni->FindClass("excatch01b"); - if (clz == NULL) { + if (clz == nullptr) { LOG("Cannot find excatch01b class!\n"); return STATUS_FAILED; } clz = jni->FindClass("excatch01a"); - if (clz == NULL) { + if (clz == nullptr) { LOG("Cannot find excatch01a class!\n"); return STATUS_FAILED; } mid = jni->GetStaticMethodID(clz, "run", "()V"); - if (mid == NULL) { + if (mid == nullptr) { LOG("Cannot find method run!\n"); return STATUS_FAILED; } @@ -213,7 +213,7 @@ Java_excatch01_check(JNIEnv *jni, jclass cls) { return STATUS_FAILED; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION_CATCH, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION_CATCH, nullptr); if (err == JVMTI_ERROR_NONE) { eventsExpected = sizeof(exs)/sizeof(exceptionInfo); } else { @@ -224,7 +224,7 @@ Java_excatch01_check(JNIEnv *jni, jclass cls) { eventsCount = 0; isVirtualExpected = jni->IsVirtualThread(thread); jni->CallStaticVoidMethod(clz, mid); - err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_EXCEPTION_CATCH, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_EXCEPTION_CATCH, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("Failed to disable JVMTI_EVENT_EXCEPTION_CATCH: %s (%d)\n", TranslateError(err), err); result = STATUS_FAILED; diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/FieldAccess/fieldacc01/libfieldacc01.cpp b/test/hotspot/jtreg/serviceability/jvmti/events/FieldAccess/fieldacc01/libfieldacc01.cpp index b0ad276a1ce..cad086cb7ef 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/FieldAccess/fieldacc01/libfieldacc01.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/events/FieldAccess/fieldacc01/libfieldacc01.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -65,45 +65,45 @@ static volatile jboolean isVirtualExpected = JNI_FALSE; static volatile int eventsExpected = 0; static volatile int eventsCount = 0; static watch_info watches[] = { - { NULL, "Lfieldacc01a;", "run", "()I", 2, + { nullptr, "Lfieldacc01a;", "run", "()I", 2, "Lfieldacc01a;", "staticBoolean", "Z", JNI_TRUE }, - { NULL, "Lfieldacc01a;", "run", "()I", 6, + { nullptr, "Lfieldacc01a;", "run", "()I", 6, "Lfieldacc01a;", "instanceBoolean", "Z", JNI_FALSE }, - { NULL, "Lfieldacc01a;", "run", "()I", 15, + { nullptr, "Lfieldacc01a;", "run", "()I", 15, "Lfieldacc01a;", "staticByte", "B", JNI_TRUE }, - { NULL, "Lfieldacc01a;", "run", "()I", 19, + { nullptr, "Lfieldacc01a;", "run", "()I", 19, "Lfieldacc01a;", "instanceByte", "B", JNI_FALSE }, - { NULL, "Lfieldacc01a;", "run", "()I", 28, + { nullptr, "Lfieldacc01a;", "run", "()I", 28, "Lfieldacc01a;", "staticShort", "S", JNI_TRUE }, - { NULL, "Lfieldacc01a;", "run", "()I", 32, + { nullptr, "Lfieldacc01a;", "run", "()I", 32, "Lfieldacc01a;", "instanceShort", "S", JNI_FALSE }, - { NULL, "Lfieldacc01a;", "run", "()I", 41, + { nullptr, "Lfieldacc01a;", "run", "()I", 41, "Lfieldacc01a;", "staticInt", "I", JNI_TRUE }, - { NULL, "Lfieldacc01a;", "run", "()I", 45, + { nullptr, "Lfieldacc01a;", "run", "()I", 45, "Lfieldacc01a;", "instanceInt", "I", JNI_FALSE }, - { NULL, "Lfieldacc01a;", "run", "()I", 54, + { nullptr, "Lfieldacc01a;", "run", "()I", 54, "Lfieldacc01a;", "staticLong", "J", JNI_TRUE }, - { NULL, "Lfieldacc01a;", "run", "()I", 58, + { nullptr, "Lfieldacc01a;", "run", "()I", 58, "Lfieldacc01a;", "instanceLong", "J", JNI_FALSE }, - { NULL, "Lfieldacc01a;", "run", "()I", 68, + { nullptr, "Lfieldacc01a;", "run", "()I", 68, "Lfieldacc01a;", "staticFloat", "F", JNI_TRUE }, - { NULL, "Lfieldacc01a;", "run", "()I", 72, + { nullptr, "Lfieldacc01a;", "run", "()I", 72, "Lfieldacc01a;", "instanceFloat", "F", JNI_FALSE }, - { NULL, "Lfieldacc01a;", "run", "()I", 82, + { nullptr, "Lfieldacc01a;", "run", "()I", 82, "Lfieldacc01a;", "staticDouble", "D", JNI_TRUE }, - { NULL, "Lfieldacc01a;", "run", "()I", 86, + { nullptr, "Lfieldacc01a;", "run", "()I", 86, "Lfieldacc01a;", "instanceDouble", "D", JNI_FALSE }, - { NULL, "Lfieldacc01a;", "run", "()I", 96, + { nullptr, "Lfieldacc01a;", "run", "()I", 96, "Lfieldacc01a;", "staticChar", "C", JNI_TRUE }, - { NULL, "Lfieldacc01a;", "run", "()I", 100, + { nullptr, "Lfieldacc01a;", "run", "()I", 100, "Lfieldacc01a;", "instanceChar", "C", JNI_FALSE }, - { NULL, "Lfieldacc01a;", "run", "()I", 109, + { nullptr, "Lfieldacc01a;", "run", "()I", 109, "Lfieldacc01a;", "staticObject", "Ljava/lang/Object;", JNI_TRUE }, - { NULL, "Lfieldacc01a;", "run", "()I", 113, + { nullptr, "Lfieldacc01a;", "run", "()I", 113, "Lfieldacc01a;", "instanceObject", "Ljava/lang/Object;", JNI_FALSE }, - { NULL, "Lfieldacc01a;", "run", "()I", 122, + { nullptr, "Lfieldacc01a;", "run", "()I", 122, "Lfieldacc01a;", "staticArrInt", "[I", JNI_TRUE }, - { NULL, "Lfieldacc01a;", "run", "()I", 128, + { nullptr, "Lfieldacc01a;", "run", "()I", 128, "Lfieldacc01a;", "instanceArrInt", "[I", JNI_FALSE } }; @@ -121,7 +121,7 @@ void JNICALL FieldAccess(jvmtiEnv *jvmti, JNIEnv *jni, watch.fid = field; watch.loc = location; - watch.is_static = (obj == NULL) ? JNI_TRUE : JNI_FALSE; + watch.is_static = (obj == nullptr) ? JNI_TRUE : JNI_FALSE; err = jvmti->GetMethodDeclaringClass(method, &cls); if (err != JVMTI_ERROR_NONE) { LOG("(GetMethodDeclaringClass) unexpected error: %s (%d)\n", TranslateError(err), err); @@ -163,16 +163,16 @@ void JNICALL FieldAccess(jvmtiEnv *jvmti, JNIEnv *jni, for (size_t i = 0; i < sizeof(watches)/sizeof(watch_info); i++) { if (watch.fid == watches[i].fid) { - if (watch.m_cls == NULL || strcmp(watch.m_cls, watches[i].m_cls) != 0) { + if (watch.m_cls == nullptr || strcmp(watch.m_cls, watches[i].m_cls) != 0) { LOG("(watch#%" PRIuPTR ") wrong class: \"%s\", expected: \"%s\"\n", i, watch.m_cls, watches[i].m_cls); result = STATUS_FAILED; } - if (watch.m_name == NULL || strcmp(watch.m_name, watches[i].m_name) != 0) { + if (watch.m_name == nullptr || strcmp(watch.m_name, watches[i].m_name) != 0) { LOG("(watch#%" PRIuPTR ") wrong method name: \"%s\"", i, watch.m_name); LOG(", expected: \"%s\"\n", watches[i].m_name); result = STATUS_FAILED; } - if (watch.m_sig == NULL || strcmp(watch.m_sig, watches[i].m_sig) != 0) { + if (watch.m_sig == nullptr || strcmp(watch.m_sig, watches[i].m_sig) != 0) { LOG("(watch#%" PRIuPTR ") wrong method sig: \"%s\"", i, watch.m_sig); LOG(", expected: \"%s\"\n", watches[i].m_sig); result = STATUS_FAILED; @@ -182,12 +182,12 @@ void JNICALL FieldAccess(jvmtiEnv *jvmti, JNIEnv *jni, LOG(", expected: 0x%x%08x\n", (jint)(watches[i].loc >> 32), (jint)watches[i].loc); result = STATUS_FAILED; } - if (watch.f_name == NULL || strcmp(watch.f_name, watches[i].f_name) != 0) { + if (watch.f_name == nullptr || strcmp(watch.f_name, watches[i].f_name) != 0) { LOG("(watch#%" PRIuPTR ") wrong field name: \"%s\"", i, watch.f_name); LOG(", expected: \"%s\"\n", watches[i].f_name); result = STATUS_FAILED; } - if (watch.f_sig == NULL || strcmp(watch.f_sig, watches[i].f_sig) != 0) { + if (watch.f_sig == nullptr || strcmp(watch.f_sig, watches[i].f_sig) != 0) { LOG("(watch#%" PRIuPTR ") wrong field sig: \"%s\"", i, watch.f_sig); LOG(", expected: \"%s\"\n", watches[i].f_sig); result = STATUS_FAILED; @@ -216,7 +216,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -245,7 +245,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FIELD_ACCESS, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FIELD_ACCESS, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("Failed to enable JVMTI_EVENT_FIELD_ACCESS: %s (%d)\n", TranslateError(err), err); return JNI_ERR; @@ -267,7 +267,7 @@ Java_fieldacc01_getReady(JNIEnv *jni, jclass klass) { LOG(">>> setting field access watches ...\n"); cls = jni->FindClass("fieldacc01a"); - if (cls == NULL) { + if (cls == nullptr) { LOG("Cannot find fieldacc01a class!\n"); result = STATUS_FAILED; return; @@ -289,7 +289,7 @@ Java_fieldacc01_getReady(JNIEnv *jni, jclass klass) { } else { watches[i].fid = jni->GetFieldID(cls, watches[i].f_name, watches[i].f_sig); } - if (watches[i].fid == NULL) { + if (watches[i].fid == nullptr) { LOG("Cannot find field \"%s\"!\n", watches[i].f_name); result = STATUS_FAILED; return; @@ -317,7 +317,7 @@ Java_fieldacc01_check(JNIEnv *jni, jclass klass) { } cls = jni->FindClass("fieldacc01a"); - if (cls == NULL) { + if (cls == nullptr) { LOG("Cannot find fieldacc01a class!\n"); result = STATUS_FAILED; return result; diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/FieldAccess/fieldacc02/libfieldacc02.cpp b/test/hotspot/jtreg/serviceability/jvmti/events/FieldAccess/fieldacc02/libfieldacc02.cpp index 59d4150e4c2..c733fb1cbc7 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/FieldAccess/fieldacc02/libfieldacc02.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/events/FieldAccess/fieldacc02/libfieldacc02.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -65,46 +65,46 @@ static volatile jboolean isVirtualExpected = JNI_FALSE; static int eventsExpected = 0; static int eventsCount = 0; static watch_info watches[] = { - { NULL, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldacc02a;", "staticBoolean", "Z", JNI_TRUE }, - { NULL, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldacc02a;", "staticByte", "B", JNI_TRUE }, - { NULL, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldacc02a;", "staticShort", "S", JNI_TRUE }, - { NULL, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldacc02a;", "staticInt", "I", JNI_TRUE }, - { NULL, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldacc02a;", "staticLong", "J", JNI_TRUE }, - { NULL, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldacc02a;", "staticFloat", "F", JNI_TRUE }, - { NULL, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldacc02a;", "staticDouble", "D", JNI_TRUE }, - { NULL, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldacc02a;", "staticChar", "C", JNI_TRUE }, - { NULL, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldacc02a;", "staticObject", "Ljava/lang/Object;", JNI_TRUE }, - { NULL, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldacc02a;", "staticArrInt", "[I", JNI_TRUE }, - { NULL, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldacc02a;", "instanceBoolean", "Z", JNI_FALSE }, - { NULL, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldacc02a;", "instanceByte", "B", JNI_FALSE }, - { NULL, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldacc02a;", "instanceShort", "S", JNI_FALSE }, - { NULL, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldacc02a;", "instanceInt", "I", JNI_FALSE }, - { NULL, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldacc02a;", "instanceLong", "J", JNI_FALSE }, - { NULL, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldacc02a;", "instanceFloat", "F", JNI_FALSE }, - { NULL, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldacc02a;", "instanceDouble", "D", JNI_FALSE }, - { NULL, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldacc02a;", "instanceChar", "C", JNI_FALSE }, - { NULL, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldacc02a;", "instanceObject", "Ljava/lang/Object;", JNI_FALSE }, - { NULL, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldacc02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldacc02a;", "instanceArrInt", "[I", JNI_FALSE } }; @@ -121,7 +121,7 @@ void JNICALL FieldAccess(jvmtiEnv *jvmti, JNIEnv *jni, watch.fid = field; watch.loc = location; - watch.is_static = (obj == NULL) ? JNI_TRUE : JNI_FALSE; + watch.is_static = (obj == nullptr) ? JNI_TRUE : JNI_FALSE; err = jvmti->GetMethodDeclaringClass(method, &cls); if (err != JVMTI_ERROR_NONE) { LOG("(GetMethodDeclaringClass) unexpected error: %s (%d)\n", TranslateError(err), err); @@ -162,16 +162,16 @@ void JNICALL FieldAccess(jvmtiEnv *jvmti, JNIEnv *jni, for (size_t i = 0; i < sizeof(watches)/sizeof(watch_info); i++) { if (watch.fid == watches[i].fid) { - if (watch.m_cls == NULL || strcmp(watch.m_cls, watches[i].m_cls) != 0) { + if (watch.m_cls == nullptr || strcmp(watch.m_cls, watches[i].m_cls) != 0) { LOG("(watch#%" PRIuPTR ") wrong class: \"%s\", expected: \"%s\"\n", i, watch.m_cls, watches[i].m_cls); result = STATUS_FAILED; } - if (watch.m_name == NULL || strcmp(watch.m_name, watches[i].m_name) != 0) { + if (watch.m_name == nullptr || strcmp(watch.m_name, watches[i].m_name) != 0) { LOG("(watch#%" PRIuPTR ") wrong method name: \"%s\"", i, watch.m_name); LOG(", expected: \"%s\"\n", watches[i].m_name); result = STATUS_FAILED; } - if (watch.m_sig == NULL || strcmp(watch.m_sig, watches[i].m_sig) != 0) { + if (watch.m_sig == nullptr || strcmp(watch.m_sig, watches[i].m_sig) != 0) { LOG("(watch#%" PRIuPTR ") wrong method sig: \"%s\"", i, watch.m_sig); LOG(", expected: \"%s\"\n", watches[i].m_sig); result = STATUS_FAILED; @@ -181,12 +181,12 @@ void JNICALL FieldAccess(jvmtiEnv *jvmti, JNIEnv *jni, LOG(", expected: 0x%x%08x\n", (jint)(watches[i].loc >> 32), (jint)watches[i].loc); result = STATUS_FAILED; } - if (watch.f_name == NULL || strcmp(watch.f_name, watches[i].f_name) != 0) { + if (watch.f_name == nullptr || strcmp(watch.f_name, watches[i].f_name) != 0) { LOG("(watch#%" PRIuPTR ") wrong field name: \"%s\"", i, watch.f_name); LOG(", expected: \"%s\"\n", watches[i].f_name); result = STATUS_FAILED; } - if (watch.f_sig == NULL || strcmp(watch.f_sig, watches[i].f_sig) != 0) { + if (watch.f_sig == nullptr || strcmp(watch.f_sig, watches[i].f_sig) != 0) { LOG("(watch#%" PRIuPTR ") wrong field sig: \"%s\"", i, watch.f_sig); LOG(", expected: \"%s\"\n", watches[i].f_sig); result = STATUS_FAILED; @@ -214,7 +214,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -243,7 +243,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FIELD_ACCESS, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FIELD_ACCESS, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("Failed to enable JVMTI_EVENT_FIELD_ACCESS: %s (%d)\n", TranslateError(err), err); @@ -264,7 +264,7 @@ JNIEXPORT void JNICALL Java_fieldacc02_getReady(JNIEnv *jni, jclass clz) { LOG(">>> setting field access watches ...\n"); cls = jni->FindClass("fieldacc02a"); - if (cls == NULL) { + if (cls == nullptr) { LOG("Cannot find fieldacc02a class!\n"); result = STATUS_FAILED; return; @@ -287,7 +287,7 @@ JNIEXPORT void JNICALL Java_fieldacc02_getReady(JNIEnv *jni, jclass clz) { } else { watches[i].fid = jni->GetFieldID(cls, watches[i].f_name, watches[i].f_sig); } - if (watches[i].fid == NULL) { + if (watches[i].fid == nullptr) { LOG("Cannot find field \"%s\"!\n", watches[i].f_name); result = STATUS_FAILED; return; @@ -313,7 +313,7 @@ Java_fieldacc02_check(JNIEnv *jni, jclass clz, jobject obj) { LOG(">>> accessing fields ...\n"); cls = jni->FindClass("fieldacc02a"); - if (cls == NULL) { + if (cls == nullptr) { LOG("Cannot find fieldacc02a class!\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/FieldAccess/fieldacc03/libfieldacc03.cpp b/test/hotspot/jtreg/serviceability/jvmti/events/FieldAccess/fieldacc03/libfieldacc03.cpp index 97c7d145918..769a26c9c7d 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/FieldAccess/fieldacc03/libfieldacc03.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/events/FieldAccess/fieldacc03/libfieldacc03.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -65,25 +65,25 @@ static volatile jboolean isVirtualExpected = JNI_FALSE; static int eventsExpected = 0; static int eventsCount = 0; static watch_info watches[] = { - { NULL, "Lfieldacc03a;", "run", "()I", 3, + { nullptr, "Lfieldacc03a;", "run", "()I", 3, "Lfieldacc03a;", "extendsBoolean", "Z", JNI_FALSE }, - { NULL, "Lfieldacc03a;", "run", "()I", 14, + { nullptr, "Lfieldacc03a;", "run", "()I", 14, "Lfieldacc03a;", "extendsByte", "B", JNI_FALSE }, - { NULL, "Lfieldacc03a;", "run", "()I", 25, + { nullptr, "Lfieldacc03a;", "run", "()I", 25, "Lfieldacc03a;", "extendsShort", "S", JNI_FALSE }, - { NULL, "Lfieldacc03a;", "run", "()I", 36, + { nullptr, "Lfieldacc03a;", "run", "()I", 36, "Lfieldacc03a;", "extendsInt", "I", JNI_FALSE }, - { NULL, "Lfieldacc03a;", "run", "()I", 47, + { nullptr, "Lfieldacc03a;", "run", "()I", 47, "Lfieldacc03a;", "extendsLong", "J", JNI_FALSE }, - { NULL, "Lfieldacc03a;", "run", "()I", 61, + { nullptr, "Lfieldacc03a;", "run", "()I", 61, "Lfieldacc03a;", "extendsFloat", "F", JNI_FALSE }, - { NULL, "Lfieldacc03a;", "run", "()I", 74, + { nullptr, "Lfieldacc03a;", "run", "()I", 74, "Lfieldacc03a;", "extendsDouble", "D", JNI_FALSE }, - { NULL, "Lfieldacc03a;", "run", "()I", 88, + { nullptr, "Lfieldacc03a;", "run", "()I", 88, "Lfieldacc03a;", "extendsChar", "C", JNI_FALSE }, - { NULL, "Lfieldacc03a;", "run", "()I", 100, + { nullptr, "Lfieldacc03a;", "run", "()I", 100, "Lfieldacc03a;", "extendsObject", "Ljava/lang/Object;", JNI_FALSE }, - { NULL, "Lfieldacc03a;", "run", "()I", 111, + { nullptr, "Lfieldacc03a;", "run", "()I", 111, "Lfieldacc03a;", "extendsArrInt", "[I", JNI_FALSE } }; @@ -100,7 +100,7 @@ void JNICALL FieldAccess(jvmtiEnv *jvmti, JNIEnv *jni, watch.fid = field; watch.loc = location; - watch.is_static = (obj == NULL) ? JNI_TRUE : JNI_FALSE; + watch.is_static = (obj == nullptr) ? JNI_TRUE : JNI_FALSE; err = jvmti->GetMethodDeclaringClass(method, &cls); if (err != JVMTI_ERROR_NONE) { LOG("(GetMethodDeclaringClass) unexpected error: %s (%d)\n", TranslateError(err), err); @@ -142,16 +142,16 @@ void JNICALL FieldAccess(jvmtiEnv *jvmti, JNIEnv *jni, for (size_t i = 0; i < sizeof(watches)/sizeof(watch_info); i++) { if (watch.fid == watches[i].fid) { - if (watch.m_cls == NULL || strcmp(watch.m_cls, watches[i].m_cls) != 0) { + if (watch.m_cls == nullptr || strcmp(watch.m_cls, watches[i].m_cls) != 0) { LOG("(watch#%" PRIuPTR ") wrong class: \"%s\", expected: \"%s\"\n", i, watch.m_cls, watches[i].m_cls); result = STATUS_FAILED; } - if (watch.m_name == NULL || strcmp(watch.m_name, watches[i].m_name) != 0) { + if (watch.m_name == nullptr || strcmp(watch.m_name, watches[i].m_name) != 0) { LOG("(watch#%" PRIuPTR ") wrong method name: \"%s\"", i, watch.m_name); LOG(", expected: \"%s\"\n", watches[i].m_name); result = STATUS_FAILED; } - if (watch.m_sig == NULL || strcmp(watch.m_sig, watches[i].m_sig) != 0) { + if (watch.m_sig == nullptr || strcmp(watch.m_sig, watches[i].m_sig) != 0) { LOG("(watch#%" PRIuPTR ") wrong method sig: \"%s\"", i, watch.m_sig); LOG(", expected: \"%s\"\n", watches[i].m_sig); result = STATUS_FAILED; @@ -161,12 +161,12 @@ void JNICALL FieldAccess(jvmtiEnv *jvmti, JNIEnv *jni, LOG(", expected: 0x%x%08x\n", (jint)(watches[i].loc >> 32), (jint)watches[i].loc); result = STATUS_FAILED; } - if (watch.f_name == NULL || strcmp(watch.f_name, watches[i].f_name) != 0) { + if (watch.f_name == nullptr || strcmp(watch.f_name, watches[i].f_name) != 0) { LOG("(watch#%" PRIuPTR ") wrong field name: \"%s\"", i, watch.f_name); LOG(", expected: \"%s\"\n", watches[i].f_name); result = STATUS_FAILED; } - if (watch.f_sig == NULL || strcmp(watch.f_sig, watches[i].f_sig) != 0) { + if (watch.f_sig == nullptr || strcmp(watch.f_sig, watches[i].f_sig) != 0) { LOG("(watch#%" PRIuPTR ") wrong field sig: \"%s\"", i, watch.f_sig); LOG(", expected: \"%s\"\n", watches[i].f_sig); result = STATUS_FAILED; @@ -194,7 +194,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -223,7 +223,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FIELD_ACCESS, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FIELD_ACCESS, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("Failed to enable JVMTI_EVENT_FIELD_ACCESS: %s (%d)\n", TranslateError(err), err); return JNI_ERR; @@ -256,7 +256,7 @@ Java_fieldacc03_getReady(JNIEnv *jni, jclass klass) { for (size_t i = 0; i < sizeof(watches)/sizeof(watch_info); i++) { cls = jni->FindClass(watches[i].f_cls); - if (cls == NULL) { + if (cls == nullptr) { LOG("Cannot find %s class!\n", watches[i].f_cls); result = STATUS_FAILED; return; @@ -266,7 +266,7 @@ Java_fieldacc03_getReady(JNIEnv *jni, jclass klass) { } else { watches[i].fid = jni->GetFieldID(cls, watches[i].f_name, watches[i].f_sig); } - if (watches[i].fid == NULL) { + if (watches[i].fid == nullptr) { LOG("Cannot get field ID for \"%s:%s\"\n", watches[i].f_name, watches[i].f_sig); result = STATUS_FAILED; return; @@ -291,7 +291,7 @@ Java_fieldacc03_check(JNIEnv *jni, jclass clz) { } for (size_t i = 0; i < sizeof(watches)/sizeof(watch_info); i++) { jclass cls = jni->FindClass(watches[i].f_cls); - if (cls == NULL) { + if (cls == nullptr) { LOG("Cannot find %s class!\n", watches[i].f_cls); result = STATUS_FAILED; return result; diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/FieldAccess/fieldacc04/libfieldacc04.cpp b/test/hotspot/jtreg/serviceability/jvmti/events/FieldAccess/fieldacc04/libfieldacc04.cpp index 1b1f9df96b7..2239294c52c 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/FieldAccess/fieldacc04/libfieldacc04.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/events/FieldAccess/fieldacc04/libfieldacc04.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -65,10 +65,10 @@ static volatile jboolean isVirtualExpected = JNI_FALSE; static int eventsExpected = 0; static int eventsCount = 0; static watch_info watches[] = { - { NULL, "Lfieldacc04a;", "run", "()I", 2, + { nullptr, "Lfieldacc04a;", "run", "()I", 2, "Lfieldacc04a;", "interfaceObject", "Ljava/lang/Object;", JNI_TRUE }, - { NULL, "Lfieldacc04a;", "run", "()I", 12, + { nullptr, "Lfieldacc04a;", "run", "()I", 12, "Lfieldacc04a;", "interfaceArrInt", "[I", JNI_TRUE } }; @@ -87,7 +87,7 @@ void JNICALL FieldAccess(jvmtiEnv *jvmti, JNIEnv *jni, watch.fid = field; watch.loc = location; - watch.is_static = (obj == NULL) ? JNI_TRUE : JNI_FALSE; + watch.is_static = (obj == nullptr) ? JNI_TRUE : JNI_FALSE; err = jvmti->GetMethodDeclaringClass(method, &cls); if (err != JVMTI_ERROR_NONE) { LOG("(GetMethodDeclaringClass) unexpected error: %s (%d)\n", TranslateError(err), err); @@ -129,16 +129,16 @@ void JNICALL FieldAccess(jvmtiEnv *jvmti, JNIEnv *jni, for (size_t i = 0; i < sizeof(watches)/sizeof(watch_info); i++) { if (watch.fid == watches[i].fid) { - if (watch.m_cls == NULL || strcmp(watch.m_cls, watches[i].m_cls) != 0) { + if (watch.m_cls == nullptr || strcmp(watch.m_cls, watches[i].m_cls) != 0) { LOG("(watch#%" PRIuPTR ") wrong class: \"%s\", expected: \"%s\"\n", i, watch.m_cls, watches[i].m_cls); result = STATUS_FAILED; } - if (watch.m_name == NULL || strcmp(watch.m_name, watches[i].m_name) != 0) { + if (watch.m_name == nullptr || strcmp(watch.m_name, watches[i].m_name) != 0) { LOG("(watch#%" PRIuPTR ") wrong method name: \"%s\"", i, watch.m_name); LOG(", expected: \"%s\"\n", watches[i].m_name); result = STATUS_FAILED; } - if (watch.m_sig == NULL || strcmp(watch.m_sig, watches[i].m_sig) != 0) { + if (watch.m_sig == nullptr || strcmp(watch.m_sig, watches[i].m_sig) != 0) { LOG("(watch#%" PRIuPTR ") wrong method sig: \"%s\"", i, watch.m_sig); LOG(", expected: \"%s\"\n", watches[i].m_sig); result = STATUS_FAILED; @@ -148,12 +148,12 @@ void JNICALL FieldAccess(jvmtiEnv *jvmti, JNIEnv *jni, LOG(", expected: 0x%x%08x\n", (jint)(watches[i].loc >> 32), (jint)watches[i].loc); result = STATUS_FAILED; } - if (watch.f_name == NULL || strcmp(watch.f_name, watches[i].f_name) != 0) { + if (watch.f_name == nullptr || strcmp(watch.f_name, watches[i].f_name) != 0) { LOG("(watch#%" PRIuPTR ") wrong field name: \"%s\"", i, watch.f_name); LOG(", expected: \"%s\"\n", watches[i].f_name); result = STATUS_FAILED; } - if (watch.f_sig == NULL || strcmp(watch.f_sig, watches[i].f_sig) != 0) { + if (watch.f_sig == nullptr || strcmp(watch.f_sig, watches[i].f_sig) != 0) { LOG("(watch#%" PRIuPTR ") wrong field sig: \"%s\"", i, watch.f_sig); LOG(", expected: \"%s\"\n", watches[i].f_sig); result = STATUS_FAILED; @@ -181,7 +181,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -210,7 +210,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FIELD_ACCESS, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FIELD_ACCESS, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("Failed to enable JVMTI_EVENT_FIELD_ACCESS: %s (%d)\n", TranslateError(err), err); return JNI_ERR; @@ -243,7 +243,7 @@ Java_fieldacc04_getReady(JNIEnv *jni, jclass klass) { for (size_t i = 0; i < sizeof(watches)/sizeof(watch_info); i++) { cls = jni->FindClass(watches[i].f_cls); - if (cls == NULL) { + if (cls == nullptr) { LOG("Cannot find %s class!\n", watches[i].f_cls); result = STATUS_FAILED; return; @@ -253,7 +253,7 @@ Java_fieldacc04_getReady(JNIEnv *jni, jclass klass) { } else { watches[i].fid = jni->GetFieldID(cls, watches[i].f_name, watches[i].f_sig); } - if (watches[i].fid == NULL) { + if (watches[i].fid == nullptr) { LOG("Cannot get field ID for \"%s:%s\"\n", watches[i].f_name, watches[i].f_sig); result = STATUS_FAILED; return; @@ -279,7 +279,7 @@ Java_fieldacc04_check(JNIEnv *jni, jclass clz) { } for (size_t i = 0; i < sizeof(watches)/sizeof(watch_info); i++) { jclass cls = jni->FindClass(watches[i].f_cls); - if (cls == NULL) { + if (cls == nullptr) { LOG("Cannot find %s class!\n", watches[i].f_cls); result = STATUS_FAILED; return result; diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/FieldModification/fieldmod01/libfieldmod01.cpp b/test/hotspot/jtreg/serviceability/jvmti/events/FieldModification/fieldmod01/libfieldmod01.cpp index cfd53a3f861..26da8fedefb 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/FieldModification/fieldmod01/libfieldmod01.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/events/FieldModification/fieldmod01/libfieldmod01.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -67,46 +67,46 @@ static volatile jboolean isVirtualExpected = JNI_FALSE; static int eventsExpected = 0; static int eventsCount = 0; static watch_info watches[] = { - { NULL, "Lfieldmod01a;", "run", "()V", 1, + { nullptr, "Lfieldmod01a;", "run", "()V", 1, "Lfieldmod01a;", "staticBoolean", "Z", JNI_TRUE, {} }, - { NULL, "Lfieldmod01a;", "run", "()V", 5, + { nullptr, "Lfieldmod01a;", "run", "()V", 5, "Lfieldmod01a;", "staticByte", "B", JNI_TRUE, {} }, - { NULL, "Lfieldmod01a;", "run", "()V", 9, + { nullptr, "Lfieldmod01a;", "run", "()V", 9, "Lfieldmod01a;", "staticShort", "S", JNI_TRUE, {} }, - { NULL, "Lfieldmod01a;", "run", "()V", 13, + { nullptr, "Lfieldmod01a;", "run", "()V", 13, "Lfieldmod01a;", "staticInt", "I", JNI_TRUE, {} }, - { NULL, "Lfieldmod01a;", "run", "()V", 19, + { nullptr, "Lfieldmod01a;", "run", "()V", 19, "Lfieldmod01a;", "staticLong", "J", JNI_TRUE, {} }, - { NULL, "Lfieldmod01a;", "run", "()V", 24, + { nullptr, "Lfieldmod01a;", "run", "()V", 24, "Lfieldmod01a;", "staticFloat", "F", JNI_TRUE, {} }, - { NULL, "Lfieldmod01a;", "run", "()V", 30, + { nullptr, "Lfieldmod01a;", "run", "()V", 30, "Lfieldmod01a;", "staticDouble", "D", JNI_TRUE, {} }, - { NULL, "Lfieldmod01a;", "run", "()V", 35, + { nullptr, "Lfieldmod01a;", "run", "()V", 35, "Lfieldmod01a;", "staticChar", "C", JNI_TRUE, {} }, - { NULL, "Lfieldmod01a;", "run", "()V", 41, + { nullptr, "Lfieldmod01a;", "run", "()V", 41, "Lfieldmod01a;", "staticObject", "Ljava/lang/Object;", JNI_TRUE, {} }, - { NULL, "Lfieldmod01a;", "run", "()V", 47, + { nullptr, "Lfieldmod01a;", "run", "()V", 47, "Lfieldmod01a;", "staticArrInt", "[I", JNI_TRUE, {} }, - { NULL, "Lfieldmod01a;", "run", "()V", 52, + { nullptr, "Lfieldmod01a;", "run", "()V", 52, "Lfieldmod01a;", "instanceBoolean", "Z", JNI_FALSE, {} }, - { NULL, "Lfieldmod01a;", "run", "()V", 58, + { nullptr, "Lfieldmod01a;", "run", "()V", 58, "Lfieldmod01a;", "instanceByte", "B", JNI_FALSE, {} }, - { NULL, "Lfieldmod01a;", "run", "()V", 64, + { nullptr, "Lfieldmod01a;", "run", "()V", 64, "Lfieldmod01a;", "instanceShort", "S", JNI_FALSE, {} }, - { NULL, "Lfieldmod01a;", "run", "()V", 70, + { nullptr, "Lfieldmod01a;", "run", "()V", 70, "Lfieldmod01a;", "instanceInt", "I", JNI_FALSE, {} }, - { NULL, "Lfieldmod01a;", "run", "()V", 77, + { nullptr, "Lfieldmod01a;", "run", "()V", 77, "Lfieldmod01a;", "instanceLong", "J", JNI_FALSE, {} }, - { NULL, "Lfieldmod01a;", "run", "()V", 83, + { nullptr, "Lfieldmod01a;", "run", "()V", 83, "Lfieldmod01a;", "instanceFloat", "F", JNI_FALSE, {} }, - { NULL, "Lfieldmod01a;", "run", "()V", 90, + { nullptr, "Lfieldmod01a;", "run", "()V", 90, "Lfieldmod01a;", "instanceDouble", "D", JNI_FALSE, {} }, - { NULL, "Lfieldmod01a;", "run", "()V", 96, + { nullptr, "Lfieldmod01a;", "run", "()V", 96, "Lfieldmod01a;", "instanceChar", "C", JNI_FALSE, {} }, - { NULL, "Lfieldmod01a;", "run", "()V", 103, + { nullptr, "Lfieldmod01a;", "run", "()V", 103, "Lfieldmod01a;", "instanceObject", "Ljava/lang/Object;", JNI_FALSE, {} }, - { NULL, "Lfieldmod01a;", "run", "()V", 110, + { nullptr, "Lfieldmod01a;", "run", "()V", 110, "Lfieldmod01a;", "instanceArrInt", "[I", JNI_FALSE, {} } }; @@ -187,7 +187,7 @@ void JNICALL FieldModification(jvmtiEnv *jvmti, JNIEnv *jni, watch.fid = field; watch.loc = location; watch.val = new_value; - watch.is_static = (obj == NULL) ? JNI_TRUE : JNI_FALSE; + watch.is_static = (obj == nullptr) ? JNI_TRUE : JNI_FALSE; err = jvmti->GetMethodDeclaringClass(method, &cls); if (err != JVMTI_ERROR_NONE) { LOG("(GetMethodDeclaringClass) unexpected error: %s (%d)\n", TranslateError(err), err); @@ -231,16 +231,16 @@ void JNICALL FieldModification(jvmtiEnv *jvmti, JNIEnv *jni, for (size_t i = 0; i < sizeof(watches)/sizeof(watch_info); i++) { if (watch.fid == watches[i].fid) { - if (watch.m_cls == NULL || strcmp(watch.m_cls, watches[i].m_cls) != 0) { + if (watch.m_cls == nullptr || strcmp(watch.m_cls, watches[i].m_cls) != 0) { LOG("(watch#%" PRIuPTR ") wrong class: \"%s\", expected: \"%s\"\n", i, watch.m_cls, watches[i].m_cls); result = STATUS_FAILED; } - if (watch.m_name == NULL || strcmp(watch.m_name, watches[i].m_name) != 0) { + if (watch.m_name == nullptr || strcmp(watch.m_name, watches[i].m_name) != 0) { LOG("(watch#%" PRIuPTR ") wrong method name: \"%s\"", i, watch.m_name); LOG(", expected: \"%s\"\n", watches[i].m_name); result = STATUS_FAILED; } - if (watch.m_sig == NULL || strcmp(watch.m_sig, watches[i].m_sig) != 0) { + if (watch.m_sig == nullptr || strcmp(watch.m_sig, watches[i].m_sig) != 0) { LOG("(watch#%" PRIuPTR ") wrong method sig: \"%s\"", i, watch.m_sig); LOG(", expected: \"%s\"\n", watches[i].m_sig); result = STATUS_FAILED; @@ -250,12 +250,12 @@ void JNICALL FieldModification(jvmtiEnv *jvmti, JNIEnv *jni, LOG(", expected: 0x%x%08x\n", (jint)(watches[i].loc >> 32), (jint)watches[i].loc); result = STATUS_FAILED; } - if (watch.f_name == NULL || strcmp(watch.f_name, watches[i].f_name) != 0) { + if (watch.f_name == nullptr || strcmp(watch.f_name, watches[i].f_name) != 0) { LOG("(watch#%" PRIuPTR ") wrong field name: \"%s\"", i, watch.f_name); LOG(", expected: \"%s\"\n", watches[i].f_name); result = STATUS_FAILED; } - if (watch.f_sig == NULL || strcmp(watch.f_sig, watches[i].f_sig) != 0) { + if (watch.f_sig == nullptr || strcmp(watch.f_sig, watches[i].f_sig) != 0) { LOG("(watch#%" PRIuPTR ") wrong field sig: \"%s\"", i, watch.f_sig); LOG(", expected: \"%s\"\n", watches[i].f_sig); result = STATUS_FAILED; @@ -291,7 +291,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -321,7 +321,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FIELD_MODIFICATION, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FIELD_MODIFICATION, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("Failed to enable JVMTI_EVENT_FIELD_MODIFICATION: %s (%d)\n", TranslateError(err), err); return JNI_ERR; @@ -353,7 +353,7 @@ Java_fieldmod01_getReady(JNIEnv *jni, jclass klass, jobject obj1, jobject obj2, LOG(">>> setting field modification watches ...\n"); cls = jni->FindClass("fieldmod01a"); - if (cls == NULL) { + if (cls == nullptr) { LOG("Cannot find fieldmod01a class!\n"); result = STATUS_FAILED; return; @@ -364,7 +364,7 @@ Java_fieldmod01_getReady(JNIEnv *jni, jclass klass, jobject obj1, jobject obj2, } else { watches[i].fid = jni->GetFieldID(cls, watches[i].f_name, watches[i].f_sig); } - if (watches[i].fid == NULL) { + if (watches[i].fid == nullptr) { LOG("Cannot get field ID for \"%s:%s\"\n", watches[i].f_name, watches[i].f_sig); result = STATUS_FAILED; return; @@ -412,7 +412,7 @@ Java_fieldmod01_check(JNIEnv *jni, jclass clz) { } jclass cls = jni->FindClass("fieldmod01a"); - if (cls == NULL) { + if (cls == nullptr) { LOG("Cannot find fieldmod01a class!\n"); result = STATUS_FAILED; return result; diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/FieldModification/fieldmod02/libfieldmod02.cpp b/test/hotspot/jtreg/serviceability/jvmti/events/FieldModification/fieldmod02/libfieldmod02.cpp index 7c0dae284eb..23e3c5f22d9 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/FieldModification/fieldmod02/libfieldmod02.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/events/FieldModification/fieldmod02/libfieldmod02.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -67,46 +67,46 @@ static volatile jboolean isVirtualExpected = JNI_FALSE; static int eventsExpected = 0; static int eventsCount = 0; static watch_info watches[] = { - { NULL, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldmod02a;", "staticBoolean", "Z", JNI_TRUE, {} }, - { NULL, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldmod02a;", "staticByte", "B", JNI_TRUE, {} }, - { NULL, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldmod02a;", "staticShort", "S", JNI_TRUE, {} }, - { NULL, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldmod02a;", "staticInt", "I", JNI_TRUE, {} }, - { NULL, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldmod02a;", "staticLong", "J", JNI_TRUE, {} }, - { NULL, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldmod02a;", "staticFloat", "F", JNI_TRUE, {} }, - { NULL, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldmod02a;", "staticDouble", "D", JNI_TRUE, {} }, - { NULL, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldmod02a;", "staticChar", "C", JNI_TRUE, {} }, - { NULL, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldmod02a;", "staticObject", "Ljava/lang/Object;", JNI_TRUE, {} }, - { NULL, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldmod02a;", "staticArrInt", "[I", JNI_TRUE, {} }, - { NULL, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldmod02a;", "instanceBoolean", "Z", JNI_FALSE, {} }, - { NULL, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldmod02a;", "instanceByte", "B", JNI_FALSE, {} }, - { NULL, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldmod02a;", "instanceShort", "S", JNI_FALSE, {} }, - { NULL, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldmod02a;", "instanceInt", "I", JNI_FALSE, {} }, - { NULL, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldmod02a;", "instanceLong", "J", JNI_FALSE, {} }, - { NULL, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldmod02a;", "instanceFloat", "F", JNI_FALSE, {} }, - { NULL, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldmod02a;", "instanceDouble", "D", JNI_FALSE, {} }, - { NULL, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldmod02a;", "instanceChar", "C", JNI_FALSE, {} }, - { NULL, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldmod02a;", "instanceObject", "Ljava/lang/Object;", JNI_FALSE, {} }, - { NULL, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, + { nullptr, "Lfieldmod02;", "check", "(Ljava/lang/Object;)I", 0, "Lfieldmod02a;", "instanceArrInt", "[I", JNI_FALSE, {} } }; @@ -187,7 +187,7 @@ void JNICALL FieldModification(jvmtiEnv *jvmti, JNIEnv *jni, watch.fid = field; watch.loc = location; - watch.is_static = (obj == NULL) ? JNI_TRUE : JNI_FALSE; + watch.is_static = (obj == nullptr) ? JNI_TRUE : JNI_FALSE; watch.val = new_value; err = jvmti->GetMethodDeclaringClass(method, &cls); if (err != JVMTI_ERROR_NONE) { @@ -232,16 +232,16 @@ void JNICALL FieldModification(jvmtiEnv *jvmti, JNIEnv *jni, for (size_t i = 0; i < sizeof(watches)/sizeof(watch_info); i++) { if (watch.fid == watches[i].fid) { - if (watch.m_cls == NULL || strcmp(watch.m_cls, watches[i].m_cls) != 0) { + if (watch.m_cls == nullptr || strcmp(watch.m_cls, watches[i].m_cls) != 0) { LOG("(watch#%" PRIuPTR ") wrong class: \"%s\", expected: \"%s\"\n", i, watch.m_cls, watches[i].m_cls); result = STATUS_FAILED; } - if (watch.m_name == NULL || strcmp(watch.m_name, watches[i].m_name) != 0) { + if (watch.m_name == nullptr || strcmp(watch.m_name, watches[i].m_name) != 0) { LOG("(watch#%" PRIuPTR ") wrong method name: \"%s\"", i, watch.m_name); LOG(", expected: \"%s\"\n", watches[i].m_name); result = STATUS_FAILED; } - if (watch.m_sig == NULL || strcmp(watch.m_sig, watches[i].m_sig) != 0) { + if (watch.m_sig == nullptr || strcmp(watch.m_sig, watches[i].m_sig) != 0) { LOG("(watch#%" PRIuPTR ") wrong method sig: \"%s\"", i, watch.m_sig); LOG(", expected: \"%s\"\n", watches[i].m_sig); result = STATUS_FAILED; @@ -251,12 +251,12 @@ void JNICALL FieldModification(jvmtiEnv *jvmti, JNIEnv *jni, LOG(", expected: 0x%x%08x\n", (jint)(watches[i].loc >> 32), (jint)watches[i].loc); result = STATUS_FAILED; } - if (watch.f_name == NULL || strcmp(watch.f_name, watches[i].f_name) != 0) { + if (watch.f_name == nullptr || strcmp(watch.f_name, watches[i].f_name) != 0) { LOG("(watch#%" PRIuPTR ") wrong field name: \"%s\"", i, watch.f_name); LOG(", expected: \"%s\"\n", watches[i].f_name); result = STATUS_FAILED; } - if (watch.f_sig == NULL || strcmp(watch.f_sig, watches[i].f_sig) != 0) { + if (watch.f_sig == nullptr || strcmp(watch.f_sig, watches[i].f_sig) != 0) { LOG("(watch#%" PRIuPTR ") wrong field sig: \"%s\"", i, watch.f_sig); LOG(", expected: \"%s\"\n", watches[i].f_sig); result = STATUS_FAILED; @@ -292,7 +292,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -321,7 +321,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FIELD_MODIFICATION, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FIELD_MODIFICATION, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("Failed to enable JVMTI_EVENT_FIELD_MODIFICATION: %s (%d)\n", TranslateError(err), err); return JNI_ERR; @@ -356,7 +356,7 @@ Java_fieldmod02_getReady(JNIEnv *jni, jclass clz) { LOG(">>> setting field modification watches ...\n"); cls = jni->FindClass("fieldmod02a"); - if (cls == NULL) { + if (cls == nullptr) { LOG("Cannot find fieldmod02a class!\n"); result = STATUS_FAILED; return; @@ -367,7 +367,7 @@ Java_fieldmod02_getReady(JNIEnv *jni, jclass clz) { } else { watches[i].fid = jni->GetFieldID(cls, watches[i].f_name, watches[i].f_sig); } - if (watches[i].fid == NULL) { + if (watches[i].fid == nullptr) { LOG("Cannot get field ID for \"%s:%s\"\n", watches[i].f_name, watches[i].f_sig); result = STATUS_FAILED; return; @@ -422,7 +422,7 @@ Java_fieldmod02_check(JNIEnv *jni, jclass clz, jobject obj) { cls = jni->FindClass("fieldmod02a"); - if (cls == NULL) { + if (cls == nullptr) { LOG("Cannot find fieldmod02a class!\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/FramePop/framepop01/libframepop01.cpp b/test/hotspot/jtreg/serviceability/jvmti/events/FramePop/framepop01/libframepop01.cpp index d757e2eff4c..04eb17d6d4c 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/FramePop/framepop01/libframepop01.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/events/FramePop/framepop01/libframepop01.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -40,7 +40,7 @@ typedef struct { jlocation loc; } pop_info; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jint result = PASSED; static volatile jboolean isVirtualExpected = JNI_FALSE; @@ -111,17 +111,17 @@ void JNICALL FramePop(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread_obj, jmethodI LOG(">>> ... done\n"); if (eventsCount < sizeof(pops)/sizeof(pop_info)) { - if (cls_sig == NULL || strcmp(cls_sig, pops[eventsCount].cls_sig) != 0) { + if (cls_sig == nullptr || strcmp(cls_sig, pops[eventsCount].cls_sig) != 0) { LOG("(pop#%" PRIuPTR ") wrong class: \"%s\"", eventsCount, cls_sig); LOG(", expected: \"%s\"\n", pops[eventsCount].cls_sig); result = STATUS_FAILED; } - if (name == NULL || strcmp(name, pops[eventsCount].name) != 0) { + if (name == nullptr || strcmp(name, pops[eventsCount].name) != 0) { LOG("(pop#%" PRIuPTR ") wrong method name: \"%s\"", eventsCount, name); LOG(", expected: \"%s\"\n", pops[eventsCount].name); result = STATUS_FAILED; } - if (sig == NULL || strcmp(sig, pops[eventsCount].sig) != 0) { + if (sig == nullptr || strcmp(sig, pops[eventsCount].sig) != 0) { LOG("(pop#%" PRIuPTR ") wrong method sig: \"%s\"", eventsCount, sig); LOG(", expected: \"%s\"\n", pops[eventsCount].sig); result = STATUS_FAILED; @@ -152,7 +152,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -203,7 +203,7 @@ Java_framepop01_check(JNIEnv *jni, jclass cls) { return STATUS_FAILED; } - if (jvmti == NULL) { + if (jvmti == nullptr) { LOG("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -218,19 +218,19 @@ Java_framepop01_check(JNIEnv *jni, jclass cls) { LOG("Failed to SetBreakpoint: %s (%d)\n", TranslateError(err), err); return STATUS_FAILED; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FRAME_POP, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FRAME_POP, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("Failed to enable JVMTI_EVENT_FRAME_POP event: %s (%d)\n", TranslateError(err), err); result = STATUS_FAILED; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("Failed to enable BREAKPOINT event: %s (%d)\n", TranslateError(err), err); result = STATUS_FAILED; } clz = jni->FindClass("framepop01a"); - if (clz == NULL) { + if (clz == nullptr) { LOG("Cannot find framepop01a class!\n"); result = STATUS_FAILED; return STATUS_FAILED; diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/FramePop/framepop02/libframepop02.cpp b/test/hotspot/jtreg/serviceability/jvmti/events/FramePop/framepop02/libframepop02.cpp index bc8f36114a2..21e8f4e7e06 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/FramePop/framepop02/libframepop02.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/events/FramePop/framepop02/libframepop02.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -45,7 +45,7 @@ typedef struct thr { item_t tos; } thr; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jrawMonitorID event_lock; static jboolean printdump = JNI_TRUE; @@ -116,7 +116,7 @@ void pop(jvmtiEnv *jvmti, JNIEnv *jni, jthread thr, jmethodID method, int depth) fatal(jni, "Unknown thread:\n"); } - if (threads[i].tos == NULL) { + if (threads[i].tos == nullptr) { watch_events = JNI_FALSE; printInfo(jni, jvmti, thr, method, depth); fatal(jni, "Stack underflow:\n"); @@ -131,7 +131,7 @@ void pop(jvmtiEnv *jvmti, JNIEnv *jni, jthread thr, jmethodID method, int depth) return; } free(old); - } while (threads[i].tos != NULL); + } while (threads[i].tos != nullptr); watch_events = JNI_FALSE; printInfo(jni, jvmti, thr, method, depth); @@ -155,11 +155,11 @@ void push(JNIEnv *jni, jthread thr, jmethodID method, int depth) { fatal(jni, "Out of threads\n"); } threads[i].thread = jni->NewGlobalRef(thr); - threads[i].tos = NULL; + threads[i].tos = nullptr; } new_item = (item_t)malloc(sizeof(item)); - if (new_item == NULL) { + if (new_item == nullptr) { fatal(jni, "Out of memory\n"); } @@ -246,7 +246,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -280,11 +280,11 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { LOG("(SetEventCallbacks) unexpected error: %s (%d)\n", TranslateError(err), err); return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_START, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_START, nullptr); if (err != JVMTI_ERROR_NONE) { return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, nullptr); if (err != JVMTI_ERROR_NONE) { return JNI_ERR; } @@ -295,18 +295,18 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { } JNIEXPORT void JNICALL Java_framepop02_getReady(JNIEnv *jni, jclass cls) { - check_jvmti_status(jni, jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_ENTRY, NULL), + check_jvmti_status(jni, jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_ENTRY, nullptr), "Error in SetEventNotificationMode"); - check_jvmti_status(jni, jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FRAME_POP, NULL), + check_jvmti_status(jni, jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FRAME_POP, nullptr), "Error in SetEventNotificationMode"); watch_events = JNI_TRUE; } JNIEXPORT void JNICALL Java_framepop02_check(JNIEnv *jni, jclass cls) { watch_events = JNI_FALSE; - check_jvmti_status(jni, jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_FRAME_POP, NULL), + check_jvmti_status(jni, jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_FRAME_POP, nullptr), "Error in SetEventNotificationMode"); - check_jvmti_status(jni, jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_METHOD_ENTRY, NULL), + check_jvmti_status(jni, jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_METHOD_ENTRY, nullptr), "Error in SetEventNotificationMode"); if (printdump == JNI_TRUE) { diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/MethodEntry/mentry01/libmentry01.cpp b/test/hotspot/jtreg/serviceability/jvmti/events/MethodEntry/mentry01/libmentry01.cpp index 780438d02f5..b5dec318029 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/MethodEntry/mentry01/libmentry01.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/events/MethodEntry/mentry01/libmentry01.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -45,7 +45,7 @@ typedef struct { const jlocation loc; } entry_info; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; static jint result = PASSED; @@ -78,7 +78,7 @@ void JNICALL MethodEntry(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread_obj, jmeth result = STATUS_FAILED; return; } - if (cls_sig != NULL && strcmp(cls_sig, "Lmentry01;") == 0) { + if (cls_sig != nullptr && strcmp(cls_sig, "Lmentry01;") == 0) { LOG(">>> retrieving method entry info ...\n"); err = jvmti->GetMethodName(method, &entry.name, &entry.sig, &generic); @@ -100,12 +100,12 @@ void JNICALL MethodEntry(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread_obj, jmeth LOG(">>> ... done\n"); if (eventsCount < sizeof(entries)/sizeof(entry_info)) { - if (entry.name == NULL || strcmp(entry.name, entries[eventsCount].name) != 0) { + if (entry.name == nullptr || strcmp(entry.name, entries[eventsCount].name) != 0) { LOG("(entry#%" PRIuPTR ") wrong method name: \"%s\"", eventsCount, entry.name); LOG(", expected: \"%s\"\n", entries[eventsCount].name); result = STATUS_FAILED; } - if (entry.sig == NULL || strcmp(entry.sig, entries[eventsCount].sig) != 0) { + if (entry.sig == nullptr || strcmp(entry.sig, entries[eventsCount].sig) != 0) { LOG("(entry#%" PRIuPTR ") wrong method sig: \"%s\"", eventsCount, entry.sig); LOG(", expected: \"%s\"\n", entries[eventsCount].sig); result = STATUS_FAILED; @@ -137,7 +137,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -176,7 +176,7 @@ JNIEXPORT void JNICALL Java_mentry01_enable(JNIEnv *jni, jclass cls) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { return; } @@ -188,7 +188,7 @@ Java_mentry01_enable(JNIEnv *jni, jclass cls) { } isVirtualExpected = jni->IsVirtualThread(thread); - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_ENTRY, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_ENTRY, nullptr); if (err == JVMTI_ERROR_NONE) { eventsExpected = sizeof(entries)/sizeof(entry_info); eventsCount = 0; @@ -202,7 +202,7 @@ JNIEXPORT jint JNICALL Java_mentry01_check(JNIEnv *jni, jclass cls) { jmethodID mid = jni->GetStaticMethodID(cls, "dummy", "()V"); - if (mid == NULL) { + if (mid == nullptr) { LOG("Cannot find metod \"dummy()\"!\n"); return STATUS_FAILED; } @@ -219,13 +219,13 @@ JNIEXPORT void JNICALL Java_mentry01_chain(JNIEnv *jni, jclass cls) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { LOG("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; } - err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_METHOD_ENTRY, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_METHOD_ENTRY, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("Failed to disable JVMTI_EVENT_METHOD_ENTRY event: %s (%d)\n", TranslateError(err), err); result = STATUS_FAILED; diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/MethodEntry/mentry02/libmentry02.cpp b/test/hotspot/jtreg/serviceability/jvmti/events/MethodEntry/mentry02/libmentry02.cpp index 90b62dcee7a..43202de0ad7 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/MethodEntry/mentry02/libmentry02.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/events/MethodEntry/mentry02/libmentry02.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -32,7 +32,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jint result = PASSED; static jboolean isVirtualExpected = JNI_FALSE; @@ -40,7 +40,7 @@ static int MethodEntriesExpected = 0; static int MethodExitsExpected = 0; static int MethodEntriesCount = 0; static int MethodExitsCount = 0; -static jmethodID mid = NULL; +static jmethodID mid = nullptr; void JNICALL MethodEntry(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread_obj, jmethodID method) { @@ -75,7 +75,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -116,7 +116,7 @@ JNIEXPORT void JNICALL Java_mentry02_getReady(JNIEnv *jni, jclass cls, jint i) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { LOG("JVMTI client was not properly loaded!\n"); return; } @@ -130,13 +130,13 @@ Java_mentry02_getReady(JNIEnv *jni, jclass cls, jint i) { isVirtualExpected = jni->IsVirtualThread(thread); mid = jni->GetStaticMethodID(cls, "emptyMethod", "()V"); - if (mid == NULL) { + if (mid == nullptr) { LOG("Cannot find Method ID for emptyMethod\n"); result = STATUS_FAILED; return; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_ENTRY, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_ENTRY, nullptr); if (err == JVMTI_ERROR_NONE) { MethodEntriesCount = 0; MethodEntriesExpected = i; @@ -145,7 +145,7 @@ Java_mentry02_getReady(JNIEnv *jni, jclass cls, jint i) { result = STATUS_FAILED; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_EXIT, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_EXIT, nullptr); if (err == JVMTI_ERROR_NONE) { MethodExitsCount = 0; MethodExitsExpected = i; diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/MethodExit/mexit01/libmexit01.cpp b/test/hotspot/jtreg/serviceability/jvmti/events/MethodExit/mexit01/libmexit01.cpp index 616b599a59b..c6980f10484 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/MethodExit/mexit01/libmexit01.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/events/MethodExit/mexit01/libmexit01.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -40,7 +40,7 @@ typedef struct { jlocation loc; } method_location_info; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jint result = PASSED; static jboolean isVirtualExpected = JNI_FALSE; @@ -73,7 +73,7 @@ void JNICALL MethodExit(jvmtiEnv *jvmti, JNIEnv *jni, result = STATUS_FAILED; return; } - if (cls_sig != NULL && strcmp(cls_sig, "Lmexit01a;") == 0) { + if (cls_sig != nullptr && strcmp(cls_sig, "Lmexit01a;") == 0) { LOG(">>> retrieving method exit info ...\n"); err = jvmti->GetMethodName(method, &name, &sig, &generic); @@ -95,17 +95,17 @@ void JNICALL MethodExit(jvmtiEnv *jvmti, JNIEnv *jni, LOG(">>> ... done\n"); if (eventsCount < sizeof(exits) / sizeof(method_location_info)) { - if (cls_sig == NULL || strcmp(cls_sig, exits[eventsCount].cls_sig) != 0) { + if (cls_sig == nullptr || strcmp(cls_sig, exits[eventsCount].cls_sig) != 0) { LOG("(exit#%" PRIuPTR ") wrong class: \"%s\"", eventsCount, cls_sig); LOG(", expected: \"%s\"\n", exits[eventsCount].cls_sig); result = STATUS_FAILED; } - if (name == NULL || strcmp(name, exits[eventsCount].name) != 0) { + if (name == nullptr || strcmp(name, exits[eventsCount].name) != 0) { LOG("(exit#%" PRIuPTR ") wrong method name: \"%s\"", eventsCount, name); LOG(", expected: \"%s\"\n", exits[eventsCount].name); result = STATUS_FAILED; } - if (sig == NULL || strcmp(sig, exits[eventsCount].sig) != 0) { + if (sig == nullptr || strcmp(sig, exits[eventsCount].sig) != 0) { LOG("(exit#%" PRIuPTR ") wrong method sig: \"%s\"", eventsCount, sig); LOG(", expected: \"%s\"\n", exits[eventsCount].sig); result = STATUS_FAILED; @@ -137,7 +137,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -177,12 +177,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { JNIEXPORT jint JNICALL Java_mexit01_init0(JNIEnv *jni, jclass cls) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { LOG("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_EXIT, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_EXIT, nullptr); if (err == JVMTI_ERROR_NONE) { eventsExpected = sizeof(exits)/sizeof(method_location_info); eventsCount = 0; @@ -200,7 +200,7 @@ Java_mexit01_check(JNIEnv *jni, jclass cls) { jclass clz; jmethodID mid; - if (jvmti == NULL) { + if (jvmti == nullptr) { LOG("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -214,20 +214,20 @@ Java_mexit01_check(JNIEnv *jni, jclass cls) { isVirtualExpected = jni->IsVirtualThread(thread); clz = jni->FindClass("mexit01a"); - if (clz == NULL) { + if (clz == nullptr) { LOG("Cannot find MethodExit.mexit01a class!\n"); return STATUS_FAILED; } mid = jni->GetStaticMethodID(clz, "dummy", "()V"); - if (mid == NULL) { + if (mid == nullptr) { LOG("Cannot find metod \"dummy()\"!\n"); return STATUS_FAILED; } jni->CallStaticVoidMethod(clz, mid); - err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_METHOD_EXIT, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_METHOD_EXIT, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("Failed to disable JVMTI_EVENT_METHOD_EXIT event: %s (%d)\n", TranslateError(err), err); result = STATUS_FAILED; diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/MethodExit/mexit02/libmexit02.cpp b/test/hotspot/jtreg/serviceability/jvmti/events/MethodExit/mexit02/libmexit02.cpp index 140a9932c14..d7d24a3f4e6 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/MethodExit/mexit02/libmexit02.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/events/MethodExit/mexit02/libmexit02.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. +* Copyright (c) 2003, 2024, 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 @@ -40,7 +40,7 @@ typedef struct { jlocation loc; } method_location_info; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jint result = PASSED; static jboolean isVirtualExpected = JNI_FALSE; @@ -73,7 +73,7 @@ void JNICALL MethodExit(jvmtiEnv *jvmti, JNIEnv *jni, result = STATUS_FAILED; return; } - if (cls_sig != NULL && strcmp(cls_sig, "Lmexit02a;") == 0) { + if (cls_sig != nullptr && strcmp(cls_sig, "Lmexit02a;") == 0) { LOG(">>> retrieving method exit info ...\n"); err = jvmti->GetMethodName(method, &name, &sig, &generic); @@ -100,17 +100,17 @@ void JNICALL MethodExit(jvmtiEnv *jvmti, JNIEnv *jni, } if (eventsCount < sizeof(exits)/sizeof(method_location_info)) { - if (cls_sig == NULL || strcmp(cls_sig, exits[eventsCount].cls_sig) != 0) { + if (cls_sig == nullptr || strcmp(cls_sig, exits[eventsCount].cls_sig) != 0) { LOG("(exit#%" PRIuPTR ") wrong class: \"%s\"", eventsCount, cls_sig); LOG(", expected: \"%s\"\n", exits[eventsCount].cls_sig); result = STATUS_FAILED; } - if (name == NULL || strcmp(name, exits[eventsCount].name) != 0) { + if (name == nullptr || strcmp(name, exits[eventsCount].name) != 0) { LOG("(exit#%" PRIuPTR ") wrong method name: \"%s\"", eventsCount, name); LOG(", expected: \"%s\"\n", exits[eventsCount].name); result = STATUS_FAILED; } - if (sig == NULL || strcmp(sig, exits[eventsCount].sig) != 0) { + if (sig == nullptr || strcmp(sig, exits[eventsCount].sig) != 0) { LOG("(exit#%" PRIuPTR ") wrong method sig: \"%s\"", eventsCount, sig); LOG(", expected: \"%s\"\n", exits[eventsCount].sig); result = STATUS_FAILED; @@ -137,7 +137,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -178,7 +178,7 @@ Java_mexit02_check(JNIEnv *jni, jclass cls) { jclass clz; jmethodID mid; - if (jvmti == NULL) { + if (jvmti == nullptr) { LOG("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -192,18 +192,18 @@ Java_mexit02_check(JNIEnv *jni, jclass cls) { isVirtualExpected = jni->IsVirtualThread(thread); clz = jni->FindClass("mexit02a"); - if (clz == NULL) { + if (clz == nullptr) { LOG("Failed to find class \"mexit02a\"!\n"); return STATUS_FAILED; } mid = jni->GetStaticMethodID(clz, "dummy", "()V"); - if (mid == NULL) { + if (mid == nullptr) { LOG("Failed to get method \"dummy\"!\n"); return STATUS_FAILED; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_EXIT, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_EXIT, nullptr); if (err == JVMTI_ERROR_NONE) { eventsExpected = sizeof(exits)/sizeof(method_location_info); eventsCount = 0; @@ -214,7 +214,7 @@ Java_mexit02_check(JNIEnv *jni, jclass cls) { jni->CallStaticVoidMethod(clz, mid); - err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_METHOD_EXIT, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_METHOD_EXIT, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("Failed to disable JVMTI_EVENT_METHOD_EXIT event: %s (%d)\n", TranslateError(err), err); result = STATUS_FAILED; diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/MonitorContendedEnter/mcontenter01/libmcontenter01.cpp b/test/hotspot/jtreg/serviceability/jvmti/events/MonitorContendedEnter/mcontenter01/libmcontenter01.cpp index 023cb075a88..77ea808dc23 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/MonitorContendedEnter/mcontenter01/libmcontenter01.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/events/MonitorContendedEnter/mcontenter01/libmcontenter01.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -35,13 +35,13 @@ extern "C" { /* ========================================================================== */ /* scaffold objects */ -static JNIEnv *jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv *jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* test objects */ -static jthread expected_thread = NULL; -static jobject expected_object = NULL; +static jthread expected_thread = nullptr; +static jobject expected_object = nullptr; static volatile int eventsCount = 0; /* ========================================================================== */ @@ -53,12 +53,12 @@ MonitorContendedEnter(jvmtiEnv *jvmti, JNIEnv *jni, jthread thr, jobject obj) { print_thread_info(jvmti, jni, thr); - if (expected_thread == NULL) { - jni->FatalError("expected_thread is NULL."); + if (expected_thread == nullptr) { + jni->FatalError("expected_thread is null."); } - if (expected_object == NULL) { - jni->FatalError("expected_object is NULL."); + if (expected_object == nullptr) { + jni->FatalError("expected_object is null."); } /* check if event is for tested thread and for tested object */ @@ -72,7 +72,7 @@ MonitorContendedEnter(jvmtiEnv *jvmti, JNIEnv *jni, jthread thr, jobject obj) { /* ========================================================================== */ static int prepare() { - jvmtiError err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTER, NULL); + jvmtiError err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTER, nullptr); if (err != JVMTI_ERROR_NONE) { jni->FatalError("Error enabling JVMTI_EVENT_MONITOR_CONTENDED_ENTER."); } @@ -82,7 +82,7 @@ static int prepare() { static int clean() { LOG("Disabling events\n"); /* disable MonitorContendedEnter event */ - jvmtiError err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTER, NULL); + jvmtiError err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTER, nullptr); if (err != JVMTI_ERROR_NONE) { set_agent_fail_status(); } @@ -139,7 +139,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { LOG("Timeout: %d msc\n", (int) timeout); res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -177,7 +177,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - set_agent_proc(agentProc, NULL); + set_agent_proc(agentProc, nullptr); return JNI_OK; } @@ -190,13 +190,13 @@ JNIEXPORT void JNICALL Java_mcontenter01_setExpected(JNIEnv *jni, jobject clz, j LOG("Remembering global reference for monitor object is %p\n", obj); /* make object accessible for a long time */ expected_object = jni->NewGlobalRef(obj); - if (expected_object == NULL) { + if (expected_object == nullptr) { jni->FatalError("Error saving global reference to monitor.\n"); } /* make thread accessable for a long time */ expected_thread = jni->NewGlobalRef(thread); - if (thread == NULL) { + if (thread == nullptr) { jni->FatalError("Error saving global reference to thread.\n"); } diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/MonitorContendedEntered/mcontentered01/libmcontentered01.cpp b/test/hotspot/jtreg/serviceability/jvmti/events/MonitorContendedEntered/mcontentered01/libmcontentered01.cpp index 6589f5dabd7..c46ccac6933 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/MonitorContendedEntered/mcontentered01/libmcontentered01.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/events/MonitorContendedEntered/mcontentered01/libmcontentered01.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -32,13 +32,13 @@ extern "C" { /* ========================================================================== */ /* scaffold objects */ -static JNIEnv *jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv *jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* test objects */ -static jthread expected_thread = NULL; -static jobject expected_object = NULL; +static jthread expected_thread = nullptr; +static jobject expected_object = nullptr; static volatile int eventsCount = 0; @@ -51,12 +51,12 @@ MonitorContendedEntered(jvmtiEnv *jvmti, JNIEnv *jni, jthread thr, jobject obj) print_thread_info(jvmti, jni, thr); - if (expected_thread == NULL) { - jni->FatalError("expected_thread is NULL."); + if (expected_thread == nullptr) { + jni->FatalError("expected_thread is null."); } - if (expected_object == NULL) { - jni->FatalError("expected_object is NULL."); + if (expected_object == nullptr) { + jni->FatalError("expected_object is null."); } /* check if event is for tested thread and for tested object */ @@ -73,12 +73,12 @@ MonitorContendedEnter(jvmtiEnv *jvmti, JNIEnv *jni, jthread thr, jobject obj) { LOG("MonitorContendedEnter event:\n\tthread: %p, object: %p, expected object: %p\n",thr, obj, expected_object); print_thread_info(jvmti, jni, thr); - if (expected_thread == NULL) { - jni->FatalError("expected_thread is NULL."); + if (expected_thread == nullptr) { + jni->FatalError("expected_thread is null."); } - if (expected_object == NULL) { - jni->FatalError("expected_object is NULL."); + if (expected_object == nullptr) { + jni->FatalError("expected_object is null."); } /* check if event is for tested thread and for tested object */ @@ -97,14 +97,14 @@ static int prepare() { LOG("Prepare: find tested thread\n"); /* enable MonitorContendedEntered event */ - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTERED, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTERED, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("Prepare: 11\n"); return JNI_FALSE; } /* enable MonitorContendedEnter event */ - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTER, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTER, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("Prepare: 11\n"); return JNI_FALSE; @@ -116,7 +116,7 @@ static int prepare() { static int clean() { jvmtiError err; /* disable MonitorContendedEntered event */ - err = jvmti->SetEventNotificationMode(JVMTI_DISABLE,JVMTI_EVENT_MONITOR_CONTENDED_ENTERED,NULL); + err = jvmti->SetEventNotificationMode(JVMTI_DISABLE,JVMTI_EVENT_MONITOR_CONTENDED_ENTERED,nullptr); if (err != JVMTI_ERROR_NONE) { set_agent_fail_status(); } @@ -173,7 +173,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { LOG("Timeout: %d msc\n", (int) timeout); res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -214,7 +214,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - set_agent_proc(agentProc, NULL); + set_agent_proc(agentProc, nullptr); return JNI_OK; } @@ -227,13 +227,13 @@ JNIEXPORT void JNICALL Java_mcontentered01_setExpected(JNIEnv *jni, jobject clz, LOG("Remembering global reference for monitor object is %p\n", obj); /* make object accessible for a long time */ expected_object = jni->NewGlobalRef(obj); - if (expected_object == NULL) { + if (expected_object == nullptr) { jni->FatalError("Error saving global reference to monitor.\n"); } /* make thread accessable for a long time */ expected_thread = jni->NewGlobalRef(thread); - if (thread == NULL) { + if (thread == nullptr) { jni->FatalError("Error saving global reference to thread.\n"); } diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/MonitorWait/monitorwait01/libmonitorwait01.cpp b/test/hotspot/jtreg/serviceability/jvmti/events/MonitorWait/monitorwait01/libmonitorwait01.cpp index 6467a6b3dcb..b85fa20ca16 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/MonitorWait/monitorwait01/libmonitorwait01.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/events/MonitorWait/monitorwait01/libmonitorwait01.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,13 +31,13 @@ extern "C" { /* scaffold objects */ -static JNIEnv *jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv *jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* test objects */ -static jthread expected_thread = NULL; -static jobject expected_object = NULL; +static jthread expected_thread = nullptr; +static jobject expected_object = nullptr; static volatile int eventsCount = 0; void JNICALL @@ -47,12 +47,12 @@ MonitorWait(jvmtiEnv *jvmti, JNIEnv *jni, jthread thr, jobject obj, jlong tout) print_thread_info(jvmti, jni, thr); - if (expected_thread == NULL) { - jni->FatalError("expected_thread is NULL."); + if (expected_thread == nullptr) { + jni->FatalError("expected_thread is null."); } - if (expected_object == NULL) { - jni->FatalError("expected_object is NULL."); + if (expected_object == nullptr) { + jni->FatalError("expected_object is null."); } /* check if event is for tested thread and for tested object */ @@ -70,7 +70,7 @@ MonitorWait(jvmtiEnv *jvmti, JNIEnv *jni, jthread thr, jobject obj, jlong tout) static int prepare() { /* enable MonitorWait event */ - jvmtiError err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_WAIT, NULL); + jvmtiError err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_WAIT, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("Prepare: 11\n"); return JNI_FALSE; @@ -80,7 +80,7 @@ static int prepare() { static int clean() { /* disable MonitorWait event */ - jvmtiError err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_MONITOR_WAIT, NULL); + jvmtiError err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_MONITOR_WAIT, nullptr); if (err != JVMTI_ERROR_NONE) { set_agent_fail_status(); } @@ -135,7 +135,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { LOG("Timeout: %d msc\n", (int) timeout); res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -173,7 +173,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - set_agent_proc(agentProc, NULL); + set_agent_proc(agentProc, nullptr); return JNI_OK; } @@ -182,13 +182,13 @@ JNIEXPORT void JNICALL Java_monitorwait01_setExpected(JNIEnv *jni, jobject clz, LOG("Remembering global reference for monitor object is %p\n", obj); /* make object accessible for a long time */ expected_object = jni->NewGlobalRef(obj); - if (expected_object == NULL) { + if (expected_object == nullptr) { jni->FatalError("Error saving global reference to monitor.\n"); } /* make thread accessable for a long time */ expected_thread = jni->NewGlobalRef(thread); - if (thread == NULL) { + if (thread == nullptr) { jni->FatalError("Error saving global reference to thread.\n"); } diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/MonitorWaited/monitorwaited01/libmonitorwaited01.cpp b/test/hotspot/jtreg/serviceability/jvmti/events/MonitorWaited/monitorwaited01/libmonitorwaited01.cpp index 2eaeefce2fc..013dbd66d81 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/MonitorWaited/monitorwaited01/libmonitorwaited01.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/events/MonitorWaited/monitorwaited01/libmonitorwaited01.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,13 +31,13 @@ extern "C" { /* scaffold objects */ -static JNIEnv *jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv *jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* test objects */ -static jthread expected_thread = NULL; -static jobject expected_object = NULL; +static jthread expected_thread = nullptr; +static jobject expected_object = nullptr; static volatile int eventsCount = 0; void JNICALL @@ -48,12 +48,12 @@ MonitorWaited(jvmtiEnv *jvmti, JNIEnv *jni, jthread thr, jobject obj, jboolean t print_thread_info(jvmti, jni, thr); - if (expected_thread == NULL) { - jni->FatalError("expected_thread is NULL."); + if (expected_thread == nullptr) { + jni->FatalError("expected_thread is null."); } - if (expected_object == NULL) { - jni->FatalError("expected_object is NULL."); + if (expected_object == nullptr) { + jni->FatalError("expected_object is null."); } /* check if event is for tested thread and for tested object */ @@ -71,7 +71,7 @@ MonitorWaited(jvmtiEnv *jvmti, JNIEnv *jni, jthread thr, jobject obj, jboolean t static int prepare() { /* enable MonitorWait event */ - jvmtiError err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_WAITED, NULL); + jvmtiError err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_WAITED, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("Prepare: 11\n"); return JNI_FALSE; @@ -81,7 +81,7 @@ static int prepare() { static int clean() { /* disable MonitorWaited event */ - jvmtiError err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_MONITOR_WAITED, NULL); + jvmtiError err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_MONITOR_WAITED, nullptr); if (err != JVMTI_ERROR_NONE) { set_agent_fail_status(); } @@ -136,7 +136,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { LOG("Timeout: %d msc\n", (int) timeout); res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -176,7 +176,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - set_agent_proc(agentProc, NULL); + set_agent_proc(agentProc, nullptr); return JNI_OK; } @@ -185,13 +185,13 @@ JNIEXPORT void JNICALL Java_monitorwaited01_setExpected(JNIEnv *jni, jobject clz LOG("Remembering global reference for monitor object is %p\n", obj); /* make object accessible for a long time */ expected_object = jni->NewGlobalRef(obj); - if (expected_object == NULL) { + if (expected_object == nullptr) { jni->FatalError("Error saving global reference to monitor.\n"); } /* make thread accessable for a long time */ expected_thread = jni->NewGlobalRef(thread); - if (thread == NULL) { + if (thread == nullptr) { jni->FatalError("Error saving global reference to thread.\n"); } diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/NativeMethodBind/nativemethbind01/libnativemethbind01.cpp b/test/hotspot/jtreg/serviceability/jvmti/events/NativeMethodBind/nativemethbind01/libnativemethbind01.cpp index e363de01b02..c0f7261b38f 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/NativeMethodBind/nativemethbind01/libnativemethbind01.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/events/NativeMethodBind/nativemethbind01/libnativemethbind01.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ static const char *CLASS_SIG = "Lnativemethbind01$TestedClass;"; static volatile jint result = PASSED; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jrawMonitorID counter_lock; @@ -76,7 +76,7 @@ NativeMethodBind(jvmtiEnv *jvmti, JNIEnv* jni, jthread thread, return; } - err = jvmti->GetMethodName(method, &methNam, &methSig, NULL); + err = jvmti->GetMethodName(method, &methNam, &methSig, nullptr); if (err != JVMTI_ERROR_NONE) { result = STATUS_FAILED; LOG("TEST FAILED: unable to get method name during NativeMethodBind callback\n\n"); @@ -118,7 +118,7 @@ anotherNativeMethod(JNIEnv *jni, jobject obj) { /* dummy method used only to provoke NativeMethodBind event */ JNIEXPORT void JNICALL Java_nativemethbind01_nativeMethod(JNIEnv *jni, jobject obj, jboolean registerNative) { - jclass testedCls = NULL; + jclass testedCls = nullptr; JNINativeMethod meth; LOG("Inside the nativeMethod()\n"); @@ -126,7 +126,7 @@ Java_nativemethbind01_nativeMethod(JNIEnv *jni, jobject obj, jboolean registerNa if (registerNative == JNI_TRUE) { LOG("Finding class \"%s\" ...\n", CLASS_SIG); testedCls = jni->FindClass(CLASS_SIG); - if (testedCls == NULL) { + if (testedCls == nullptr) { result = STATUS_FAILED; COMPLAIN("TEST FAILURE: unable to find class \"%s\"\n\n", CLASS_SIG); return; @@ -168,7 +168,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_9); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -203,7 +203,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; LOG("setting event callbacks done\nenabling JVMTI events ...\n"); - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_NATIVE_METHOD_BIND, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_NATIVE_METHOD_BIND, nullptr); if (err != JVMTI_ERROR_NONE){ return JNI_ERR; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/NativeMethodBind/nativemethbind02/libnativemethbind02.cpp b/test/hotspot/jtreg/serviceability/jvmti/events/NativeMethodBind/nativemethbind02/libnativemethbind02.cpp index 2d5dcefe557..747952d4a10 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/NativeMethodBind/nativemethbind02/libnativemethbind02.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/events/NativeMethodBind/nativemethbind02/libnativemethbind02.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,7 @@ extern "C" { static volatile int wrongBindEv = 0; static volatile jint result = PASSED; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jrawMonitorID counter_lock; @@ -46,7 +46,7 @@ NativeMethodBind(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread, jmethodID method, void *addr, void **new_addr) { jvmtiPhase phase; jvmtiError err; - char *methNam = NULL, *methSig = NULL; + char *methNam = nullptr, *methSig = nullptr; RawMonitorLocker rml(jvmti, jni, counter_lock); err = jvmti->GetPhase(&phase); @@ -60,7 +60,7 @@ NativeMethodBind(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread, return; } - err = jvmti->GetMethodName(method, &methNam, &methSig, NULL); + err = jvmti->GetMethodName(method, &methNam, &methSig, nullptr); if (err != JVMTI_ERROR_NONE) { result = STATUS_FAILED; @@ -70,7 +70,7 @@ NativeMethodBind(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread, LOG("NativeMethodBind received for \"%s %s\"\n", methNam, methSig); } - if (methNam != NULL) { + if (methNam != nullptr) { err = jvmti->Deallocate((unsigned char *) methNam); if (err != JVMTI_ERROR_NONE) { result = STATUS_FAILED; @@ -78,7 +78,7 @@ NativeMethodBind(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread, } } - if (methSig != NULL) { + if (methSig != nullptr) { err = jvmti->Deallocate((unsigned char *) methSig); if (err != JVMTI_ERROR_NONE) { result = STATUS_FAILED; @@ -116,7 +116,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_9); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -150,11 +150,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; LOG("setting event callbacks done\nenabling JVMTI events ...\n"); - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_NATIVE_METHOD_BIND, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_NATIVE_METHOD_BIND, nullptr); if (err != JVMTI_ERROR_NONE) { return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, nullptr); if (err != JVMTI_ERROR_NONE) { return JNI_ERR; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/NativeMethodBind/nativemethbind03/libnativemethbind03.cpp b/test/hotspot/jtreg/serviceability/jvmti/events/NativeMethodBind/nativemethbind03/libnativemethbind03.cpp index 19d94f560c8..d637f7dc713 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/NativeMethodBind/nativemethbind03/libnativemethbind03.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/events/NativeMethodBind/nativemethbind03/libnativemethbind03.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,7 @@ static const char *CLASS_SIG = "Lnativemethbind03$TestedClass;"; static volatile jint result = PASSED; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jrawMonitorID counter_lock; @@ -72,7 +72,7 @@ NativeMethodBind(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread, jmethodID method, return; } - err = jvmti->GetMethodName(method, &methNam, &methSig, NULL); + err = jvmti->GetMethodName(method, &methNam, &methSig, nullptr); if (err != JVMTI_ERROR_NONE) { result = STATUS_FAILED; COMPLAIN("TEST FAILED: unable to get method name during NativeMethodBind callback\n\n"); @@ -84,7 +84,7 @@ NativeMethodBind(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread, jmethodID method, LOG("\tmethod: \"%s %s\"\n", methNam, methSig); } - if (methNam != NULL) { + if (methNam != nullptr) { err = jvmti->Deallocate((unsigned char *) methNam); if (err != JVMTI_ERROR_NONE) { result = STATUS_FAILED; @@ -92,7 +92,7 @@ NativeMethodBind(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread, jmethodID method, } } - if (methSig != NULL) { + if (methSig != nullptr) { err = jvmti->Deallocate((unsigned char *) methSig); if (err != JVMTI_ERROR_NONE) { result = STATUS_FAILED; @@ -133,13 +133,13 @@ nativeMethod(JNIEnv *jni, jobject obj) { /* dummy method used only to provoke NativeMethodBind event */ JNIEXPORT void JNICALL Java_nativemethbind03_registerNative(JNIEnv *jni, jobject obj) { - jclass testedCls = NULL; + jclass testedCls = nullptr; JNINativeMethod meth; LOG("Inside the registerNative()\n" "Finding class \"%s\" ...\n", CLASS_SIG); testedCls = jni->FindClass(CLASS_SIG); - if (testedCls == NULL) { + if (testedCls == nullptr) { result = STATUS_FAILED; COMPLAIN("TEST FAILURE: unable to find class \"%s\"\n\n", CLASS_SIG); return; @@ -171,7 +171,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_9); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -207,11 +207,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; LOG("setting event callbacks done\nenabling JVMTI events ...\n"); - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_NATIVE_METHOD_BIND, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_NATIVE_METHOD_BIND, nullptr); if (err != JVMTI_ERROR_NONE) { return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, nullptr); if (err != JVMTI_ERROR_NONE) { return JNI_ERR; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/NativeMethodBind/nativemethbind04/libnativemethbind04.cpp b/test/hotspot/jtreg/serviceability/jvmti/events/NativeMethodBind/nativemethbind04/libnativemethbind04.cpp index 174084d0494..871028423ef 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/NativeMethodBind/nativemethbind04/libnativemethbind04.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/events/NativeMethodBind/nativemethbind04/libnativemethbind04.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ static volatile int origCalls = 0; static volatile int redirCalls = 0; static volatile jint result = PASSED; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jrawMonitorID counter_lock; @@ -84,7 +84,7 @@ NativeMethodBind(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread, jmethodID method, return; } - err = jvmti->GetMethodName(method, &methNam, &methSig, NULL); + err = jvmti->GetMethodName(method, &methNam, &methSig, nullptr); if (err != JVMTI_ERROR_NONE) { result = STATUS_FAILED; LOG("TEST FAILED: unable to get method name during NativeMethodBind callback\n\n"); @@ -97,7 +97,7 @@ NativeMethodBind(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread, jmethodID method, *new_addr = (void *) redirNativeMethod; } - if (methNam != NULL) { + if (methNam != nullptr) { err = jvmti->Deallocate((unsigned char *) methNam); if (err != JVMTI_ERROR_NONE) { result = STATUS_FAILED; @@ -105,7 +105,7 @@ NativeMethodBind(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread, jmethodID method, } } - if (methSig != NULL) { + if (methSig != nullptr) { err = jvmti->Deallocate((unsigned char *) methSig); if (err != JVMTI_ERROR_NONE) { result = STATUS_FAILED; @@ -146,7 +146,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_9); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -179,7 +179,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; LOG("setting event callbacks done\nenabling JVMTI events ...\n"); - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_NATIVE_METHOD_BIND, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_NATIVE_METHOD_BIND, nullptr); if (err != JVMTI_ERROR_NONE) { return JNI_ERR; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/SingleStep/singlestep01/libsinglestep01.cpp b/test/hotspot/jtreg/serviceability/jvmti/events/SingleStep/singlestep01/libsinglestep01.cpp index 003cc55e425..7c4d6ef2ea7 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/SingleStep/singlestep01/libsinglestep01.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/events/SingleStep/singlestep01/libsinglestep01.cpp @@ -50,7 +50,7 @@ static const char *CLASS_SIG = "Lsinglestep01;"; static volatile jint result = PASSED; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static volatile jboolean isVirtualExpected = JNI_FALSE; @@ -62,7 +62,7 @@ static void setBP(jvmtiEnv *jvmti, JNIEnv *jni, jclass klass) { jvmtiError err; mid = jni->GetMethodID(klass, METHODS[0], METHOD_SIGS[0]); - if (mid == NULL) { + if (mid == nullptr) { jni->FatalError("failed to get ID for the java method\n"); } @@ -86,7 +86,7 @@ ClassLoad(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread, jclass klass) { if (err != JVMTI_ERROR_NONE) { jni->FatalError("failed to obtain a class signature\n"); } - if (sig != NULL && (strcmp(sig, CLASS_SIG) == 0)) { + if (sig != nullptr && (strcmp(sig, CLASS_SIG) == 0)) { LOG("ClassLoad event received for the class \"%s\"\n" "\tsetting breakpoint ...\n", sig); setBP(jvmti, jni, klass); @@ -117,7 +117,7 @@ Breakpoint(jvmtiEnv *jvmti, JNIEnv *jni, jthread thr, jmethodID method, jlocatio jni->FatalError("Breakpoint: failed to obtain a class signature\n"); } - if (sig != NULL && (strcmp(sig, CLASS_SIG) == 0)) { + if (sig != nullptr && (strcmp(sig, CLASS_SIG) == 0)) { LOG("method declaring class \"%s\"\n\tenabling SingleStep events ...\n", sig); err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, thr); if (err != JVMTI_ERROR_NONE) { @@ -145,7 +145,7 @@ SingleStep(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread, jmethodID method, jloca print_thread_info(jvmti, jni, thread); - err = jvmti->GetMethodName(method, &methNam, &methSig, NULL); + err = jvmti->GetMethodName(method, &methNam, &methSig, nullptr); if (err != JVMTI_ERROR_NONE) { result = STATUS_FAILED; COMPLAIN("TEST FAILED: unable to get method name during SingleStep callback\n\n"); @@ -166,7 +166,7 @@ SingleStep(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread, jmethodID method, jloca return; } - if (sig != NULL) { + if (sig != nullptr) { LOG("\tmethod name: \"%s\"\n" "\tsignature: \"%s\"\n" "\tmethod declaring class: \"%s\"\n", @@ -244,7 +244,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -284,19 +284,19 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } LOG("setting event callbacks done\nenabling JVMTI events ...\n"); - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_START, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_START, nullptr); if (err != JVMTI_ERROR_NONE) { return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, nullptr); if (err != JVMTI_ERROR_NONE) { return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, nullptr); if (err != JVMTI_ERROR_NONE) { return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, nullptr); if (err != JVMTI_ERROR_NONE) { return JNI_ERR; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/SingleStep/singlestep02/libsinglestep02.cpp b/test/hotspot/jtreg/serviceability/jvmti/events/SingleStep/singlestep02/libsinglestep02.cpp index e80903ac243..f5437de1f3d 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/SingleStep/singlestep02/libsinglestep02.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/events/SingleStep/singlestep02/libsinglestep02.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -35,7 +35,7 @@ extern "C" { static volatile jint result = PASSED; static volatile long wrongStepEv = 0; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; /** callback functions **/ void JNICALL @@ -78,7 +78,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -113,11 +113,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } LOG("setting event callbacks done\nenabling JVMTI events ...\n"); - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, nullptr); if (err != JVMTI_ERROR_NONE) { return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, nullptr); if (err != JVMTI_ERROR_NONE) { return JNI_ERR; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/SingleStep/singlestep03/libsinglestep03.cpp b/test/hotspot/jtreg/serviceability/jvmti/events/SingleStep/singlestep03/libsinglestep03.cpp index e8455006590..51ac700efad 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/SingleStep/singlestep03/libsinglestep03.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/events/SingleStep/singlestep03/libsinglestep03.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ static const char *CLASS_SIG = "Lsinglestep03;"; static volatile jint result = PASSED; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static volatile int callbacksEnabled = JNI_FALSE; @@ -64,7 +64,7 @@ static void setBP(jvmtiEnv *jvmti, JNIEnv *jni, jclass klass) { jvmtiError err; mid = jni->GetMethodID(klass, METHODS[0][0], METHODS[0][1]); - if (mid == NULL) { + if (mid == nullptr) { jni->FatalError("failed to get ID for the java method\n"); } @@ -91,7 +91,7 @@ ClassLoad(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread, jclass klass) { jni->FatalError("failed to obtain a class signature\n"); } - if (sig != NULL && (strcmp(sig, CLASS_SIG) == 0)) { + if (sig != nullptr && (strcmp(sig, CLASS_SIG) == 0)) { LOG("ClassLoad event received for the class \"%s\"\n" "\tsetting breakpoint ...\n", sig); setBP(jvmti, jni, klass); @@ -133,7 +133,7 @@ Breakpoint(jvmtiEnv *jvmti, JNIEnv *jni, jthread thr, jmethodID method, jlocatio jni->FatalError("Breakpoint: failed to obtain a class signature\n"); } - if (sig != NULL && (strcmp(sig, CLASS_SIG) == 0)) { + if (sig != nullptr && (strcmp(sig, CLASS_SIG) == 0)) { LOG("method declaring class \"%s\"\n\tenabling SingleStep events ...\n", sig); err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, thr); if (err != JVMTI_ERROR_NONE) { @@ -159,7 +159,7 @@ SingleStep(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread, jmethodID method, jloca LOG(">>>> SingleStep event received\n"); - err = jvmti->GetMethodName(method, &methNam, &methSig, NULL); + err = jvmti->GetMethodName(method, &methNam, &methSig, nullptr); if (err != JVMTI_ERROR_NONE) { result = STATUS_FAILED; COMPLAIN("TEST FAILED: unable to get method name during SingleStep callback\n\n"); @@ -180,7 +180,7 @@ SingleStep(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread, jmethodID method, jloca return; } - if (sig != NULL) { + if (sig != nullptr) { if (stepEv[METH_NUM - 1][0] == 1) { result = STATUS_FAILED; COMPLAIN("TEST FAILED: SingleStep event received after disabling the event generation\n\n"); @@ -272,7 +272,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -310,19 +310,19 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } LOG("setting event callbacks done\nenabling JVMTI events ...\n"); - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_START, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_START, nullptr); if (err != JVMTI_ERROR_NONE) { return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, nullptr); if (err != JVMTI_ERROR_NONE) { return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, nullptr); if (err != JVMTI_ERROR_NONE) { return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, nullptr); if (err != JVMTI_ERROR_NONE) { return JNI_ERR; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/ThreadEnd/threadend01/libthreadend01.cpp b/test/hotspot/jtreg/serviceability/jvmti/events/ThreadEnd/threadend01/libthreadend01.cpp index 6cfb057902b..b39276eeb00 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/ThreadEnd/threadend01/libthreadend01.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/events/ThreadEnd/threadend01/libthreadend01.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,12 +34,12 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jint result = PASSED; static int eventsCount = 0; static int eventsExpected = 0; -static const char *prefix = NULL; +static const char *prefix = nullptr; void JNICALL ThreadEnd(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread) { jvmtiError err; @@ -54,10 +54,10 @@ void JNICALL ThreadEnd(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread) { print_thread_info(jvmti, jni, thread); - if (inf.name != NULL && strstr(inf.name, prefix) == inf.name) { + if (inf.name != nullptr && strstr(inf.name, prefix) == inf.name) { eventsCount++; snprintf(name, sizeof(name), "%s%d", prefix, eventsCount); - if (inf.name == NULL || strcmp(name, inf.name) != 0) { + if (inf.name == nullptr || strcmp(name, inf.name) != 0) { LOG("(#%d) wrong thread name: \"%s\"",eventsCount, inf.name); LOG(", expected: \"%s\"\n", name); result = STATUS_FAILED; @@ -70,7 +70,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -89,19 +89,19 @@ JNIEXPORT void JNICALL Java_threadend01_getReady(JNIEnv *jni, jclass cls, jint i, jstring name) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { LOG("JVMTI client was not properly loaded!\n"); return; } - prefix = jni->GetStringUTFChars(name, NULL); - if (prefix == NULL) { + prefix = jni->GetStringUTFChars(name, nullptr); + if (prefix == nullptr) { LOG("Failed to copy UTF-8 string!\n"); result = STATUS_FAILED; return; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_END, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_END, nullptr); if (err == JVMTI_ERROR_NONE) { eventsExpected = i; } else { @@ -112,12 +112,12 @@ Java_threadend01_getReady(JNIEnv *jni, jclass cls, jint i, jstring name) { JNIEXPORT jint JNICALL Java_threadend01_check(JNIEnv *jni, jclass cls) { - if (jvmti == NULL) { + if (jvmti == nullptr) { LOG("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } -jvmtiError err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_THREAD_END, NULL); +jvmtiError err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_THREAD_END, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("Failed to disable JVMTI_EVENT_THREAD_END: %s (%d)\n", TranslateError(err), err); result = STATUS_FAILED; diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/ThreadEnd/threadend02/libthreadend02.cpp b/test/hotspot/jtreg/serviceability/jvmti/events/ThreadEnd/threadend02/libthreadend02.cpp index 1d2cfe36de3..2ffc67d3d8e 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/ThreadEnd/threadend02/libthreadend02.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/events/ThreadEnd/threadend02/libthreadend02.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -32,7 +32,7 @@ extern "C" { /* scaffold objects */ -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; static int eventCount = 0; @@ -52,7 +52,7 @@ enableEvent(jvmtiEventMode enable, jvmtiEvent event) { LOG("disabling %s\n", TranslateEvent(event)); } - err = jvmti->SetEventNotificationMode(enable, event, NULL); + err = jvmti->SetEventNotificationMode(enable, event, nullptr); if (err != JVMTI_ERROR_NONE) { set_agent_fail_status(); return JNI_FALSE; @@ -129,7 +129,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = 60 * 1000; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -150,7 +150,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - set_agent_proc(agentProc, NULL); + set_agent_proc(agentProc, nullptr); return JNI_OK; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/ThreadStart/threadstart01/libthreadstart01.cpp b/test/hotspot/jtreg/serviceability/jvmti/events/ThreadStart/threadstart01/libthreadstart01.cpp index 935f4fc1002..2ebaf2d9f0f 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/ThreadStart/threadstart01/libthreadstart01.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/events/ThreadStart/threadstart01/libthreadstart01.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,12 +34,12 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jint result = PASSED; static int eventsCount = 0; static int eventsExpected = 0; -static const char *prefix = NULL; +static const char *prefix = nullptr; void JNICALL ThreadStart(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread) { @@ -54,7 +54,7 @@ ThreadStart(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread) { LOG(">>> %s\n", inf.name); - if (inf.name != NULL && strstr(inf.name, prefix) == inf.name) { + if (inf.name != nullptr && strstr(inf.name, prefix) == inf.name) { snprintf(name, sizeof(name), "%s%d", prefix, eventsCount); if (strcmp(name, inf.name) != 0) { LOG("(#%d) wrong thread name: \"%s\"", eventsCount, inf.name); @@ -70,7 +70,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -89,19 +89,19 @@ JNIEXPORT void JNICALL Java_threadstart01_getReady(JNIEnv *jni, jclass cls, jint i, jstring name) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { LOG("JVMTI client was not properly loaded!\n"); return; } - prefix = jni->GetStringUTFChars(name, NULL); - if (prefix == NULL) { + prefix = jni->GetStringUTFChars(name, nullptr); + if (prefix == nullptr) { LOG("Failed to copy UTF-8 string!\n"); result = STATUS_FAILED; return; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, nullptr); if (err == JVMTI_ERROR_NONE) { eventsExpected = i; } else { @@ -114,12 +114,12 @@ JNIEXPORT jint JNICALL Java_threadstart01_check(JNIEnv *jni, jclass cls) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { LOG("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } - err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_THREAD_START, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_THREAD_START, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("Failed to disable JVMTI_EVENT_THREAD_START: %s (%d)\n", TranslateError(err), err); result = STATUS_FAILED; diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/ThreadStart/threadstart02/libthreadstart02.cpp b/test/hotspot/jtreg/serviceability/jvmti/events/ThreadStart/threadstart02/libthreadstart02.cpp index e5ae8be3107..1ab67b64603 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/ThreadStart/threadstart02/libthreadstart02.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/events/ThreadStart/threadstart02/libthreadstart02.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,16 +33,16 @@ extern "C" { #define STATUS_FAILED 2 #define WAIT_TIME 20000 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; /* volatile variables */ static jrawMonitorID agent_start_lock, thr_start_lock, thr_resume_lock, thr_event_lock; -static volatile jthread agent_thread = NULL; +static volatile jthread agent_thread = nullptr; static volatile jboolean terminate_debug_agent = JNI_FALSE; static volatile jboolean debug_agent_timed_out = JNI_FALSE; static volatile jboolean debug_agent_started = JNI_FALSE; -static volatile jthread next_thread = NULL; +static volatile jthread next_thread = nullptr; static jvmtiThreadInfo inf; static volatile int eventsCount = 0; static volatile jint result = PASSED; @@ -128,12 +128,12 @@ debug_agent(jvmtiEnv *jvmti, JNIEnv *jni, void *p) { RawMonitorLocker thr_start_locker(jvmti, jni, thr_start_lock); while (terminate_debug_agent != JNI_TRUE) { - if (next_thread == NULL) { + if (next_thread == nullptr) { /* wait till new thread will be created and started */ thr_start_locker.wait(); } - if (next_thread != NULL) { + if (next_thread != nullptr) { /* hmm, why NewGlobalRef is called one more time??? * next_thread = env->NewGlobalRef(next_thread); */ @@ -160,7 +160,7 @@ debug_agent(jvmtiEnv *jvmti, JNIEnv *jni, void *p) { } jni->DeleteGlobalRef(next_thread); - next_thread = NULL; + next_thread = nullptr; /* Notify ThreadStart callback that thread has been resumed */ @@ -267,38 +267,38 @@ void JNICALL ThreadStart(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread) { } void JNICALL VMInit(jvmtiEnv *jvmti, JNIEnv *jni, jthread thr) { - jclass cls = NULL; - jmethodID mid = NULL; + jclass cls = nullptr; + jmethodID mid = nullptr; LOG(">>> VMInit event: start\n"); - check_jvmti_status(jni, jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, NULL), + check_jvmti_status(jni, jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, nullptr), "Failed to enable JVMTI_EVENT_THREAD_START"); /* Start agent thread */ cls = jni->FindClass("java/lang/Thread"); - if (cls == NULL) { + if (cls == nullptr) { result = STATUS_FAILED; COMPLAIN("TEST FAILED: Cannot start agent thread: FindClass() failed\n"); return; } mid = jni->GetMethodID(cls, "", "()V"); - if (mid == NULL) { + if (mid == nullptr) { result = STATUS_FAILED; COMPLAIN("TEST FAILED: Cannot start agent thread: GetMethodID() failed\n"); return; } agent_thread = jni->NewObject(cls, mid); - if (agent_thread == NULL) { + if (agent_thread == nullptr) { result = STATUS_FAILED; COMPLAIN("Cannot start agent thread: NewObject() failed\n"); return; } agent_thread = (jthread) jni->NewGlobalRef(agent_thread); - if (agent_thread == NULL) { + if (agent_thread == nullptr) { result = STATUS_FAILED; COMPLAIN("Cannot create global reference for agent_thread\n"); return; @@ -311,7 +311,7 @@ void JNICALL VMInit(jvmtiEnv *jvmti, JNIEnv *jni, jthread thr) { RawMonitorLocker agent_start_locker(jvmti, jni, agent_start_lock); - check_jvmti_status(jni, jvmti->RunAgentThread(agent_thread, debug_agent, NULL, JVMTI_THREAD_NORM_PRIORITY), + check_jvmti_status(jni, jvmti->RunAgentThread(agent_thread, debug_agent, nullptr, JVMTI_THREAD_NORM_PRIORITY), "Failed to RunAgentThread"); agent_start_locker.wait(); LOG(">>> VMInit event: end\n"); @@ -327,7 +327,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -366,14 +366,14 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("Failed to disable JVMTI_EVENT_THREAD_START: %s (%d)\n", TranslateError(err), err); result = STATUS_FAILED; return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("Failed to disable JVMTI_EVENT_THREAD_END: %s (%d)\n", TranslateError(err), err); result = STATUS_FAILED; diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/ThreadStart/threadstart03/libthreadstart03.cpp b/test/hotspot/jtreg/serviceability/jvmti/events/ThreadStart/threadstart03/libthreadstart03.cpp index a14fa1dbdb3..6373f8df19c 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/ThreadStart/threadstart03/libthreadstart03.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/events/ThreadStart/threadstart03/libthreadstart03.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -35,11 +35,11 @@ extern "C" { #define STATUS_FAILED 2 #define WAIT_TIME 1000 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jint result = PASSED; static jrawMonitorID wait_lock; -static const char *threadName = NULL; +static const char *threadName = nullptr; static int startsCount = 0; static int startsExpected = 0; static int endsCount = 0; @@ -57,7 +57,7 @@ void JNICALL ThreadStart(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread) { LOG(">>> start: %s\n", inf.name); - if (inf.name != NULL && strcmp(inf.name, threadName) == 0) { + if (inf.name != nullptr && strcmp(inf.name, threadName) == 0) { startsCount++; } } @@ -74,7 +74,7 @@ void JNICALL ThreadEnd(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread) { LOG(">>> end: %s\n", inf.name); - if (inf.name != NULL && strcmp(inf.name, threadName) == 0) { + if (inf.name != nullptr && strcmp(inf.name, threadName) == 0) { endsCount++; } } @@ -84,7 +84,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -110,20 +110,20 @@ JNIEXPORT jint JNICALL Java_threadstart03_check(JNIEnv *jni, jclass cls, jthread thr, jstring name) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { LOG("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } - threadName = jni->GetStringUTFChars(name, NULL); - if (threadName == NULL) { + threadName = jni->GetStringUTFChars(name, nullptr); + if (threadName == nullptr) { LOG("Failed to copy UTF-8 string!\n"); return STATUS_FAILED; } wait_lock = create_raw_monitor(jvmti, "_wait_lock"); - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, nullptr); if (err == JVMTI_ERROR_NONE) { startsExpected = 1; } else { @@ -131,7 +131,7 @@ Java_threadstart03_check(JNIEnv *jni, jclass cls, jthread thr, jstring name) { result = STATUS_FAILED; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_END, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_END, nullptr); if (err == JVMTI_ERROR_NONE) { endsExpected = 1; } else { @@ -143,7 +143,7 @@ Java_threadstart03_check(JNIEnv *jni, jclass cls, jthread thr, jstring name) { { RawMonitorLocker wait_locker(jvmti, jni, wait_lock); - err = jvmti->RunAgentThread(thr, threadProc, NULL, JVMTI_THREAD_MAX_PRIORITY); + err = jvmti->RunAgentThread(thr, threadProc, nullptr, JVMTI_THREAD_MAX_PRIORITY); if (err != JVMTI_ERROR_NONE) { LOG("(RunAgentThread) unexpected error: %s (%d)\n", TranslateError(err), err); result = STATUS_FAILED; @@ -164,13 +164,13 @@ Java_threadstart03_check(JNIEnv *jni, jclass cls, jthread thr, jstring name) { } - err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_THREAD_START, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_THREAD_START, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("Failed to disable JVMTI_EVENT_THREAD_START: %s (%d)\n", TranslateError(err), err); result = STATUS_FAILED; } - err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_THREAD_END, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_THREAD_END, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("Failed to disable JVMTI_EVENT_THREAD_END: %s (%d)\n", TranslateError(err), err); result = STATUS_FAILED; diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/VMObjectAlloc/vmobjalloc01/libvmobjalloc01.cpp b/test/hotspot/jtreg/serviceability/jvmti/events/VMObjectAlloc/vmobjalloc01/libvmobjalloc01.cpp index 24cef0250c5..46006b00ad4 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/VMObjectAlloc/vmobjalloc01/libvmobjalloc01.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/events/VMObjectAlloc/vmobjalloc01/libvmobjalloc01.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -65,10 +65,10 @@ VMObjectAlloc(jvmtiEnv *jvmti, JNIEnv* jni, jthread thread, jobject object, jcla LOG("VMObjectAlloc: \"%s\", size=%ld\n", signature, (long)size); - if (signature != NULL) + if (signature != nullptr) jvmti->Deallocate((unsigned char*)signature); - if (generic != NULL) + if (generic != nullptr) jvmti->Deallocate((unsigned char*)generic); } @@ -92,7 +92,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { } jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiCapabilities caps; jvmtiEventCallbacks callbacks; jvmtiError err; @@ -103,7 +103,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_9); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -127,12 +127,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } /* enable VMObjectAlloc event */ - if (jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_OBJECT_ALLOC, NULL) != JVMTI_ERROR_NONE) { + if (jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_OBJECT_ALLOC, nullptr) != JVMTI_ERROR_NONE) { return JNI_ERR; } /* register agent proc and arg */ - set_agent_proc(agentProc, NULL); + set_agent_proc(agentProc, nullptr); return JNI_OK; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/negative/GetAllThreadsNullTest/libGetAllThreadsNullTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/negative/GetAllThreadsNullTest/libGetAllThreadsNullTest.cpp index 2c665df4f27..1231a9e1ce1 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/negative/GetAllThreadsNullTest/libGetAllThreadsNullTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/negative/GetAllThreadsNullTest/libGetAllThreadsNullTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -28,12 +28,12 @@ extern "C" { -static jvmtiEnv *jvmti_env = NULL; +static jvmtiEnv *jvmti_env = nullptr; JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { jint res = jvm->GetEnv((void **) &jvmti_env, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti_env == NULL) { + if (res != JNI_OK || jvmti_env == nullptr) { LOG("Wrong test_passed of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -48,14 +48,14 @@ Java_GetAllThreadsNullTest_check(JNIEnv *env, jclass cls) { jthread *threadsPtr; jboolean test_passed = JNI_TRUE; - if (jvmti_env == NULL) { + if (jvmti_env == nullptr) { LOG("JVMTI client was not properly loaded!\n"); return JNI_FALSE; } LOG(">>> (threadsCountPtr) null pointer check ...\n"); - err = jvmti_env->GetAllThreads(NULL, &threadsPtr); + err = jvmti_env->GetAllThreads(nullptr, &threadsPtr); if (err != JVMTI_ERROR_NULL_POINTER) { LOG("(threadsCountPtr) error expected: JVMTI_ERROR_NULL_POINTER,\n"); LOG(" got: %s (%d)\n", TranslateError(err), err); @@ -64,14 +64,14 @@ Java_GetAllThreadsNullTest_check(JNIEnv *env, jclass cls) { LOG(">>> (threadsPtr) null pointer check ...\n"); - err = jvmti_env->GetAllThreads(&threadsCountPtr, NULL); + err = jvmti_env->GetAllThreads(&threadsCountPtr, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { LOG("(threadsPtr) error expected: JVMTI_ERROR_NULL_POINTER,\n"); LOG(" got: %s (%d)\n", TranslateError(err), err); test_passed = JNI_FALSE; } - err = jvmti_env->GetAllThreads(NULL, NULL); + err = jvmti_env->GetAllThreads(nullptr, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { LOG("(threadsPtr) error expected: JVMTI_ERROR_NULL_POINTER,\n"); LOG(" got: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/serviceability/jvmti/negative/contmon03/libcontmon03.cpp b/test/hotspot/jtreg/serviceability/jvmti/negative/contmon03/libcontmon03.cpp index 35e6f859afd..f9188a371ff 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/negative/contmon03/libcontmon03.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/negative/contmon03/libcontmon03.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, 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 @@ -32,7 +32,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; JNIEXPORT jint JNICALL @@ -42,7 +42,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { jvmtiCapabilities caps; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -64,7 +64,7 @@ Java_contmon03_check(JNIEnv *env, jclass cls, jthread thread) { jvmtiError err; jobject monitor; - if (jvmti == NULL) { + if (jvmti == nullptr) { LOG("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -80,7 +80,7 @@ Java_contmon03_check(JNIEnv *env, jclass cls, jthread thread) { LOG(">>> null pointer check ...\n"); - err = jvmti->GetCurrentContendedMonitor(thread, NULL); + err = jvmti->GetCurrentContendedMonitor(thread, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { LOG("Error expected: JVMTI_ERROR_NULL_POINTER,\n"); LOG(" got: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/serviceability/jvmti/negative/framecnt02/libframecnt02.cpp b/test/hotspot/jtreg/serviceability/jvmti/negative/framecnt02/libframecnt02.cpp index f8d76a2f882..0b4286991f7 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/negative/framecnt02/libframecnt02.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/negative/framecnt02/libframecnt02.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -32,7 +32,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; JNIEXPORT jint JNICALL @@ -40,7 +40,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } @@ -54,7 +54,7 @@ Java_framecnt02_checkFrames(JNIEnv *env, jclass cls, jthread thr, jint thr_num) jint frameCount; if (thr_num == 0) { - err = jvmti->GetFrameCount(thr, NULL); + err = jvmti->GetFrameCount(thr, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { LOG("Error expected: JVMTI_ERROR_NULL_POINTER, got: %s (%d)\n", TranslateError(err), err); result = STATUS_FAILED; diff --git a/test/hotspot/jtreg/serviceability/jvmti/negative/framecnt03/libframecnt03.cpp b/test/hotspot/jtreg/serviceability/jvmti/negative/framecnt03/libframecnt03.cpp index 74769bb29f5..b72c7b87ab1 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/negative/framecnt03/libframecnt03.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/negative/framecnt03/libframecnt03.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -32,7 +32,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; JNIEXPORT jint JNICALL @@ -40,7 +40,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -53,7 +53,7 @@ Java_framecnt03_check(JNIEnv *env, jclass cls) { jvmtiError err; jint countPtr; - if (jvmti == NULL) { + if (jvmti == nullptr) { LOG("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/negative/frameloc03/libframeloc03.cpp b/test/hotspot/jtreg/serviceability/jvmti/negative/frameloc03/libframeloc03.cpp index 631ad8d383f..b763d0433ee 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/negative/frameloc03/libframeloc03.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/negative/frameloc03/libframeloc03.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -32,7 +32,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -43,12 +43,12 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -84,7 +84,7 @@ Java_frameloc03_check(JNIEnv *env, jclass cls, jthread thr) { jmethodID mid; jlocation loc; - if (jvmti == NULL) { + if (jvmti == nullptr) { LOG("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -123,7 +123,7 @@ Java_frameloc03_check(JNIEnv *env, jclass cls, jthread thr) { if (printdump == JNI_TRUE) { LOG(">>> (methodPtr) null pointer check ...\n"); } - err = jvmti->GetFrameLocation(thr, 0, NULL, &loc); + err = jvmti->GetFrameLocation(thr, 0, nullptr, &loc); if (err != JVMTI_ERROR_NULL_POINTER) { LOG("Error expected: JVMTI_ERROR_NULL_POINTER,\n"); LOG(" actual: %s (%d)\n", TranslateError(err), err); @@ -133,7 +133,7 @@ Java_frameloc03_check(JNIEnv *env, jclass cls, jthread thr) { if (printdump == JNI_TRUE) { LOG(">>> (locationPtr) null pointer check ...\n"); } - err = jvmti->GetFrameLocation(thr, 0, &mid, NULL); + err = jvmti->GetFrameLocation(thr, 0, &mid, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { LOG("Error expected: JVMTI_ERROR_NULL_POINTER,\n"); LOG(" actual: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/serviceability/jvmti/negative/getstacktr02/libgetstacktr02.cpp b/test/hotspot/jtreg/serviceability/jvmti/negative/getstacktr02/libgetstacktr02.cpp index 061b717af37..b12b322bba4 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/negative/getstacktr02/libgetstacktr02.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/negative/getstacktr02/libgetstacktr02.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -32,7 +32,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -40,12 +40,12 @@ JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -59,7 +59,7 @@ Java_getstacktr02_check(JNIEnv *env, jclass cls, jthread thread) { jvmtiFrameInfo frame; jint count; - if (jvmti == NULL) { + if (jvmti == nullptr) { LOG("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -85,7 +85,7 @@ Java_getstacktr02_check(JNIEnv *env, jclass cls, jthread thread) { if (printdump == JNI_TRUE) { LOG(">>> (stack_buffer) null pointer check ...\n"); } - err = jvmti->GetStackTrace(thread, 0, 1, NULL, &count); + err = jvmti->GetStackTrace(thread, 0, 1, nullptr, &count); if (err != JVMTI_ERROR_NULL_POINTER) { LOG("(stack_buffer) error expected: JVMTI_ERROR_NULL_POINTER,"); LOG(" got: %s (%d)\n", TranslateError(err), err); @@ -95,7 +95,7 @@ Java_getstacktr02_check(JNIEnv *env, jclass cls, jthread thread) { if (printdump == JNI_TRUE) { LOG(">>> (count_ptr) null pointer check ...\n"); } - err = jvmti->GetStackTrace(thread, 0, 1, &frame, NULL); + err = jvmti->GetStackTrace(thread, 0, 1, &frame, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { LOG("(count_ptr) error expected: JVMTI_ERROR_NULL_POINTER,"); LOG(" got: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/serviceability/jvmti/negative/getstacktr09/libgetstacktr09.cpp b/test/hotspot/jtreg/serviceability/jvmti/negative/getstacktr09/libgetstacktr09.cpp index f9b6e4dd077..bdac7128c3b 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/negative/getstacktr09/libgetstacktr09.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/negative/getstacktr09/libgetstacktr09.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -32,7 +32,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -40,12 +40,12 @@ JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -59,7 +59,7 @@ Java_getstacktr09_check(JNIEnv *env, jclass cls, jthread thread1, jthread thread jvmtiFrameInfo frame; jint count; - if (jvmti == NULL) { + if (jvmti == nullptr) { LOG("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/negative/thrinfo02/libthrinfo02.cpp b/test/hotspot/jtreg/serviceability/jvmti/negative/thrinfo02/libthrinfo02.cpp index 8c47aaa7f4b..6ab0c456704 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/negative/thrinfo02/libthrinfo02.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/negative/thrinfo02/libthrinfo02.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -32,7 +32,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -40,12 +40,12 @@ JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -58,7 +58,7 @@ Java_thrinfo02_check(JNIEnv *env, jclass cls, jthread thr, jthreadGroup group) { jvmtiError err; jvmtiThreadInfo inf; - if (jvmti == NULL) { + if (jvmti == nullptr) { LOG("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -66,14 +66,14 @@ Java_thrinfo02_check(JNIEnv *env, jclass cls, jthread thr, jthreadGroup group) { if (printdump == JNI_TRUE) { LOG(">>> invalid thread check ...\n"); } - err = jvmti->GetThreadInfo(NULL, &inf); + err = jvmti->GetThreadInfo(nullptr, &inf); if (err != JVMTI_ERROR_NONE) { LOG("Error expected: JVMTI_ERROR_NONE,\n"); LOG(" got: %s (%d)\n", TranslateError(err), err); result = STATUS_FAILED; } - if (inf.name == NULL || strcmp(inf.name, "main")) { + if (inf.name == nullptr || strcmp(inf.name, "main")) { LOG("Thread %s: incorrect name: %s\n", "main", inf.name); result = STATUS_FAILED; } @@ -93,7 +93,7 @@ Java_thrinfo02_check(JNIEnv *env, jclass cls, jthread thr, jthreadGroup group) { if (printdump == JNI_TRUE) { LOG(">>> null pointer check ...\n"); } - err = jvmti->GetThreadInfo(thr, NULL); + err = jvmti->GetThreadInfo(thr, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { LOG("Error expected: JVMTI_ERROR_NULL_POINTER,\n"); LOG(" got: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/serviceability/jvmti/negative/thrstat04/libthrstat04.cpp b/test/hotspot/jtreg/serviceability/jvmti/negative/thrstat04/libthrstat04.cpp index 05baab36d51..b63e84d0c49 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/negative/thrstat04/libthrstat04.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/negative/thrstat04/libthrstat04.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -32,7 +32,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -40,12 +40,12 @@ JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -58,7 +58,7 @@ Java_thrstat04_check(JNIEnv *env, jclass cls, jthread thr) { jvmtiError err; jint thrState; - if (jvmti == NULL) { + if (jvmti == nullptr) { LOG("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -66,7 +66,7 @@ Java_thrstat04_check(JNIEnv *env, jclass cls, jthread thr) { if (printdump == JNI_TRUE) { LOG(">>> (threadStatePtr) null pointer check ...\n"); } - err = jvmti->GetThreadState(thr, NULL); + err = jvmti->GetThreadState(thr, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { LOG("(threadStatePtr) error expected: JVMTI_ERROR_NULL_POINTER,\n"); LOG(" got: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/serviceability/jvmti/stress/StackTrace/NotSuspended/libGetStackTraceNotSuspendedStress.cpp b/test/hotspot/jtreg/serviceability/jvmti/stress/StackTrace/NotSuspended/libGetStackTraceNotSuspendedStress.cpp index 12e685b3714..ee2dc9d2859 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/stress/StackTrace/NotSuspended/libGetStackTraceNotSuspendedStress.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/stress/StackTrace/NotSuspended/libGetStackTraceNotSuspendedStress.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ const char CONTINUATION_METHOD_NAME[] = "enter"; static void test_stack_trace(jvmtiEnv *jvmti, JNIEnv *jni, jthread vthread) { jvmtiFrameInfo frames[MAX_FRAME_COUNT]; jint count = -1; - jmethodID method = NULL; + jmethodID method = nullptr; jvmtiError err; err = jvmti->GetStackTrace(vthread, 0, MAX_FRAME_COUNT, frames, &count); @@ -78,7 +78,7 @@ agentProc(jvmtiEnv * jvmti, JNIEnv * jni, void * arg) { LOG("Agent: started\n"); while (true) { - jthread *threads = NULL; + jthread *threads = nullptr; jint count = 0; jvmtiError err; @@ -90,7 +90,7 @@ agentProc(jvmtiEnv * jvmti, JNIEnv * jni, void * arg) { } check_jvmti_status(jni, err, "Error in JVMTI GetAllThreads"); for (int i = 0; i < count; i++) { - jthread tested_thread = NULL; + jthread tested_thread = nullptr; err = GetVirtualThread(jvmti, jni, threads[i], &tested_thread); if (err == JVMTI_ERROR_THREAD_NOT_ALIVE) { @@ -100,7 +100,7 @@ agentProc(jvmtiEnv * jvmti, JNIEnv * jni, void * arg) { return; } check_jvmti_status(jni, err, "Error in JVMTI extension GetVirtualThread"); - if (tested_thread != NULL) { + if (tested_thread != nullptr) { test_stack_trace(jvmti, jni, tested_thread); } } @@ -132,7 +132,7 @@ extern JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *res return JNI_ERR; } - if (set_agent_proc(agentProc, NULL) != JNI_TRUE) { + if (set_agent_proc(agentProc, nullptr) != JNI_TRUE) { return JNI_ERR; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/stress/StackTrace/Suspended/libGetStackTraceSuspendedStress.cpp b/test/hotspot/jtreg/serviceability/jvmti/stress/StackTrace/Suspended/libGetStackTraceSuspendedStress.cpp index 65e79fb33f2..639b40d4839 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/stress/StackTrace/Suspended/libGetStackTraceSuspendedStress.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/stress/StackTrace/Suspended/libGetStackTraceSuspendedStress.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, 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,13 +31,13 @@ static const char CONTINUATION_CLASS_NAME[] = "jdk/internal/vm/Continuation"; static const char CONTINUATION_METHOD_NAME[] = "enter"; -static jrawMonitorID event_mon = NULL; +static jrawMonitorID event_mon = nullptr; static void test_stack_trace(jvmtiEnv *jvmti, JNIEnv *jni, jthread vthread) { jvmtiFrameInfo frames[MAX_FRAME_COUNT]; jint count = -1; - jmethodID method = NULL; + jmethodID method = nullptr; jvmtiError err; err = jvmti->GetStackTrace(vthread, 0, MAX_FRAME_COUNT, frames, &count); @@ -93,7 +93,7 @@ check_link_consistency(jvmtiEnv *jvmti, JNIEnv *jni, jthread vthread) { fatal(jni, "Carrier thread is NOT expected to be suspended"); } - if (cthread != NULL) { + if (cthread != nullptr) { jthread cthread_to_vthread = get_virtual_thread(jvmti, jni, cthread); if (!jni->IsSameObject(vthread, cthread_to_vthread)) { @@ -118,12 +118,12 @@ check_vthread_consistency_suspended(jvmtiEnv *jvmti, JNIEnv *jni, jthread vthrea jni->FatalError("Agent: check_vthread_consistency_suspended: vthread is expected to be virtual"); } jthread cthread = get_carrier_thread(jvmti, jni, vthread); - //const char* cname = (cthread == NULL) ? "" : get_thread_name(jvmti, jni, cthread); + //const char* cname = (cthread == nullptr) ? "" : get_thread_name(jvmti, jni, cthread); err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, vthread); check_jvmti_status(jni, err, "Error in JVMTI SetEventNotificationMode: enable SINGLE_STEP"); - if (cthread != NULL) { // pre-condition for reliable testing + if (cthread != nullptr) { // pre-condition for reliable testing test_stack_trace(jvmti, jni, vthread); check_link_consistency(jvmti, jni, vthread); } @@ -145,7 +145,7 @@ SingleStep(jvmtiEnv *jvmti, JNIEnv* jni, jthread thread, print_stack_trace(jvmti, jni, thread); jthread cthread = get_carrier_thread(jvmti, jni, thread); - if (cthread != NULL) { + if (cthread != nullptr) { print_stack_trace(jvmti, jni, cthread); } @@ -170,7 +170,7 @@ agentProc(jvmtiEnv * jvmti, JNIEnv * jni, void * arg) { int iter = 0; while (true) { - jthread *threads = NULL; + jthread *threads = nullptr; jint count = 0; jvmtiError err; @@ -182,7 +182,7 @@ agentProc(jvmtiEnv * jvmti, JNIEnv * jni, void * arg) { for (int i = 0; i < count; i++) { jthread cthread = threads[i]; - jthread vthread = NULL; + jthread vthread = nullptr; err = GetVirtualThread(jvmti, jni, cthread, &vthread); if (err == JVMTI_ERROR_THREAD_NOT_ALIVE) { @@ -192,7 +192,7 @@ agentProc(jvmtiEnv * jvmti, JNIEnv * jni, void * arg) { return; } check_jvmti_status(jni, err, "Error in GetVirtualThread"); - if (iter > 50 && vthread != NULL) { + if (iter > 50 && vthread != nullptr) { // char* cname = get_thread_name(jvmti, jni, cthread); // char* vname = get_thread_name(jvmti, jni, vthread); @@ -256,7 +256,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (set_agent_proc(agentProc, NULL) != JNI_TRUE) { + if (set_agent_proc(agentProc, nullptr) != JNI_TRUE) { return JNI_ERR; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/stress/ThreadLocalStorage/SetGetThreadLocalStorageStressTest/libSetGetThreadLocalStorageStress.cpp b/test/hotspot/jtreg/serviceability/jvmti/stress/ThreadLocalStorage/SetGetThreadLocalStorageStressTest/libSetGetThreadLocalStorageStress.cpp index 43ddccc84a4..1c09fac92ba 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/stress/ThreadLocalStorage/SetGetThreadLocalStorageStressTest/libSetGetThreadLocalStorageStress.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/stress/ThreadLocalStorage/SetGetThreadLocalStorageStressTest/libSetGetThreadLocalStorageStress.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, 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 @@ -48,15 +48,15 @@ StorageStructure* check_tls(jvmtiEnv * jvmti, JNIEnv * jni, jthread thread, cons jvmtiError err = jvmti->GetThreadLocalStorage(thread, (void **) &storage); if (err == JVMTI_ERROR_THREAD_NOT_ALIVE) { - return NULL; + return nullptr; } check_jvmti_status(jni, err, "Error in GetThreadLocalStorage"); LOG("Check %s with %p in %s\n", thread_info.name, storage, source); - if (storage == NULL) { + if (storage == nullptr) { // Might be not set - return NULL; + return nullptr; } if (storage->self_pointer != storage || (strcmp(thread_info.name, storage->data) != 0)) { @@ -71,12 +71,12 @@ StorageStructure* check_tls(jvmtiEnv * jvmti, JNIEnv * jni, jthread thread, cons void check_delete_tls(jvmtiEnv * jvmti, JNIEnv * jni, jthread thread, const char* source) { StorageStructure *storage = check_tls(jvmti, jni, thread, source); - if (storage == NULL) { + if (storage == nullptr) { return; } check_jvmti_status(jni, jvmti->Deallocate((unsigned char *)storage), "Deallocation failed."); - jvmtiError err = jvmti->SetThreadLocalStorage(thread, NULL); + jvmtiError err = jvmti->SetThreadLocalStorage(thread, nullptr); if (err == JVMTI_ERROR_THREAD_NOT_ALIVE) { return; } @@ -125,7 +125,7 @@ agentProc(jvmtiEnv * jvmti, JNIEnv * jni, void * arg) { LOG("Started.....\n"); while (true) { - jthread *threads = NULL; + jthread *threads = nullptr; jint count = 0; sleep_ms(10); @@ -136,7 +136,7 @@ agentProc(jvmtiEnv * jvmti, JNIEnv * jni, void * arg) { } check_jvmti_status(jni, jvmti->GetAllThreads(&count, &threads), "Error in GetAllThreads"); for (int i = 0; i < count; i++) { - jthread testedThread = NULL; + jthread testedThread = nullptr; jvmtiError err; err = GetVirtualThread(jvmti, jni, threads[i], &testedThread); @@ -145,7 +145,7 @@ agentProc(jvmtiEnv * jvmti, JNIEnv * jni, void * arg) { } check_jvmti_status(jni, err, "Error in GetVirtualThread"); - if (testedThread == NULL) { + if (testedThread == nullptr) { testedThread = threads[i]; continue; } @@ -205,7 +205,7 @@ VirtualThreadEnd(jvmtiEnv *jvmti, JNIEnv *jni, jthread vthread) { JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv * jvmti = NULL; + jvmtiEnv * jvmti = nullptr; jvmtiEventCallbacks callbacks; jvmtiCapabilities caps; @@ -213,7 +213,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -250,19 +250,19 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { if (err != JVMTI_ERROR_NONE) { return JNI_ERR; } - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL); - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL); - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, NULL); - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_END, NULL); - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VIRTUAL_THREAD_START, NULL); - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VIRTUAL_THREAD_END, NULL); + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, nullptr); + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, nullptr); + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, nullptr); + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_END, nullptr); + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VIRTUAL_THREAD_START, nullptr); + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VIRTUAL_THREAD_END, nullptr); err = init_agent_data(jvmti, &agent_data); if (err != JVMTI_ERROR_NONE) { return JNI_ERR; } - if (set_agent_proc(agentProc, NULL) != JNI_TRUE) { + if (set_agent_proc(agentProc, nullptr) != JNI_TRUE) { return JNI_ERR; } return JNI_OK; diff --git a/test/hotspot/jtreg/serviceability/jvmti/thread/GetAllThreads/allthr01/allthr01.java b/test/hotspot/jtreg/serviceability/jvmti/thread/GetAllThreads/allthr01/allthr01.java index 29f4b176b52..b9b3f76df3c 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/thread/GetAllThreads/allthr01/allthr01.java +++ b/test/hotspot/jtreg/serviceability/jvmti/thread/GetAllThreads/allthr01/allthr01.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ * @requires vm.continuations * @library /test/lib * @compile allthr01.java - * @run main/othervm/native -Djava.util.concurrent.ForkJoinPool.common.parallelism=1 -agentlib:allthr01 allthr01 + * @run main/othervm/native -Djdk.virtualThreadScheduler.maxPoolSize=1 -agentlib:allthr01 allthr01 */ import java.util.concurrent.atomic.AtomicBoolean; diff --git a/test/hotspot/jtreg/serviceability/jvmti/thread/GetAllThreads/allthr01/liballthr01.cpp b/test/hotspot/jtreg/serviceability/jvmti/thread/GetAllThreads/allthr01/liballthr01.cpp index 1b3079c6e30..442913b4ea2 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/thread/GetAllThreads/allthr01/liballthr01.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/thread/GetAllThreads/allthr01/liballthr01.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,7 @@ static jrawMonitorID stopping_agent_thread_lock; static const char main_name[] = "main"; static const char thread1_name[] = "thread1"; static const char sys_thread_name[] = "SysThread"; -// Tes uses -Djava.util.concurrent.ForkJoinPool.common.parallelism=1 +// Test uses -Djdk.virtualThreadScheduler.maxPoolSize=1 // to make name of carrier thread deterministic static const char fj_thread_name[] = "ForkJoinPool-1-worker-1"; @@ -93,7 +93,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti_env, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti_env == NULL) { + if (res != JNI_OK || jvmti_env == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -162,7 +162,7 @@ JNIEXPORT void Java_allthr01_startAgentThread(JNIEnv *jni) { RawMonitorLocker rml1 = RawMonitorLocker(jvmti_env, jni, starting_agent_thread_lock); jvmtiError err = jvmti_env->RunAgentThread(create_jthread(jni), - sys_thread, NULL,JVMTI_THREAD_NORM_PRIORITY); + sys_thread, nullptr,JVMTI_THREAD_NORM_PRIORITY); check_jvmti_status(jni, err, "Failed to run AgentThread"); rml1.wait(); LOG("Started Agent Thread\n"); diff --git a/test/hotspot/jtreg/serviceability/jvmti/thread/GetCurrentContendedMonitor/contmon01/libcontmon01.cpp b/test/hotspot/jtreg/serviceability/jvmti/thread/GetCurrentContendedMonitor/contmon01/libcontmon01.cpp index 4e9ef9a9c91..e3d95e113a0 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/thread/GetCurrentContendedMonitor/contmon01/libcontmon01.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/thread/GetCurrentContendedMonitor/contmon01/libcontmon01.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, 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 @@ -29,13 +29,13 @@ extern "C" { -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { jint res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } @@ -54,7 +54,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { JNIEXPORT void JNICALL Java_contmon01_checkMonitor(JNIEnv *jni, jclass cls, jint point, jthread thread, jobject lock) { - jobject monitor = NULL; + jobject monitor = nullptr; jvmtiError err = jvmti->GetCurrentContendedMonitor(thread, &monitor); if (err == JVMTI_ERROR_THREAD_NOT_ALIVE && point == 5) { diff --git a/test/hotspot/jtreg/serviceability/jvmti/thread/GetCurrentContendedMonitor/contmon02/libcontmon02.cpp b/test/hotspot/jtreg/serviceability/jvmti/thread/GetCurrentContendedMonitor/contmon02/libcontmon02.cpp index dbbc63c57cd..65a2211a004 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/thread/GetCurrentContendedMonitor/contmon02/libcontmon02.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/thread/GetCurrentContendedMonitor/contmon02/libcontmon02.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { jint res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } @@ -56,7 +56,7 @@ Java_contmon02_checkMonitor(JNIEnv *jni, jclass cls, jint point, jthread thread) jobject monitor; jvmtiError err = jvmti->GetCurrentContendedMonitor(thread, &monitor); check_jvmti_status(jni, err, "Error in GetCurrentContendedMonitor"); - if (monitor != NULL) { + if (monitor != nullptr) { LOG("(#%d) unexpected monitor object: 0x%p\n", point, monitor); fatal(jni, "GetCurrentContendedMonitor return unexpected monitor."); } diff --git a/test/hotspot/jtreg/serviceability/jvmti/thread/GetFrameCount/framecnt01/libframecnt01.cpp b/test/hotspot/jtreg/serviceability/jvmti/thread/GetFrameCount/framecnt01/libframecnt01.cpp index fc5319fa9c7..c9dd399138a 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/thread/GetFrameCount/framecnt01/libframecnt01.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/thread/GetFrameCount/framecnt01/libframecnt01.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -27,7 +27,7 @@ extern "C" { -static jvmtiEnv *jvmti_env = NULL; +static jvmtiEnv *jvmti_env = nullptr; JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { @@ -35,7 +35,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti_env, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti_env == NULL) { + if (res != JNI_OK || jvmti_env == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/thread/GetFrameLocation/frameloc01/libframeloc01.cpp b/test/hotspot/jtreg/serviceability/jvmti/thread/GetFrameLocation/frameloc01/libframeloc01.cpp index bc4a81e8ab1..89855a8d66e 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/thread/GetFrameLocation/frameloc01/libframeloc01.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/thread/GetFrameLocation/frameloc01/libframeloc01.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti_env = NULL; +static jvmtiEnv *jvmti_env = nullptr; static jint result = PASSED; static jmethodID mid1; @@ -40,7 +40,7 @@ static jmethodID mid1; jboolean checkFrame(jvmtiEnv *jvmti_env, JNIEnv *jni, jthread thr, jmethodID exp_mid, jlocation exp_loc, jlocation exp_loc_alternative, jboolean mustPass) { jvmtiError err; - jmethodID mid = NULL; + jmethodID mid = nullptr; jlocation loc = -1; char *meth, *sig, *generic; jboolean isOk = JNI_FALSE; @@ -88,7 +88,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res = jvm->GetEnv((void **) &jvmti_env, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti_env == NULL) { + if (res != JNI_OK || jvmti_env == nullptr) { LOG("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } @@ -115,13 +115,13 @@ JNIEXPORT void JNICALL Java_frameloc01_getReady(JNIEnv *jni, jclass cls, jclass klass) { jvmtiError err; mid1 = jni->GetMethodID(klass, "meth01", "(I)V"); - if (mid1 == NULL) { + if (mid1 == nullptr) { LOG("Cannot get jmethodID for method \"meth01\"\n"); result = STATUS_FAILED; return; } - err = jvmti_env->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION_CATCH, NULL); + err = jvmti_env->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION_CATCH, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("(SetEventNotificationMode) unexpected error: %s (%d)\n", TranslateError(err), err); result = STATUS_FAILED; @@ -134,7 +134,7 @@ Java_frameloc01_checkFrame01(JNIEnv *jni, jclass cls, jthread thr, jclass klass, jboolean isOk = JNI_FALSE; mid = jni->GetMethodID(klass, "run", "()V"); - if (mid == NULL) { + if (mid == nullptr) { LOG("Cannot get jmethodID for method \"run\"\n"); result = STATUS_FAILED; return JNI_TRUE; diff --git a/test/hotspot/jtreg/serviceability/jvmti/thread/GetFrameLocation/frameloc02/libframeloc02.cpp b/test/hotspot/jtreg/serviceability/jvmti/thread/GetFrameLocation/frameloc02/libframeloc02.cpp index 46724b12e9f..53e9378fc8d 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/thread/GetFrameLocation/frameloc02/libframeloc02.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/thread/GetFrameLocation/frameloc02/libframeloc02.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ typedef struct { jlocation loc; } frame_info; -static jvmtiEnv *jvmti_env = NULL; +static jvmtiEnv *jvmti_env = nullptr; static jint result = PASSED; static frame_info fi = {"Lframeloc02;", "check", @@ -47,7 +47,7 @@ static frame_info fi = JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { jint res = jvm->GetEnv((void **) &jvmti_env, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti_env == NULL) { + if (res != JNI_OK || jvmti_env == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -98,17 +98,17 @@ Java_frameloc02_check(JNIEnv *env, jclass cls, jthread thr) { LOG(">>> method: \"%s%s\"\n", name, sig); LOG(">>> location: %s\n", jlong_to_string(loc, buffer)); - if (cls_sig == NULL || strcmp(cls_sig, fi.cls_sig) != 0) { + if (cls_sig == nullptr || strcmp(cls_sig, fi.cls_sig) != 0) { LOG("(GetFrameLocation) wrong class: \"%s\"\n", cls_sig); LOG(", expected: \"%s\"\n", fi.cls_sig); result = STATUS_FAILED; } - if (name == NULL || strcmp(name, fi.name) != 0) { + if (name == nullptr || strcmp(name, fi.name) != 0) { LOG("(GetFrameLocation) wrong method name: \"%s\"", name); LOG(", expected: \"%s\"\n", fi.name); result = STATUS_FAILED; } - if (sig == NULL || strcmp(sig, fi.sig) != 0) { + if (sig == nullptr || strcmp(sig, fi.sig) != 0) { LOG("(GetFrameLocation) wrong method signature: \"%s\"", sig); LOG(", expected: \"%s\"\n", fi.sig); result = STATUS_FAILED; diff --git a/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/GetStackTraceAndRetransformTest/libGetStackTraceAndRetransformTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/GetStackTraceAndRetransformTest/libGetStackTraceAndRetransformTest.cpp index 3be6dcf824f..eea96df83f7 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/GetStackTraceAndRetransformTest/libGetStackTraceAndRetransformTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/GetStackTraceAndRetransformTest/libGetStackTraceAndRetransformTest.cpp @@ -25,19 +25,19 @@ #include #include "jvmti.h" #include "jvmti_common.h" -#include "../get_stack_trace.h" +#include "../get_stack_trace.hpp" extern "C" { -static jvmtiEnv *jvmti = NULL; -static jmethodID* ids = NULL; +static jvmtiEnv *jvmti = nullptr; +static jmethodID* ids = nullptr; static int ids_size = 0; JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { jint res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -71,11 +71,11 @@ Java_GetStackTraceAndRetransformTest_check(JNIEnv *jni, jclass cls, jint expecte exit(2); } for (int i = 0; i < ids_size; i++) { - jclass rslt = NULL; - char* class_name = NULL; + jclass rslt = nullptr; + char* class_name = nullptr; jvmti->GetMethodDeclaringClass(ids[i], &rslt); - if (rslt != NULL) { - jvmti->GetClassSignature(rslt, &class_name, NULL); + if (rslt != nullptr) { + jvmti->GetClassSignature(rslt, &class_name, nullptr); } } } diff --git a/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/GetStackTraceCurrentThreadTest/libGetStackTraceCurrentThreadTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/GetStackTraceCurrentThreadTest/libGetStackTraceCurrentThreadTest.cpp index deb494dd0aa..17e721a151e 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/GetStackTraceCurrentThreadTest/libGetStackTraceCurrentThreadTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/GetStackTraceCurrentThreadTest/libGetStackTraceCurrentThreadTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -25,12 +25,12 @@ #include #include "jvmti.h" #include "jvmti_common.h" -#include "../get_stack_trace.h" +#include "../get_stack_trace.hpp" extern "C" { -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static frame_info expected_virtual_frames[] = { {"LGetStackTraceCurrentThreadTest;", "check", "(Ljava/lang/Thread;)V"}, {"LGetStackTraceCurrentThreadTest;", "dummy", "()V"}, @@ -52,7 +52,7 @@ static frame_info expected_platform_frames[] = { JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { jint res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/get_stack_trace.h b/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/get_stack_trace.hpp similarity index 90% rename from test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/get_stack_trace.h rename to test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/get_stack_trace.hpp index 788d3dd123c..d7c85704275 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/get_stack_trace.h +++ b/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/get_stack_trace.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -21,8 +21,8 @@ * questions. */ -#ifndef GET_STACK_TRACE_H -#define GET_STACK_TRACE_H +#ifndef GET_STACK_TRACE_HPP +#define GET_STACK_TRACE_HPP #include "jvmti.h" typedef struct { @@ -81,18 +81,18 @@ int compare_stack_trace(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread, lambda_idx = lambda - expected_frames[exp_idx].cls; printf("Comparing only first %zu chars in classname.\n", lambda_idx); } - if (class_signature == NULL || strncmp(class_signature, expected_frames[exp_idx].cls, lambda_idx) != 0) { + if (class_signature == nullptr || strncmp(class_signature, expected_frames[exp_idx].cls, lambda_idx) != 0) { printf("(frame#%d) wrong class sig: \"%s\", expected: \"%s\"\n", exp_idx, class_signature, expected_frames[exp_idx].cls); result = JNI_FALSE; } - if (name == NULL || strcmp(name, expected_frames[exp_idx].name) != 0) { + if (name == nullptr || strcmp(name, expected_frames[exp_idx].name) != 0) { printf("(frame#%d) wrong method name: \"%s\", expected: \"%s\"\n", exp_idx, name, expected_frames[exp_idx].name); result = JNI_FALSE; } - if (sig == NULL || strcmp(sig, expected_frames[exp_idx].sig) != 0) { + if (sig == nullptr || strcmp(sig, expected_frames[exp_idx].sig) != 0) { printf("(frame#%d) wrong method sig: \"%s\", expected: \"%s\"\n", exp_idx, sig, expected_frames[exp_idx].sig); result = JNI_FALSE; @@ -103,4 +103,4 @@ int compare_stack_trace(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread, } -#endif //GET_STACK_TRACE_H +#endif //GET_STACK_TRACE_HPP diff --git a/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/getstacktr03/libgetstacktr03.cpp b/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/getstacktr03/libgetstacktr03.cpp index dc4d75be86f..51c6f5dc4c4 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/getstacktr03/libgetstacktr03.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/getstacktr03/libgetstacktr03.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -25,11 +25,11 @@ #include #include "jvmti.h" #include "jvmti_common.h" -#include "../get_stack_trace.h" +#include "../get_stack_trace.hpp" extern "C" { -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static frame_info expected_platform_frames[] = { {"Ljava/lang/Object;", "wait", "()V"}, {"Lgetstacktr03;", "dummy", "()V"}, @@ -55,7 +55,7 @@ JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/getstacktr04/libgetstacktr04.cpp b/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/getstacktr04/libgetstacktr04.cpp index 873522ab531..0cdbb7d0271 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/getstacktr04/libgetstacktr04.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/getstacktr04/libgetstacktr04.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -25,11 +25,11 @@ #include #include "jvmti.h" #include "jvmti_common.h" -#include "../get_stack_trace.h" +#include "../get_stack_trace.hpp" extern "C" { -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jmethodID mid; static frame_info expected_platform_frames[] = { {"Lgetstacktr04$TestThread;", "checkPoint", "()V"}, @@ -80,7 +80,7 @@ JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -108,12 +108,12 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { JNIEXPORT void JNICALL Java_getstacktr04_getReady(JNIEnv *jni, jclass cls, jclass clazz) { mid = jni->GetMethodID(clazz, "checkPoint", "()V"); - if (mid == NULL) { + if (mid == nullptr) { jni->FatalError("Cannot find Method ID for method checkPoint\n"); } check_jvmti_status(jni, jvmti->SetBreakpoint(mid, 0), "SetBreakpoint failed."); - set_event_notification_mode(jvmti, jni, JVMTI_ENABLE,JVMTI_EVENT_BREAKPOINT, NULL); + set_event_notification_mode(jvmti, jni, JVMTI_ENABLE,JVMTI_EVENT_BREAKPOINT, nullptr); } } diff --git a/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/getstacktr05/libgetstacktr05.cpp b/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/getstacktr05/libgetstacktr05.cpp index 0cb2992b646..19c6eb3967e 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/getstacktr05/libgetstacktr05.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/getstacktr05/libgetstacktr05.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -25,11 +25,11 @@ #include #include "jvmti.h" #include "jvmti_common.h" -#include "../get_stack_trace.h" +#include "../get_stack_trace.hpp" extern "C" { -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; static jmethodID mid; @@ -102,7 +102,7 @@ JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -132,11 +132,11 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { JNIEXPORT void JNICALL Java_getstacktr05_getReady(JNIEnv *jni, jclass cls, jclass clazz) { mid = jni->GetMethodID(clazz, "checkPoint", "()V"); - if (mid == NULL) { + if (mid == nullptr) { jni->FatalError("Cannot find Method ID for method checkPoint\n"); } check_jvmti_status(jni, jvmti->SetBreakpoint(mid, 0), "SetBreakpoint failed."); - set_event_notification_mode(jvmti, jni, JVMTI_ENABLE,JVMTI_EVENT_BREAKPOINT, NULL); + set_event_notification_mode(jvmti, jni, JVMTI_ENABLE,JVMTI_EVENT_BREAKPOINT, nullptr); } } diff --git a/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/getstacktr06/libgetstacktr06.cpp b/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/getstacktr06/libgetstacktr06.cpp index 0fd52c697f4..f0f17d50b17 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/getstacktr06/libgetstacktr06.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/getstacktr06/libgetstacktr06.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -25,7 +25,7 @@ #include #include "jvmti.h" #include "jvmti_common.h" -#include "../get_stack_trace.h" +#include "../get_stack_trace.hpp" extern "C" { @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; static jmethodID mid; @@ -67,7 +67,7 @@ void JNICALL Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *jni, jthread thr, jmethodID } check_jvmti_status(jni, jvmti->ClearBreakpoint(mid, 0), "ClearBreakpoint failed."); - set_event_notification_mode(jvmti, jni, JVMTI_DISABLE,JVMTI_EVENT_BREAKPOINT, NULL); + set_event_notification_mode(jvmti, jni, JVMTI_DISABLE,JVMTI_EVENT_BREAKPOINT, nullptr); set_event_notification_mode(jvmti, jni, JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, thr); LOG(">>> popping frame ...\n"); @@ -92,7 +92,7 @@ JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -128,12 +128,12 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { JNIEXPORT void JNICALL Java_getstacktr06_getReady(JNIEnv *jni, jclass cls, jclass clazz) { mid = jni->GetMethodID(clazz, "checkPoint", "()V"); - if (mid == NULL) { + if (mid == nullptr) { jni->FatalError("Cannot find Method ID for method checkPoint\n"); } check_jvmti_status(jni, jvmti->SetBreakpoint(mid, 0), "SetBreakpoint failed."); - set_event_notification_mode(jvmti, jni, JVMTI_ENABLE,JVMTI_EVENT_BREAKPOINT, NULL); + set_event_notification_mode(jvmti, jni, JVMTI_ENABLE,JVMTI_EVENT_BREAKPOINT, nullptr); } diff --git a/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/getstacktr07/libgetstacktr07.cpp b/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/getstacktr07/libgetstacktr07.cpp index a422fc0782f..baa5f8e90d9 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/getstacktr07/libgetstacktr07.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/getstacktr07/libgetstacktr07.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -25,14 +25,14 @@ #include #include "jvmti.h" #include "jvmti_common.h" -#include "../get_stack_trace.h" +#include "../get_stack_trace.hpp" extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; static jint result = PASSED; @@ -73,7 +73,7 @@ void JNICALL Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *jni, jthread thread, jmetho jni->FatalError("ERROR: don't know where we get called from"); } - if (classBytes == NULL) { + if (classBytes == nullptr) { jni->FatalError("ERROR: don't have any bytes"); } @@ -83,11 +83,11 @@ void JNICALL Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *jni, jthread thread, jmetho class_def.klass = klass; class_def.class_byte_count = jni->GetArrayLength(classBytes); - class_def.class_bytes = (unsigned char *) jni->GetByteArrayElements(classBytes, NULL); + class_def.class_bytes = (unsigned char *) jni->GetByteArrayElements(classBytes, nullptr); check_jvmti_status(jni, jvmti->RedefineClasses(1, &class_def), "RedefineClasses failed."); jni->DeleteGlobalRef(classBytes); - classBytes = NULL; + classBytes = nullptr; frame_info *expected_frames = jni->IsVirtualThread(thread) ? expected_virtual_frames @@ -105,7 +105,7 @@ JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -137,12 +137,12 @@ Java_getstacktr07_getReady(JNIEnv *jni, jclass cls, jclass clazz, jbyteArray byt classBytes = (jbyteArray) jni->NewGlobalRef(bytes); mid = jni->GetMethodID(clazz, "checkPoint", "()V"); - if (mid == NULL) { + if (mid == nullptr) { jni->FatalError("Cannot find Method ID for method checkPoint\n"); } check_jvmti_status(jni, jvmti->SetBreakpoint(mid, 0), "SetBreakpoint failed."); - set_event_notification_mode(jvmti, jni, JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL); + set_event_notification_mode(jvmti, jni, JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, nullptr); } diff --git a/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/getstacktr08/libgetstacktr08.cpp b/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/getstacktr08/libgetstacktr08.cpp index 977bbf00b04..c3f6ad667b1 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/getstacktr08/libgetstacktr08.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/thread/GetStackTrace/getstacktr08/libgetstacktr08.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -25,12 +25,12 @@ #include #include "jvmti.h" #include "jvmti_common.h" -#include "../get_stack_trace.h" +#include "../get_stack_trace.hpp" extern "C" { -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jboolean wasFramePop = JNI_FALSE; static jmethodID mid_checkPoint, mid_chain4; @@ -116,7 +116,7 @@ void JNICALL SingleStep(jvmtiEnv *jvmti_env, JNIEnv *jni, } - if (classBytes == NULL) { + if (classBytes == nullptr) { jni->FatalError("ERROR: don't have any bytes"); } @@ -125,11 +125,11 @@ void JNICALL SingleStep(jvmtiEnv *jvmti_env, JNIEnv *jni, classDef.klass = klass; classDef.class_byte_count = jni->GetArrayLength(classBytes); - classDef.class_bytes = (unsigned char *) jni->GetByteArrayElements(classBytes, NULL); + classDef.class_bytes = (unsigned char *) jni->GetByteArrayElements(classBytes, nullptr); check_jvmti_status(jni, jvmti_env->RedefineClasses(1, &classDef), "RedefineClasses failed."); jni->DeleteGlobalRef(classBytes); - classBytes = NULL; + classBytes = nullptr; if (!compare_stack_trace(jvmti_env, jni, thread, 2)) { jni->ThrowNew(jni->FindClass("java/lang/RuntimeException"), "Stacktrace differs from expected."); } @@ -140,7 +140,7 @@ JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -176,12 +176,12 @@ Java_getstacktr08_getReady(JNIEnv *jni, jclass cls, jclass clazz, jbyteArray byt mid_chain4 = jni->GetStaticMethodID(clazz, "chain4", "()V"); check_jvmti_status(jni, jvmti->SetBreakpoint(mid_checkPoint, 0), "SetBreakpoint failed."); - set_event_notification_mode(jvmti, jni, JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL); + set_event_notification_mode(jvmti, jni, JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, nullptr); } JNIEXPORT void JNICALL Java_getstacktr08_nativeChain(JNIEnv *jni, jclass cls, jclass clazz) { - if (mid_chain4 != NULL) { + if (mid_chain4 != nullptr) { jni->CallStaticVoidMethod(clazz, mid_chain4); } if (!compare_stack_trace(jvmti, jni, get_current_thread(jvmti, jni), 3)) { diff --git a/test/hotspot/jtreg/serviceability/jvmti/thread/GetThreadInfo/thrinfo01/libthrinfo01.cpp b/test/hotspot/jtreg/serviceability/jvmti/thread/GetThreadInfo/thrinfo01/libthrinfo01.cpp index 53f10cb7d5c..e040b88ba88 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/thread/GetThreadInfo/thrinfo01/libthrinfo01.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/thread/GetThreadInfo/thrinfo01/libthrinfo01.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -35,7 +35,7 @@ typedef struct { jboolean is_daemon; } info; -static jvmtiEnv *jvmti_env = NULL; +static jvmtiEnv *jvmti_env = nullptr; static info expected_info_array[] = { {"main", JNI_TRUE,JVMTI_THREAD_NORM_PRIORITY, JNI_FALSE}, {"thread1",JNI_TRUE,JVMTI_THREAD_MIN_PRIORITY + 2, JNI_TRUE}, @@ -49,7 +49,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { jvmtiCapabilities caps; res = jvm->GetEnv((void **) &jvmti_env, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti_env == NULL) { + if (res != JNI_OK || jvmti_env == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -75,8 +75,8 @@ Java_thrinfo01_checkInfo0(JNIEnv *jni, jclass cls, jthread thread, jthreadGroup info expected_info = expected_info_array[expected_idx]; check_jvmti_status(jni, jvmti_env->GetThreadInfo(thread, &inf), "Error in GetThreadInfo."); - if (inf.name == NULL) { - LOG("Thread %s: incorrect name in NULL\n", expected_info.name); + if (inf.name == nullptr) { + LOG("Thread %s: incorrect name in null\n", expected_info.name); result = JNI_FALSE; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/thread/GetThreadState/thrstat01/libthrstat01.cpp b/test/hotspot/jtreg/serviceability/jvmti/thread/GetThreadState/thrstat01/libthrstat01.cpp index 825ac1ffd75..4d54648a73f 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/thread/GetThreadState/thrstat01/libthrstat01.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/thread/GetThreadState/thrstat01/libthrstat01.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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,11 +31,11 @@ extern "C" { #define WAIT_START 100 #define WAIT_TIME (2*60*1000) -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jrawMonitorID access_lock; static jrawMonitorID wait_lock; -static jthread tested_thread_thr1 = NULL; +static jthread tested_thread_thr1 = nullptr; static jint state[] = { JVMTI_THREAD_STATE_RUNNABLE, @@ -45,9 +45,9 @@ static jint state[] = { void JNICALL VMInit(jvmtiEnv *jvmti_env, JNIEnv *jni, jthread thr) { - jvmtiError err = jvmti_env->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, NULL); + jvmtiError err = jvmti_env->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, nullptr); check_jvmti_status(jni, err, "Error in SetEventNotificationMode"); - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VIRTUAL_THREAD_START, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VIRTUAL_THREAD_START, nullptr); check_jvmti_status(jni, err, "Error in SetEventNotificationMode"); } @@ -58,7 +58,7 @@ ThreadStart(jvmtiEnv *jvmti_env, JNIEnv *jni, jthread thread) { jvmtiThreadInfo thread_info = get_thread_info(jvmti, jni, thread); LOG(">>> ThreadStart: \"%s\"\n", thread_info.name); - if (thread_info.name != NULL && strcmp(thread_info.name, "tested_thread_thr1") == 0) { + if (thread_info.name != nullptr && strcmp(thread_info.name, "tested_thread_thr1") == 0) { tested_thread_thr1 = jni->NewGlobalRef(thread); LOG(">>> ThreadStart: \"%s\", 0x%p\n", thread_info.name, tested_thread_thr1); } @@ -72,7 +72,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { LOG("Agent_OnLoad started\n"); res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -101,7 +101,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("(SetEventNotificationMode) unexpected error: %s (%d)\n", TranslateError(err), err); return JNI_ERR; @@ -117,7 +117,7 @@ Java_thrstat01_checkStatus0(JNIEnv *jni, jclass cls, jint stat_ind) { LOG("native method checkStatus started\n"); - if (tested_thread_thr1 == NULL) { + if (tested_thread_thr1 == nullptr) { LOG("Missing thread \"tested_thread_thr1\" start event\n"); return JNI_FALSE; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/thread/GetThreadState/thrstat02/libthrstat02.cpp b/test/hotspot/jtreg/serviceability/jvmti/thread/GetThreadState/thrstat02/libthrstat02.cpp index 0de51f8e5cf..588b2268f6d 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/thread/GetThreadState/thrstat02/libthrstat02.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/thread/GetThreadState/thrstat02/libthrstat02.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,9 +30,9 @@ extern "C" { #define WAIT_START 100 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jrawMonitorID access_lock, wait_lock; -static jthread thr_ptr = NULL; +static jthread thr_ptr = nullptr; static jint wait_time = 0; static jint state[] = { JVMTI_THREAD_STATE_RUNNABLE, @@ -55,7 +55,7 @@ void printStateFlags(jint flags) { void JNICALL VMInit(jvmtiEnv *jvmti_env, JNIEnv *jni, jthread thr) { - jvmtiError err = jvmti_env->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, NULL); + jvmtiError err = jvmti_env->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, nullptr); check_jvmti_status(jni, err, "Failed to enable THREAD_START event"); } @@ -63,7 +63,7 @@ void JNICALL ThreadStart(jvmtiEnv *jvmti_env, JNIEnv *jni, jthread thread) { RawMonitorLocker rml = RawMonitorLocker(jvmti, jni, access_lock); jvmtiThreadInfo thread_info = get_thread_info(jvmti_env, jni, thread); - if (thread_info.name != NULL && strcmp(thread_info.name, "tested_thread_thr1") == 0) { + if (thread_info.name != nullptr && strcmp(thread_info.name, "tested_thread_thr1") == 0) { thr_ptr = jni->NewGlobalRef(thread); LOG(">>> ThreadStart: \"%s\", 0x%p\n", thread_info.name, thr_ptr); } @@ -77,7 +77,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -103,7 +103,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("Failed to enable VM_INIT event: %s (%d)\n", TranslateError(err), err); return JNI_ERR; @@ -135,12 +135,12 @@ Java_thrstat02_checkStatus0(JNIEnv *jni, jclass cls, jint statInd, jboolean susp jboolean timeout_is_reached; unsigned int waited_millis; - if (jvmti == NULL) { + if (jvmti == nullptr) { LOG("JVMTI client was not properly loaded!\n"); return JNI_FALSE; } - if (thr_ptr == NULL) { + if (thr_ptr == nullptr) { LOG("Missing thread \"tested_thread_thr1\" start event\n"); return JNI_FALSE; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/thread/GetThreadState/thrstat03/libthrstat03.cpp b/test/hotspot/jtreg/serviceability/jvmti/thread/GetThreadState/thrstat03/libthrstat03.cpp index 632d4136e35..36a632ff32c 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/thread/GetThreadState/thrstat03/libthrstat03.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/thread/GetThreadState/thrstat03/libthrstat03.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,7 @@ extern "C" { #define WAIT_START 100 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint wait_time = 0; static jint state[] = { 0, /* JVMTI_THREAD_STATUS_NOT_STARTED, */ @@ -46,7 +46,7 @@ Java_thrstat03_init(JNIEnv *env, jclass cls, jint waitTime) { JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { jint res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -59,7 +59,7 @@ Java_thrstat03_check(JNIEnv *jni, jclass cls, jthread thread, jint statInd) { jrawMonitorID wait_lock; jint thr_state = 0; - if (jvmti == NULL) { + if (jvmti == nullptr) { LOG("JVMTI client was not properly loaded!\n"); return JNI_FALSE; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/thread/GetThreadState/thrstat05/libthrstat05.cpp b/test/hotspot/jtreg/serviceability/jvmti/thread/GetThreadState/thrstat05/libthrstat05.cpp index e96dd665f59..3fd9b535de4 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/thread/GetThreadState/thrstat05/libthrstat05.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/thread/GetThreadState/thrstat05/libthrstat05.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -66,7 +66,7 @@ static int g_ThreadState[] = { | JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT, /* TS_RUN_WAIT_SLEEPING */ }; -static jvmtiEnv *jvmti_env = NULL; +static jvmtiEnv *jvmti_env = nullptr; static int g_wait_time = 1000; jrawMonitorID wait_lock; /* Monitor is used just for sleeping */ @@ -75,7 +75,7 @@ JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { jint res = jvm->GetEnv((void **) &jvmti_env, JVMTI_VERSION_1_1); if (res != JNI_OK || !jvmti_env) { - LOG("Agent_OnLoad: Error: GetEnv returned error or NULL\n"); + LOG("Agent_OnLoad: Error: GetEnv returned error or null\n"); return JNI_ERR; } wait_lock = create_raw_monitor(jvmti_env, "beast"); diff --git a/test/hotspot/jtreg/serviceability/jvmti/thread/ResumeThread/resumethrd01/libresumethrd01.cpp b/test/hotspot/jtreg/serviceability/jvmti/thread/ResumeThread/resumethrd01/libresumethrd01.cpp index 3e07b2aee4c..d3b2f5745b5 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/thread/ResumeThread/resumethrd01/libresumethrd01.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/thread/ResumeThread/resumethrd01/libresumethrd01.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -48,11 +48,11 @@ agentProc(jvmtiEnv *jvmti, JNIEnv *jni, void *arg) { /* perform testing */ { - jthread testedThread = NULL; + jthread testedThread = nullptr; LOG("Find thread: %s\n", THREAD_NAME); testedThread = find_thread_by_name(jvmti, jni, THREAD_NAME); - if (testedThread == NULL) { + if (testedThread == nullptr) { return; } LOG(" ... found thread: %p\n", (void *) testedThread); @@ -100,13 +100,13 @@ agentProc(jvmtiEnv *jvmti, JNIEnv *jni, void *arg) { JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv *jvmti = NULL; + jvmtiEnv *jvmti = nullptr; timeout = 60 * 1000; LOG("Agent_OnLoad started\n"); jint res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_9); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -122,7 +122,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!set_agent_proc(agentProc, NULL)) { + if (!set_agent_proc(agentProc, nullptr)) { return JNI_ERR; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/thread/ResumeThread/resumethrd02/libresumethrd02.cpp b/test/hotspot/jtreg/serviceability/jvmti/thread/ResumeThread/resumethrd02/libresumethrd02.cpp index c9de5e4ee0d..665c1a4da93 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/thread/ResumeThread/resumethrd02/libresumethrd02.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/thread/ResumeThread/resumethrd02/libresumethrd02.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ static jvmtiEvent eventsList[EVENTS_COUNT] = { }; static volatile int eventsReceived = 0; -static jthread testedThread = NULL; +static jthread testedThread = nullptr; /* ============================================================================= */ @@ -59,14 +59,14 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { { LOG("Find thread: %s\n", THREAD_NAME); testedThread = find_thread_by_name(jvmti, jni,THREAD_NAME); - if (testedThread == NULL) { + if (testedThread == nullptr) { return; } LOG(" ... found thread: %p\n", (void*)testedThread); eventsReceived = 0; LOG("Enable event: %s\n", "THREAD_END"); - enable_events_notifications(jvmti, jni, JVMTI_ENABLE, EVENTS_COUNT, eventsList, NULL); + enable_events_notifications(jvmti, jni, JVMTI_ENABLE, EVENTS_COUNT, eventsList, nullptr); LOG("Suspend thread: %p\n", (void*)testedThread); jvmtiError err = jvmti->SuspendThread(testedThread); @@ -102,7 +102,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { } LOG("Disable event: %s\n", "THREAD_END"); - enable_events_notifications(jvmti, jni,JVMTI_DISABLE, EVENTS_COUNT, eventsList, NULL); + enable_events_notifications(jvmti, jni,JVMTI_DISABLE, EVENTS_COUNT, eventsList, nullptr); LOG("Wait for thread to finish\n"); if (!agent_wait_for_sync(timeout)) @@ -123,7 +123,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { JNIEXPORT void JNICALL callbackThreadEnd(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { /* check if event is for tested thread */ - if (thread != NULL && jni->IsSameObject(testedThread, thread)) { + if (thread != nullptr && jni->IsSameObject(testedThread, thread)) { LOG(" ... received THREAD_END event for tested thread: %p\n", (void*)thread); eventsReceived++; } else { @@ -136,12 +136,12 @@ callbackThreadEnd(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { /** Agent library initialization. */ JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; timeout = 60 * 1000; jint res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_9); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -173,7 +173,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - if (!set_agent_proc(agentProc, NULL)) { + if (!set_agent_proc(agentProc, nullptr)) { return JNI_ERR; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/thread/ResumeThreadList/resumethrdlst01/libresumethrdlst01.cpp b/test/hotspot/jtreg/serviceability/jvmti/thread/ResumeThreadList/resumethrdlst01/libresumethrdlst01.cpp index 5784ae79978..42c4a4579fe 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/thread/ResumeThreadList/resumethrdlst01/libresumethrdlst01.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/thread/ResumeThreadList/resumethrdlst01/libresumethrdlst01.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,8 +52,8 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { /* perform testing */ { - jthread* threads = NULL; - jvmtiError* results = NULL; + jthread* threads = nullptr; + jvmtiError* results = nullptr; LOG("Allocate threads array: %d threads\n", THREADS_COUNT); check_jvmti_status(jni, jvmti->Allocate((THREADS_COUNT * sizeof(jthread)), (unsigned char**)&threads), ""); @@ -123,7 +123,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { LOG("Delete threads references\n"); for (int i = 0; i < THREADS_COUNT; i++) { - if (threads[i] != NULL) + if (threads[i] != nullptr) jni->DeleteGlobalRef(threads[i]); } @@ -143,13 +143,13 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { static int find_threads_by_name(jvmtiEnv* jvmti, JNIEnv* jni, const char name[], int foundCount, jthread foundThreads[]) { jint count = 0; - jthread* threads = NULL; + jthread* threads = nullptr; size_t len = strlen(name); int found = 0; for (int i = 0; i < foundCount; i++) { - foundThreads[i] = NULL; + foundThreads[i] = nullptr; } check_jvmti_status(jni, jvmti->GetAllThreads(&count, &threads), "Error in GetAllThreads"); @@ -159,7 +159,7 @@ static int find_threads_by_name(jvmtiEnv* jvmti, JNIEnv* jni, jvmtiThreadInfo info; check_jvmti_status(jni, jvmti->GetThreadInfo(threads[i], &info), ""); - if (info.name != NULL && strncmp(name, info.name, len) == 0) { + if (info.name != nullptr && strncmp(name, info.name, len) == 0) { LOG(" ... found thread #%d: %p (%s)\n", found, threads[i], info.name); if (found < foundCount) foundThreads[found] = threads[i]; @@ -182,7 +182,7 @@ static int find_threads_by_name(jvmtiEnv* jvmti, JNIEnv* jni, LOG("Make global references for threads: %d threads\n", foundCount); for (int i = 0; i < foundCount; i++) { foundThreads[i] = (jthread) jni->NewGlobalRef(foundThreads[i]); - if ( foundThreads[i] == NULL) { + if ( foundThreads[i] == nullptr) { set_agent_fail_status(); return JNI_FALSE; } @@ -194,12 +194,12 @@ static int find_threads_by_name(jvmtiEnv* jvmti, JNIEnv* jni, JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; timeout = 60 * 1000; jint res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_9); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -219,7 +219,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - if (!set_agent_proc(agentProc, NULL)) { + if (!set_agent_proc(agentProc, nullptr)) { return JNI_ERR; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/thread/ResumeThreadList/resumethrdlst02/libresumethrdlst02.cpp b/test/hotspot/jtreg/serviceability/jvmti/thread/ResumeThreadList/resumethrdlst02/libresumethrdlst02.cpp index 8345a56d352..5d622b926db 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/thread/ResumeThreadList/resumethrdlst02/libresumethrdlst02.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/thread/ResumeThreadList/resumethrdlst02/libresumethrdlst02.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,7 +47,7 @@ static jvmtiEvent eventsList[EVENTS_COUNT] = { }; static const int THREADS_COUNT = 10; -static jthread* threads = NULL; +static jthread* threads = nullptr; static volatile int eventsReceived = 0; static jrawMonitorID eventsReceivedMtx = 0; @@ -65,7 +65,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { /* perform testing */ { - jvmtiError* results = NULL; + jvmtiError* results = nullptr; LOG("Allocate threads array: %d threads\n", THREADS_COUNT); check_jvmti_status(jni, jvmti->Allocate((THREADS_COUNT * sizeof(jthread)), (unsigned char**)&threads), ""); @@ -98,7 +98,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { eventsReceived = 0; LOG("Enable event: %s\n", "THREAD_END"); - enable_events_notifications(jvmti, jni,JVMTI_ENABLE, EVENTS_COUNT, eventsList, NULL); + enable_events_notifications(jvmti, jni,JVMTI_ENABLE, EVENTS_COUNT, eventsList, nullptr); LOG("Let threads to run and finish\n"); if (!agent_resume_sync()) @@ -136,7 +136,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { } LOG("Disable event: %s\n", "THREAD_END"); - enable_events_notifications(jvmti, jni, JVMTI_DISABLE, EVENTS_COUNT, eventsList, NULL); + enable_events_notifications(jvmti, jni, JVMTI_DISABLE, EVENTS_COUNT, eventsList, nullptr); LOG("Wait for thread to finish\n"); if (!agent_wait_for_sync(timeout)) @@ -144,7 +144,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { LOG("Delete threads references\n"); for (int i = 0; i < THREADS_COUNT; i++) { - if (threads[i] != NULL) + if (threads[i] != nullptr) jni->DeleteGlobalRef(threads[i]); } @@ -164,13 +164,13 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { static int find_threads_by_name(jvmtiEnv* jvmti, JNIEnv* jni, const char name[], int foundCount, jthread foundThreads[]) { jint count = 0; - jthread* threads = NULL; + jthread* threads = nullptr; size_t len = strlen(name); int found = 0; for (int i = 0; i < foundCount; i++) { - foundThreads[i] = NULL; + foundThreads[i] = nullptr; } check_jvmti_status(jni, jvmti->GetAllThreads(&count, &threads), "Error in GetAllThreads"); @@ -180,7 +180,7 @@ static int find_threads_by_name(jvmtiEnv* jvmti, JNIEnv* jni, jvmtiThreadInfo info; check_jvmti_status(jni, jvmti->GetThreadInfo(threads[i], &info), ""); - if (info.name != NULL && strncmp(name, info.name, len) == 0) { + if (info.name != nullptr && strncmp(name, info.name, len) == 0) { LOG(" ... found thread #%d: %p (%s)\n", found, threads[i], info.name); if (found < foundCount) foundThreads[found] = threads[i]; @@ -203,7 +203,7 @@ static int find_threads_by_name(jvmtiEnv* jvmti, JNIEnv* jni, LOG("Make global references for threads: %d threads\n", foundCount); for (int i = 0; i < foundCount; i++) { foundThreads[i] = (jthread) jni->NewGlobalRef(foundThreads[i]); - if ( foundThreads[i] == NULL) { + if ( foundThreads[i] == nullptr) { set_agent_fail_status(); return JNI_FALSE; } @@ -221,7 +221,7 @@ callbackThreadEnd(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { /* check if event is for tested thread */ for (int i = 0; i < THREADS_COUNT; i++) { - if (thread != NULL && jni->IsSameObject(threads[i], thread)) { + if (thread != nullptr && jni->IsSameObject(threads[i], thread)) { LOG(" ... received THREAD_END event for thread #%d: %p\n", i, (void*)thread); eventsReceived++; jvmti->RawMonitorExit(eventsReceivedMtx); @@ -234,12 +234,12 @@ callbackThreadEnd(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; timeout = 60 * 1000; jint res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_9); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -273,7 +273,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - if (!set_agent_proc(agentProc, NULL)) { + if (!set_agent_proc(agentProc, nullptr)) { return JNI_ERR; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/thread/SuspendThread/suspendthrd01/libsuspendthrd01.cpp b/test/hotspot/jtreg/serviceability/jvmti/thread/SuspendThread/suspendthrd01/libsuspendthrd01.cpp index 0df18a09f2d..300a479d4ce 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/thread/SuspendThread/suspendthrd01/libsuspendthrd01.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/thread/SuspendThread/suspendthrd01/libsuspendthrd01.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -50,7 +50,7 @@ agentProc(jvmtiEnv *jvmti, JNIEnv *jni, void *arg) { { LOG("Find thread: %s\n", THREAD_NAME); jthread tested_thread = find_thread_by_name(jvmti, jni, THREAD_NAME); - if (tested_thread == NULL) { + if (tested_thread == nullptr) { return; } LOG(" ... found thread: %p\n", (void *) tested_thread); @@ -97,12 +97,12 @@ agentProc(jvmtiEnv *jvmti, JNIEnv *jni, void *arg) { JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv *jvmti = NULL; + jvmtiEnv *jvmti = nullptr; timeout = 60 * 1000; jint res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_9); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -122,7 +122,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - if (!set_agent_proc(agentProc, NULL)) { + if (!set_agent_proc(agentProc, nullptr)) { return JNI_ERR; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/thread/SuspendThread/suspendthrd02/libsuspendthrd02.cpp b/test/hotspot/jtreg/serviceability/jvmti/thread/SuspendThread/suspendthrd02/libsuspendthrd02.cpp index 9f3e59e6a88..9ab8e053a51 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/thread/SuspendThread/suspendthrd02/libsuspendthrd02.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/thread/SuspendThread/suspendthrd02/libsuspendthrd02.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,7 @@ static jvmtiEvent eventsList[EVENTS_COUNT] = { }; static volatile int eventsReceived = 0; -static jthread testedThread = NULL; +static jthread testedThread = nullptr; /** Agent algorithm. */ static void JNICALL @@ -61,14 +61,14 @@ agentProc(jvmtiEnv *jvmti, JNIEnv *jni, void *arg) { { LOG("Find thread: %s\n", THREAD_NAME); testedThread = find_thread_by_name(jvmti, jni, THREAD_NAME); - if (testedThread == NULL) { + if (testedThread == nullptr) { return; } LOG(" ... found thread: %p\n", (void *) testedThread); eventsReceived = 0; LOG("Enable event: %s\n", "THREAD_END"); - enable_events_notifications(jvmti, jni, JVMTI_ENABLE, EVENTS_COUNT, eventsList, NULL); + enable_events_notifications(jvmti, jni, JVMTI_ENABLE, EVENTS_COUNT, eventsList, nullptr); LOG("Suspend thread: %p\n", (void *) testedThread); err = jvmti->SuspendThread(testedThread); @@ -96,7 +96,7 @@ agentProc(jvmtiEnv *jvmti, JNIEnv *jni, void *arg) { } LOG("Disable event: %s\n", "THREAD_END"); - enable_events_notifications(jvmti, jni, JVMTI_DISABLE, EVENTS_COUNT, eventsList, NULL); + enable_events_notifications(jvmti, jni, JVMTI_DISABLE, EVENTS_COUNT, eventsList, nullptr); LOG("Resume thread: %p\n", (void *) testedThread); err = jvmti->ResumeThread(testedThread); @@ -122,7 +122,7 @@ agentProc(jvmtiEnv *jvmti, JNIEnv *jni, void *arg) { JNIEXPORT void JNICALL callbackThreadEnd(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread) { /* check if event is for tested thread */ - if (thread != NULL && jni->IsSameObject(testedThread, thread)) { + if (thread != nullptr && jni->IsSameObject(testedThread, thread)) { LOG(" ... received THREAD_END event for tested thread: %p\n", (void *) thread); eventsReceived++; } else { @@ -132,12 +132,12 @@ callbackThreadEnd(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread) { JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv *jvmti = NULL; + jvmtiEnv *jvmti = nullptr; timeout = 60 * 1000; jint res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_9); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -168,7 +168,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } /* register agent proc and arg */ - if (!set_agent_proc(agentProc, NULL)) { + if (!set_agent_proc(agentProc, nullptr)) { return JNI_ERR; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/thread/SuspendThreadList/suspendthrdlst01/libsuspendthrdlst01.cpp b/test/hotspot/jtreg/serviceability/jvmti/thread/SuspendThreadList/suspendthrdlst01/libsuspendthrdlst01.cpp index 19bb8e0cadb..30fb104beff 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/thread/SuspendThreadList/suspendthrdlst01/libsuspendthrdlst01.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/thread/SuspendThreadList/suspendthrdlst01/libsuspendthrdlst01.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -54,8 +54,8 @@ agentProc(jvmtiEnv *jvmti, JNIEnv *jni, void *arg) { /* perform testing */ { - jthread *threads = NULL; - jvmtiError *results = NULL; + jthread *threads = nullptr; + jvmtiError *results = nullptr; LOG("Allocate threads array: %d threads\n", THREADS_COUNT); check_jvmti_status(jni, jvmti->Allocate((THREADS_COUNT * sizeof(jthread)), @@ -120,7 +120,7 @@ agentProc(jvmtiEnv *jvmti, JNIEnv *jni, void *arg) { LOG("Delete threads references\n"); for (int i = 0; i < THREADS_COUNT; i++) { - if (threads[i] != NULL) + if (threads[i] != nullptr) jni->DeleteGlobalRef(threads[i]); } @@ -141,13 +141,13 @@ agentProc(jvmtiEnv *jvmti, JNIEnv *jni, void *arg) { /** Find threads whose name starts with specified name prefix. */ static int find_threads_by_name(jvmtiEnv *jvmti, JNIEnv *jni, const char *name, int found_count, jthread *found_threads) { jint count = 0; - jthread *threads = NULL; + jthread *threads = nullptr; size_t len = strlen(name); int found = 0; for (int i = 0; i < found_count; i++) { - found_threads[i] = NULL; + found_threads[i] = nullptr; } check_jvmti_status(jni, jvmti->GetAllThreads(&count, &threads), "Error in GetAllThreads"); @@ -158,7 +158,7 @@ static int find_threads_by_name(jvmtiEnv *jvmti, JNIEnv *jni, const char *name, check_jvmti_status(jni, jvmti->GetThreadInfo(threads[i], &info), ""); - if (info.name != NULL && strncmp(name, info.name, len) == 0) { + if (info.name != nullptr && strncmp(name, info.name, len) == 0) { LOG(" ... found thread #%d: %p (%s)\n", found, threads[i], info.name); if (found < found_count) found_threads[found] = threads[i]; @@ -182,7 +182,7 @@ static int find_threads_by_name(jvmtiEnv *jvmti, JNIEnv *jni, const char *name, LOG("Make global references for threads: %d threads\n", found_count); for (int i = 0; i < found_count; i++) { found_threads[i] = (jthread) jni->NewGlobalRef(found_threads[i]); - if (found_threads[i] == NULL) { + if (found_threads[i] == nullptr) { set_agent_fail_status(); return JNI_FALSE; } @@ -194,12 +194,12 @@ static int find_threads_by_name(jvmtiEnv *jvmti, JNIEnv *jni, const char *name, JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv *jvmti = NULL; + jvmtiEnv *jvmti = nullptr; timeout = 60 * 1000; jint res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_9); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -216,7 +216,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } /* register agent proc and arg */ - if (!set_agent_proc(agentProc, NULL)) { + if (!set_agent_proc(agentProc, nullptr)) { return JNI_ERR; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/thread/SuspendThreadList/suspendthrdlst02/libsuspendthrdlst02.cpp b/test/hotspot/jtreg/serviceability/jvmti/thread/SuspendThreadList/suspendthrdlst02/libsuspendthrdlst02.cpp index 5fb6c80af98..2ccc96c2596 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/thread/SuspendThreadList/suspendthrdlst02/libsuspendthrdlst02.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/thread/SuspendThreadList/suspendthrdlst02/libsuspendthrdlst02.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ static jvmtiEvent eventsList[EVENTS_COUNT] = { JVMTI_EVENT_THREAD_END }; -static jthread* threads = NULL; +static jthread* threads = nullptr; static volatile int eventsReceived = 0; @@ -66,7 +66,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { /* perform testing */ { - jvmtiError* results = NULL; + jvmtiError* results = nullptr; LOG("Allocate threads array: %d threads\n", THREADS_COUNT); check_jvmti_status(jni, jvmti->Allocate((THREADS_COUNT * sizeof(jthread)), @@ -100,7 +100,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { eventsReceived = 0; LOG("Enable event: %s\n", "THREAD_END"); - enable_events_notifications(jvmti, jni, JVMTI_ENABLE, EVENTS_COUNT, eventsList, NULL); + enable_events_notifications(jvmti, jni, JVMTI_ENABLE, EVENTS_COUNT, eventsList, nullptr); LOG("Let threads to run and finish\n"); if (!agent_resume_sync()) @@ -121,7 +121,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { } LOG("Disable event: %s\n", "THREAD_END"); - enable_events_notifications(jvmti, jni,JVMTI_DISABLE, EVENTS_COUNT, eventsList, NULL); + enable_events_notifications(jvmti, jni,JVMTI_DISABLE, EVENTS_COUNT, eventsList, nullptr); LOG("Resume threads list\n"); err = jvmti->ResumeThreadList(THREADS_COUNT, threads, results); @@ -137,7 +137,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { LOG("Delete threads references\n"); for (int i = 0; i < THREADS_COUNT; i++) { - if (threads[i] != NULL) { + if (threads[i] != nullptr) { jni->DeleteGlobalRef(threads[i]); } } @@ -159,12 +159,12 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { static int find_threads_by_name(jvmtiEnv* jvmti, JNIEnv* jni, const char name[], int foundCount, jthread foundThreads[]) { jint count = 0; - jthread* threads = NULL; + jthread* threads = nullptr; size_t len = strlen(name); int found = 0; for (int i = 0; i < foundCount; i++) { - foundThreads[i] = NULL; + foundThreads[i] = nullptr; } check_jvmti_status(jni, jvmti->GetAllThreads(&count, &threads), ""); @@ -174,7 +174,7 @@ static int find_threads_by_name(jvmtiEnv* jvmti, JNIEnv* jni, jvmtiThreadInfo info; check_jvmti_status(jni, jvmti->GetThreadInfo(threads[i], &info), ""); - if (info.name != NULL && strncmp(name, info.name, len) == 0) { + if (info.name != nullptr && strncmp(name, info.name, len) == 0) { LOG(" ... found thread #%d: %p (%s)\n", found, threads[i], info.name); if (found < foundCount) { foundThreads[found] = threads[i]; @@ -198,7 +198,7 @@ static int find_threads_by_name(jvmtiEnv* jvmti, JNIEnv* jni, LOG("Make global references for threads: %d threads\n", foundCount); for (int i = 0; i < foundCount; i++) { foundThreads[i] = (jthread) jni->NewGlobalRef(foundThreads[i]); - if (foundThreads[i] == NULL) { + if (foundThreads[i] == nullptr) { set_agent_fail_status(); return JNI_FALSE; } @@ -213,7 +213,7 @@ JNIEXPORT void JNICALL callbackThreadEnd(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { /* check if event is for tested thread */ for (int i = 0; i < THREADS_COUNT; i++) { - if (thread != NULL && jni->IsSameObject(threads[i], thread)) { + if (thread != nullptr && jni->IsSameObject(threads[i], thread)) { LOG(" ... received THREAD_END event for thread #%d: %p\n", i, (void*)thread); eventsReceived++; return; @@ -224,12 +224,12 @@ callbackThreadEnd(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; timeout = 60 * 1000; jint res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_9); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -261,7 +261,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - if (!set_agent_proc(agentProc, NULL)) { + if (!set_agent_proc(agentProc, nullptr)) { return JNI_ERR; } return JNI_OK; diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/BreakpointInYieldTest/libBreakpointInYieldTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/vthread/BreakpointInYieldTest/libBreakpointInYieldTest.cpp index 01b1f2f93dc..aa9f3bbd52a 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/BreakpointInYieldTest/libBreakpointInYieldTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/BreakpointInYieldTest/libBreakpointInYieldTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, 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 @@ -27,8 +27,8 @@ extern "C" { -static jvmtiEnv *jvmti = NULL; -static jrawMonitorID event_mon = NULL; +static jvmtiEnv *jvmti = nullptr; +static jrawMonitorID event_mon = nullptr; static int method_entry_count = 0; static int method_exit_count = 0; static int breakpoint_count = 0; @@ -63,7 +63,7 @@ set_breakpoint(JNIEnv *jni, jclass klass, const char *mname) jlocation location = (jlocation)0L; jvmtiError err; - if (method == NULL) { + if (method == nullptr) { jni->FatalError("Error in set_breakpoint: not found method"); } err = jvmti->SetBreakpoint(method, location); @@ -131,13 +131,13 @@ VirtualThreadMount(jvmtiEnv *jvmti, ...) { if (done) { return; // defence against JVMTI_ERROR_WRONG_PHASE failures } - jmethodID method = NULL; + jmethodID method = nullptr; jlocation loc = 0L; jvmtiError err; va_list ap; - JNIEnv* jni = NULL; - jthread thread = NULL; + JNIEnv* jni = nullptr; + jthread thread = nullptr; va_start(ap, jvmti); jni = va_arg(ap, JNIEnv*); @@ -162,13 +162,13 @@ VirtualThreadUnmount(jvmtiEnv *jvmti, ...) { if (done) { return; // defence against JVMTI_ERROR_WRONG_PHASE failures } - jmethodID method = NULL; + jmethodID method = nullptr; jlocation loc = 0L; jvmtiError err; va_list ap; - JNIEnv* jni = NULL; - jthread thread = NULL; + JNIEnv* jni = nullptr; + jthread thread = nullptr; va_start(ap, jvmti); jni = va_arg(ap, JNIEnv*); @@ -239,24 +239,24 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("error in JVMTI SetEventNotificationMode: %d\n", err); return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VIRTUAL_THREAD_START, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VIRTUAL_THREAD_START, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("error in JVMTI SetEventNotificationMode: %d\n", err); } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, EXT_EVENT_VIRTUAL_THREAD_MOUNT, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, EXT_EVENT_VIRTUAL_THREAD_MOUNT, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("error in JVMTI SetEventNotificationMode: %d\n", err); return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, EXT_EVENT_VIRTUAL_THREAD_UNMOUNT, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, EXT_EVENT_VIRTUAL_THREAD_UNMOUNT, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("error in JVMTI SetEventNotificationMode: %d\n", err); return JNI_ERR; @@ -276,16 +276,16 @@ Java_BreakpointInYieldTest_enableEvents(JNIEnv *jni, jclass klass, jthread threa LOG("enableEvents: started\n"); - jclass k1 = find_class(jvmti, jni, NULL, "Ljava/lang/VirtualThread;"); - jclass k2 = find_class(jvmti, jni, NULL, "Ljdk/internal/vm/Continuation;"); - if (k1 == NULL || k2 == NULL) { + jclass k1 = find_class(jvmti, jni, nullptr, "Ljava/lang/VirtualThread;"); + jclass k2 = find_class(jvmti, jni, nullptr, "Ljdk/internal/vm/Continuation;"); + if (k1 == nullptr || k2 == nullptr) { jni->FatalError("Did not find one of the classes by name: VirtualThread or Continuation"); } set_breakpoint(jni, k1, "run"); set_breakpoint(jni, k2, "yield"); // Enable Breakpoint events globally - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, nullptr); check_jvmti_status(jni, err, "enableEvents: error in JVMTI SetEventNotificationMode: enable BREAKPOINT"); LOG("enableEvents: finished\n"); @@ -297,19 +297,19 @@ Java_BreakpointInYieldTest_check(JNIEnv *jni, jclass cls) { jvmtiError err; done = true; // defence against JVMTI_ERROR_WRONG_PHASE failures - err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_THREAD_START, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_THREAD_START, nullptr); check_jvmti_status(jni, err, "check: error in JVMTI SetEventNotificationMode: disable THREAD_START"); - err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_VIRTUAL_THREAD_START, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_VIRTUAL_THREAD_START, nullptr); check_jvmti_status(jni, err, "check: error in JVMTI SetEventNotificationMode: disable VIRTUAL_THREAD_START"); - err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, EXT_EVENT_VIRTUAL_THREAD_MOUNT, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, EXT_EVENT_VIRTUAL_THREAD_MOUNT, nullptr); check_jvmti_status(jni, err, "check: error in JVMTI SetEventNotificationMode: disable VIRTUAL_THREAD_MOUNT"); - err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, EXT_EVENT_VIRTUAL_THREAD_UNMOUNT, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, EXT_EVENT_VIRTUAL_THREAD_UNMOUNT, nullptr); check_jvmti_status(jni, err, "check: error in JVMTI SetEventNotificationMode: disable VIRTUAL_THREAD_UNMOUNT"); - err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_BREAKPOINT, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_BREAKPOINT, nullptr); check_jvmti_status(jni, err, "check: error in JVMTI SetEventNotificationMode: disable BREAKPOINT"); LOG("\n"); diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/ContFramePopTest/libContFramePopTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/vthread/ContFramePopTest/libContFramePopTest.cpp index 191d47585e9..1840b6ccac7 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/ContFramePopTest/libContFramePopTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/ContFramePopTest/libContFramePopTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, 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 @@ -29,9 +29,9 @@ extern "C" { #define MAX_FRAME_COUNT 20 -static jvmtiEnv *jvmti = NULL; -static jthread exp_thread = NULL; -static jrawMonitorID event_mon = NULL; +static jvmtiEnv *jvmti = nullptr; +static jthread exp_thread = nullptr; +static jrawMonitorID event_mon = nullptr; static int method_entry_count = 0; static int method_exit_count = 0; static int frame_pop_count = 0; @@ -40,11 +40,11 @@ static void print_frame_event_info(jvmtiEnv *jvmti, JNIEnv* jni, jthread thread, jmethodID method, const char* event_name) { char* tname = get_thread_name(jvmti, jni, thread); char* cname = get_method_class_name(jvmti, jni, method); - char* mname = NULL; - char* msign = NULL; + char* mname = nullptr; + char* msign = nullptr; jvmtiError err; - err = jvmti->GetMethodName(method, &mname, &msign, NULL); + err = jvmti->GetMethodName(method, &mname, &msign, nullptr); check_jvmti_status(jni, err, "event handler: error in JVMTI GetMethodName call"); if (strcmp(event_name, "MethodEntry") == 0) { diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/ContStackDepthTest/libContStackDepthTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/vthread/ContStackDepthTest/libContStackDepthTest.cpp index f0b6fcaa254..9bafe3bd5d0 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/ContStackDepthTest/libContStackDepthTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/ContStackDepthTest/libContStackDepthTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, 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 @@ -28,9 +28,9 @@ extern "C" { -static jvmtiEnv *jvmti = NULL; -static jthread exp_thread = NULL; -static jrawMonitorID event_mon = NULL; +static jvmtiEnv *jvmti = nullptr; +static jthread exp_thread = nullptr; +static jrawMonitorID event_mon = nullptr; static int breakpoint_count = 0; static int frame_pop_count = 0; static int method_entry_count = 0; @@ -42,11 +42,11 @@ print_frame_event_info(jvmtiEnv *jvmti, JNIEnv* jni, jthread thread, jmethodID m const char* event_name, int event_count) { char* tname = get_thread_name(jvmti, jni, thread); char* cname = get_method_class_name(jvmti, jni, method); - char* mname = NULL; - char* msign = NULL; + char* mname = nullptr; + char* msign = nullptr; jvmtiError err; - err = jvmti->GetMethodName(method, &mname, &msign, NULL); + err = jvmti->GetMethodName(method, &mname, &msign, nullptr); check_jvmti_status(jni, err, "event handler: error in JVMTI GetMethodName call"); LOG("\n%s event #%d: thread: %s, method: %s: %s%s\n", @@ -181,10 +181,10 @@ FramePop(jvmtiEnv *jvmti, JNIEnv* jni, jthread thread, print_frame_event_info(jvmti, jni, thread, method, "FramePop", ++frame_pop_count); - err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, nullptr); check_jvmti_status(jni, err, "FramePop: error in JVMTI SetEventNotificationMode: disable SINGLE_STEP"); - err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_FRAME_POP, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_FRAME_POP, nullptr); check_jvmti_status(jni, err, "FramePop: error in JVMTI SetEventNotificationMode: disable FRAME_POP"); deallocate(jvmti, jni, (void*)mname); @@ -236,8 +236,8 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { JNIEXPORT void JNICALL Java_ContStackDepthTest_enableEvents(JNIEnv *jni, jclass klass, jthread thread) { jint method_count = 0; - jmethodID* methods = NULL; - jmethodID method = NULL; + jmethodID* methods = nullptr; + jmethodID method = nullptr; jlocation location = (jlocation)0L; jvmtiError err; @@ -259,7 +259,7 @@ Java_ContStackDepthTest_enableEvents(JNIEnv *jni, jclass klass, jthread thread) } deallocate(jvmti, jni, (void*)mname); } - if (method == NULL) { + if (method == nullptr) { jni->FatalError("Error in enableEvents: not found method fibTest()"); } @@ -267,7 +267,7 @@ Java_ContStackDepthTest_enableEvents(JNIEnv *jni, jclass klass, jthread thread) check_jvmti_status(jni, err, "enableEvents: error in JVMTI SetBreakpoint"); // Enable Breakpoint events globally - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, nullptr); check_jvmti_status(jni, err, "enableEvents: error in JVMTI SetEventNotificationMode: enable BREAKPOINT"); LOG("enableEvents: finished\n"); diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/ContYieldBreakPointTest/libContYieldBreakPointTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/vthread/ContYieldBreakPointTest/libContYieldBreakPointTest.cpp index b4f3da42e4a..e8ac3886461 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/ContYieldBreakPointTest/libContYieldBreakPointTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/ContYieldBreakPointTest/libContYieldBreakPointTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, 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 @@ -28,9 +28,9 @@ extern "C" { -static jvmtiEnv *jvmti = NULL; -static jthread exp_thread = NULL; -static jrawMonitorID event_mon = NULL; +static jvmtiEnv *jvmti = nullptr; +static jthread exp_thread = nullptr; +static jrawMonitorID event_mon = nullptr; static int breakpoint_count = 0; static int single_step_count = 0; @@ -39,11 +39,11 @@ print_frame_event_info(jvmtiEnv *jvmti, JNIEnv* jni, jthread thread, jmethodID m const char* event_name, int event_count) { char* tname = get_thread_name(jvmti, jni, thread); char* cname = get_method_class_name(jvmti, jni, method); - char* mname = NULL; - char* msign = NULL; + char* mname = nullptr; + char* msign = nullptr; jvmtiError err; - err = jvmti->GetMethodName(method, &mname, &msign, NULL); + err = jvmti->GetMethodName(method, &mname, &msign, nullptr); check_jvmti_status(jni, err, "event handler: error in JVMTI GetMethodName call"); LOG("\n%s event #%d: thread: %s, method: %s: %s%s\n", @@ -150,8 +150,8 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { JNIEXPORT void JNICALL Java_ContYieldBreakPointTest_enableEvents(JNIEnv *jni, jclass klass, jthread thread, jclass contKlass) { jint method_count = 0; - jmethodID* methods = NULL; - jmethodID method = NULL; + jmethodID* methods = nullptr; + jmethodID method = nullptr; jlocation location = (jlocation)0L; jvmtiError err; @@ -172,7 +172,7 @@ Java_ContYieldBreakPointTest_enableEvents(JNIEnv *jni, jclass klass, jthread thr } deallocate(jvmti, jni, (void*)mname); } - if (method == NULL) { + if (method == nullptr) { jni->FatalError("Error in enableEvents: not found method fibTest()"); } @@ -180,7 +180,7 @@ Java_ContYieldBreakPointTest_enableEvents(JNIEnv *jni, jclass klass, jthread thr check_jvmti_status(jni, err, "enableEvents: error in JVMTI SetBreakpoint"); // Enable Breakpoint events globally - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, nullptr); check_jvmti_status(jni, err, "enableEvents: error in JVMTI SetEventNotificationMode: enable BREAKPOINT"); LOG("enableEvents: finished\n"); diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/ContinuationTest/libContinuationTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/vthread/ContinuationTest/libContinuationTest.cpp index c2bc14887b0..81cc1368ad8 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/ContinuationTest/libContinuationTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/ContinuationTest/libContinuationTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,9 +30,9 @@ extern "C" { #define MAX_FRAME_COUNT 20 #define FRAMES_TO_NOTIFY_POP 7 -static jvmtiEnv *jvmti = NULL; -static jthread exp_thread = NULL; -static jrawMonitorID event_mon = NULL; +static jvmtiEnv *jvmti = nullptr; +static jthread exp_thread = nullptr; +static jrawMonitorID event_mon = nullptr; static int method_entry_count = 0; static int frame_pop_count = 0; @@ -40,13 +40,13 @@ static void print_frame_event_info(jvmtiEnv *jvmti, JNIEnv* jni, jthread thread, jmethodID method, const char* event_name) { char* tname = get_thread_name(jvmti, jni, thread); char* cname = get_method_class_name(jvmti, jni, method); - char* mname = NULL; - char* msign = NULL; + char* mname = nullptr; + char* msign = nullptr; jboolean is_virtual = jni->IsVirtualThread(thread); const char* virt = is_virtual ? "virtual" : "carrier"; jvmtiError err; - err = jvmti->GetMethodName(method, &mname, &msign, NULL); + err = jvmti->GetMethodName(method, &mname, &msign, nullptr); check_jvmti_status(jni, err, "event handler: error in JVMTI GetMethodName call"); if (strcmp(event_name, "MethodEntry") == 0) { @@ -78,7 +78,7 @@ MethodEntry(jvmtiEnv *jvmti, JNIEnv* jni, jthread thread, jmethodID method) { // Request FramePop notifications for all continuation frames. // They all are expected to be cleared as a part of yield protocol. for (jint depth = 0; depth < FRAMES_TO_NOTIFY_POP; depth++) { - jmethodID frame_method = NULL; + jmethodID frame_method = nullptr; jlocation location = 0LL; err = jvmti->NotifyFramePop(thread, depth); diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/FollowReferences/VThreadStackRefTest.java b/test/hotspot/jtreg/serviceability/jvmti/vthread/FollowReferences/VThreadStackRefTest.java index 5d965ed1d69..7b8b8e47519 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/FollowReferences/VThreadStackRefTest.java +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/FollowReferences/VThreadStackRefTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, 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 @@ -26,7 +26,7 @@ * @requires vm.jvmti * @requires vm.continuations * @run main/othervm/native - * -Djdk.virtualThreadScheduler.parallelism=1 + * -Djdk.virtualThreadScheduler.maxPoolSize=1 * -agentlib:VThreadStackRefTest * VThreadStackRefTest */ diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/ForceEarlyReturnTest/libForceEarlyReturnTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/vthread/ForceEarlyReturnTest/libForceEarlyReturnTest.cpp index 86cdf781f7f..4407c5d074d 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/ForceEarlyReturnTest/libForceEarlyReturnTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/ForceEarlyReturnTest/libForceEarlyReturnTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, 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 @@ -28,9 +28,9 @@ extern "C" { -static jvmtiEnv *jvmti = NULL; -static jmethodID mid_B = NULL; -static jrawMonitorID monitor = NULL; +static jvmtiEnv *jvmti = nullptr; +static jmethodID mid_B = nullptr; +static jrawMonitorID monitor = nullptr; static volatile bool bp_sync_reached = false; static void JNICALL @@ -55,7 +55,7 @@ Breakpoint(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread, check_jvmti_status(jni, err, "Breakpoint: Failed in JVMTI GetLocalInt"); if (force_return != 0) { - jobject ret_obj = NULL; + jobject ret_obj = nullptr; err = jvmti->ClearBreakpoint(mid_B, 0); check_jvmti_status(jni, err, "Breakpoint: Failed in JVMTI ClearBreakpoint"); @@ -79,7 +79,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { LOG("Agent init\n"); res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Agent init: Failed in GetEnv!\n"); return JNI_ERR; } @@ -124,17 +124,17 @@ Java_ForceEarlyReturnTest_prepareAgent(JNIEnv *jni, jclass cls, jclass task_claz LOG("Main: prepareAgent started\n"); - if (jvmti == NULL) { + if (jvmti == nullptr) { fatal(jni, "prepareAgent: Failed as JVMTI client was not properly loaded!\n"); } mid_B = jni->GetStaticMethodID(task_clazz, "B", "(ZLjava/lang/String;)Ljava/lang/String;"); - if (mid_B == NULL) { + if (mid_B == nullptr) { fatal(jni, "prepareAgent: Failed to find Method ID for method: TestTask.B()\n"); } err = jvmti->SetBreakpoint(mid_B, 0); // location: 0 check_jvmti_status(jni, err, "prepareAgent: Failed in JVMTI SetBreakpoint"); - set_event_notification_mode(jvmti, JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL); + set_event_notification_mode(jvmti, JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, nullptr); LOG("Main: prepareAgent finished\n"); } diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/GetSetLocalTest/libGetSetLocalTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/vthread/GetSetLocalTest/libGetSetLocalTest.cpp index c127e9fff9b..20b2edb1e9d 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/GetSetLocalTest/libGetSetLocalTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/GetSetLocalTest/libGetSetLocalTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, 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 @@ typedef struct Values { } Values; static const int MAX_EVENTS_TO_PROCESS = 20; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static volatile jboolean completed = JNI_FALSE; static void @@ -60,7 +60,7 @@ set_breakpoint(JNIEnv *jni, jclass klass, const char *mname, jlocation location) jmethodID method = find_method(jvmti, jni, klass, mname); jvmtiError err; - if (method == NULL) { + if (method == nullptr) { LOG("set_breakpoint: Failed to find method %s()\n", mname); fatal(jni, "set_breakpoint: not found method"); } @@ -88,10 +88,10 @@ find_method_depth(jvmtiEnv *jvmti, JNIEnv *jni, jthread vthread, const char *mna for (int depth = 0; depth < count; depth++) { jmethodID method = frames[depth].method; - char* name = NULL; - char* sign = NULL; + char* name = nullptr; + char* sign = nullptr; - err = jvmti->GetMethodName(method, &name, &sign, NULL); + err = jvmti->GetMethodName(method, &name, &sign, nullptr); if (err == JVMTI_ERROR_WRONG_PHASE || err == JVMTI_ERROR_THREAD_NOT_ALIVE) { return -1; // VM or target thread completed its work } @@ -107,15 +107,15 @@ find_method_depth(jvmtiEnv *jvmti, JNIEnv *jni, jthread vthread, const char *mna static void test_GetLocal(jvmtiEnv *jvmti, JNIEnv *jni, jthread cthread, jthread vthread, int depth, int frame_count, Values *exp_values) { - jobject msg = NULL; - jobject tt = NULL; + jobject msg = nullptr; + jobject tt = nullptr; jint ii = 0; jlong ll = 0L; jfloat ff = 0.0; jdouble dd = 0.0; jvmtiError err; - LOG("test_GetLocal: mounted: %d depth: %d fcount: %d\n", cthread != NULL, depth, frame_count); + LOG("test_GetLocal: mounted: %d depth: %d fcount: %d\n", cthread != nullptr, depth, frame_count); int dep = find_method_depth(jvmti, jni, vthread, "producer"); if (dep == -1) { @@ -126,7 +126,7 @@ test_GetLocal(jvmtiEnv *jvmti, JNIEnv *jni, jthread cthread, jthread vthread, } // #0: Test JVMTI GetLocalInstance function for carrier thread - if (cthread != NULL) { + if (cthread != nullptr) { suspend_thread(jvmti, jni, cthread); err = jvmti->GetLocalInstance(cthread, 3, &msg); @@ -165,18 +165,18 @@ test_GetLocal(jvmtiEnv *jvmti, JNIEnv *jni, jthread cthread, jthread vthread, " to return JVMTI_ERROR_INVALID_SLOT or JVMTI_ERROR_TYPE_MISMATCH"); } - // #5: Test JVMTI GetLocalObject function with NULL value_ptr - err = jvmti->GetLocalObject(vthread, depth, SlotString, NULL); + // #5: Test JVMTI GetLocalObject function with nullptr value_ptr + err = jvmti->GetLocalObject(vthread, depth, SlotString, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { - LOG("JVMTI GetLocalObject with NULL value_ptr returned error: %d\n", err); - fatal(jni, "JVMTI GetLocalObject with NULL value_ptr failed to return JVMTI_ERROR_NULL_POINTER"); + LOG("JVMTI GetLocalObject with null value_ptr returned error: %d\n", err); + fatal(jni, "JVMTI GetLocalObject with null value_ptr failed to return JVMTI_ERROR_NULL_POINTER"); } // #6: Test JVMTI GetLocal functions with a good vthread err = jvmti->GetLocalObject(vthread, depth, SlotString, &msg); check_jvmti_status(jni, err, "error in JVMTI GetLocalObject with good vthread"); - const char* str = jni->GetStringUTFChars((jstring)msg, NULL); + const char* str = jni->GetStringUTFChars((jstring)msg, nullptr); LOG(" local String value at slot %d: %s\n", SlotString, str); const char* exp_str = "msg: ..."; if (strncmp(str, exp_str, 5) != 0) { @@ -189,7 +189,7 @@ test_GetLocal(jvmtiEnv *jvmti, JNIEnv *jni, jthread cthread, jthread vthread, check_jvmti_status(jni, err, "error in JVMTI GetLocalObject with good vthread"); LOG(" local Thread value at slot %d: %p\n", SlotThread, (void*)tt); - if (exp_values->tt != NULL && !jni->IsSameObject(tt, exp_values->tt)) { + if (exp_values->tt != nullptr && !jni->IsSameObject(tt, exp_values->tt)) { LOG(" Failed: Expected local Thread value: %p, got: %p\n", exp_values->tt, tt); fatal(jni, "JVMTI GetLocalObject returned unexpected local Thread value"); } @@ -239,7 +239,7 @@ test_SetLocal(jvmtiEnv *jvmti, JNIEnv *jni, jthread cthread, jthread vthread, int depth, int frame_count, Values *values, bool at_event) { jvmtiError err; - LOG("test_SetLocal: mounted: %d depth: %d fcount: %d\n", cthread != NULL, depth, frame_count); + LOG("test_SetLocal: mounted: %d depth: %d fcount: %d\n", cthread != nullptr, depth, frame_count); // #1: Test JVMTI SetLocalObject function with negative frame depth err = jvmti->SetLocalObject(vthread, -1, SlotString, values->tt); @@ -257,7 +257,7 @@ test_SetLocal(jvmtiEnv *jvmti, JNIEnv *jni, jthread cthread, jthread vthread, // #3: Test JVMTI SetLocalObject function with invalid slot -1 err = jvmti->SetLocalObject(vthread, depth, SlotInvalid0, values->tt); - if (depth > 0 || cthread == NULL) { + if (depth > 0 || cthread == nullptr) { // JVMTI_ERROR_OPAQUE_FRAME can be returned for unmouted vthread or depth > 0 if (err != JVMTI_ERROR_OPAQUE_FRAME) { LOG("JVMTI SetLocalObject for unmounted vthread or depth > 0 failed to return JVMTI_ERROR_OPAQUE_FRAME: %d\n", err); @@ -271,14 +271,14 @@ test_SetLocal(jvmtiEnv *jvmti, JNIEnv *jni, jthread cthread, jthread vthread, // #4: Test JVMTI SetLocalObject function with unaligned slot 4 err = jvmti->SetLocalObject(vthread, depth, SlotUnaligned, values->tt); - if (depth > 0 || cthread == NULL) { + if (depth > 0 || cthread == nullptr) { // JVMTI_ERROR_OPAQUE_FRAME can be returned for unmouted vthread or depth > 0 if (err != JVMTI_ERROR_OPAQUE_FRAME) { LOG("JVMTI SetLocalObject for unmounted vthread or depth > 0 failed to return JVMTI_ERROR_OPAQUE_FRAME: %d\n", err); fatal(jni, "JVMTI SetLocalObject for unmounted vthread or depth > 0 failed to return JVMTI_ERROR_OPAQUE_FRAME"); } } - else if (cthread != NULL && err != JVMTI_ERROR_INVALID_SLOT && err != JVMTI_ERROR_TYPE_MISMATCH) { + else if (cthread != nullptr && err != JVMTI_ERROR_INVALID_SLOT && err != JVMTI_ERROR_TYPE_MISMATCH) { LOG("JVMTI SetLocalObject with unaligned slot 4 returned error: %d\n", err); fatal(jni, "JVMTI SetLocalObject with unaligned slot 4 failed" " to return JVMTI_ERROR_INVALID_SLOT or JVMTI_ERROR_TYPE_MISMATCH"); @@ -286,7 +286,7 @@ test_SetLocal(jvmtiEnv *jvmti, JNIEnv *jni, jthread cthread, jthread vthread, // #6: Test JVMTI SetLocal functions with a good vthread err = jvmti->SetLocalObject(vthread, depth, SlotThread, values->tt); - if (depth > 0 || cthread == NULL) { + if (depth > 0 || cthread == nullptr) { if (err != JVMTI_ERROR_OPAQUE_FRAME) { LOG("JVMTI SetLocalObject for unmounted vthread or depth > 0 failed to return JVMTI_ERROR_OPAQUE_FRAME: %d\n", err); fatal(jni, "JVMTI SetLocalObject for unmounted vthread pr depth > 0failed to return JVMTI_ERROR_OPAQUE_FRAME"); @@ -314,8 +314,8 @@ test_SetLocal(jvmtiEnv *jvmti, JNIEnv *jni, jthread cthread, jthread vthread, static void test_GetSetLocal(jvmtiEnv *jvmti, JNIEnv* jni, jthread vthread, int depth, int frame_count, bool at_event) { - Values values0 = { NULL, NULL, 1, 2L, (jfloat)3.2F, (jdouble)4.500000047683716 }; - Values values1 = { NULL, NULL, 2, 3L, (jfloat)4.2F, (jdouble)5.500000047683716 }; + Values values0 = { nullptr, nullptr, 1, 2L, (jfloat)3.2F, (jdouble)4.500000047683716 }; + Values values1 = { nullptr, nullptr, 2, 3L, (jfloat)4.2F, (jdouble)5.500000047683716 }; jthread cthread = get_carrier_thread(jvmti, jni, vthread); values0.tt = vthread; @@ -329,7 +329,7 @@ test_GetSetLocal(jvmtiEnv *jvmti, JNIEnv* jni, jthread vthread, int depth, int f if (!success) { goto End; // skip testing for compiled frame that can't be deoptimized } - if (depth > 0 || cthread == NULL) { + if (depth > 0 || cthread == nullptr) { // No values are expected to be set by SetLocal above as // unmounted virtual thread case is not supported. // So, we expect local values to remain the same. @@ -368,8 +368,8 @@ Breakpoint(jvmtiEnv *jvmti, JNIEnv* jni, jthread vthread, test_GetSetLocal(jvmti, jni, vthread, depth, frame_count, true /* at_event */); // vthread passed to callback has to refer to current thread, - // so we can also test with NULL in place of vthread. - test_GetSetLocal(jvmti, jni, NULL, depth, frame_count, true /* at_event */); + // so we can also test with nullptr in place of vthread. + test_GetSetLocal(jvmti, jni, nullptr, depth, frame_count, true /* at_event */); } deallocate(jvmti, jni, (void*)mname); deallocate(jvmti, jni, (void*)tname); @@ -439,7 +439,7 @@ Java_GetSetLocalTest_testSuspendedVirtualThreads(JNIEnv *jni, jclass klass, jthr // Test each of these cases only once: unmounted, positive depth, frame count 0. while (iter++ < 50 && (!seen_depth_0 || !seen_depth_positive || !seen_unmounted)) { - jmethodID method = NULL; + jmethodID method = nullptr; jlocation location = 0; sleep_ms(1); @@ -460,7 +460,7 @@ Java_GetSetLocalTest_testSuspendedVirtualThreads(JNIEnv *jni, jclass klass, jthr } bool case_0 = !seen_depth_0 && depth == 0 && (int)location >= 30; bool case_1 = !seen_depth_positive && depth > 0 && (int)location >= 30; - bool case_2 = !seen_unmounted && depth >= 0 && cthread == NULL; + bool case_2 = !seen_unmounted && depth >= 0 && cthread == nullptr; if (case_0) { LOG("testSuspendedVirtualThreads: DEPTH == 0\n"); diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/HeapDump/VThreadInHeapDump.java b/test/hotspot/jtreg/serviceability/jvmti/vthread/HeapDump/VThreadInHeapDump.java index 2243a1d37b6..de64706a896 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/HeapDump/VThreadInHeapDump.java +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/HeapDump/VThreadInHeapDump.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, 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 @@ -184,7 +184,7 @@ private static void createDump(File dumpFile, String[] extraOptions) throws Exce theApp = new VThreadInHeapDumpTarg(); List extraVMArgs = new ArrayList<>(); - extraVMArgs.add("-Djdk.virtualThreadScheduler.parallelism=1"); + extraVMArgs.add("-Djdk.virtualThreadScheduler.maxPoolSize=1"); extraVMArgs.add("-Xlog:heapdump"); extraVMArgs.addAll(Arrays.asList(extraOptions)); LingeredApp.startApp(theApp, extraVMArgs.toArray(new String[0])); diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/InterruptThreadTest/libInterruptThreadTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/vthread/InterruptThreadTest/libInterruptThreadTest.cpp index f601aa15e3f..6be49bfb456 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/InterruptThreadTest/libInterruptThreadTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/InterruptThreadTest/libInterruptThreadTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, 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 @@ -29,7 +29,7 @@ extern "C" { -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static void JNICALL agent_proc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/MethodExitTest/libMethodExitTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/vthread/MethodExitTest/libMethodExitTest.cpp index 9676d583206..fb6b0bab587 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/MethodExitTest/libMethodExitTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/MethodExitTest/libMethodExitTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, 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 @@ -27,9 +27,9 @@ extern "C" { -static jvmtiEnv *jvmti = NULL; -static jthread exp_thread = NULL; -static jrawMonitorID event_mon = NULL; +static jvmtiEnv *jvmti = nullptr; +static jthread exp_thread = nullptr; +static jrawMonitorID event_mon = nullptr; static int vthread_mounted_count = 0; static int vthread_unmounted_count = 0; static int breakpoint_count = 0; @@ -41,9 +41,9 @@ static jboolean received_method_exit_event = JNI_FALSE; static jboolean passed = JNI_TRUE; static bool done = false; -static jmethodID *test_methods = NULL; +static jmethodID *test_methods = nullptr; jint test_method_count = 0; -jclass test_class = NULL; +jclass test_class = nullptr; static void print_frame_event_info(jvmtiEnv *jvmti, JNIEnv* jni, jthread thread, jmethodID method, @@ -79,7 +79,7 @@ set_or_clear_breakpoint(JNIEnv *jni, jboolean set, const char *methodName, jclass klass, jmethodID methods[], int method_count) { jlocation location = (jlocation)0L; - jmethodID method = NULL; + jmethodID method = nullptr; jvmtiError err; // Find the jmethodID of the specified method @@ -93,7 +93,7 @@ set_or_clear_breakpoint(JNIEnv *jni, jboolean set, const char *methodName, } deallocate(jvmti, jni, (void*)mname); } - if (method == NULL) { + if (method == nullptr) { LOG("setupBreakpoint: not found method %s() to %s a breakpoint\n", methodName, set ? "set" : "clear"); jni->FatalError("Error in setupBreakpoint: not found method"); @@ -131,7 +131,7 @@ breakpoint_hit1(jvmtiEnv *jvmti, JNIEnv* jni, jthread thread, jthread cthread, jboolean is_virtual, char* mname) { char* tname = get_thread_name(jvmti, jni, cthread); - jthread vthread = NULL; + jthread vthread = nullptr; jvmtiError err; // Test GetVirtualThread for carrier thread. @@ -161,10 +161,10 @@ breakpoint_hit1(jvmtiEnv *jvmti, JNIEnv* jni, LOG("GetThreadLocalStorage for carrier thread returned value %p as expected\n\n", tls_data); } { - jmethodID method = NULL; + jmethodID method = nullptr; jlocation loc = 0L; - char* mname1 = NULL; - char* cname1 = NULL; + char* mname1 = nullptr; + char* cname1 = nullptr; err = jvmti->GetFrameLocation(cthread, 0, &method, &loc); check_jvmti_status(jni, err, "Breakpoint: error in JVMTI GetFrameLocation"); @@ -252,7 +252,7 @@ breakpoint_hit3(jvmtiEnv *jvmti, JNIEnv* jni, // Disable breakpoint events. clear_breakpoint(jni, "brkpt", test_class, test_methods, test_method_count); - set_event_notification_mode(jvmti, jni, JVMTI_DISABLE, JVMTI_EVENT_BREAKPOINT, NULL); + set_event_notification_mode(jvmti, jni, JVMTI_DISABLE, JVMTI_EVENT_BREAKPOINT, nullptr); // Disable METHOD_EXIT events on the vthread. LOG("Hit #3: Breakpoint: %s: disabling MethodExit events on virtual thread: %p\n", mname, (void*)thread); @@ -279,7 +279,7 @@ Breakpoint(jvmtiEnv *jvmti, JNIEnv* jni, jthread thread, if (done) { return; // avoid failures with JVMTI_ERROR_WRONG_PHASE } - jthread cthread = NULL; + jthread cthread = nullptr; char* mname = get_method_name(jvmti, jni, method); jboolean is_virtual = jni->IsVirtualThread(thread); @@ -347,7 +347,7 @@ MethodExit(jvmtiEnv *jvmti, JNIEnv* jni, jthread thread, jmethodID method, } // print_frame_event_info(jvmti, jni, thread, method, "MethodExit", method_exit_count); - if (strstr(mname, "brkpt") != NULL) { // event IS in the "brkpt" method + if (strstr(mname, "brkpt") != nullptr) { // event IS in the "brkpt" method LOG("Hit #%d: MethodExit #%d: method: %s on thread: %p\n", brkptBreakpointHit, method_exit_count, mname, (void*)thread); received_method_exit_event = JNI_TRUE; // set it for brkpt method only if brkptBreakpointHit > 1 @@ -433,15 +433,15 @@ VirtualThreadMount(jvmtiEnv *jvmti, ...) { if (done) { return; // avoid failures with JVMTI_ERROR_WRONG_PHASE } - jmethodID method = NULL; + jmethodID method = nullptr; jlocation loc = 0L; - char* mname = NULL; - char* cname = NULL; + char* mname = nullptr; + char* cname = nullptr; jvmtiError err; va_list ap; - JNIEnv* jni = NULL; - jthread thread = NULL; + JNIEnv* jni = nullptr; + jthread thread = nullptr; va_start(ap, jvmti); jni = va_arg(ap, JNIEnv*); @@ -478,15 +478,15 @@ VirtualThreadUnmount(jvmtiEnv *jvmti, ...) { if (done) { return; // avoid failures with JVMTI_ERROR_WRONG_PHASE } - jmethodID method = NULL; + jmethodID method = nullptr; jlocation loc = 0L; - char* mname = NULL; - char* cname = NULL; + char* mname = nullptr; + char* cname = nullptr; jvmtiError err; va_list ap; - JNIEnv* jni = NULL; - jthread thread = NULL; + JNIEnv* jni = nullptr; + jthread thread = nullptr; va_start(ap, jvmti); jni = va_arg(ap, JNIEnv*); @@ -562,9 +562,9 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { LOG("Agent_OnLoad: Error in JVMTI SetEventCallbacks: %d\n", err); return JNI_ERR; } - set_event_notification_mode(jvmti, JVMTI_ENABLE, JVMTI_EVENT_FRAME_POP, NULL); - set_event_notification_mode(jvmti, JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, NULL); - set_event_notification_mode(jvmti, JVMTI_ENABLE, JVMTI_EVENT_VIRTUAL_THREAD_START, NULL); + set_event_notification_mode(jvmti, JVMTI_ENABLE, JVMTI_EVENT_FRAME_POP, nullptr); + set_event_notification_mode(jvmti, JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, nullptr); + set_event_notification_mode(jvmti, JVMTI_ENABLE, JVMTI_EVENT_VIRTUAL_THREAD_START, nullptr); event_mon = create_raw_monitor(jvmti, "Events Monitor"); @@ -585,7 +585,7 @@ Java_MethodExitTest_enableEvents(JNIEnv *jni, jclass klass, jthread thread, jcla set_breakpoint(jni, "brkpt", testKlass, test_methods, test_method_count); // Enable Breakpoint events globally - set_event_notification_mode(jvmti, jni, JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL); + set_event_notification_mode(jvmti, jni, JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, nullptr); LOG("enableEvents: finished\n"); } diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/NullAsCurrentThreadTest/libNullAsCurrentThreadTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/vthread/NullAsCurrentThreadTest/libNullAsCurrentThreadTest.cpp index 140375d4cb5..82c51dfed75 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/NullAsCurrentThreadTest/libNullAsCurrentThreadTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/NullAsCurrentThreadTest/libNullAsCurrentThreadTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, 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 @@ -28,7 +28,7 @@ extern "C" { static const jint MAX_FRAME_CNT = 30; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static int vt_support_enabled = 0; static jboolean failed_status = JNI_FALSE; @@ -49,16 +49,16 @@ checkStackTraces(jvmtiEnv* jvmti, JNIEnv* jni, jvmtiFrameInfo* frames0, jvmtiFra for (int idx = 0; idx < cnt; idx++) { jmethodID method0 = frames0[idx].method; jmethodID method1 = frames1[idx].method; - char* name0 = NULL; - char* name1 = NULL; - char* sign0 = NULL; - char* sign1 = NULL; + char* name0 = nullptr; + char* name1 = nullptr; + char* sign0 = nullptr; + char* sign1 = nullptr; - err = jvmti->GetMethodName(method0, &name0, &sign0, NULL); + err = jvmti->GetMethodName(method0, &name0, &sign0, nullptr); check_jvmti_status(jni, err, "GetMethodName"); if (method0 != method1) { - err = jvmti->GetMethodName(method1, &name1, &sign1, NULL); + err = jvmti->GetMethodName(method1, &name1, &sign1, nullptr); check_jvmti_status(jni, err, "GetMethodName"); failed_status = JNI_TRUE; @@ -80,13 +80,13 @@ testGetThreadInfo(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { jvmtiThreadInfo inf0; jvmtiThreadInfo inf1; - err = jvmti->GetThreadInfo(NULL, &inf0); + err = jvmti->GetThreadInfo(nullptr, &inf0); check(jni, "GetThreadInfo", err); err = jvmti->GetThreadInfo(thread, &inf1); check(jni, "GetThreadInfo", err); - const char* name = (inf0.name == NULL) ? "" : inf0.name; + const char* name = (inf0.name == nullptr) ? "" : inf0.name; LOG("Agent: GetThreadInfo: current thread: %s\n", name); if (strcmp(inf0.name, inf1.name) != 0) { @@ -121,7 +121,7 @@ testGetThreadState(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { jint state0 = 0; jint state1 = 0; - err = jvmti->GetThreadState(NULL, &state0); + err = jvmti->GetThreadState(nullptr, &state0); check_jvmti_status(jni, err, "GetThreadState"); err = jvmti->GetThreadState(thread, &state1); @@ -145,7 +145,7 @@ testGetFrameCount(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { err = jvmti->GetFrameCount(thread, &count0); check_jvmti_status(jni, err,"GetFrameCount"); - err = jvmti->GetFrameCount(NULL, &count1); + err = jvmti->GetFrameCount(nullptr, &count1); check_jvmti_status(jni, err,"GetFrameCount"); if (count0 != count1) { @@ -163,24 +163,24 @@ testGetFrameLocation(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { const jint DEPTH = 1; jlocation loc0 = 0; jlocation loc1 = 0; - jmethodID method0 = NULL; - jmethodID method1 = NULL; - char* name0 = NULL; - char* name1 = NULL; - char* sign0 = NULL; - char* sign1 = NULL; - - err = jvmti->GetFrameLocation(NULL, DEPTH, &method0, &loc0); + jmethodID method0 = nullptr; + jmethodID method1 = nullptr; + char* name0 = nullptr; + char* name1 = nullptr; + char* sign0 = nullptr; + char* sign1 = nullptr; + + err = jvmti->GetFrameLocation(nullptr, DEPTH, &method0, &loc0); check_jvmti_status(jni, err, "GetFrameLocation"); err = jvmti->GetFrameLocation(thread, DEPTH, &method1, &loc1); check_jvmti_status(jni, err, "GetFrameLocation"); - err = jvmti->GetMethodName(method0, &name0, &sign0, NULL); + err = jvmti->GetMethodName(method0, &name0, &sign0, nullptr); check_jvmti_status(jni, err, "GetMethodName"); if (method0 != method1) { - err = jvmti->GetMethodName(method1, &name1, &sign1, NULL); + err = jvmti->GetMethodName(method1, &name1, &sign1, nullptr); check_jvmti_status(jni, err, "GetMethodName"); failed_status = JNI_TRUE; @@ -207,7 +207,7 @@ testGetStackTrace(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { memset(frames0, 0, sizeof(frames0)); memset(frames1, 0, sizeof(frames1)); - err = jvmti->GetStackTrace(NULL, 0, MAX_FRAME_CNT, frames0, &count0); + err = jvmti->GetStackTrace(nullptr, 0, MAX_FRAME_CNT, frames0, &count0); check_jvmti_status(jni, err, "GetStackTrace"); err = jvmti->GetStackTrace(thread, 0, MAX_FRAME_CNT, frames1, &count1); @@ -226,8 +226,8 @@ testGetOwnedMonitorInfo(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { jvmtiError err; jint count0 = 0; jint count1 = 0; - jobject* monitors0 = NULL; - jobject* monitors1 = NULL; + jobject* monitors0 = nullptr; + jobject* monitors1 = nullptr; err = jvmti->GetOwnedMonitorInfo(thread, &count0, &monitors0); check_jvmti_status(jni, err, "GetOwnedMonitorInfo"); @@ -263,10 +263,10 @@ testGetOwnedMonitorStackDepthInfo(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) jvmtiError err; jint count0 = 0; jint count1 = 0; - jvmtiMonitorStackDepthInfo* inf0 = NULL; - jvmtiMonitorStackDepthInfo* inf1 = NULL; + jvmtiMonitorStackDepthInfo* inf0 = nullptr; + jvmtiMonitorStackDepthInfo* inf1 = nullptr; - err = jvmti->GetOwnedMonitorStackDepthInfo(NULL, &count0, &inf0); + err = jvmti->GetOwnedMonitorStackDepthInfo(nullptr, &count0, &inf0); check_jvmti_status(jni, err, "GetOwnedMonitorStackDepthInfo"); err = jvmti->GetOwnedMonitorStackDepthInfo(thread, &count1, &inf1); @@ -302,10 +302,10 @@ testGetOwnedMonitorStackDepthInfo(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) static void testGetCurrentContendedMonitor(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { jvmtiError err; - jobject monitor0 = NULL; - jobject monitor1 = NULL; + jobject monitor0 = nullptr; + jobject monitor1 = nullptr; - err = jvmti->GetCurrentContendedMonitor(NULL, &monitor0); + err = jvmti->GetCurrentContendedMonitor(nullptr, &monitor0); check_jvmti_status(jni, err, "GetCurrentContendedMonitor"); err = jvmti->GetCurrentContendedMonitor(thread, &monitor1); @@ -321,17 +321,17 @@ testGetCurrentContendedMonitor(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { } /* - * Execute JVMTI functions with NULL jthread and check the result is correct. + * Execute JVMTI functions with nullptr jthread and check the result is correct. */ JNIEXPORT void JNICALL Java_NullAsCurrentThreadTest_testJvmtiFunctions(JNIEnv *jni, jclass cls) { jvmtiError err; - jthread cur_thr = NULL; + jthread cur_thr = nullptr; err = jvmti->GetCurrentThread(&cur_thr); check(jni, "GetCurrentThread", err); - LOG("Testing JMTI functions accepting NULL jthread as current thread\n"); + LOG("Testing JMTI functions accepting null jthread as current thread\n"); testGetThreadInfo(jvmti, jni, cur_thr); testGetThreadState(jvmti, jni, cur_thr); @@ -395,7 +395,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { if (err != JVMTI_ERROR_NONE) { LOG("Agent_OnLoad: error in JVMTI SetEventCallbacks: %d\n", err); } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, EXT_EVENT_VIRTUAL_THREAD_MOUNT, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, EXT_EVENT_VIRTUAL_THREAD_MOUNT, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("Agent_OnLoad: error in JVMTI SetEventNotificationMode: %d\n", err); } diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/PinnedTaskTest/libPinnedTaskTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/vthread/PinnedTaskTest/libPinnedTaskTest.cpp index f7f740ae9e1..d50d1ab4b8b 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/PinnedTaskTest/libPinnedTaskTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/PinnedTaskTest/libPinnedTaskTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, 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 @@ -26,7 +26,7 @@ extern "C" { -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static void JNICALL agent_proc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/PopFrameTest/libPopFrameTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/vthread/PopFrameTest/libPopFrameTest.cpp index 20e4b940649..327b7d1cb2a 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/PopFrameTest/libPopFrameTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/PopFrameTest/libPopFrameTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, 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 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { LOG("Agent init\n"); res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Agent init: Failed in GetEnv!\n"); return JNI_ERR; } @@ -114,19 +114,19 @@ Java_PopFrameTest_prepareAgent(JNIEnv *jni, jclass cls, jclass task_clazz, jbool LOG("Main: prepareAgent started\n"); - if (jvmti == NULL) { + if (jvmti == nullptr) { fatal(jni, "prepareAgent: Failed as JVMTI client was not properly loaded!\n"); } do_pop_frame = do_pop; mid_B = jni->GetStaticMethodID(task_clazz, "B", "()V"); - if (mid_B == NULL) { + if (mid_B == nullptr) { fatal(jni, "prepareAgent: Failed to find Method ID for method: TestTask.B()\n"); } err = jvmti->SetBreakpoint(mid_B, 0); check_jvmti_status(jni, err, "prepareAgent: Failed in JVMTI SetBreakpoint"); - set_event_notification_mode(jvmti, JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL); + set_event_notification_mode(jvmti, JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, nullptr); LOG("Main: prepareAgent finished\n"); } diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/RawMonitorTest/libRawMonitorTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/vthread/RawMonitorTest/libRawMonitorTest.cpp index 89015fe4bcb..1e7c49af7a9 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/RawMonitorTest/libRawMonitorTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/RawMonitorTest/libRawMonitorTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, 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 @@ -29,7 +29,7 @@ extern "C" { -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jrawMonitorID monitor; JNIEXPORT void JNICALL diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/SelfSuspendDisablerTest/libSelfSuspendDisablerTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/vthread/SelfSuspendDisablerTest/libSelfSuspendDisablerTest.cpp index fdb8110aa57..74a1a3efc0d 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/SelfSuspendDisablerTest/libSelfSuspendDisablerTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/SelfSuspendDisablerTest/libSelfSuspendDisablerTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, 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 @@ -25,7 +25,7 @@ #include "jvmti.h" #include "jvmti_common.h" -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; extern "C" { @@ -50,12 +50,12 @@ Java_SelfSuspendDisablerTest_isSuspended(JNIEnv* jni, jclass cls, jthread thread JNIEXPORT void JNICALL Java_SelfSuspendDisablerTest_suspendAllVirtualThreads(JNIEnv* jni, jclass cls) { - check_jvmti_status(jni, jvmti->SuspendAllVirtualThreads(0, NULL), "Error in SuspendAllVirtualThreads"); + check_jvmti_status(jni, jvmti->SuspendAllVirtualThreads(0, nullptr), "Error in SuspendAllVirtualThreads"); } JNIEXPORT void JNICALL Java_SelfSuspendDisablerTest_resumeAllVirtualThreads(JNIEnv* jni, jclass cls) { - check_jvmti_status(jni, jvmti->ResumeAllVirtualThreads(0, NULL), "Error in ResumeAllVirtualThreads"); + check_jvmti_status(jni, jvmti->ResumeAllVirtualThreads(0, nullptr), "Error in ResumeAllVirtualThreads"); } JNIEXPORT jint JNICALL diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/StopThreadTest/libStopThreadTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/vthread/StopThreadTest/libStopThreadTest.cpp index 9cb9bc4c5a4..ade0e7fb67c 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/StopThreadTest/libStopThreadTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/StopThreadTest/libStopThreadTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, 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 @@ -28,10 +28,10 @@ extern "C" { -static jvmtiEnv *jvmti = NULL; -static jmethodID mid_B = NULL; -static jobject exception_obj = NULL; -static jrawMonitorID monitor = NULL; +static jvmtiEnv *jvmti = nullptr; +static jmethodID mid_B = nullptr; +static jobject exception_obj = nullptr; +static jrawMonitorID monitor = nullptr; static volatile bool bp_sync_reached = false; static void JNICALL @@ -73,7 +73,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { LOG("Agent init\n"); res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Agent init: Failed in GetEnv!\n"); return JNI_ERR; } @@ -118,21 +118,21 @@ Java_StopThreadTest_prepareAgent(JNIEnv *jni, jclass cls, jclass task_clazz, job LOG("Main: prepareAgent started\n"); - if (jvmti == NULL) { + if (jvmti == nullptr) { fatal(jni, "prepareAgent: Failed as JVMTI client was not properly loaded!\n"); } exception_obj = jni->NewGlobalRef(exc_obj); - if (exception_obj == NULL) { + if (exception_obj == nullptr) { fatal(jni, "prepareAgent: Failed in JNI NewGlobalRef\n"); } mid_B = jni->GetStaticMethodID(task_clazz, "B", "()V"); - if (mid_B == NULL) { + if (mid_B == nullptr) { fatal(jni, "prepareAgent: Failed to find Method ID for method: TestTask.B()\n"); } err = jvmti->SetBreakpoint(mid_B, 0); check_jvmti_status(jni, err, "prepareAgent: Failed in JVMTI SetBreakpoint"); - set_event_notification_mode(jvmti, JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL); + set_event_notification_mode(jvmti, JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, nullptr); LOG("Main: prepareAgent finished\n"); } diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/SuspendResume1/SuspendResume1.java b/test/hotspot/jtreg/serviceability/jvmti/vthread/SuspendResume1/SuspendResume1.java index a3fb80a4ec1..96926a389e1 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/SuspendResume1/SuspendResume1.java +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/SuspendResume1/SuspendResume1.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, 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 @@ -29,7 +29,7 @@ * @compile SuspendResume1.java * @run driver jdk.test.lib.FileInstaller . . * @run main/othervm/native/timeout=600 - * -Djava.util.concurrent.ForkJoinPool.common.parallelism=1 + * -Djdk.virtualThreadScheduler.maxPoolSize=1 * -agentlib:SuspendResume1 * SuspendResume1 */ @@ -41,7 +41,6 @@ * @compile SuspendResume1.java * @run driver jdk.test.lib.FileInstaller . . * @run main/othervm/native/timeout=600 - * -Djava.util.concurrent.ForkJoinPool.common.parallelism=1 * -agentlib:SuspendResume1 * -XX:+UnlockExperimentalVMOptions * -XX:-VMContinuations diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/SuspendResume1/libSuspendResume1.cpp b/test/hotspot/jtreg/serviceability/jvmti/vthread/SuspendResume1/libSuspendResume1.cpp index 78f1922f546..9854008c142 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/SuspendResume1/libSuspendResume1.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/SuspendResume1/libSuspendResume1.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, 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 @@ -35,8 +35,8 @@ extern "C" { static const char* CTHREAD_NAME_START = "ForkJoinPool"; static const int CTHREAD_NAME_START_LEN = (int)strlen("ForkJoinPool"); -static jvmtiEnv *jvmti = NULL; -static jrawMonitorID agent_event_lock = NULL; +static jvmtiEnv *jvmti = nullptr; +static jrawMonitorID agent_event_lock = nullptr; static jthread tested_vthreads[VTHREAD_CNT]; static int vthread_no = 0; @@ -48,7 +48,7 @@ test_get_stack_trace(JNIEnv *jni, jthread thread) { static void test_get_thread_list_stack_traces(JNIEnv *jni, bool is_virt, jint thread_cnt, jthread* thread_list) { - jvmtiStackInfo* stack_info_arr = NULL; + jvmtiStackInfo* stack_info_arr = nullptr; LOG("## Agent: test_get_thread_list_stack_traces started: is virtual: %d, count: %d\n\n", is_virt, thread_cnt); @@ -70,9 +70,9 @@ static void test_get_frame_location(JNIEnv* jni, jthread thread, char* tname) { const jint DEPTH = 1; jlocation loc = 0; - jmethodID method = NULL; - char* name = NULL; - char* sign = NULL; + jmethodID method = nullptr; + char* name = nullptr; + char* sign = nullptr; jboolean is_virtual = jni->IsVirtualThread(thread); jvmtiError err = jvmti->GetFrameLocation(thread, DEPTH, &method, &loc); @@ -84,7 +84,7 @@ test_get_frame_location(JNIEnv* jni, jthread thread, char* tname) { } return; } - err = jvmti->GetMethodName(method, &name, &sign, NULL); + err = jvmti->GetMethodName(method, &name, &sign, nullptr); check_jvmti_status(jni, err, "test_get_frame_location: error in JVMTI GetMethodName"); LOG("Agent: GetFrameLocation: frame for current thread %s: method: %s%s, loc: %lld\n", @@ -93,7 +93,7 @@ test_get_frame_location(JNIEnv* jni, jthread thread, char* tname) { static jint get_cthreads(JNIEnv* jni, jthread** cthreads_p) { - jthread* tested_cthreads = NULL; + jthread* tested_cthreads = nullptr; jint all_cnt = 0; jint ct_cnt = 0; @@ -313,7 +313,7 @@ test_jvmti_functions_for_threads(JNIEnv* jni, bool is_virt, jint thread_cnt, jth JNIEXPORT void JNICALL Java_SuspendResume1_TestSuspendResume(JNIEnv* jni, jclass cls) { - jthread* tested_cthreads = NULL; + jthread* tested_cthreads = nullptr; jint cthread_cnt = 0; LOG("\n## TestSuspendResume: Test carrier threads\n"); @@ -395,7 +395,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_VIRTUAL_THREAD_START, NULL); + JVMTI_EVENT_VIRTUAL_THREAD_START, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("Agent init: error in JVMTI SetEventNotificationMode: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/SuspendResume2/SuspendResume2.java b/test/hotspot/jtreg/serviceability/jvmti/vthread/SuspendResume2/SuspendResume2.java index 5d3dceff83f..65381468ba9 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/SuspendResume2/SuspendResume2.java +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/SuspendResume2/SuspendResume2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, 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 @@ -28,7 +28,7 @@ * @compile SuspendResume2.java * @run driver jdk.test.lib.FileInstaller . . * @run main/othervm/native - * -Djava.util.concurrent.ForkJoinPool.common.parallelism=1 + * -Djdk.virtualThreadScheduler.maxPoolSize=1 * -agentlib:SuspendResume2 * SuspendResume2 */ @@ -40,7 +40,6 @@ * @compile SuspendResume2.java * @run driver jdk.test.lib.FileInstaller . . * @run main/othervm/native - * -Djava.util.concurrent.ForkJoinPool.common.parallelism=1 * -agentlib:SuspendResume2 * -XX:+UnlockExperimentalVMOptions * -XX:-VMContinuations diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/SuspendResume2/libSuspendResume2.cpp b/test/hotspot/jtreg/serviceability/jvmti/vthread/SuspendResume2/libSuspendResume2.cpp index 56faa994be5..97cae4f0f0c 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/SuspendResume2/libSuspendResume2.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/SuspendResume2/libSuspendResume2.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, 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 @@ -35,16 +35,16 @@ extern "C" { static const char* CTHREAD_NAME_START = "ForkJoinPool"; static const int CTHREAD_NAME_START_LEN = (int)strlen("ForkJoinPool"); -static jvmtiEnv *jvmti = NULL; -static jrawMonitorID agent_event_lock = NULL; -static volatile jthread agent_thread = NULL; +static jvmtiEnv *jvmti = nullptr; +static jrawMonitorID agent_event_lock = nullptr; +static volatile jthread agent_thread = nullptr; static jthread tested_vthreads[VTHREAD_CNT]; static int vthread_no = 0; static jint get_cthreads(JNIEnv* jni, jthread** cthreads_p) { - jthread* tested_cthreads = NULL; + jthread* tested_cthreads = nullptr; jint all_cnt = 0; jint ct_cnt = 0; @@ -106,7 +106,7 @@ test_vthread_suspend_all(JNIEnv* jni, const jthread* thread_list, int suspend_ma LOG("\n## Agent: test_vthread_suspend_all started\n"); const jint EXCLUDE_CNT = 2; - jthread exclude_list[EXCLUDE_CNT] = { NULL, NULL }; + jthread exclude_list[EXCLUDE_CNT] = { nullptr, nullptr }; for (int idx = 0; idx < EXCLUDE_CNT; idx++) { exclude_list[idx] = thread_list[idx]; } @@ -138,7 +138,7 @@ test_vthread_resume_all(JNIEnv* jni, const jthread* thread_list, int suspend_mas LOG("\n## Agent: test_vthread_resume_all started\n"); const jint EXCLUDE_CNT = 2; - jthread exclude_list[EXCLUDE_CNT] = { NULL, NULL }; + jthread exclude_list[EXCLUDE_CNT] = { nullptr, nullptr }; for (int idx = 0; idx < EXCLUDE_CNT; idx++) { exclude_list[idx] = thread_list[idx]; } @@ -224,7 +224,7 @@ check_threads_resumed_state(JNIEnv* jni, const jthread* thread_list, int thread_ JNIEXPORT void JNICALL Java_SuspendResume2_TestSuspendResume(JNIEnv* jni, jclass cls) { - jthread* tested_cthreads = NULL; + jthread* tested_cthreads = nullptr; LOG("\n## TestSuspendResume: started\n"); @@ -310,7 +310,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_VIRTUAL_THREAD_START, NULL); + JVMTI_EVENT_VIRTUAL_THREAD_START, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("Agent init: error in JVMTI SetEventNotificationMode: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/SuspendResumeAll/SuspendResumeAll.java b/test/hotspot/jtreg/serviceability/jvmti/vthread/SuspendResumeAll/SuspendResumeAll.java index 2e3ac4736fd..342ba3ea996 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/SuspendResumeAll/SuspendResumeAll.java +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/SuspendResumeAll/SuspendResumeAll.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, 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 @@ -28,7 +28,7 @@ * @compile SuspendResumeAll.java * @run driver jdk.test.lib.FileInstaller . . * @run main/othervm/native - * -Djava.util.concurrent.ForkJoinPool.common.parallelism=1 + * -Djdk.virtualThreadScheduler.maxPoolSize=1 * -agentlib:SuspendResumeAll * SuspendResumeAll */ @@ -40,7 +40,6 @@ * @compile SuspendResumeAll.java * @run driver jdk.test.lib.FileInstaller . . * @run main/othervm/native - * -Djava.util.concurrent.ForkJoinPool.common.parallelism=1 * -agentlib:SuspendResumeAll * -XX:+UnlockExperimentalVMOptions * -XX:-VMContinuations diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/SuspendResumeAll/libSuspendResumeAll.cpp b/test/hotspot/jtreg/serviceability/jvmti/vthread/SuspendResumeAll/libSuspendResumeAll.cpp index 7270d237d74..4aef71c8737 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/SuspendResumeAll/libSuspendResumeAll.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/SuspendResumeAll/libSuspendResumeAll.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, 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 @@ -35,21 +35,21 @@ extern "C" { static const char* CTHREAD_NAME_START = "ForkJoinPool"; static const int CTHREAD_NAME_START_LEN = (int)strlen("ForkJoinPool"); -static jvmtiEnv *jvmti = NULL; -static jrawMonitorID agent_event_lock = NULL; -static volatile jthread agent_thread = NULL; +static jvmtiEnv *jvmti = nullptr; +static jrawMonitorID agent_event_lock = nullptr; +static volatile jthread agent_thread = nullptr; static jthread tested_vthreads[VTHREAD_CNT]; static int vthread_no = 0; -static jmethodID *test_methods = NULL; +static jmethodID *test_methods = nullptr; jint test_method_count = 0; -jclass test_class = NULL; +jclass test_class = nullptr; static void set_or_clear_breakpoint(JNIEnv *jni, jboolean set, const char *methodName, jclass klass, jmethodID methods[], int method_count) { jlocation location = (jlocation)0L; - jmethodID method = NULL; + jmethodID method = nullptr; jvmtiError err; // Find the jmethodID of the specified method @@ -63,7 +63,7 @@ set_or_clear_breakpoint(JNIEnv *jni, jboolean set, const char *methodName, } deallocate(jvmti, jni, (void*)mname); } - if (method == NULL) { + if (method == nullptr) { LOG("setupBreakpoint: not found method %s() to %s a breakpoint\n", methodName, set ? "set" : "clear"); jni->FatalError("Error in setupBreakpoint: not found method"); @@ -109,7 +109,7 @@ Java_SuspendResumeAll_setBreakpoint(JNIEnv *jni, jclass klass, jclass testKlass) static jint get_cthreads(JNIEnv* jni, jthread** cthreads_p) { - jthread* tested_cthreads = NULL; + jthread* tested_cthreads = nullptr; jint all_cnt = 0; jint ct_cnt = 0; @@ -171,7 +171,7 @@ test_vthread_suspend_all(JNIEnv* jni, const jthread* thread_list, int suspend_ma LOG("\n## Agent: test_vthread_suspend_all started\n"); const jint EXCLUDE_CNT = 2; - jthread exclude_list[EXCLUDE_CNT] = { NULL, NULL }; + jthread exclude_list[EXCLUDE_CNT] = { nullptr, nullptr }; for (int idx = 0; idx < EXCLUDE_CNT; idx++) { exclude_list[idx] = thread_list[idx]; } @@ -204,7 +204,7 @@ test_vthread_resume_all(JNIEnv* jni, const jthread* thread_list, int suspend_mas LOG("\n## Agent: test_vthread_resume_all started\n"); const jint EXCLUDE_CNT = 2; - jthread exclude_list[EXCLUDE_CNT] = { NULL, NULL }; + jthread exclude_list[EXCLUDE_CNT] = { nullptr, nullptr }; for (int idx = 0; idx < EXCLUDE_CNT; idx++) { exclude_list[idx] = thread_list[idx]; // Enable Breakpoint events on excluded thread @@ -264,7 +264,7 @@ check_threads_resumed_state(JNIEnv* jni, const jthread* thread_list, int thread_ JNIEXPORT void JNICALL Java_SuspendResumeAll_TestSuspendResume(JNIEnv* jni, jclass cls) { - jthread* tested_cthreads = NULL; + jthread* tested_cthreads = nullptr; jint cthread_cnt = get_cthreads(jni, &tested_cthreads); LOG("\n## TestSuspendResume: started\n"); @@ -368,7 +368,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_VIRTUAL_THREAD_START, NULL); + JVMTI_EVENT_VIRTUAL_THREAD_START, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("Agent init: error in JVMTI SetEventNotificationMode: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/ThreadListStackTracesTest/libThreadListStackTracesTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/vthread/ThreadListStackTracesTest/libThreadListStackTracesTest.cpp index 7441343ac40..3edb2871cc2 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/ThreadListStackTracesTest/libThreadListStackTracesTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/ThreadListStackTracesTest/libThreadListStackTracesTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ extern "C" { JNIEXPORT jint JNICALL Java_ThreadListStackTracesTest_getStateSingle(JNIEnv* jni, jclass clazz, jthread vthread) { - jvmtiStackInfo* info = NULL; + jvmtiStackInfo* info = nullptr; jvmtiError err = jvmti->GetThreadListStackTraces(1, &vthread, MAX_FRAME_COUNT, &info); check_jvmti_status(jni, err, "getStateSingle: error in JVMTI GetThreadListStackTraces"); @@ -45,7 +45,7 @@ Java_ThreadListStackTracesTest_getStateSingle(JNIEnv* jni, jclass clazz, jthread JNIEXPORT jint JNICALL Java_ThreadListStackTracesTest_getStateMultiple(JNIEnv* jni, jclass clazz, jthread vhread, jthread other) { jthread threads[2] = { vhread, other }; - jvmtiStackInfo* info = NULL; + jvmtiStackInfo* info = nullptr; jvmtiError err = jvmti->GetThreadListStackTraces(2, threads, MAX_FRAME_COUNT, &info); check_jvmti_status(jni, err, "getStateMultiple: error in JVMTI GetThreadListStackTraces"); diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/ThreadStateTest/libThreadStateTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/vthread/ThreadStateTest/libThreadStateTest.cpp index 895a2ba198e..c07b0924cfe 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/ThreadStateTest/libThreadStateTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/ThreadStateTest/libThreadStateTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, 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 @@ -87,7 +87,7 @@ JNIEXPORT void JNICALL Java_ThreadStateTest_testGetThreadListStackTraces(JNIEnv* jni, jclass klass, jthread vthread) { jthread cthread = get_carrier_thread(jvmti, jni, vthread); jthread threads[2] = { cthread, vthread }; - jvmtiStackInfo* stackInfo = NULL; + jvmtiStackInfo* stackInfo = nullptr; jvmtiError err = jvmti->GetThreadListStackTraces(2, threads, MAX_FRAME_COUNT, &stackInfo); check_jvmti_status(jni, err, "testGetThreadState: error in JVMTI GetThreadListStackTraces"); diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/ToggleNotifyJvmtiTest/libToggleNotifyJvmtiTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/vthread/ToggleNotifyJvmtiTest/libToggleNotifyJvmtiTest.cpp index 1cf4a06592c..9ecece684ab 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/ToggleNotifyJvmtiTest/libToggleNotifyJvmtiTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/ToggleNotifyJvmtiTest/libToggleNotifyJvmtiTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, 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,13 +34,13 @@ static volatile int vthread_ended_cnt = 0; static volatile int thread_started_cnt = 0; static volatile int thread_ended_cnt = 0; -static jrawMonitorID agent_lock = NULL; +static jrawMonitorID agent_lock = nullptr; static volatile jboolean agent_started = JNI_FALSE; static void check_and_print_thread_names(jvmtiEnv *jvmti, JNIEnv* jni, jthread thread, bool is_virtual, const char* msg) { - jthread cthread = NULL; - jthread vthread = NULL; + jthread cthread = nullptr; + jthread vthread = nullptr; if (is_virtual) { vthread = thread; @@ -52,7 +52,7 @@ static void check_and_print_thread_names(jvmtiEnv *jvmti, JNIEnv* jni, jthread t cthread = thread; } char* ctname = get_thread_name(jvmti, jni, cthread); - char* vtname = vthread == NULL ? NULL : get_thread_name(jvmti, jni, vthread); + char* vtname = vthread == nullptr ? nullptr : get_thread_name(jvmti, jni, vthread); LOG("Event: %s virtual: %d ct: %s vt: %s\n", msg, is_virtual, ctname, vtname); @@ -158,22 +158,22 @@ jint agent_init(JavaVM *jvm, char *options, void *reserved) { LOG("Agent init: error in JVMTI AddCapabilities: %s (%d)\n", TranslateError(err), err); return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VIRTUAL_THREAD_START, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VIRTUAL_THREAD_START, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("Agent init: error in JVMTI SetEventNotificationMode: %s (%d)\n", TranslateError(err), err); return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VIRTUAL_THREAD_END, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VIRTUAL_THREAD_END, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("Agent init: error in JVMTI SetEventNotificationMode: %s (%d)\n", TranslateError(err), err); return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("Agent init: error in JVMTI SetEventNotificationMode: %s (%d)\n", TranslateError(err), err); return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_END, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_END, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("Agent init: error in JVMTI SetEventNotificationMode: %s (%d)\n", TranslateError(err), err); return JNI_ERR; diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/VThreadMonitorTest/libVThreadMonitorTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/vthread/VThreadMonitorTest/libVThreadMonitorTest.cpp index 72be78078bb..c05404658fe 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/VThreadMonitorTest/libVThreadMonitorTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/VThreadMonitorTest/libVThreadMonitorTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, 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 @@ -35,13 +35,13 @@ extern "C" { #define TEST_CLASS_0 "MonitorClass0" #define TEST_CLASS_2 "MonitorClass2" -static jvmtiEnv *jvmti = NULL; -static jrawMonitorID agent_monitor = NULL; +static jvmtiEnv *jvmti = nullptr; +static jrawMonitorID agent_monitor = nullptr; static volatile bool was_lock0_contended = false; static volatile bool was_lock2_contended = false; static volatile jint status = STATUS_PASSED; -static volatile jclass test_class_0 = NULL; -static volatile jclass test_class_2 = NULL; +static volatile jclass test_class_0 = nullptr; +static volatile jclass test_class_2 = nullptr; static jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved); @@ -60,7 +60,7 @@ static void ShowErrorMessage(jvmtiEnv *jvmti, jvmtiError errCode, } static jboolean CheckLockObject0(JNIEnv *jni, jobject monitor) { - if (test_class_0 == NULL) { + if (test_class_0 == nullptr) { // JNI_OnLoad has not been called yet, so can't possibly be an instance of TEST_CLASS_0. return JNI_FALSE; } @@ -68,7 +68,7 @@ static jboolean CheckLockObject0(JNIEnv *jni, jobject monitor) { } static jboolean CheckLockObject2(JNIEnv *jni, jobject monitor) { - if (test_class_2 == NULL) { + if (test_class_2 == nullptr) { // JNI_OnLoad has not been called yet, so can't possibly be an instance of TEST_CLASS_2. return JNI_FALSE; } @@ -98,7 +98,7 @@ check_contended_monitor(jvmtiEnv *jvmti, JNIEnv *jni, const char* func, jni->IsSameObject(monitor2, contended_monitor) == JNI_FALSE) { LOG("FAIL: is_vt: %d: unexpected monitor from GetCurrentContendedMonitor\n", is_vt); LOG("stack trace of current thread:\n"); - print_stack_trace(jvmti, jni, NULL); + print_stack_trace(jvmti, jni, nullptr); LOG("stack trace of target thread:\n"); print_stack_trace(jvmti, jni, thread); status = STATUS_FAILED; @@ -123,7 +123,7 @@ check_owned_monitor(jvmtiEnv *jvmti, JNIEnv *jni, const char* func, jvmtiError err; jint state = 0; jint mcount = -1; - jobject *owned_monitors = NULL; + jobject *owned_monitors = nullptr; err = jvmti->GetOwnedMonitorInfo(thread, &mcount, &owned_monitors); if (err != JVMTI_ERROR_NONE) { @@ -182,9 +182,9 @@ MonitorContendedEnter(jvmtiEnv *jvmti, JNIEnv *jni, jthread vthread, jobject mon char* ctname = get_thread_name(jvmti, jni, cthread); check_contended_monitor(jvmti, jni, "MonitorContendedEnter", - vthread, vtname, JNI_TRUE, monitor, NULL); + vthread, vtname, JNI_TRUE, monitor, nullptr); check_contended_monitor(jvmti, jni, "MonitorContendedEnter", - cthread, ctname, JNI_FALSE, NULL, NULL); + cthread, ctname, JNI_FALSE, nullptr, nullptr); check_owned_monitor(jvmti, jni, "MonitorContendedEnter", vthread, vtname, JNI_TRUE, monitor); check_owned_monitor(jvmti, jni, "MonitorContendedEnter", @@ -204,9 +204,9 @@ MonitorContendedEntered(jvmtiEnv *jvmti, JNIEnv *jni, jthread vthread, jobject m char* ctname = get_thread_name(jvmti, jni, cthread); check_contended_monitor(jvmti, jni, "MonitorContendedEntered", - vthread, vtname, JNI_TRUE, NULL, NULL); + vthread, vtname, JNI_TRUE, nullptr, nullptr); check_contended_monitor(jvmti, jni, "MonitorContendedEntered", - cthread, ctname, JNI_FALSE, NULL, NULL); + cthread, ctname, JNI_FALSE, nullptr, nullptr); deallocate(jvmti, jni, (void*)vtname); deallocate(jvmti, jni, (void*)ctname); @@ -226,7 +226,7 @@ static jclass find_test_class(JNIEnv *jni, const char* cname) { jclass k = jni->FindClass(cname); - if (k == NULL) { + if (k == nullptr) { LOG("Error: Could not find class %s!\n", cname); } else { k = (jclass)jni->NewGlobalRef(k); @@ -240,7 +240,7 @@ JNI_OnLoad(JavaVM *jvm, void *reserved) { JNIEnv *jni; res = jvm->GetEnv((void **)&jni, JNI_VERSION_9); - if (res != JNI_OK || jni == NULL) { + if (res != JNI_OK || jni == nullptr) { LOG("Error: GetEnv call failed(%d)!\n", res); return JNI_ERR; } @@ -248,7 +248,7 @@ JNI_OnLoad(JavaVM *jvm, void *reserved) { test_class_0 = find_test_class(jni, TEST_CLASS_0); test_class_2 = find_test_class(jni, TEST_CLASS_2); - if (test_class_0 == NULL || test_class_2 == NULL) { + if (test_class_0 == nullptr || test_class_2 == nullptr) { return JNI_ERR; } return JNI_VERSION_9; @@ -264,7 +264,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { LOG("Agent_OnLoad started\n"); res = jvm->GetEnv((void **)&jvmti, JVMTI_VERSION); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Error: wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -315,14 +315,14 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_MONITOR_CONTENDED_ENTER, NULL); + JVMTI_EVENT_MONITOR_CONTENDED_ENTER, nullptr); if (err != JVMTI_ERROR_NONE) { ShowErrorMessage(jvmti, err, "Agent_OnLoad", "error in JVMTI SetEventNotificationMode #1"); return JNI_ERR; } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_MONITOR_CONTENDED_ENTERED, NULL); + JVMTI_EVENT_MONITOR_CONTENDED_ENTERED, nullptr); if (err != JVMTI_ERROR_NONE) { ShowErrorMessage(jvmti, err, "Agent_OnLoad", "error in JVMTI SetEventNotificationMode #2"); diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/VThreadNotifyFramePopTest/libVThreadNotifyFramePopTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/vthread/VThreadNotifyFramePopTest/libVThreadNotifyFramePopTest.cpp index 55803e5abf5..d5254293ab1 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/VThreadNotifyFramePopTest/libVThreadNotifyFramePopTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/VThreadNotifyFramePopTest/libVThreadNotifyFramePopTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, 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 @@ -29,32 +29,32 @@ extern "C" { #define MAX_FRAME_COUNT 20 -static jvmtiEnv *jvmti = NULL; -static jrawMonitorID event_mon = NULL; +static jvmtiEnv *jvmti = nullptr; +static jrawMonitorID event_mon = nullptr; static int breakpoint_count = 0; static int frame_pop_count = 0; static int brkptBreakpointHit = 0; static jboolean received_frame_pop_event = JNI_FALSE; static jboolean passed = JNI_TRUE; -static jmethodID *test_methods = NULL; +static jmethodID *test_methods = nullptr; jint test_method_count = 0; -jclass test_class = NULL; +jclass test_class = nullptr; -static jmethodID *url_methods = NULL; +static jmethodID *url_methods = nullptr; jint url_method_count = 0; -jclass url_class = NULL; +jclass url_class = nullptr; static void print_frame_event_info(jvmtiEnv *jvmti, JNIEnv* jni, jthread thread, jmethodID method, const char* event_name, int event_count) { char* tname = get_thread_name(jvmti, jni, thread); char* cname = get_method_class_name(jvmti, jni, method); - char* mname = NULL; - char* msign = NULL; + char* mname = nullptr; + char* msign = nullptr; jvmtiError err; - err = jvmti->GetMethodName(method, &mname, &msign, NULL); + err = jvmti->GetMethodName(method, &mname, &msign, nullptr); check_jvmti_status(jni, err, "event handler: error in JVMTI GetMethodName call"); LOG("%s #%d: thread: %s, method: %s.%s%s\n", @@ -84,7 +84,7 @@ static void set_or_clear_breakpoint(JNIEnv *jni, jboolean set, const char *methodName, jclass klass, jmethodID methods[], int method_count) { jlocation location = (jlocation)0L; - jmethodID method = NULL; + jmethodID method = nullptr; jvmtiError err; // Find the jmethodID of the specified method @@ -98,7 +98,7 @@ set_or_clear_breakpoint(JNIEnv *jni, jboolean set, const char *methodName, } deallocate(jvmti, jni, (void*)mname); } - if (method == NULL) { + if (method == nullptr) { LOG("setupBreakpoint: not found method %s() to %s a breakpoint\n", methodName, set ? "set" : "clear"); jni->FatalError("Error in setupBreakpoint: not found method"); @@ -237,7 +237,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { LOG("Agent_OnLoad: Error in JVMTI SetEventCallbacks: %d\n", err); } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FRAME_POP, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FRAME_POP, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("error in JVMTI SetEventNotificationMode: %d\n", err); } @@ -268,7 +268,7 @@ Java_VThreadNotifyFramePopTest_enableEvents(JNIEnv *jni, jclass klass, jthread t set_breakpoint(jni, "openStream", urlKlass, url_methods, url_method_count); // Enable Breakpoint events globally - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, nullptr); check_jvmti_status(jni, err, "enableEvents: error in JVMTI SetEventNotificationMode: enable BREAKPOINT"); LOG("enableEvents: finished\n"); diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/VThreadTest/libVThreadTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/vthread/VThreadTest/libVThreadTest.cpp index 32037f79f53..701797bcfc2 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/VThreadTest/libVThreadTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/VThreadTest/libVThreadTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,8 +36,8 @@ typedef struct Tinfo { } Tinfo; static const int MAX_EVENTS_TO_PROCESS = 20; -static jvmtiEnv *jvmti = NULL; -static jrawMonitorID events_monitor = NULL; +static jvmtiEnv *jvmti = nullptr; +static jrawMonitorID events_monitor = nullptr; static Tinfo tinfo[MAX_WORKER_THREADS]; static int vthread_mount_count = 0; @@ -46,13 +46,13 @@ static jboolean passed = JNI_TRUE; static Tinfo* find_tinfo(JNIEnv* jni, const char* tname) { - Tinfo* inf = NULL; + Tinfo* inf = nullptr; int idx = 0; // Find slot with named worker thread or empty slot for (; idx < MAX_WORKER_THREADS; idx++) { inf = &tinfo[idx]; - if (inf->tname == NULL) { + if (inf->tname == nullptr) { inf->tname = (char*)malloc(strlen(tname) + 1); strcpy(inf->tname, tname); break; @@ -78,10 +78,10 @@ find_method_depth(jvmtiEnv *jvmti, JNIEnv *jni, jthread vthread, const char *mna for (int depth = 0; depth < count; depth++) { jmethodID method = frames[depth].method; - char* name = NULL; - char* sign = NULL; + char* name = nullptr; + char* sign = nullptr; - err = jvmti->GetMethodName(method, &name, &sign, NULL); + err = jvmti->GetMethodName(method, &name, &sign, nullptr); check_jvmti_status(jni, err, "find_method_depth: error in JVMTI GetMethodName"); if (strcmp(name, mname) == 0) { @@ -102,7 +102,7 @@ print_vthread_event_info(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread, jthread v inf->just_scheduled = JNI_TRUE; } else { - if (inf->tname == NULL && strcmp(event_name, "VirtualThreadEnd") != 0) { + if (inf->tname == nullptr && strcmp(event_name, "VirtualThreadEnd") != 0) { fatal(jni, "VThread event: worker thread not found!"); } if (strcmp(event_name, "VirtualThreadUnmount") == 0) { @@ -117,19 +117,19 @@ print_vthread_event_info(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread, jthread v static void test_GetVirtualThread(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread, jthread vthread, const char *event_name) { - jobject thread_vthread = NULL; + jobject thread_vthread = nullptr; jvmtiError err; LOG("\ntest_GetVirtualThread: event: %s\n", event_name); - // #1: Test JVMTI GetVirtualThread extension function NULL thread (current) - err = GetVirtualThread(jvmti, jni, NULL, &thread_vthread); - check_jvmti_status(jni, err, "event handler: error in JVMTI GetVirtualThread with NULL thread (current)"); + // #1: Test JVMTI GetVirtualThread extension function nullptr thread (current) + err = GetVirtualThread(jvmti, jni, nullptr, &thread_vthread); + check_jvmti_status(jni, err, "event handler: error in JVMTI GetVirtualThread with null thread (current)"); - if (thread_vthread == NULL) { - fatal(jni, "event handler: JVMTI GetVirtualThread with NULL thread (current) failed to return non-NULL vthread"); + if (thread_vthread == nullptr) { + fatal(jni, "event handler: JVMTI GetVirtualThread with nullptr thread (current) failed to return non-null vthread"); } - LOG("JVMTI GetVirtualThread with NULL thread (current) returned non-NULL vthread as expected\n"); + LOG("JVMTI GetVirtualThread with nullptr thread (current) returned non-null vthread as expected\n"); // #2: Test JVMTI GetVirtualThread extension function with a bad thread err = GetVirtualThread(jvmti, jni, vthread, &thread_vthread); @@ -141,21 +141,21 @@ test_GetVirtualThread(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread, jthread vthr err = GetVirtualThread(jvmti, jni,thread, &thread_vthread); check_jvmti_status(jni, err, "event handler: error in JVMTI GetVirtualThread"); - if (thread_vthread == NULL) { - fatal(jni, "event handler: JVMTI GetVirtualThread with good thread failed to return non-NULL vthread"); + if (thread_vthread == nullptr) { + fatal(jni, "event handler: JVMTI GetVirtualThread with good thread failed to return non-null vthread"); } - LOG("JVMTI GetVirtualThread with good thread returned non-NULL vthread as expected\n"); + LOG("JVMTI GetVirtualThread with good thread returned non-null vthread as expected\n"); } static void test_GetCarrierThread(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread, jthread vthread, const char *event_name) { - jthread vthread_thread = NULL; + jthread vthread_thread = nullptr; jvmtiError err; LOG("\ntest_GetCarrierThread: event: %s\n", event_name); - // #1: Test JVMTI GetCarrierThread extension function with NULL vthread - err = GetCarrierThread(jvmti, jni, NULL, &vthread_thread); + // #1: Test JVMTI GetCarrierThread extension function with nullptr vthread + err = GetCarrierThread(jvmti, jni, nullptr, &vthread_thread); check_jvmti_status(jni, err, "event handler: error in JVMTI GetCarrierThread"); // #2: Test JVMTI GetCarrierThread extension function with a bad vthread @@ -168,10 +168,10 @@ test_GetCarrierThread(jvmtiEnv *jvmti, JNIEnv *jni, jthread thread, jthread vthr err = GetCarrierThread(jvmti, jni, vthread, &vthread_thread); check_jvmti_status(jni, err, "event handler: error in JVMTI GetCarrierThread"); - if (vthread_thread == NULL) { - fatal(jni, "event handler: JVMTI GetCarrierThread with good vthread failed to return non-NULL carrier thread"); + if (vthread_thread == nullptr) { + fatal(jni, "event handler: JVMTI GetCarrierThread with good vthread failed to return non-null carrier thread"); } - LOG("JVMTI GetCarrierThread with good vthread returned non-NULL carrier thread as expected\n"); + LOG("JVMTI GetCarrierThread with good vthread returned non-null carrier thread as expected\n"); } static void @@ -180,7 +180,7 @@ test_GetThreadInfo(jvmtiEnv *jvmti, JNIEnv *jni, jthread vthread, const char *ev jvmtiThreadInfo thr_info; jvmtiThreadGroupInfo ginfo; jint class_count = -1; - jclass* classes = NULL; + jclass* classes = nullptr; jboolean found = JNI_FALSE; LOG("test_GetThreadInfo: started\n"); @@ -207,11 +207,11 @@ test_GetThreadInfo(jvmtiEnv *jvmti, JNIEnv *jni, jthread vthread, const char *ev // #4: Test the thr_info.context_class_loader has the VThreadTest class for (int idx = 0; idx < class_count; idx++) { - char* sign = NULL; - err = jvmti->GetClassSignature(classes[idx], &sign, NULL); + char* sign = nullptr; + err = jvmti->GetClassSignature(classes[idx], &sign, nullptr); check_jvmti_status(jni, err, "event handler: error in JVMTI GetClassSignature"); - if (strstr(sign, "VThreadTest") != NULL) { + if (strstr(sign, "VThreadTest") != nullptr) { found = JNI_TRUE; break; } @@ -228,11 +228,11 @@ test_GetFrameCount(jvmtiEnv *jvmti, JNIEnv *jni, jthread vthread, const char *ev jint frame_count = -1; jvmtiError err; - // #1: Test JVMTI GetFrameCount function with NULL count_ptr pointer - err = jvmti->GetFrameCount(vthread, NULL); + // #1: Test JVMTI GetFrameCount function with nullptr count_ptr pointer + err = jvmti->GetFrameCount(vthread, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { - LOG("JVMTI GetFrameCount with NULL count_ptr returned error: %d\n", err); - fatal(jni, "event handler: JVMTI GetFrameCount with NULL count_ptr pointer failed to return JVMTI_ERROR_NULL_POINTER"); + LOG("JVMTI GetFrameCount with null count_ptr returned error: %d\n", err); + fatal(jni, "event handler: JVMTI GetFrameCount with null count_ptr pointer failed to return JVMTI_ERROR_NULL_POINTER"); } // #2: Test JVMTI GetFrameCount function with a good vthread @@ -249,7 +249,7 @@ test_GetFrameCount(jvmtiEnv *jvmti, JNIEnv *jni, jthread vthread, const char *ev static void test_GetFrameLocation(jvmtiEnv *jvmti, JNIEnv *jni, jthread vthread, const char *event_name, jint frame_count) { - jmethodID method = NULL; + jmethodID method = nullptr; jlocation location = -1; jvmtiError err; @@ -260,18 +260,18 @@ test_GetFrameLocation(jvmtiEnv *jvmti, JNIEnv *jni, jthread vthread, const char fatal(jni, "event handler: JVMTI GetFrameLocation with negative frame depth failed to return JVMTI_ERROR_ILLEGAL_ARGUMENT"); } - // #2: Test JVMTI GetFrameLocation function with NULL method_ptr - err = jvmti->GetFrameLocation(vthread, 0, NULL, &location); + // #2: Test JVMTI GetFrameLocation function with nullptr method_ptr + err = jvmti->GetFrameLocation(vthread, 0, nullptr, &location); if (err != JVMTI_ERROR_NULL_POINTER) { - LOG("JVMTI GetFrameLocation with NULL method_ptr returned error: %d\n", err); - fatal(jni, "event handler: JVMTI GetFrameLocation with NULL method_ptr failed to return JVMTI_ERROR_NULL_POINTER"); + LOG("JVMTI GetFrameLocation with null method_ptr returned error: %d\n", err); + fatal(jni, "event handler: JVMTI GetFrameLocation with null method_ptr failed to return JVMTI_ERROR_NULL_POINTER"); } - // #3: Test JVMTI GetFrameLocation function with NULL location_ptr - err = jvmti->GetFrameLocation(vthread, 0, &method, NULL); + // #3: Test JVMTI GetFrameLocation function with nullptr location_ptr + err = jvmti->GetFrameLocation(vthread, 0, &method, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { - LOG("JVMTI GetFrameCount with NULL location_ptr returned error: %d\n", err); - fatal(jni, "event handler: JVMTI GetFrameLocation with NULL location_ptr failed to return JVMTI_ERROR_NULL_POINTER"); + LOG("JVMTI GetFrameCount with null location_ptr returned error: %d\n", err); + fatal(jni, "event handler: JVMTI GetFrameLocation with null location_ptr failed to return JVMTI_ERROR_NULL_POINTER"); } // #4: Test JVMTI GetFrameLocation function with a good vthread @@ -304,7 +304,7 @@ static void test_GetStackTrace(jvmtiEnv *jvmti, JNIEnv *jni, jthread vthread, const char *event_name, jint frame_count) { jvmtiFrameInfo frames[MAX_FRAME_COUNT]; jint count = -1; - jmethodID method = NULL; + jmethodID method = nullptr; jvmtiError err; LOG("\n"); @@ -328,18 +328,18 @@ test_GetStackTrace(jvmtiEnv *jvmti, JNIEnv *jni, jthread vthread, const char *ev fatal(jni, "event handler: JVMTI GetStackTrace with negative max_frame_count failed to return JVMTI_ERROR_ILLEGAL_ARGUMENT"); } - // #3: Test JVMTI GetStackTrace function with NULL frame_buffer pointer - err = jvmti->GetStackTrace(vthread, 0, MAX_FRAME_COUNT, NULL, &count); + // #3: Test JVMTI GetStackTrace function with nullptr frame_buffer pointer + err = jvmti->GetStackTrace(vthread, 0, MAX_FRAME_COUNT, nullptr, &count); if (err != JVMTI_ERROR_NULL_POINTER) { - LOG("JVMTI GetStackTrace with NULL frame_buffer pointer returned error: %d\n", err); - fatal(jni, "event handler: JVMTI GetStackTrace witt NULL frame_buffer pointer failed to return JVMTI_ERROR_NULL_POINTER"); + LOG("JVMTI GetStackTrace with null frame_buffer pointer returned error: %d\n", err); + fatal(jni, "event handler: JVMTI GetStackTrace witt null frame_buffer pointer failed to return JVMTI_ERROR_NULL_POINTER"); } - // #4: Test JVMTI GetStackTrace function with NULL count_ptr pointer - err = jvmti->GetStackTrace(vthread, 0, MAX_FRAME_COUNT, frames, NULL); + // #4: Test JVMTI GetStackTrace function with nullptr count_ptr pointer + err = jvmti->GetStackTrace(vthread, 0, MAX_FRAME_COUNT, frames, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { - LOG("JVMTI GetStackTrace with NULL count_ptr pointer returned error: %d\n", err); - fatal(jni, "event handler: JVMTI GetStackTrace witt NULL count_ptr pointer failed to return JVMTI_ERROR_NULL_POINTER"); + LOG("JVMTI GetStackTrace with null count_ptr pointer returned error: %d\n", err); + fatal(jni, "event handler: JVMTI GetStackTrace witt null count_ptr pointer failed to return JVMTI_ERROR_NULL_POINTER"); } // #5: Test JVMTI GetStackTrace function with a good vthread @@ -364,8 +364,8 @@ enum Slots { SlotInvalid0 = -1, SlotObj = 0, SlotInt = 1, SlotLong = 2, SlotUnal static void test_GetLocal(jvmtiEnv *jvmti, JNIEnv *jni, jthread cthread, jthread vthread, const char *event_name, jint frame_count) { - jmethodID method = NULL; - jobject obj = NULL; + jmethodID method = nullptr; + jobject obj = nullptr; jint ii = 0; jlong ll = 0L; jfloat ff = 0.0; @@ -423,18 +423,18 @@ test_GetLocal(jvmtiEnv *jvmti, JNIEnv *jni, jthread cthread, jthread vthread, co " to return JVMTI_ERROR_INVALID_SLOT or JVMTI_ERROR_TYPE_MISMATCH"); } - // #5: Test JVMTI GetLocalObject function with NULL value_ptr - err = jvmti->GetLocalObject(vthread, depth, SlotObj, NULL); + // #5: Test JVMTI GetLocalObject function with null value_ptr + err = jvmti->GetLocalObject(vthread, depth, SlotObj, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { - LOG("JVMTI GetLocalObject with NULL method_ptr returned error: %d\n", err); - fatal(jni, "JVMTI GetLocalObject with NULL method_ptr failed to return JVMTI_ERROR_NULL_POINTER"); + LOG("JVMTI GetLocalObject with null method_ptr returned error: %d\n", err); + fatal(jni, "JVMTI GetLocalObject with null method_ptr failed to return JVMTI_ERROR_NULL_POINTER"); } // #6: Test JVMTI GetLocal functions with a good vthread err = jvmti->GetLocalObject(vthread, depth, SlotObj, &obj); check_jvmti_status(jni, err, "event handler: error in JVMTI GetLocalObject with good vthread"); - const char* str = jni->GetStringUTFChars((jstring)obj, NULL); + const char* str = jni->GetStringUTFChars((jstring)obj, nullptr); LOG(" local String value at slot %d: %s\n", SlotObj, str); const char* exp_str = "msg: ..."; if (strncmp(str, exp_str, 5) != 0) { @@ -500,7 +500,7 @@ processVThreadEvent(jvmtiEnv *jvmti, JNIEnv *jni, jthread vthread, const char *e deallocate(jvmti, jni, (void*)tname); if (strcmp(event_name, "VirtualThreadEnd") == 0) { - return; // skip further testing as GetVirtualThread can return NULL + return; // skip further testing as GetVirtualThread can return nullptr } test_GetVirtualThread(jvmti, jni, cthread, vthread, event_name); @@ -532,8 +532,8 @@ VirtualThreadEnd(jvmtiEnv *jvmti, JNIEnv *jni, jthread vthread) { static void JNICALL VirtualThreadMount(jvmtiEnv *jvmti, ...) { va_list ap; - JNIEnv* jni = NULL; - jthread thread = NULL; + JNIEnv* jni = nullptr; + jthread thread = nullptr; va_start(ap, jvmti); jni = va_arg(ap, JNIEnv*); @@ -549,8 +549,8 @@ VirtualThreadMount(jvmtiEnv *jvmti, ...) { static void JNICALL VirtualThreadUnmount(jvmtiEnv *jvmti, ...) { va_list ap; - JNIEnv* jni = NULL; - jthread thread = NULL; + JNIEnv* jni = nullptr; + jthread thread = nullptr; va_start(ap, jvmti); jni = va_arg(ap, JNIEnv*); @@ -608,25 +608,25 @@ Agent_OnLoad(JavaVM *jvm, char *options, return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VIRTUAL_THREAD_START, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VIRTUAL_THREAD_START, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("error in JVMTI SetEventNotificationMode: %d\n", err); return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VIRTUAL_THREAD_END, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VIRTUAL_THREAD_END, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("error in JVMTI SetEventNotificationMode: %d\n", err); return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, EXT_EVENT_VIRTUAL_THREAD_MOUNT, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, EXT_EVENT_VIRTUAL_THREAD_MOUNT, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("error in JVMTI SetEventNotificationMode: %d\n", err); return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, EXT_EVENT_VIRTUAL_THREAD_UNMOUNT, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, EXT_EVENT_VIRTUAL_THREAD_UNMOUNT, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("error in JVMTI SetEventNotificationMode: %d\n", err); return JNI_ERR; diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/VThreadUnsupportedTest/libVThreadUnsupportedTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/vthread/VThreadUnsupportedTest/libVThreadUnsupportedTest.cpp index 14698b6e528..5b299a46f48 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/VThreadUnsupportedTest/libVThreadUnsupportedTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/VThreadUnsupportedTest/libVThreadUnsupportedTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, 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 @@ -29,7 +29,7 @@ extern "C" { -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static std::atomic is_completed_test_in_event; @@ -68,7 +68,7 @@ test_unsupported_jvmti_functions(jvmtiEnv *jvmti, JNIEnv *jni, jthread vthread) jvmtiError err; jboolean is_vthread; jvmtiCapabilities caps; - void* local_storage_data = NULL; + void* local_storage_data = nullptr; jlong nanos; LOG("test_unsupported_jvmti_functions: started\n"); @@ -98,7 +98,7 @@ test_unsupported_jvmti_functions(jvmtiEnv *jvmti, JNIEnv *jni, jthread vthread) check_jvmti_error_unsupported_operation(jni, "GetCurrentThreadCpuTime", err); } - err = jvmti->RunAgentThread(vthread, agent_proc, (const void*)NULL, JVMTI_THREAD_NORM_PRIORITY); + err = jvmti->RunAgentThread(vthread, agent_proc, nullptr, JVMTI_THREAD_NORM_PRIORITY); check_jvmti_error_unsupported_operation(jni, "RunAgentThread", err); LOG("test_unsupported_jvmti_functions: finished\n"); @@ -121,8 +121,8 @@ Java_VThreadUnsupportedTest_testJvmtiFunctionsInJNICall(JNIEnv *jni, jobject obj static void JNICALL VirtualThreadMount(jvmtiEnv *jvmti, ...) { va_list ap; - JNIEnv* jni = NULL; - jthread thread = NULL; + JNIEnv* jni = nullptr; + jthread thread = nullptr; va_start(ap, jvmti); jni = va_arg(ap, JNIEnv*); @@ -175,7 +175,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, EXT_EVENT_VIRTUAL_THREAD_MOUNT, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, EXT_EVENT_VIRTUAL_THREAD_MOUNT, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("error in JVMTI SetEventNotificationMode: %d\n", err); return JNI_ERR; diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/VirtualStackTraceTest/libVirtualStackTraceTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/vthread/VirtualStackTraceTest/libVirtualStackTraceTest.cpp index eb387a1f8dc..744e75ac29f 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/VirtualStackTraceTest/libVirtualStackTraceTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/VirtualStackTraceTest/libVirtualStackTraceTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, 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 @@ -40,21 +40,21 @@ Java_VirtualStackTraceTest_getStackTrace(JNIEnv* jni, jclass clazz) { jobject visibleFrames[MAX_COUNT]; jvmtiFrameInfo frameInfo[MAX_COUNT]; - err = jvmti->GetStackTrace(NULL, 0, MAX_COUNT, frameInfo, &count); + err = jvmti->GetStackTrace(nullptr, 0, MAX_COUNT, frameInfo, &count); check_jvmti_status(jni, err, "event handler: error in JVMTI GetStackTrace call"); for (int idx = 0; idx < count; idx++) { - jclass declaringClass = NULL; - char *clasSignature = NULL; - char *methodName = NULL; + jclass declaringClass = nullptr; + char *clasSignature = nullptr; + char *methodName = nullptr; err = jvmti->GetMethodDeclaringClass(frameInfo[idx].method, &declaringClass); check_jvmti_status(jni, err, "event handler: error in JVMTI GetMethodDeclaringClass call"); - err = jvmti->GetClassSignature(declaringClass, &clasSignature, NULL); + err = jvmti->GetClassSignature(declaringClass, &clasSignature, nullptr); check_jvmti_status(jni, err, "event handler: error in JVMTI GetClassSignature call"); - err = jvmti->GetMethodName(frameInfo[idx].method, &methodName, NULL, NULL); + err = jvmti->GetMethodName(frameInfo[idx].method, &methodName, nullptr, nullptr); check_jvmti_status(jni, err, "event handler: error in JVMTI GetMethodName call"); if (strchr(clasSignature, '.')) { @@ -66,11 +66,11 @@ Java_VirtualStackTraceTest_getStackTrace(JNIEnv* jni, jclass clazz) { jvmti->Deallocate(reinterpret_cast(methodName)); jvmti->Deallocate(reinterpret_cast(clasSignature)); } - jobjectArray methodNames = jni->NewObjectArray(count - skipped, jni->FindClass("java/lang/String"), NULL); + jobjectArray methodNames = jni->NewObjectArray(count - skipped, jni->FindClass("java/lang/String"), nullptr); for (int idx = 0; idx < count - skipped; idx++) { jni->SetObjectArrayElement(methodNames, idx, visibleFrames[idx]); } - print_stack_trace(jvmti, jni, NULL); + print_stack_trace(jvmti, jni, nullptr); return methodNames; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/VirtualThreadStartTest/libVirtualThreadStartTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/vthread/VirtualThreadStartTest/libVirtualThreadStartTest.cpp index b4eefa992ef..262712dfb0c 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/VirtualThreadStartTest/libVirtualThreadStartTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/VirtualThreadStartTest/libVirtualThreadStartTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,7 @@ extern "C" { static jvmtiEnv *jvmti; static int started_thread_cnt = 0; -static jrawMonitorID agent_event_lock = NULL; +static jrawMonitorID agent_event_lock = nullptr; static const char* TESTED_TNAME_START = "Tested-VT"; static const size_t TESTED_TNAME_START_LEN = strlen(TESTED_TNAME_START); static bool can_support_vt_enabled = false; @@ -40,7 +40,7 @@ void JNICALL ThreadStart(jvmtiEnv *jvmti, JNIEnv* jni, jthread thread) { RawMonitorLocker agent_start_locker(jvmti, jni, agent_event_lock); - if (tname != NULL && strncmp(tname, TESTED_TNAME_START, TESTED_TNAME_START_LEN) == 0) { + if (tname != nullptr && strncmp(tname, TESTED_TNAME_START, TESTED_TNAME_START_LEN) == 0) { jboolean is_virtual = jni->IsVirtualThread(thread); if (!is_virtual) { fatal(jni, "Failed: tested thread expected to be virtual"); @@ -59,7 +59,7 @@ void JNICALL VirtualThreadStart(jvmtiEnv *jvmti, JNIEnv* jni, jthread thread) { RawMonitorLocker agent_start_locker(jvmti, jni, agent_event_lock); - if (tname != NULL && strncmp(tname, TESTED_TNAME_START, TESTED_TNAME_START_LEN) == 0) { + if (tname != nullptr && strncmp(tname, TESTED_TNAME_START, TESTED_TNAME_START_LEN) == 0) { jboolean is_virtual = jni->IsVirtualThread(thread); if (!is_virtual) { fatal(jni, "Failed: tested thread expected to be virtual"); @@ -101,7 +101,7 @@ jint agent_init(JavaVM *jvm, char *options, void *reserved) { callbacks.ThreadStart = &ThreadStart; callbacks.VirtualThreadStart = &VirtualThreadStart; - if (options != NULL && strcmp(options, "can_support_virtual_threads") == 0) { + if (options != nullptr && strcmp(options, "can_support_virtual_threads") == 0) { can_support_vt_enabled = true; caps.can_support_virtual_threads = 1; @@ -110,13 +110,13 @@ jint agent_init(JavaVM *jvm, char *options, void *reserved) { LOG("Agent init: error in JVMTI AddCapabilities: %s (%d)\n", TranslateError(err), err); return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VIRTUAL_THREAD_START, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VIRTUAL_THREAD_START, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("Agent init: error in JVMTI SetEventNotificationMode: %s (%d)\n", TranslateError(err), err); return JNI_ERR; } } else { - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, nullptr); if (err != JVMTI_ERROR_NONE) { LOG("Agent init: error in JVMTI SetEventNotificationMode: %s (%d)\n", TranslateError(err), err); return JNI_ERR; diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/WaitNotifySuspendedVThreadTest/WaitNotifySuspendedVThreadTest.java b/test/hotspot/jtreg/serviceability/jvmti/vthread/WaitNotifySuspendedVThreadTest/WaitNotifySuspendedVThreadTest.java index a7b4b6ff43c..5af72902280 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/WaitNotifySuspendedVThreadTest/WaitNotifySuspendedVThreadTest.java +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/WaitNotifySuspendedVThreadTest/WaitNotifySuspendedVThreadTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ * @library /test/lib * @compile WaitNotifySuspendedVThreadTest.java * @run main/othervm/native - * -Djava.util.concurrent.ForkJoinPool.common.parallelism=1 + * -Djdk.virtualThreadScheduler.maxPoolSize=1 * -agentlib:WaitNotifySuspendedVThread WaitNotifySuspendedVThreadTest */ diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/WaitNotifySuspendedVThreadTest/libWaitNotifySuspendedVThread.cpp b/test/hotspot/jtreg/serviceability/jvmti/vthread/WaitNotifySuspendedVThreadTest/libWaitNotifySuspendedVThread.cpp index e6ad883944a..44b931c0ff9 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/WaitNotifySuspendedVThreadTest/libWaitNotifySuspendedVThread.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/WaitNotifySuspendedVThreadTest/libWaitNotifySuspendedVThread.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ set_breakpoint(JNIEnv *jni, jclass klass, const char *mname) { jmethodID method = find_method(jvmti_env, jni, klass, mname); jvmtiError err; - if (method == NULL) { + if (method == nullptr) { jni->FatalError("Error in set_breakpoint: not found method"); } err = jvmti_env->SetBreakpoint(method, location); @@ -56,7 +56,7 @@ Java_WaitNotifySuspendedVThreadTask_setBreakpoint(JNIEnv *jni, jclass klass) { set_breakpoint(jni, klass, "methBreakpoint"); // Enable Breakpoint events globally - err = jvmti_env->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL); + err = jvmti_env->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, nullptr); check_jvmti_status(jni, err, "enableEvents: error in JVMTI SetEventNotificationMode: enable BREAKPOINT"); LOG("setBreakpoint: finished\n"); @@ -137,7 +137,7 @@ Breakpoint(jvmtiEnv *jvmti, JNIEnv* jni, jthread thread, JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv * jvmti = NULL; + jvmtiEnv * jvmti = nullptr; jvmtiEventCallbacks callbacks; jvmtiCapabilities caps; @@ -145,7 +145,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { LOG("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } diff --git a/test/hotspot/jtreg/serviceability/monitoring/ThreadInfo/GetLockOwnerName/libGetLockOwnerName.cpp b/test/hotspot/jtreg/serviceability/monitoring/ThreadInfo/GetLockOwnerName/libGetLockOwnerName.cpp index ee4fb5c6d8a..cc377667093 100644 --- a/test/hotspot/jtreg/serviceability/monitoring/ThreadInfo/GetLockOwnerName/libGetLockOwnerName.cpp +++ b/test/hotspot/jtreg/serviceability/monitoring/ThreadInfo/GetLockOwnerName/libGetLockOwnerName.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, 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 @@ -26,7 +26,7 @@ extern "C" { -static jvmtiEnv* jvmti = NULL; +static jvmtiEnv* jvmti = nullptr; #define LOG(...) \ do { \ @@ -53,7 +53,7 @@ Java_GetLockOwnerName_wait4ContendedEnter(JNIEnv *jni, jclass cls, jthread thr) if (err != JVMTI_ERROR_NONE) { return err; } - if (monitor_ptr != NULL) { + if (monitor_ptr != nullptr) { break; } } diff --git a/test/hotspot/jtreg/testlibrary/jvmti/libJvmtiUtils.cpp b/test/hotspot/jtreg/testlibrary/jvmti/libJvmtiUtils.cpp index 0e7f1eba383..28afafda3a7 100644 --- a/test/hotspot/jtreg/testlibrary/jvmti/libJvmtiUtils.cpp +++ b/test/hotspot/jtreg/testlibrary/jvmti/libJvmtiUtils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, 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 @@ -27,7 +27,7 @@ extern "C" { -static jvmtiEnv* jvmti = NULL; +static jvmtiEnv* jvmti = nullptr; JNIEXPORT jint JNICALL Java_jvmti_JVMTIUtils_init(JNIEnv *jni, jclass cls) { diff --git a/test/hotspot/jtreg/vmTestbase/gc/g1/unloading/libdefine.cpp b/test/hotspot/jtreg/vmTestbase/gc/g1/unloading/libdefine.cpp index 157ea1f92a7..e1b16107e12 100644 --- a/test/hotspot/jtreg/vmTestbase/gc/g1/unloading/libdefine.cpp +++ b/test/hotspot/jtreg/vmTestbase/gc/g1/unloading/libdefine.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,14 +44,14 @@ extern "C" { JNIEXPORT jclass JNICALL Java_gc_g1_unloading_classloaders_JNIClassloader_loadThroughJNI0 (JNIEnv * env, jclass clazz, jstring className, jobject classLoader, jbyteArray bytecode) { - const char * classNameChar = env->GetStringUTFChars(className, NULL); - jbyte * arrayContent = env->GetByteArrayElements(bytecode, NULL); + const char * classNameChar = env->GetStringUTFChars(className, nullptr); + jbyte * arrayContent = env->GetByteArrayElements(bytecode, nullptr); jsize bytecodeLength = env->GetArrayLength(bytecode); jclass returnValue = env->DefineClass(classNameChar, classLoader, arrayContent, bytecodeLength); env->ReleaseByteArrayElements(bytecode, arrayContent, JNI_ABORT); env->ReleaseStringUTFChars(className, classNameChar); if (!returnValue) { - printf("ERROR: DefineClass call returned NULL by some reason. Classloading failed.\n"); + printf("ERROR: DefineClass call returned null by some reason. Classloading failed.\n"); } return returnValue; @@ -101,7 +101,7 @@ JNIEXPORT jint JNICALL Java_gc_g1_unloading_loading_ClassLoadingHelper_makeRede classDef.klass = redefCls; classDef.class_byte_count = env->GetArrayLength(classBytes); - jbyte * class_bytes = env->GetByteArrayElements(classBytes, NULL); + jbyte * class_bytes = env->GetByteArrayElements(classBytes, nullptr); classDef.class_bytes = (unsigned char *)class_bytes; if (fl == 2) { @@ -167,7 +167,7 @@ JNIEXPORT void JNICALL Java_gc_g1_unloading_keepref_JNILocalRefHolder_holdWithJN objectToKeepField = env->GetFieldID(clazz, "objectToKeep", "Ljava/lang/Object;"); objectToKeep = env->GetObjectField(thisObject, objectToKeepField); localRef = env->NewLocalRef(objectToKeep); - env->SetObjectField(thisObject, objectToKeepField, NULL); + env->SetObjectField(thisObject, objectToKeepField, nullptr); objectClazz = env->FindClass("Ljava/lang/Object;"); waitMethod = env->GetMethodID(objectClazz, "wait", "()V"); diff --git a/test/hotspot/jtreg/vmTestbase/gc/gctests/nativeGC03/libnativeGC03.cpp b/test/hotspot/jtreg/vmTestbase/gc/gctests/nativeGC03/libnativeGC03.cpp index e8520a1ad4f..2c97863db5a 100644 --- a/test/hotspot/jtreg/vmTestbase/gc/gctests/nativeGC03/libnativeGC03.cpp +++ b/test/hotspot/jtreg/vmTestbase/gc/gctests/nativeGC03/libnativeGC03.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ Java_gc_gctests_nativeGC03_nativeGC03_nativeMethod03 /*Trash all the linked lists */ while (count < 10) { while (i < len) { - env->SetObjectArrayElement(listHolder, i, NULL); + env->SetObjectArrayElement(listHolder, i, nullptr); i++; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/aod/VirtualMachine/VirtualMachine07/agent00.cpp b/test/hotspot/jtreg/vmTestbase/nsk/aod/VirtualMachine/VirtualMachine07/agent00.cpp index 932d44e6727..5d819851e4b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/aod/VirtualMachine/VirtualMachine07/agent00.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/aod/VirtualMachine/VirtualMachine07/agent00.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ JNIEXPORT jint JNICALL Agent_OnAttach(JavaVM *vm, char *optionsString, void *res // can't use NSK_DISPLAY since needed for nsk_ functions initialization isn't done here jni = (JNIEnv*) nsk_aod_createJNIEnv(vm); - if (jni == NULL) + if (jni == nullptr) return JNI_ERR; printf("%s: initialization was done\n", AGENT_NAME); @@ -46,7 +46,7 @@ JNIEXPORT jint JNICALL Agent_OnAttach(JavaVM *vm, char *optionsString, void *res if (!NSK_VERIFY(nsk_aod_agentLoaded(jni, AGENT_NAME))) return JNI_ERR; - if (optionsString == NULL) { + if (optionsString == nullptr) { success = 0; printf("%s: ERROR: unexpected null options\n", AGENT_NAME); fflush(stdout); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/aod/VirtualMachine/VirtualMachine07/agent01.cpp b/test/hotspot/jtreg/vmTestbase/nsk/aod/VirtualMachine/VirtualMachine07/agent01.cpp index 04949f4d861..d2c5f13cd34 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/aod/VirtualMachine/VirtualMachine07/agent01.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/aod/VirtualMachine/VirtualMachine07/agent01.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024, 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 @@ -40,7 +40,7 @@ JNIEXPORT jint JNICALL Agent_OnAttach(JavaVM *vm, char *optionsString, void *res // can't use NSK_DISPLAY since needed for nsk_ functions initialization isn't done here jni = (JNIEnv*) nsk_aod_createJNIEnv(vm); - if (jni == NULL) + if (jni == nullptr) return JNI_ERR; printf("%s: initialization was done\n", AGENT_NAME); @@ -49,7 +49,7 @@ JNIEXPORT jint JNICALL Agent_OnAttach(JavaVM *vm, char *optionsString, void *res if (!NSK_VERIFY(nsk_aod_agentLoaded(jni, AGENT_NAME))) return JNI_ERR; - if (optionsString == NULL) { + if (optionsString == nullptr) { success = 0; printf("%s: ERROR: unexpected null options\n", AGENT_NAME); fflush(stdout); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/aod/VirtualMachine/VirtualMachine07/agent02.cpp b/test/hotspot/jtreg/vmTestbase/nsk/aod/VirtualMachine/VirtualMachine07/agent02.cpp index b93f3ba03c0..257511c60f3 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/aod/VirtualMachine/VirtualMachine07/agent02.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/aod/VirtualMachine/VirtualMachine07/agent02.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ JNIEXPORT jint JNICALL Agent_OnAttach(JavaVM *vm, char *optionsString, void *res // can't use NSK_DISPLAY since needed for nsk_ functions initialization isn't done here jni = (JNIEnv*) nsk_aod_createJNIEnv(vm); - if (jni == NULL) + if (jni == nullptr) return JNI_ERR; printf("%s: initialization was done\n", AGENT_NAME); @@ -51,7 +51,7 @@ JNIEXPORT jint JNICALL Agent_OnAttach(JavaVM *vm, char *optionsString, void *res if (!NSK_VERIFY(nsk_aod_agentLoaded(jni, AGENT_NAME))) return JNI_ERR; - if (optionsString == NULL) { + if (optionsString == nullptr) { success = 0; printf("%s: ERROR: unexpected null options\n", AGENT_NAME); fflush(stdout); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/aod/VirtualMachine/VirtualMachine07/agent03.cpp b/test/hotspot/jtreg/vmTestbase/nsk/aod/VirtualMachine/VirtualMachine07/agent03.cpp index 029057cc4b9..66bbc6a990a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/aod/VirtualMachine/VirtualMachine07/agent03.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/aod/VirtualMachine/VirtualMachine07/agent03.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ JNIEXPORT jint JNICALL Agent_OnAttach(JavaVM *vm, char *optionsString, void *res JNIEnv* jni; jni = (JNIEnv*) nsk_aod_createJNIEnv(vm); - if (jni == NULL) + if (jni == nullptr) return JNI_ERR; // can't use NSK_DISPLAY since needed for nsk_ functions initialization isn't done here diff --git a/test/hotspot/jtreg/vmTestbase/nsk/aod/VirtualMachine/VirtualMachine09/agent00.cpp b/test/hotspot/jtreg/vmTestbase/nsk/aod/VirtualMachine/VirtualMachine09/agent00.cpp index c63187191d9..e7e6452603f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/aod/VirtualMachine/VirtualMachine09/agent00.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/aod/VirtualMachine/VirtualMachine09/agent00.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,18 +44,18 @@ JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *vm, char *optionsString, void *reser } JNIEXPORT jint JNICALL Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved) { - JNIEnv* jni = NULL; - Options* options = NULL; + JNIEnv* jni = nullptr; + Options* options = nullptr; const char* agentName; options = (Options*) nsk_aod_createOptions(optionsString); - if (!NSK_VERIFY(options != NULL)) + if (!NSK_VERIFY(options != nullptr)) return JNI_ERR; agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION); jni = (JNIEnv*) nsk_aod_createJNIEnv(vm); - if (jni == NULL) + if (jni == nullptr) return JNI_ERR; NSK_DISPLAY1("%s: initialization was done\n", agentName); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AddCapabilities/addcaps001/addcaps001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AddCapabilities/addcaps001/addcaps001.cpp index 86626181ea3..65ff008a046 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AddCapabilities/addcaps001/addcaps001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AddCapabilities/addcaps001/addcaps001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -268,7 +268,7 @@ callbackVMDeath(jvmtiEnv* jvmti, JNIEnv* jni) { success = checkCapabilities(jvmti, &initCaps, "VM_DEATH callback"); NSK_DISPLAY1("Disable events: %d events\n", EVENTS_COUNT); - if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, NULL)) { + if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, nullptr)) { success = NSK_FALSE; } else { NSK_DISPLAY0(" ... disabled\n"); @@ -295,7 +295,7 @@ JNIEXPORT jint JNI_OnLoad_addcaps001(JavaVM *jvm, char *options, void *reserved) } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -303,7 +303,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; { @@ -318,7 +318,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; NSK_DISPLAY0(">>> Testcase #0: Add empty capabilities list in Agent_OnLoad()\n"); @@ -333,7 +333,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } NSK_DISPLAY1("Enable events: %d events\n", EVENTS_COUNT); - if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, NULL)) { + if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, nullptr)) { NSK_DISPLAY0(" ... enabled\n"); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AddCapabilities/addcaps002/addcaps002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AddCapabilities/addcaps002/addcaps002.cpp index 54b85588f5c..5853d3db13e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AddCapabilities/addcaps002/addcaps002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AddCapabilities/addcaps002/addcaps002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -287,7 +287,7 @@ callbackVMDeath(jvmtiEnv* jvmti, JNIEnv* jni) { success = checkCapabilities(jvmti, &initCaps, "VM_DEATH callback"); NSK_DISPLAY1("Disable events: %d events\n", EVENTS_COUNT); - if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, NULL)) { + if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, nullptr)) { success = NSK_FALSE; } else { NSK_DISPLAY0(" ... disabled\n"); @@ -314,7 +314,7 @@ JNIEXPORT jint JNI_OnLoad_addcaps002(JavaVM *jvm, char *options, void *reserved) } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -322,7 +322,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; { @@ -337,7 +337,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&initCaps, 0, sizeof(jvmtiCapabilities)); @@ -356,7 +356,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } NSK_DISPLAY1("Enable events: %d events\n", EVENTS_COUNT); - if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, NULL)) { + if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, nullptr)) { NSK_DISPLAY0(" ... enabled\n"); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AddCapabilities/addcaps003/addcaps003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AddCapabilities/addcaps003/addcaps003.cpp index 0f5476edc1d..742d50aaf8e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AddCapabilities/addcaps003/addcaps003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AddCapabilities/addcaps003/addcaps003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -136,7 +136,7 @@ callbackVMDeath(jvmtiEnv* jvmti, JNIEnv* jni) { success = checkCapabilities(jvmti, &initCaps, "VM_DEATH callback"); NSK_DISPLAY1("Disable events: %d events\n", EVENTS_COUNT); - if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, NULL)) { + if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, nullptr)) { success = NSK_FALSE; } else { NSK_DISPLAY0(" ... disabled\n"); @@ -163,7 +163,7 @@ JNIEXPORT jint JNI_OnLoad_addcaps003(JavaVM *jvm, char *options, void *reserved) } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -171,7 +171,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; { @@ -186,7 +186,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&initCaps, 0, sizeof(jvmtiCapabilities)); @@ -205,7 +205,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } NSK_DISPLAY1("Enable events: %d events\n", EVENTS_COUNT); - if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, NULL)) { + if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, nullptr)) { NSK_DISPLAY0(" ... enabled\n"); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Agent_OnLoad/agentonload001/agentonload001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Agent_OnLoad/agentonload001/agentonload001.cpp index 1aa6e1b6679..b74de21db4e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Agent_OnLoad/agentonload001/agentonload001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Agent_OnLoad/agentonload001/agentonload001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -67,13 +67,13 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { NSK_DISPLAY1(" options: \"%s\"\n", nsk_null_string(options)); NSK_DISPLAY1(" reserved: 0x%p\n", (void*)jvm); - if (jvm == NULL) { - NSK_COMPLAIN1("First parameter 'vm' in JVM_OnLoad() is NULL: 0x%p\n", (void*)jvm); + if (jvm == nullptr) { + NSK_COMPLAIN1("First parameter 'vm' in JVM_OnLoad() is null: 0x%p\n", (void*)jvm); status = STATUS_FAILED; } - if (options == NULL) { - NSK_COMPLAIN1("Second parameter 'options' in JVM_OnLoad() is NULL: 0x%p\n", (void*)options); + if (options == nullptr) { + NSK_COMPLAIN1("Second parameter 'options' in JVM_OnLoad() is null: 0x%p\n", (void*)options); status = STATUS_FAILED; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Agent_OnLoad/agentonload002/agentonload002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Agent_OnLoad/agentonload002/agentonload002.cpp index d591cac18a5..abec073b2f8 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Agent_OnLoad/agentonload002/agentonload002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Agent_OnLoad/agentonload002/agentonload002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -48,8 +48,8 @@ JNIEXPORT jint JNI_OnLoad_agentonload002(JavaVM *jvm, char *options, void *reser #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - if (options == NULL) { - printf("# ERROR: Second parameter 'options' in JVM_OnLoad() is NULL: 0x%p\n", + if (options == nullptr) { + printf("# ERROR: Second parameter 'options' in JVM_OnLoad() is null: 0x%p\n", (void*)options); return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Agent_OnLoad/agentonload003/agentonload003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Agent_OnLoad/agentonload003/agentonload003.cpp index 9aa1c4a0e58..271bf79be5b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Agent_OnLoad/agentonload003/agentonload003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Agent_OnLoad/agentonload003/agentonload003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -48,8 +48,8 @@ JNIEXPORT jint JNI_OnLoad_agentonload003(JavaVM *jvm, char *options, void *reser #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - if (options == NULL) { - printf("# ERROR: Second parameter 'options' in JVM_OnLoad() is NULL: 0x%p\n", + if (options == nullptr) { + printf("# ERROR: Second parameter 'options' in JVM_OnLoad() is null: 0x%p\n", (void*)options); return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Allocate/alloc001/alloc001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Allocate/alloc001/alloc001.cpp index d2df97bdea9..77402be9a4d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Allocate/alloc001/alloc001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Allocate/alloc001/alloc001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -40,7 +40,7 @@ extern "C" { // limit virtual memory (this usually happens on mac). #define MAX_CHUNK_COUNT 8 * 1024 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; #ifdef STATIC_BUILD @@ -59,7 +59,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -71,17 +71,17 @@ JNIEXPORT jint JNICALL Java_nsk_jvmti_Allocate_alloc001_Test_check(JNIEnv *env, jclass cls) { jvmtiError err; size_t size; - void *prev = NULL; + void *prev = nullptr; void **mem; int memCount = 1; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } printf(">>> Null pointer check ...\n"); - err = jvmti->Allocate((jlong)1, NULL); + err = jvmti->Allocate((jlong)1, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { printf("Error expected: JVMTI_ERROR_NULL_POINTER, got: %s\n", TranslateError(err)); @@ -135,7 +135,7 @@ Java_nsk_jvmti_Allocate_alloc001_Test_check(JNIEnv *env, jclass cls) { printf(">>> ... done (%dMb)\n", memCount); printf(">>> Deallocation ...\n"); - while (prev != NULL) { + while (prev != nullptr) { mem = (void**) prev; prev = *mem; err = jvmti->Deallocate((unsigned char *)mem); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach002/attach002Agent00.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach002/attach002Agent00.cpp index de5229e6b6e..53283bd74ad 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach002/attach002Agent00.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach002/attach002Agent00.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -45,7 +45,7 @@ extern "C" { // class name in the ClassFileLoadHook callback #define REDEFINED_CLASS_NAME_INTERNAL "nsk/jvmti/AttachOnDemand/attach002/ClassToRedefine" -static Options* options = NULL; +static Options* options = nullptr; static const char* agentName; static volatile jboolean agentGotCapabilities = JNI_FALSE; @@ -152,13 +152,13 @@ void JNICALL classFileLoadHoockHandler( jint * new_class_data_len, unsigned char** new_class_data) { - if (name != NULL) { + if (name != nullptr) { NSK_DISPLAY2("%s: ClassFileLoadHook event received for class '%s'\n", agentName, name); if (!strcmp(name, REDEFINED_CLASS_NAME_INTERNAL)) { classFileLoadHookReceived++; } } else { - NSK_DISPLAY1("%s: ClassFileLoadHook event received for class with NULL name\n", agentName); + NSK_DISPLAY1("%s: ClassFileLoadHook event received for class with null name\n", agentName); } } @@ -177,21 +177,21 @@ Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved) { jvmtiEventCallbacks eventCallbacks; jvmtiCapabilities caps; - jvmtiEnv* jvmti = NULL; - JNIEnv* jni = NULL; + jvmtiEnv* jvmti = nullptr; + JNIEnv* jni = nullptr; options = (Options*) nsk_aod_createOptions(optionsString); - if (!NSK_VERIFY(options != NULL)) + if (!NSK_VERIFY(options != nullptr)) return JNI_ERR; agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION); jni = (JNIEnv*) nsk_aod_createJNIEnv(vm); - if (jni == NULL) + if (jni == nullptr) return NSK_FALSE; jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; registerNativeMethods(jni); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach002a/attach002aAgent00.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach002a/attach002aAgent00.cpp index ccc022edd1f..0ff97a05b20 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach002a/attach002aAgent00.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach002a/attach002aAgent00.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -40,7 +40,7 @@ extern "C" { #define REDEFINED_CLASS_NAME "Ljava/lang/InterruptedException;" #define REDEFINED_CLASS_FILE_NAME "java/lang/InterruptedException" -static Options* options = NULL; +static Options* options = nullptr; static const char* agentName; static jvmtiEvent testEvents[] = { JVMTI_EVENT_VM_OBJECT_ALLOC }; @@ -89,21 +89,21 @@ Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved) { jvmtiEventCallbacks eventCallbacks; jvmtiCapabilities caps; - jvmtiEnv* jvmti = NULL; - JNIEnv* jni = NULL; + jvmtiEnv* jvmti = nullptr; + JNIEnv* jni = nullptr; options = (Options*) nsk_aod_createOptions(optionsString); - if (!NSK_VERIFY(options != NULL)) + if (!NSK_VERIFY(options != nullptr)) return JNI_ERR; agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION); jni = (JNIEnv*) nsk_aod_createJNIEnv(vm); - if (jni == NULL) + if (jni == nullptr) return NSK_FALSE; jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; memset(&caps, 0, sizeof(caps)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach008/attach008Agent00.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach008/attach008Agent00.cpp index c1e9bce3ee3..b65c1cd6d9f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach008/attach008Agent00.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach008/attach008Agent00.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ extern "C" { #define THREAD_GENERATING_EVENTS_NAME "ThreadGeneratingEvents" -static Options* options = NULL; +static Options* options = nullptr; static const char* agentName; static jvmtiEvent testEvents[] = { JVMTI_EVENT_MONITOR_CONTENDED_ENTER, JVMTI_EVENT_MONITOR_CONTENDED_ENTERED }; @@ -107,21 +107,21 @@ Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved) { jvmtiEventCallbacks eventCallbacks; jvmtiCapabilities caps; - jvmtiEnv* jvmti = NULL; - JNIEnv* jni = NULL; + jvmtiEnv* jvmti = nullptr; + JNIEnv* jni = nullptr; options = (Options*) nsk_aod_createOptions(optionsString); - if (!NSK_VERIFY(options != NULL)) + if (!NSK_VERIFY(options != nullptr)) return JNI_ERR; agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION); jni = (JNIEnv*) nsk_aod_createJNIEnv(vm); - if (jni == NULL) + if (jni == nullptr) return NSK_FALSE; jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; memset(&caps, 0, sizeof(caps)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach009/attach009Agent00.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach009/attach009Agent00.cpp index 3256b62582f..62afb281ba2 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach009/attach009Agent00.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach009/attach009Agent00.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ extern "C" { * - receive ClassLoad event for class LastLoadedClass and finish work */ -static Options* options = NULL; +static Options* options = nullptr; static const char* agentName; #define FIRST_LOADED_CLASS "Lnsk/jvmti/AttachOnDemand/attach009/FirstLoadedClass;" @@ -129,17 +129,17 @@ Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved) JNIEnv* jni; options = (Options*) nsk_aod_createOptions(optionsString); - if (!NSK_VERIFY(options != NULL)) + if (!NSK_VERIFY(options != nullptr)) return JNI_ERR; agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION); jni = (JNIEnv*) nsk_aod_createJNIEnv(vm); - if (jni == NULL) + if (jni == nullptr) return NSK_FALSE; jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; memset(&eventCallbacks,0, sizeof(eventCallbacks)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach012/attach012Agent00.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach012/attach012Agent00.cpp index 64ab7c0974b..05ee3d82ac5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach012/attach012Agent00.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach012/attach012Agent00.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024, 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,23 +49,23 @@ Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved) #endif { jvmtiEnv* jvmti; - JNIEnv* jni = NULL; - Options* options = NULL; + JNIEnv* jni = nullptr; + Options* options = nullptr; const char* agentName; jvmtiCapabilities caps; options = (Options*) nsk_aod_createOptions(optionsString); - if (!NSK_VERIFY(options != NULL)) + if (!NSK_VERIFY(options != nullptr)) return JNI_ERR; agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION); jni = (JNIEnv*) nsk_aod_createJNIEnv(vm); - if (jni == NULL) + if (jni == nullptr) return NSK_FALSE; jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->GetPotentialCapabilities(&caps))) { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach014/attach014Agent00.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach014/attach014Agent00.cpp index ce3fa29a4e2..4575d4d7bfb 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach014/attach014Agent00.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach014/attach014Agent00.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ extern "C" { * - agent receives ClassLoad event for this class, calls DisposeEnvironment and finishes work */ -static Options* options = NULL; +static Options* options = nullptr; static const char* agentName; void JNICALL @@ -88,21 +88,21 @@ Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved) #endif { jvmtiEventCallbacks eventCallbacks; - jvmtiEnv* jvmti = NULL; - JNIEnv* jni = NULL; + jvmtiEnv* jvmti = nullptr; + JNIEnv* jni = nullptr; options = (Options*) nsk_aod_createOptions(optionsString); - if (!NSK_VERIFY(options != NULL)) + if (!NSK_VERIFY(options != nullptr)) return JNI_ERR; agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION); jni = (JNIEnv*) nsk_aod_createJNIEnv(vm); - if (jni == NULL) + if (jni == nullptr) return NSK_FALSE; jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; memset(&eventCallbacks,0, sizeof(eventCallbacks)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach015/attach015Agent00.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach015/attach015Agent00.cpp index a28c912880c..c96519aecf2 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach015/attach015Agent00.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach015/attach015Agent00.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -40,7 +40,7 @@ extern "C" { #define CLASS_NAME1 "Lnsk/jvmti/AttachOnDemand/attach015/ClassToLoad1;" #define CLASS_NAME2 "Lnsk/jvmti/AttachOnDemand/attach015/ClassToLoad2;" -static Options* options = NULL; +static Options* options = nullptr; static const char* agentName; static int receivedEventsCount = 0; @@ -81,21 +81,21 @@ Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved) #endif { jvmtiEventCallbacks eventCallbacks; - jvmtiEnv* jvmti = NULL; - JNIEnv* jni = NULL; + jvmtiEnv* jvmti = nullptr; + JNIEnv* jni = nullptr; options = (Options*) nsk_aod_createOptions(optionsString); - if (!NSK_VERIFY(options != NULL)) + if (!NSK_VERIFY(options != nullptr)) return JNI_ERR; agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION); jni = (JNIEnv*) nsk_aod_createJNIEnv(vm); - if (jni == NULL) + if (jni == nullptr) return NSK_FALSE; jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; memset(&eventCallbacks,0, sizeof(eventCallbacks)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach015/attach015Agent01.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach015/attach015Agent01.cpp index 78527c41cc8..eb42625c140 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach015/attach015Agent01.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach015/attach015Agent01.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -40,7 +40,7 @@ extern "C" { #define CLASS_NAME1 "Lnsk/jvmti/AttachOnDemand/attach015/ClassToLoad1;" #define CLASS_NAME2 "Lnsk/jvmti/AttachOnDemand/attach015/ClassToLoad2;" -static Options* options = NULL; +static Options* options = nullptr; static const char* agentName; static int receivedEventsCount = 0; @@ -81,21 +81,21 @@ Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved) #endif { jvmtiEventCallbacks eventCallbacks; - jvmtiEnv* jvmti = NULL; - JNIEnv* jni = NULL; + jvmtiEnv* jvmti = nullptr; + JNIEnv* jni = nullptr; options = (Options*) nsk_aod_createOptions(optionsString); - if (!NSK_VERIFY(options != NULL)) + if (!NSK_VERIFY(options != nullptr)) return JNI_ERR; agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION); jni = (JNIEnv*) nsk_aod_createJNIEnv(vm); - if (jni == NULL) + if (jni == nullptr) return JNI_ERR; jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; memset(&eventCallbacks,0, sizeof(eventCallbacks)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach020/attach020Agent00.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach020/attach020Agent00.cpp index 0a229c858a2..7552e2bb936 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach020/attach020Agent00.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach020/attach020Agent00.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ extern "C" { * */ -static Options* options = NULL; +static Options* options = nullptr; static const char* agentName; static jvmtiEvent testEvents[] = { JVMTI_EVENT_GARBAGE_COLLECTION_START, JVMTI_EVENT_GARBAGE_COLLECTION_FINISH }; @@ -116,10 +116,10 @@ int startAuxiliaryThread(jvmtiEnv* jvmti, JNIEnv* jni) { jthread thread; thread = nsk_jvmti_aod_createThread(jni); - if (!NSK_VERIFY(thread != NULL)) + if (!NSK_VERIFY(thread != nullptr)) return NSK_FALSE; - if (!NSK_JVMTI_VERIFY(jvmti->RunAgentThread(thread, auxiliaryThreadFunction, NULL, JVMTI_THREAD_NORM_PRIORITY))) { + if (!NSK_JVMTI_VERIFY(jvmti->RunAgentThread(thread, auxiliaryThreadFunction, nullptr, JVMTI_THREAD_NORM_PRIORITY))) { return NSK_FALSE; } @@ -147,17 +147,17 @@ Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved) JNIEnv* jni; options = (Options*) nsk_aod_createOptions(optionsString); - if (!NSK_VERIFY(options != NULL)) + if (!NSK_VERIFY(options != nullptr)) return JNI_ERR; agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION); jni = (JNIEnv*) nsk_aod_createJNIEnv(vm); - if (jni == NULL) + if (jni == nullptr) return JNI_ERR; jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("GCFinishMonitor", &gcFinishMonitor))) { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach021/attach021Agent00.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach021/attach021Agent00.cpp index 9a921d36a6f..cae9a35c8ee 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach021/attach021Agent00.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach021/attach021Agent00.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -48,7 +48,7 @@ extern "C" { static jvmtiEnv* jvmti; -static Options* options = NULL; +static Options* options = nullptr; static const char* agentName; // agent should set success status from objectFreeHandler @@ -74,7 +74,7 @@ Java_nsk_jvmti_AttachOnDemand_attach021_attach021Target_shutdownAgent(JNIEnv * j for any pending ObjectFree events. */ if (jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_OBJECT_FREE, - NULL) != JVMTI_ERROR_NONE) { + nullptr) != JVMTI_ERROR_NONE) { success = 0; } @@ -127,17 +127,17 @@ Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved) JNIEnv* jni; options = (Options*) nsk_aod_createOptions(optionsString); - if (!NSK_VERIFY(options != NULL)) + if (!NSK_VERIFY(options != nullptr)) return JNI_ERR; agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION); jni = (JNIEnv*) nsk_aod_createJNIEnv(vm); - if (jni == NULL) + if (jni == nullptr) return JNI_ERR; jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; registerNativeMethods(jni); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach022/attach022Agent00.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach022/attach022Agent00.cpp index dfece015378..422cfa01356 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach022/attach022Agent00.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach022/attach022Agent00.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ extern "C" { #define OBJECTS_FOR_ALLOCATION_TEST_CLASS_NAME "Lnsk/jvmti/AttachOnDemand/attach022/ClassForAllocationEventsTest;" static jvmtiEnv* jvmti; -static Options* options = NULL; +static Options* options = nullptr; static const char* agentName; static jvmtiEvent testEvents[] = { JVMTI_EVENT_OBJECT_FREE, JVMTI_EVENT_VM_OBJECT_ALLOC }; @@ -174,17 +174,17 @@ Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved) JNIEnv* jni; options = (Options*) nsk_aod_createOptions(optionsString); - if (!NSK_VERIFY(options != NULL)) + if (!NSK_VERIFY(options != nullptr)) return JNI_ERR; agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION); jni = (JNIEnv*) nsk_aod_createJNIEnv(vm); - if (jni == NULL) + if (jni == nullptr) return JNI_ERR; jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; registerNativeMethods(jni); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach037/attach037Agent00.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach037/attach037Agent00.cpp index c7e22cdd3f0..798c1a77bc1 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach037/attach037Agent00.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach037/attach037Agent00.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ extern "C" { #define THREAD_GENERATING_EVENTS_NAME "ThreadGeneratingEvents" -static Options* options = NULL; +static Options* options = nullptr; static const char* agentName; static jvmtiEvent testEvents[] = { JVMTI_EVENT_MONITOR_WAIT, JVMTI_EVENT_MONITOR_WAITED }; @@ -110,17 +110,17 @@ Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved) JNIEnv* jni; options = (Options*) nsk_aod_createOptions(optionsString); - if (!NSK_VERIFY(options != NULL)) + if (!NSK_VERIFY(options != nullptr)) return JNI_ERR; agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION); jni = (JNIEnv*) nsk_aod_createJNIEnv(vm); - if (jni == NULL) + if (jni == nullptr) return JNI_ERR; jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; memset(&caps, 0, sizeof(caps)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach038/attach038Agent00.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach038/attach038Agent00.cpp index d2f0767a9a4..6e66ecde85f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach038/attach038Agent00.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach038/attach038Agent00.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ extern "C" { #define THREAD_GENERATING_EVENTS_NAME "ThreadGeneratingEvents" -static Options* options = NULL; +static Options* options = nullptr; static const char* agentName; static jvmtiEvent testEvents[] = { JVMTI_EVENT_THREAD_START, JVMTI_EVENT_THREAD_END }; @@ -106,17 +106,17 @@ Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved) JNIEnv* jni; options = (Options*) nsk_aod_createOptions(optionsString); - if (!NSK_VERIFY(options != NULL)) + if (!NSK_VERIFY(options != nullptr)) return JNI_ERR; agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION); jni = (JNIEnv*) nsk_aod_createJNIEnv(vm); - if (jni == NULL) + if (jni == nullptr) return JNI_ERR; jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; memset(&eventCallbacks,0, sizeof(eventCallbacks)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach039/attach039Agent00.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach039/attach039Agent00.cpp index 7fcea1fac3b..d1ca8919c40 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach039/attach039Agent00.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach039/attach039Agent00.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -40,7 +40,7 @@ extern "C" { #define STARTED_THREAD_NAME "ThreadStartedByAgent" -static Options* options = NULL; +static Options* options = nullptr; static const char* agentName; static jvmtiEvent testEvents[] = { JVMTI_EVENT_THREAD_START, JVMTI_EVENT_THREAD_END }; @@ -52,7 +52,7 @@ volatile int threadWasExecuted = 0; void JNICALL startedThreadFunction(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { char threadName[MAX_STRING_LENGTH]; - if (!nsk_jvmti_aod_getThreadName(jvmti, NULL, threadName)) { + if (!nsk_jvmti_aod_getThreadName(jvmti, nullptr, threadName)) { nsk_jvmti_aod_disableEventsAndFinish(agentName, testEvents, testEventsNumber, 0, jvmti, jni); return; } @@ -66,10 +66,10 @@ int startNewThread(jvmtiEnv* jvmti, JNIEnv* jni) { jthread thread; thread = nsk_jvmti_aod_createThreadWithName(jni, STARTED_THREAD_NAME); - if (!NSK_VERIFY(thread != NULL)) + if (!NSK_VERIFY(thread != nullptr)) return NSK_FALSE; - if (!NSK_JVMTI_VERIFY(jvmti->RunAgentThread(thread, startedThreadFunction, NULL, JVMTI_THREAD_NORM_PRIORITY))) { + if (!NSK_JVMTI_VERIFY(jvmti->RunAgentThread(thread, startedThreadFunction, nullptr, JVMTI_THREAD_NORM_PRIORITY))) { return NSK_FALSE; } @@ -142,17 +142,17 @@ Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved) JNIEnv* jni; options = (Options*) nsk_aod_createOptions(optionsString); - if (!NSK_VERIFY(options != NULL)) + if (!NSK_VERIFY(options != nullptr)) return JNI_ERR; agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION); jni = (JNIEnv*) nsk_aod_createJNIEnv(vm); - if (jni == NULL) + if (jni == nullptr) return JNI_ERR; jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; memset(&eventCallbacks,0, sizeof(eventCallbacks)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach040/attach040Agent00.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach040/attach040Agent00.cpp index b5ec2fbf809..d4ee65131c5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach040/attach040Agent00.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach040/attach040Agent00.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,7 +47,7 @@ static jrawMonitorID threadsCounterMonitor; static volatile int testThreadsCounter = 0; -static Options* options = NULL; +static Options* options = nullptr; static const char* agentName; void JNICALL threadStartHandler(jvmtiEnv *jvmti, @@ -134,17 +134,17 @@ Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved) JNIEnv* jni; options = (Options*) nsk_aod_createOptions(optionsString); - if (!NSK_VERIFY(options != NULL)) + if (!NSK_VERIFY(options != nullptr)) return JNI_ERR; agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION); jni = (JNIEnv*) nsk_aod_createJNIEnv(vm); - if (jni == NULL) + if (jni == nullptr) return JNI_ERR; jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("threadsCounterMonitor", &threadsCounterMonitor))) { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach041/attach041Agent00.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach041/attach041Agent00.cpp index 6934868d6d3..e2aeb3c8dbe 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach041/attach041Agent00.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach041/attach041Agent00.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -40,14 +40,14 @@ extern "C" { #define STARTED_TEST_THREAD_NAME "attach041-TestThread" -static Options* options = NULL; +static Options* options = nullptr; static const char* agentName; int tryFindThread(jvmtiEnv *jvmti, jthreadGroup group, const char* threadNameToFind) { jint threadsCount = 0; - jthread *threads = NULL; + jthread *threads = nullptr; jint groupsCount = 0; - jthreadGroup* groups = NULL; + jthreadGroup* groups = nullptr; jvmtiThreadGroupInfo groupInfo; int i; char threadGroupName[MAX_STRING_LENGTH]; @@ -160,17 +160,17 @@ Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved) JNIEnv* jni; options = (Options*) nsk_aod_createOptions(optionsString); - if (!NSK_VERIFY(options != NULL)) + if (!NSK_VERIFY(options != nullptr)) return JNI_ERR; agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION); jni = (JNIEnv*) nsk_aod_createJNIEnv(vm); - if (jni == NULL) + if (jni == nullptr) return JNI_ERR; jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; memset(&eventCallbacks,0, sizeof(eventCallbacks)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach042/attach042Agent00.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach042/attach042Agent00.cpp index 0edaf1107ad..262fd40fd26 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach042/attach042Agent00.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach042/attach042Agent00.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -40,7 +40,7 @@ extern "C" { #define STARTED_TEST_THREAD_NAME "attach042-TestThread" -static Options* options = NULL; +static Options* options = nullptr; static const char* agentName; void JNICALL threadStartHandler(jvmtiEnv *jvmti, @@ -58,7 +58,7 @@ void JNICALL threadStartHandler(jvmtiEnv *jvmti, if (!strcmp(startedThreadName, STARTED_TEST_THREAD_NAME)) { int success = 1; jint threadsCount = 0; - jthread* threads = NULL; + jthread* threads = nullptr; int i; int startedThreadWasFound = 0; @@ -124,17 +124,17 @@ Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved) JNIEnv* jni; options = (Options*) nsk_aod_createOptions(optionsString); - if (!NSK_VERIFY(options != NULL)) + if (!NSK_VERIFY(options != nullptr)) return JNI_ERR; agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION); jni = (JNIEnv*) nsk_aod_createJNIEnv(vm); - if (jni == NULL) + if (jni == nullptr) return JNI_ERR; jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; memset(&eventCallbacks,0, sizeof(eventCallbacks)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach045/attach045Agent00.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach045/attach045Agent00.cpp index a196150bc81..593f880330d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach045/attach045Agent00.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach045/attach045Agent00.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ extern "C" { #define EXPECTED_EVENTS_NUMBER 500 -static Options* options = NULL; +static Options* options = nullptr; static const char* agentName; static jrawMonitorID eventsCounterMonitor; @@ -98,17 +98,17 @@ Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved) JNIEnv* jni; options = (Options*) nsk_aod_createOptions(optionsString); - if (!NSK_VERIFY(options != NULL)) + if (!NSK_VERIFY(options != nullptr)) return JNI_ERR; agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION); jni = (JNIEnv*) nsk_aod_createJNIEnv(vm); - if (jni == NULL) + if (jni == nullptr) return JNI_ERR; jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("attach045-agent00-eventsCounterMonitor", &eventsCounterMonitor))) { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach045/attach045Agent01.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach045/attach045Agent01.cpp index a7ce1343d9e..a3957d5b2ce 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach045/attach045Agent01.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach045/attach045Agent01.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ extern "C" { #define EXPECTED_EVENTS_NUMBER 500 -static Options* options = NULL; +static Options* options = nullptr; static const char* agentName; static jrawMonitorID eventsCounterMonitor; @@ -109,17 +109,17 @@ Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved) JNIEnv* jni; options = (Options*) nsk_aod_createOptions(optionsString); - if (!NSK_VERIFY(options != NULL)) + if (!NSK_VERIFY(options != nullptr)) return JNI_ERR; agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION); jni = (JNIEnv*) nsk_aod_createJNIEnv(vm); - if (jni == NULL) + if (jni == nullptr) return JNI_ERR; jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("attach045-agent01-eventsCounterMonitor", &eventsCounterMonitor))) { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach045/attach045Agent02.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach045/attach045Agent02.cpp index f2f05136e6d..a4e08c526f2 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach045/attach045Agent02.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach045/attach045Agent02.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ extern "C" { #define EXPECTED_EVENTS_NUMBER 200 -static Options* options = NULL; +static Options* options = nullptr; static const char* agentName; static jvmtiEvent testEvents[] = { JVMTI_EVENT_THREAD_START, JVMTI_EVENT_THREAD_END }; @@ -129,17 +129,17 @@ Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved) JNIEnv* jni; options = (Options*) nsk_aod_createOptions(optionsString); - if (!NSK_VERIFY(options != NULL)) + if (!NSK_VERIFY(options != nullptr)) return JNI_ERR; agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION); jni = (JNIEnv*) nsk_aod_createJNIEnv(vm); - if (jni == NULL) + if (jni == nullptr) return JNI_ERR; jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("attach045-agent02-eventsCounterMonitor", &eventsCounterMonitor))) { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach045/attach045Agent03.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach045/attach045Agent03.cpp index 65bd1604681..7cb7362289d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach045/attach045Agent03.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach045/attach045Agent03.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ extern "C" { #define EXPECTED_EVENTS_NUMBER 500 -static Options* options = NULL; +static Options* options = nullptr; static const char* agentName; static jvmtiEvent testEvents[] = { JVMTI_EVENT_VM_OBJECT_ALLOC }; @@ -119,17 +119,17 @@ Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved) JNIEnv* jni; options = (Options*) nsk_aod_createOptions(optionsString); - if (!NSK_VERIFY(options != NULL)) + if (!NSK_VERIFY(options != nullptr)) return JNI_ERR; agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION); jni = (JNIEnv*) nsk_aod_createJNIEnv(vm); - if (jni == NULL) + if (jni == nullptr) return JNI_ERR; jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("attach045-agent03-eventsCounterMonitor", &eventsCounterMonitor))) { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach046/attach046Agent00.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach046/attach046Agent00.cpp index 0c1e03cf5f0..df01f06eac5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach046/attach046Agent00.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach046/attach046Agent00.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ void JNICALL classLoadHandler( Options* options; options = nsk_jvmti_aod_getMultiagentsOptions(jvmti); - if (!NSK_VERIFY(options != NULL)) { + if (!NSK_VERIFY(options != nullptr)) { NSK_COMPLAIN0("Failed to get agents's options\n"); nsk_jvmti_aod_disableEvent(jvmti, JVMTI_EVENT_CLASS_LOAD); // can't call nsk_aod_agentFinished because of without options can't get agent's name @@ -96,23 +96,23 @@ Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved) { jvmtiEventCallbacks eventCallbacks; jvmtiCapabilities caps; - jvmtiEnv* jvmti = NULL; - JNIEnv* jni = NULL; + jvmtiEnv* jvmti = nullptr; + JNIEnv* jni = nullptr; Options* options; const char* agentName; options = (Options*) nsk_aod_createOptions(optionsString); - if (!NSK_VERIFY(options != NULL)) + if (!NSK_VERIFY(options != nullptr)) return JNI_ERR; agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION); jni = (JNIEnv*) nsk_aod_createJNIEnv(vm); - if (jni == NULL) + if (jni == nullptr) return NSK_FALSE; jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; memset(&caps, 0, sizeof(caps)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach050/attach050Agent00.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach050/attach050Agent00.cpp index 6a7ceeb4c48..beaca490a34 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach050/attach050Agent00.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach050/attach050Agent00.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024, 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 @@ -54,22 +54,22 @@ Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved) #endif { jvmtiEnv* jvmti; - JNIEnv* jni = NULL; - Options* options = NULL; + JNIEnv* jni = nullptr; + Options* options = nullptr; const char* agentName; options = (Options*) nsk_aod_createOptions(optionsString); - if (!NSK_VERIFY(options != NULL)) + if (!NSK_VERIFY(options != nullptr)) return JNI_ERR; agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION); jni = (JNIEnv*) nsk_aod_createJNIEnv(vm); - if (jni == NULL) + if (jni == nullptr) return JNI_ERR; jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; NSK_DISPLAY1("%s: initialization was done\n", agentName); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/sharedAgents/simpleAgent00.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/sharedAgents/simpleAgent00.cpp index d24922f2bfe..8f0f986f05d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/sharedAgents/simpleAgent00.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/sharedAgents/simpleAgent00.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024, 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 @@ -50,22 +50,22 @@ Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved) #endif { jvmtiEnv* jvmti; - JNIEnv* jni = NULL; - Options* options = NULL; + JNIEnv* jni = nullptr; + Options* options = nullptr; const char* agentName; options = (Options*) nsk_aod_createOptions(optionsString); - if (!NSK_VERIFY(options != NULL)) + if (!NSK_VERIFY(options != nullptr)) return JNI_ERR; agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION); jni = (JNIEnv*) nsk_aod_createJNIEnv(vm); - if (jni == NULL) + if (jni == nullptr) return JNI_ERR; jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; NSK_DISPLAY1("%s: initialization was done\n", agentName); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk001/classfloadhk001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk001/classfloadhk001.cpp index ef6c10fc9fc..e204e5aedf5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk001/classfloadhk001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk001/classfloadhk001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ extern "C" { const char* CLASS_NAME = "nsk/jvmti/ClassFileLoadHook/classfloadhk001"; static jint result = STATUS_FAILED; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; /** callback functions **/ @@ -51,7 +51,7 @@ ClassFileLoadHook(jvmtiEnv *jvmti_env, JNIEnv *env, jclass class_beeing_redefine jint class_data_len, const unsigned char* class_data, jint *new_class_data_len, unsigned char** new_class_data) { - if (name != NULL && (strcmp(name, CLASS_NAME) == 0)) { + if (name != nullptr && (strcmp(name, CLASS_NAME) == 0)) { NSK_DISPLAY1("CHECK PASSED: ClassFileLoadHook event received for the class \"%s\" as expected\n", name); result = PASSED; @@ -87,7 +87,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; NSK_DISPLAY0("setting event callbacks ...\n"); @@ -97,7 +97,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; NSK_DISPLAY0("setting event callbacks done\nenabling ClassFileLoadHook event ...\n"); - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, nullptr))) return JNI_ERR; NSK_DISPLAY0("enabling ClassFileLoadHook event done\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk002/classfloadhk002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk002/classfloadhk002.cpp index 520563f459f..976a53cc1c8 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk002/classfloadhk002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk002/classfloadhk002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ static jlong timeout = 0; #define BYTECODE_FIELD_SIG "[B" #define ORIG_BYTECODE_FIELD_NAME "origClassBytes" -static unsigned char* origClassBytes = NULL; +static unsigned char* origClassBytes = nullptr; static jint origClassSize = 0; static volatile int eventsCount = 0; @@ -59,8 +59,8 @@ static int checkBytecode(const char kind[], jint size, const unsigned char bytes nsk_printHexBytes(" ", 16, size, bytes); } - if (bytes == NULL) { - NSK_COMPLAIN2("Unexpected NULL pointer to %s bytecode in CLASS_FILE_LOAD_HOOK: 0x%p\n", + if (bytes == nullptr) { + NSK_COMPLAIN2("Unexpected null pointer to %s bytecode in CLASS_FILE_LOAD_HOOK: 0x%p\n", kind, (void*)bytes); return NSK_FALSE; } @@ -115,14 +115,14 @@ static int getBytecode(jvmtiEnv* jvmti, JNIEnv* jni, jclass cls, const char fieldName[], const char fieldSig[], jint* size, unsigned char* *bytes) { - jfieldID fieldID = NULL; - jbyteArray array = NULL; + jfieldID fieldID = nullptr; + jbyteArray array = nullptr; jbyte* elements; int i; NSK_DISPLAY1("Find static field: %s\n", fieldName); if (!NSK_JNI_VERIFY(jni, (fieldID = - jni->GetStaticFieldID(cls, fieldName, fieldSig)) != NULL)) { + jni->GetStaticFieldID(cls, fieldName, fieldSig)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -130,7 +130,7 @@ static int getBytecode(jvmtiEnv* jvmti, JNIEnv* jni, jclass cls, NSK_DISPLAY1("Get classfile bytes array from static field: %s\n", fieldName); if (!NSK_JNI_VERIFY(jni, (array = (jbyteArray) - jni->GetStaticObjectField(cls, fieldID)) != NULL)) { + jni->GetStaticObjectField(cls, fieldID)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -144,7 +144,7 @@ static int getBytecode(jvmtiEnv* jvmti, JNIEnv* jni, jclass cls, { jboolean isCopy; - if (!NSK_JNI_VERIFY(jni, (elements = jni->GetByteArrayElements(array, &isCopy)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (elements = jni->GetByteArrayElements(array, &isCopy)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -182,11 +182,11 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { { NSK_DISPLAY0(">>> Obtain original bytecode of tested class\n"); { - jclass debugeeClass = NULL; + jclass debugeeClass = nullptr; NSK_DISPLAY1("Find debugee class: %s\n", DEBUGEE_CLASS_NAME); if (!NSK_JNI_VERIFY(jni, (debugeeClass = - jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) { + jni->FindClass(DEBUGEE_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -204,7 +204,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { jvmtiEvent event = JVMTI_EVENT_CLASS_FILE_LOAD_HOOK; NSK_DISPLAY1("Enable event: %s\n", "CLASS_FILE_LOAD_HOOK"); - if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, NULL))) + if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, nullptr))) return; NSK_DISPLAY0(" ... event enabled\n"); @@ -216,7 +216,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { return; NSK_DISPLAY1("Disable event: %s\n", "CLASS_FILE_LOAD_HOOK"); - if (NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_DISABLE, 1, &event, NULL))) { + if (NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_DISABLE, 1, &event, nullptr))) { NSK_DISPLAY0(" ... event disabled\n"); } @@ -261,13 +261,13 @@ callbackClassFileLoadHook(jvmtiEnv *jvmti_env, JNIEnv *env, nsk_null_string(name), (void*)loader, (void*)class_being_redefined, (void*)class_data, (int)class_data_len); - if (name != NULL && (strcmp(name, TESTED_CLASS_NAME) == 0)) { + if (name != nullptr && (strcmp(name, TESTED_CLASS_NAME) == 0)) { NSK_DISPLAY1("SUCCESS! CLASS_FILE_LOAD_HOOK for tested class: %s\n", TESTED_CLASS_NAME); eventsCount++; NSK_DISPLAY1("Check class_being_redefined: 0x%p\n", (void*)class_being_redefined); - if (class_being_redefined != NULL) { - NSK_COMPLAIN1("Unexpected not NULL class_being_redefined in CLASS_FILE_LOAD_HOOK: 0x%p\n", + if (class_being_redefined != nullptr) { + NSK_COMPLAIN1("Unexpected not null class_being_redefined in CLASS_FILE_LOAD_HOOK: 0x%p\n", (void*)class_being_redefined); nsk_jvmti_setFailStatus(); } @@ -294,7 +294,7 @@ JNIEXPORT jint JNI_OnLoad_classfloadhk002(JavaVM *jvm, char *options, void *rese } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -304,7 +304,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; NSK_DISPLAY1("Add required capability: %s\n", "can_generate_eraly_class_hook_events"); @@ -333,7 +333,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { NSK_DISPLAY0(" ... set\n"); /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk003/classfloadhk003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk003/classfloadhk003.cpp index b9a11398753..d254e93b833 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk003/classfloadhk003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk003/classfloadhk003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -45,9 +45,9 @@ static jlong timeout = 0; #define BYTECODE_FIELD_SIG "[B" #define ORIG_BYTECODE_FIELD_NAME "origClassBytes" -static jobject classLoader = NULL; +static jobject classLoader = nullptr; static jint origClassSize = 0; -static unsigned char* origClassBytes = NULL; +static unsigned char* origClassBytes = nullptr; static volatile int eventsCount = 0; @@ -64,8 +64,8 @@ static int checkBytecode(const char kind[], jint size, const unsigned char bytes nsk_printHexBytes(" ", 16, size, bytes); } - if (bytes == NULL) { - NSK_COMPLAIN2("Unexpected NULL pointer to %s bytecode in CLASS_FILE_LOAD_HOOK: 0x%p\n", + if (bytes == nullptr) { + NSK_COMPLAIN2("Unexpected null pointer to %s bytecode in CLASS_FILE_LOAD_HOOK: 0x%p\n", kind, (void*)bytes); return NSK_FALSE; } @@ -120,14 +120,14 @@ static int getBytecode(jvmtiEnv* jvmti, JNIEnv* jni, jclass cls, const char fieldName[], const char fieldSig[], jint* size, unsigned char* *bytes) { - jfieldID fieldID = NULL; - jbyteArray array = NULL; + jfieldID fieldID = nullptr; + jbyteArray array = nullptr; jbyte* elements; int i; NSK_DISPLAY1("Find static field: %s\n", fieldName); if (!NSK_JNI_VERIFY(jni, (fieldID = - jni->GetStaticFieldID(cls, fieldName, fieldSig)) != NULL)) { + jni->GetStaticFieldID(cls, fieldName, fieldSig)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -135,7 +135,7 @@ static int getBytecode(jvmtiEnv* jvmti, JNIEnv* jni, jclass cls, NSK_DISPLAY1("Get classfile bytes array from static field: %s\n", fieldName); if (!NSK_JNI_VERIFY(jni, (array = (jbyteArray) - jni->GetStaticObjectField(cls, fieldID)) != NULL)) { + jni->GetStaticObjectField(cls, fieldID)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -149,7 +149,7 @@ static int getBytecode(jvmtiEnv* jvmti, JNIEnv* jni, jclass cls, { jboolean isCopy; - if (!NSK_JNI_VERIFY(jni, (elements = jni->GetByteArrayElements(array, &isCopy)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (elements = jni->GetByteArrayElements(array, &isCopy)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -178,28 +178,28 @@ static int getBytecode(jvmtiEnv* jvmti, JNIEnv* jni, jclass cls, static jobject getObject(jvmtiEnv* jvmti, JNIEnv* jni, jclass cls, const char fieldName[], const char fieldSig[]) { - jfieldID fieldID = NULL; - jobject obj = NULL; + jfieldID fieldID = nullptr; + jobject obj = nullptr; NSK_DISPLAY1("Find static field: %s\n", fieldName); if (!NSK_JNI_VERIFY(jni, (fieldID = - jni->GetStaticFieldID(cls, fieldName, fieldSig)) != NULL)) { + jni->GetStaticFieldID(cls, fieldName, fieldSig)) != nullptr)) { nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } NSK_DISPLAY1(" ... got fieldID: 0x%p\n", (void*)fieldID); NSK_DISPLAY1("Get object from static field: %s\n", fieldName); - if (!NSK_JNI_VERIFY(jni, (obj = jni->GetStaticObjectField(cls, fieldID)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (obj = jni->GetStaticObjectField(cls, fieldID)) != nullptr)) { nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } NSK_DISPLAY1(" ... got object: 0x%p\n", (void*)obj); NSK_DISPLAY1("Make global reference to object: 0x%p\n", obj); - if (!NSK_JNI_VERIFY(jni, (obj = jni->NewGlobalRef(obj)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (obj = jni->NewGlobalRef(obj)) != nullptr)) { nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } NSK_DISPLAY1(" ... got global ref: 0x%p\n", (void*)obj); @@ -218,12 +218,12 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { /* perform testing */ { { - jclass debugeeClass = NULL; + jclass debugeeClass = nullptr; NSK_DISPLAY0(">>> Obtain debuggee class\n"); NSK_DISPLAY1("Find debugee class: %s\n", DEBUGEE_CLASS_NAME); if (!NSK_JNI_VERIFY(jni, (debugeeClass = - jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) { + jni->FindClass(DEBUGEE_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -232,7 +232,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY0(">>> Obtain classloader of tested class\n"); if (!NSK_VERIFY((classLoader = getObject(jvmti, jni, debugeeClass, CLASSLOADER_FIELD_NAME, - TESTED_CLASSLOADER_SIG)) != NULL)) + TESTED_CLASSLOADER_SIG)) != nullptr)) return; NSK_DISPLAY0(">>> Obtain original bytecode of tested class\n"); @@ -248,7 +248,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { jvmtiEvent event = JVMTI_EVENT_CLASS_FILE_LOAD_HOOK; NSK_DISPLAY1("Enable event: %s\n", "CLASS_FILE_LOAD_HOOK"); - if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, NULL))) + if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, nullptr))) return; NSK_DISPLAY0(" ... event enabled\n"); @@ -260,7 +260,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { return; NSK_DISPLAY1("Disable event: %s\n", "CLASS_FILE_LOAD_HOOK"); - if (NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_DISABLE, 1, &event, NULL))) { + if (NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_DISABLE, 1, &event, nullptr))) { NSK_DISPLAY0(" ... event disabled\n"); } @@ -308,20 +308,20 @@ callbackClassFileLoadHook(jvmtiEnv *jvmti, JNIEnv *jni, nsk_null_string(name), (void*)loader, (void*)class_being_redefined, (void*)class_data, (int)class_data_len); - if (name != NULL && (strcmp(name, TESTED_CLASS_NAME) == 0)) { + if (name != nullptr && (strcmp(name, TESTED_CLASS_NAME) == 0)) { NSK_DISPLAY1("SUCCESS! CLASS_FILE_LOAD_HOOK for tested class: %s\n", TESTED_CLASS_NAME); eventsCount++; NSK_DISPLAY1("Check class_being_redefined: 0x%p\n", (void*)class_being_redefined); - if (class_being_redefined != NULL) { - NSK_COMPLAIN1("Unexpected not NULL class_being_redefined in CLASS_FILE_LOAD_HOOK: 0x%p\n", + if (class_being_redefined != nullptr) { + NSK_COMPLAIN1("Unexpected not null class_being_redefined in CLASS_FILE_LOAD_HOOK: 0x%p\n", (void*)class_being_redefined); nsk_jvmti_setFailStatus(); } NSK_DISPLAY1("Check classloader: 0x%p\n", (void*)loader); - if (loader == NULL) { - NSK_COMPLAIN1("Unexpected NULL classloader in CLASS_FILE_LOAD_HOOK: 0x%p\n", + if (loader == nullptr) { + NSK_COMPLAIN1("Unexpected null classloader in CLASS_FILE_LOAD_HOOK: 0x%p\n", (void*)loader); nsk_jvmti_setFailStatus(); } else if (!jni->IsSameObject(loader, classLoader)) { @@ -354,7 +354,7 @@ JNIEXPORT jint JNI_OnLoad_classfloadhk003(JavaVM *jvm, char *options, void *rese } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -364,7 +364,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; NSK_DISPLAY1("Add required capability: %s\n", "can_generate_eraly_class_hook_events"); @@ -393,7 +393,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { NSK_DISPLAY0(" ... set\n"); /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk004/classfloadhk004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk004/classfloadhk004.cpp index 7fe5d9b89d1..e587e45c1da 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk004/classfloadhk004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk004/classfloadhk004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ static jlong timeout = 0; #define NEW_BYTECODE_FIELD_NAME "newClassBytes" static jint newClassSize = 0; -static unsigned char* newClassBytes = NULL; +static unsigned char* newClassBytes = nullptr; static volatile int eventsCount = 0; @@ -54,14 +54,14 @@ static int getBytecode(jvmtiEnv* jvmti, JNIEnv* jni, jclass cls, const char fieldName[], const char fieldSig[], jint* size, unsigned char* *bytes) { - jfieldID fieldID = NULL; - jbyteArray array = NULL; + jfieldID fieldID = nullptr; + jbyteArray array = nullptr; jbyte* elements; int i; NSK_DISPLAY1("Find static field: %s\n", fieldName); if (!NSK_JNI_VERIFY(jni, (fieldID = - jni->GetStaticFieldID(cls, fieldName, fieldSig)) != NULL)) { + jni->GetStaticFieldID(cls, fieldName, fieldSig)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -69,7 +69,7 @@ static int getBytecode(jvmtiEnv* jvmti, JNIEnv* jni, jclass cls, NSK_DISPLAY1("Get classfile bytes array from static field: %s\n", fieldName); if (!NSK_JNI_VERIFY(jni, (array = (jbyteArray) - jni->GetStaticObjectField(cls, fieldID)) != NULL)) { + jni->GetStaticObjectField(cls, fieldID)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -83,7 +83,7 @@ static int getBytecode(jvmtiEnv* jvmti, JNIEnv* jni, jclass cls, { jboolean isCopy; - if (!NSK_JNI_VERIFY(jni, (elements = jni->GetByteArrayElements(array, &isCopy)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (elements = jni->GetByteArrayElements(array, &isCopy)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -121,11 +121,11 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { { NSK_DISPLAY0(">>> Obtain classloader and instrumented bytecode of tested class\n"); { - jclass debugeeClass = NULL; + jclass debugeeClass = nullptr; NSK_DISPLAY1("Find debugee class: %s\n", DEBUGEE_CLASS_NAME); if (!NSK_JNI_VERIFY(jni, (debugeeClass = - jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) { + jni->FindClass(DEBUGEE_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -143,7 +143,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { jvmtiEvent event = JVMTI_EVENT_CLASS_FILE_LOAD_HOOK; NSK_DISPLAY1("Enable event: %s\n", "CLASS_FILE_LOAD_HOOK"); - if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, NULL))) + if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, nullptr))) return; NSK_DISPLAY0(" ... event enabled\n"); @@ -155,7 +155,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { return; NSK_DISPLAY1("Disable event: %s\n", "CLASS_FILE_LOAD_HOOK"); - if (NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_DISABLE, 1, &event, NULL))) { + if (NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_DISABLE, 1, &event, nullptr))) { NSK_DISPLAY0(" ... event disabled\n"); } @@ -196,7 +196,7 @@ callbackClassFileLoadHook(jvmtiEnv *jvmti, JNIEnv *jni, nsk_null_string(name), (void*)loader, (void*)class_being_redefined, (void*)class_data, (int)class_data_len); - if (name != NULL && (strcmp(name, TESTED_CLASS_NAME) == 0)) { + if (name != nullptr && (strcmp(name, TESTED_CLASS_NAME) == 0)) { NSK_DISPLAY1("SUCCESS! CLASS_FILE_LOAD_HOOK for tested class: %s\n", TESTED_CLASS_NAME); eventsCount++; @@ -207,20 +207,20 @@ callbackClassFileLoadHook(jvmtiEnv *jvmti, JNIEnv *jni, } NSK_DISPLAY1("Check pointer to new_class_data_len: 0x%p\n", (void*)new_class_data_len); - if (new_class_data_len == NULL) { - NSK_COMPLAIN1("NULL new_class_data_len pointer passed to CLASS_FILE_LOAD_HOOK: 0x%p\n", + if (new_class_data_len == nullptr) { + NSK_COMPLAIN1("null new_class_data_len pointer passed to CLASS_FILE_LOAD_HOOK: 0x%p\n", (void*)new_class_data_len); nsk_jvmti_setFailStatus(); } NSK_DISPLAY1("Check pointer to new_class_data: 0x%p\n", (void*)new_class_data); - if (new_class_data == NULL) { - NSK_COMPLAIN1("NULL new_class_data pointer passed to CLASS_FILE_LOAD_HOOK: 0x%p\n", + if (new_class_data == nullptr) { + NSK_COMPLAIN1("null new_class_data pointer passed to CLASS_FILE_LOAD_HOOK: 0x%p\n", (void*)new_class_data); nsk_jvmti_setFailStatus(); } - if (new_class_data_len != NULL && new_class_data != NULL) { + if (new_class_data_len != nullptr && new_class_data != nullptr) { NSK_DISPLAY2("Replace with new bytecode: 0x%p:%d\n", (void*)newClassBytes, (int)newClassSize); if (nsk_getVerboseMode()) { @@ -248,7 +248,7 @@ JNIEXPORT jint JNI_OnLoad_classfloadhk004(JavaVM *jvm, char *options, void *rese } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -258,7 +258,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; NSK_DISPLAY1("Add required capability: %s\n", "can_generate_eraly_class_hook_events"); @@ -287,7 +287,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { NSK_DISPLAY0(" ... set\n"); /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk005/classfloadhk005.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk005/classfloadhk005.cpp index 937d8d4a3e2..112f0dda0e9 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk005/classfloadhk005.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk005/classfloadhk005.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ static jlong timeout = 0; #define NEW_BYTECODE_FIELD_NAME "newClassBytes" static jint newClassSize = 0; -static unsigned char* newClassBytes = NULL; +static unsigned char* newClassBytes = nullptr; static volatile int eventsCount = 0; @@ -60,8 +60,8 @@ static int checkBytecode(const char kind[], jint size, const unsigned char bytes nsk_printHexBytes(" ", 16, size, bytes); } - if (bytes == NULL) { - NSK_COMPLAIN2("Unexpected NULL pointer to %s bytecode in CLASS_FILE_LOAD_HOOK: 0x%p\n", + if (bytes == nullptr) { + NSK_COMPLAIN2("Unexpected null pointer to %s bytecode in CLASS_FILE_LOAD_HOOK: 0x%p\n", kind, (void*)bytes); return NSK_FALSE; } @@ -116,14 +116,14 @@ static int getBytecode(jvmtiEnv* jvmti, JNIEnv* jni, jclass cls, const char fieldName[], const char fieldSig[], jint* size, unsigned char* *bytes) { - jfieldID fieldID = NULL; - jbyteArray array = NULL; + jfieldID fieldID = nullptr; + jbyteArray array = nullptr; jbyte* elements; int i; NSK_DISPLAY1("Find static field: %s\n", fieldName); if (!NSK_JNI_VERIFY(jni, (fieldID = - jni->GetStaticFieldID(cls, fieldName, fieldSig)) != NULL)) { + jni->GetStaticFieldID(cls, fieldName, fieldSig)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -131,7 +131,7 @@ static int getBytecode(jvmtiEnv* jvmti, JNIEnv* jni, jclass cls, NSK_DISPLAY1("Get classfile bytes array from static field: %s\n", fieldName); if (!NSK_JNI_VERIFY(jni, (array = (jbyteArray) - jni->GetStaticObjectField(cls, fieldID)) != NULL)) { + jni->GetStaticObjectField(cls, fieldID)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -145,7 +145,7 @@ static int getBytecode(jvmtiEnv* jvmti, JNIEnv* jni, jclass cls, { jboolean isCopy; - if (!NSK_JNI_VERIFY(jni, (elements = jni->GetByteArrayElements(array, &isCopy)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (elements = jni->GetByteArrayElements(array, &isCopy)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -183,11 +183,11 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { { NSK_DISPLAY0(">>> Obtain classloader and instrumented bytecode of tested class\n"); { - jclass debugeeClass = NULL; + jclass debugeeClass = nullptr; NSK_DISPLAY1("Find debugee class: %s\n", DEBUGEE_CLASS_NAME); if (!NSK_JNI_VERIFY(jni, (debugeeClass = - jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) { + jni->FindClass(DEBUGEE_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -205,7 +205,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { jvmtiEvent event = JVMTI_EVENT_CLASS_FILE_LOAD_HOOK; NSK_DISPLAY1("Enable event: %s\n", "CLASS_FILE_LOAD_HOOK"); - if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, NULL))) + if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, nullptr))) return; NSK_DISPLAY0(" ... event enabled\n"); @@ -217,7 +217,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { return; NSK_DISPLAY1("Disable event: %s\n", "CLASS_FILE_LOAD_HOOK"); - if (NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_DISABLE, 1, &event, NULL))) { + if (NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_DISABLE, 1, &event, nullptr))) { NSK_DISPLAY0(" ... event disabled\n"); } @@ -258,7 +258,7 @@ callbackClassFileLoadHook(jvmtiEnv *jvmti, JNIEnv *jni, nsk_null_string(name), (void*)loader, (void*)class_being_redefined, (void*)class_data, (int)class_data_len); - if (name != NULL && (strcmp(name, TESTED_CLASS_NAME) == 0)) { + if (name != nullptr && (strcmp(name, TESTED_CLASS_NAME) == 0)) { NSK_DISPLAY1("SUCCESS! CLASS_FILE_LOAD_HOOK for tested class: %s\n", TESTED_CLASS_NAME); eventsCount++; @@ -269,20 +269,20 @@ callbackClassFileLoadHook(jvmtiEnv *jvmti, JNIEnv *jni, } NSK_DISPLAY1("Check pointer to new_class_data_len: 0x%p\n", (void*)new_class_data_len); - if (new_class_data_len == NULL) { - NSK_COMPLAIN1("NULL new_class_data_len pointer passed to CLASS_FILE_LOAD_HOOK: 0x%p\n", + if (new_class_data_len == nullptr) { + NSK_COMPLAIN1("null new_class_data_len pointer passed to CLASS_FILE_LOAD_HOOK: 0x%p\n", (void*)new_class_data_len); nsk_jvmti_setFailStatus(); } NSK_DISPLAY1("Check pointer to new_class_data: 0x%p\n", (void*)new_class_data); - if (new_class_data == NULL) { - NSK_COMPLAIN1("NULL new_class_data pointer passed to CLASS_FILE_LOAD_HOOK: 0x%p\n", + if (new_class_data == nullptr) { + NSK_COMPLAIN1("null new_class_data pointer passed to CLASS_FILE_LOAD_HOOK: 0x%p\n", (void*)new_class_data); nsk_jvmti_setFailStatus(); } - if (new_class_data_len != NULL && new_class_data != NULL) { + if (new_class_data_len != nullptr && new_class_data != nullptr) { NSK_DISPLAY2("Replace with instrumented bytecode: 0x%p:%d\n", (void*)newClassBytes, (int)newClassSize); if (nsk_getVerboseMode()) { @@ -310,7 +310,7 @@ JNIEXPORT jint JNI_OnLoad_classfloadhk005(JavaVM *jvm, char *options, void *rese } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -320,7 +320,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; NSK_DISPLAY1("Add required capability: %s\n", "can_generate_eraly_class_hook_events"); @@ -349,7 +349,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { NSK_DISPLAY0(" ... set\n"); /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk006/classfloadhk006.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk006/classfloadhk006.cpp index 41d48e5a484..31414b4ed90 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk006/classfloadhk006.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk006/classfloadhk006.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -45,10 +45,10 @@ static jlong timeout = 0; #define TESTED_CLASS_FIELD_NAME "testedClass" #define TESTED_CLASS_FIELD_SIG "Ljava/lang/Class;" -static jclass testedClass = NULL; +static jclass testedClass = nullptr; static jint redefClassSize = 0; -static unsigned char* redefClassBytes = NULL; +static unsigned char* redefClassBytes = nullptr; static volatile int eventsCount = 0; @@ -65,8 +65,8 @@ static int checkBytecode(const char kind[], jint size, const unsigned char bytes nsk_printHexBytes(" ", 16, size, bytes); } - if (bytes == NULL) { - NSK_COMPLAIN2("Unexpected NULL pointer to %s bytecode in CLASS_FILE_LOAD_HOOK: 0x%p\n", + if (bytes == nullptr) { + NSK_COMPLAIN2("Unexpected null pointer to %s bytecode in CLASS_FILE_LOAD_HOOK: 0x%p\n", kind, (void*)bytes); return NSK_FALSE; } @@ -121,14 +121,14 @@ static int getBytecode(jvmtiEnv* jvmti, JNIEnv* jni, jclass cls, const char fieldName[], const char fieldSig[], jint* size, unsigned char* *bytes) { - jfieldID fieldID = NULL; - jbyteArray array = NULL; + jfieldID fieldID = nullptr; + jbyteArray array = nullptr; jbyte* elements; int i; NSK_DISPLAY1("Find static field: %s\n", fieldName); if (!NSK_JNI_VERIFY(jni, (fieldID = - jni->GetStaticFieldID(cls, fieldName, fieldSig)) != NULL)) { + jni->GetStaticFieldID(cls, fieldName, fieldSig)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -136,7 +136,7 @@ static int getBytecode(jvmtiEnv* jvmti, JNIEnv* jni, jclass cls, NSK_DISPLAY1("Get classfile bytes array from static field: %s\n", fieldName); if (!NSK_JNI_VERIFY(jni, (array = (jbyteArray) - jni->GetStaticObjectField(cls, fieldID)) != NULL)) { + jni->GetStaticObjectField(cls, fieldID)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -150,7 +150,7 @@ static int getBytecode(jvmtiEnv* jvmti, JNIEnv* jni, jclass cls, { jboolean isCopy; - if (!NSK_JNI_VERIFY(jni, (elements = jni->GetByteArrayElements(array, &isCopy)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (elements = jni->GetByteArrayElements(array, &isCopy)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -179,28 +179,28 @@ static int getBytecode(jvmtiEnv* jvmti, JNIEnv* jni, jclass cls, static jobject getObject(jvmtiEnv* jvmti, JNIEnv* jni, jclass cls, const char fieldName[], const char fieldSig[]) { - jfieldID fieldID = NULL; - jobject obj = NULL; + jfieldID fieldID = nullptr; + jobject obj = nullptr; NSK_DISPLAY1("Find static field: %s\n", fieldName); if (!NSK_JNI_VERIFY(jni, (fieldID = - jni->GetStaticFieldID(cls, fieldName, fieldSig)) != NULL)) { + jni->GetStaticFieldID(cls, fieldName, fieldSig)) != nullptr)) { nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } NSK_DISPLAY1(" ... got fieldID: 0x%p\n", (void*)fieldID); NSK_DISPLAY1("Get object from static field: %s\n", fieldName); - if (!NSK_JNI_VERIFY(jni, (obj = jni->GetStaticObjectField(cls, fieldID)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (obj = jni->GetStaticObjectField(cls, fieldID)) != nullptr)) { nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } NSK_DISPLAY1(" ... got object: 0x%p\n", (void*)obj); NSK_DISPLAY1("Make global reference to object: 0x%p\n", obj); - if (!NSK_JNI_VERIFY(jni, (obj = jni->NewGlobalRef(obj)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (obj = jni->NewGlobalRef(obj)) != nullptr)) { nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } NSK_DISPLAY1(" ... got global ref: 0x%p\n", (void*)obj); @@ -238,12 +238,12 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { /* perform testing */ { { - jclass debugeeClass = NULL; + jclass debugeeClass = nullptr; NSK_DISPLAY0(">>> Obtain debuggee class\n"); NSK_DISPLAY1("Find debugee class: %s\n", DEBUGEE_CLASS_NAME); if (!NSK_JNI_VERIFY(jni, (debugeeClass = - jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) { + jni->FindClass(DEBUGEE_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -252,7 +252,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY0(">>> Obtain tested class object\n"); if (!NSK_VERIFY((testedClass = (jclass) getObject(jvmti, jni, debugeeClass, TESTED_CLASS_FIELD_NAME, - TESTED_CLASS_FIELD_SIG)) != NULL)) + TESTED_CLASS_FIELD_SIG)) != nullptr)) return; NSK_DISPLAY0(">>> Obtain redefined bytecode of tested class\n"); @@ -275,7 +275,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { jvmtiEvent event = JVMTI_EVENT_CLASS_FILE_LOAD_HOOK; NSK_DISPLAY1("Enable event: %s\n", "CLASS_FILE_LOAD_HOOK"); - if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, NULL))) + if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, nullptr))) return; NSK_DISPLAY0(" ... event enabled\n"); @@ -283,7 +283,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { redefClassSize, redefClassBytes)); NSK_DISPLAY1("Disable event: %s\n", "CLASS_FILE_LOAD_HOOK"); - if (NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_DISABLE, 1, &event, NULL))) { + if (NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_DISABLE, 1, &event, nullptr))) { NSK_DISPLAY0(" ... event disabled\n"); } @@ -330,13 +330,13 @@ callbackClassFileLoadHook(jvmtiEnv *jvmti, JNIEnv *jni, nsk_null_string(name), (void*)loader, (void*)class_being_redefined, (void*)class_data, (int)class_data_len); - if (name != NULL && (strcmp(name, TESTED_CLASS_NAME) == 0)) { + if (name != nullptr && (strcmp(name, TESTED_CLASS_NAME) == 0)) { NSK_DISPLAY1("SUCCESS! CLASS_FILE_LOAD_HOOK for tested class: %s\n", TESTED_CLASS_NAME); eventsCount++; NSK_DISPLAY1("Check class_being_redefined: 0x%p\n", (void*)class_being_redefined); - if (class_being_redefined == NULL) { - NSK_COMPLAIN1("Unexpected NULL class_being_redefined in CLASS_FILE_LOAD_HOOK: 0x%p\n", + if (class_being_redefined == nullptr) { + NSK_COMPLAIN1("Unexpected null class_being_redefined in CLASS_FILE_LOAD_HOOK: 0x%p\n", (void*)class_being_redefined); nsk_jvmti_setFailStatus(); } else if (!jni->IsSameObject(class_being_redefined, testedClass)) { @@ -369,7 +369,7 @@ JNIEXPORT jint JNI_OnLoad_classfloadhk006(JavaVM *jvm, char *options, void *rese } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -379,7 +379,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; NSK_DISPLAY1("Add required capabilities: %s\n", "can_generate_eraly_class_hook_events, can_redefine_classes"); @@ -409,7 +409,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { NSK_DISPLAY0(" ... set\n"); /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk007/classfloadhk007.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk007/classfloadhk007.cpp index 8c1f686361a..7107ccfdf41 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk007/classfloadhk007.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk007/classfloadhk007.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -48,11 +48,11 @@ static jlong timeout = 0; #define TESTED_CLASS_FIELD_NAME "testedClass" #define TESTED_CLASS_FIELD_SIG "Ljava/lang/Class;" -static jobject classLoader = NULL; -static jclass testedClass = NULL; +static jobject classLoader = nullptr; +static jclass testedClass = nullptr; static jint redefClassSize = 0; -static unsigned char* redefClassBytes = NULL; +static unsigned char* redefClassBytes = nullptr; static volatile int eventsCount = 0; @@ -69,8 +69,8 @@ static int checkBytecode(const char kind[], jint size, const unsigned char bytes nsk_printHexBytes(" ", 16, size, bytes); } - if (bytes == NULL) { - NSK_COMPLAIN2("Unexpected NULL pointer to %s bytecode in CLASS_FILE_LOAD_HOOK: 0x%p\n", + if (bytes == nullptr) { + NSK_COMPLAIN2("Unexpected null pointer to %s bytecode in CLASS_FILE_LOAD_HOOK: 0x%p\n", kind, (void*)bytes); return NSK_FALSE; } @@ -125,14 +125,14 @@ static int getBytecode(jvmtiEnv* jvmti, JNIEnv* jni, jclass cls, const char fieldName[], const char fieldSig[], jint* size, unsigned char* *bytes) { - jfieldID fieldID = NULL; - jbyteArray array = NULL; + jfieldID fieldID = nullptr; + jbyteArray array = nullptr; jbyte* elements; int i; NSK_DISPLAY1("Find static field: %s\n", fieldName); if (!NSK_JNI_VERIFY(jni, (fieldID = - jni->GetStaticFieldID(cls, fieldName, fieldSig)) != NULL)) { + jni->GetStaticFieldID(cls, fieldName, fieldSig)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -140,7 +140,7 @@ static int getBytecode(jvmtiEnv* jvmti, JNIEnv* jni, jclass cls, NSK_DISPLAY1("Get classfile bytes array from static field: %s\n", fieldName); if (!NSK_JNI_VERIFY(jni, (array = (jbyteArray) - jni->GetStaticObjectField(cls, fieldID)) != NULL)) { + jni->GetStaticObjectField(cls, fieldID)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -154,7 +154,7 @@ static int getBytecode(jvmtiEnv* jvmti, JNIEnv* jni, jclass cls, { jboolean isCopy; - if (!NSK_JNI_VERIFY(jni, (elements = jni->GetByteArrayElements(array, &isCopy)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (elements = jni->GetByteArrayElements(array, &isCopy)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -183,28 +183,28 @@ static int getBytecode(jvmtiEnv* jvmti, JNIEnv* jni, jclass cls, static jobject getObject(jvmtiEnv* jvmti, JNIEnv* jni, jclass cls, const char fieldName[], const char fieldSig[]) { - jfieldID fieldID = NULL; - jobject obj = NULL; + jfieldID fieldID = nullptr; + jobject obj = nullptr; NSK_DISPLAY1("Find static field: %s\n", fieldName); if (!NSK_JNI_VERIFY(jni, (fieldID = - jni->GetStaticFieldID(cls, fieldName, fieldSig)) != NULL)) { + jni->GetStaticFieldID(cls, fieldName, fieldSig)) != nullptr)) { nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } NSK_DISPLAY1(" ... got fieldID: 0x%p\n", (void*)fieldID); NSK_DISPLAY1("Get object from static field: %s\n", fieldName); - if (!NSK_JNI_VERIFY(jni, (obj = jni->GetStaticObjectField(cls, fieldID)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (obj = jni->GetStaticObjectField(cls, fieldID)) != nullptr)) { nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } NSK_DISPLAY1(" ... got object: 0x%p\n", (void*)obj); NSK_DISPLAY1("Make global reference to object: 0x%p\n", obj); - if (!NSK_JNI_VERIFY(jni, (obj = jni->NewGlobalRef(obj)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (obj = jni->NewGlobalRef(obj)) != nullptr)) { nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } NSK_DISPLAY1(" ... got global ref: 0x%p\n", (void*)obj); @@ -242,12 +242,12 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { /* perform testing */ { { - jclass debugeeClass = NULL; + jclass debugeeClass = nullptr; NSK_DISPLAY0(">>> Obtain debuggee class\n"); NSK_DISPLAY1("Find debugee class: %s\n", DEBUGEE_CLASS_NAME); if (!NSK_JNI_VERIFY(jni, (debugeeClass = - jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) { + jni->FindClass(DEBUGEE_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -256,13 +256,13 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY0(">>> Obtain tested class object\n"); if (!NSK_VERIFY((testedClass = (jclass) getObject(jvmti, jni, debugeeClass, TESTED_CLASS_FIELD_NAME, - TESTED_CLASS_FIELD_SIG)) != NULL)) + TESTED_CLASS_FIELD_SIG)) != nullptr)) return; NSK_DISPLAY0(">>> Obtain classloader object\n"); if (!NSK_VERIFY((classLoader = getObject(jvmti, jni, debugeeClass, CLASSLOADER_FIELD_NAME, - TESTED_CLASSLOADER_SIG)) != NULL)) + TESTED_CLASSLOADER_SIG)) != nullptr)) return; NSK_DISPLAY0(">>> Obtain redefined bytecode of tested class\n"); @@ -285,7 +285,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { jvmtiEvent event = JVMTI_EVENT_CLASS_FILE_LOAD_HOOK; NSK_DISPLAY1("Enable event: %s\n", "CLASS_FILE_LOAD_HOOK"); - if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, NULL))) + if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, nullptr))) return; NSK_DISPLAY0(" ... event enabled\n"); @@ -293,7 +293,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { redefClassSize, redefClassBytes)); NSK_DISPLAY1("Disable event: %s\n", "CLASS_FILE_LOAD_HOOK"); - if (NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_DISABLE, 1, &event, NULL))) { + if (NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_DISABLE, 1, &event, nullptr))) { NSK_DISPLAY0(" ... event disabled\n"); } @@ -343,13 +343,13 @@ callbackClassFileLoadHook(jvmtiEnv *jvmti, JNIEnv *jni, nsk_null_string(name), (void*)loader, (void*)class_being_redefined, (void*)class_data, (int)class_data_len); - if (name != NULL && (strcmp(name, TESTED_CLASS_NAME) == 0)) { + if (name != nullptr && (strcmp(name, TESTED_CLASS_NAME) == 0)) { NSK_DISPLAY1("SUCCESS! CLASS_FILE_LOAD_HOOK for tested class: %s\n", TESTED_CLASS_NAME); eventsCount++; NSK_DISPLAY1("Check classloader: 0x%p\n", (void*)loader); - if (loader == NULL) { - NSK_COMPLAIN1("Unexpected NULL classloader in CLASS_FILE_LOAD_HOOK: 0x%p\n", + if (loader == nullptr) { + NSK_COMPLAIN1("Unexpected null classloader in CLASS_FILE_LOAD_HOOK: 0x%p\n", (void*)loader); nsk_jvmti_setFailStatus(); } else if (!jni->IsSameObject(loader, classLoader)) { @@ -361,8 +361,8 @@ callbackClassFileLoadHook(jvmtiEnv *jvmti, JNIEnv *jni, } NSK_DISPLAY1("Check class_being_redefined: 0x%p\n", (void*)class_being_redefined); - if (class_being_redefined == NULL) { - NSK_COMPLAIN1("Unexpected NULL class_being_redefined in CLASS_FILE_LOAD_HOOK: 0x%p\n", + if (class_being_redefined == nullptr) { + NSK_COMPLAIN1("Unexpected null class_being_redefined in CLASS_FILE_LOAD_HOOK: 0x%p\n", (void*)class_being_redefined); nsk_jvmti_setFailStatus(); } else if (!jni->IsSameObject(class_being_redefined, testedClass)) { @@ -395,7 +395,7 @@ JNIEXPORT jint JNI_OnLoad_classfloadhk007(JavaVM *jvm, char *options, void *rese } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -405,7 +405,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; NSK_DISPLAY1("Add required capabilities: %s\n", "can_generate_eraly_class_hook_events, can_redefine_classes"); @@ -435,7 +435,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { NSK_DISPLAY0(" ... set\n"); /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk008/classfloadhk008.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk008/classfloadhk008.cpp index 7f18912194d..01ea3da04a6 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk008/classfloadhk008.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk008/classfloadhk008.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,13 +46,13 @@ static jlong timeout = 0; #define TESTED_CLASS_FIELD_NAME "testedClass" #define TESTED_CLASS_FIELD_SIG "Ljava/lang/Class;" -static jclass testedClass = NULL; +static jclass testedClass = nullptr; static jint redefClassSize = 0; -static unsigned char* redefClassBytes = NULL; +static unsigned char* redefClassBytes = nullptr; static jint newClassSize = 0; -static unsigned char* newClassBytes = NULL; +static unsigned char* newClassBytes = nullptr; static volatile int eventsCount = 0; @@ -63,14 +63,14 @@ static int getBytecode(jvmtiEnv* jvmti, JNIEnv* jni, jclass cls, const char fieldName[], const char fieldSig[], jint* size, unsigned char* *bytes) { - jfieldID fieldID = NULL; - jbyteArray array = NULL; + jfieldID fieldID = nullptr; + jbyteArray array = nullptr; jbyte* elements; int i; NSK_DISPLAY1("Find static field: %s\n", fieldName); if (!NSK_JNI_VERIFY(jni, (fieldID = - jni->GetStaticFieldID(cls, fieldName, fieldSig)) != NULL)) { + jni->GetStaticFieldID(cls, fieldName, fieldSig)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -78,7 +78,7 @@ static int getBytecode(jvmtiEnv* jvmti, JNIEnv* jni, jclass cls, NSK_DISPLAY1("Get classfile bytes array from static field: %s\n", fieldName); if (!NSK_JNI_VERIFY(jni, (array = (jbyteArray) - jni->GetStaticObjectField(cls, fieldID)) != NULL)) { + jni->GetStaticObjectField(cls, fieldID)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -92,7 +92,7 @@ static int getBytecode(jvmtiEnv* jvmti, JNIEnv* jni, jclass cls, { jboolean isCopy; - if (!NSK_JNI_VERIFY(jni, (elements = jni->GetByteArrayElements(array, &isCopy)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (elements = jni->GetByteArrayElements(array, &isCopy)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -121,28 +121,28 @@ static int getBytecode(jvmtiEnv* jvmti, JNIEnv* jni, jclass cls, static jobject getObject(jvmtiEnv* jvmti, JNIEnv* jni, jclass cls, const char fieldName[], const char fieldSig[]) { - jfieldID fieldID = NULL; - jobject obj = NULL; + jfieldID fieldID = nullptr; + jobject obj = nullptr; NSK_DISPLAY1("Find static field: %s\n", fieldName); if (!NSK_JNI_VERIFY(jni, (fieldID = - jni->GetStaticFieldID(cls, fieldName, fieldSig)) != NULL)) { + jni->GetStaticFieldID(cls, fieldName, fieldSig)) != nullptr)) { nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } NSK_DISPLAY1(" ... got fieldID: 0x%p\n", (void*)fieldID); NSK_DISPLAY1("Get object from static field: %s\n", fieldName); - if (!NSK_JNI_VERIFY(jni, (obj = jni->GetStaticObjectField(cls, fieldID)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (obj = jni->GetStaticObjectField(cls, fieldID)) != nullptr)) { nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } NSK_DISPLAY1(" ... got object: 0x%p\n", (void*)obj); NSK_DISPLAY1("Make global reference to object: 0x%p\n", obj); - if (!NSK_JNI_VERIFY(jni, (obj = jni->NewGlobalRef(obj)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (obj = jni->NewGlobalRef(obj)) != nullptr)) { nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } NSK_DISPLAY1(" ... got global ref: 0x%p\n", (void*)obj); @@ -180,12 +180,12 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { /* perform testing */ { { - jclass debugeeClass = NULL; + jclass debugeeClass = nullptr; NSK_DISPLAY0(">>> Obtain debuggee class\n"); NSK_DISPLAY1("Find debugee class: %s\n", DEBUGEE_CLASS_NAME); if (!NSK_JNI_VERIFY(jni, (debugeeClass = - jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) { + jni->FindClass(DEBUGEE_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -194,7 +194,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY0(">>> Obtain tested class object\n"); if (!NSK_VERIFY((testedClass = (jclass) getObject(jvmti, jni, debugeeClass, TESTED_CLASS_FIELD_NAME, - TESTED_CLASS_FIELD_SIG)) != NULL)) + TESTED_CLASS_FIELD_SIG)) != nullptr)) return; NSK_DISPLAY0(">>> Obtain redefined bytecode of tested class\n"); @@ -224,7 +224,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { jvmtiEvent event = JVMTI_EVENT_CLASS_FILE_LOAD_HOOK; NSK_DISPLAY1("Enable event: %s\n", "CLASS_FILE_LOAD_HOOK"); - if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, NULL))) + if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, nullptr))) return; NSK_DISPLAY0(" ... event enabled\n"); @@ -232,7 +232,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { redefClassSize, redefClassBytes)); NSK_DISPLAY1("Disable event: %s\n", "CLASS_FILE_LOAD_HOOK"); - if (NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_DISABLE, 1, &event, NULL))) { + if (NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_DISABLE, 1, &event, nullptr))) { NSK_DISPLAY0(" ... event disabled\n"); } @@ -279,7 +279,7 @@ callbackClassFileLoadHook(jvmtiEnv *jvmti, JNIEnv *jni, nsk_null_string(name), (void*)loader, (void*)class_being_redefined, (void*)class_data, (int)class_data_len); - if (name != NULL && (strcmp(name, TESTED_CLASS_NAME) == 0)) { + if (name != nullptr && (strcmp(name, TESTED_CLASS_NAME) == 0)) { NSK_DISPLAY1("SUCCESS! CLASS_FILE_LOAD_HOOK for tested class: %s\n", TESTED_CLASS_NAME); eventsCount++; @@ -290,20 +290,20 @@ callbackClassFileLoadHook(jvmtiEnv *jvmti, JNIEnv *jni, } NSK_DISPLAY1("Check pointer to new_class_data_len: 0x%p\n", (void*)new_class_data_len); - if (new_class_data_len == NULL) { - NSK_COMPLAIN1("NULL new_class_data_len pointer passed to CLASS_FILE_LOAD_HOOK: 0x%p\n", + if (new_class_data_len == nullptr) { + NSK_COMPLAIN1("null new_class_data_len pointer passed to CLASS_FILE_LOAD_HOOK: 0x%p\n", (void*)new_class_data_len); nsk_jvmti_setFailStatus(); } NSK_DISPLAY1("Check pointer to new_class_data: 0x%p\n", (void*)new_class_data); - if (new_class_data == NULL) { - NSK_COMPLAIN1("NULL new_class_data pointer passed to CLASS_FILE_LOAD_HOOK: 0x%p\n", + if (new_class_data == nullptr) { + NSK_COMPLAIN1("null new_class_data pointer passed to CLASS_FILE_LOAD_HOOK: 0x%p\n", (void*)new_class_data); nsk_jvmti_setFailStatus(); } - if (new_class_data_len != NULL && new_class_data != NULL) { + if (new_class_data_len != nullptr && new_class_data != nullptr) { NSK_DISPLAY2("Replace with new instrumented bytecode: 0x%p:%d\n", (void*)newClassBytes, (int)newClassSize); if (nsk_getVerboseMode()) { @@ -331,7 +331,7 @@ JNIEXPORT jint JNI_OnLoad_classfloadhk008(JavaVM *jvm, char *options, void *rese } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -341,7 +341,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; NSK_DISPLAY1("Add required capabilities: %s\n", "can_generate_eraly_class_hook_events, can_redefine_classes"); @@ -371,7 +371,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { NSK_DISPLAY0(" ... set\n"); /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk009/classfloadhk009.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk009/classfloadhk009.cpp index e4a2067772c..296c10cb84a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk009/classfloadhk009.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk009/classfloadhk009.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,13 +46,13 @@ static jlong timeout = 0; #define TESTED_CLASS_FIELD_NAME "testedClass" #define TESTED_CLASS_FIELD_SIG "Ljava/lang/Class;" -static jclass testedClass = NULL; +static jclass testedClass = nullptr; static jint redefClassSize = 0; -static unsigned char* redefClassBytes = NULL; +static unsigned char* redefClassBytes = nullptr; static jint newClassSize = 0; -static unsigned char* newClassBytes = NULL; +static unsigned char* newClassBytes = nullptr; static volatile int eventsCount = 0; @@ -63,14 +63,14 @@ static int getBytecode(jvmtiEnv* jvmti, JNIEnv* jni, jclass cls, const char fieldName[], const char fieldSig[], jint* size, unsigned char* *bytes) { - jfieldID fieldID = NULL; - jbyteArray array = NULL; + jfieldID fieldID = nullptr; + jbyteArray array = nullptr; jbyte* elements; int i; NSK_DISPLAY1("Find static field: %s\n", fieldName); if (!NSK_JNI_VERIFY(jni, (fieldID = - jni->GetStaticFieldID(cls, fieldName, fieldSig)) != NULL)) { + jni->GetStaticFieldID(cls, fieldName, fieldSig)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -78,7 +78,7 @@ static int getBytecode(jvmtiEnv* jvmti, JNIEnv* jni, jclass cls, NSK_DISPLAY1("Get classfile bytes array from static field: %s\n", fieldName); if (!NSK_JNI_VERIFY(jni, (array = (jbyteArray) - jni->GetStaticObjectField(cls, fieldID)) != NULL)) { + jni->GetStaticObjectField(cls, fieldID)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -92,7 +92,7 @@ static int getBytecode(jvmtiEnv* jvmti, JNIEnv* jni, jclass cls, { jboolean isCopy; - if (!NSK_JNI_VERIFY(jni, (elements = jni->GetByteArrayElements(array, &isCopy)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (elements = jni->GetByteArrayElements(array, &isCopy)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -121,28 +121,28 @@ static int getBytecode(jvmtiEnv* jvmti, JNIEnv* jni, jclass cls, static jobject getObject(jvmtiEnv* jvmti, JNIEnv* jni, jclass cls, const char fieldName[], const char fieldSig[]) { - jfieldID fieldID = NULL; - jobject obj = NULL; + jfieldID fieldID = nullptr; + jobject obj = nullptr; NSK_DISPLAY1("Find static field: %s\n", fieldName); if (!NSK_JNI_VERIFY(jni, (fieldID = - jni->GetStaticFieldID(cls, fieldName, fieldSig)) != NULL)) { + jni->GetStaticFieldID(cls, fieldName, fieldSig)) != nullptr)) { nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } NSK_DISPLAY1(" ... got fieldID: 0x%p\n", (void*)fieldID); NSK_DISPLAY1("Get object from static field: %s\n", fieldName); - if (!NSK_JNI_VERIFY(jni, (obj = jni->GetStaticObjectField(cls, fieldID)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (obj = jni->GetStaticObjectField(cls, fieldID)) != nullptr)) { nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } NSK_DISPLAY1(" ... got object: 0x%p\n", (void*)obj); NSK_DISPLAY1("Make global reference to object: 0x%p\n", obj); - if (!NSK_JNI_VERIFY(jni, (obj = jni->NewGlobalRef(obj)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (obj = jni->NewGlobalRef(obj)) != nullptr)) { nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } NSK_DISPLAY1(" ... got global ref: 0x%p\n", (void*)obj); @@ -180,12 +180,12 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { /* perform testing */ { { - jclass debugeeClass = NULL; + jclass debugeeClass = nullptr; NSK_DISPLAY0(">>> Obtain debuggee class\n"); NSK_DISPLAY1("Find debugee class: %s\n", DEBUGEE_CLASS_NAME); if (!NSK_JNI_VERIFY(jni, (debugeeClass = - jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) { + jni->FindClass(DEBUGEE_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -194,7 +194,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY0(">>> Obtain tested class object\n"); if (!NSK_VERIFY((testedClass = (jclass) getObject(jvmti, jni, debugeeClass, TESTED_CLASS_FIELD_NAME, - TESTED_CLASS_FIELD_SIG)) != NULL)) + TESTED_CLASS_FIELD_SIG)) != nullptr)) return; NSK_DISPLAY0(">>> Obtain redefined bytecode of tested class\n"); @@ -224,7 +224,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { jvmtiEvent event = JVMTI_EVENT_CLASS_FILE_LOAD_HOOK; NSK_DISPLAY1("Enable event: %s\n", "CLASS_FILE_LOAD_HOOK"); - if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, NULL))) + if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, nullptr))) return; NSK_DISPLAY0(" ... event enabled\n"); @@ -232,7 +232,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { redefClassSize, redefClassBytes)); NSK_DISPLAY1("Disable event: %s\n", "CLASS_FILE_LOAD_HOOK"); - if (NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_DISABLE, 1, &event, NULL))) { + if (NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_DISABLE, 1, &event, nullptr))) { NSK_DISPLAY0(" ... event disabled\n"); } @@ -279,7 +279,7 @@ callbackClassFileLoadHook(jvmtiEnv *jvmti, JNIEnv *jni, nsk_null_string(name), (void*)loader, (void*)class_being_redefined, (void*)class_data, (int)class_data_len); - if (name != NULL && (strcmp(name, TESTED_CLASS_NAME) == 0)) { + if (name != nullptr && (strcmp(name, TESTED_CLASS_NAME) == 0)) { NSK_DISPLAY1("SUCCESS! CLASS_FILE_LOAD_HOOK for tested class: %s\n", TESTED_CLASS_NAME); eventsCount++; @@ -290,20 +290,20 @@ callbackClassFileLoadHook(jvmtiEnv *jvmti, JNIEnv *jni, } NSK_DISPLAY1("Check pointer to new_class_data_len: 0x%p\n", (void*)new_class_data_len); - if (new_class_data_len == NULL) { - NSK_COMPLAIN1("NULL new_class_data_len pointer passed to CLASS_FILE_LOAD_HOOK: 0x%p\n", + if (new_class_data_len == nullptr) { + NSK_COMPLAIN1("null new_class_data_len pointer passed to CLASS_FILE_LOAD_HOOK: 0x%p\n", (void*)new_class_data_len); nsk_jvmti_setFailStatus(); } NSK_DISPLAY1("Check pointer to new_class_data: 0x%p\n", (void*)new_class_data); - if (new_class_data == NULL) { - NSK_COMPLAIN1("NULL new_class_data pointer passed to CLASS_FILE_LOAD_HOOK: 0x%p\n", + if (new_class_data == nullptr) { + NSK_COMPLAIN1("null new_class_data pointer passed to CLASS_FILE_LOAD_HOOK: 0x%p\n", (void*)new_class_data); nsk_jvmti_setFailStatus(); } - if (new_class_data_len != NULL && new_class_data != NULL) { + if (new_class_data_len != nullptr && new_class_data != nullptr) { NSK_DISPLAY2("Replace with new instrumented bytecode: 0x%p:%d\n", (void*)newClassBytes, (int)newClassSize); if (nsk_getVerboseMode()) { @@ -331,7 +331,7 @@ JNIEXPORT jint JNI_OnLoad_classfloadhk009(JavaVM *jvm, char *options, void *rese } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -341,7 +341,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; NSK_DISPLAY1("Add required capabilities: %s\n", "can_generate_eraly_class_hook_events, can_redefine_classes"); @@ -371,7 +371,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { NSK_DISPLAY0(" ... set\n"); /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearBreakpoint/clrbrk001/clrbrk001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearBreakpoint/clrbrk001/clrbrk001.cpp index 07540af5bf0..cae177d2537 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearBreakpoint/clrbrk001/clrbrk001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearBreakpoint/clrbrk001/clrbrk001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; static jint result = PASSED; @@ -62,12 +62,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -102,7 +102,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_BREAKPOINT, NULL); + JVMTI_EVENT_BREAKPOINT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable BREAKPOINT event: %s (%d)\n", TranslateError(err), err); @@ -118,7 +118,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { JNIEXPORT void JNICALL Java_nsk_jvmti_ClearBreakpoint_clrbrk001_getReady(JNIEnv *env, jclass cls, jint i) { mid = env->GetStaticMethodID(cls, "trial", "(I)I"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot find method \"trial(I)I\"\n"); result = STATUS_FAILED; } else { @@ -129,7 +129,7 @@ Java_nsk_jvmti_ClearBreakpoint_clrbrk001_getReady(JNIEnv *env, jclass cls, jint JNIEXPORT void JNICALL Java_nsk_jvmti_ClearBreakpoint_clrbrk001_setBP(JNIEnv *env, jclass cls) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return; } @@ -138,7 +138,7 @@ JNIEXPORT void JNICALL Java_nsk_jvmti_ClearBreakpoint_clrbrk001_setBP(JNIEnv *en return; } - if (mid == NULL) { + if (mid == nullptr) { return; } @@ -153,7 +153,7 @@ JNIEXPORT void JNICALL Java_nsk_jvmti_ClearBreakpoint_clrbrk001_setBP(JNIEnv *en JNIEXPORT void JNICALL Java_nsk_jvmti_ClearBreakpoint_clrbrk001_clearBP(JNIEnv *env, jclass cls) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return; } @@ -162,7 +162,7 @@ JNIEXPORT void JNICALL Java_nsk_jvmti_ClearBreakpoint_clrbrk001_clearBP(JNIEnv * return; } - if (mid == NULL) { + if (mid == nullptr) { return; } @@ -176,7 +176,7 @@ JNIEXPORT void JNICALL Java_nsk_jvmti_ClearBreakpoint_clrbrk001_clearBP(JNIEnv * JNIEXPORT jint JNICALL Java_nsk_jvmti_ClearBreakpoint_clrbrk001_check(JNIEnv *env, jclass cls) { - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearBreakpoint/clrbrk002/clrbrk002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearBreakpoint/clrbrk002/clrbrk002.cpp index 79fde2ad9f2..e61a953186d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearBreakpoint/clrbrk002/clrbrk002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearBreakpoint/clrbrk002/clrbrk002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -53,12 +53,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -98,7 +98,7 @@ Java_nsk_jvmti_ClearBreakpoint_clrbrk002_check(JNIEnv *env, jclass cls) { jlocation start; jlocation end; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -108,7 +108,7 @@ Java_nsk_jvmti_ClearBreakpoint_clrbrk002_check(JNIEnv *env, jclass cls) { } mid = env->GetStaticMethodID(cls, "run", "([Ljava/lang/String;Ljava/io/PrintStream;)I"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot find method run\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearBreakpoint/clrbrk005/clrbrk005.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearBreakpoint/clrbrk005/clrbrk005.cpp index f431e14ef10..d845833d94b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearBreakpoint/clrbrk005/clrbrk005.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearBreakpoint/clrbrk005/clrbrk005.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -53,12 +53,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -96,7 +96,7 @@ Java_nsk_jvmti_ClearBreakpoint_clrbrk005_check(JNIEnv *env, jclass cls) { jvmtiError err; jmethodID mid; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -114,7 +114,7 @@ Java_nsk_jvmti_ClearBreakpoint_clrbrk005_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> invalid method check ...\n"); } - err = jvmti->ClearBreakpoint(NULL, 0); + err = jvmti->ClearBreakpoint(nullptr, 0); if (err != JVMTI_ERROR_INVALID_METHODID) { printf("Error expected: JVMTI_ERROR_INVALID_METHODID,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearFieldAccessWatch/clrfldw001/clrfldw001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearFieldAccessWatch/clrfldw001/clrfldw001.cpp index b40cf1e70fa..09561cd971b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearFieldAccessWatch/clrfldw001/clrfldw001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearFieldAccessWatch/clrfldw001/clrfldw001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -45,14 +45,14 @@ static jvmtiEnv *jvmti; static jvmtiEventCallbacks callbacks; static jvmtiCapabilities caps; static jint result = PASSED; -static jfieldID thrown_fid = NULL; +static jfieldID thrown_fid = nullptr; static field fields[] = { - { "nsk/jvmti/ClearFieldAccessWatch/clrfldw001", "fld0", "I", 0, NULL }, - { "nsk/jvmti/ClearFieldAccessWatch/clrfldw001", "fld1", "I", 1, NULL }, + { "nsk/jvmti/ClearFieldAccessWatch/clrfldw001", "fld0", "I", 0, nullptr }, + { "nsk/jvmti/ClearFieldAccessWatch/clrfldw001", "fld1", "I", 1, nullptr }, { "nsk/jvmti/ClearFieldAccessWatch/clrfldw001", "fld2", - "Lnsk/jvmti/ClearFieldAccessWatch/clrfldw001a;", 0, NULL }, - { "nsk/jvmti/ClearFieldAccessWatch/clrfldw001a", "fld3", "[I", 0, NULL }, - { "nsk/jvmti/ClearFieldAccessWatch/clrfldw001b", "fld4", "F", 0, NULL }, + "Lnsk/jvmti/ClearFieldAccessWatch/clrfldw001a;", 0, nullptr }, + { "nsk/jvmti/ClearFieldAccessWatch/clrfldw001a", "fld3", "[I", 0, nullptr }, + { "nsk/jvmti/ClearFieldAccessWatch/clrfldw001b", "fld4", "F", 0, nullptr }, }; void switchWatch(JNIEnv *env, jint ind, jboolean on) { @@ -62,7 +62,7 @@ void switchWatch(JNIEnv *env, jint ind, jboolean on) { const char *msg; cls = env->FindClass(fld.klass); - if (fld.fid == NULL) { + if (fld.fid == nullptr) { if (fld.stat) { fields[ind].fid = env->GetStaticFieldID(cls, fld.name, fld.sig); } else { @@ -109,7 +109,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } @@ -145,7 +145,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_FIELD_ACCESS, NULL); + JVMTI_EVENT_FIELD_ACCESS, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable JVMTI_EVENT_FIELD_ACCESS: %s (%d)\n", TranslateError(err), err); @@ -182,7 +182,7 @@ JNIEXPORT void JNICALL Java_nsk_jvmti_ClearFieldAccessWatch_clrfldw001_check(JNIEnv *env, jclass cls, jint fld_ind, jboolean flag) { if (caps.can_generate_field_access_events) { - if (flag == JNI_FALSE && thrown_fid != NULL) { + if (flag == JNI_FALSE && thrown_fid != nullptr) { result = STATUS_FAILED; printf("(Field %d) FIELD_ACCESS event without access watch set\n", fld_ind); @@ -191,7 +191,7 @@ Java_nsk_jvmti_ClearFieldAccessWatch_clrfldw001_check(JNIEnv *env, printf("(Field %d) thrown field ID expected: 0x%p, got: 0x%p\n", fld_ind, fields[fld_ind].fid, thrown_fid); } - thrown_fid = NULL; + thrown_fid = nullptr; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearFieldAccessWatch/clrfldw002/clrfldw002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearFieldAccessWatch/clrfldw002/clrfldw002.cpp index 889c2781623..4ae421245ee 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearFieldAccessWatch/clrfldw002/clrfldw002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearFieldAccessWatch/clrfldw002/clrfldw002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -59,7 +59,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } @@ -96,7 +96,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_FIELD_ACCESS, NULL); + JVMTI_EVENT_FIELD_ACCESS, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable JVMTI_EVENT_FIELD_ACCESS: %s (%d)\n", TranslateError(err), err); @@ -125,14 +125,14 @@ Java_nsk_jvmti_ClearFieldAccessWatch_clrfldw002_check(JNIEnv *env, jclass cls) { TranslateError(err), err); } } else { - err = jvmti->ClearFieldAccessWatch(NULL, fid2); + err = jvmti->ClearFieldAccessWatch(nullptr, fid2); if (err != JVMTI_ERROR_INVALID_CLASS) { result = STATUS_FAILED; printf("Failed to return JVMTI_ERROR_INVALID_CLASS: %s (%d)\n", TranslateError(err), err); } - err = jvmti->ClearFieldAccessWatch(cls, NULL); + err = jvmti->ClearFieldAccessWatch(cls, nullptr); if (err != JVMTI_ERROR_INVALID_FIELDID) { result = STATUS_FAILED; printf("Failed to return INVALID_FIELDID: %s (%d)\n", diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearFieldModificationWatch/clrfmodw001/clrfmodw001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearFieldModificationWatch/clrfmodw001/clrfmodw001.cpp index 46e0dffa21c..eaf686e623e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearFieldModificationWatch/clrfmodw001/clrfmodw001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearFieldModificationWatch/clrfmodw001/clrfmodw001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -45,14 +45,14 @@ static jvmtiEnv *jvmti; static jvmtiEventCallbacks callbacks; static jvmtiCapabilities caps; static jint result = PASSED; -static jfieldID thrown_fid = NULL; +static jfieldID thrown_fid = nullptr; static field fields[] = { - { "nsk/jvmti/ClearFieldModificationWatch/clrfmodw001", "fld0", "I", 0, NULL }, - { "nsk/jvmti/ClearFieldModificationWatch/clrfmodw001", "fld1", "I", 1, NULL }, + { "nsk/jvmti/ClearFieldModificationWatch/clrfmodw001", "fld0", "I", 0, nullptr }, + { "nsk/jvmti/ClearFieldModificationWatch/clrfmodw001", "fld1", "I", 1, nullptr }, { "nsk/jvmti/ClearFieldModificationWatch/clrfmodw001", "fld2", - "Lnsk/jvmti/ClearFieldModificationWatch/clrfmodw001a;", 0, NULL }, - { "nsk/jvmti/ClearFieldModificationWatch/clrfmodw001a", "fld3", "[I", 0, NULL }, - { "nsk/jvmti/ClearFieldModificationWatch/clrfmodw001b", "fld4", "F", 0, NULL }, + "Lnsk/jvmti/ClearFieldModificationWatch/clrfmodw001a;", 0, nullptr }, + { "nsk/jvmti/ClearFieldModificationWatch/clrfmodw001a", "fld3", "[I", 0, nullptr }, + { "nsk/jvmti/ClearFieldModificationWatch/clrfmodw001b", "fld4", "F", 0, nullptr }, }; void switchWatch(JNIEnv *env, jint ind, jboolean on) { @@ -62,7 +62,7 @@ void switchWatch(JNIEnv *env, jint ind, jboolean on) { const char *msg; cls = env->FindClass(fld.klass); - if (fld.fid == NULL) { + if (fld.fid == nullptr) { if (fld.stat) { fields[ind].fid = env->GetStaticFieldID(cls, fld.name, fld.sig); } else { @@ -109,7 +109,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } @@ -145,7 +145,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_FIELD_MODIFICATION, NULL); + JVMTI_EVENT_FIELD_MODIFICATION, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable JVMTI_EVENT_FIELD_MODIFICATION: %s (%d)\n", TranslateError(err), err); @@ -175,7 +175,7 @@ JNIEXPORT void JNICALL Java_nsk_jvmti_ClearFieldModificationWatch_clrfmodw001_to JNIEXPORT void JNICALL Java_nsk_jvmti_ClearFieldModificationWatch_clrfmodw001_check(JNIEnv *env, jclass cls, jint fld_ind, jboolean flag) { if (caps.can_generate_field_modification_events) { - if (flag == JNI_FALSE && thrown_fid != NULL) { + if (flag == JNI_FALSE && thrown_fid != nullptr) { result = STATUS_FAILED; printf("(Field %d) ", fld_ind); printf("FieldModification event without modification watch set\n"); @@ -184,7 +184,7 @@ Java_nsk_jvmti_ClearFieldModificationWatch_clrfmodw001_check(JNIEnv *env, jclass printf("(Field %d) thrown field ID expected: 0x%p, got: 0x%p\n", fld_ind, fields[fld_ind].fid, thrown_fid); } - thrown_fid = NULL; + thrown_fid = nullptr; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearFieldModificationWatch/clrfmodw002/clrfmodw002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearFieldModificationWatch/clrfmodw002/clrfmodw002.cpp index 127653e5010..329e8c32a2c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearFieldModificationWatch/clrfmodw002/clrfmodw002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearFieldModificationWatch/clrfmodw002/clrfmodw002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -60,7 +60,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } @@ -96,7 +96,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_FIELD_MODIFICATION, NULL); + JVMTI_EVENT_FIELD_MODIFICATION, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable JVMTI_EVENT_FIELD_MODIFICATION: %s (%d)\n", TranslateError(err), err); @@ -127,14 +127,14 @@ Java_nsk_jvmti_ClearFieldModificationWatch_clrfmodw002_check(JNIEnv *env, TranslateError(err), err); } } else { - err = jvmti->ClearFieldModificationWatch(NULL, fid2); + err = jvmti->ClearFieldModificationWatch(nullptr, fid2); if (err != JVMTI_ERROR_INVALID_CLASS) { result = STATUS_FAILED; printf("Failed to return JVMTI_ERROR_INVALID_CLASS: %s (%d)\n", TranslateError(err), err); } - err = jvmti->ClearFieldModificationWatch(cls, NULL); + err = jvmti->ClearFieldModificationWatch(cls, nullptr); if (err != JVMTI_ERROR_INVALID_FIELDID) { result = STATUS_FAILED; printf("Failed to return INVALID_FIELDID: %s (%d)\n", diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/CompiledMethodLoad/compmethload001/compmethload001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/CompiledMethodLoad/compmethload001/compmethload001.cpp index a75546f9bdd..f70ded6238a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/CompiledMethodLoad/compmethload001/compmethload001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/CompiledMethodLoad/compmethload001/compmethload001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,7 @@ extern "C" { #define PASSED 0 static volatile jint result = PASSED; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jvmtiCapabilities caps; @@ -113,7 +113,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add capability to generate compiled method events */ @@ -137,9 +137,9 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; NSK_DISPLAY0("setting event callbacks done\nenabling VMInit, CompiledMethodLoad event ...\n"); - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, nullptr))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_LOAD, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_LOAD, nullptr))) return JNI_ERR; NSK_DISPLAY0("enabling the events done\n\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/CompiledMethodUnload/compmethunload001/compmethunload001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/CompiledMethodUnload/compmethunload001/compmethunload001.cpp index 7b048a2202f..e3b50a0474e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/CompiledMethodUnload/compmethunload001/compmethunload001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/CompiledMethodUnload/compmethunload001/compmethunload001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ extern "C" { static volatile jint result = PASSED; static volatile int compunload = 0; static volatile int class_unloaded = 0; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jvmtiCapabilities caps; @@ -88,7 +88,7 @@ CompiledMethodUnload(jvmtiEnv *jvmti_env, jmethodID method, NSK_DISPLAY0("CompiledMethodUnload event received\n"); // Check for the case that the class has been unloaded - err = jvmti_env->GetMethodName(method, &name, &sig, NULL); + err = jvmti_env->GetMethodName(method, &name, &sig, nullptr); if (err == JVMTI_ERROR_NONE) { NSK_DISPLAY3("for: \tmethod: name=\"%s\" signature=\"%s\"\n\tnative address=0x%p\n", name, sig, code_addr); @@ -157,7 +157,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add capability to generate compiled method events */ @@ -182,11 +182,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; NSK_DISPLAY0("setting event callbacks done\nenabling JVMTI events ...\n"); - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, nullptr))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_LOAD, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_LOAD, nullptr))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_UNLOAD, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_UNLOAD, nullptr))) return JNI_ERR; NSK_DISPLAY0("enabling the events done\n\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/CreateRawMonitor/crrawmon001/crrawmon001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/CreateRawMonitor/crrawmon001/crrawmon001.cpp index 4e8af24dc49..d2a0073b2ae 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/CreateRawMonitor/crrawmon001/crrawmon001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/CreateRawMonitor/crrawmon001/crrawmon001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ extern "C" { #define STATUS_FAILED 2 #define RAW_MONITORS_NUMBER 1024 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -57,7 +57,7 @@ void JNICALL VMInit(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thr) { printf("(CreateRawMonitor#%d) unexpected error: %s (%d)\n", i, TranslateError(err), err); result = STATUS_FAILED; - } else if (monitors[i] == NULL) { + } else if (monitors[i] == nullptr) { printf("(CreateRawMonitor#%d) jrawMonitorID is null\n", i); result = STATUS_FAILED; } @@ -79,12 +79,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -98,7 +98,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_VM_INIT, NULL); + JVMTI_EVENT_VM_INIT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable JVMTI_EVENT_VM_INIT: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/CreateRawMonitor/crrawmon002/crrawmon002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/CreateRawMonitor/crrawmon002/crrawmon002.cpp index 65edf664342..12519a57c2a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/CreateRawMonitor/crrawmon002/crrawmon002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/CreateRawMonitor/crrawmon002/crrawmon002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_crrawmon002(JavaVM *jvm, char *options, void *reserved jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -69,7 +69,7 @@ Java_nsk_jvmti_CreateRawMonitor_crrawmon002_check(JNIEnv *env, jclass cls) { jvmtiError err; jrawMonitorID monitor; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -77,7 +77,7 @@ Java_nsk_jvmti_CreateRawMonitor_crrawmon002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> name null pointer check ...\n"); } - err = jvmti->CreateRawMonitor(NULL, &monitor); + err = jvmti->CreateRawMonitor(nullptr, &monitor); if (err != JVMTI_ERROR_NULL_POINTER) { printf("Error expected: JVMTI_ERROR_NULL_POINTER, got: %s\n", TranslateError(err)); @@ -87,7 +87,7 @@ Java_nsk_jvmti_CreateRawMonitor_crrawmon002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> monitorPtr null pointer check ...\n"); } - err = jvmti->CreateRawMonitor("dummy", NULL); + err = jvmti->CreateRawMonitor("dummy", nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { printf("Error expected: JVMTI_ERROR_NULL_POINTER, got: %s\n", TranslateError(err)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/DataDumpRequest/datadumpreq001/datadumpreq001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/DataDumpRequest/datadumpreq001/datadumpreq001.cpp index 61994f9b6a6..5a8843e6e38 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/DataDumpRequest/datadumpreq001/datadumpreq001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/DataDumpRequest/datadumpreq001/datadumpreq001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ extern "C" { #define PASSED 0 static jint result = STATUS_FAILED; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jboolean eventReceived = JNI_FALSE; @@ -106,7 +106,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) { + if (!NSK_VERIFY(jvmti != nullptr)) { return JNI_ERR; } @@ -122,7 +122,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; NSK_DISPLAY0("setting event callbacks done\nenabling JVMTI events ...\n"); - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_DATA_DUMP_REQUEST, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_DATA_DUMP_REQUEST, nullptr))) return JNI_ERR; NSK_DISPLAY0("enabling the events done\n\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Deallocate/dealloc001/dealloc001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Deallocate/dealloc001/dealloc001.cpp index 3aac4d41b95..82ea6825b63 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Deallocate/dealloc001/dealloc001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Deallocate/dealloc001/dealloc001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_dealloc001(JavaVM *jvm, char *options, void *reserved) jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -68,7 +68,7 @@ JNIEXPORT jint JNICALL Java_nsk_jvmti_Deallocate_dealloc001_check(JNIEnv *env, jclass cls) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -76,7 +76,7 @@ Java_nsk_jvmti_Deallocate_dealloc001_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> Null pointer check ...\n"); } - err = jvmti->Deallocate(NULL); + err = jvmti->Deallocate(nullptr); if (err != JVMTI_ERROR_NONE) { printf("Error expected: JVMTI_ERROR_NONE, got: %s\n", TranslateError(err)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/DestroyRawMonitor/drrawmon001/drrawmon001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/DestroyRawMonitor/drrawmon001/drrawmon001.cpp index 35f2e6557f2..341da0a65b3 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/DestroyRawMonitor/drrawmon001/drrawmon001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/DestroyRawMonitor/drrawmon001/drrawmon001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ extern "C" { #define STATUS_FAILED 2 #define RAW_MONITORS_NUMBER 1024 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -58,7 +58,7 @@ void JNICALL VMInit(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thr) { i, TranslateError(err), err); result = STATUS_FAILED; return; - } else if (monitors[i] == NULL) { + } else if (monitors[i] == nullptr) { printf("(CreateRawMonitor#%d) jrawMonitorID is null\n", i); result = STATUS_FAILED; return; @@ -94,12 +94,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -113,7 +113,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_VM_INIT, NULL); + JVMTI_EVENT_VM_INIT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable JVMTI_EVENT_VM_INIT: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/DestroyRawMonitor/drrawmon003/drrawmon003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/DestroyRawMonitor/drrawmon003/drrawmon003.cpp index 451be8b3bc8..22765b973d8 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/DestroyRawMonitor/drrawmon003/drrawmon003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/DestroyRawMonitor/drrawmon003/drrawmon003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jboolean printdump = JNI_FALSE; #ifdef STATIC_BUILD @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_drrawmon003(JavaVM *jvm, char *options, void *reserved jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -69,7 +69,7 @@ Java_nsk_jvmti_DestroyRawMonitor_drrawmon003_check(JNIEnv *env, jclass cls) { jvmtiError err; jrawMonitorID monitor; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/DestroyRawMonitor/drrawmon004/drrawmon004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/DestroyRawMonitor/drrawmon004/drrawmon004.cpp index 18e322e2438..154e98fe12f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/DestroyRawMonitor/drrawmon004/drrawmon004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/DestroyRawMonitor/drrawmon004/drrawmon004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_drrawmon004(JavaVM *jvm, char *options, void *reserved jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -68,7 +68,7 @@ JNIEXPORT jint JNICALL Java_nsk_jvmti_DestroyRawMonitor_drrawmon004_check(JNIEnv *env, jclass cls) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -77,7 +77,7 @@ Java_nsk_jvmti_DestroyRawMonitor_drrawmon004_check(JNIEnv *env, jclass cls) { printf(">>> invalid monitor check ...\n"); } - err = jvmti->DestroyRawMonitor(NULL); + err = jvmti->DestroyRawMonitor(nullptr); if (err != JVMTI_ERROR_INVALID_MONITOR) { printf("Error expected: JVMTI_ERROR_INVALID_MONITOR,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/DisposeEnvironment/disposeenv001/disposeenv001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/DisposeEnvironment/disposeenv001/disposeenv001.cpp index 43dc539ab3f..b652a8259dd 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/DisposeEnvironment/disposeenv001/disposeenv001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/DisposeEnvironment/disposeenv001/disposeenv001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,13 +44,13 @@ JNIEXPORT jint JNI_OnLoad_disposeenv001(JavaVM *jvm, char *options, void *reserv } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; NSK_DISPLAY0(">>> Testcase #1: Dispose JVMTI environment in Agent_OnLoad()\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/DisposeEnvironment/disposeenv002/disposeenv002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/DisposeEnvironment/disposeenv002/disposeenv002.cpp index c804a2ca64c..220243ae1a2 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/DisposeEnvironment/disposeenv002/disposeenv002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/DisposeEnvironment/disposeenv002/disposeenv002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -45,7 +45,7 @@ callbackVMDeath(jvmtiEnv* jvmti, JNIEnv* jni) { NSK_DISPLAY0("Disable VM_DEATH event in VM_DEATH callback\n"); if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_VM_DEATH, NULL))) { + jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_VM_DEATH, nullptr))) { success = NSK_FALSE; } else { NSK_DISPLAY0(" ... disabled\n"); @@ -79,13 +79,13 @@ JNIEXPORT jint JNI_OnLoad_disposeenv002(JavaVM *jvm, char *options, void *reserv } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; { @@ -99,7 +99,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { NSK_DISPLAY0("Enable VM_DEATH event in JVM_OnLoad()\n"); if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL))) { + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, nullptr))) { return JNI_ERR; } NSK_DISPLAY0(" ... enabled\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/DynamicCodeGenerated/dyncodgen001/dyncodgen001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/DynamicCodeGenerated/dyncodgen001/dyncodgen001.cpp index 9de2b542633..676fd762a7a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/DynamicCodeGenerated/dyncodgen001/dyncodgen001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/DynamicCodeGenerated/dyncodgen001/dyncodgen001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -99,7 +99,7 @@ JNIEXPORT jint JNI_OnLoad_dyncodgen001(JavaVM *jvm, char *options, void *reserve } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiEventCallbacks callbacks; /* init framework and parse options */ @@ -111,7 +111,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; memset(&callbacks, 0, sizeof(callbacks)); @@ -121,11 +121,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* enable DynamicCodeGenerated event */ if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_DYNAMIC_CODE_GENERATED, NULL))) + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_DYNAMIC_CODE_GENERATED, nullptr))) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ForceEarlyReturn/ForceEarlyReturn001/ForceEarlyReturn001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ForceEarlyReturn/ForceEarlyReturn001/ForceEarlyReturn001.cpp index c3eed7356cc..29df3168b9b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ForceEarlyReturn/ForceEarlyReturn001/ForceEarlyReturn001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ForceEarlyReturn/ForceEarlyReturn001/ForceEarlyReturn001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ extern "C" { /* ============================================================================= */ -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; @@ -178,7 +178,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { jvmtiCapabilities caps; - if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved)) != NULL)) + if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved)) != nullptr)) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->GetCapabilities(&caps))) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ForceGarbageCollection/forcegc001/forcegc001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ForceGarbageCollection/forcegc001/forcegc001.cpp index d7d1d712550..eb956244fe5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ForceGarbageCollection/forcegc001/forcegc001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ForceGarbageCollection/forcegc001/forcegc001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -72,7 +72,7 @@ JNIEXPORT jint JNI_OnLoad_forcegc001(JavaVM *jvm, char *options, void *reserved) } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -80,10 +80,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ForceGarbageCollection/forcegc002/forcegc002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ForceGarbageCollection/forcegc002/forcegc002.cpp index a069c099e50..5332beb8397 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ForceGarbageCollection/forcegc002/forcegc002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ForceGarbageCollection/forcegc002/forcegc002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -50,7 +50,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { events = 0; NSK_DISPLAY0("Enable event GarbageCollectionStart\n"); - if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, NULL))) + if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, nullptr))) return; NSK_DISPLAY0("Call ForceGarbageCollection()\n"); @@ -60,7 +60,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { } NSK_DISPLAY0("Disable event GarbageCollectionStart\n"); - if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_DISABLE, 1, &event, NULL))) + if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_DISABLE, 1, &event, nullptr))) return; NSK_DISPLAY0("Check if expected events received\n"); @@ -98,7 +98,7 @@ JNIEXPORT jint JNI_OnLoad_forcegc002(JavaVM *jvm, char *options, void *reserved) } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -106,7 +106,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; { @@ -125,7 +125,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GarbageCollectionFinish/gcfinish001/gcfinish001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GarbageCollectionFinish/gcfinish001/gcfinish001.cpp index e247fbdbd00..819aa9189aa 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GarbageCollectionFinish/gcfinish001/gcfinish001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GarbageCollectionFinish/gcfinish001/gcfinish001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ extern "C" { #define MEM_SIZE 1024 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jvmtiCapabilities caps; @@ -194,7 +194,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add capability to generate compiled method events */ @@ -218,9 +218,9 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; NSK_DISPLAY0("setting event callbacks done\nenabling JVMTI events ...\n"); - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, nullptr))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_FINISH, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_FINISH, nullptr))) return JNI_ERR; NSK_DISPLAY0("enabling the events done\n\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GarbageCollectionStart/gcstart001/gcstart001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GarbageCollectionStart/gcstart001/gcstart001.cpp index d9dab1b0c7d..ff8e837f277 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GarbageCollectionStart/gcstart001/gcstart001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GarbageCollectionStart/gcstart001/gcstart001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ extern "C" { static volatile jint result = PASSED; static volatile int gcstart = 0; static volatile int gcfinish = 0; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jvmtiCapabilities caps; @@ -114,7 +114,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add capability to generate compiled method events */ @@ -139,11 +139,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; NSK_DISPLAY0("setting event callbacks done\nenabling JVMTI events ...\n"); - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, nullptr))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_START, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_START, nullptr))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_FINISH, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_FINISH, nullptr))) return JNI_ERR; NSK_DISPLAY0("enabling the events done\n\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GarbageCollectionStart/gcstart002/gcstart002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GarbageCollectionStart/gcstart002/gcstart002.cpp index fb9d69ddd08..ba134f06ed8 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GarbageCollectionStart/gcstart002/gcstart002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GarbageCollectionStart/gcstart002/gcstart002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ extern "C" { #define MEM_SIZE 1024 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jvmtiCapabilities caps; @@ -195,7 +195,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add capability to generate compiled method events */ @@ -219,9 +219,9 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; NSK_DISPLAY0("setting event callbacks done\nenabling JVMTI events ...\n"); - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, nullptr))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_START, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_START, nullptr))) return JNI_ERR; NSK_DISPLAY0("enabling the events done\n\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GenerateEvents/genevents001/genevents001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GenerateEvents/genevents001/genevents001.cpp index f208bcdfb42..02228b3021a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GenerateEvents/genevents001/genevents001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GenerateEvents/genevents001/genevents001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -94,7 +94,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { } NSK_DISPLAY1("Enable events: %d events\n", EVENTS_COUNT); - if (!nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, eventsList, NULL)) { + if (!nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, eventsList, nullptr)) { nsk_jvmti_setFailStatus(); } @@ -108,7 +108,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { } NSK_DISPLAY1("Disable events: %d events\n", EVENTS_COUNT); - if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, eventsList, NULL)) { + if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, eventsList, nullptr)) { nsk_jvmti_setFailStatus(); } @@ -174,7 +174,7 @@ JNIEXPORT jint JNI_OnLoad_genevents001(JavaVM *jvm, char *options, void *reserve } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -182,10 +182,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; /* add required capabilities */ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetArgumentsSize/argsize001/argsize001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetArgumentsSize/argsize001/argsize001.cpp index 38b2612cab8..25d72ff3ba6 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetArgumentsSize/argsize001/argsize001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetArgumentsSize/argsize001/argsize001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -32,12 +32,12 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; void chk(JNIEnv *env, jclass cl, const char *name, const char *sig, int stat, int size) { jvmtiError err; - jmethodID mid = NULL; + jmethodID mid = nullptr; jint ret_size; if (stat) { @@ -45,7 +45,7 @@ void chk(JNIEnv *env, jclass cl, const char *name, const char *sig, int stat, in } else { mid = env->GetMethodID(cl, name, sig); } - if (mid == NULL) { + if (mid == nullptr) { printf("Name = %s, sig = %s: mid = 0\n", name, sig); } err = jvmti->GetArgumentsSize(mid, &ret_size); @@ -76,7 +76,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetArgumentsSize/argsize002/argsize002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetArgumentsSize/argsize002/argsize002.cpp index 5fd7c0d2d04..f2d9f76e219 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetArgumentsSize/argsize002/argsize002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetArgumentsSize/argsize002/argsize002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_argsize002(JavaVM *jvm, char *options, void *reserved) jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -70,13 +70,13 @@ Java_nsk_jvmti_GetArgumentsSize_argsize002_check(JNIEnv *env, jclass cls) { jmethodID mid; jint size; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } mid = env->GetMethodID(cls, "", "()V"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot get method ID for \"\"!\n"); return STATUS_FAILED; } @@ -84,7 +84,7 @@ Java_nsk_jvmti_GetArgumentsSize_argsize002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> invalid method check ...\n"); } - err = jvmti->GetArgumentsSize(NULL, &size); + err = jvmti->GetArgumentsSize(nullptr, &size); if (err != JVMTI_ERROR_INVALID_METHODID) { printf("Error expected: JVMTI_ERROR_INVALID_METHODID,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -94,7 +94,7 @@ Java_nsk_jvmti_GetArgumentsSize_argsize002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> null pointer check ...\n"); } - err = jvmti->GetArgumentsSize(mid, NULL); + err = jvmti->GetArgumentsSize(mid, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { printf("Error expected: JVMTI_ERROR_NULL_POINTER,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -102,7 +102,7 @@ Java_nsk_jvmti_GetArgumentsSize_argsize002_check(JNIEnv *env, jclass cls) { } mid = env->GetStaticMethodID(cls, "check", "()I"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot get method ID for \"check\"!\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetAvailableProcessors/getavailproc001/getavailproc001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetAvailableProcessors/getavailproc001/getavailproc001.cpp index 28d4ad2a91a..f374cef29ae 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetAvailableProcessors/getavailproc001/getavailproc001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetAvailableProcessors/getavailproc001/getavailproc001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -112,7 +112,7 @@ callbackVMDeath(jvmtiEnv* jvmti, JNIEnv* jni) { success = checkProcessors(jvmti, "VM_DEATH callback"); NSK_DISPLAY1("Disable events: %d events\n", EVENTS_COUNT); - if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, NULL)) { + if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, nullptr)) { success = NSK_FALSE; } else { NSK_DISPLAY0(" ... disabled\n"); @@ -139,7 +139,7 @@ JNIEXPORT jint JNI_OnLoad_getavailproc001(JavaVM *jvm, char *options, void *rese } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -147,7 +147,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; { @@ -162,7 +162,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; NSK_DISPLAY0(">>> Testcase #1: Check available processors in Agent_OnLoad()\n"); @@ -171,7 +171,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } NSK_DISPLAY1("Enable events: %d events\n", EVENTS_COUNT); - if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, NULL)) { + if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, nullptr)) { NSK_DISPLAY0(" ... enabled\n"); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetBytecodes/bytecodes001/bytecodes001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetBytecodes/bytecodes001/bytecodes001.cpp index ee476a7ce33..b0971242418 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetBytecodes/bytecodes001/bytecodes001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetBytecodes/bytecodes001/bytecodes001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ typedef struct { unsigned char *codes; } info; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -70,12 +70,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -117,12 +117,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { void checkMeth(JNIEnv *env, jclass cl, int meth_ind) { jvmtiError err; - jmethodID mid = NULL; + jmethodID mid = nullptr; jint count = -1; - unsigned char *codes = NULL; + unsigned char *codes = nullptr; int i; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; @@ -135,7 +135,7 @@ void checkMeth(JNIEnv *env, jclass cl, int meth_ind) { mid = env->GetMethodID(cl, meth_tab[meth_ind].name, meth_tab[meth_ind].sig); } - if (mid == NULL) { + if (mid == nullptr) { printf("\"%s%s\": cannot get method ID!\n", meth_tab[meth_ind].name, meth_tab[meth_ind].sig); result = STATUS_FAILED; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetBytecodes/bytecodes002/bytecodes002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetBytecodes/bytecodes002/bytecodes002.cpp index ad5e5eeacd2..63a0a3c866a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetBytecodes/bytecodes002/bytecodes002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetBytecodes/bytecodes002/bytecodes002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -53,12 +53,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -105,13 +105,13 @@ Java_nsk_jvmti_GetBytecodes_bytecodes002_check(JNIEnv *env, jclass cls) { jint bytecodeCount; unsigned char *bytecodes; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } mid = env->GetMethodID(cls, "", "()V"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot get method ID for \"\"!\n"); return STATUS_FAILED; } @@ -119,7 +119,7 @@ Java_nsk_jvmti_GetBytecodes_bytecodes002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> invalid method check ...\n"); } - err = jvmti->GetBytecodes(NULL, &bytecodeCount, &bytecodes); + err = jvmti->GetBytecodes(nullptr, &bytecodeCount, &bytecodes); if (err == JVMTI_ERROR_MUST_POSSESS_CAPABILITY && !caps.can_get_bytecodes) { /* It is OK */ } else if (err != JVMTI_ERROR_INVALID_METHODID) { @@ -131,7 +131,7 @@ Java_nsk_jvmti_GetBytecodes_bytecodes002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> (bytecodeCountPtr) null pointer check ...\n"); } - err = jvmti->GetBytecodes(mid, NULL, &bytecodes); + err = jvmti->GetBytecodes(mid, nullptr, &bytecodes); if (err == JVMTI_ERROR_MUST_POSSESS_CAPABILITY && !caps.can_get_bytecodes) { /* It is OK */ } else if (err != JVMTI_ERROR_NULL_POINTER) { @@ -143,7 +143,7 @@ Java_nsk_jvmti_GetBytecodes_bytecodes002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> (bytecodesPtr) null pointer check ...\n"); } - err = jvmti->GetBytecodes(mid, &bytecodeCount, NULL); + err = jvmti->GetBytecodes(mid, &bytecodeCount, nullptr); if (err == JVMTI_ERROR_MUST_POSSESS_CAPABILITY && !caps.can_get_bytecodes) { /* It is OK */ } else if (err != JVMTI_ERROR_NULL_POINTER) { @@ -153,7 +153,7 @@ Java_nsk_jvmti_GetBytecodes_bytecodes002_check(JNIEnv *env, jclass cls) { } mid = env->GetStaticMethodID(cls, "check", "()I"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot get method ID for \"check\"!\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetBytecodes/bytecodes003/bytecodes003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetBytecodes/bytecodes003/bytecodes003.cpp index bd8c2e25abe..4d7ed6978de 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetBytecodes/bytecodes003/bytecodes003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetBytecodes/bytecodes003/bytecodes003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,7 @@ typedef struct { int length; } opcode_info; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; static jint result = PASSED; @@ -324,8 +324,8 @@ void JNICALL ClassPrepare(jvmtiEnv *jvmti_env, JNIEnv *env, unsigned char *bytecodes; jint i; - sig = NULL; - err = jvmti_env->GetClassSignature(cls, &sig, NULL); + sig = nullptr; + err = jvmti_env->GetClassSignature(cls, &sig, nullptr); if (err != JVMTI_ERROR_NONE) { printf("(GetClassSignature#%d) unexpected error: %s (%d)\n", eventsCount, TranslateError(err), err); @@ -347,15 +347,15 @@ void JNICALL ClassPrepare(jvmtiEnv *jvmti_env, JNIEnv *env, } for (i = 0; i < mcount; i++) { - if (methods[i] == NULL) { + if (methods[i] == nullptr) { if (printdump == JNI_TRUE) { printf(" null"); } } else { - name = NULL; - msig = NULL; - bytecodes = NULL; - err = jvmti_env->GetMethodName(methods[i], &name, &msig, NULL); + name = nullptr; + msig = nullptr; + bytecodes = nullptr; + err = jvmti_env->GetMethodName(methods[i], &name, &msig, nullptr); if (err != JVMTI_ERROR_NONE) { printf("(GetMethodName) unexpected error: %s (%d)\n", TranslateError(err), err); @@ -397,22 +397,22 @@ void JNICALL ClassPrepare(jvmtiEnv *jvmti_env, JNIEnv *env, } } } - if (name != NULL) { + if (name != nullptr) { jvmti_env->Deallocate((unsigned char *)name); } - if (msig != NULL) { + if (msig != nullptr) { jvmti_env->Deallocate((unsigned char *)msig); } - if (bytecodes != NULL) { + if (bytecodes != nullptr) { jvmti_env->Deallocate(bytecodes); } } } - if (methods != NULL) { + if (methods != nullptr) { jvmti_env->Deallocate((unsigned char *)methods); } - if (sig != NULL) { + if (sig != nullptr) { jvmti_env->Deallocate((unsigned char *)sig); } eventsCount++; @@ -433,12 +433,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -488,7 +488,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_CLASS_PREPARE, NULL); + JVMTI_EVENT_CLASS_PREPARE, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable ClassPrepare: %s (%d)\n", TranslateError(err), err); @@ -505,14 +505,14 @@ JNIEXPORT jint JNICALL Java_nsk_jvmti_GetBytecodes_bytecodes003_check(JNIEnv *env, jclass cls) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } if (caps.can_get_bytecodes) { err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, - JVMTI_EVENT_CLASS_PREPARE, NULL); + JVMTI_EVENT_CLASS_PREPARE, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to disable JVMTI_EVENT_CLASS_PREPARE: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCapabilities/getcaps001/getcaps001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCapabilities/getcaps001/getcaps001.cpp index 33057c64901..74adc9187a8 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCapabilities/getcaps001/getcaps001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCapabilities/getcaps001/getcaps001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_getcaps001(JavaVM *jvm, char *options, void *reserved) jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -68,7 +68,7 @@ JNIEXPORT jint JNICALL Java_nsk_jvmti_GetCapabilities_getcaps001_check(JNIEnv *env, jclass cls) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -76,7 +76,7 @@ Java_nsk_jvmti_GetCapabilities_getcaps001_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> null pointer check ...\n"); } - err = jvmti->GetCapabilities(NULL); + err = jvmti->GetCapabilities(nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { printf("Error expected: JVMTI_ERROR_NULL_POINTER,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCapabilities/getcaps002/getcaps002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCapabilities/getcaps002/getcaps002.cpp index d3ddec8ad80..90bab14b567 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCapabilities/getcaps002/getcaps002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCapabilities/getcaps002/getcaps002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -252,7 +252,7 @@ callbackVMDeath(jvmtiEnv* jvmti, JNIEnv* jni) { success = checkCapabilities(jvmti, "VM_DEATH callback"); NSK_DISPLAY1("Disable events: %d events\n", EVENTS_COUNT); - if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, NULL)) { + if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, nullptr)) { success = NSK_FALSE; } else { NSK_DISPLAY0(" ... disabled\n"); @@ -279,7 +279,7 @@ JNIEXPORT jint JNI_OnLoad_getcaps002(JavaVM *jvm, char *options, void *reserved) } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -287,7 +287,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; { @@ -302,7 +302,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; NSK_DISPLAY0(">>> Testcase #1: Check capabilities in Agent_OnLoad()\n"); @@ -311,7 +311,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } NSK_DISPLAY1("Enable events: %d events\n", EVENTS_COUNT); - if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, NULL)) { + if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, nullptr)) { NSK_DISPLAY0(" ... enabled\n"); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassFields/getclfld005/getclfld005.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassFields/getclfld005/getclfld005.cpp index 38264eaa61a..cd178863545 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassFields/getclfld005/getclfld005.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassFields/getclfld005/getclfld005.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_getclfld005(JavaVM *jvm, char *options, void *reserved jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -70,7 +70,7 @@ Java_nsk_jvmti_GetClassFields_getclfld005_check(JNIEnv *env, jclass cls) { jint fcount; jfieldID *fields; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -78,7 +78,7 @@ Java_nsk_jvmti_GetClassFields_getclfld005_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> invalid class check ...\n"); } - err = jvmti->GetClassFields(NULL, &fcount, &fields); + err = jvmti->GetClassFields(nullptr, &fcount, &fields); if (err != JVMTI_ERROR_INVALID_CLASS) { printf("Error expected: JVMTI_ERROR_INVALID_CLASS,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -88,7 +88,7 @@ Java_nsk_jvmti_GetClassFields_getclfld005_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> (fieldCountPtr) null pointer check ...\n"); } - err = jvmti->GetClassFields(cls, NULL, &fields); + err = jvmti->GetClassFields(cls, nullptr, &fields); if (err != JVMTI_ERROR_NULL_POINTER) { printf("(fieldCountPtr) error expected: JVMTI_ERROR_NULL_POINTER,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -98,7 +98,7 @@ Java_nsk_jvmti_GetClassFields_getclfld005_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> (fieldsPtr) null pointer check ...\n"); } - err = jvmti->GetClassFields(cls, &fcount, NULL); + err = jvmti->GetClassFields(cls, &fcount, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { printf("(fieldsPtr) error expected: JVMTI_ERROR_NULL_POINTER,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassFields/getclfld006/getclfld006.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassFields/getclfld006/getclfld006.cpp index aace1a93e3c..1c786d84908 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassFields/getclfld006/getclfld006.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassFields/getclfld006/getclfld006.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_getclfld006(JavaVM *jvm, char *options, void *reserved jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -70,7 +70,7 @@ Java_nsk_jvmti_GetClassFields_getclfld006_check(JNIEnv *env, jclass cls, jint i, jint fcount; jfieldID *fields; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassFields/getclfld007/getclfld007.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassFields/getclfld007/getclfld007.cpp index 93da371fd54..c3f5a53daa5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassFields/getclfld007/getclfld007.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassFields/getclfld007/getclfld007.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,16 +33,16 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; // compares 'value' with jobject_arr[index] static bool equals_str(JNIEnv *env, const char *value, jobjectArray jobject_arr, jint index) { jstring jstr = (jstring)env->GetObjectArrayElement(jobject_arr, index); - const char* utf = env->GetStringUTFChars(jstr, NULL); + const char* utf = env->GetStringUTFChars(jstr, nullptr); bool res = false; - if (utf != NULL) { + if (utf != nullptr) { res = strcmp(value, utf) == 0; env->ReleaseStringUTFChars(jstr, utf); } else { @@ -68,7 +68,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -84,7 +84,7 @@ Java_nsk_jvmti_GetClassFields_getclfld007_check(JNIEnv *env, jclass cls, jclass char *name, *sig; int j; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); fflush(0); result = STATUS_FAILED; @@ -109,12 +109,12 @@ Java_nsk_jvmti_GetClassFields_getclfld007_check(JNIEnv *env, jclass cls, jclass result = STATUS_FAILED; } for (j = 0; j < fcount; j++) { - if (fields[j] == NULL) { + if (fields[j] == nullptr) { printf("(%d) fieldID = null\n", j); result = STATUS_FAILED; continue; } - err = jvmti->GetFieldName(clazz, fields[j], &name, &sig, NULL); + err = jvmti->GetFieldName(clazz, fields[j], &name, &sig, nullptr); if (err != JVMTI_ERROR_NONE) { printf("(GetFieldName#%d) unexpected error: %s (%d)\n", j, TranslateError(err), err); @@ -123,7 +123,7 @@ Java_nsk_jvmti_GetClassFields_getclfld007_check(JNIEnv *env, jclass cls, jclass } printf(">>> [%d]: %s, sig = \"%s\"\n", j, name, sig); if ((j < field_count) && - (name == NULL || sig == NULL || + (name == nullptr || sig == nullptr || !equals_str(env, name, fieldArr, j * 2) || !equals_str(env, sig, fieldArr, j * 2 + 1))) { printf("(%d) wrong field: \"%s%s\"", j, name, sig); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoader/getclsldr001/getclsldr001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoader/getclsldr001/getclsldr001.cpp index f337c203ba7..9d2d8a449d3 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoader/getclsldr001/getclsldr001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoader/getclsldr001/getclsldr001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_getclsldr001(JavaVM *jvm, char *options, void *reserve jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -69,7 +69,7 @@ Java_nsk_jvmti_GetClassLoader_getclsldr001_check(JNIEnv *env, jclass cls) { jvmtiError err; jobject classloader; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -77,7 +77,7 @@ Java_nsk_jvmti_GetClassLoader_getclsldr001_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> invalid class check ...\n"); } - err = jvmti->GetClassLoader(NULL, &classloader); + err = jvmti->GetClassLoader(nullptr, &classloader); if (err != JVMTI_ERROR_INVALID_CLASS) { printf("Error expected: JVMTI_ERROR_INVALID_CLASS,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -87,7 +87,7 @@ Java_nsk_jvmti_GetClassLoader_getclsldr001_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> null pointer check ...\n"); } - err = jvmti->GetClassLoader(cls, NULL); + err = jvmti->GetClassLoader(cls, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { printf("Error expected: JVMTI_ERROR_NULL_POINTER,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoader/getclsldr002/getclsldr002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoader/getclsldr002/getclsldr002.cpp index 04d473fc7c3..968158cc087 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoader/getclsldr002/getclsldr002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoader/getclsldr002/getclsldr002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_getclsldr002(JavaVM *jvm, char *options, void *reserve jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -71,7 +71,7 @@ Java_nsk_jvmti_GetClassLoader_getclsldr002_check(JNIEnv *env, jobject classloader; char *sig, *generic; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; @@ -97,8 +97,8 @@ Java_nsk_jvmti_GetClassLoader_getclsldr002_check(JNIEnv *env, printf(">>> %d: %s\n", i, sig); } - if (classloader != NULL) { - printf("(%d:%s) class loader is not NULL: 0x%p\n", + if (classloader != nullptr) { + printf("(%d:%s) class loader is not null: 0x%p\n", i, sig, classloader); result = STATUS_FAILED; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoader/getclsldr003/getclsldr003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoader/getclsldr003/getclsldr003.cpp index d003074a629..3bd7008a32d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoader/getclsldr003/getclsldr003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoader/getclsldr003/getclsldr003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_getclsldr003(JavaVM *jvm, char *options, void *reserve jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -71,7 +71,7 @@ Java_nsk_jvmti_GetClassLoader_getclsldr003_check(JNIEnv *env, jobject classloader; char *sig, *generic; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoaderClasses/clsldrclss001/clsldrclss001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoaderClasses/clsldrclss001/clsldrclss001.cpp index afe7952ab20..af3a2e0b162 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoaderClasses/clsldrclss001/clsldrclss001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoaderClasses/clsldrclss001/clsldrclss001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_clsldrclss001(JavaVM *jvm, char *options, void *reserv jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -71,7 +71,7 @@ Java_nsk_jvmti_GetClassLoaderClasses_clsldrclss001_check(JNIEnv *env, jclass cls jclass *classes; jint classCount; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -87,7 +87,7 @@ Java_nsk_jvmti_GetClassLoaderClasses_clsldrclss001_check(JNIEnv *env, jclass cls if (printdump == JNI_TRUE) { printf(">>> (initiatingLoader) null pointer check ...\n"); } - err = jvmti->GetClassLoaderClasses(NULL, &classCount, &classes); + err = jvmti->GetClassLoaderClasses(nullptr, &classCount, &classes); if (err == JVMTI_ERROR_NULL_POINTER) { printf("Expected: the classes initiated by the bootstrap loader,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -97,7 +97,7 @@ Java_nsk_jvmti_GetClassLoaderClasses_clsldrclss001_check(JNIEnv *env, jclass cls if (printdump == JNI_TRUE) { printf(">>> (classCountPtr) null pointer check ...\n"); } - err = jvmti->GetClassLoaderClasses(classloader, NULL, &classes); + err = jvmti->GetClassLoaderClasses(classloader, nullptr, &classes); if (err != JVMTI_ERROR_NULL_POINTER) { printf("Error expected: JVMTI_ERROR_NULL_POINTER,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -107,7 +107,7 @@ Java_nsk_jvmti_GetClassLoaderClasses_clsldrclss001_check(JNIEnv *env, jclass cls if (printdump == JNI_TRUE) { printf(">>> (classesPtr) null pointer check ...\n"); } - err = jvmti->GetClassLoaderClasses(classloader, &classCount, NULL); + err = jvmti->GetClassLoaderClasses(classloader, &classCount, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { printf("Error expected: JVMTI_ERROR_NULL_POINTER,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoaderClasses/clsldrclss002/clsldrclss002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoaderClasses/clsldrclss002/clsldrclss002.cpp index 65116a118a3..f389a9d56e1 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoaderClasses/clsldrclss002/clsldrclss002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassLoaderClasses/clsldrclss002/clsldrclss002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -35,9 +35,9 @@ extern "C" { static jlong timeout = 0; /* test objects */ -static jobject testedClassLoader = NULL; -static jclass testedClass = NULL; -static jfieldID testedFieldID = NULL; +static jobject testedClassLoader = nullptr; +static jclass testedClass = nullptr; +static jfieldID testedFieldID = nullptr; static const char* CLASS_SIG = "Lnsk/jvmti/GetClassLoaderClasses/clsldrclss002;"; @@ -58,15 +58,15 @@ static int prepare(JNIEnv* jni) { NSK_DISPLAY0("Obtain tested object from a static field of debugee class\n"); NSK_DISPLAY1("Find class: %s\n", CLASS_NAME); - if (!NSK_JNI_VERIFY(jni, (testedClass = jni->FindClass(CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (testedClass = jni->FindClass(CLASS_NAME)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (testedClass = (jclass) jni->NewGlobalRef(testedClass)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (testedClass = (jclass) jni->NewGlobalRef(testedClass)) != nullptr)) return NSK_FALSE; NSK_DISPLAY2("Find field: %s:%s\n", FIELD_NAME, FIELD_SIGNATURE); if (!NSK_JNI_VERIFY(jni, (testedFieldID = - jni->GetStaticFieldID(testedClass, FIELD_NAME, FIELD_SIGNATURE)) != NULL)) + jni->GetStaticFieldID(testedClass, FIELD_NAME, FIELD_SIGNATURE)) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -82,15 +82,15 @@ static int lookup(jvmtiEnv* jvmti, if (!NSK_JVMTI_VERIFY(jvmti->GetClassSignature(classes[i], &signature, &generic))) break; - if (signature != NULL && strcmp(signature, exp_sig) == 0) { + if (signature != nullptr && strcmp(signature, exp_sig) == 0) { NSK_DISPLAY1("Expected class found: %s\n", exp_sig); found = NSK_TRUE; } - if (signature != NULL) + if (signature != nullptr) jvmti->Deallocate((unsigned char*)signature); - if (generic != NULL) + if (generic != nullptr) jvmti->Deallocate((unsigned char*)generic); } @@ -115,7 +115,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY0("Testcase #1: check on default classloader\n"); if (!NSK_JNI_VERIFY(jni, (testedClassLoader = - jni->GetStaticObjectField(testedClass, testedFieldID)) != NULL)) { + jni->GetStaticObjectField(testedClass, testedFieldID)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -127,7 +127,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { nsk_jvmti_setFailStatus(); return; } - if (!NSK_VERIFY(classes != NULL)) { + if (!NSK_VERIFY(classes != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -136,7 +136,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { nsk_jvmti_setFailStatus(); return; } - if (classes != NULL) + if (classes != nullptr) jvmti->Deallocate((unsigned char*)classes); if (!nsk_jvmti_resumeSync()) @@ -146,7 +146,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY0("Testcase #2: check on custom classloader\n"); if (!NSK_JNI_VERIFY(jni, (testedClassLoader = - jni->GetStaticObjectField(testedClass, testedFieldID)) != NULL)) { + jni->GetStaticObjectField(testedClass, testedFieldID)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -158,7 +158,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { nsk_jvmti_setFailStatus(); return; } - if (!NSK_VERIFY(classes != NULL)) { + if (!NSK_VERIFY(classes != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -174,7 +174,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_COMPLAIN1("Cannot find class in the list: %s\n", CLASS_SIG_E); nsk_jvmti_setFailStatus(); } - if (classes != NULL) + if (classes != nullptr) jvmti->Deallocate((unsigned char*)classes); NSK_TRACE(jni->DeleteGlobalRef(testedClass)); @@ -198,7 +198,7 @@ JNIEXPORT jint JNI_OnLoad_clsldrclss002(JavaVM *jvm, char *options, void *reserv } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; NSK_DISPLAY0("Agent_OnLoad\n"); @@ -208,10 +208,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassMethods/getclmthd005/getclmthd005.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassMethods/getclmthd005/getclmthd005.cpp index ec8da62bb60..5a39a2bf549 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassMethods/getclmthd005/getclmthd005.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassMethods/getclmthd005/getclmthd005.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_getclmthd005(JavaVM *jvm, char *options, void *reserve jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -70,7 +70,7 @@ Java_nsk_jvmti_GetClassMethods_getclmthd005_check(JNIEnv *env, jclass cls) { jint mcount; jmethodID *methods; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -78,7 +78,7 @@ Java_nsk_jvmti_GetClassMethods_getclmthd005_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> invalid class check ...\n"); } - err = jvmti->GetClassMethods(NULL, &mcount, &methods); + err = jvmti->GetClassMethods(nullptr, &mcount, &methods); if (err != JVMTI_ERROR_INVALID_CLASS) { printf("Error expected: JVMTI_ERROR_INVALID_CLASS,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -88,7 +88,7 @@ Java_nsk_jvmti_GetClassMethods_getclmthd005_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> (methodCountPtr) null pointer check ...\n"); } - err = jvmti->GetClassMethods(cls, NULL, &methods); + err = jvmti->GetClassMethods(cls, nullptr, &methods); if (err != JVMTI_ERROR_NULL_POINTER) { printf("(methodCountPtr) error expected: JVMTI_ERROR_NULL_POINTER,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -98,7 +98,7 @@ Java_nsk_jvmti_GetClassMethods_getclmthd005_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> (methodsPtr) null pointer check ...\n"); } - err = jvmti->GetClassMethods(cls, &mcount, NULL); + err = jvmti->GetClassMethods(cls, &mcount, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { printf("(methodsPtr) error expected: JVMTI_ERROR_NULL_POINTER,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassMethods/getclmthd006/getclmthd006.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassMethods/getclmthd006/getclmthd006.cpp index 03d1152454c..3435c915a48 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassMethods/getclmthd006/getclmthd006.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassMethods/getclmthd006/getclmthd006.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_getclmthd006(JavaVM *jvm, char *options, void *reserve jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -70,7 +70,7 @@ Java_nsk_jvmti_GetClassMethods_getclmthd006_check(JNIEnv *env, jclass cls, jint jint mcount; jmethodID *methods; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassMethods/getclmthd007/getclmthd007.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassMethods/getclmthd007/getclmthd007.cpp index 031f11d03ed..e5e75b5d9b1 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassMethods/getclmthd007/getclmthd007.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassMethods/getclmthd007/getclmthd007.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ typedef struct { meth_info *meths; } class_info; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -124,12 +124,12 @@ JNIEXPORT jint JNI_OnLoad_getclmthd007(JavaVM *jvm, char *options, void *reserve jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -147,7 +147,7 @@ Java_nsk_jvmti_GetClassMethods_getclmthd007_check(JNIEnv *env, int j, k; int failed = JNI_FALSE; // enable debugging on failure - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; @@ -173,7 +173,7 @@ Java_nsk_jvmti_GetClassMethods_getclmthd007_check(JNIEnv *env, printf(">>> %s:\n", classes[i].name); } for (k = 0; k < mcount; k++) { - if (methods[k] == NULL) { + if (methods[k] == nullptr) { printf("(%d:%d) methodID = null\n", i, k); result = STATUS_FAILED; } else if (printdump == JNI_TRUE || failed == JNI_TRUE) { @@ -187,7 +187,7 @@ Java_nsk_jvmti_GetClassMethods_getclmthd007_check(JNIEnv *env, for (j = 0; j < classes[i].mcount; j++) { /* search the returned table for each expected entry */ for (k = 0; k < mcount; k++) { - if (methods[k] != NULL) { + if (methods[k] != nullptr) { err = jvmti->GetMethodName(methods[k], &name, &sig, &generic); if (err != JVMTI_ERROR_NONE) { @@ -195,7 +195,7 @@ Java_nsk_jvmti_GetClassMethods_getclmthd007_check(JNIEnv *env, i, k, TranslateError(err), err); result = STATUS_FAILED; } else { - if (name != NULL && sig != NULL && + if (name != nullptr && sig != nullptr && strcmp(name, classes[i].meths[j].name) == 0 && strcmp(sig, classes[i].meths[j].sig) == 0) break; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassModifiers/getclmdf004/getclmdf004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassModifiers/getclmdf004/getclmdf004.cpp index da09f1c5f2c..f929d466d9c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassModifiers/getclmdf004/getclmdf004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassModifiers/getclmdf004/getclmdf004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_getclmdf004(JavaVM *jvm, char *options, void *reserved jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -69,7 +69,7 @@ Java_nsk_jvmti_GetClassModifiers_getclmdf004_check(JNIEnv *env, jclass cls) { jvmtiError err; jint modifiers; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -77,7 +77,7 @@ Java_nsk_jvmti_GetClassModifiers_getclmdf004_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> invalid class check ...\n"); } - err = jvmti->GetClassModifiers(NULL, &modifiers); + err = jvmti->GetClassModifiers(nullptr, &modifiers); if (err != JVMTI_ERROR_INVALID_CLASS) { printf("Error expected: JVMTI_ERROR_INVALID_CLASS,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -87,7 +87,7 @@ Java_nsk_jvmti_GetClassModifiers_getclmdf004_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> null pointer check ...\n"); } - err = jvmti->GetClassModifiers(cls, NULL); + err = jvmti->GetClassModifiers(cls, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { printf("Error expected: JVMTI_ERROR_NULL_POINTER,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassModifiers/getclmdf005/getclmdf005.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassModifiers/getclmdf005/getclmdf005.cpp index 7a83d1dbd72..8cdaff36314 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassModifiers/getclmdf005/getclmdf005.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassModifiers/getclmdf005/getclmdf005.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ extern "C" { #define ACC_FINAL 0x0010 #define ACC_INTERFACE 0x0200 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -57,12 +57,12 @@ JNIEXPORT jint JNI_OnLoad_getclmdf005(JavaVM *jvm, char *options, void *reserved jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -75,7 +75,7 @@ Java_nsk_jvmti_GetClassModifiers_getclmdf005_check(JNIEnv *env, jclass cls, jint jvmtiError err; jint modifiers; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassModifiers/getclmdf006/getclmdf006.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassModifiers/getclmdf006/getclmdf006.cpp index d13e51d5a5d..14d7a0b2e29 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassModifiers/getclmdf006/getclmdf006.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassModifiers/getclmdf006/getclmdf006.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ extern "C" { #define ACC_INTERFACE 0x0200 #define ACC_ABSTRACT 0x0400 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -60,12 +60,12 @@ JNIEXPORT jint JNI_OnLoad_getclmdf006(JavaVM *jvm, char *options, void *reserved jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -90,7 +90,7 @@ Java_nsk_jvmti_GetClassModifiers_getclmdf006_check(JNIEnv *env, jclass cls, jcla jvmtiError err; jint modifiers; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassModifiers/getclmdf007/getclmdf007.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassModifiers/getclmdf007/getclmdf007.cpp index f6742e15cd7..5315c795dba 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassModifiers/getclmdf007/getclmdf007.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassModifiers/getclmdf007/getclmdf007.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ extern "C" { #define ACC_INTERFACE 0x0200 #define ACC_ABSTRACT 0x0400 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -60,12 +60,12 @@ JNIEXPORT jint JNI_OnLoad_getclmdf007(JavaVM *jvm, char *options, void *reserved jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -91,7 +91,7 @@ Java_nsk_jvmti_GetClassModifiers_getclmdf007_check(JNIEnv *env, jclass cls, jint jint ArrayModifiers; jint ComponentModifiers; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassSignature/getclsig004/getclsig004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassSignature/getclsig004/getclsig004.cpp index 782a331729b..d01bf625873 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassSignature/getclsig004/getclsig004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassSignature/getclsig004/getclsig004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; static const char *sigs[] = { @@ -63,12 +63,12 @@ JNIEXPORT jint JNI_OnLoad_getclsig004(JavaVM *jvm, char *options, void *reserved jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -82,7 +82,7 @@ Java_nsk_jvmti_GetClassSignature_getclsig004_check(JNIEnv *env, jvmtiError err; char *sig, *generic; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassSignature/getclsig005/getclsig005.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassSignature/getclsig005/getclsig005.cpp index 149ab655a72..919bd50b940 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassSignature/getclsig005/getclsig005.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassSignature/getclsig005/getclsig005.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ extern "C" { #define STATUS_FAILED 2 #define CLASS_SIGNATURE "Lnsk/jvmti/GetClassSignature/getclsig005;" -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -52,12 +52,12 @@ JNIEXPORT jint JNI_OnLoad_getclsig005(JavaVM *jvm, char *options, void *reserved jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -70,7 +70,7 @@ Java_nsk_jvmti_GetClassSignature_getclsig005_check(JNIEnv *env, jclass cls) { jvmtiError err; char *sig, *generic; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -78,7 +78,7 @@ Java_nsk_jvmti_GetClassSignature_getclsig005_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> invalid class check ...\n"); } - err = jvmti->GetClassSignature(NULL, &sig, &generic); + err = jvmti->GetClassSignature(nullptr, &sig, &generic); if (err != JVMTI_ERROR_INVALID_CLASS) { printf("Error expected: JVMTI_ERROR_INVALID_CLASS,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -88,7 +88,7 @@ Java_nsk_jvmti_GetClassSignature_getclsig005_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> (signature_ptr) null pointer check ...\n"); } - err = jvmti->GetClassSignature(cls, NULL, &generic); + err = jvmti->GetClassSignature(cls, nullptr, &generic); if (err != JVMTI_ERROR_NONE) { printf("(signature_ptr) unexpected error: %s (%d)\n", TranslateError(err), err); @@ -102,7 +102,7 @@ Java_nsk_jvmti_GetClassSignature_getclsig005_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> (generic_ptr) null pointer check ...\n"); } - err = jvmti->GetClassSignature(cls, &sig, NULL); + err = jvmti->GetClassSignature(cls, &sig, nullptr); if (err != JVMTI_ERROR_NONE) { printf("(generic_ptr) unexpected error: %s (%d)\n", TranslateError(err), err); @@ -111,7 +111,7 @@ Java_nsk_jvmti_GetClassSignature_getclsig005_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> sig = \"%s\"\n", sig); } - if (sig == NULL || strcmp(sig, CLASS_SIGNATURE) != 0) { + if (sig == nullptr || strcmp(sig, CLASS_SIGNATURE) != 0) { printf("Wrong class sig: \"%s\", expected: \"%s\"\n", CLASS_SIGNATURE, sig); result = STATUS_FAILED; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassSignature/getclsig006/getclsig006.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassSignature/getclsig006/getclsig006.cpp index acd3ed52578..56b79a1cdf1 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassSignature/getclsig006/getclsig006.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassSignature/getclsig006/getclsig006.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -40,7 +40,7 @@ extern "C" { /* expected class signatures are below */ static const char *class_sig[][CLS_NUM] = { - { "getclsig006", "Lnsk/jvmti/GetClassSignature/getclsig006;", "NULL" }, + { "getclsig006", "Lnsk/jvmti/GetClassSignature/getclsig006;", "null" }, { "getclsig006b", "Lnsk/jvmti/GetClassSignature/getclsig006b;", "Ljava/lang/Object;" }, { "getclsig006c", "Lnsk/jvmti/GetClassSignature/getclsig006c;", @@ -51,7 +51,7 @@ static const char *class_sig[][CLS_NUM] = { "Ljava/lang/Object;" } }; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static int checkSig(JNIEnv *jni_env, jclass testedCls, int idx) { int totRes = PASSED; @@ -67,7 +67,7 @@ static int checkSig(JNIEnv *jni_env, jclass testedCls, int idx) { class_sig[idx][0]); if (strcmp(class_sig[idx][1], sign) != 0 || - strcmp(class_sig[idx][2], (gen_sign == NULL) ? "NULL" : gen_sign) != 0) { + strcmp(class_sig[idx][2], (gen_sign == nullptr) ? "null" : gen_sign) != 0) { NSK_COMPLAIN5( "TEST FAILED: class: \"%s\" has\n" "\tsignature: \"%s\"\n" @@ -75,19 +75,19 @@ static int checkSig(JNIEnv *jni_env, jclass testedCls, int idx) { "\tExpected: \"%s\"\n" "\t\"%s\"\n\n", class_sig[idx][0], - sign, (gen_sign == NULL) ? "NULL" : gen_sign, + sign, (gen_sign == nullptr) ? "null" : gen_sign, class_sig[idx][1], class_sig[idx][2]); totRes = STATUS_FAILED; } else NSK_DISPLAY2("CHECK PASSED: signature: \"%s\",\n\tgeneric signature: \"%s\"\n", - sign, (gen_sign == NULL) ? "NULL" : gen_sign); + sign, (gen_sign == nullptr) ? "null" : gen_sign); NSK_DISPLAY0("Deallocating the signature array\n"); if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*) sign))) { totRes = STATUS_FAILED; } - if (gen_sign != NULL) + if (gen_sign != nullptr) if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*) gen_sign))) { totRes = STATUS_FAILED; } @@ -105,7 +105,7 @@ Java_nsk_jvmti_GetClassSignature_getclsig006_check( jclass testedCls; for (i=0; iFindClass(class_sig[i][1])) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (testedCls = jni->FindClass(class_sig[i][1])) != nullptr)) { NSK_COMPLAIN1("TEST FAILURE: unable to find class \"%s\"\n\n", class_sig[i][0]); res = STATUS_FAILED; @@ -137,7 +137,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassStatus/getclstat005/getclstat005.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassStatus/getclstat005/getclstat005.cpp index f348991f670..7bc57e7082b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassStatus/getclstat005/getclstat005.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassStatus/getclstat005/getclstat005.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_getclstat005(JavaVM *jvm, char *options, void *reserve jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -69,7 +69,7 @@ Java_nsk_jvmti_GetClassStatus_getclstat005_check(JNIEnv *env, jclass cls) { jvmtiError err; jint status; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -77,7 +77,7 @@ Java_nsk_jvmti_GetClassStatus_getclstat005_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> invalid class check ...\n"); } - err = jvmti->GetClassStatus(NULL, &status); + err = jvmti->GetClassStatus(nullptr, &status); if (err != JVMTI_ERROR_INVALID_CLASS) { printf("Error expected: JVMTI_ERROR_INVALID_CLASS,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -87,7 +87,7 @@ Java_nsk_jvmti_GetClassStatus_getclstat005_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> null pointer check ...\n"); } - err = jvmti->GetClassStatus(cls, NULL); + err = jvmti->GetClassStatus(cls, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { printf("Error expected: JVMTI_ERROR_NULL_POINTER,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassStatus/getclstat006/getclstat006.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassStatus/getclstat006/getclstat006.cpp index 8f8a5d38820..72fb949f9b0 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassStatus/getclstat006/getclstat006.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassStatus/getclstat006/getclstat006.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ typedef struct { const char *name; } bit_info; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; static bit_info bits[] = { @@ -60,12 +60,12 @@ JNIEXPORT jint JNI_OnLoad_getclstat006(JavaVM *jvm, char *options, void *reserve jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -78,7 +78,7 @@ Java_nsk_jvmti_GetClassStatus_getclstat006_check(JNIEnv *env, jclass cls, jint i jvmtiError err; jint status; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassStatus/getclstat007/getclstat007.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassStatus/getclstat007/getclstat007.cpp index ed1ce5ace77..4daaed64594 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassStatus/getclstat007/getclstat007.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassStatus/getclstat007/getclstat007.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_getclstat007(JavaVM *jvm, char *options, void *reserve jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -70,7 +70,7 @@ Java_nsk_jvmti_GetClassStatus_getclstat007_check(JNIEnv *env, jclass cls, jvmtiError err; jint status; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCurrentThreadCpuTime/curthrcputime001/curthrcputime001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCurrentThreadCpuTime/curthrcputime001/curthrcputime001.cpp index 3e7fcdd1b17..b883c0b682f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCurrentThreadCpuTime/curthrcputime001/curthrcputime001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCurrentThreadCpuTime/curthrcputime001/curthrcputime001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -80,7 +80,7 @@ static int checkCpuTime(jvmtiEnv* jvmti, jthread thread, julong* time, where, julong_to_string(*time, buf)); } - if (prevTime != NULL) { + if (prevTime != nullptr) { julong diff = *time - *prevTime; NSK_DISPLAY1("Compare with previous time: %s\n", @@ -147,7 +147,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY0(">>> Testcase #2: Check initial cpu time in agent thread\n"); { - if (!checkCpuTime(jvmti, testAgentThread, &prevAgentThreadTime, NULL, "agent thread")) { + if (!checkCpuTime(jvmti, testAgentThread, &prevAgentThreadTime, nullptr, "agent thread")) { nsk_jvmti_setFailStatus(); } } @@ -157,7 +157,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { runIterations(iterations); NSK_DISPLAY1("Enable thread events: %d events\n", THREAD_EVENTS_COUNT); - if (nsk_jvmti_enableEvents(JVMTI_ENABLE, THREAD_EVENTS_COUNT, threadEvents, NULL)) { + if (nsk_jvmti_enableEvents(JVMTI_ENABLE, THREAD_EVENTS_COUNT, threadEvents, nullptr)) { NSK_DISPLAY0(" ... enabled\n"); } @@ -184,7 +184,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { return; NSK_DISPLAY1("Disable thread events: %d events\n", THREAD_EVENTS_COUNT); - if (nsk_jvmti_enableEvents(JVMTI_DISABLE, THREAD_EVENTS_COUNT, threadEvents, NULL)) { + if (nsk_jvmti_enableEvents(JVMTI_DISABLE, THREAD_EVENTS_COUNT, threadEvents, nullptr)) { NSK_DISPLAY0(" ... disabled\n"); } } @@ -214,7 +214,7 @@ callbackVMInit(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { NSK_DISPLAY0(">>> Testcase #1: Check initial cpu time in VM_INIT callback\n"); { julong time = 0; - if (!checkCpuTime(jvmti, thread, &time, NULL, "VM_INIT callback")) { + if (!checkCpuTime(jvmti, thread, &time, nullptr, "VM_INIT callback")) { nsk_jvmti_setFailStatus(); } } @@ -230,14 +230,14 @@ callbackVMDeath(jvmtiEnv* jvmti, JNIEnv* jni) { NSK_DISPLAY0(">>> Testcase #7: Check initial cpu time in VM_DEATH callback\n"); { julong time = 0; - if (!checkCpuTime(jvmti, NULL, &time, NULL, "VM_DEATH callback")) { + if (!checkCpuTime(jvmti, nullptr, &time, nullptr, "VM_DEATH callback")) { success = NSK_FALSE; nsk_jvmti_setFailStatus(); } } NSK_DISPLAY1("Disable events: %d events\n", EVENTS_COUNT); - if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, NULL)) { + if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, nullptr)) { success = NSK_FALSE; } else { NSK_DISPLAY0(" ... disabled\n"); @@ -266,9 +266,9 @@ callbackThreadStart(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { NSK_DISPLAY1(" for thread: %s\n", nsk_null_string(threadInfo.name)); } - if (threadInfo.name != NULL && strcmp(threadInfo.name, TESTED_THREAD_NAME) == 0) { + if (threadInfo.name != nullptr && strcmp(threadInfo.name, TESTED_THREAD_NAME) == 0) { NSK_DISPLAY0(">>> Testcase #3: Check initial cpu time in THREAD_START callback\n"); - if (!checkCpuTime(jvmti, thread, &prevTestedThreadTime, NULL, "THREAD_START callback")) { + if (!checkCpuTime(jvmti, thread, &prevTestedThreadTime, nullptr, "THREAD_START callback")) { nsk_jvmti_setFailStatus(); } } @@ -289,7 +289,7 @@ callbackThreadEnd(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { NSK_DISPLAY1(" for thread: %s\n", nsk_null_string(threadInfo.name)); } - if (threadInfo.name != NULL && strcmp(threadInfo.name, TESTED_THREAD_NAME) == 0) { + if (threadInfo.name != nullptr && strcmp(threadInfo.name, TESTED_THREAD_NAME) == 0) { julong time = 0; NSK_DISPLAY0(">>> Testcase #5: Check final cpu time in THREAD_END callback\n"); if (!checkCpuTime(jvmti, thread, &time, &prevTestedThreadTime, "THREAD_END callback")) { @@ -313,7 +313,7 @@ JNIEXPORT jint JNI_OnLoad_curthrcputime001(JavaVM *jvm, char *options, void *res } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -325,7 +325,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; NSK_DISPLAY1("Add required capability: %s\n", "can_get_current_thread_cpu_time"); @@ -355,11 +355,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } NSK_DISPLAY0(" ... callbacks set\n"); - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; NSK_DISPLAY1("Enable events: %d events\n", EVENTS_COUNT); - if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, NULL)) { + if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, nullptr)) { NSK_DISPLAY0(" ... enabled\n"); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCurrentThreadCpuTimerInfo/curthrtimerinfo001/curthrtimerinfo001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCurrentThreadCpuTimerInfo/curthrtimerinfo001/curthrtimerinfo001.cpp index cf22a491b08..2efa96fb584 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCurrentThreadCpuTimerInfo/curthrtimerinfo001/curthrtimerinfo001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetCurrentThreadCpuTimerInfo/curthrtimerinfo001/curthrtimerinfo001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -76,7 +76,7 @@ static int checkTimerInfo(jvmtiEnv* jvmti, jvmtiTimerInfo* info, NSK_DISPLAY1(" may_skip_forward: %d\n", (int)info->may_skip_forward); NSK_DISPLAY1(" may_skip_backward: %d\n", (int)info->may_skip_backward); - if (initInfo != NULL) { + if (initInfo != nullptr) { NSK_DISPLAY0("Compare with initial timer info\n"); if (info->max_value != initInfo->max_value) { NSK_COMPLAIN4("In %s GetCurrentThreadCpuTimerInfo() returned different info:\n" @@ -132,7 +132,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY0(">>> Testcases #3,4: Check timer info in thread events\n"); { NSK_DISPLAY1("Enable thread events: %d events\n", THREAD_EVENTS_COUNT); - if (nsk_jvmti_enableEvents(JVMTI_ENABLE, THREAD_EVENTS_COUNT, threadEvents, NULL)) { + if (nsk_jvmti_enableEvents(JVMTI_ENABLE, THREAD_EVENTS_COUNT, threadEvents, nullptr)) { NSK_DISPLAY0(" ... enabled\n"); } @@ -143,7 +143,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { return; NSK_DISPLAY1("Disable thread events: %d events\n", THREAD_EVENTS_COUNT); - if (nsk_jvmti_enableEvents(JVMTI_DISABLE, THREAD_EVENTS_COUNT, threadEvents, NULL)) { + if (nsk_jvmti_enableEvents(JVMTI_DISABLE, THREAD_EVENTS_COUNT, threadEvents, nullptr)) { NSK_DISPLAY0(" ... disabled\n"); } } @@ -163,7 +163,7 @@ callbackVMInit(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { NSK_DISPLAY0(">>> Testcase #1: Check initial timer info in VM_INIT callback\n"); { - if (!checkTimerInfo(jvmti, &initInfo, NULL, "VM_INIT callback")) { + if (!checkTimerInfo(jvmti, &initInfo, nullptr, "VM_INIT callback")) { nsk_jvmti_setFailStatus(); } } @@ -183,7 +183,7 @@ callbackVMDeath(jvmtiEnv* jvmti, JNIEnv* jni) { } NSK_DISPLAY1("Disable events: %d events\n", EVENTS_COUNT); - if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, NULL)) { + if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, nullptr)) { success = NSK_FALSE; } else { NSK_DISPLAY0(" ... disabled\n"); @@ -242,7 +242,7 @@ JNIEXPORT jint JNI_OnLoad_curthrtimerinfo001(JavaVM *jvm, char *options, void *r } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -250,7 +250,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; NSK_DISPLAY1("Add required capability: %s\n", "can_get_current_thread_cpu_time"); @@ -282,11 +282,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } NSK_DISPLAY0(" ... callbacks set\n"); - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; NSK_DISPLAY1("Enable events: %d events\n", EVENTS_COUNT); - if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, NULL)) { + if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, nullptr)) { NSK_DISPLAY0(" ... enabled\n"); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetEnv/GetEnv001/GetEnv001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetEnv/GetEnv001/GetEnv001.cpp index 0a6ba80bf70..3959c846492 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetEnv/GetEnv001/GetEnv001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetEnv/GetEnv001/GetEnv001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -87,7 +87,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) return JNI_ERR; } - if (vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1) != JNI_OK || jvmti == NULL) { + if (vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1) != JNI_OK || jvmti == nullptr) { NSK_COMPLAIN0("JVMTI_VERSION_1_1 isn't supported."); return JNI_OK; } @@ -109,7 +109,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) return JNI_ERR; // Enable class retransformation - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetEnvironmentLocalStorage/getenvstor001/getenvstor001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetEnvironmentLocalStorage/getenvstor001/getenvstor001.cpp index c196ea89f1d..34b26debe67 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetEnvironmentLocalStorage/getenvstor001/getenvstor001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetEnvironmentLocalStorage/getenvstor001/getenvstor001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -50,7 +50,7 @@ static jvmtiEvent events[EVENTS_COUNT] = { * @returns NSK_FALSE if any error occured. */ static int checkEnvStorage(jvmtiEnv* jvmti, const char where[]) { - void* storage = NULL; + void* storage = nullptr; NSK_DISPLAY0("GetEnvironmentLocalStorage() for current JVMTI env\n"); if (!NSK_JVMTI_VERIFY(jvmti->GetEnvironmentLocalStorage(&storage))) { @@ -58,8 +58,8 @@ static int checkEnvStorage(jvmtiEnv* jvmti, const char where[]) { } NSK_DISPLAY1(" ... got storage: 0x%p\n", (void*)storage); - if (storage != NULL) { - NSK_COMPLAIN2("GetEnvironmentLocalStorage() returned NOT NULL storage in %s:\n" + if (storage != nullptr) { + NSK_COMPLAIN2("GetEnvironmentLocalStorage() returned NOT null storage in %s:\n" "# storage pointer: 0x%p\n", where, (void*)storage); return NSK_FALSE; @@ -113,7 +113,7 @@ callbackVMDeath(jvmtiEnv* jvmti, JNIEnv* jni) { success = checkEnvStorage(jvmti, "VM_DEATH callback"); NSK_DISPLAY1("Disable events: %d events\n", EVENTS_COUNT); - if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, NULL)) { + if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, nullptr)) { success = NSK_FALSE; } else { NSK_DISPLAY0(" ... disabled\n"); @@ -140,7 +140,7 @@ JNIEXPORT jint JNI_OnLoad_getenvstor001(JavaVM *jvm, char *options, void *reserv } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -148,7 +148,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; { @@ -163,7 +163,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; NSK_DISPLAY0(">>> Testcase #1: Check env storage in JVM_OnLoad()\n"); @@ -172,7 +172,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } NSK_DISPLAY1("Enable events: %d events\n", EVENTS_COUNT); - if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, NULL)) { + if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, nullptr)) { NSK_DISPLAY0(" ... enabled\n"); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetErrorName/geterrname001/geterrname001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetErrorName/geterrname001/geterrname001.cpp index cc0aa8ba792..6f8bcb17b3a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetErrorName/geterrname001/geterrname001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetErrorName/geterrname001/geterrname001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -253,7 +253,7 @@ JNIEXPORT jint JNI_OnLoad_geterrname001(JavaVM *jvm, char *options, void *reserv } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv *jvmti = NULL; + jvmtiEnv *jvmti = nullptr; jvmtiEventCallbacks callbacks; /* init framework and parse options */ @@ -265,7 +265,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* Create data access lock */ @@ -290,16 +290,16 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* enable VMInit event */ if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL))) + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, nullptr))) return JNI_ERR; /* enable ClassFileLoadHook event */ if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL))) + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, nullptr))) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetErrorName/geterrname002/geterrname002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetErrorName/geterrname002/geterrname002.cpp index 05937d62892..9dcf87e7be1 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetErrorName/geterrname002/geterrname002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetErrorName/geterrname002/geterrname002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ agentProc(jvmtiEnv *jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY0("Testcase #2: check on JVMTI_ERROR_NULL_POINTER\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_NULL_POINTER, - jvmti->GetErrorName(JVMTI_ERROR_NONE, NULL))) + jvmti->GetErrorName(JVMTI_ERROR_NONE, nullptr))) nsk_jvmti_setFailStatus(); /* resume debugee after last sync */ @@ -76,7 +76,7 @@ JNIEXPORT jint JNI_OnLoad_geterrname002(JavaVM *jvm, char *options, void *reserv } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv *jvmti = NULL; + jvmtiEnv *jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -89,11 +89,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetExtensionEvents/extevents001/extevents001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetExtensionEvents/extevents001/extevents001.cpp index 24edbbbd494..bdc033f35cb 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetExtensionEvents/extevents001/extevents001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetExtensionEvents/extevents001/extevents001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -50,7 +50,7 @@ static jlong timeout = 0; static int checkExtensions(jvmtiEnv* jvmti, const char phase[]) { int success = NSK_TRUE; jint extCount = 0; - jvmtiExtensionEventInfo* extList = NULL; + jvmtiExtensionEventInfo* extList = nullptr; int i; NSK_DISPLAY0("Get extension events list\n"); @@ -61,8 +61,8 @@ static int checkExtensions(jvmtiEnv* jvmti, const char phase[]) { NSK_DISPLAY1(" ... got list: 0x%p\n", (void*)extList); if (extCount > 0) { - if (extList == NULL) { - NSK_COMPLAIN3("In %s phase GetExtensionEvents() returned NULL pointer:\n" + if (extList == nullptr) { + NSK_COMPLAIN3("In %s phase GetExtensionEvents() returned null pointer:\n" "# extensions pointer: 0x%p\n" "# extensions count: %d\n", phase, (void*)extList, (int)extCount); @@ -80,7 +80,7 @@ static int checkExtensions(jvmtiEnv* jvmti, const char phase[]) { NSK_DISPLAY1(" param_count: %d\n", (int)extList[i].param_count); NSK_DISPLAY1(" params: 0x%p\n", (void*)extList[i].params); - if (extList[i].params != NULL) { + if (extList[i].params != nullptr) { for (j = 0; j < extList[i].param_count; j++) { NSK_DISPLAY1(" param #%d:\n", j); NSK_DISPLAY1(" name: \"%s\"\n", @@ -94,10 +94,10 @@ static int checkExtensions(jvmtiEnv* jvmti, const char phase[]) { } } - if (extList[i].id == NULL - || extList[i].short_description == NULL - || (extList[i].params == NULL && extList[i].param_count > 0)) { - NSK_COMPLAIN9("In %s phase GetExtensionEvents() returned event #%d with NULL attribute(s):\n" + if (extList[i].id == nullptr + || extList[i].short_description == nullptr + || (extList[i].params == nullptr && extList[i].param_count > 0)) { + NSK_COMPLAIN9("In %s phase GetExtensionEvents() returned event #%d with null attribute(s):\n" "# event_index: %d\n" "# id: 0x%p (%s)\n" "# short_desc: 0x%p (%s)\n" @@ -111,7 +111,7 @@ static int checkExtensions(jvmtiEnv* jvmti, const char phase[]) { success = NSK_FALSE; } - if (extList[i].id != NULL && strlen(extList[i].id) <= 0) { + if (extList[i].id != nullptr && strlen(extList[i].id) <= 0) { NSK_COMPLAIN6("In %s phase GetExtensionEvents() returned event #%d with empty id:\n" "# event_index: %d\n" "# id: \"%s\"\n" @@ -123,7 +123,7 @@ static int checkExtensions(jvmtiEnv* jvmti, const char phase[]) { nsk_null_string(extList[i].short_description), (int)extList[i].param_count); success = NSK_FALSE; - } else if (strstr(extList[i].id, NAME_PREFIX) == NULL) { + } else if (strstr(extList[i].id, NAME_PREFIX) == nullptr) { NSK_COMPLAIN6("In %s phase GetExtensionEvents() returned event #%d with unexpected id:\n" "# event_index: %d\n" "# id: \"%s\"\n" @@ -137,7 +137,7 @@ static int checkExtensions(jvmtiEnv* jvmti, const char phase[]) { success = NSK_FALSE; } - if (extList[i].short_description != NULL && strlen(extList[i].short_description) <= 0) { + if (extList[i].short_description != nullptr && strlen(extList[i].short_description) <= 0) { NSK_COMPLAIN6("In %s phase GetExtensionEvents() returned event #%d with empty desc:\n" "# event_index: %d\n" "# id: \"%s\"\n" @@ -151,9 +151,9 @@ static int checkExtensions(jvmtiEnv* jvmti, const char phase[]) { success = NSK_FALSE; } - if (extList[i].param_count > 0 && extList[i].params != NULL) { + if (extList[i].param_count > 0 && extList[i].params != nullptr) { for (j = 0; j < extList[i].param_count; j++) { - if (extList[i].params[j].name == NULL + if (extList[i].params[j].name == nullptr || strlen(extList[i].params[j].name) <= 0) { NSK_COMPLAIN9("In %s phase GetExtensionEvents() returned event #%d with empty desc:\n" "# event_index: %d\n" @@ -262,7 +262,7 @@ JNIEXPORT jint JNI_OnLoad_extevents001(JavaVM *jvm, char *options, void *reserve } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -270,7 +270,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; NSK_DISPLAY0(">>> Testcase #1: Check extension events in OnLoad phase\n"); @@ -280,7 +280,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetExtensionFunctions/extfuncs001/extfuncs001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetExtensionFunctions/extfuncs001/extfuncs001.cpp index 60f573c2b71..015313e7b2b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetExtensionFunctions/extfuncs001/extfuncs001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetExtensionFunctions/extfuncs001/extfuncs001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ static jlong timeout = 0; static int checkExtensions(jvmtiEnv* jvmti, const char phase[]) { int success = NSK_TRUE; jint extCount = 0; - jvmtiExtensionFunctionInfo* extList = NULL; + jvmtiExtensionFunctionInfo* extList = nullptr; int i; NSK_DISPLAY0("Get extension functions list\n"); @@ -60,8 +60,8 @@ static int checkExtensions(jvmtiEnv* jvmti, const char phase[]) { NSK_DISPLAY1(" ... got list: 0x%p\n", (void*)extList); if (extCount > 0) { - if (extList == NULL) { - NSK_COMPLAIN3("In %s phase GetExtensionFunctions() returned NULL pointer:\n" + if (extList == nullptr) { + NSK_COMPLAIN3("In %s phase GetExtensionFunctions() returned null pointer:\n" "# extensions pointer: 0x%p\n" "# extensions count: %d\n", phase, (void*)extList, (int)extCount); @@ -79,7 +79,7 @@ static int checkExtensions(jvmtiEnv* jvmti, const char phase[]) { NSK_DISPLAY1(" param_count: %d\n", (int)extList[i].param_count); NSK_DISPLAY1(" params: 0x%p\n", (void*)extList[i].params); - if (extList[i].params != NULL) { + if (extList[i].params != nullptr) { for (j = 0; j < extList[i].param_count; j++) { NSK_DISPLAY1(" param #%d:\n", j); NSK_DISPLAY1(" name: \"%s\"\n", @@ -96,19 +96,19 @@ static int checkExtensions(jvmtiEnv* jvmti, const char phase[]) { NSK_DISPLAY1(" error_count: %d\n", (int)extList[i].error_count); NSK_DISPLAY1(" errors: 0x%p\n", (void*)extList[i].errors); - if (extList[i].errors != NULL) { + if (extList[i].errors != nullptr) { for (j = 0; j < extList[i].error_count; j++) { NSK_DISPLAY2(" error #%d: %d\n", j, (int)extList[i].errors[j]); } } - if (extList[i].func == NULL - || extList[i].id == NULL - || extList[i].short_description == NULL - || (extList[i].params == NULL && extList[i].param_count > 0) - || (extList[i].errors == NULL && extList[i].error_count > 0)) { - NSK_COMPLAIN9("In %s phase GetExtensionFunctions() returned function #%d with NULL attribute(s):\n" + if (extList[i].func == nullptr + || extList[i].id == nullptr + || extList[i].short_description == nullptr + || (extList[i].params == nullptr && extList[i].param_count > 0) + || (extList[i].errors == nullptr && extList[i].error_count > 0)) { + NSK_COMPLAIN9("In %s phase GetExtensionFunctions() returned function #%d with null attribute(s):\n" "# func: 0x%p\n" "# id: 0x%p (%s)\n" "# short_desc: 0x%p (%s)\n" @@ -122,7 +122,7 @@ static int checkExtensions(jvmtiEnv* jvmti, const char phase[]) { success = NSK_FALSE; } - if (extList[i].id != NULL && strlen(extList[i].id) <= 0) { + if (extList[i].id != nullptr && strlen(extList[i].id) <= 0) { NSK_COMPLAIN6("In %s phase GetExtensionFunctions() returned function #%d with empty id:\n" "# func: 0x%p\n" "# id: \"%s\"\n" @@ -134,7 +134,7 @@ static int checkExtensions(jvmtiEnv* jvmti, const char phase[]) { nsk_null_string(extList[i].short_description), (int)extList[i].param_count); success = NSK_FALSE; - } else if (strstr(extList[i].id, NAME_PREFIX) == NULL) { + } else if (strstr(extList[i].id, NAME_PREFIX) == nullptr) { NSK_COMPLAIN6("In %s phase GetExtensionFunctions() returned function #%d with unexpected id:\n" "# func: 0x%p\n" "# id: \"%s\"\n" @@ -148,7 +148,7 @@ static int checkExtensions(jvmtiEnv* jvmti, const char phase[]) { success = NSK_FALSE; } - if (extList[i].short_description != NULL && strlen(extList[i].short_description) <= 0) { + if (extList[i].short_description != nullptr && strlen(extList[i].short_description) <= 0) { NSK_COMPLAIN6("In %s phase GetExtensionFunctions() returned function #%d with empty desc:\n" "# func: 0x%p\n" "# id: \"%s\"\n" @@ -162,9 +162,9 @@ static int checkExtensions(jvmtiEnv* jvmti, const char phase[]) { success = NSK_FALSE; } - if (extList[i].param_count > 0 && extList[i].params != NULL) { + if (extList[i].param_count > 0 && extList[i].params != nullptr) { for (j = 0; j < extList[i].param_count; j++) { - if (extList[i].params[j].name == NULL + if (extList[i].params[j].name == nullptr || strlen(extList[i].params[j].name) <= 0) { NSK_COMPLAIN9("In %s phase GetExtensionFunctions() returned function #%d with empty desc:\n" "# func: 0x%p\n" @@ -273,7 +273,7 @@ JNIEXPORT jint JNI_OnLoad_extfuncs001(JavaVM *jvm, char *options, void *reserved } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -281,7 +281,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; NSK_DISPLAY0(">>> Testcase #1: Check extension functions in OnLoad phase\n"); @@ -291,7 +291,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldDeclaringClass/getfldecl001/getfldecl001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldDeclaringClass/getfldecl001/getfldecl001.cpp index 9c1e9b050c9..695d6758f24 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldDeclaringClass/getfldecl001/getfldecl001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldDeclaringClass/getfldecl001/getfldecl001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; static const char* fields[] = { "x", "y", "z" }; @@ -52,12 +52,12 @@ JNIEXPORT jint JNI_OnLoad_getfldecl001(JavaVM *jvm, char *options, void *reserve jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -73,7 +73,7 @@ Java_nsk_jvmti_GetFieldDeclaringClass_getfldecl001_check(JNIEnv *env, jclass declaringClass; char *sig, *generic; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; @@ -84,7 +84,7 @@ Java_nsk_jvmti_GetFieldDeclaringClass_getfldecl001_check(JNIEnv *env, } else { fid = env->GetFieldID(cls1, fields[i], "I"); } - if (fid == NULL) { + if (fid == nullptr) { printf("(%d) cannot get field ID for %s:\"I\"\n", i, fields[i]); result = STATUS_FAILED; return; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldDeclaringClass/getfldecl002/getfldecl002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldDeclaringClass/getfldecl002/getfldecl002.cpp index 10ba137744c..aac0cbe4d66 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldDeclaringClass/getfldecl002/getfldecl002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldDeclaringClass/getfldecl002/getfldecl002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; static const char* fields[] = { "const1", "fld", "xx" }; @@ -52,12 +52,12 @@ JNIEXPORT jint JNI_OnLoad_getfldecl002(JavaVM *jvm, char *options, void *reserve jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -73,7 +73,7 @@ Java_nsk_jvmti_GetFieldDeclaringClass_getfldecl002_check(JNIEnv *env, jclass declaringClass; char *sig, *generic; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; @@ -84,7 +84,7 @@ Java_nsk_jvmti_GetFieldDeclaringClass_getfldecl002_check(JNIEnv *env, } else { fid = env->GetFieldID(cls1, fields[i], "I"); } - if (fid == NULL) { + if (fid == nullptr) { printf("(%d) cannot get field ID for %s:\"I\"\n", i, fields[i]); result = STATUS_FAILED; return; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldDeclaringClass/getfldecl004/getfldecl004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldDeclaringClass/getfldecl004/getfldecl004.cpp index 1661a4dc28e..66bfdd8ce2f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldDeclaringClass/getfldecl004/getfldecl004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldDeclaringClass/getfldecl004/getfldecl004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ typedef struct { jboolean is_static; } field_info; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; static field_info fields[] = { @@ -71,12 +71,12 @@ JNIEXPORT jint JNI_OnLoad_getfldecl004(JavaVM *jvm, char *options, void *reserve jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -92,7 +92,7 @@ Java_nsk_jvmti_GetFieldDeclaringClass_getfldecl004_check(JNIEnv *env, jclass declaringClass; char *sig, *generic; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; @@ -103,7 +103,7 @@ Java_nsk_jvmti_GetFieldDeclaringClass_getfldecl004_check(JNIEnv *env, } else { fid = env->GetFieldID(cls1, fields[i].name, fields[i].sig); } - if (fid == NULL) { + if (fid == nullptr) { printf("(%d) cannot get field ID for %s:\"%s\"\n", i, fields[i].name, fields[i].sig); result = STATUS_FAILED; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldModifiers/getfldmdf003/getfldmdf003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldModifiers/getfldmdf003/getfldmdf003.cpp index e112f59ab60..f763138923d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldModifiers/getfldmdf003/getfldmdf003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldModifiers/getfldmdf003/getfldmdf003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_getfldmdf003(JavaVM *jvm, char *options, void *reserve jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -70,13 +70,13 @@ Java_nsk_jvmti_GetFieldModifiers_getfldmdf003_check(JNIEnv *env, jclass cls) { jfieldID fid; jint modifiers; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } fid = env->GetFieldID(cls, "fld", "I"); - if (fid == NULL) { + if (fid == nullptr) { printf("Cannot get field ID!\n"); return STATUS_FAILED; } @@ -84,7 +84,7 @@ Java_nsk_jvmti_GetFieldModifiers_getfldmdf003_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> invalid class check ...\n"); } - err = jvmti->GetFieldModifiers(NULL, fid, &modifiers); + err = jvmti->GetFieldModifiers(nullptr, fid, &modifiers); if (err != JVMTI_ERROR_INVALID_CLASS) { printf("Error expected: JVMTI_ERROR_INVALID_CLASS,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -94,7 +94,7 @@ Java_nsk_jvmti_GetFieldModifiers_getfldmdf003_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> invalid field check ...\n"); } - err = jvmti->GetFieldModifiers(cls, NULL, &modifiers); + err = jvmti->GetFieldModifiers(cls, nullptr, &modifiers); if (err != JVMTI_ERROR_INVALID_FIELDID) { printf("Error expected: JVMTI_ERROR_INVALID_FIELDID,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -104,7 +104,7 @@ Java_nsk_jvmti_GetFieldModifiers_getfldmdf003_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> null pointer check ...\n"); } - err = jvmti->GetFieldModifiers(cls, fid, NULL); + err = jvmti->GetFieldModifiers(cls, fid, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { printf("(namePtr) error expected: JVMTI_ERROR_NULL_POINTER,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldModifiers/getfldmdf004/getfldmdf004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldModifiers/getfldmdf004/getfldmdf004.cpp index ab10f30398e..72fc33280e5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldModifiers/getfldmdf004/getfldmdf004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldModifiers/getfldmdf004/getfldmdf004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ typedef struct { jboolean is_static; } field_info; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; static field_info fields[] = { @@ -120,12 +120,12 @@ JNIEXPORT jint JNI_OnLoad_getfldmdf004(JavaVM *jvm, char *options, void *reserve jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -155,7 +155,7 @@ Java_nsk_jvmti_GetFieldModifiers_getfldmdf004_check(JNIEnv *env, jfieldID fid; jint modifiers; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; @@ -166,7 +166,7 @@ Java_nsk_jvmti_GetFieldModifiers_getfldmdf004_check(JNIEnv *env, } else { fid = env->GetFieldID(cls, fields[i].name, fields[i].sig); } - if (fid == NULL) { + if (fid == nullptr) { printf("(%d) cannot get field ID for %s:\"%s\"\n", i, fields[i].name, fields[i].sig); result = STATUS_FAILED; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldName/getfldnm003/getfldnm003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldName/getfldnm003/getfldnm003.cpp index 643f0ce376d..c1121a55259 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldName/getfldnm003/getfldnm003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldName/getfldnm003/getfldnm003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_getfldnm003(JavaVM *jvm, char *options, void *reserved jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -70,13 +70,13 @@ Java_nsk_jvmti_GetFieldName_getfldnm003_check(JNIEnv *env, jclass cls) { jfieldID field; char *name, *sig, *generic; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } field = env->GetFieldID(cls, "fld", "I"); - if (field == NULL) { + if (field == nullptr) { printf("Cannot get field ID!\n"); return STATUS_FAILED; } @@ -84,7 +84,7 @@ Java_nsk_jvmti_GetFieldName_getfldnm003_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> invalid class check ...\n"); } - err = jvmti->GetFieldName(NULL, field, &name, &sig, &generic); + err = jvmti->GetFieldName(nullptr, field, &name, &sig, &generic); if (err != JVMTI_ERROR_INVALID_CLASS) { printf("Error expected: JVMTI_ERROR_INVALID_CLASS,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -94,7 +94,7 @@ Java_nsk_jvmti_GetFieldName_getfldnm003_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> invalid field check ...\n"); } - err = jvmti->GetFieldName(cls, NULL, &name, &sig, &generic); + err = jvmti->GetFieldName(cls, nullptr, &name, &sig, &generic); if (err != JVMTI_ERROR_INVALID_FIELDID) { printf("Error expected: JVMTI_ERROR_INVALID_FIELDID,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -104,7 +104,7 @@ Java_nsk_jvmti_GetFieldName_getfldnm003_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> (namePtr) null pointer check ...\n"); } - err = jvmti->GetFieldName(cls, field, NULL, &sig, &generic); + err = jvmti->GetFieldName(cls, field, nullptr, &sig, &generic); if (err != JVMTI_ERROR_NONE) { printf("(name_ptr) unexpected error: %s (%d)\n", TranslateError(err), err); @@ -113,7 +113,7 @@ Java_nsk_jvmti_GetFieldName_getfldnm003_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> sig = \"%s\", generic = \"%s\"\n", sig, generic); } - if (sig == NULL || strcmp(sig, "I") != 0) { + if (sig == nullptr || strcmp(sig, "I") != 0) { printf("Wrong field sig: \"%s\", expected: \"I\"\n", sig); result = STATUS_FAILED; } @@ -122,7 +122,7 @@ Java_nsk_jvmti_GetFieldName_getfldnm003_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> (signature_ptr) null pointer check ...\n"); } - err = jvmti->GetFieldName(cls, field, &name, NULL, &generic); + err = jvmti->GetFieldName(cls, field, &name, nullptr, &generic); if (err != JVMTI_ERROR_NONE) { printf("(signaturePtr) unexpected error: %s (%d)\n", TranslateError(err), err); @@ -131,7 +131,7 @@ Java_nsk_jvmti_GetFieldName_getfldnm003_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> name = \"%s\", generic = \"%s\"\n", name, generic); } - if (name == NULL || strcmp(name, "fld") != 0) { + if (name == nullptr || strcmp(name, "fld") != 0) { printf("Wrong field name: \"%s\", expected: \"fld\"\n", name); result = STATUS_FAILED; } @@ -140,7 +140,7 @@ Java_nsk_jvmti_GetFieldName_getfldnm003_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> (generic_ptr) null pointer check ...\n"); } - err = jvmti->GetFieldName(cls, field, &name, &sig, NULL); + err = jvmti->GetFieldName(cls, field, &name, &sig, nullptr); if (err != JVMTI_ERROR_NONE) { printf("(signaturePtr) unexpected error: %s (%d)\n", TranslateError(err), err); @@ -149,11 +149,11 @@ Java_nsk_jvmti_GetFieldName_getfldnm003_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> name = \"%s\", sig = \"%s\"\n", name, sig); } - if (name == NULL || strcmp(name, "fld") != 0) { + if (name == nullptr || strcmp(name, "fld") != 0) { printf("Wrong field name: \"%s\", expected: \"fld\"\n", name); result = STATUS_FAILED; } - if (sig == NULL || strcmp(sig, "I") != 0) { + if (sig == nullptr || strcmp(sig, "I") != 0) { printf("Wrong field sig: \"%s\", expected: \"I\"\n", sig); result = STATUS_FAILED; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldName/getfldnm004/getfldnm004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldName/getfldnm004/getfldnm004.cpp index 5cb6eca8ddf..f748f6600c0 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldName/getfldnm004/getfldnm004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldName/getfldnm004/getfldnm004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -40,7 +40,7 @@ typedef struct { jboolean is_static; } field_info; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; static field_info fields[] = { @@ -81,12 +81,12 @@ JNIEXPORT jint JNI_OnLoad_getfldnm004(JavaVM *jvm, char *options, void *reserved jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -102,7 +102,7 @@ Java_nsk_jvmti_GetFieldName_getfldnm004_check(JNIEnv *env, char *name, *sig, *generic; size_t i; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -115,7 +115,7 @@ Java_nsk_jvmti_GetFieldName_getfldnm004_check(JNIEnv *env, fid = env->GetFieldID( clazz, fields[i].name, fields[i].sig); } - if (fid == NULL) { + if (fid == nullptr) { printf("(%" PRIuPTR ") cannot get field ID for %s:\"%s\"\n", i, fields[i].name, fields[i].sig); result = STATUS_FAILED; @@ -131,12 +131,12 @@ Java_nsk_jvmti_GetFieldName_getfldnm004_check(JNIEnv *env, if (printdump == JNI_TRUE) { printf(">>> %" PRIuPTR " -- %s:\"%s\"\n", i, name, sig); } - if (name == NULL || strcmp(name, fields[i].name) != 0) { + if (name == nullptr || strcmp(name, fields[i].name) != 0) { printf("(%" PRIuPTR ") wrong field name: \"%s\"", i, name); printf(", expected: \"%s\"\n", fields[i].name); result = STATUS_FAILED; } - if (sig == NULL || strcmp(sig, fields[i].sig) != 0) { + if (sig == nullptr || strcmp(sig, fields[i].sig) != 0) { printf("(%" PRIuPTR ") wrong field sig: \"%s\"", i, sig); printf(", expected: \"%s\"\n", fields[i].sig); result = STATUS_FAILED; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldName/getfldnm005/getfldnm005.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldName/getfldnm005/getfldnm005.cpp index 87332b15447..65508b38baf 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldName/getfldnm005/getfldnm005.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetFieldName/getfldnm005/getfldnm005.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ extern "C" { /* expected field signatures are below */ static const char *fld_sig[][FLDS_NUM] = { { "_getfldnm005St", "static", - "Lnsk/jvmti/GetFieldName/getfldnm005;", "NULL" }, + "Lnsk/jvmti/GetFieldName/getfldnm005;", "null" }, { "_getfldnm005b", "instance", "Lnsk/jvmti/GetFieldName/getfldnm005b;", @@ -59,10 +59,10 @@ static const char *fld_sig[][FLDS_NUM] = { { "_getfldnm005e", "instance", "Lnsk/jvmti/GetFieldName/getfldnm005e;", - "NULL" }, + "null" }, { "_getfldnm005eSt", "static", "Lnsk/jvmti/GetFieldName/getfldnm005e;", - "NULL" }, + "null" }, { "_getfldnm005if", "instance", "Lnsk/jvmti/GetFieldName/getfldnm005if;", @@ -80,10 +80,10 @@ static const char *fld_sig[][FLDS_NUM] = { { "_getfldnm005gArr", "instance", "[Lnsk/jvmti/GetFieldName/getfldnm005g;", - "NULL" } + "null" } }; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static int checkSig(JNIEnv *jni_env, jclass testedCls, jfieldID testedFld, int instance, int idx) { @@ -101,7 +101,7 @@ static int checkSig(JNIEnv *jni_env, jclass testedCls, name); if (strcmp(fld_sig[idx][2], sign) != 0 || - strcmp(fld_sig[idx][3], (gen_sign == NULL) ? "NULL" : gen_sign) != 0) { + strcmp(fld_sig[idx][3], (gen_sign == nullptr) ? "null" : gen_sign) != 0) { NSK_COMPLAIN6( "TEST FAILED: %s field \"%s\" has\n" "\tsignature: \"%s\"\n" @@ -110,20 +110,20 @@ static int checkSig(JNIEnv *jni_env, jclass testedCls, "\t\t\"%s\"\n\n", (instance == 0) ? "instance" : "static", fld_sig[idx][0], - sign, (gen_sign == NULL) ? "NULL" : gen_sign, + sign, (gen_sign == nullptr) ? "null" : gen_sign, fld_sig[idx][2], fld_sig[idx][3]); totRes = STATUS_FAILED; } else NSK_DISPLAY2("CHECK PASSED: signature: \"%s\",\n\tgeneric signature: \"%s\"\n", - sign, (gen_sign == NULL) ? "NULL" : gen_sign); + sign, (gen_sign == nullptr) ? "null" : gen_sign); NSK_DISPLAY0("Deallocating name & signature arrays\n"); if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*) name))) totRes = STATUS_FAILED; if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*) sign))) totRes = STATUS_FAILED; - if (gen_sign != NULL) + if (gen_sign != nullptr) if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*) gen_sign))) totRes = STATUS_FAILED; } @@ -135,7 +135,7 @@ JNIEXPORT jint JNICALL Java_nsk_jvmti_GetFieldName_getfldnm005_check( JNIEnv *jni, jobject obj) { int res = PASSED, i, instance; - jfieldID testedFld = NULL; + jfieldID testedFld = nullptr; jclass objCls = jni->GetObjectClass(obj); for (i=0; iGetFieldID(objCls, fld_sig[i][0], fld_sig[i][2])) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (testedFld = jni->GetFieldID(objCls, fld_sig[i][0], fld_sig[i][2])) != nullptr)) { NSK_COMPLAIN1("TEST FAILERE: unable to get field ID for \"%s\"\n\n", fld_sig[i][0]); res = STATUS_FAILED; @@ -153,7 +153,7 @@ Java_nsk_jvmti_GetFieldName_getfldnm005_check( } } else - if (!NSK_JNI_VERIFY(jni, (testedFld = jni->GetStaticFieldID(objCls, fld_sig[i][0], fld_sig[i][2])) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (testedFld = jni->GetStaticFieldID(objCls, fld_sig[i][0], fld_sig[i][2])) != nullptr)) { NSK_COMPLAIN1("TEST FAILERE: unable to get field ID for \"%s\"\n\n", fld_sig[i][0]); res = STATUS_FAILED; @@ -189,7 +189,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetImplementedInterfaces/getintrf005/getintrf005.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetImplementedInterfaces/getintrf005/getintrf005.cpp index ee7b56923c4..89e743f1b9f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetImplementedInterfaces/getintrf005/getintrf005.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetImplementedInterfaces/getintrf005/getintrf005.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_getintrf005(JavaVM *jvm, char *options, void *reserved jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -70,7 +70,7 @@ Java_nsk_jvmti_GetImplementedInterfaces_getintrf005_check(JNIEnv *env, jclass cl jint icount; jclass *interfaces; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -78,7 +78,7 @@ Java_nsk_jvmti_GetImplementedInterfaces_getintrf005_check(JNIEnv *env, jclass cl if (printdump == JNI_TRUE) { printf(">>> invalid class check ...\n"); } - err = jvmti->GetImplementedInterfaces(NULL, &icount, &interfaces); + err = jvmti->GetImplementedInterfaces(nullptr, &icount, &interfaces); if (err != JVMTI_ERROR_INVALID_CLASS) { printf("Error expected: JVMTI_ERROR_INVALID_CLASS,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -88,7 +88,7 @@ Java_nsk_jvmti_GetImplementedInterfaces_getintrf005_check(JNIEnv *env, jclass cl if (printdump == JNI_TRUE) { printf(">>> (interfaceCountPtr) null pointer check ...\n"); } - err = jvmti->GetImplementedInterfaces(cls, NULL, &interfaces); + err = jvmti->GetImplementedInterfaces(cls, nullptr, &interfaces); if (err != JVMTI_ERROR_NULL_POINTER) { printf("(interfaceCountPtr) error expected: JVMTI_ERROR_NULL_POINTER,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -98,7 +98,7 @@ Java_nsk_jvmti_GetImplementedInterfaces_getintrf005_check(JNIEnv *env, jclass cl if (printdump == JNI_TRUE) { printf(">>> (interfacesPtr) null pointer check ...\n"); } - err = jvmti->GetImplementedInterfaces(cls, &icount, NULL); + err = jvmti->GetImplementedInterfaces(cls, &icount, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { printf("(interfacesPtr) error expected: JVMTI_ERROR_NULL_POINTER,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetImplementedInterfaces/getintrf006/getintrf006.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetImplementedInterfaces/getintrf006/getintrf006.cpp index 50b4f30383e..6c6b4e060fb 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetImplementedInterfaces/getintrf006/getintrf006.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetImplementedInterfaces/getintrf006/getintrf006.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_getintrf006(JavaVM *jvm, char *options, void *reserved jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -70,7 +70,7 @@ Java_nsk_jvmti_GetImplementedInterfaces_getintrf006_check(JNIEnv *env, jclass cl jint icount; jclass *interfaces; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetImplementedInterfaces/getintrf007/getintrf007.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetImplementedInterfaces/getintrf007/getintrf007.cpp index da6fb2acbc4..5b855f85b9d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetImplementedInterfaces/getintrf007/getintrf007.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetImplementedInterfaces/getintrf007/getintrf007.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ typedef struct { iface_info *ifaces; } class_info; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -68,17 +68,17 @@ static iface_info i9[] = { }; static class_info classes[] = { - { "InnerClass1", 0, NULL }, - { "InnerInterface1", 0, NULL }, + { "InnerClass1", 0, nullptr }, + { "InnerInterface1", 0, nullptr }, { "InnerInterface2", 1, i2 }, { "InnerClass2", 1, i3 }, - { "OuterClass1", 0, NULL }, - { "OuterClass2", 0, NULL }, - { "OuterInterface1", 0, NULL }, + { "OuterClass1", 0, nullptr }, + { "OuterClass2", 0, nullptr }, + { "OuterInterface1", 0, nullptr }, { "OuterClass3", 1, i7 }, { "OuterInterface2", 1, i8 }, { "OuterClass4", 1, i9 }, - { "OuterClass5", 0, NULL } + { "OuterClass5", 0, nullptr } }; #ifdef STATIC_BUILD @@ -95,12 +95,12 @@ JNIEXPORT jint JNI_OnLoad_getintrf007(JavaVM *jvm, char *options, void *reserved jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -116,7 +116,7 @@ Java_nsk_jvmti_GetImplementedInterfaces_getintrf007_check(JNIEnv *env, jclass cl char *sig, *generic; int j; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; @@ -141,7 +141,7 @@ Java_nsk_jvmti_GetImplementedInterfaces_getintrf007_check(JNIEnv *env, jclass cl } for (j = 0; j < icount; j++) { - if (interfaces[j] == NULL) { + if (interfaces[j] == nullptr) { printf("(%d:%d) null reference\n", i, j); } else { err = jvmti->GetClassSignature(interfaces[j], @@ -153,7 +153,7 @@ Java_nsk_jvmti_GetImplementedInterfaces_getintrf007_check(JNIEnv *env, jclass cl if (printdump == JNI_TRUE) { printf(">>> [%d]: %s\n", j, sig); } - if ((j < classes[i].icount) && (sig == NULL || + if ((j < classes[i].icount) && (sig == nullptr || strcmp(sig, classes[i].ifaces[j].sig) != 0)) { printf("(%d:%d) wrong interface: \"%s\"", i, j, sig); printf(", expected: \"%s\"\n", classes[i].ifaces[j].sig); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetJLocationFormat/getjlocfmt001/getjlocfmt001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetJLocationFormat/getjlocfmt001/getjlocfmt001.cpp index b604af51f8a..2725d43068f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetJLocationFormat/getjlocfmt001/getjlocfmt001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetJLocationFormat/getjlocfmt001/getjlocfmt001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -156,7 +156,7 @@ JNIEXPORT jint JNI_OnLoad_getjlocfmt001(JavaVM *jvm, char *options, void *reserv } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv *jvmti = NULL; + jvmtiEnv *jvmti = nullptr; jvmtiJlocationFormat format; jvmtiEventCallbacks callbacks; @@ -169,7 +169,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* Create data access lock */ @@ -199,16 +199,16 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* enable VMInit event */ if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL))) + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, nullptr))) return JNI_ERR; /* enable ClassFileLoadHook event */ if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL))) + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, nullptr))) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetJLocationFormat/getjlocfmt002/getjlocfmt002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetJLocationFormat/getjlocfmt002/getjlocfmt002.cpp index b8125340a95..f13d7f1cf10 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetJLocationFormat/getjlocfmt002/getjlocfmt002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetJLocationFormat/getjlocfmt002/getjlocfmt002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -45,8 +45,8 @@ agentProc(jvmtiEnv *jvmti, JNIEnv* jni, void* arg) { if (!nsk_jvmti_waitForSync(timeout)) return; - NSK_DISPLAY0("Check if GetJLocationFormat(NULL) returns JVMTI_ERROR_NULL_POINTER\n"); - if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_NULL_POINTER, jvmti->GetJLocationFormat(NULL))) + NSK_DISPLAY0("Check if GetJLocationFormat(null) returns JVMTI_ERROR_NULL_POINTER\n"); + if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_NULL_POINTER, jvmti->GetJLocationFormat(nullptr))) nsk_jvmti_setFailStatus(); /* resume debugee after last sync */ @@ -69,7 +69,7 @@ JNIEXPORT jint JNI_OnLoad_getjlocfmt002(JavaVM *jvm, char *options, void *reserv } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv *jvmti = NULL; + jvmtiEnv *jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -82,11 +82,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetJNIFunctionTable/getjniftab001/getjniftab001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetJNIFunctionTable/getjniftab001/getjniftab001.cpp index 213daccd426..a1293a0cb5d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetJNIFunctionTable/getjniftab001/getjniftab001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetJNIFunctionTable/getjniftab001/getjniftab001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,17 +38,17 @@ extern "C" { #define STATUS_FAILED 2 static JavaVM *vm; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static int verbose = 0; static jint result = PASSED; /* the original JNI function table */ -static jniNativeInterface *orig_jni_functions = NULL; +static jniNativeInterface *orig_jni_functions = nullptr; /* the redirected JNI function table */ -static jniNativeInterface *redir_jni_functions = NULL; +static jniNativeInterface *redir_jni_functions = nullptr; /* number of the redirected JNI function calls */ static volatile int redir_calls = 0; @@ -120,7 +120,7 @@ static void doRestore(JNIEnv *env) { } static void checkRedir(JNIEnv *env, int exCalls) { - jniNativeInterface *tested_jni_functions = NULL; + jniNativeInterface *tested_jni_functions = nullptr; jvmtiError err; jint res; @@ -156,7 +156,7 @@ JNIEXPORT jint JNICALL Java_nsk_jvmti_GetJNIFunctionTable_getjniftab001_check(JNIEnv *env, jobject obj) { int exitCode = PASSED; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("(%s,%d): TEST FAILURE: JVMTI client was not properly loaded\n", __FILE__, __LINE__); return STATUS_FAILED; @@ -191,14 +191,14 @@ JNIEXPORT jint JNI_OnLoad_getjniftab001(JavaVM *jvm, char *options, void *reserv jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "-verbose") == 0) + if (options != nullptr && strcmp(options, "-verbose") == 0) verbose = 1; if (verbose) printf("verbose mode on\n"); res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("(%s,%d): Failed to call GetEnv\n", __FILE__, __LINE__); return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetJNIFunctionTable/getjniftab002/getjniftab002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetJNIFunctionTable/getjniftab002/getjniftab002.cpp index db01fdbe12d..7c564bfa28c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetJNIFunctionTable/getjniftab002/getjniftab002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetJNIFunctionTable/getjniftab002/getjniftab002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,8 +33,8 @@ extern "C" { #define STATUS_FAILED 2 static JavaVM *vm; -static jvmtiEnv *jvmti = NULL; -static jniNativeInterface *orig_jni_functions = NULL; +static jvmtiEnv *jvmti = nullptr; +static jniNativeInterface *orig_jni_functions = nullptr; static int verbose = 0; static jint result = PASSED; @@ -46,7 +46,7 @@ void redirect(JNIEnv *env, jvmtiError exError) { printf("\ntrying to get the JNI function table expecting the error %s to be returned ...\n", TranslateError(exError)); - err = jvmti->GetJNIFunctionTable((exError == JVMTI_ERROR_NULL_POINTER) ? NULL : &orig_jni_functions); + err = jvmti->GetJNIFunctionTable((exError == JVMTI_ERROR_NULL_POINTER) ? nullptr : &orig_jni_functions); if (err != exError) { result = STATUS_FAILED; printf("(%s,%d): TEST FAILED: GetJNIFunctionTable() returns %s instead of %s as expected\n", @@ -61,9 +61,9 @@ void redirect(JNIEnv *env, jvmtiError exError) { JNIEXPORT jint JNICALL Java_nsk_jvmti_GetJNIFunctionTable_getjniftab002_check(JNIEnv *env, jobject obj) { jint err; - JNIEnv *nextEnv = NULL; + JNIEnv *nextEnv = nullptr; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("(%s,%d): TEST FAILURE: JVMTI client was not properly loaded\n", __FILE__, __LINE__); return STATUS_FAILED; @@ -115,14 +115,14 @@ JNIEXPORT jint JNI_OnLoad_getjniftab002(JavaVM *jvm, char *options, void *reserv jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "-verbose") == 0) + if (options != nullptr && strcmp(options, "-verbose") == 0) verbose = 1; if (verbose) printf("verbose mode on\n"); res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("(%s,%d): Failed to call GetEnv\n", __FILE__, __LINE__); return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLineNumberTable/linetab001/linetab001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLineNumberTable/linetab001/linetab001.cpp index 17884af7497..669374789ec 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLineNumberTable/linetab001/linetab001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLineNumberTable/linetab001/linetab001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -67,8 +67,8 @@ void checkMeth(JNIEnv *env, jclass cl, const char *name, const char *sig, } else { mid = env->GetMethodID(cl, name, sig); } - if (mid == NULL) { - printf("Name = %s, sig = %s: mid = NULL\n", name, sig); + if (mid == nullptr) { + printf("Name = %s, sig = %s: mid = null\n", name, sig); result = STATUS_FAILED; return; } @@ -132,7 +132,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLineNumberTable/linetab002/linetab002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLineNumberTable/linetab002/linetab002.cpp index a4df264ccbe..ad5984a64d9 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLineNumberTable/linetab002/linetab002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLineNumberTable/linetab002/linetab002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -53,12 +53,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -98,7 +98,7 @@ Java_nsk_jvmti_GetLineNumberTable_linetab002_check(JNIEnv *env, jclass cls) { jint entryCount; jvmtiLineNumberEntry *table; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -108,7 +108,7 @@ Java_nsk_jvmti_GetLineNumberTable_linetab002_check(JNIEnv *env, jclass cls) { } mid = env->GetMethodID(cls, "", "()V"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot get method ID!\n"); return STATUS_FAILED; } @@ -116,7 +116,7 @@ Java_nsk_jvmti_GetLineNumberTable_linetab002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> invalid method check ...\n"); } - err = jvmti->GetLineNumberTable(NULL, &entryCount, &table); + err = jvmti->GetLineNumberTable(nullptr, &entryCount, &table); if (err != JVMTI_ERROR_INVALID_METHODID) { printf("Error expected: JVMTI_ERROR_INVALID_METHODID,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -126,7 +126,7 @@ Java_nsk_jvmti_GetLineNumberTable_linetab002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> (entryCountPtr) null pointer check ...\n"); } - err = jvmti->GetLineNumberTable(mid, NULL, &table); + err = jvmti->GetLineNumberTable(mid, nullptr, &table); if (err != JVMTI_ERROR_NULL_POINTER) { printf("(entryCountPtr) error expected: JVMTI_ERROR_NULL_POINTER,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -136,7 +136,7 @@ Java_nsk_jvmti_GetLineNumberTable_linetab002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> (tablePtr) null pointer check ...\n"); } - err = jvmti->GetLineNumberTable(mid, &entryCount, NULL); + err = jvmti->GetLineNumberTable(mid, &entryCount, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { printf("(tablePtr) error expected: JVMTI_ERROR_NULL_POINTER,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLineNumberTable/linetab003/linetab003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLineNumberTable/linetab003/linetab003.cpp index 26ba35b8472..00468064849 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLineNumberTable/linetab003/linetab003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLineNumberTable/linetab003/linetab003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -53,12 +53,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -99,7 +99,7 @@ Java_nsk_jvmti_GetLineNumberTable_linetab003_check(JNIEnv *env, jclass cls) { jvmtiLineNumberEntry *table; int i; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -109,7 +109,7 @@ Java_nsk_jvmti_GetLineNumberTable_linetab003_check(JNIEnv *env, jclass cls) { } mid = env->GetMethodID(cls, "meth", "()I"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot get method ID!\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLoadedClasses/loadedclss001/loadedclss001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLoadedClasses/loadedclss001/loadedclss001.cpp index 12515f15fca..23bd64d6284 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLoadedClasses/loadedclss001/loadedclss001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLoadedClasses/loadedclss001/loadedclss001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_loadedclss001(JavaVM *jvm, char *options, void *reserv jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -69,7 +69,7 @@ Java_nsk_jvmti_GetLoadedClasses_loadedclss001_check(JNIEnv *env, jclass cls) { jclass *classes; jint classCount; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -77,7 +77,7 @@ Java_nsk_jvmti_GetLoadedClasses_loadedclss001_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> (classCountPtr) null pointer check ...\n"); } - err = jvmti->GetLoadedClasses(NULL, &classes); + err = jvmti->GetLoadedClasses(nullptr, &classes); if (err != JVMTI_ERROR_NULL_POINTER) { printf("Error expected: JVMTI_ERROR_NULL_POINTER,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -87,7 +87,7 @@ Java_nsk_jvmti_GetLoadedClasses_loadedclss001_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> (classesPtr) null pointer check ...\n"); } - err = jvmti->GetLoadedClasses(&classCount, NULL); + err = jvmti->GetLoadedClasses(&classCount, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { printf("Error expected: JVMTI_ERROR_NULL_POINTER,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLoadedClasses/loadedclss002/loadedclss002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLoadedClasses/loadedclss002/loadedclss002.cpp index 8a65e34cfd4..73e8472c3c4 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLoadedClasses/loadedclss002/loadedclss002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLoadedClasses/loadedclss002/loadedclss002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -35,9 +35,9 @@ extern "C" { static jlong timeout = 0; /* test objects */ -static jobject testedClassLoader = NULL; -static jclass testedClass = NULL; -static jfieldID testedFieldID = NULL; +static jobject testedClassLoader = nullptr; +static jclass testedClass = nullptr; +static jfieldID testedFieldID = nullptr; static const char *CLASS_SIG[] = { "Lnsk/jvmti/GetLoadedClasses/loadedclss002;", @@ -63,15 +63,15 @@ static int lookup(jvmtiEnv* jvmti, if (!NSK_JVMTI_VERIFY(jvmti->GetClassSignature(classes[i], &signature, &generic))) break; - if (signature != NULL && strcmp(signature, exp_sig) == 0) { + if (signature != nullptr && strcmp(signature, exp_sig) == 0) { NSK_DISPLAY1("Expected class found: %s\n", exp_sig); found = NSK_TRUE; } - if (signature != NULL) + if (signature != nullptr) jvmti->Deallocate((unsigned char*)signature); - if (generic != NULL) + if (generic != nullptr) jvmti->Deallocate((unsigned char*)generic); } @@ -100,7 +100,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { return; } - if (!NSK_VERIFY(classes != NULL)) { + if (!NSK_VERIFY(classes != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -121,7 +121,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { } } - if (classes != NULL) + if (classes != nullptr) jvmti->Deallocate((unsigned char*)classes); if (!nsk_jvmti_resumeSync()) @@ -143,7 +143,7 @@ JNIEXPORT jint JNI_OnLoad_loadedclss002(JavaVM *jvm, char *options, void *reserv } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; NSK_DISPLAY0("Agent_OnLoad\n"); @@ -153,10 +153,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariable/getlocal001/getlocal001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariable/getlocal001/getlocal001.cpp index 42bdfb46cc2..9095312a5b6 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariable/getlocal001/getlocal001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariable/getlocal001/getlocal001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -146,7 +146,7 @@ void check2(jvmtiEnv *jvmti_env, jthread thr, jint depth, void check3(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thr, jint depth, jvmtiLocalVariableEntry *table, jint count, jmethodID mid) { jvmtiError err; - jobject ob1 = NULL, ob2 = NULL; + jobject ob1 = nullptr, ob2 = nullptr; jclass cls; jfieldID fid; jint fldVal = 0; @@ -171,7 +171,7 @@ void check3(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thr, jint depth, continue; } fid = env->GetFieldID(cls, "fld", "I"); - if (fid == NULL) { + if (fid == nullptr) { printf("Cannot find ID for \"fld\" field of meth03\n"); env->ExceptionClear(); result = STATUS_FAILED; @@ -284,7 +284,7 @@ void JNICALL MethodExit(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thr, jmethodID mid, jboolean was_poped_by_exception, jvalue return_value) { jvmtiError err; - jvmtiLocalVariableEntry *table = NULL; + jvmtiLocalVariableEntry *table = nullptr; jint entryCount = 0; int i; @@ -307,7 +307,7 @@ void JNICALL MethodExit(jvmtiEnv *jvmti_env, JNIEnv *env, printf(">>> exit: meth02\n"); } check2(jvmti_env, thr, 0, table, entryCount); - mid2 = NULL; + mid2 = nullptr; } else if (mid == mid3) { if (printdump == JNI_TRUE) { printf(">>> exit: meth03\n"); @@ -320,7 +320,7 @@ void JNICALL MethodExit(jvmtiEnv *jvmti_env, JNIEnv *env, check4(jvmti_env, thr, 0, table, entryCount); } } - if (table != NULL) { + if (table != nullptr) { for (i = 0; i < entryCount; i++) { jvmti_env->Deallocate((unsigned char*)table[i].name); jvmti_env->Deallocate((unsigned char*)table[i].signature); @@ -332,7 +332,7 @@ void JNICALL MethodExit(jvmtiEnv *jvmti_env, JNIEnv *env, void JNICALL Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thr, jmethodID method, jlocation location) { jvmtiError err; - jvmtiLocalVariableEntry *table = NULL; + jvmtiLocalVariableEntry *table = nullptr; jint entryCount = 0; jmethodID mid; jlocation loc; @@ -376,7 +376,7 @@ void JNICALL Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *env, printf("ERROR: didn't know where we got called from"); result = STATUS_FAILED; } - if (table != NULL) { + if (table != nullptr) { for (i = 0; i < entryCount; i++) { jvmti_env->Deallocate((unsigned char*)table[i].name); jvmti_env->Deallocate((unsigned char*)table[i].signature); @@ -400,12 +400,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } @@ -474,7 +474,7 @@ Java_nsk_jvmti_GetLocalVariable_getlocal001_getMeth(JNIEnv *env, jclass cls, result = STATUS_FAILED; return; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_EXIT, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_EXIT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable METHOD_EXIT event: %s (%d)\n", TranslateError(err), err); @@ -487,7 +487,7 @@ Java_nsk_jvmti_GetLocalVariable_getlocal001_getMeth(JNIEnv *env, jclass cls, return; } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_BREAKPOINT, NULL); + JVMTI_EVENT_BREAKPOINT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable BREAKPOINT event: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariable/getlocal002/getlocal002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariable/getlocal002/getlocal002.cpp index 6f6081fe24e..48fac6fc75f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariable/getlocal002/getlocal002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariable/getlocal002/getlocal002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,12 +33,12 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; static jint result = PASSED; static jboolean printdump = JNI_FALSE; -static jmethodID mid = NULL; +static jmethodID mid = nullptr; void JNICALL MethodExit(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thr, jmethodID method, @@ -52,7 +52,7 @@ void JNICALL MethodExit(jvmtiEnv *jvmti_env, JNIEnv *env, if (mid == method) { err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, - JVMTI_EVENT_METHOD_EXIT, NULL); + JVMTI_EVENT_METHOD_EXIT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to disable metod exit event: %s (%d)\n", TranslateError(err), err); @@ -98,7 +98,7 @@ void JNICALL MethodExit(jvmtiEnv *jvmti_env, JNIEnv *env, if (printdump == JNI_TRUE) { printf(">>> null pointer check ...\n"); } - err = jvmti->GetLocalFloat(thr, 0, table[i].slot, NULL); + err = jvmti->GetLocalFloat(thr, 0, table[i].slot, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { printf("Error expected: JVMTI_ERROR_NULL_POINTER,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -129,12 +129,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -181,7 +181,7 @@ JNIEXPORT void JNICALL Java_nsk_jvmti_GetLocalVariable_getlocal002_getMeth(JNIEnv *env, jclass cls) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; @@ -191,14 +191,14 @@ Java_nsk_jvmti_GetLocalVariable_getlocal002_getMeth(JNIEnv *env, jclass cls) { !caps.can_generate_method_exit_events) return; mid = env->GetMethodID(cls, "meth01", "()D"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot find Method ID for meth01\n"); result = STATUS_FAILED; return; } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_METHOD_EXIT, NULL); + JVMTI_EVENT_METHOD_EXIT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable metod exit event: %s (%d)\n", TranslateError(err), err); @@ -215,12 +215,12 @@ Java_nsk_jvmti_GetLocalVariable_getlocal002_checkLoc(JNIEnv *env, jmethodID mid; jint i1; - if (jvmti == NULL) { + if (jvmti == nullptr) { return; } mid = env->GetStaticMethodID(cls, "meth02", "()V"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot find Method ID for meth02\n"); result = STATUS_FAILED; return; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab001/localtab001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab001/localtab001.cpp index fcc3e5040ba..bca81f0d9fe 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab001/localtab001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab001/localtab001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,47 +42,47 @@ static jvmtiEnv *jvmti; static jvmtiCapabilities caps; static jint result = PASSED; static jvmtiLocalVariableEntry m1[] = { - { 0, 21, (char*) "this", (char*) "Lnsk/jvmti/GetLocalVariableTable/localtab001;", NULL, 0 }, - { 4, 17, (char*) "l", (char*) "J", NULL, 1 }, - { 7, 14, (char*) "f", (char*) "F", NULL, 2 }, - { 12, 9, (char*) "d", (char*) "D", NULL, 3 } + { 0, 21, (char*) "this", (char*) "Lnsk/jvmti/GetLocalVariableTable/localtab001;", nullptr, 0 }, + { 4, 17, (char*) "l", (char*) "J", nullptr, 1 }, + { 7, 14, (char*) "f", (char*) "F", nullptr, 2 }, + { 12, 9, (char*) "d", (char*) "D", nullptr, 3 } }; static jvmtiLocalVariableEntry m2[] = { - { 0, 32, (char*) "this", (char*) "Lnsk/jvmti/GetLocalVariableTable/localtab001;", NULL, 0 }, - { 0, 32, (char*) "step", (char*) "I", NULL, 1 }, - { 2, 29, (char*) "i2", (char*) "S", NULL, 2 }, - { 4, 27, (char*) "i3", (char*) "C", NULL, 3 }, - { 7, 24, (char*) "i4", (char*) "B", NULL, 4 }, - { 10,21, (char*) "i5", (char*) "Z", NULL, 5 }, - { 13,18, (char*) "i1", (char*) "I", NULL, 6 } + { 0, 32, (char*) "this", (char*) "Lnsk/jvmti/GetLocalVariableTable/localtab001;", nullptr, 0 }, + { 0, 32, (char*) "step", (char*) "I", nullptr, 1 }, + { 2, 29, (char*) "i2", (char*) "S", nullptr, 2 }, + { 4, 27, (char*) "i3", (char*) "C", nullptr, 3 }, + { 7, 24, (char*) "i4", (char*) "B", nullptr, 4 }, + { 10,21, (char*) "i5", (char*) "Z", nullptr, 5 }, + { 13,18, (char*) "i1", (char*) "I", nullptr, 6 } }; static jvmtiLocalVariableEntry m3[] = { - { 0, 70, (char*) "ob", (char*) "Lnsk/jvmti/GetLocalVariableTable/localtab001;", NULL, 0 }, - { 2, 67, (char*) "ob1", (char*) "Lnsk/jvmti/GetLocalVariableTable/localtab001;", NULL, 1 }, - { 56,13, (char*) "ob2", (char*) "[I", NULL, 2 }, - { 61, 0, (char*) "i", (char*) "I", NULL, 3 }, - { 64, 5, (char*) "e", (char*) "Ljava/lang/IndexOutOfBoundsException;", NULL, 4 } + { 0, 70, (char*) "ob", (char*) "Lnsk/jvmti/GetLocalVariableTable/localtab001;", nullptr, 0 }, + { 2, 67, (char*) "ob1", (char*) "Lnsk/jvmti/GetLocalVariableTable/localtab001;", nullptr, 1 }, + { 56,13, (char*) "ob2", (char*) "[I", nullptr, 2 }, + { 61, 0, (char*) "i", (char*) "I", nullptr, 3 }, + { 64, 5, (char*) "e", (char*) "Ljava/lang/IndexOutOfBoundsException;", nullptr, 4 } }; static jvmtiLocalVariableEntry m4[] = { - { 0, 33, (char*) "i1", (char*) "I", NULL, 0 }, - { 0, 33, (char*) "l", (char*) "J", NULL, 1 }, - { 0, 33, (char*) "i2", (char*) "S", NULL, 2 }, - { 0, 33, (char*) "d", (char*) "D", NULL, 3 }, - { 0, 33, (char*) "i3", (char*) "C", NULL, 4 }, - { 0, 33, (char*) "f", (char*) "F", NULL, 5 }, - { 0, 33, (char*) "i4", (char*) "B", NULL, 6 }, - { 0, 33, (char*) "b", (char*) "Z", NULL, 7 } + { 0, 33, (char*) "i1", (char*) "I", nullptr, 0 }, + { 0, 33, (char*) "l", (char*) "J", nullptr, 1 }, + { 0, 33, (char*) "i2", (char*) "S", nullptr, 2 }, + { 0, 33, (char*) "d", (char*) "D", nullptr, 3 }, + { 0, 33, (char*) "i3", (char*) "C", nullptr, 4 }, + { 0, 33, (char*) "f", (char*) "F", nullptr, 5 }, + { 0, 33, (char*) "i4", (char*) "B", nullptr, 6 }, + { 0, 33, (char*) "b", (char*) "Z", nullptr, 7 } }; static jvmtiLocalVariableEntry m5[] = { - { 0, 6, (char*) "this", (char*) "Lnsk/jvmti/GetLocalVariableTable/localtab001;", NULL, 0 }, - { 0, 6, (char*) "i", (char*) "I", NULL, 1 }, - { 2, 4, (char*) "i12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678", (char*) "I", NULL, 2 } + { 0, 6, (char*) "this", (char*) "Lnsk/jvmti/GetLocalVariableTable/localtab001;", nullptr, 0 }, + { 0, 6, (char*) "i", (char*) "I", nullptr, 1 }, + { 2, 4, (char*) "i12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678", (char*) "I", nullptr, 2 } }; static jvmtiLocalVariableEntry m6[] = { - { 0, 5, (char*) "this", (char*) "Lnsk/jvmti/GetLocalVariableTable/localtab001;", NULL, 0 }, + { 0, 5, (char*) "this", (char*) "Lnsk/jvmti/GetLocalVariableTable/localtab001;", nullptr, 0 }, }; static info meth_tab[] = { - { 0, NULL }, + { 0, nullptr }, { 4, m1 }, { 7, m2 }, { 5, m3 }, @@ -106,8 +106,8 @@ void checkMeth(JNIEnv *env, jclass cl, const char *name, const char *sig, } else { mid = env->GetMethodID(cl, name, sig); } - if (mid == NULL) { - printf("Name = %s, sig = %s: mid = NULL\n", name, sig); + if (mid == nullptr) { + printf("Name = %s, sig = %s: mid = null\n", name, sig); result = STATUS_FAILED; return; } @@ -194,7 +194,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab002/localtab002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab002/localtab002.cpp index 10ce5662641..877ed5fe517 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab002/localtab002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab002/localtab002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -53,12 +53,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -98,7 +98,7 @@ Java_nsk_jvmti_GetLocalVariableTable_localtab002_check(JNIEnv *env, jclass cls) jint entryCount; jvmtiLocalVariableEntry *table; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -106,7 +106,7 @@ Java_nsk_jvmti_GetLocalVariableTable_localtab002_check(JNIEnv *env, jclass cls) if (!caps.can_access_local_variables) return result; mid = env->GetMethodID(cls, "", "()V"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot get method ID for \"\"!\n"); return STATUS_FAILED; } @@ -114,7 +114,7 @@ Java_nsk_jvmti_GetLocalVariableTable_localtab002_check(JNIEnv *env, jclass cls) if (printdump == JNI_TRUE) { printf(">>> invalid method check ...\n"); } - err = jvmti->GetLocalVariableTable(NULL, &entryCount, &table); + err = jvmti->GetLocalVariableTable(nullptr, &entryCount, &table); if (err != JVMTI_ERROR_INVALID_METHODID) { printf("Error expected: JVMTI_ERROR_INVALID_METHODID,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -124,7 +124,7 @@ Java_nsk_jvmti_GetLocalVariableTable_localtab002_check(JNIEnv *env, jclass cls) if (printdump == JNI_TRUE) { printf(">>> (entryCountPtr) null pointer check ...\n"); } - err = jvmti->GetLocalVariableTable(mid, NULL, &table); + err = jvmti->GetLocalVariableTable(mid, nullptr, &table); if (err != JVMTI_ERROR_NULL_POINTER) { printf("Error expected: JVMTI_ERROR_NULL_POINTER,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -134,7 +134,7 @@ Java_nsk_jvmti_GetLocalVariableTable_localtab002_check(JNIEnv *env, jclass cls) if (printdump == JNI_TRUE) { printf(">>> (tablePtr) null pointer check ...\n"); } - err = jvmti->GetLocalVariableTable(mid, &entryCount, NULL); + err = jvmti->GetLocalVariableTable(mid, &entryCount, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { printf("Error expected: JVMTI_ERROR_NULL_POINTER,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -142,7 +142,7 @@ Java_nsk_jvmti_GetLocalVariableTable_localtab002_check(JNIEnv *env, jclass cls) } mid = env->GetStaticMethodID(cls, "check", "()I"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot get method ID for \"check\"!\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab003/localtab003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab003/localtab003.cpp index f1763f736ea..00f3498d4d8 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab003/localtab003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab003/localtab003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -53,12 +53,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -99,7 +99,7 @@ Java_nsk_jvmti_GetLocalVariableTable_localtab003_check(JNIEnv *env, jclass cls) jvmtiLocalVariableEntry *table; int i; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -107,7 +107,7 @@ Java_nsk_jvmti_GetLocalVariableTable_localtab003_check(JNIEnv *env, jclass cls) if (!caps.can_access_local_variables) return result; mid = env->GetMethodID(cls, "meth", "()I"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot get method ID!\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab004/localtab004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab004/localtab004.cpp index 8f25575e04d..2bd35a65392 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab004/localtab004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab004/localtab004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,12 +81,12 @@ typedef struct { /* local variables of a method */ /* list of tested methods */ static methodInfo methInfo[] = { - { 1, (char*) "", (char*) "()V", 6, constr_lv, NULL }, - { 1, (char*) "finMethod", (char*) "(CJIJ)V", 7, finMeth_lv, NULL }, - { 0, (char*) "statMethod", (char*) "(III)D", 5, statMeth_lv, NULL } + { 1, (char*) "", (char*) "()V", 6, constr_lv, nullptr }, + { 1, (char*) "finMethod", (char*) "(CJIJ)V", 7, finMeth_lv, nullptr }, + { 0, (char*) "statMethod", (char*) "(III)D", 5, statMeth_lv, nullptr } }; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static int checkAttr(JNIEnv *jni_env, jclass testedCls) { @@ -102,7 +102,7 @@ static int checkAttr(JNIEnv *jni_env, jclass testedCls) { methInfo[i].mid = jni_env->GetMethodID(testedCls, methInfo[i].m_name, methInfo[i].m_sign); else /* a static method */ methInfo[i].mid = jni_env->GetStaticMethodID(testedCls, methInfo[i].m_name, methInfo[i].m_sign); - if (methInfo[i].mid == NULL) { + if (methInfo[i].mid == nullptr) { NSK_COMPLAIN3("TEST FAILURE: unable to get the method ID for the %s method \"%s\", signature \"%s\"\n\n", methInfo[i].inst ? "instance" : "static", methInfo[i].m_name, methInfo[i].m_sign); @@ -196,7 +196,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add capability to access local variables */ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab005/localtab005.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab005/localtab005.cpp index 3a681654762..0436b7f1d49 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab005/localtab005.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLocalVariableTable/localtab005/localtab005.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -45,35 +45,35 @@ typedef struct { /* local variable info */ /* expected local variable info are below */ static localVar constr_lv[] = { /* constructor's local variables */ - { "this", "Lnsk/jvmti/GetLocalVariableTable/localtab005a;", "NULL" }, + { "this", "Lnsk/jvmti/GetLocalVariableTable/localtab005a;", "null" }, { "constr_b", "Lnsk/jvmti/GetLocalVariableTable/localtab005b;", "Lnsk/jvmti/GetLocalVariableTable/localtab005b;" }, - { "constr_i", "I", "NULL" }, + { "constr_i", "I", "null" }, { "constr_c", "Lnsk/jvmti/GetLocalVariableTable/localtab005c;", "Lnsk/jvmti/GetLocalVariableTable/localtab005c;" }, - { "constr_f", "F", "NULL" }, - { "constr_ch", "C", "NULL" }, + { "constr_f", "F", "null" }, + { "constr_ch", "C", "null" }, { "constr_if", "Lnsk/jvmti/GetLocalVariableTable/localtab005if;", "Lnsk/jvmti/GetLocalVariableTable/localtab005if;" } }; static localVar insMeth_lv[] = { /* finMethod()'s local variables */ - { "this", "Lnsk/jvmti/GetLocalVariableTable/localtab005a;", "NULL" }, - { "ins_c", "C", "NULL" }, - { "ins_i", "J", "NULL" }, + { "this", "Lnsk/jvmti/GetLocalVariableTable/localtab005a;", "null" }, + { "ins_c", "C", "null" }, + { "ins_i", "J", "null" }, { "ltab005d", "Lnsk/jvmti/GetLocalVariableTable/localtab005d;", "Lnsk/jvmti/GetLocalVariableTable/localtab005d;" }, - { "ins_k", "J", "NULL" }, - { "ins_l", "J", "NULL" }, + { "ins_k", "J", "null" }, + { "ins_l", "J", "null" }, { "ins_g", "Lnsk/jvmti/GetLocalVariableTable/localtab005g;", "Lnsk/jvmti/GetLocalVariableTable/localtab005g;" } }; static localVar statMeth_lv[] = { /* statMethod()'s local variables */ - { "stat_x", "I", "NULL" }, - { "stat_y", "I", "NULL" }, - { "stat_z", "I", "NULL" }, - { "stat_j", "D", "NULL" }, + { "stat_x", "I", "null" }, + { "stat_y", "I", "null" }, + { "stat_z", "I", "null" }, + { "stat_j", "D", "null" }, { "stat_d", "Lnsk/jvmti/GetLocalVariableTable/localtab005d;", "Lnsk/jvmti/GetLocalVariableTable/localtab005d;" } }; @@ -89,12 +89,12 @@ typedef struct { /* local variables of a method */ /* list of tested methods */ static methodInfo methInfo[] = { - { 1, (char*) "", (char*) "()V", 7, constr_lv, NULL }, - { 1, (char*) "insMethod", (char*) "(CJLnsk/jvmti/GetLocalVariableTable/localtab005d;J)V", 7, insMeth_lv, NULL }, - { 0, (char*) "statMethod", (char*) "(III)D", 5, statMeth_lv, NULL } + { 1, (char*) "", (char*) "()V", 7, constr_lv, nullptr }, + { 1, (char*) "insMethod", (char*) "(CJLnsk/jvmti/GetLocalVariableTable/localtab005d;J)V", 7, insMeth_lv, nullptr }, + { 0, (char*) "statMethod", (char*) "(III)D", 5, statMeth_lv, nullptr } }; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static int checkAttr(JNIEnv *jni_env, jclass testedCls) { @@ -110,7 +110,7 @@ static int checkAttr(JNIEnv *jni_env, jclass testedCls) { methInfo[i].mid = jni_env->GetMethodID(testedCls, methInfo[i].m_name, methInfo[i].m_sign); else /* a static method */ methInfo[i].mid = jni_env->GetStaticMethodID(testedCls, methInfo[i].m_name, methInfo[i].m_sign); - if (methInfo[i].mid == NULL) { + if (methInfo[i].mid == nullptr) { NSK_COMPLAIN3("TEST FAILURE: unable to get the method ID for the %s method \"%s\", signature \"%s\"\n\n", methInfo[i].inst ? "instance" : "static", methInfo[i].m_name, methInfo[i].m_sign); @@ -137,7 +137,7 @@ static int checkAttr(JNIEnv *jni_env, jclass testedCls) { NSK_COMPLAIN4("\t%d) name: \"%s\"\n\tsignature: \"%s\"\n\tgeneric signature: \"%s\"\n", j+1, lv_table[j].name, lv_table[j].signature, - (lv_table[j].generic_signature == NULL) ? "NULL" : lv_table[j].generic_signature); + (lv_table[j].generic_signature == nullptr) ? "null" : lv_table[j].generic_signature); NSK_COMPLAIN0("\n"); continue; @@ -155,7 +155,7 @@ static int checkAttr(JNIEnv *jni_env, jclass testedCls) { for (k=0; kGetMethodID(cl, name, sig); } - if (mid == NULL) { + if (mid == nullptr) { printf("Name = %s, sig = %s: mid = 0\n", name, sig); result = STATUS_FAILED; return; @@ -77,7 +77,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMaxLocals/maxloc002/maxloc002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMaxLocals/maxloc002/maxloc002.cpp index 6fbea7d6a5a..81851e1e282 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMaxLocals/maxloc002/maxloc002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMaxLocals/maxloc002/maxloc002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_maxloc002(JavaVM *jvm, char *options, void *reserved) jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -70,13 +70,13 @@ Java_nsk_jvmti_GetMaxLocals_maxloc002_check(JNIEnv *env, jclass cls) { jmethodID mid; jint max; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } mid = env->GetMethodID(cls, "", "()V"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot get method ID for \"\"!\n"); return STATUS_FAILED; } @@ -84,7 +84,7 @@ Java_nsk_jvmti_GetMaxLocals_maxloc002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> invalid method check ...\n"); } - err = jvmti->GetMaxLocals(NULL, &max); + err = jvmti->GetMaxLocals(nullptr, &max); if (err != JVMTI_ERROR_INVALID_METHODID) { printf("Error expected: JVMTI_ERROR_INVALID_METHODID,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -94,7 +94,7 @@ Java_nsk_jvmti_GetMaxLocals_maxloc002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> null pointer check ...\n"); } - err = jvmti->GetMaxLocals(mid, NULL); + err = jvmti->GetMaxLocals(mid, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { printf("Error expected: JVMTI_ERROR_NULL_POINTER,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -102,7 +102,7 @@ Java_nsk_jvmti_GetMaxLocals_maxloc002_check(JNIEnv *env, jclass cls) { } mid = env->GetStaticMethodID(cls, "check", "()I"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot get method ID for \"check\"!\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodDeclaringClass/declcls001/declcls001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodDeclaringClass/declcls001/declcls001.cpp index ec3691af227..bfb2441f7dc 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodDeclaringClass/declcls001/declcls001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodDeclaringClass/declcls001/declcls001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,8 +49,8 @@ void checkMeth(JNIEnv *env, const char *cl_name, const char *name, const char *s } else { mid = env->GetMethodID(cl, name, sig); } - if (mid == NULL) { - printf("%s.%s%s: mid = NULL\n", cl_name, name, sig); + if (mid == nullptr) { + printf("%s.%s%s: mid = null\n", cl_name, name, sig); result = STATUS_FAILED; return; } @@ -95,7 +95,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodDeclaringClass/declcls002/declcls002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodDeclaringClass/declcls002/declcls002.cpp index a923fd4d950..8edd98ab96e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodDeclaringClass/declcls002/declcls002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodDeclaringClass/declcls002/declcls002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_declcls002(JavaVM *jvm, char *options, void *reserved) jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -70,13 +70,13 @@ Java_nsk_jvmti_GetMethodDeclaringClass_declcls002_check(JNIEnv *env, jclass cls) jmethodID mid; jclass declaringClass; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } mid = env->GetMethodID(cls, "", "()V"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot get method ID!\n"); return STATUS_FAILED; } @@ -84,7 +84,7 @@ Java_nsk_jvmti_GetMethodDeclaringClass_declcls002_check(JNIEnv *env, jclass cls) if (printdump == JNI_TRUE) { printf(">>> invalid method check ...\n"); } - err = jvmti->GetMethodDeclaringClass(NULL, &declaringClass); + err = jvmti->GetMethodDeclaringClass(nullptr, &declaringClass); if (err != JVMTI_ERROR_INVALID_METHODID) { printf("Error expected: JVMTI_ERROR_INVALID_METHODID,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -94,7 +94,7 @@ Java_nsk_jvmti_GetMethodDeclaringClass_declcls002_check(JNIEnv *env, jclass cls) if (printdump == JNI_TRUE) { printf(">>> null pointer check ...\n"); } - err = jvmti->GetMethodDeclaringClass(mid, NULL); + err = jvmti->GetMethodDeclaringClass(mid, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { printf("Error expected: JVMTI_ERROR_NULL_POINTER,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodDeclaringClass/declcls003/declcls003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodDeclaringClass/declcls003/declcls003.cpp index 8f447709770..ca7bce9eb81 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodDeclaringClass/declcls003/declcls003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodDeclaringClass/declcls003/declcls003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; static const char *exp_class_sig = "Ljava/lang/Object;"; @@ -55,8 +55,8 @@ void do_check(JNIEnv *env, const char *name, const char *meth, const char *sig) cl = env->FindClass(name); mid = env->GetMethodID(cl, meth, sig); - if (mid == NULL) { - printf("%s.%s%s: mid = NULL\n", name, meth, sig); + if (mid == nullptr) { + printf("%s.%s%s: mid = null\n", name, meth, sig); result = STATUS_FAILED; return; } @@ -105,12 +105,12 @@ JNIEXPORT jint JNI_OnLoad_declcls003(JavaVM *jvm, char *options, void *reserved) jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodLocation/methloc001/methloc001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodLocation/methloc001/methloc001.cpp index c8e9cd6c730..53978f36efe 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodLocation/methloc001/methloc001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodLocation/methloc001/methloc001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -59,8 +59,8 @@ void checkMeth(JNIEnv *env, jclass cl, const char *name, const char *sig, } else { mid = env->GetMethodID(cl, name, sig); } - if (mid == NULL) { - printf("Name = %s, sig = %s: mid = NULL\n", name, sig); + if (mid == nullptr) { + printf("Name = %s, sig = %s: mid = null\n", name, sig); result = STATUS_FAILED; return; } @@ -103,7 +103,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodLocation/methloc002/methloc002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodLocation/methloc002/methloc002.cpp index 858553a7d85..2e596dd7861 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodLocation/methloc002/methloc002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodLocation/methloc002/methloc002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_methloc002(JavaVM *jvm, char *options, void *reserved) jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -71,13 +71,13 @@ Java_nsk_jvmti_GetMethodLocation_methloc002_check(JNIEnv *env, jclass cls) { jlocation startLocation; jlocation endLocation; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } mid = env->GetMethodID(cls, "", "()V"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot get method ID for \"\"!\n"); return STATUS_FAILED; } @@ -85,7 +85,7 @@ Java_nsk_jvmti_GetMethodLocation_methloc002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> invalid method check ...\n"); } - err = jvmti->GetMethodLocation(NULL, &startLocation, &endLocation); + err = jvmti->GetMethodLocation(nullptr, &startLocation, &endLocation); if (err != JVMTI_ERROR_INVALID_METHODID) { printf("Error expected: JVMTI_ERROR_INVALID_METHODID,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -95,7 +95,7 @@ Java_nsk_jvmti_GetMethodLocation_methloc002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> (startLocationPtr) null pointer check ...\n"); } - err = jvmti->GetMethodLocation(mid, NULL, &endLocation); + err = jvmti->GetMethodLocation(mid, nullptr, &endLocation); if (err != JVMTI_ERROR_NULL_POINTER) { printf("(startLocationPtr) error expected: JVMTI_ERROR_NULL_POINTER,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -105,7 +105,7 @@ Java_nsk_jvmti_GetMethodLocation_methloc002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> (endLocationPtr) null pointer check ...\n"); } - err = jvmti->GetMethodLocation(mid, &startLocation, NULL); + err = jvmti->GetMethodLocation(mid, &startLocation, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { printf("(endLocationPtr) error expected: JVMTI_ERROR_NULL_POINTER,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -113,7 +113,7 @@ Java_nsk_jvmti_GetMethodLocation_methloc002_check(JNIEnv *env, jclass cls) { } mid = env->GetStaticMethodID(cls, "check", "()I"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot get method ID for \"check\"!\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodModifiers/methmod001/methmod001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodModifiers/methmod001/methmod001.cpp index 838adc03019..3b44d8daf4c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodModifiers/methmod001/methmod001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodModifiers/methmod001/methmod001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ extern "C" { #define ACC_NATIVE 0x100 #define ACC_ABSTRACT 0x400 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -70,7 +70,7 @@ void checkMeth(jvmtiEnv *jvmti_env, JNIEnv *env, jclass cl, } else { mid = env->GetMethodID(cl, name, sig); } - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot find MethodID for \"%s%s\"\n", name, sig); result = STATUS_FAILED; return; @@ -135,12 +135,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -154,7 +154,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_CLASS_LOAD, NULL); + JVMTI_EVENT_CLASS_LOAD, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable event JVMTI_EVENT_CLASS_LOAD: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodModifiers/methmod002/methmod002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodModifiers/methmod002/methmod002.cpp index 5542a3d35fc..02fc2a5ba77 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodModifiers/methmod002/methmod002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodModifiers/methmod002/methmod002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_methmod002(JavaVM *jvm, char *options, void *reserved) jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -70,13 +70,13 @@ Java_nsk_jvmti_GetMethodModifiers_methmod002_check(JNIEnv *env, jclass cls) { jmethodID mid; jint modifiers; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } mid = env->GetMethodID(cls, "", "()V"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot get method ID!\n"); return STATUS_FAILED; } @@ -84,7 +84,7 @@ Java_nsk_jvmti_GetMethodModifiers_methmod002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> invalid method check ...\n"); } - err = jvmti->GetMethodModifiers(NULL, &modifiers); + err = jvmti->GetMethodModifiers(nullptr, &modifiers); if (err != JVMTI_ERROR_INVALID_METHODID) { printf("Error expected: JVMTI_ERROR_INVALID_METHODID,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -94,7 +94,7 @@ Java_nsk_jvmti_GetMethodModifiers_methmod002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> null pointer check ...\n"); } - err = jvmti->GetMethodModifiers(mid, NULL); + err = jvmti->GetMethodModifiers(mid, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { printf("Error expected: JVMTI_ERROR_NULL_POINTER,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodName/methname001/methname001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodName/methname001/methname001.cpp index 79c0db9c6af..6c4dcbb889e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodName/methname001/methname001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodName/methname001/methname001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -50,7 +50,7 @@ void checkMeth(jvmtiEnv *jvmti_env, JNIEnv *env, jclass cl, } else { mid = env->GetMethodID(cl, name, sig); } - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot find MethodID for \"%s%s\"\n", name, sig); result = STATUS_FAILED; return; @@ -115,12 +115,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -134,7 +134,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_CLASS_LOAD, NULL); + JVMTI_EVENT_CLASS_LOAD, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable event JVMTI_EVENT_CLASS_LOAD: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodName/methname002/methname002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodName/methname002/methname002.cpp index 292d5f2b4be..bd503a6ae8c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodName/methname002/methname002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodName/methname002/methname002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_methname002(JavaVM *jvm, char *options, void *reserved jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -70,13 +70,13 @@ Java_nsk_jvmti_GetMethodName_methname002_check(JNIEnv *env, jclass cls) { jmethodID mid; char *name, *sig, *generic; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } mid = env->GetMethodID(cls, "", "()V"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot get method ID!\n"); return STATUS_FAILED; } @@ -84,7 +84,7 @@ Java_nsk_jvmti_GetMethodName_methname002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> invalid method check ...\n"); } - err = jvmti->GetMethodName(NULL, &name, &sig, &generic); + err = jvmti->GetMethodName(nullptr, &name, &sig, &generic); if (err != JVMTI_ERROR_INVALID_METHODID) { printf("Error expected: JVMTI_ERROR_INVALID_METHODID,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -94,7 +94,7 @@ Java_nsk_jvmti_GetMethodName_methname002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> (namePtr) null pointer check ...\n"); } - err = jvmti->GetMethodName(mid, NULL, &sig, &generic); + err = jvmti->GetMethodName(mid, nullptr, &sig, &generic); if (err != JVMTI_ERROR_NONE) { printf("(namePtr) unexpected error: %s (%d)\n", TranslateError(err), err); @@ -103,7 +103,7 @@ Java_nsk_jvmti_GetMethodName_methname002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> sig = \"%s\", generic = \"%s\"\n", sig, generic); } - if (sig == NULL || strcmp(sig, "()V") != 0) { + if (sig == nullptr || strcmp(sig, "()V") != 0) { printf("Wrong field sig: \"%s\", expected: \"I\"\n", sig); result = STATUS_FAILED; } @@ -112,7 +112,7 @@ Java_nsk_jvmti_GetMethodName_methname002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> (signaturePtr) null pointer check ...\n"); } - err = jvmti->GetMethodName(mid, &name, NULL, &generic); + err = jvmti->GetMethodName(mid, &name, nullptr, &generic); if (err != JVMTI_ERROR_NONE) { printf("(signaturePtr) unexpected error: %s (%d)\n", TranslateError(err), err); @@ -121,7 +121,7 @@ Java_nsk_jvmti_GetMethodName_methname002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> name = \"%s\", generic = \"%s\"\n", name, generic); } - if (name == NULL || strcmp(name, "") != 0) { + if (name == nullptr || strcmp(name, "") != 0) { printf("Wrong field name: \"%s\", expected: \"fld\"\n", name); result = STATUS_FAILED; } @@ -130,7 +130,7 @@ Java_nsk_jvmti_GetMethodName_methname002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> (genericPtr) null pointer check ...\n"); } - err = jvmti->GetMethodName(mid, &name, &sig, NULL); + err = jvmti->GetMethodName(mid, &name, &sig, nullptr); if (err != JVMTI_ERROR_NONE) { printf("(signaturePtr) unexpected error: %s (%d)\n", TranslateError(err), err); @@ -139,11 +139,11 @@ Java_nsk_jvmti_GetMethodName_methname002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> name = \"%s\", sig = \"%s\"\n", name, sig); } - if (name == NULL || strcmp(name, "") != 0) { + if (name == nullptr || strcmp(name, "") != 0) { printf("Wrong field name: \"%s\", expected: \"fld\"\n", name); result = STATUS_FAILED; } - if (sig == NULL || strcmp(sig, "()V") != 0) { + if (sig == nullptr || strcmp(sig, "()V") != 0) { printf("Wrong field sig: \"%s\", expected: \"I\"\n", sig); result = STATUS_FAILED; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodName/methname003/methname003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodName/methname003/methname003.cpp index 669500625f1..a7a3a44022f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodName/methname003/methname003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetMethodName/methname003/methname003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -60,14 +60,14 @@ static const char *meth_sig[][METH_NUM][TOT_NUM] = { { { "methname003eMeth", "instance", "(Lnsk/jvmti/GetMethodName/methname003e;)V", - "NULL" }, + "null" }, { "methname003eMethSt", "static", "(Lnsk/jvmti/GetMethodName/methname003e;)V", - "NULL" } }, + "null" } }, { { "methname003ifMeth", "instance", "()I", - "NULL" }, + "null" }, { "methname003ifMeth2", "instance", "(Ljava/lang/Object;)I", "(TT;)I" } }, @@ -80,7 +80,7 @@ static const char *meth_sig[][METH_NUM][TOT_NUM] = { "(TA;TB;)V" } } }; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static int checkSig(JNIEnv *jni_env, jmethodID testedMeth, int instance, int clsIdx, int methIdx) { @@ -98,17 +98,17 @@ static int checkSig(JNIEnv *jni_env, jmethodID testedMeth, meth_sig[clsIdx][methIdx][0]); if (strcmp(meth_sig[clsIdx][methIdx][2], sign) != 0 || - strcmp(meth_sig[clsIdx][methIdx][3], (gen_sign == NULL) ? "NULL" : gen_sign) != 0) { + strcmp(meth_sig[clsIdx][methIdx][3], (gen_sign == nullptr) ? "null" : gen_sign) != 0) { NSK_COMPLAIN5("TEST FAILED: class: \"%s\" \ has\n\tsignature: \"%s\"\n\tgeneric signature: \"%s\"\n\n\tExpected: \"%s\"\n\t\t\"%s\"\n\n", meth_sig[clsIdx][methIdx][0], - sign, (gen_sign == NULL) ? "NULL" : gen_sign, + sign, (gen_sign == nullptr) ? "null" : gen_sign, meth_sig[clsIdx][methIdx][2], meth_sig[clsIdx][methIdx][3]); totRes = STATUS_FAILED; } else NSK_DISPLAY2("CHECK PASSED: signature: \"%s\",\n\tgeneric signature: \"%s\"\n", - sign, (gen_sign == NULL) ? "NULL" : gen_sign); + sign, (gen_sign == nullptr) ? "null" : gen_sign); NSK_DISPLAY0("Deallocating name & signature arrays\n"); if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*) name))) { @@ -117,7 +117,7 @@ has\n\tsignature: \"%s\"\n\tgeneric signature: \"%s\"\n\n\tExpected: \"%s\"\n\t\ if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*) sign))) { totRes = STATUS_FAILED; } - if (gen_sign != NULL) + if (gen_sign != nullptr) if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*) gen_sign))) { totRes = STATUS_FAILED; } @@ -130,7 +130,7 @@ JNIEXPORT jint JNICALL Java_nsk_jvmti_GetMethodName_methname003_check( JNIEnv *jni, jobject obj, jobject testedObj, jint clsIdx) { int res = PASSED, i, instance; - jmethodID testedMeth = NULL; + jmethodID testedMeth = nullptr; jclass objCls = jni->GetObjectClass(testedObj); for (i=0; iGetMethodID(objCls, meth_sig[clsIdx][i][0], meth_sig[clsIdx][i][2])) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (testedMeth = jni->GetMethodID(objCls, meth_sig[clsIdx][i][0], meth_sig[clsIdx][i][2])) != nullptr)) { NSK_COMPLAIN2("TEST FAILERE: unable to get method ID for \"%s\" \"%s\"\n\n", meth_sig[clsIdx][i][0], meth_sig[clsIdx][i][2]); res = STATUS_FAILED; @@ -148,7 +148,7 @@ Java_nsk_jvmti_GetMethodName_methname003_check( } } else - if (!NSK_JNI_VERIFY(jni, (testedMeth = jni->GetStaticMethodID(objCls, meth_sig[clsIdx][i][0], meth_sig[clsIdx][i][2])) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (testedMeth = jni->GetStaticMethodID(objCls, meth_sig[clsIdx][i][0], meth_sig[clsIdx][i][2])) != nullptr)) { NSK_COMPLAIN2("TEST FAILERE: unable to get method ID for \"%s\" \"%s\"\n\n", meth_sig[clsIdx][i][0], meth_sig[clsIdx][i][2]); res = STATUS_FAILED; @@ -184,7 +184,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectHashCode/objhashcode001/objhashcode001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectHashCode/objhashcode001/objhashcode001.cpp index da85ff4c539..2931d0b0319 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectHashCode/objhashcode001/objhashcode001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectHashCode/objhashcode001/objhashcode001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,16 +51,16 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { /* perform testing */ { - jobject testedObject = NULL; + jobject testedObject = nullptr; jint objectHashCode = 0; NSK_DISPLAY0(">>> Obtain tested object from a static field of debugee class\n"); { - jclass debugeeClass = NULL; - jfieldID objectField = NULL; + jclass debugeeClass = nullptr; + jfieldID objectField = nullptr; NSK_DISPLAY1("Find debugee class: %s\n", DEBUGEE_CLASS_NAME); - if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -68,7 +68,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY1("Find static field: %s\n", OBJECT_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (objectField = - jni->GetStaticFieldID(debugeeClass, OBJECT_FIELD_NAME, OBJECT_CLASS_SIG)) != NULL)) { + jni->GetStaticFieldID(debugeeClass, OBJECT_FIELD_NAME, OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -76,14 +76,14 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY1("Get object from static field: %s\n", OBJECT_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (testedObject = - jni->GetStaticObjectField(debugeeClass, objectField)) != NULL)) { + jni->GetStaticObjectField(debugeeClass, objectField)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY1(" ... got object: %p\n", (void*)testedObject); NSK_DISPLAY1("Create global reference for object: %p\n", (void*)testedObject); - if (!NSK_JNI_VERIFY(jni, (testedObject = jni->NewGlobalRef(testedObject)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (testedObject = jni->NewGlobalRef(testedObject)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -180,7 +180,7 @@ JNIEXPORT jint JNI_OnLoad_objhashcode001(JavaVM *jvm, char *options, void *reser } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -190,11 +190,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage001/objmonusage001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage001/objmonusage001.cpp index de518c2240f..a02179847f6 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage001/objmonusage001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage001/objmonusage001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -53,12 +53,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } @@ -117,7 +117,7 @@ Java_nsk_jvmti_GetObjectMonitorUsage_objmonusage001_check(JNIEnv *env, } if (printdump == JNI_TRUE) { - if (inf.owner == NULL) { + if (inf.owner == nullptr) { printf(">>> [%2d] owner: none (0x0)\n", i); } else { jvmti->GetThreadInfo(inf.owner, &tinf); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage002/objmonusage002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage002/objmonusage002.cpp index dda31c173b1..2dd0eaa24f0 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage002/objmonusage002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage002/objmonusage002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -53,12 +53,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -97,7 +97,7 @@ Java_nsk_jvmti_GetObjectMonitorUsage_objmonusage002_check(JNIEnv *env, jvmtiError err; jvmtiMonitorUsage inf; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -105,7 +105,7 @@ Java_nsk_jvmti_GetObjectMonitorUsage_objmonusage002_check(JNIEnv *env, if (printdump == JNI_TRUE) { printf(">>> invalid object check ...\n"); } - err = jvmti->GetObjectMonitorUsage(NULL, &inf); + err = jvmti->GetObjectMonitorUsage(nullptr, &inf); if (err == JVMTI_ERROR_MUST_POSSESS_CAPABILITY && !caps.can_get_monitor_info) { /* Ok, it's expected */ @@ -118,7 +118,7 @@ Java_nsk_jvmti_GetObjectMonitorUsage_objmonusage002_check(JNIEnv *env, if (printdump == JNI_TRUE) { printf(">>> null pointer check ...\n"); } - err = jvmti->GetObjectMonitorUsage(obj, NULL); + err = jvmti->GetObjectMonitorUsage(obj, nullptr); if (err == JVMTI_ERROR_MUST_POSSESS_CAPABILITY && !caps.can_get_monitor_info) { /* Ok, it's expected */ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage003/objmonusage003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage003/objmonusage003.cpp index b9d8346c879..d696fa08c4f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage003/objmonusage003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage003/objmonusage003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -54,12 +54,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } @@ -116,7 +116,7 @@ Java_nsk_jvmti_GetObjectMonitorUsage_objmonusage003_check(JNIEnv *env, } if (printdump == JNI_TRUE) { - if (inf.owner == NULL) { + if (inf.owner == nullptr) { printf(">>> [%2d] owner: none (0x0)\n", count); } else { err = jvmti->GetThreadInfo(inf.owner, &tinf); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage004/objmonusage004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage004/objmonusage004.cpp index 34e340e1f65..47be3771376 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage004/objmonusage004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage004/objmonusage004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -54,12 +54,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } @@ -116,7 +116,7 @@ Java_nsk_jvmti_GetObjectMonitorUsage_objmonusage004_check(JNIEnv *env, } if (printdump == JNI_TRUE) { - if (inf.owner == NULL) { + if (inf.owner == nullptr) { printf(">>> [%2d] owner: none (0x0)\n", count); } else { err = jvmti->GetThreadInfo(inf.owner, &tinf); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage005/objmonusage005.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage005/objmonusage005.cpp index 881607b4678..36aed3377ca 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage005/objmonusage005.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage005/objmonusage005.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; @@ -53,7 +53,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage006/objmonusage006.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage006/objmonusage006.cpp index 460abfd41c7..2be448e7342 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage006/objmonusage006.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectMonitorUsage/objmonusage006/objmonusage006.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; @@ -53,7 +53,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectSize/objsize001/objsize001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectSize/objsize001/objsize001.cpp index 10860792e17..87dfb9c40f7 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectSize/objsize001/objsize001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectSize/objsize001/objsize001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -48,16 +48,16 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { return; { - jobject testedObject = NULL; + jobject testedObject = nullptr; jlong objectSize = 0; NSK_DISPLAY0(">>> Obtain tested object from a static field of debugee class\n"); { - jclass debugeeClass = NULL; - jfieldID objectField = NULL; + jclass debugeeClass = nullptr; + jfieldID objectField = nullptr; NSK_DISPLAY1("Find debugee class: %s\n", DEBUGEE_CLASS_NAME); - if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -65,7 +65,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY1("Find static field: %s\n", OBJECT_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (objectField = - jni->GetStaticFieldID(debugeeClass, OBJECT_FIELD_NAME, OBJECT_CLASS_SIG)) != NULL)) { + jni->GetStaticFieldID(debugeeClass, OBJECT_FIELD_NAME, OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -73,14 +73,14 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY1("Get object from static field: %s\n", OBJECT_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (testedObject = - jni->GetStaticObjectField(debugeeClass, objectField)) != NULL)) { + jni->GetStaticObjectField(debugeeClass, objectField)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY1(" ... got object: 0x%p\n", (void*)testedObject); NSK_DISPLAY1("Create global reference for object: 0x%p\n", (void*)testedObject); - if (!NSK_JNI_VERIFY(jni, (testedObject = jni->NewGlobalRef(testedObject)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (testedObject = jni->NewGlobalRef(testedObject)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -180,7 +180,7 @@ JNIEXPORT jint JNI_OnLoad_objsize001(JavaVM *jvm, char *options, void *reserved) } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -188,10 +188,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectsWithTags/objwithtags001/objwithtags001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectsWithTags/objwithtags001/objwithtags001.cpp index d6ea8445774..c2f4d92e318 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectsWithTags/objwithtags001/objwithtags001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetObjectsWithTags/objwithtags001/objwithtags001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,9 +56,9 @@ static int objectsCount = 0; /** Obtain tested objects from static field of debugee class. */ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int tagsCount, int objectsCount, jobject* *objects, jlong* *tags) { - jclass debugeeClass = NULL; - jfieldID objectField = NULL; - jobjectArray arrayObject = NULL; + jclass debugeeClass = nullptr; + jfieldID objectField = nullptr; + jobjectArray arrayObject = nullptr; int size = tagsCount * objectsCount; NSK_DISPLAY2("Allocate memory for lists: %d objects for %d tags\n", @@ -78,7 +78,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int tagsCount, int obj { int i, k; for (k = 0; k < size; k++) { - (*objects)[k] = NULL; + (*objects)[k] = nullptr; } for (i = 0; i < tagsCount; i++) { @@ -87,7 +87,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int tagsCount, int obj } NSK_DISPLAY1("Find debugee class: %s\n", DEBUGEE_CLASS_NAME); - if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -95,7 +95,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int tagsCount, int obj NSK_DISPLAY1("Find static field: %s\n", OBJECTS_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (objectField = - jni->GetStaticFieldID(debugeeClass, OBJECTS_FIELD_NAME, OBJECTS_FIELD_SIG)) != NULL)) { + jni->GetStaticFieldID(debugeeClass, OBJECTS_FIELD_NAME, OBJECTS_FIELD_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -103,7 +103,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int tagsCount, int obj NSK_DISPLAY1("Get objects array from static field: %s\n", OBJECTS_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (arrayObject = (jobjectArray) - jni->GetStaticObjectField(debugeeClass, objectField)) != NULL)) { + jni->GetStaticObjectField(debugeeClass, objectField)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -121,13 +121,13 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int tagsCount, int obj NSK_DISPLAY1(" ... got array length: %d\n", (int)size); for (k = 0; k < size; k++) { - jobject object = NULL; + jobject object = nullptr; - if (!NSK_JNI_VERIFY(jni, (object = jni->GetObjectArrayElement(arrayObject, k)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (object = jni->GetObjectArrayElement(arrayObject, k)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } - if (!NSK_JNI_VERIFY(jni, (object = jni->NewGlobalRef(object)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (object = jni->NewGlobalRef(object)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -146,12 +146,12 @@ static int releaseTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int tagsCount, int int size = tagsCount * objectsCount; int k; - if (objects == NULL) + if (objects == nullptr) return NSK_TRUE; NSK_DISPLAY1("Release objects references: %d objects\n", size); for (k = 0; k < size; k++) { - if (objects[k] != NULL) { + if (objects[k] != nullptr) { NSK_TRACE(jni->DeleteGlobalRef(objects[k])); } } @@ -163,7 +163,7 @@ static int releaseTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int tagsCount, int nsk_jvmti_setFailStatus(); } - if (tags == NULL) + if (tags == nullptr) return NSK_FALSE; NSK_DISPLAY1("Deallocate tags list: 0x%p\n", (void*)tags); @@ -180,8 +180,8 @@ static int checkTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int tagsCount, int o jlong tags[], jobject objects[], const char kind[], int expectedCount) { jint taggedObjectsCount = 0; - jobject* taggedObjectsList = NULL; - jlong* taggedObjectsTags = NULL; + jobject* taggedObjectsList = nullptr; + jlong* taggedObjectsTags = nullptr; jlong expectedTag = 0; int k; @@ -201,15 +201,15 @@ static int checkTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int tagsCount, int o nsk_jvmti_setFailStatus(); } - if (taggedObjectsList == NULL && taggedObjectsCount > 0) { - NSK_COMPLAIN2("GetObjectsWithTags() returns NULL list of objects %s: 0x%p\n", + if (taggedObjectsList == nullptr && taggedObjectsCount > 0) { + NSK_COMPLAIN2("GetObjectsWithTags() returns null list of objects %s: 0x%p\n", kind, (void*)taggedObjectsList); nsk_jvmti_setFailStatus(); return NSK_TRUE; } - if (taggedObjectsTags == NULL && taggedObjectsCount > 0) { - NSK_COMPLAIN2("GetObjectsWithTags() returns NULL list of tags for objects %s: 0x%p\n", + if (taggedObjectsTags == nullptr && taggedObjectsCount > 0) { + NSK_COMPLAIN2("GetObjectsWithTags() returns null list of tags for objects %s: 0x%p\n", kind, (void*)taggedObjectsTags); nsk_jvmti_setFailStatus(); return NSK_TRUE; @@ -223,8 +223,8 @@ static int checkTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int tagsCount, int o NSK_DISPLAY3(" #%d: object: 0x%p, tag: %ld\n", k, (void*)object, (long)tag); - if (object == NULL) { - NSK_COMPLAIN3("GetObjectsWithTags() returns NULL for object #%d %s: 0x%p\n", + if (object == nullptr) { + NSK_COMPLAIN3("GetObjectsWithTags() returns null for object #%d %s: 0x%p\n", k, kind, (void*)object); nsk_jvmti_setFailStatus(); continue; @@ -306,8 +306,8 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { /* perform testing */ { int size = tagsCount * objectsCount; - jobject* objects = NULL; - jlong* tags = NULL; + jobject* objects = nullptr; + jlong* tags = nullptr; NSK_DISPLAY0(">>> Obtain tested objects list from a static field of debugee class\n"); { @@ -417,7 +417,7 @@ JNIEXPORT jint JNI_OnLoad_objwithtags001(JavaVM *jvm, char *options, void *reser } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -433,7 +433,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add required capabilities */ @@ -448,7 +448,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetOwnedMonitorInfo/ownmoninf001/ownmoninf001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetOwnedMonitorInfo/ownmoninf001/ownmoninf001.cpp index 3d304530135..e86bf820b34 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetOwnedMonitorInfo/ownmoninf001/ownmoninf001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetOwnedMonitorInfo/ownmoninf001/ownmoninf001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; @@ -53,7 +53,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } @@ -89,7 +89,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jobject *getInfo(JNIEnv *env, jint point, jthread thr, int count) { jvmtiError err; jint owned_monitor_count; - jobject *owned_monitors = NULL; + jobject *owned_monitors = nullptr; err = jvmti->GetOwnedMonitorInfo(thr, &owned_monitor_count, &owned_monitors); @@ -100,13 +100,13 @@ jobject *getInfo(JNIEnv *env, jint point, jthread thr, int count) { printf("(GetOwnedMonitorInfo#%d) unexpected error: %s (%d)\n", point, TranslateError(err), err); result = STATUS_FAILED; - return NULL; + return nullptr; } else { if (owned_monitor_count != count) { result = STATUS_FAILED; printf("Point %d: number of owned monitors expected: %d, got: %d\n", point, count, owned_monitor_count); - return NULL; + return nullptr; } } return owned_monitors; @@ -123,7 +123,7 @@ Java_nsk_jvmti_GetOwnedMonitorInfo_ownmoninf001_checkMon1(JNIEnv *env, jclass cls, jint point, jthread thr, jobject lock) { jobject *monitors; monitors = getInfo(env, point, thr, 1); - if (monitors == NULL) { + if (monitors == nullptr) { return; } if (!env->IsSameObject(lock, monitors[0])) { @@ -137,7 +137,7 @@ Java_nsk_jvmti_GetOwnedMonitorInfo_ownmoninf001_checkMon2(JNIEnv *env, jclass cls, jint point, jthread thr, jobject lock1, jobject lock2) { jobject *monitors; monitors = getInfo(env, point, thr, 2); - if (monitors == NULL) { + if (monitors == nullptr) { return; } if (!env->IsSameObject(lock1, monitors[0]) && !env->IsSameObject(lock2, monitors[0])) { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetOwnedMonitorInfo/ownmoninf002/ownmoninf002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetOwnedMonitorInfo/ownmoninf002/ownmoninf002.cpp index 7ad4e1b0ef3..f5c13cfe71d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetOwnedMonitorInfo/ownmoninf002/ownmoninf002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetOwnedMonitorInfo/ownmoninf002/ownmoninf002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; @@ -53,7 +53,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetOwnedMonitorInfo/ownmoninf003/ownmoninf003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetOwnedMonitorInfo/ownmoninf003/ownmoninf003.cpp index 83b39f17aaa..975be49082b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetOwnedMonitorInfo/ownmoninf003/ownmoninf003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetOwnedMonitorInfo/ownmoninf003/ownmoninf003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -53,12 +53,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } @@ -98,7 +98,7 @@ Java_nsk_jvmti_GetOwnedMonitorInfo_ownmoninf003_check(JNIEnv *env, jint owned_monitor_count; jobject *owned_monitors; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -120,7 +120,7 @@ Java_nsk_jvmti_GetOwnedMonitorInfo_ownmoninf003_check(JNIEnv *env, if (printdump == JNI_TRUE) { printf(">>> (owned_monitor_count_ptr) null pointer check ...\n"); } - err = jvmti->GetOwnedMonitorInfo(thr, NULL, &owned_monitors); + err = jvmti->GetOwnedMonitorInfo(thr, nullptr, &owned_monitors); if (err == JVMTI_ERROR_MUST_POSSESS_CAPABILITY && !caps.can_get_monitor_info) { /* Ok, it's expected */ @@ -133,7 +133,7 @@ Java_nsk_jvmti_GetOwnedMonitorInfo_ownmoninf003_check(JNIEnv *env, if (printdump == JNI_TRUE) { printf(">>> (owned_monitors_ptr) null pointer check ...\n"); } - err = jvmti->GetOwnedMonitorInfo(thr, &owned_monitor_count, NULL); + err = jvmti->GetOwnedMonitorInfo(thr, &owned_monitor_count, nullptr); if (err == JVMTI_ERROR_MUST_POSSESS_CAPABILITY && !caps.can_get_monitor_info) { /* Ok, it's expected */ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetPhase/getphase001/getphase001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetPhase/getphase001/getphase001.cpp index e3c4df42cba..70228ae0274 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetPhase/getphase001/getphase001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetPhase/getphase001/getphase001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -268,7 +268,7 @@ JNIEXPORT jint JNI_OnLoad_getphase001(JavaVM *jvm, char *options, void *reserved } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv *jvmti = NULL; + jvmtiEnv *jvmti = nullptr; jvmtiPhase phase; jvmtiCapabilities caps; jvmtiEventCallbacks callbacks; @@ -284,7 +284,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* Create data access lock */ @@ -319,31 +319,31 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* enable VMStart event */ if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_START, NULL))) + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_START, nullptr))) return JNI_ERR; /* enable VMInit event */ if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL))) + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, nullptr))) return JNI_ERR; /* enable NativeMethodBind event */ if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_NATIVE_METHOD_BIND, NULL))) + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_NATIVE_METHOD_BIND, nullptr))) return JNI_ERR; /* enable ClassFileLoadHook event */ if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL))) + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, nullptr))) return JNI_ERR; /* enable VMDeath event */ if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL))) + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, nullptr))) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetPhase/getphase002/getphase002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetPhase/getphase002/getphase002.cpp index e1d03830f70..ec67d08a9f6 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetPhase/getphase002/getphase002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetPhase/getphase002/getphase002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -45,9 +45,9 @@ agentProc(jvmtiEnv *jvmti, JNIEnv* jni, void* arg) { if (!nsk_jvmti_waitForSync(timeout)) return; - NSK_DISPLAY0("Check if GetPhase(NULL) returns JVMTI_ERROR_NULL_POINTER\n"); + NSK_DISPLAY0("Check if GetPhase(null) returns JVMTI_ERROR_NULL_POINTER\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_NULL_POINTER, - jvmti->GetPhase(NULL))) + jvmti->GetPhase(nullptr))) nsk_jvmti_setFailStatus(); /* resume debugee after last sync */ @@ -70,7 +70,7 @@ JNIEXPORT jint JNI_OnLoad_getphase002(JavaVM *jvm, char *options, void *reserved } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv *jvmti = NULL; + jvmtiEnv *jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -83,11 +83,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetPotentialCapabilities/getpotcaps001/getpotcaps001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetPotentialCapabilities/getpotcaps001/getpotcaps001.cpp index 0e5d7159d27..f69b88176f1 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetPotentialCapabilities/getpotcaps001/getpotcaps001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetPotentialCapabilities/getpotcaps001/getpotcaps001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -188,7 +188,7 @@ callbackVMDeath(jvmtiEnv* jvmti, JNIEnv* jni) { success = checkCapabilities(jvmti, "VM_DEATH callback"); NSK_DISPLAY1("Disable events: %d events\n", EVENTS_COUNT); - if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, NULL)) { + if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, nullptr)) { success = NSK_FALSE; } else { NSK_DISPLAY0(" ... disabled\n"); @@ -215,7 +215,7 @@ JNIEXPORT jint JNI_OnLoad_getpotcaps001(JavaVM *jvm, char *options, void *reserv } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -223,7 +223,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; { @@ -239,7 +239,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; NSK_DISPLAY0(">>> Testcase #1: Check capabilities in Agent_OnLoad()\n"); @@ -248,7 +248,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } NSK_DISPLAY1("Enable events: %d events\n", EVENTS_COUNT); - if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, NULL)) { + if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, nullptr)) { NSK_DISPLAY0(" ... enabled\n"); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceDebugExtension/srcdebugex001/srcdebugex001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceDebugExtension/srcdebugex001/srcdebugex001.cpp index 66e4dbdceeb..ab1125b0037 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceDebugExtension/srcdebugex001/srcdebugex001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceDebugExtension/srcdebugex001/srcdebugex001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } @@ -90,7 +90,7 @@ JNIEXPORT jint JNICALL Java_nsk_jvmti_GetSourceDebugExtension_srcdebugex001_getSrcDebugX(JNIEnv *env, jclass cls, jboolean vrb) { jvmtiError err; - char *srcDebugX = NULL; + char *srcDebugX = nullptr; if (!caps.can_get_source_debug_extension) return result; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceDebugExtension/srcdebugex002/srcdebugex002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceDebugExtension/srcdebugex002/srcdebugex002.cpp index b05b1b38225..420f38f84c6 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceDebugExtension/srcdebugex002/srcdebugex002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceDebugExtension/srcdebugex002/srcdebugex002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } @@ -90,18 +90,18 @@ JNIEXPORT jint JNICALL Java_nsk_jvmti_GetSourceDebugExtension_srcdebugex002_getSrcDebugX(JNIEnv *env, jclass cls, jint t_case) { jvmtiError err; - char *srcDebugX = NULL; + char *srcDebugX = nullptr; jobject invalCls; /* used as invalid class */ if (!caps.can_get_source_debug_extension) return result; switch (t_case) { - case 1: /* NULL pointer in test debug mode */ - printf("\nInvoke GetSourceDebugExtension() with NULL pointer...\n"); + case 1: /* nullptr pointer in test debug mode */ + printf("\nInvoke GetSourceDebugExtension() with null pointer...\n"); fflush(stdout); // fallthrough - case 0: /* NULL pointer */ - err = jvmti->GetSourceDebugExtension(cls, NULL); + case 0: /* nullptr pointer */ + err = jvmti->GetSourceDebugExtension(cls, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { printf("TEST FAILED: the function GetSourceDebugExtension() returned the error %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceDebugExtension/srcdebugex003/srcdebugex003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceDebugExtension/srcdebugex003/srcdebugex003.cpp index e4759cf49df..37fc8742807 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceDebugExtension/srcdebugex003/srcdebugex003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceDebugExtension/srcdebugex003/srcdebugex003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -55,7 +55,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } @@ -92,7 +92,7 @@ JNIEXPORT jint JNICALL Java_nsk_jvmti_GetSourceDebugExtension_srcdebugex003_getSrcDebugX(JNIEnv *env, jclass cls, jboolean vrb) { jvmtiError err; - char *srcDebugX = NULL; + char *srcDebugX = nullptr; if (!caps.can_get_source_debug_extension) return result; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceFileName/getsrcfn004/getsrcfn004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceFileName/getsrcfn004/getsrcfn004.cpp index 18d96711181..e9a2aff2a52 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceFileName/getsrcfn004/getsrcfn004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceFileName/getsrcfn004/getsrcfn004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; static jvmtiCapabilities caps; @@ -53,12 +53,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint code; jvmtiError res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } code = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (code != JNI_OK || jvmti == NULL) { + if (code != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -96,7 +96,7 @@ Java_nsk_jvmti_GetSourceFileName_getsrcfn004_check(JNIEnv *env, jclass cls) { jvmtiError err; char *name; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -104,7 +104,7 @@ Java_nsk_jvmti_GetSourceFileName_getsrcfn004_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> invalid class check ...\n"); } - err = jvmti->GetSourceFileName(NULL, &name); + err = jvmti->GetSourceFileName(nullptr, &name); if (err == JVMTI_ERROR_MUST_POSSESS_CAPABILITY && caps.can_get_source_file_name) { printf("Error expected: JVMTI_ERROR_INVALID_CLASS,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -118,7 +118,7 @@ Java_nsk_jvmti_GetSourceFileName_getsrcfn004_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> null pointer check ...\n"); } - err = jvmti->GetSourceFileName(cls, NULL); + err = jvmti->GetSourceFileName(cls, nullptr); if (err == JVMTI_ERROR_MUST_POSSESS_CAPABILITY && caps.can_get_source_file_name) { printf("Error expected: JVMTI_ERROR_NULL_POINTER,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceFileName/getsrcfn005/getsrcfn005.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceFileName/getsrcfn005/getsrcfn005.cpp index 63676521f85..16bf11e65f1 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceFileName/getsrcfn005/getsrcfn005.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceFileName/getsrcfn005/getsrcfn005.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; static jvmtiCapabilities caps; @@ -53,12 +53,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError res; jint code; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } code = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (code != JNI_OK || jvmti == NULL) { + if (code != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -96,7 +96,7 @@ Java_nsk_jvmti_GetSourceFileName_getsrcfn005_check(JNIEnv *env, jclass cls, jint jvmtiError err; char *name; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceFileName/getsrcfn006/getsrcfn006.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceFileName/getsrcfn006/getsrcfn006.cpp index 9edb42aa836..390c9c1e124 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceFileName/getsrcfn006/getsrcfn006.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSourceFileName/getsrcfn006/getsrcfn006.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; static jvmtiCapabilities caps; @@ -59,12 +59,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError res; jint code; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } code = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (code != JNI_OK || jvmti == NULL) { + if (code != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -102,7 +102,7 @@ Java_nsk_jvmti_GetSourceFileName_getsrcfn006_check(JNIEnv *env, jclass cls, jint jvmtiError err; char *name; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSystemProperties/getsysprops001/getsysprops001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSystemProperties/getsysprops001/getsysprops001.cpp index ec770b75655..13a391227cb 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSystemProperties/getsysprops001/getsysprops001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSystemProperties/getsysprops001/getsysprops001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ static jlong timeout = 0; static int checkProperties(jvmtiEnv* jvmti, const char phase[]) { int success = NSK_TRUE; jint count = 0; - char** properties = NULL; + char** properties = nullptr; NSK_DISPLAY0("Invoke GetSystemProperties()\n"); if (!NSK_JVMTI_VERIFY( @@ -56,8 +56,8 @@ static int checkProperties(jvmtiEnv* jvmti, const char phase[]) { success = NSK_FALSE; } - if (properties == NULL) { - NSK_COMPLAIN2("In %s phase GetSystemProperties() returned NULL pointer for properties list: 0x%p\n", + if (properties == nullptr) { + NSK_COMPLAIN2("In %s phase GetSystemProperties() returned null pointer for properties list: 0x%p\n", phase, (void*)properties); success = NSK_FALSE; } else { @@ -66,8 +66,8 @@ static int checkProperties(jvmtiEnv* jvmti, const char phase[]) { NSK_DISPLAY1("Check each property: %d properties\n", (int)count); for (i = 0; i < count; i++) { NSK_DISPLAY2(" property #%d: [%s]\n", i, nsk_null_string(properties[i])); - if (properties[i] == NULL) { - NSK_COMPLAIN3("In %s phase GetSystemProperties() returned NULL for property #%d: 0x%p\n", + if (properties[i] == nullptr) { + NSK_COMPLAIN3("In %s phase GetSystemProperties() returned null for property #%d: 0x%p\n", phase, i, (void*)properties[i]); success = NSK_FALSE; } @@ -118,7 +118,7 @@ JNIEXPORT jint JNI_OnLoad_getsysprops001(JavaVM *jvm, char *options, void *reser } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -126,7 +126,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; NSK_DISPLAY0(">>> Check system properties in OnLoad phase\n"); @@ -134,7 +134,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { nsk_jvmti_setFailStatus(); } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSystemProperties/getsysprops002/getsysprops002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSystemProperties/getsysprops002/getsysprops002.cpp index a48128e2bc6..81bd1819948 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSystemProperties/getsysprops002/getsysprops002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSystemProperties/getsysprops002/getsysprops002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ static PropertyDesc propDescList[PROPERTIES_COUNT] = { static int checkProperties (jvmtiEnv* jvmti, const char phase[]) { int success = NSK_TRUE; jint count = 0; - char** properties = NULL; + char** properties = nullptr; NSK_DISPLAY0("Get system properties list\n"); if (!NSK_JVMTI_VERIFY( @@ -61,7 +61,7 @@ static int checkProperties (jvmtiEnv* jvmti, const char phase[]) { } NSK_DISPLAY1(" ... got properties: %d\n", (int)count); - if (!NSK_VERIFY(properties != NULL)) { + if (!NSK_VERIFY(properties != nullptr)) { return NSK_FALSE; } @@ -77,7 +77,7 @@ static int checkProperties (jvmtiEnv* jvmti, const char phase[]) { for (i = 0; i < count; i++) { NSK_DISPLAY2(" property #%d: [%s]\n", i, nsk_null_string(properties[i])); - if (properties[i] != NULL) { + if (properties[i] != nullptr) { for (j = 0; j < PROPERTIES_COUNT; j++) { if (strcmp(properties[i], propDescList[j].name) == 0) { NSK_DISPLAY1("SUCCESS: found tested property: %s\n", @@ -150,7 +150,7 @@ JNIEXPORT jint JNI_OnLoad_getsysprops002(JavaVM *jvm, char *options, void *reser } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -158,7 +158,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; NSK_DISPLAY0(">>> Check system properties in OnLoad phase\n"); @@ -166,7 +166,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { nsk_jvmti_setFailStatus(); } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSystemProperty/getsysprop001/getsysprop001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSystemProperty/getsysprop001/getsysprop001.cpp index 126712c66f8..0540d756238 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSystemProperty/getsysprop001/getsysprop001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSystemProperty/getsysprop001/getsysprop001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ static jlong timeout = 0; static int checkProperties(jvmtiEnv* jvmti, const char phase[]) { int success = NSK_TRUE; jint count = 0; - char** properties = NULL; + char** properties = nullptr; NSK_DISPLAY0("Get system properties names\n"); if (!NSK_JVMTI_VERIFY( @@ -47,7 +47,7 @@ static int checkProperties(jvmtiEnv* jvmti, const char phase[]) { } NSK_DISPLAY1(" ... got properties: %d\n", (int)count); - if (!NSK_VERIFY(properties != NULL)) { + if (!NSK_VERIFY(properties != nullptr)) { return NSK_FALSE; } @@ -56,10 +56,10 @@ static int checkProperties(jvmtiEnv* jvmti, const char phase[]) { int i; for (i = 0; i < count; i++) { - char* value = NULL; + char* value = nullptr; NSK_DISPLAY2(" property #%d: [%s]:\n", i, nsk_null_string(properties[i])); - if (!NSK_VERIFY(properties[i] != NULL)) { + if (!NSK_VERIFY(properties[i] != nullptr)) { success = NSK_FALSE; continue; } @@ -71,8 +71,8 @@ static int checkProperties(jvmtiEnv* jvmti, const char phase[]) { } NSK_DISPLAY1(" value: \"%s\"\n", nsk_null_string(value)); - if (value == NULL) { - NSK_COMPLAIN4("In %s phase GetSystemProperty() returned NULL for property #%d:\n" + if (value == nullptr) { + NSK_COMPLAIN4("In %s phase GetSystemProperty() returned null for property #%d:\n" "# property name: %s\n" "# got value: 0x%p\n", phase, i, @@ -131,7 +131,7 @@ JNIEXPORT jint JNI_OnLoad_getsysprop001(JavaVM *jvm, char *options, void *reserv } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -139,7 +139,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; NSK_DISPLAY0(">>> Check system properties in OnLoad phase\n"); @@ -147,7 +147,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { nsk_jvmti_setFailStatus(); } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSystemProperty/getsysprop002/getsysprop002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSystemProperty/getsysprop002/getsysprop002.cpp index a9704eed75b..38687ba8e9a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSystemProperty/getsysprop002/getsysprop002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetSystemProperty/getsysprop002/getsysprop002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ static PropertyDesc propDescList[PROPERTIES_COUNT] = { static int checkProperty(jvmtiEnv* jvmti, const char phase[], PropertyDesc* desc) { int success = NSK_TRUE; - char* value = NULL; + char* value = nullptr; NSK_DISPLAY1("Get value of tested property: %s\n", desc->name); if (!NSK_JVMTI_VERIFY( @@ -58,8 +58,8 @@ static int checkProperty(jvmtiEnv* jvmti, const char phase[], PropertyDesc* desc } NSK_DISPLAY1(" ... got value: \"%s\"\n", nsk_null_string(value)); - if (value == NULL) { - NSK_COMPLAIN4("In %s phase GetSystemProperty() returned NULL value for property:\n" + if (value == nullptr) { + NSK_COMPLAIN4("In %s phase GetSystemProperty() returned null value for property:\n" "# defined as: -D%s=\"%s\"\n" "# got value: 0x%p\n", phase, desc->name, desc->value, (void*)value); @@ -130,7 +130,7 @@ JNIEXPORT jint JNI_OnLoad_getsysprop002(JavaVM *jvm, char *options, void *reserv } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -138,7 +138,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; NSK_DISPLAY0(">>> Check defined system properties in OnLoad phase\n"); @@ -146,7 +146,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { nsk_jvmti_setFailStatus(); } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTag/gettag001/gettag001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTag/gettag001/gettag001.cpp index 801d210de35..926ef71ddab 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTag/gettag001/gettag001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTag/gettag001/gettag001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,17 +51,17 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { /* perform testing */ { - jobject testedObject = NULL; + jobject testedObject = nullptr; jlong objectTag = 0; NSK_DISPLAY0(">>> Obtain tested object from a static field of debugee class\n"); { - jclass debugeeClass = NULL; - jfieldID objectField = NULL; + jclass debugeeClass = nullptr; + jfieldID objectField = nullptr; NSK_DISPLAY1("Find debugee class: %s\n", DEBUGEE_CLASS_NAME); if (!NSK_JNI_VERIFY(jni, (debugeeClass = - jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) { + jni->FindClass(DEBUGEE_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -69,7 +69,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY1("Find static field: %s\n", OBJECT_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (objectField = - jni->GetStaticFieldID(debugeeClass, OBJECT_FIELD_NAME, OBJECT_CLASS_SIG)) != NULL)) { + jni->GetStaticFieldID(debugeeClass, OBJECT_FIELD_NAME, OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -77,7 +77,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY1("Get object from static field: %s\n", OBJECT_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (testedObject = - jni->GetStaticObjectField(debugeeClass, objectField)) != NULL)) { + jni->GetStaticObjectField(debugeeClass, objectField)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -85,7 +85,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY1("Create global reference for object: 0x%p\n", (void*)testedObject); if (!NSK_JNI_VERIFY(jni, (testedObject = - jni->NewGlobalRef(testedObject)) != NULL)) { + jni->NewGlobalRef(testedObject)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -142,7 +142,7 @@ JNIEXPORT jint JNI_OnLoad_gettag001(JavaVM *jvm, char *options, void *reserved) } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -152,7 +152,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add required capabilities */ @@ -168,7 +168,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadCpuTime/thrcputime001/thrcputime001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadCpuTime/thrcputime001/thrcputime001.cpp index 4effa902072..127ae04a0f9 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadCpuTime/thrcputime001/thrcputime001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadCpuTime/thrcputime001/thrcputime001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,9 +69,9 @@ static int checkCpuTime(jvmtiEnv* jvmti, jthread thread, julong* time, char buf[64], buf2[64], buf3[64]; int success = NSK_TRUE; - NSK_DISPLAY1("GetThreadCpuTime() for current thread (passing NULL): 0x%p\n", (void*)thread); + NSK_DISPLAY1("GetThreadCpuTime() for current thread (passing null): 0x%p\n", (void*)thread); if (!NSK_JVMTI_VERIFY( - jvmti->GetThreadCpuTime(NULL, (jlong *)time))) { + jvmti->GetThreadCpuTime(nullptr, (jlong *)time))) { return NSK_FALSE; } NSK_DISPLAY1(" ... got cpu time: %s\n", julong_to_string(*time, buf)); @@ -81,7 +81,7 @@ static int checkCpuTime(jvmtiEnv* jvmti, jthread thread, julong* time, where, julong_to_string(*time, buf)); } - if (prevTime != NULL) { + if (prevTime != nullptr) { julong diff = *time - *prevTime; NSK_DISPLAY1("Compare with previous time: %s\n", @@ -148,7 +148,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY0(">>> Testcase #2: Check initial cpu time in agent thread\n"); { - if (!checkCpuTime(jvmti, testAgentThread, &prevAgentThreadTime, NULL, "agent thread")) { + if (!checkCpuTime(jvmti, testAgentThread, &prevAgentThreadTime, nullptr, "agent thread")) { nsk_jvmti_setFailStatus(); } } @@ -158,7 +158,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { runIterations(iterations); NSK_DISPLAY1("Enable thread events: %d events\n", THREAD_EVENTS_COUNT); - if (nsk_jvmti_enableEvents(JVMTI_ENABLE, THREAD_EVENTS_COUNT, threadEvents, NULL)) { + if (nsk_jvmti_enableEvents(JVMTI_ENABLE, THREAD_EVENTS_COUNT, threadEvents, nullptr)) { NSK_DISPLAY0(" ... enabled\n"); } @@ -185,7 +185,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { return; NSK_DISPLAY1("Disable thread events: %d events\n", THREAD_EVENTS_COUNT); - if (nsk_jvmti_enableEvents(JVMTI_DISABLE, THREAD_EVENTS_COUNT, threadEvents, NULL)) { + if (nsk_jvmti_enableEvents(JVMTI_DISABLE, THREAD_EVENTS_COUNT, threadEvents, nullptr)) { NSK_DISPLAY0(" ... disabled\n"); } } @@ -215,7 +215,7 @@ callbackVMInit(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { NSK_DISPLAY0(">>> Testcase #1: Check initial cpu time in VM_INIT callback\n"); { julong time = 0; - if (!checkCpuTime(jvmti, thread, &time, NULL, "VM_INIT callback")) { + if (!checkCpuTime(jvmti, thread, &time, nullptr, "VM_INIT callback")) { nsk_jvmti_setFailStatus(); } } @@ -231,14 +231,14 @@ callbackVMDeath(jvmtiEnv* jvmti, JNIEnv* jni) { NSK_DISPLAY0(">>> Testcase #7: Check initial cpu time in VM_DEATH callback\n"); { julong time = 0; - if (!checkCpuTime(jvmti, NULL, &time, NULL, "VM_DEATH callback")) { + if (!checkCpuTime(jvmti, nullptr, &time, nullptr, "VM_DEATH callback")) { success = NSK_FALSE; nsk_jvmti_setFailStatus(); } } NSK_DISPLAY1("Disable events: %d events\n", EVENTS_COUNT); - if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, NULL)) { + if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, nullptr)) { success = NSK_FALSE; } else { NSK_DISPLAY0(" ... disabled\n"); @@ -268,9 +268,9 @@ callbackThreadStart(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { NSK_DISPLAY1(" for thread: %s\n", nsk_null_string(threadInfo.name)); } - if (threadInfo.name != NULL && strcmp(threadInfo.name, TESTED_THREAD_NAME) == 0) { + if (threadInfo.name != nullptr && strcmp(threadInfo.name, TESTED_THREAD_NAME) == 0) { NSK_DISPLAY0(">>> Testcase #3: Check initial cpu time in THREAD_START callback\n"); - if (!checkCpuTime(jvmti, thread, &prevTestedThreadTime, NULL, "THREAD_START callback")) { + if (!checkCpuTime(jvmti, thread, &prevTestedThreadTime, nullptr, "THREAD_START callback")) { nsk_jvmti_setFailStatus(); } } @@ -292,7 +292,7 @@ callbackThreadEnd(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { NSK_DISPLAY1(" for thread: %s\n", nsk_null_string(threadInfo.name)); } - if (threadInfo.name != NULL && strcmp(threadInfo.name, TESTED_THREAD_NAME) == 0) { + if (threadInfo.name != nullptr && strcmp(threadInfo.name, TESTED_THREAD_NAME) == 0) { julong time = 0; NSK_DISPLAY0(">>> Testcase #5: Check final cpu time in THREAD_END callback\n"); if (!checkCpuTime(jvmti, thread, &time, &prevTestedThreadTime, "THREAD_END callback")) { @@ -316,7 +316,7 @@ JNIEXPORT jint JNI_OnLoad_thrcputime001(JavaVM *jvm, char *options, void *reserv } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -328,7 +328,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; NSK_DISPLAY1("Add required capability: %s\n", "can_get_thread_cpu_time"); @@ -360,11 +360,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } NSK_DISPLAY0(" ... callbacks set\n"); - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; NSK_DISPLAY1("Enable events: %d events\n", EVENTS_COUNT); - if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, NULL)) { + if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, nullptr)) { NSK_DISPLAY0(" ... enabled\n"); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadCpuTime/thrcputime002/thrcputime002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadCpuTime/thrcputime002/thrcputime002.cpp index 2782c060621..e69f2de6286 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadCpuTime/thrcputime002/thrcputime002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadCpuTime/thrcputime002/thrcputime002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -55,8 +55,8 @@ static jvmtiEvent threadEvents[THREAD_EVENTS_COUNT] = { static julong prevTestedThreadTime = 0; static julong prevAgentThreadTime = 0; -static jthread testedThread = NULL; -static jthread testAgentThread = NULL; +static jthread testedThread = nullptr; +static jthread testAgentThread = nullptr; static int iterations = 0; @@ -83,7 +83,7 @@ static int checkCpuTime(jvmtiEnv* jvmti, jthread thread, julong* time, where, julong_to_string(*time, buf)); } - if (prevTime != NULL) { + if (prevTime != nullptr) { julong diff = *time - *prevTime; NSK_DISPLAY1("Compare with previous time: %s\n", @@ -150,7 +150,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY0(">>> Testcase #2: Check initial cpu time in agent thread\n"); { - if (!checkCpuTime(jvmti, testAgentThread, &prevAgentThreadTime, NULL, "agent thread")) { + if (!checkCpuTime(jvmti, testAgentThread, &prevAgentThreadTime, nullptr, "agent thread")) { nsk_jvmti_setFailStatus(); } } @@ -160,7 +160,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { runIterations(iterations); NSK_DISPLAY1("Enable thread events: %d events\n", THREAD_EVENTS_COUNT); - if (nsk_jvmti_enableEvents(JVMTI_ENABLE, THREAD_EVENTS_COUNT, threadEvents, NULL)) { + if (nsk_jvmti_enableEvents(JVMTI_ENABLE, THREAD_EVENTS_COUNT, threadEvents, nullptr)) { NSK_DISPLAY0(" ... enabled\n"); } @@ -180,7 +180,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { } } - if (testedThread != NULL) { + if (testedThread != nullptr) { NSK_DISPLAY0(">>> Testcase #6: Check tested thread cpu time from agent thread\n"); { julong time = 0; @@ -198,7 +198,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { return; NSK_DISPLAY1("Disable thread events: %d events\n", THREAD_EVENTS_COUNT); - if (nsk_jvmti_enableEvents(JVMTI_DISABLE, THREAD_EVENTS_COUNT, threadEvents, NULL)) { + if (nsk_jvmti_enableEvents(JVMTI_DISABLE, THREAD_EVENTS_COUNT, threadEvents, nullptr)) { NSK_DISPLAY0(" ... disabled\n"); } } @@ -228,7 +228,7 @@ callbackVMInit(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { NSK_DISPLAY0(">>> Testcase #1: Check initial cpu time in VM_INIT callback\n"); { julong time = 0; - if (!checkCpuTime(jvmti, thread, &time, NULL, "VM_INIT callback")) { + if (!checkCpuTime(jvmti, thread, &time, nullptr, "VM_INIT callback")) { nsk_jvmti_setFailStatus(); } } @@ -242,7 +242,7 @@ callbackVMDeath(jvmtiEnv* jvmti, JNIEnv* jni) { int success = NSK_TRUE; NSK_DISPLAY1("Disable events: %d events\n", EVENTS_COUNT); - if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, NULL)) { + if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, nullptr)) { success = NSK_FALSE; } else { NSK_DISPLAY0(" ... disabled\n"); @@ -279,13 +279,13 @@ callbackThreadStart(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { } } - if (threadInfo.name != NULL && strcmp(threadInfo.name, TESTED_THREAD_NAME) == 0) { - if (!NSK_JNI_VERIFY(jni, (testedThread = jni->NewGlobalRef(thread)) != NULL)) { + if (threadInfo.name != nullptr && strcmp(threadInfo.name, TESTED_THREAD_NAME) == 0) { + if (!NSK_JNI_VERIFY(jni, (testedThread = jni->NewGlobalRef(thread)) != nullptr)) { nsk_jvmti_setFailStatus(); } NSK_DISPLAY0(">>> Testcase #4: Check initial cpu time in THREAD_START callback\n"); - if (!checkCpuTime(jvmti, thread, &prevTestedThreadTime, NULL, "THREAD_START callback")) { + if (!checkCpuTime(jvmti, thread, &prevTestedThreadTime, nullptr, "THREAD_START callback")) { nsk_jvmti_setFailStatus(); } } @@ -314,14 +314,14 @@ callbackThreadEnd(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { } } - if (threadInfo.name != NULL && strcmp(threadInfo.name, TESTED_THREAD_NAME) == 0) { + if (threadInfo.name != nullptr && strcmp(threadInfo.name, TESTED_THREAD_NAME) == 0) { julong time = 0; NSK_DISPLAY0(">>> Testcase #8: Check final cpu time in THREAD_END callback\n"); if (!checkCpuTime(jvmti, thread, &time, &prevTestedThreadTime, "THREAD_END callback")) { nsk_jvmti_setFailStatus(); } NSK_TRACE(jni->DeleteGlobalRef(testedThread)); - testedThread = NULL; + testedThread = nullptr; } } @@ -340,7 +340,7 @@ JNIEXPORT jint JNI_OnLoad_thrcputime002(JavaVM *jvm, char *options, void *reserv } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -352,7 +352,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; NSK_DISPLAY1("Add required capability: %s\n", "can_get_thread_cpu_time"); @@ -382,11 +382,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } NSK_DISPLAY0(" ... callbacks set\n"); - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; NSK_DISPLAY1("Enable events: %d events\n", EVENTS_COUNT); - if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, NULL)) { + if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, nullptr)) { NSK_DISPLAY0(" ... enabled\n"); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadCpuTimerInfo/thrtimerinfo001/thrtimerinfo001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadCpuTimerInfo/thrtimerinfo001/thrtimerinfo001.cpp index 81bfb416b58..5d7ee5fb8a5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadCpuTimerInfo/thrtimerinfo001/thrtimerinfo001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadCpuTimerInfo/thrtimerinfo001/thrtimerinfo001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -76,7 +76,7 @@ static int checkTimerInfo(jvmtiEnv* jvmti, jvmtiTimerInfo* info, NSK_DISPLAY1(" may_skip_forward: %d\n", (int)info->may_skip_forward); NSK_DISPLAY1(" may_skip_backward: %d\n", (int)info->may_skip_backward); - if (initInfo != NULL) { + if (initInfo != nullptr) { NSK_DISPLAY0("Compare with initial timer info\n"); if (info->max_value != initInfo->max_value) { NSK_COMPLAIN4("In %s GetThreadCpuTimerInfo() returned different info:\n" @@ -132,7 +132,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY0(">>> Testcases #3,4: Check timer info in thread events\n"); { NSK_DISPLAY1("Enable thread events: %d events\n", THREAD_EVENTS_COUNT); - if (nsk_jvmti_enableEvents(JVMTI_ENABLE, THREAD_EVENTS_COUNT, threadEvents, NULL)) { + if (nsk_jvmti_enableEvents(JVMTI_ENABLE, THREAD_EVENTS_COUNT, threadEvents, nullptr)) { NSK_DISPLAY0(" ... enabled\n"); } @@ -143,7 +143,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { return; NSK_DISPLAY1("Disable thread events: %d events\n", THREAD_EVENTS_COUNT); - if (nsk_jvmti_enableEvents(JVMTI_DISABLE, THREAD_EVENTS_COUNT, threadEvents, NULL)) { + if (nsk_jvmti_enableEvents(JVMTI_DISABLE, THREAD_EVENTS_COUNT, threadEvents, nullptr)) { NSK_DISPLAY0(" ... disabled\n"); } } @@ -163,7 +163,7 @@ callbackVMInit(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { NSK_DISPLAY0(">>> Testcase #1: Check initial timer info in VM_INIT callback\n"); { - if (!checkTimerInfo(jvmti, &initInfo, NULL, "VM_INIT callback")) { + if (!checkTimerInfo(jvmti, &initInfo, nullptr, "VM_INIT callback")) { nsk_jvmti_setFailStatus(); } } @@ -183,7 +183,7 @@ callbackVMDeath(jvmtiEnv* jvmti, JNIEnv* jni) { } NSK_DISPLAY1("Disable events: %d events\n", EVENTS_COUNT); - if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, NULL)) { + if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, nullptr)) { success = NSK_FALSE; } else { NSK_DISPLAY0(" ... disabled\n"); @@ -242,7 +242,7 @@ JNIEXPORT jint JNI_OnLoad_thrtimerinfo001(JavaVM *jvm, char *options, void *rese } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -250,7 +250,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; NSK_DISPLAY1("Add required capability: %s\n", "can_get_thread_cpu_time"); @@ -282,11 +282,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } NSK_DISPLAY0(" ... callbacks set\n"); - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; NSK_DISPLAY1("Enable events: %d events\n", EVENTS_COUNT); - if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, NULL)) { + if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, nullptr)) { NSK_DISPLAY0(" ... enabled\n"); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadGroupChildren/getthrdgrpchld001/getthrdgrpchld001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadGroupChildren/getthrdgrpchld001/getthrdgrpchld001.cpp index 4c04b046d70..e81cf933140 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadGroupChildren/getthrdgrpchld001/getthrdgrpchld001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadGroupChildren/getthrdgrpchld001/getthrdgrpchld001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -32,8 +32,8 @@ extern "C" { /* ============================================================================= */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* constant names */ @@ -69,15 +69,15 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { /* perform testing */ { - jthreadGroup rootGroup = NULL; - jthreadGroup runningGroup = NULL; - jthreadGroup notStartedGroup = NULL; - jthreadGroup finishedGroup = NULL; + jthreadGroup rootGroup = nullptr; + jthreadGroup runningGroup = nullptr; + jthreadGroup notStartedGroup = nullptr; + jthreadGroup finishedGroup = nullptr; /* find root thread group */ { jint topGroupsCount = 0; - jthreadGroup* topGroups = NULL; + jthreadGroup* topGroups = nullptr; NSK_DISPLAY0("Get top level thread groups\n"); if (!NSK_JVMTI_VERIFY( @@ -87,13 +87,13 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { } NSK_DISPLAY1(" ... got groups: %d\n", (int)topGroupsCount); - if (!NSK_VERIFY(topGroupsCount > 0 && topGroups != NULL)) + if (!NSK_VERIFY(topGroupsCount > 0 && topGroups != nullptr)) return; NSK_DISPLAY1("Find thread group by name: %s\n", ROOT_GROUP_NAME); if (!NSK_VERIFY((rootGroup = findThreadGroupByName(jvmti, jni, ROOT_GROUP_NAME, - topGroupsCount, topGroups)) != NULL)) { + topGroupsCount, topGroups)) != nullptr)) { NSK_COMPLAIN1("No tested root thread group found: %s\n", ROOT_GROUP_NAME); nsk_jvmti_setFailStatus(); return; @@ -105,8 +105,8 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { { jint groupsCount = 0; jint threadsCount = 0; - jthread* threads = NULL; - jthreadGroup* groups = NULL; + jthread* threads = nullptr; + jthreadGroup* groups = nullptr; NSK_DISPLAY1("Get children of root thread group: %p\n", (void*)rootGroup); if (!NSK_JVMTI_VERIFY( @@ -150,7 +150,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { if (strcmp(info.name, RUNNING_GROUP_NAME) == 0) { NSK_DISPLAY2(" ... found runningThreadGroup: %p (%s)\n", groups[i], info.name); - if (runningGroup != NULL) { + if (runningGroup != nullptr) { NSK_COMPLAIN6("Duplicated runningThreadGroup in rootThreadGroup:\n" "# parent group: %p (%s)\n" "# existing group: %p (%s)\n" @@ -168,7 +168,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { if (strcmp(info.name, NOT_STARTED_GROUP_NAME) == 0) { NSK_DISPLAY2(" ... found notStartedThreadGroup: %p (%s)\n", groups[i], info.name); - if (notStartedGroup != NULL) { + if (notStartedGroup != nullptr) { NSK_COMPLAIN6("Duplicated notStartedThreadGroup in rootThreadGroup:\n" "# parent group: %p (%s)\n" "# existing group: %p (%s)\n" @@ -186,7 +186,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { if (strcmp(info.name, FINISHED_GROUP_NAME) == 0) { NSK_DISPLAY2(" ... found finishedThreadGroup: %p (%s)\n", groups[i], info.name); - if (finishedGroup != NULL) { + if (finishedGroup != nullptr) { NSK_COMPLAIN6("Duplicated finishedThreadGroup in rootThreadGroup:\n" "# parent group: %p (%s)\n" "# existing group: %p (%s)\n" @@ -243,7 +243,7 @@ static int checkThreadGroup(jvmtiEnv* jvmti, JNIEnv* jni, jint expectedThreadsCount, const char expectedThreadName[]) { size_t threadNameLen = strlen(expectedThreadName); - if (group == NULL) { + if (group == nullptr) { NSK_COMPLAIN1("No expected group found in rootThreadGroup: %s\n", groupName); nsk_jvmti_setFailStatus(); return NSK_FALSE; @@ -253,8 +253,8 @@ static int checkThreadGroup(jvmtiEnv* jvmti, JNIEnv* jni, { jint threadsCount = 0; jint groupsCount = 0; - jthread* threads = NULL; - jthreadGroup* groups = NULL; + jthread* threads = nullptr; + jthreadGroup* groups = nullptr; if (!NSK_JVMTI_VERIFY( jvmti->GetThreadGroupChildren(group, &threadsCount, &threads, &groupsCount, &groups))) { @@ -296,7 +296,7 @@ static int checkThreadGroup(jvmtiEnv* jvmti, JNIEnv* jni, NSK_DISPLAY2(" ... found thread: %p (%s)\n", (void*)threads[i], nsk_null_string(info.name)); - if (info.name == NULL || + if (info.name == nullptr || strncmp(info.name, expectedThreadName, threadNameLen) != 0) { NSK_COMPLAIN5("Found unexpected thread in thread group:\n" "# thread group: %p (%s)\n" @@ -327,31 +327,31 @@ static int checkThreadGroup(jvmtiEnv* jvmti, JNIEnv* jni, /** Recursively find thread group by its name among given groups and their childrens. */ static jthreadGroup findThreadGroupByName(jvmtiEnv* jvmti, JNIEnv* jni, const char name[], jint count, jthreadGroup groupsList[]) { - jthreadGroup foundGroup = NULL; + jthreadGroup foundGroup = nullptr; int i; - for (i = 0; i < count && foundGroup == NULL; i++) { + for (i = 0; i < count && foundGroup == nullptr; i++) { jint threadsCount = 0; jint groupsCount = 0; - jthread* threads = NULL; - jthreadGroup * groups = NULL; + jthread* threads = nullptr; + jthreadGroup * groups = nullptr; if (!NSK_JVMTI_VERIFY( jvmti->GetThreadGroupChildren(groupsList[i], &threadsCount, &threads, &groupsCount, &groups))) { nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } if (groupsCount > 0) { int j; - if (!NSK_VERIFY(groups != NULL)) - return NULL; + if (!NSK_VERIFY(groups != nullptr)) + return nullptr; for (j = 0; j < groupsCount; j++) { jvmtiThreadGroupInfo info; - if (groups[j] != NULL) { + if (groups[j] != nullptr) { if (!NSK_JVMTI_VERIFY( jvmti->GetThreadGroupInfo(groups[j], &info))) { @@ -366,7 +366,7 @@ static jthreadGroup findThreadGroupByName(jvmtiEnv* jvmti, JNIEnv* jni, const ch } } - if (foundGroup == NULL) { + if (foundGroup == nullptr) { foundGroup = findThreadGroupByName(jvmti, jni, name, groupsCount, groups); } } @@ -400,7 +400,7 @@ JNIEXPORT jint JNI_OnLoad_getthrdgrpchld001(JavaVM *jvm, char *options, void *re } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -415,11 +415,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadGroupInfo/thrgrpinfo001/thrgrpinfo001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadGroupInfo/thrgrpinfo001/thrgrpinfo001.cpp index 92134d1e0ff..1d8bf4c02d2 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadGroupInfo/thrgrpinfo001/thrgrpinfo001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadGroupInfo/thrgrpinfo001/thrgrpinfo001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; static jint stage = 0; @@ -53,12 +53,12 @@ JNIEXPORT jint JNI_OnLoad_thrgrpinfo001(JavaVM *jvm, char *options, void *reserv jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -72,7 +72,7 @@ Java_nsk_jvmti_GetThreadGroupInfo_thrgrpinfo001_check(JNIEnv *env, jclass cls, j jvmtiError err; jvmtiThreadGroupInfo inf; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -97,7 +97,7 @@ Java_nsk_jvmti_GetThreadGroupInfo_thrgrpinfo001_check(JNIEnv *env, jclass cls, j (inf.is_daemon == JNI_TRUE) ? "true" : "false"); } - if (inf.name == NULL || strcmp(inf.name, expName) != 0) { + if (inf.name == nullptr || strcmp(inf.name, expName) != 0) { printf("(%d) unexpected name: \"%s\",", stage, inf.name); printf(" expected: \"%s\"\n", expName); result = STATUS_FAILED; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadGroupInfo/thrgrpinfo002/thrgrpinfo002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadGroupInfo/thrgrpinfo002/thrgrpinfo002.cpp index 0a57ad0ea8f..02a4161f64e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadGroupInfo/thrgrpinfo002/thrgrpinfo002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadGroupInfo/thrgrpinfo002/thrgrpinfo002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_thrgrpinfo002(JavaVM *jvm, char *options, void *reserv jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -71,7 +71,7 @@ Java_nsk_jvmti_GetThreadGroupInfo_thrgrpinfo002_check(JNIEnv *env, jclass cls) { jthreadGroup *groups; jvmtiThreadGroupInfo inf; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -89,7 +89,7 @@ Java_nsk_jvmti_GetThreadGroupInfo_thrgrpinfo002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> invalid group check ...\n"); } - err = jvmti->GetThreadGroupInfo(NULL, &inf); + err = jvmti->GetThreadGroupInfo(nullptr, &inf); if (err != JVMTI_ERROR_INVALID_THREAD_GROUP) { printf("Error expected: JVMTI_ERROR_INVALID_THREAD_GROUP,\n"); printf(" got: %s (%d)\n", TranslateError(err), err); @@ -99,7 +99,7 @@ Java_nsk_jvmti_GetThreadGroupInfo_thrgrpinfo002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> null pointer check ...\n"); } - err = jvmti->GetThreadGroupInfo(*groups, NULL); + err = jvmti->GetThreadGroupInfo(*groups, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { printf("Error expected: JVMTI_ERROR_NULL_POINTER,\n"); printf(" got: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadLocalStorage/getthrdstor001/getthrdstor001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadLocalStorage/getthrdstor001/getthrdstor001.cpp index a37007735d0..aa962164c15 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadLocalStorage/getthrdstor001/getthrdstor001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadLocalStorage/getthrdstor001/getthrdstor001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -48,12 +48,12 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { /* perform testing */ { - jthread testedThread = NULL; - void* storage = NULL; + jthread testedThread = nullptr; + void* storage = nullptr; NSK_DISPLAY1("Find thread: %s\n", THREAD_NAME); if (!NSK_VERIFY((testedThread = - nsk_jvmti_threadByName(THREAD_NAME)) != NULL)) + nsk_jvmti_threadByName(THREAD_NAME)) != nullptr)) return; NSK_DISPLAY1(" ... found thread: %p\n", (void*)testedThread); @@ -65,9 +65,9 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { } NSK_DISPLAY1(" ... got storage: %p\n", (void*)storage); - NSK_DISPLAY0("Check obtained storage pointer against NULL\n"); - if (storage != NULL) { - NSK_COMPLAIN2("GetThreadLocalStorage() returned NOT NULL storage for tested thread:\n" + NSK_DISPLAY0("Check obtained storage pointer against null\n"); + if (storage != nullptr) { + NSK_COMPLAIN2("GetThreadLocalStorage() returned NOT null storage for tested thread:\n" "# thread: %p\n" "# storage: %p\n", (void*)testedThread, (void*)storage); @@ -76,15 +76,15 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY0("GetThreadLocalStorage() for current agent thread\n"); if (!NSK_JVMTI_VERIFY( - jvmti->GetThreadLocalStorage(NULL, &storage))) { + jvmti->GetThreadLocalStorage(nullptr, &storage))) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY1(" ... got storage: %p\n", (void*)storage); - NSK_DISPLAY0("Check obtained storage pointer against NULL\n"); - if (storage != NULL) { - NSK_COMPLAIN1("GetThreadLocalStorage() returned NOT NULL storage for current agent thread:\n" + NSK_DISPLAY0("Check obtained storage pointer against null\n"); + if (storage != nullptr) { + NSK_COMPLAIN1("GetThreadLocalStorage() returned NOT null storage for current agent thread:\n" "# storage: %p\n", (void*)storage); nsk_jvmti_setFailStatus(); @@ -114,7 +114,7 @@ JNIEXPORT jint JNI_OnLoad_getthrdstor001(JavaVM *jvm, char *options, void *reser } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -124,11 +124,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTime/gettime001/gettime001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTime/gettime001/gettime001.cpp index 3ed38448feb..df8312be312 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTime/gettime001/gettime001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTime/gettime001/gettime001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,7 +64,7 @@ static bool checkTime(jvmtiEnv* jvmti, julong* time, } NSK_DISPLAY1(" ... got time: %s\n", julong_to_string(*time, buf)); - if (prevTime != NULL) { + if (prevTime != nullptr) { julong diff = *time - *prevTime; NSK_DISPLAY1("Compare with previous time: %s\n", @@ -141,7 +141,7 @@ callbackVMDeath(jvmtiEnv* jvmti, JNIEnv* jni) { } NSK_DISPLAY1("Disable events: %d events\n", EVENTS_COUNT); - if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, NULL)) { + if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, nullptr)) { success = false; } else { NSK_DISPLAY0(" ... disabled\n"); @@ -168,7 +168,7 @@ JNIEXPORT jint JNI_OnLoad_gettime001(JavaVM *jvm, char *options, void *reserved) } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -176,7 +176,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; { @@ -192,18 +192,18 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; NSK_DISPLAY0(">>> Testcase #1: Check initial time in Agent_OnLoad()\n"); { - if (!checkTime(jvmti, &prevTime, NULL, "Agent_OnLoad()")) { + if (!checkTime(jvmti, &prevTime, nullptr, "Agent_OnLoad()")) { nsk_jvmti_setFailStatus(); } } NSK_DISPLAY1("Enable events: %d events\n", EVENTS_COUNT); - if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, NULL)) { + if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, nullptr)) { NSK_DISPLAY0(" ... enabled\n"); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTimerInfo/timerinfo001/timerinfo001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTimerInfo/timerinfo001/timerinfo001.cpp index daa5778d194..eebbfa837b6 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTimerInfo/timerinfo001/timerinfo001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTimerInfo/timerinfo001/timerinfo001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ static bool checkTimerInfo(jvmtiEnv* jvmti, jvmtiTimerInfo* info, NSK_DISPLAY1(" may_skip_forward: %d\n", (int)info->may_skip_forward); NSK_DISPLAY1(" may_skip_backward: %d\n", (int)info->may_skip_backward); - if (initInfo != NULL) { + if (initInfo != nullptr) { NSK_DISPLAY0("Compare with initial timer info\n"); if (info->max_value != initInfo->max_value) { NSK_COMPLAIN4("In %s GetTimerInfo() returned different info:\n" @@ -158,7 +158,7 @@ callbackVMDeath(jvmtiEnv* jvmti, JNIEnv* jni) { } NSK_DISPLAY1("Disable events: %d events\n", EVENTS_COUNT); - if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, NULL)) { + if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, nullptr)) { success = false; } else { NSK_DISPLAY0(" ... disabled\n"); @@ -185,7 +185,7 @@ JNIEXPORT jint JNI_OnLoad_timerinfo001(JavaVM *jvm, char *options, void *reserve } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -193,7 +193,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; { @@ -209,18 +209,18 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; NSK_DISPLAY0(">>> Testcase #1: Check initial timer info in Agent_OnLoad()\n"); { - if (!checkTimerInfo(jvmti, &initInfo, NULL, "Agent_OnLoad()")) { + if (!checkTimerInfo(jvmti, &initInfo, nullptr, "Agent_OnLoad()")) { nsk_jvmti_setFailStatus(); } } NSK_DISPLAY1("Enable events: %d events\n", EVENTS_COUNT); - if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, NULL)) { + if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, nullptr)) { NSK_DISPLAY0(" ... enabled\n"); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTopThreadGroups/topthrgrp001/topthrgrp001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTopThreadGroups/topthrgrp001/topthrgrp001.cpp index 748880fee41..69baf58e6a7 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTopThreadGroups/topthrgrp001/topthrgrp001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTopThreadGroups/topthrgrp001/topthrgrp001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_topthrgrp001(JavaVM *jvm, char *options, void *reserve jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -68,10 +68,10 @@ JNIEXPORT jint JNICALL Java_nsk_jvmti_GetTopThreadGroups_topthrgrp001_check(JNIEnv *env, jclass cls) { jvmtiError err; jint i, groupCount = 0; - jthreadGroup *groups = NULL; + jthreadGroup *groups = nullptr; jvmtiThreadGroupInfo inf; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -105,7 +105,7 @@ Java_nsk_jvmti_GetTopThreadGroups_topthrgrp001_check(JNIEnv *env, jclass cls) { printf(">>> is daemon: %s\n", (inf.is_daemon == JNI_TRUE) ? "true" : "false"); } - if (inf.parent != NULL) { + if (inf.parent != nullptr) { printf("ERROR: thread group is not parentless!\n"); printf(" group name: %s\n", inf.name); printf(" parent: 0x%p\n", inf.parent); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTopThreadGroups/topthrgrp002/topthrgrp002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTopThreadGroups/topthrgrp002/topthrgrp002.cpp index 50b23125dfa..b8817fcc1be 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTopThreadGroups/topthrgrp002/topthrgrp002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetTopThreadGroups/topthrgrp002/topthrgrp002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_topthrgrp002(JavaVM *jvm, char *options, void *reserve jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -70,7 +70,7 @@ Java_nsk_jvmti_GetTopThreadGroups_topthrgrp002_check(JNIEnv *env, jclass cls) { jint groupCount; jthreadGroup *groups; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -78,7 +78,7 @@ Java_nsk_jvmti_GetTopThreadGroups_topthrgrp002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> (groupCountPtr) null pointer check ...\n"); } - err = jvmti->GetTopThreadGroups(NULL, &groups); + err = jvmti->GetTopThreadGroups(nullptr, &groups); if (err != JVMTI_ERROR_NULL_POINTER) { printf("(groupCountPtr) error expected: JVMTI_ERROR_NULL_POINTER,\n"); printf(" got: %s (%d)\n", TranslateError(err), err); @@ -88,7 +88,7 @@ Java_nsk_jvmti_GetTopThreadGroups_topthrgrp002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> (groupsPtr) null pointer check ...\n"); } - err = jvmti->GetTopThreadGroups(&groupCount, NULL); + err = jvmti->GetTopThreadGroups(&groupCount, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { printf("(groupsPtr) error expected: JVMTI_ERROR_NULL_POINTER,\n"); printf(" got: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetVersionNumber/getvern001/getvern001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetVersionNumber/getvern001/getvern001.cpp index 1d8071891fc..80ba1ffe5c7 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetVersionNumber/getvern001/getvern001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetVersionNumber/getvern001/getvern001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_getvern001(JavaVM *jvm, char *options, void *reserved) jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -68,7 +68,7 @@ JNIEXPORT jint JNICALL Java_nsk_jvmti_GetVersionNumber_getvern001_check(JNIEnv * jvmtiError err; jint ver = 0; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -90,7 +90,7 @@ JNIEXPORT jint JNICALL Java_nsk_jvmti_GetVersionNumber_getvern001_check(JNIEnv * if (printdump == JNI_TRUE) { printf(">>> null pointer check ...\n"); } - err = jvmti->GetVersionNumber(NULL); + err = jvmti->GetVersionNumber(nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { printf("Error expected: JVMTI_ERROR_NULL_POINTER, got: %s\n", TranslateError(err)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/InterruptThread/intrpthrd001/intrpthrd001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/InterruptThread/intrpthrd001/intrpthrd001.cpp index 2bdfea11a6f..e89a4ea7b4f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/InterruptThread/intrpthrd001/intrpthrd001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/InterruptThread/intrpthrd001/intrpthrd001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,9 +38,9 @@ extern "C" { static jlong timeout = 0; /* test objects */ -static jthread runningThread = NULL; -static jthread waitingThread = NULL; -static jthread sleepingThread = NULL; +static jthread runningThread = nullptr; +static jthread waitingThread = nullptr; +static jthread sleepingThread = nullptr; /* ========================================================================== */ @@ -49,7 +49,7 @@ static int prepare(jvmtiEnv* jvmti) { const char* WAITING_THREAD_NAME = "DebuggeeWaitingThread"; const char* SLEEPING_THREAD_NAME = "DebuggeeSleepingThread"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; int i; @@ -60,12 +60,12 @@ static int prepare(jvmtiEnv* jvmti) { jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -76,7 +76,7 @@ static int prepare(jvmtiEnv* jvmti) { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL) { + if (info.name != nullptr) { if (strcmp(info.name, RUNNING_THREAD_NAME) == 0) { runningThread = threads[i]; } else if (strcmp(info.name, WAITING_THREAD_NAME) == 0) { @@ -109,7 +109,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { } NSK_DISPLAY0("Testcase #1: call InterruptThread for runningThread\n"); - if (!NSK_VERIFY(runningThread != NULL)) { + if (!NSK_VERIFY(runningThread != nullptr)) { nsk_jvmti_setFailStatus(); } else { if (!NSK_JVMTI_VERIFY(jvmti->InterruptThread(runningThread))) @@ -117,7 +117,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { } NSK_DISPLAY0("Testcase #2: call InterruptThread for waitingThread\n"); - if (!NSK_VERIFY(waitingThread != NULL)) { + if (!NSK_VERIFY(waitingThread != nullptr)) { nsk_jvmti_setFailStatus(); } else { if (!NSK_JVMTI_VERIFY(jvmti->InterruptThread(waitingThread))) @@ -125,7 +125,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { } NSK_DISPLAY0("Testcase #3: call InterruptThread for sleepingThread\n"); - if (!NSK_VERIFY(sleepingThread != NULL)) { + if (!NSK_VERIFY(sleepingThread != nullptr)) { nsk_jvmti_setFailStatus(); } else { if (!NSK_JVMTI_VERIFY(jvmti->InterruptThread(sleepingThread))) @@ -151,7 +151,7 @@ JNIEXPORT jint JNI_OnLoad_intrpthrd001(JavaVM *jvm, char *options, void *reserve } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiCapabilities caps; NSK_DISPLAY0("Agent_OnLoad\n"); @@ -162,10 +162,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&caps, 0, sizeof(caps)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/InterruptThread/intrpthrd002/intrpthrd002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/InterruptThread/intrpthrd002/intrpthrd002.cpp index 60c2384b1c1..9411e9365d4 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/InterruptThread/intrpthrd002/intrpthrd002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/InterruptThread/intrpthrd002/intrpthrd002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/InterruptThread/intrpthrd003/intrpthrd003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/InterruptThread/intrpthrd003/intrpthrd003.cpp index b05c5d5cd7d..dd81a65cb21 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/InterruptThread/intrpthrd003/intrpthrd003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/InterruptThread/intrpthrd003/intrpthrd003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -55,7 +55,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsArrayClass/isarray004/isarray004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsArrayClass/isarray004/isarray004.cpp index 30277bcc619..ac14708af83 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsArrayClass/isarray004/isarray004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsArrayClass/isarray004/isarray004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_isarray004(JavaVM *jvm, char *options, void *reserved) jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -69,7 +69,7 @@ Java_nsk_jvmti_IsArrayClass_isarray004_check(JNIEnv *env, jclass cls) { jvmtiError err; jboolean isArrayClass; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -77,7 +77,7 @@ Java_nsk_jvmti_IsArrayClass_isarray004_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> invalid class check ...\n"); } - err = jvmti->IsArrayClass(NULL, &isArrayClass); + err = jvmti->IsArrayClass(nullptr, &isArrayClass); if (err != JVMTI_ERROR_INVALID_CLASS) { printf("Error expected: JVMTI_ERROR_INVALID_CLASS,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -87,7 +87,7 @@ Java_nsk_jvmti_IsArrayClass_isarray004_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> null pointer check ...\n"); } - err = jvmti->IsArrayClass(cls, NULL); + err = jvmti->IsArrayClass(cls, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { printf("Error expected: JVMTI_ERROR_NULL_POINTER,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsArrayClass/isarray005/isarray005.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsArrayClass/isarray005/isarray005.cpp index 4aacc6f21fe..774ec0574be 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsArrayClass/isarray005/isarray005.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsArrayClass/isarray005/isarray005.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_isarray005(JavaVM *jvm, char *options, void *reserved) jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -75,7 +75,7 @@ Java_nsk_jvmti_IsArrayClass_isarray005_check(JNIEnv *env, jboolean isArrayClass; char *sig, *generic; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsFieldSynthetic/isfldsin002/isfldsin002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsFieldSynthetic/isfldsin002/isfldsin002.cpp index ca52e5801d2..1d4a737551d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsFieldSynthetic/isfldsin002/isfldsin002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsFieldSynthetic/isfldsin002/isfldsin002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -53,12 +53,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -97,13 +97,13 @@ Java_nsk_jvmti_IsFieldSynthetic_isfldsin002_check(JNIEnv *env, jclass cls) { jfieldID fid; jboolean isSynthetic; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } fid = env->GetFieldID(cls, "fld", "I"); - if (fid == NULL) { + if (fid == nullptr) { printf("Cannot get field ID!\n"); return STATUS_FAILED; } @@ -111,7 +111,7 @@ Java_nsk_jvmti_IsFieldSynthetic_isfldsin002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> invalid class check ...\n"); } - err = jvmti->IsFieldSynthetic(NULL, fid, &isSynthetic); + err = jvmti->IsFieldSynthetic(nullptr, fid, &isSynthetic); if (err == JVMTI_ERROR_MUST_POSSESS_CAPABILITY && !caps.can_get_synthetic_attribute) { /* It is OK */ @@ -124,7 +124,7 @@ Java_nsk_jvmti_IsFieldSynthetic_isfldsin002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> invalid field check ...\n"); } - err = jvmti->IsFieldSynthetic(cls, NULL, &isSynthetic); + err = jvmti->IsFieldSynthetic(cls, nullptr, &isSynthetic); if (err == JVMTI_ERROR_MUST_POSSESS_CAPABILITY && !caps.can_get_synthetic_attribute) { /* It is OK */ @@ -137,7 +137,7 @@ Java_nsk_jvmti_IsFieldSynthetic_isfldsin002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> null pointer check ...\n"); } - err = jvmti->IsFieldSynthetic(cls, fid, NULL); + err = jvmti->IsFieldSynthetic(cls, fid, nullptr); if (err == JVMTI_ERROR_MUST_POSSESS_CAPABILITY && !caps.can_get_synthetic_attribute) { /* It is OK */ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsFieldSynthetic/isfldsin003/isfldsin003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsFieldSynthetic/isfldsin003/isfldsin003.cpp index a06e1fd1dff..0089b0e6f70 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsFieldSynthetic/isfldsin003/isfldsin003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsFieldSynthetic/isfldsin003/isfldsin003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -40,7 +40,7 @@ typedef struct { jboolean is_synthetic; } field_info; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -64,12 +64,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -114,14 +114,14 @@ Java_nsk_jvmti_IsFieldSynthetic_isfldsin003a_check(JNIEnv *env, jboolean isSynthetic; size_t i; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } for (i = 0; i < sizeof(fields) / sizeof(field_info); i++) { fid = env->GetFieldID(clazz, fields[i].name, fields[i].sig); - if (fid == NULL) { + if (fid == nullptr) { printf("(%" PRIuPTR ") cannot get field ID for %s:\"%s\"\n", i, fields[i].name, fields[i].sig); result = STATUS_FAILED; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsInterface/isintrf004/isintrf004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsInterface/isintrf004/isintrf004.cpp index 01c232547f7..fdc8da2bc78 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsInterface/isintrf004/isintrf004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsInterface/isintrf004/isintrf004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_isintrf004(JavaVM *jvm, char *options, void *reserved) jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -69,7 +69,7 @@ Java_nsk_jvmti_IsInterface_isintrf004_check(JNIEnv *env, jclass cls) { jvmtiError err; jboolean isInterface; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -77,7 +77,7 @@ Java_nsk_jvmti_IsInterface_isintrf004_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> invalid class check ...\n"); } - err = jvmti->IsInterface(NULL, &isInterface); + err = jvmti->IsInterface(nullptr, &isInterface); if (err != JVMTI_ERROR_INVALID_CLASS) { printf("Error expected: JVMTI_ERROR_INVALID_CLASS,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -87,7 +87,7 @@ Java_nsk_jvmti_IsInterface_isintrf004_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> null pointer check ...\n"); } - err = jvmti->IsInterface(cls, NULL); + err = jvmti->IsInterface(cls, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { printf("Error expected: JVMTI_ERROR_NULL_POINTER,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsInterface/isintrf005/isintrf005.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsInterface/isintrf005/isintrf005.cpp index 887cd625052..57f0386f2a9 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsInterface/isintrf005/isintrf005.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsInterface/isintrf005/isintrf005.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_isintrf005(JavaVM *jvm, char *options, void *reserved) jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -74,7 +74,7 @@ Java_nsk_jvmti_IsInterface_isintrf005_check(JNIEnv *env, jclass cls, jclass claz jboolean isInterface; char *sig, *generic; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsMethodNative/isnative001/isnative001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsMethodNative/isnative001/isnative001.cpp index f4af7621adb..4e2b49fa0a3 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsMethodNative/isnative001/isnative001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsMethodNative/isnative001/isnative001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_isnative001(JavaVM *jvm, char *options, void *reserved jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -79,7 +79,7 @@ void checkMeth(JNIEnv *env, jclass cl, } else { mid = env->GetMethodID(cl, name, sig); } - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot find MethodID for \"%s%s\"\n", name, sig); result = STATUS_FAILED; return; @@ -116,7 +116,7 @@ Java_nsk_jvmti_IsMethodNative_isnative001_check(JNIEnv *env, jclass cls) { checkMeth(env, cls, "check", "()I", 1, JNI_TRUE); clsId = env->FindClass("nsk/jvmti/IsMethodNative/isnative001$Inn"); - if (clsId == NULL) { + if (clsId == nullptr) { printf("Cannot find nsk.jvmti.IsMethodNative.isnative001$Inn class!\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsMethodNative/isnative002/isnative002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsMethodNative/isnative002/isnative002.cpp index 99528346766..3160237fb47 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsMethodNative/isnative002/isnative002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsMethodNative/isnative002/isnative002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_isnative002(JavaVM *jvm, char *options, void *reserved jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -70,13 +70,13 @@ Java_nsk_jvmti_IsMethodNative_isnative002_check(JNIEnv *env, jclass cls) { jmethodID mid; jboolean isNative; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } mid = env->GetMethodID(cls, "", "()V"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot get method ID!\n"); return STATUS_FAILED; } @@ -84,7 +84,7 @@ Java_nsk_jvmti_IsMethodNative_isnative002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> invalid method check ...\n"); } - err = jvmti->IsMethodNative(NULL, &isNative); + err = jvmti->IsMethodNative(nullptr, &isNative); if (err != JVMTI_ERROR_INVALID_METHODID) { printf("Error expected: JVMTI_ERROR_INVALID_METHODID,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); @@ -94,7 +94,7 @@ Java_nsk_jvmti_IsMethodNative_isnative002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> null pointer check ...\n"); } - err = jvmti->IsMethodNative(mid, NULL); + err = jvmti->IsMethodNative(mid, nullptr); if (err != JVMTI_ERROR_NULL_POINTER) { printf("Error expected: JVMTI_ERROR_NULL_POINTER,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsMethodObsolete/isobsolete001/isobsolete001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsMethodObsolete/isobsolete001/isobsolete001.cpp index 399d894f9b4..fcc857134bf 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsMethodObsolete/isobsolete001/isobsolete001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsMethodObsolete/isobsolete001/isobsolete001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -95,10 +95,10 @@ static void checkStackMethodsObsolete(jvmtiEnv* jvmti, jthread thread, int i; for (i = 0; i < frameCount; i++) { - char* name = NULL; - char* signature = NULL; - char* generic = NULL; - char* kind = NULL; + char* name = nullptr; + char* signature = nullptr; + char* generic = nullptr; + char* kind = nullptr; NSK_DISPLAY1(" frame #%i:\n", i); NSK_DISPLAY1(" methodID: %p\n", (void*)frameStack[i].method); @@ -110,7 +110,7 @@ static void checkStackMethodsObsolete(jvmtiEnv* jvmti, jthread thread, NSK_DISPLAY1(" name: %s\n", nsk_null_string(name)); NSK_DISPLAY1(" signature: %s\n", nsk_null_string(signature)); NSK_DISPLAY1(" generic: %s\n", nsk_null_string(generic)); - if (name != NULL + if (name != nullptr && (strcmp(STATIC_METHOD_NAME, name) == 0 || strcmp(INSTANCE_METHOD_NAME, name) == 0)) { found++; @@ -166,15 +166,15 @@ static int redefineClass(jvmtiEnv* jvmti, jclass klass, const char className[], /** Get classfile bytes to redefine. */ static int getClassfileBytes(JNIEnv* jni, jvmtiEnv* jvmti, jint* size, unsigned char* *bytes) { - jclass debugeeClass = NULL; - jfieldID fieldID = NULL; - jbyteArray array = NULL; + jclass debugeeClass = nullptr; + jfieldID fieldID = nullptr; + jbyteArray array = nullptr; jbyte* elements; int i; NSK_DISPLAY1("Find debugee class: %s\n", DEBUGEE_CLASS_NAME); if (!NSK_JNI_VERIFY(jni, (debugeeClass = - jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) { + jni->FindClass(DEBUGEE_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -182,7 +182,7 @@ static int getClassfileBytes(JNIEnv* jni, jvmtiEnv* jvmti, NSK_DISPLAY1("Find static field: %s\n", CLASSFILE_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (fieldID = - jni->GetStaticFieldID(debugeeClass, CLASSFILE_FIELD_NAME, CLASSFILE_FIELD_SIG)) != NULL)) { + jni->GetStaticFieldID(debugeeClass, CLASSFILE_FIELD_NAME, CLASSFILE_FIELD_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -190,7 +190,7 @@ static int getClassfileBytes(JNIEnv* jni, jvmtiEnv* jvmti, NSK_DISPLAY1("Get classfile bytes array from static field: %s\n", CLASSFILE_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (array = (jbyteArray) - jni->GetStaticObjectField(debugeeClass, fieldID)) != NULL)) { + jni->GetStaticObjectField(debugeeClass, fieldID)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -206,7 +206,7 @@ static int getClassfileBytes(JNIEnv* jni, jvmtiEnv* jvmti, { jboolean isCopy; if (!NSK_JNI_VERIFY(jni, (elements = - jni->GetByteArrayElements(array, &isCopy)) != NULL)) { + jni->GetByteArrayElements(array, &isCopy)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -242,11 +242,11 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { /* perform testing */ { - jclass testedClass = NULL; - jobject testedThread = NULL; - jmethodID staticMethodID = NULL; - jmethodID instanceMethodID = NULL; - unsigned char* classfileBytes = NULL; + jclass testedClass = nullptr; + jobject testedThread = nullptr; + jmethodID staticMethodID = nullptr; + jmethodID instanceMethodID = nullptr; + unsigned char* classfileBytes = nullptr; jint classfileSize = 0; NSK_DISPLAY0(">>> Obtain bytes for class file redefinition\n"); @@ -259,7 +259,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { { NSK_DISPLAY1("Find tested class: %s\n", TESTED_CLASS_NAME); if (!NSK_JNI_VERIFY(jni, (testedClass = - jni->FindClass(TESTED_CLASS_NAME)) != NULL)) { + jni->FindClass(TESTED_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -267,7 +267,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY1("Make global reference for class object: %p\n", (void*)testedClass); if (!NSK_JNI_VERIFY(jni, (testedClass = (jclass) - jni->NewGlobalRef(testedClass)) != NULL)) { + jni->NewGlobalRef(testedClass)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -275,7 +275,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY1("Get static methodID: %s\n", STATIC_METHOD_NAME); if (!NSK_JNI_VERIFY(jni, (staticMethodID = - jni->GetStaticMethodID(testedClass, STATIC_METHOD_NAME, STATIC_METHOD_SIG)) != NULL)) { + jni->GetStaticMethodID(testedClass, STATIC_METHOD_NAME, STATIC_METHOD_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -283,7 +283,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY1("Get instance methodID: %s\n", INSTANCE_METHOD_NAME); if (!NSK_JNI_VERIFY(jni, (instanceMethodID = - jni->GetMethodID(testedClass, INSTANCE_METHOD_NAME, INSTANCE_METHOD_SIG)) != NULL)) { + jni->GetMethodID(testedClass, INSTANCE_METHOD_NAME, INSTANCE_METHOD_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -291,7 +291,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY1("Find thread with running methods by name: %s\n", TESTED_THREAD_NAME); if (!NSK_VERIFY((testedThread = - nsk_jvmti_threadByName(TESTED_THREAD_NAME)) != NULL)) { + nsk_jvmti_threadByName(TESTED_THREAD_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -367,7 +367,7 @@ JNIEXPORT jint JNI_OnLoad_isobsolete001(JavaVM *jvm, char *options, void *reserv } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -377,7 +377,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add required capabilities */ @@ -393,7 +393,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsMethodSynthetic/issynth001/issynth001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsMethodSynthetic/issynth001/issynth001.cpp index e9088348e02..a10f3b8e0ee 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsMethodSynthetic/issynth001/issynth001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsMethodSynthetic/issynth001/issynth001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ typedef struct { jboolean is_synthetic; } method_info; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -76,12 +76,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -139,7 +139,7 @@ Java_nsk_jvmti_IsMethodSynthetic_issynth001a_check(JNIEnv *env, } else { mid = env->GetMethodID(cl, methods[i].name, methods[i].signature); } - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot find MethodID for \"%s%s\"\n", methods[i].name, methods[i].signature); result = STATUS_FAILED; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsMethodSynthetic/issynth002/issynth002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsMethodSynthetic/issynth002/issynth002.cpp index 96eb657d238..ab344596ab7 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsMethodSynthetic/issynth002/issynth002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IsMethodSynthetic/issynth002/issynth002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -53,12 +53,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -97,13 +97,13 @@ Java_nsk_jvmti_IsMethodSynthetic_issynth002_check(JNIEnv *env, jclass cls) { jmethodID mid; jboolean isSynthetic; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } mid = env->GetMethodID(cls, "", "()V"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot find method \"()V\"!\n"); return STATUS_FAILED; } @@ -111,7 +111,7 @@ Java_nsk_jvmti_IsMethodSynthetic_issynth002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> invalid method check ...\n"); } - err = jvmti->IsMethodSynthetic(NULL, &isSynthetic); + err = jvmti->IsMethodSynthetic(nullptr, &isSynthetic); if (err == JVMTI_ERROR_MUST_POSSESS_CAPABILITY && !caps.can_get_synthetic_attribute) { /* It is OK */ @@ -124,7 +124,7 @@ Java_nsk_jvmti_IsMethodSynthetic_issynth002_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> null pointer check ...\n"); } - err = jvmti->IsMethodSynthetic(mid, NULL); + err = jvmti->IsMethodSynthetic(mid, nullptr); if (err == JVMTI_ERROR_MUST_POSSESS_CAPABILITY && !caps.can_get_synthetic_attribute) { /* It is OK */ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverHeap/iterheap001/iterheap001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverHeap/iterheap001/iterheap001.cpp index 3d54b28b6c8..fbfaac26708 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverHeap/iterheap001/iterheap001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverHeap/iterheap001/iterheap001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -65,7 +65,7 @@ typedef struct ObjectDescStruct { static int chainLength = 0; static int objectsCount = 0; -static ObjectDesc* objectDescList = NULL; +static ObjectDesc* objectDescList = nullptr; static volatile int foundUntagged = 0; @@ -82,7 +82,7 @@ static int getChainObjects(jvmtiEnv* jvmti, JNIEnv* jni, jobject firstObject, jlong tag, int reachable) { int success = NSK_TRUE; - jobject obj = NULL; + jobject obj = nullptr; jlong objTag = (!reachable ? -tag : (tag % 2 != 0) ? tag : (jlong)0); if (count <= 0) @@ -92,7 +92,7 @@ static int getChainObjects(jvmtiEnv* jvmti, JNIEnv* jni, jobject firstObject, tag++; if (!NSK_JNI_VERIFY(jni, (obj = - jni->GetObjectField(firstObject, firstField)) != NULL)) { + jni->GetObjectField(firstObject, firstField)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -118,16 +118,16 @@ static int getChainObjects(jvmtiEnv* jvmti, JNIEnv* jni, jobject firstObject, /** Obtain all tested objects from debugee class and tag them recursively. */ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, int *objectsCount, ObjectDesc* *objectDescList) { - jclass debugeeClass = NULL; - jclass rootObjectClass = NULL; - jclass chainObjectClass = NULL; + jclass debugeeClass = nullptr; + jclass rootObjectClass = nullptr; + jclass chainObjectClass = nullptr; - jfieldID objectField = NULL; - jfieldID reachableChainField = NULL; - jfieldID unreachableChainField = NULL; - jfieldID tailField = NULL; + jfieldID objectField = nullptr; + jfieldID reachableChainField = nullptr; + jfieldID unreachableChainField = nullptr; + jfieldID tailField = nullptr; - jobject rootObject = NULL; + jobject rootObject = nullptr; jlong chainObjectTag = 100; @@ -151,7 +151,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find debugee class: %s\n", DEBUGEE_CLASS_NAME); if (!NSK_JNI_VERIFY(jni, (debugeeClass = - jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) { + jni->FindClass(DEBUGEE_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -159,7 +159,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find root object class: %s\n", ROOT_OBJECT_CLASS_NAME); if (!NSK_JNI_VERIFY(jni, (rootObjectClass = - jni->FindClass(ROOT_OBJECT_CLASS_NAME)) != NULL)) { + jni->FindClass(ROOT_OBJECT_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -167,7 +167,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find chain object class: %s\n", CHAIN_OBJECT_CLASS_NAME); if (!NSK_JNI_VERIFY(jni, (chainObjectClass = - jni->FindClass(CHAIN_OBJECT_CLASS_NAME)) != NULL)) { + jni->FindClass(CHAIN_OBJECT_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -175,7 +175,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find static field in debugee class: %s\n", OBJECT_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (objectField = - jni->GetStaticFieldID(debugeeClass, OBJECT_FIELD_NAME, ROOT_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetStaticFieldID(debugeeClass, OBJECT_FIELD_NAME, ROOT_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -183,7 +183,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find instance field in root object class: %s\n", REACHABLE_CHAIN_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (reachableChainField = - jni->GetFieldID(rootObjectClass, REACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetFieldID(rootObjectClass, REACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -191,7 +191,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find instance field in root object class: %s\n", UNREACHABLE_CHAIN_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (unreachableChainField = - jni->GetFieldID(rootObjectClass, UNREACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetFieldID(rootObjectClass, UNREACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -199,7 +199,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find instance field in chain object class: %s\n", TAIL_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (tailField = - jni->GetFieldID(chainObjectClass, TAIL_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetFieldID(chainObjectClass, TAIL_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -207,7 +207,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Get root object from static field: %s\n", OBJECT_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (rootObject = - jni->GetStaticObjectField(debugeeClass, objectField)) != NULL)) { + jni->GetStaticObjectField(debugeeClass, objectField)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -302,7 +302,7 @@ static int checkTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, /** Release references to the tested objects and free allocated memory. */ static int releaseTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, ObjectDesc* objectDescList) { - if (objectDescList != NULL) { + if (objectDescList != nullptr) { NSK_DISPLAY1("Deallocate objects list: 0x%p\n", (void*)objectDescList); if (!NSK_JVMTI_VERIFY( jvmti->Deallocate((unsigned char*)objectDescList))) { @@ -322,9 +322,9 @@ heapObjectCallback(jlong class_tag, jlong size, jlong* tag_ptr, void* user_data) if (info & INFO_HEAPOBJ) { NSK_DISPLAY3(" heapObjectCallback: class_tag=%-3ld size=%-3ld *tag_ptr=%-5ld\n", (long)class_tag, (long)size, - (long)(tag_ptr == NULL ? (jlong)0 : *tag_ptr)); + (long)(tag_ptr == nullptr ? (jlong)0 : *tag_ptr)); } else if ((info & INFO_TAGGED) != 0 && - tag_ptr != NULL && *tag_ptr != 0) { + tag_ptr != nullptr && *tag_ptr != 0) { NSK_DISPLAY3(" heapObjectCallback: class_tag=%-3ld size=%-3ld *tag_ptr=%-5ld\n", (long)class_tag, (long)size, (long)*tag_ptr); @@ -341,8 +341,8 @@ heapObjectCallback(jlong class_tag, jlong size, jlong* tag_ptr, void* user_data) nsk_jvmti_setFailStatus(); } - if (tag_ptr == NULL) { - NSK_COMPLAIN3("NULL tag_ptr is passed to heapObjectCallback:\n" + if (tag_ptr == nullptr) { + NSK_COMPLAIN3("null tag_ptr is passed to heapObjectCallback:\n" "# tag_ptr: 0x%p\n" "# class_tag: %ld\n" "# size: %ld\n", @@ -411,7 +411,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY0(">>> Enable OBJECT_FREE event and let debugee to clean links to unreachable objects\n"); { jvmtiEvent event = JVMTI_EVENT_OBJECT_FREE; - if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, NULL))) + if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, nullptr))) return; if (!NSK_VERIFY(nsk_jvmti_resumeSync())) @@ -432,7 +432,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY0(">>> Disable OBJECT_FREE event and check if tagged/untagged objects were iterated:\n"); { jvmtiEvent event = JVMTI_EVENT_OBJECT_FREE; - if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_DISABLE, 1, &event, NULL))) + if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_DISABLE, 1, &event, nullptr))) return; if (!checkTestedObjects(jvmti, jni, chainLength, objectDescList)) { @@ -487,7 +487,7 @@ JNIEXPORT jint JNI_OnLoad_iterheap001(JavaVM *jvm, char *options, void *reserved } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -496,7 +496,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { { const char* infoOpt = nsk_jvmti_findOptionValue("info"); - if (infoOpt != NULL) { + if (infoOpt != nullptr) { if (strcmp(infoOpt, "none") == 0) info = INFO_NONE; else if (strcmp(infoOpt, "all") == 0) @@ -523,7 +523,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; { @@ -547,7 +547,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverHeap/iterheap002/iterheap002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverHeap/iterheap002/iterheap002.cpp index 9d4171ef71c..e1d5a366266 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverHeap/iterheap002/iterheap002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverHeap/iterheap002/iterheap002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -65,7 +65,7 @@ typedef struct ObjectDescStruct { static int chainLength = 0; static int objectsCount = 0; -static ObjectDesc* objectDescList = NULL; +static ObjectDesc* objectDescList = nullptr; static volatile int foundUntagged = 0; @@ -82,7 +82,7 @@ static int getChainObjects(jvmtiEnv* jvmti, JNIEnv* jni, jobject firstObject, jlong tag, int reachable) { int success = NSK_TRUE; - jobject obj = NULL; + jobject obj = nullptr; jlong objTag = (!reachable ? -tag : (tag % 2 != 0) ? tag : (jlong)0); if (count <= 0) @@ -92,7 +92,7 @@ static int getChainObjects(jvmtiEnv* jvmti, JNIEnv* jni, jobject firstObject, tag++; if (!NSK_JNI_VERIFY(jni, (obj = - jni->GetObjectField(firstObject, firstField)) != NULL)) { + jni->GetObjectField(firstObject, firstField)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -118,16 +118,16 @@ static int getChainObjects(jvmtiEnv* jvmti, JNIEnv* jni, jobject firstObject, /** Obtain all tested objects from debugee class and tag them recursively. */ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, int *objectsCount, ObjectDesc* *objectDescList) { - jclass debugeeClass = NULL; - jclass rootObjectClass = NULL; - jclass chainObjectClass = NULL; + jclass debugeeClass = nullptr; + jclass rootObjectClass = nullptr; + jclass chainObjectClass = nullptr; - jfieldID objectField = NULL; - jfieldID reachableChainField = NULL; - jfieldID unreachableChainField = NULL; - jfieldID tailField = NULL; + jfieldID objectField = nullptr; + jfieldID reachableChainField = nullptr; + jfieldID unreachableChainField = nullptr; + jfieldID tailField = nullptr; - jobject rootObject = NULL; + jobject rootObject = nullptr; jlong chainObjectTag = 100; @@ -151,7 +151,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find debugee class: %s\n", DEBUGEE_CLASS_NAME); if (!NSK_JNI_VERIFY(jni, (debugeeClass = - jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) { + jni->FindClass(DEBUGEE_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -159,7 +159,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find root object class: %s\n", ROOT_OBJECT_CLASS_NAME); if (!NSK_JNI_VERIFY(jni, (rootObjectClass = - jni->FindClass(ROOT_OBJECT_CLASS_NAME)) != NULL)) { + jni->FindClass(ROOT_OBJECT_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -167,7 +167,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find chain object class: %s\n", CHAIN_OBJECT_CLASS_NAME); if (!NSK_JNI_VERIFY(jni, (chainObjectClass = - jni->FindClass(CHAIN_OBJECT_CLASS_NAME)) != NULL)) { + jni->FindClass(CHAIN_OBJECT_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -175,7 +175,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find static field in debugee class: %s\n", OBJECT_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (objectField = - jni->GetStaticFieldID(debugeeClass, OBJECT_FIELD_NAME, ROOT_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetStaticFieldID(debugeeClass, OBJECT_FIELD_NAME, ROOT_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -183,7 +183,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find instance field in root object class: %s\n", REACHABLE_CHAIN_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (reachableChainField = - jni->GetFieldID(rootObjectClass, REACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetFieldID(rootObjectClass, REACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -191,7 +191,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find instance field in root object class: %s\n", UNREACHABLE_CHAIN_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (unreachableChainField = - jni->GetFieldID(rootObjectClass, UNREACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetFieldID(rootObjectClass, UNREACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -199,7 +199,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find instance field in chain object class: %s\n", TAIL_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (tailField = - jni->GetFieldID(chainObjectClass, TAIL_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetFieldID(chainObjectClass, TAIL_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -207,7 +207,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Get root object from static field: %s\n", OBJECT_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (rootObject = - jni->GetStaticObjectField(debugeeClass, objectField)) != NULL)) { + jni->GetStaticObjectField(debugeeClass, objectField)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -302,7 +302,7 @@ static int checkTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, /** Release references to the tested objects and free allocated memory. */ static int releaseTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, ObjectDesc* objectDescList) { - if (objectDescList != NULL) { + if (objectDescList != nullptr) { NSK_DISPLAY1("Deallocate objects list: 0x%p\n", (void*)objectDescList); if (!NSK_JVMTI_VERIFY( jvmti->Deallocate((unsigned char*)objectDescList))) { @@ -322,9 +322,9 @@ heapObjectCallback(jlong class_tag, jlong size, jlong* tag_ptr, void* user_data) if (info & INFO_HEAPOBJ) { NSK_DISPLAY3(" heapObjectCallback: class_tag=%-3ld size=%-3ld *tag_ptr=%-5ld\n", (long)class_tag, (long)size, - (long)(tag_ptr == NULL ? (jlong)0 : *tag_ptr)); + (long)(tag_ptr == nullptr ? (jlong)0 : *tag_ptr)); } else if ((info & INFO_TAGGED) != 0 && - tag_ptr != NULL && *tag_ptr != 0) { + tag_ptr != nullptr && *tag_ptr != 0) { NSK_DISPLAY3(" heapObjectCallback: class_tag=%-3ld size=%-3ld *tag_ptr=%-5ld\n", (long)class_tag, (long)size, (long)*tag_ptr); @@ -341,8 +341,8 @@ heapObjectCallback(jlong class_tag, jlong size, jlong* tag_ptr, void* user_data) nsk_jvmti_setFailStatus(); } - if (tag_ptr == NULL) { - NSK_COMPLAIN3("NULL tag_ptr is passed to heapObjectCallback:\n" + if (tag_ptr == nullptr) { + NSK_COMPLAIN3("null tag_ptr is passed to heapObjectCallback:\n" "# tag_ptr: 0x%p\n" "# class_tag: %ld\n" "# size: %ld\n", @@ -419,7 +419,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY0(">>> Enable OBJECT_FREE event and let debugee to clean links to unreachable objects\n"); { jvmtiEvent event = JVMTI_EVENT_OBJECT_FREE; - if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, NULL))) + if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, nullptr))) return; if (!NSK_VERIFY(nsk_jvmti_resumeSync())) @@ -440,7 +440,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY0(">>> Disable OBJECT_FREE event and check if tagged objects were iterated:\n"); { jvmtiEvent event = JVMTI_EVENT_OBJECT_FREE; - if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_DISABLE, 1, &event, NULL))) + if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_DISABLE, 1, &event, nullptr))) return; if (!checkTestedObjects(jvmti, jni, chainLength, objectDescList)) { @@ -495,7 +495,7 @@ JNIEXPORT jint JNI_OnLoad_iterheap002(JavaVM *jvm, char *options, void *reserved } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -504,7 +504,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { { const char* infoOpt = nsk_jvmti_findOptionValue("info"); - if (infoOpt != NULL) { + if (infoOpt != nullptr) { if (strcmp(infoOpt, "none") == 0) info = INFO_NONE; else if (strcmp(infoOpt, "all") == 0) @@ -531,7 +531,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; { @@ -555,7 +555,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverHeap/iterheap003/iterheap003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverHeap/iterheap003/iterheap003.cpp index a485c4bb6ee..488ce612a1b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverHeap/iterheap003/iterheap003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverHeap/iterheap003/iterheap003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -65,7 +65,7 @@ typedef struct ObjectDescStruct { static int chainLength = 0; static int objectsCount = 0; -static ObjectDesc* objectDescList = NULL; +static ObjectDesc* objectDescList = nullptr; static volatile int foundUntagged = 0; @@ -82,7 +82,7 @@ static int getChainObjects(jvmtiEnv* jvmti, JNIEnv* jni, jobject firstObject, jlong tag, int reachable) { int success = NSK_TRUE; - jobject obj = NULL; + jobject obj = nullptr; jlong objTag = (!reachable ? -tag : (tag % 2 != 0) ? tag : (jlong)0); if (count <= 0) @@ -92,7 +92,7 @@ static int getChainObjects(jvmtiEnv* jvmti, JNIEnv* jni, jobject firstObject, tag++; if (!NSK_JNI_VERIFY(jni, (obj = - jni->GetObjectField(firstObject, firstField)) != NULL)) { + jni->GetObjectField(firstObject, firstField)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -118,16 +118,16 @@ static int getChainObjects(jvmtiEnv* jvmti, JNIEnv* jni, jobject firstObject, /** Obtain all tested objects from debugee class and tag them recursively. */ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, int *objectsCount, ObjectDesc* *objectDescList) { - jclass debugeeClass = NULL; - jclass rootObjectClass = NULL; - jclass chainObjectClass = NULL; + jclass debugeeClass = nullptr; + jclass rootObjectClass = nullptr; + jclass chainObjectClass = nullptr; - jfieldID objectField = NULL; - jfieldID reachableChainField = NULL; - jfieldID unreachableChainField = NULL; - jfieldID tailField = NULL; + jfieldID objectField = nullptr; + jfieldID reachableChainField = nullptr; + jfieldID unreachableChainField = nullptr; + jfieldID tailField = nullptr; - jobject rootObject = NULL; + jobject rootObject = nullptr; jlong chainObjectTag = 100; @@ -151,7 +151,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find debugee class: %s\n", DEBUGEE_CLASS_NAME); if (!NSK_JNI_VERIFY(jni, (debugeeClass = - jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) { + jni->FindClass(DEBUGEE_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -159,7 +159,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find root object class: %s\n", ROOT_OBJECT_CLASS_NAME); if (!NSK_JNI_VERIFY(jni, (rootObjectClass = - jni->FindClass(ROOT_OBJECT_CLASS_NAME)) != NULL)) { + jni->FindClass(ROOT_OBJECT_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -167,7 +167,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find chain object class: %s\n", CHAIN_OBJECT_CLASS_NAME); if (!NSK_JNI_VERIFY(jni, (chainObjectClass = - jni->FindClass(CHAIN_OBJECT_CLASS_NAME)) != NULL)) { + jni->FindClass(CHAIN_OBJECT_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -175,7 +175,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find static field in debugee class: %s\n", OBJECT_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (objectField = - jni->GetStaticFieldID(debugeeClass, OBJECT_FIELD_NAME, ROOT_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetStaticFieldID(debugeeClass, OBJECT_FIELD_NAME, ROOT_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -183,7 +183,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find instance field in root object class: %s\n", REACHABLE_CHAIN_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (reachableChainField = - jni->GetFieldID(rootObjectClass, REACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetFieldID(rootObjectClass, REACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -191,7 +191,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find instance field in root object class: %s\n", UNREACHABLE_CHAIN_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (unreachableChainField = - jni->GetFieldID(rootObjectClass, UNREACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetFieldID(rootObjectClass, UNREACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -199,7 +199,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find instance field in chain object class: %s\n", TAIL_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (tailField = - jni->GetFieldID(chainObjectClass, TAIL_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetFieldID(chainObjectClass, TAIL_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -207,7 +207,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Get root object from static field: %s\n", OBJECT_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (rootObject = - jni->GetStaticObjectField(debugeeClass, objectField)) != NULL)) { + jni->GetStaticObjectField(debugeeClass, objectField)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -302,7 +302,7 @@ static int checkTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, /** Release references to the tested objects and free allocated memory. */ static int releaseTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, ObjectDesc* objectDescList) { - if (objectDescList != NULL) { + if (objectDescList != nullptr) { NSK_DISPLAY1("Deallocate objects list: 0x%p\n", (void*)objectDescList); if (!NSK_JVMTI_VERIFY( jvmti->Deallocate((unsigned char*)objectDescList))) { @@ -322,9 +322,9 @@ heapObjectCallback(jlong class_tag, jlong size, jlong* tag_ptr, void* user_data) if (info & INFO_HEAPOBJ) { NSK_DISPLAY3(" heapObjectCallback: class_tag=%-3ld size=%-3ld *tag_ptr=%-5ld\n", (long)class_tag, (long)size, - (long)(tag_ptr == NULL ? (jlong)0 : *tag_ptr)); + (long)(tag_ptr == nullptr ? (jlong)0 : *tag_ptr)); } else if ((info & INFO_TAGGED) != 0 && - tag_ptr != NULL && *tag_ptr != 0) { + tag_ptr != nullptr && *tag_ptr != 0) { NSK_DISPLAY3(" heapObjectCallback: class_tag=%-3ld size=%-3ld *tag_ptr=%-5ld\n", (long)class_tag, (long)size, (long)*tag_ptr); @@ -341,8 +341,8 @@ heapObjectCallback(jlong class_tag, jlong size, jlong* tag_ptr, void* user_data) nsk_jvmti_setFailStatus(); } - if (tag_ptr == NULL) { - NSK_COMPLAIN3("NULL tag_ptr is passed to heapObjectCallback:\n" + if (tag_ptr == nullptr) { + NSK_COMPLAIN3("null tag_ptr is passed to heapObjectCallback:\n" "# tag_ptr: 0x%p\n" "# class_tag: %ld\n" "# size: %ld\n", @@ -420,7 +420,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY0(">>> Enable OBJECT_FREE event and let debugee to clean links to unreachable objects\n"); { jvmtiEvent event = JVMTI_EVENT_OBJECT_FREE; - if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, NULL))) + if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, nullptr))) return; if (!NSK_VERIFY(nsk_jvmti_resumeSync())) @@ -441,7 +441,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY0(">>> Disable OBJECT_FREE event and check if untagged objects were iterated:\n"); { jvmtiEvent event = JVMTI_EVENT_OBJECT_FREE; - if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_DISABLE, 1, &event, NULL))) + if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_DISABLE, 1, &event, nullptr))) return; if (!checkTestedObjects(jvmti, jni, chainLength, objectDescList)) { @@ -496,7 +496,7 @@ JNIEXPORT jint JNI_OnLoad_iterheap003(JavaVM *jvm, char *options, void *reserved } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -505,7 +505,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { { const char* infoOpt = nsk_jvmti_findOptionValue("info"); - if (infoOpt != NULL) { + if (infoOpt != nullptr) { if (strcmp(infoOpt, "none") == 0) info = INFO_NONE; else if (strcmp(infoOpt, "all") == 0) @@ -532,7 +532,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; { @@ -556,7 +556,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverHeap/iterheap004/iterheap004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverHeap/iterheap004/iterheap004.cpp index 54eb590a962..8e30927f00b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverHeap/iterheap004/iterheap004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverHeap/iterheap004/iterheap004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -29,8 +29,8 @@ extern "C" { -static JNIEnv *jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv *jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jlong timeout = 0; @@ -126,7 +126,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { { do { - objectDescList = NULL; + objectDescList = nullptr; NSK_DISPLAY0("Calling IterateOverHeap with filter JVMTI_HEAP_OBJECT_UNTAGGED\n"); { @@ -170,7 +170,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { } /* Verify objectDescCount and objectDescList length in agreement */ - if (!NSK_VERIFY(objectDesc == NULL)) { + if (!NSK_VERIFY(objectDesc == nullptr)) { nsk_jvmti_setFailStatus(); break; } @@ -242,7 +242,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; memset(&caps, 0, sizeof(caps)); @@ -258,7 +258,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!caps.can_tag_objects) NSK_DISPLAY0("Warning: tagging objects is not available\n"); - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverHeap/iterheap005/iterheap005.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverHeap/iterheap005/iterheap005.cpp index d2ccacfe2d2..86b1c537a2c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverHeap/iterheap005/iterheap005.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverHeap/iterheap005/iterheap005.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { static jlong timeout = 0; static int fakeUserData = 0, objCounter = 0; -static jvmtiEnv* st_jvmti = NULL; +static jvmtiEnv* st_jvmti = nullptr; /* ============================================================================= */ @@ -44,7 +44,7 @@ heapObjectCallback(jlong class_tag, void* user_data) { const char* name = "monitorName"; - jrawMonitorID monitor_ptr = NULL; + jrawMonitorID monitor_ptr = nullptr; /* Check RawMonitor functions for first 10 objects */ if (objCounter >= 10) return JVMTI_ITERATION_ABORT; @@ -150,7 +150,7 @@ JNIEXPORT jint JNI_OnLoad_iterheap005(JavaVM *jvm, char *options, void *reserved } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -158,7 +158,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* save pointer to environment to use it in callbacks */ @@ -175,7 +175,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverHeap/iterheap006/iterheap006.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverHeap/iterheap006/iterheap006.cpp index 9e387542ca3..cc8da20efcc 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverHeap/iterheap006/iterheap006.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverHeap/iterheap006/iterheap006.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -32,9 +32,9 @@ extern "C" { /* ============================================================================= */ static jlong timeout = 0; -static jvmtiEnv* st_jvmti = NULL; +static jvmtiEnv* st_jvmti = nullptr; static const char *storage_data = "local_storage_data"; -static void *storage_ptr = NULL; +static void *storage_ptr = nullptr; /* ============================================================================= */ @@ -111,7 +111,7 @@ JNIEXPORT jint JNI_OnLoad_iterheap006(JavaVM *jvm, char *options, void *reserved } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -119,7 +119,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* save pointer to environment to use it in callbacks */ @@ -136,7 +136,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverHeap/iterheap007/iterheap007.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverHeap/iterheap007/iterheap007.cpp index 467fd6bc796..7075025ec09 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverHeap/iterheap007/iterheap007.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverHeap/iterheap007/iterheap007.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -32,7 +32,7 @@ extern "C" { /* ============================================================================= */ static jlong timeout = 0; -static jvmtiEnv* st_jvmti = NULL; +static jvmtiEnv* st_jvmti = nullptr; static jlong nanos = 0; static jvmtiTimerInfo timer_info1, timer_info2; static int *user_data = 0; @@ -135,7 +135,7 @@ JNIEXPORT jint JNI_OnLoad_iterheap007(JavaVM *jvm, char *options, void *reserved } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -143,7 +143,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* save pointer to environment to use it in callbacks */ @@ -160,7 +160,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls001/iterinstcls001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls001/iterinstcls001.cpp index c9a0acc33ee..32b7adc30de 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls001/iterinstcls001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls001/iterinstcls001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -65,7 +65,7 @@ typedef struct ObjectDescStruct { static int chainLength = 0; static int objectsCount = 0; -static ObjectDesc* objectDescList = NULL; +static ObjectDesc* objectDescList = nullptr; static volatile int foundUntagged = 0; @@ -82,7 +82,7 @@ static int getChainObjects(jvmtiEnv* jvmti, JNIEnv* jni, jobject firstObject, jlong tag, int reachable) { int success = NSK_TRUE; - jobject obj = NULL; + jobject obj = nullptr; jlong objTag = (!reachable ? -tag : (tag % 2 != 0) ? tag : (jlong)0); if (count <= 0) @@ -92,7 +92,7 @@ static int getChainObjects(jvmtiEnv* jvmti, JNIEnv* jni, jobject firstObject, tag++; if (!NSK_JNI_VERIFY(jni, (obj = - jni->GetObjectField(firstObject, firstField)) != NULL)) { + jni->GetObjectField(firstObject, firstField)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -119,16 +119,16 @@ static int getChainObjects(jvmtiEnv* jvmti, JNIEnv* jni, jobject firstObject, static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, int *objectsCount, ObjectDesc* *objectDescList, jclass *testedClass) { - jclass debugeeClass = NULL; - jclass rootObjectClass = NULL; - jclass chainObjectClass = NULL; + jclass debugeeClass = nullptr; + jclass rootObjectClass = nullptr; + jclass chainObjectClass = nullptr; - jfieldID objectField = NULL; - jfieldID reachableChainField = NULL; - jfieldID unreachableChainField = NULL; - jfieldID tailField = NULL; + jfieldID objectField = nullptr; + jfieldID reachableChainField = nullptr; + jfieldID unreachableChainField = nullptr; + jfieldID tailField = nullptr; - jobject rootObject = NULL; + jobject rootObject = nullptr; jlong testedClassTag = 1; jlong chainObjectTag = 100; @@ -153,7 +153,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find debugee class: %s\n", DEBUGEE_CLASS_NAME); if (!NSK_JNI_VERIFY(jni, (debugeeClass = - jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) { + jni->FindClass(DEBUGEE_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -161,7 +161,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find root object class: %s\n", ROOT_OBJECT_CLASS_NAME); if (!NSK_JNI_VERIFY(jni, (rootObjectClass = - jni->FindClass(ROOT_OBJECT_CLASS_NAME)) != NULL)) { + jni->FindClass(ROOT_OBJECT_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -169,7 +169,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find chain object class: %s\n", CHAIN_OBJECT_CLASS_NAME); if (!NSK_JNI_VERIFY(jni, (chainObjectClass = - jni->FindClass(CHAIN_OBJECT_CLASS_NAME)) != NULL)) { + jni->FindClass(CHAIN_OBJECT_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -177,7 +177,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Create global ref to tested class: 0x%p\n", chainObjectClass); if (!NSK_JNI_VERIFY(jni, (*testedClass = (jclass) - jni->NewGlobalRef(chainObjectClass)) != NULL)) { + jni->NewGlobalRef(chainObjectClass)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -185,7 +185,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find static field in debugee class: %s\n", OBJECT_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (objectField = - jni->GetStaticFieldID(debugeeClass, OBJECT_FIELD_NAME, ROOT_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetStaticFieldID(debugeeClass, OBJECT_FIELD_NAME, ROOT_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -193,7 +193,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find instance field in root object class: %s\n", REACHABLE_CHAIN_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (reachableChainField = - jni->GetFieldID(rootObjectClass, REACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetFieldID(rootObjectClass, REACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -201,7 +201,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find instance field in root object class: %s\n", UNREACHABLE_CHAIN_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (unreachableChainField = - jni->GetFieldID(rootObjectClass, UNREACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetFieldID(rootObjectClass, UNREACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -209,7 +209,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find instance field in chain object class: %s\n", TAIL_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (tailField = - jni->GetFieldID(chainObjectClass, TAIL_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetFieldID(chainObjectClass, TAIL_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -217,7 +217,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Get root object from static field: %s\n", OBJECT_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (rootObject = - jni->GetStaticObjectField(debugeeClass, objectField)) != NULL)) { + jni->GetStaticObjectField(debugeeClass, objectField)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -320,12 +320,12 @@ static int checkTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, /** Release references to the tested objects and free allocated memory. */ static int releaseTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, ObjectDesc* objectDescList, jclass testedClass) { - if (testedClass != NULL) { + if (testedClass != nullptr) { NSK_DISPLAY1("Release object reference to tested class: 0x%p\n", testedClass); NSK_TRACE(jni->DeleteGlobalRef(testedClass)); } - if (objectDescList != NULL) { + if (objectDescList != nullptr) { NSK_DISPLAY1("Deallocate objects list: 0x%p\n", (void*)objectDescList); if (!NSK_JVMTI_VERIFY( jvmti->Deallocate((unsigned char*)objectDescList))) { @@ -345,7 +345,7 @@ heapObjectCallback(jlong class_tag, jlong size, jlong* tag_ptr, void* user_data) if (info & INFO_HEAPOBJ) { NSK_DISPLAY3(" heapObjectCallback: class_tag=%-3ld size=%-3ld *tag_ptr=%-5ld\n", (long)class_tag, (long)size, - (long)(tag_ptr == NULL ? (jlong)0 : *tag_ptr)); + (long)(tag_ptr == nullptr ? (jlong)0 : *tag_ptr)); } if (class_tag != 1) { @@ -359,8 +359,8 @@ heapObjectCallback(jlong class_tag, jlong size, jlong* tag_ptr, void* user_data) nsk_jvmti_setFailStatus(); } - if (tag_ptr == NULL) { - NSK_COMPLAIN3("NULL tag_ptr is passed to heapObjectCallback:\n" + if (tag_ptr == nullptr) { + NSK_COMPLAIN3("null tag_ptr is passed to heapObjectCallback:\n" "# tag_ptr: 0x%p\n" "# class_tag: %ld\n" "# size: %ld\n", @@ -419,7 +419,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { return; { - jclass testedClass = NULL; + jclass testedClass = nullptr; NSK_DISPLAY0(">>> Obtain and tag tested objects from debugee class\n"); { @@ -431,7 +431,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY0(">>> Enable OBJECT_FREE event and let debugee to clean links to unreachable objects\n"); { jvmtiEvent event = JVMTI_EVENT_OBJECT_FREE; - if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, NULL))) + if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, nullptr))) return; if (!NSK_VERIFY(nsk_jvmti_resumeSync())) @@ -452,7 +452,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY0(">>> Disable OBJECT_FREE event and check if tagged/untagged objects were iterated:\n"); { jvmtiEvent event = JVMTI_EVENT_OBJECT_FREE; - if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_DISABLE, 1, &event, NULL))) + if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_DISABLE, 1, &event, nullptr))) return; if (!checkTestedObjects(jvmti, jni, chainLength, objectDescList)) { @@ -508,7 +508,7 @@ JNIEXPORT jint JNI_OnLoad_iterinstcls001(JavaVM *jvm, char *options, void *reser } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -517,7 +517,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { { const char* infoOpt = nsk_jvmti_findOptionValue("info"); - if (infoOpt != NULL) { + if (infoOpt != nullptr) { if (strcmp(infoOpt, "none") == 0) info = INFO_NONE; else if (strcmp(infoOpt, "all") == 0) @@ -542,7 +542,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; { @@ -566,7 +566,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls002/iterinstcls002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls002/iterinstcls002.cpp index 13288e2fd5e..b048103203b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls002/iterinstcls002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls002/iterinstcls002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -65,7 +65,7 @@ typedef struct ObjectDescStruct { static int chainLength = 0; static int objectsCount = 0; -static ObjectDesc* objectDescList = NULL; +static ObjectDesc* objectDescList = nullptr; static volatile int foundUntagged = 0; @@ -82,7 +82,7 @@ static int getChainObjects(jvmtiEnv* jvmti, JNIEnv* jni, jobject firstObject, jlong tag, int reachable) { int success = NSK_TRUE; - jobject obj = NULL; + jobject obj = nullptr; jlong objTag = (!reachable ? -tag : (tag % 2 != 0) ? tag : (jlong)0); if (count <= 0) @@ -92,7 +92,7 @@ static int getChainObjects(jvmtiEnv* jvmti, JNIEnv* jni, jobject firstObject, tag++; if (!NSK_JNI_VERIFY(jni, (obj = - jni->GetObjectField(firstObject, firstField)) != NULL)) { + jni->GetObjectField(firstObject, firstField)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -119,16 +119,16 @@ static int getChainObjects(jvmtiEnv* jvmti, JNIEnv* jni, jobject firstObject, static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, int *objectsCount, ObjectDesc* *objectDescList, jclass *testedClass) { - jclass debugeeClass = NULL; - jclass rootObjectClass = NULL; - jclass chainObjectClass = NULL; + jclass debugeeClass = nullptr; + jclass rootObjectClass = nullptr; + jclass chainObjectClass = nullptr; - jfieldID objectField = NULL; - jfieldID reachableChainField = NULL; - jfieldID unreachableChainField = NULL; - jfieldID tailField = NULL; + jfieldID objectField = nullptr; + jfieldID reachableChainField = nullptr; + jfieldID unreachableChainField = nullptr; + jfieldID tailField = nullptr; - jobject rootObject = NULL; + jobject rootObject = nullptr; jlong testedClassTag = 1; jlong chainObjectTag = 100; @@ -153,7 +153,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find debugee class: %s\n", DEBUGEE_CLASS_NAME); if (!NSK_JNI_VERIFY(jni, (debugeeClass = - jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) { + jni->FindClass(DEBUGEE_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -161,7 +161,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find root object class: %s\n", ROOT_OBJECT_CLASS_NAME); if (!NSK_JNI_VERIFY(jni, (rootObjectClass = - jni->FindClass(ROOT_OBJECT_CLASS_NAME)) != NULL)) { + jni->FindClass(ROOT_OBJECT_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -169,7 +169,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find chain object class: %s\n", CHAIN_OBJECT_CLASS_NAME); if (!NSK_JNI_VERIFY(jni, (chainObjectClass = - jni->FindClass(CHAIN_OBJECT_CLASS_NAME)) != NULL)) { + jni->FindClass(CHAIN_OBJECT_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -177,7 +177,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Create global ref to tested class: 0x%p\n", chainObjectClass); if (!NSK_JNI_VERIFY(jni, (*testedClass = (jclass) - jni->NewGlobalRef(chainObjectClass)) != NULL)) { + jni->NewGlobalRef(chainObjectClass)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -185,7 +185,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find static field in debugee class: %s\n", OBJECT_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (objectField = - jni->GetStaticFieldID(debugeeClass, OBJECT_FIELD_NAME, ROOT_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetStaticFieldID(debugeeClass, OBJECT_FIELD_NAME, ROOT_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -193,7 +193,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find instance field in root object class: %s\n", REACHABLE_CHAIN_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (reachableChainField = - jni->GetFieldID(rootObjectClass, REACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetFieldID(rootObjectClass, REACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -201,7 +201,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find instance field in root object class: %s\n", UNREACHABLE_CHAIN_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (unreachableChainField = - jni->GetFieldID(rootObjectClass, UNREACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetFieldID(rootObjectClass, UNREACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -209,7 +209,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find instance field in chain object class: %s\n", TAIL_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (tailField = - jni->GetFieldID(chainObjectClass, TAIL_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetFieldID(chainObjectClass, TAIL_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -217,7 +217,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Get root object from static field: %s\n", OBJECT_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (rootObject = - jni->GetStaticObjectField(debugeeClass, objectField)) != NULL)) { + jni->GetStaticObjectField(debugeeClass, objectField)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -320,12 +320,12 @@ static int checkTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, /** Release references to the tested objects and free allocated memory. */ static int releaseTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, ObjectDesc* objectDescList, jclass testedClass) { - if (testedClass != NULL) { + if (testedClass != nullptr) { NSK_DISPLAY1("Release object reference to tested class: 0x%p\n", testedClass); NSK_TRACE(jni->DeleteGlobalRef(testedClass)); } - if (objectDescList != NULL) { + if (objectDescList != nullptr) { NSK_DISPLAY1("Deallocate objects list: 0x%p\n", (void*)objectDescList); if (!NSK_JVMTI_VERIFY( jvmti->Deallocate((unsigned char*)objectDescList))) { @@ -345,7 +345,7 @@ heapObjectCallback(jlong class_tag, jlong size, jlong* tag_ptr, void* user_data) if (info & INFO_HEAPOBJ) { NSK_DISPLAY3(" heapObjectCallback: class_tag=%-3ld size=%-3ld *tag_ptr=%-5ld\n", (long)class_tag, (long)size, - (long)(tag_ptr == NULL ? (jlong)0 : *tag_ptr)); + (long)(tag_ptr == nullptr ? (jlong)0 : *tag_ptr)); } if (class_tag != 1) { @@ -359,8 +359,8 @@ heapObjectCallback(jlong class_tag, jlong size, jlong* tag_ptr, void* user_data) nsk_jvmti_setFailStatus(); } - if (tag_ptr == NULL) { - NSK_COMPLAIN3("NULL tag_ptr is passed to heapObjectCallback:\n" + if (tag_ptr == nullptr) { + NSK_COMPLAIN3("null tag_ptr is passed to heapObjectCallback:\n" "# tag_ptr: 0x%p\n" "# class_tag: %ld\n" "# size: %ld\n", @@ -427,7 +427,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { return; { - jclass testedClass = NULL; + jclass testedClass = nullptr; NSK_DISPLAY0(">>> Obtain and tag tested objects from debugee class\n"); { @@ -439,7 +439,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY0(">>> Enable OBJECT_FREE event and let debugee to clean links to unreachable objects\n"); { jvmtiEvent event = JVMTI_EVENT_OBJECT_FREE; - if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, NULL))) + if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, nullptr))) return; if (!NSK_VERIFY(nsk_jvmti_resumeSync())) @@ -460,7 +460,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY0(">>> Disable OBJECT_FREE event and check if tagged objects were iterated:\n"); { jvmtiEvent event = JVMTI_EVENT_OBJECT_FREE; - if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_DISABLE, 1, &event, NULL))) + if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_DISABLE, 1, &event, nullptr))) return; if (!checkTestedObjects(jvmti, jni, chainLength, objectDescList)) { @@ -516,7 +516,7 @@ JNIEXPORT jint JNI_OnLoad_iterinstcls002(JavaVM *jvm, char *options, void *reser } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -525,7 +525,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { { const char* infoOpt = nsk_jvmti_findOptionValue("info"); - if (infoOpt != NULL) { + if (infoOpt != nullptr) { if (strcmp(infoOpt, "none") == 0) info = INFO_NONE; else if (strcmp(infoOpt, "all") == 0) @@ -550,7 +550,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; { @@ -574,7 +574,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls003/iterinstcls003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls003/iterinstcls003.cpp index e552dc0b3b9..147003ff77f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls003/iterinstcls003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls003/iterinstcls003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -65,7 +65,7 @@ typedef struct ObjectDescStruct { static int chainLength = 0; static int objectsCount = 0; -static ObjectDesc* objectDescList = NULL; +static ObjectDesc* objectDescList = nullptr; static volatile int foundUntagged = 0; @@ -82,7 +82,7 @@ static int getChainObjects(jvmtiEnv* jvmti, JNIEnv* jni, jobject firstObject, jlong tag, int reachable) { int success = NSK_TRUE; - jobject obj = NULL; + jobject obj = nullptr; jlong objTag = (!reachable ? -tag : (tag % 2 != 0) ? tag : (jlong)0); if (count <= 0) @@ -92,7 +92,7 @@ static int getChainObjects(jvmtiEnv* jvmti, JNIEnv* jni, jobject firstObject, tag++; if (!NSK_JNI_VERIFY(jni, (obj = - jni->GetObjectField(firstObject, firstField)) != NULL)) { + jni->GetObjectField(firstObject, firstField)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -119,16 +119,16 @@ static int getChainObjects(jvmtiEnv* jvmti, JNIEnv* jni, jobject firstObject, static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, int *objectsCount, ObjectDesc* *objectDescList, jclass *testedClass) { - jclass debugeeClass = NULL; - jclass rootObjectClass = NULL; - jclass chainObjectClass = NULL; + jclass debugeeClass = nullptr; + jclass rootObjectClass = nullptr; + jclass chainObjectClass = nullptr; - jfieldID objectField = NULL; - jfieldID reachableChainField = NULL; - jfieldID unreachableChainField = NULL; - jfieldID tailField = NULL; + jfieldID objectField = nullptr; + jfieldID reachableChainField = nullptr; + jfieldID unreachableChainField = nullptr; + jfieldID tailField = nullptr; - jobject rootObject = NULL; + jobject rootObject = nullptr; jlong testedClassTag = 1; jlong chainObjectTag = 100; @@ -153,7 +153,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find debugee class: %s\n", DEBUGEE_CLASS_NAME); if (!NSK_JNI_VERIFY(jni, (debugeeClass = - jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) { + jni->FindClass(DEBUGEE_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -161,7 +161,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find root object class: %s\n", ROOT_OBJECT_CLASS_NAME); if (!NSK_JNI_VERIFY(jni, (rootObjectClass = - jni->FindClass(ROOT_OBJECT_CLASS_NAME)) != NULL)) { + jni->FindClass(ROOT_OBJECT_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -169,7 +169,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find chain object class: %s\n", CHAIN_OBJECT_CLASS_NAME); if (!NSK_JNI_VERIFY(jni, (chainObjectClass = - jni->FindClass(CHAIN_OBJECT_CLASS_NAME)) != NULL)) { + jni->FindClass(CHAIN_OBJECT_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -177,7 +177,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Create global ref to tested class: 0x%p\n", chainObjectClass); if (!NSK_JNI_VERIFY(jni, (*testedClass = (jclass) - jni->NewGlobalRef(chainObjectClass)) != NULL)) { + jni->NewGlobalRef(chainObjectClass)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -185,7 +185,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find static field in debugee class: %s\n", OBJECT_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (objectField = - jni->GetStaticFieldID(debugeeClass, OBJECT_FIELD_NAME, ROOT_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetStaticFieldID(debugeeClass, OBJECT_FIELD_NAME, ROOT_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -193,7 +193,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find instance field in root object class: %s\n", REACHABLE_CHAIN_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (reachableChainField = - jni->GetFieldID(rootObjectClass, REACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetFieldID(rootObjectClass, REACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -201,7 +201,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find instance field in root object class: %s\n", UNREACHABLE_CHAIN_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (unreachableChainField = - jni->GetFieldID(rootObjectClass, UNREACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetFieldID(rootObjectClass, UNREACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -209,7 +209,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find instance field in chain object class: %s\n", TAIL_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (tailField = - jni->GetFieldID(chainObjectClass, TAIL_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetFieldID(chainObjectClass, TAIL_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -217,7 +217,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Get root object from static field: %s\n", OBJECT_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (rootObject = - jni->GetStaticObjectField(debugeeClass, objectField)) != NULL)) { + jni->GetStaticObjectField(debugeeClass, objectField)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -320,12 +320,12 @@ static int checkTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, /** Release references to the tested objects and free allocated memory. */ static int releaseTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, ObjectDesc* objectDescList, jclass testedClass) { - if (testedClass != NULL) { + if (testedClass != nullptr) { NSK_DISPLAY1("Release object reference to tested class: 0x%p\n", testedClass); NSK_TRACE(jni->DeleteGlobalRef(testedClass)); } - if (objectDescList != NULL) { + if (objectDescList != nullptr) { NSK_DISPLAY1("Deallocate objects list: 0x%p\n", (void*)objectDescList); if (!NSK_JVMTI_VERIFY( jvmti->Deallocate((unsigned char*)objectDescList))) { @@ -345,7 +345,7 @@ heapObjectCallback(jlong class_tag, jlong size, jlong* tag_ptr, void* user_data) if (info & INFO_HEAPOBJ) { NSK_DISPLAY3(" heapObjectCallback: class_tag=%-3ld size=%-3ld *tag_ptr=%-5ld\n", (long)class_tag, (long)size, - (long)(tag_ptr == NULL ? (jlong)0 : *tag_ptr)); + (long)(tag_ptr == nullptr ? (jlong)0 : *tag_ptr)); } if (class_tag != 1) { @@ -359,8 +359,8 @@ heapObjectCallback(jlong class_tag, jlong size, jlong* tag_ptr, void* user_data) nsk_jvmti_setFailStatus(); } - if (tag_ptr == NULL) { - NSK_COMPLAIN3("NULL tag_ptr is passed to heapObjectCallback:\n" + if (tag_ptr == nullptr) { + NSK_COMPLAIN3("null tag_ptr is passed to heapObjectCallback:\n" "# tag_ptr: 0x%p\n" "# class_tag: %ld\n" "# size: %ld\n", @@ -428,7 +428,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { return; { - jclass testedClass = NULL; + jclass testedClass = nullptr; NSK_DISPLAY0(">>> Obtain and tag tested objects from debugee class\n"); { @@ -440,7 +440,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY0(">>> Enable OBJECT_FREE event and let debugee to clean links to unreachable objects\n"); { jvmtiEvent event = JVMTI_EVENT_OBJECT_FREE; - if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, NULL))) + if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, nullptr))) return; if (!NSK_VERIFY(nsk_jvmti_resumeSync())) @@ -461,7 +461,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY0(">>> Disable OBJECT_FREE event and check if untagged objects were iterated:\n"); { jvmtiEvent event = JVMTI_EVENT_OBJECT_FREE; - if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_DISABLE, 1, &event, NULL))) + if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_DISABLE, 1, &event, nullptr))) return; if (!checkTestedObjects(jvmti, jni, chainLength, objectDescList)) { @@ -517,7 +517,7 @@ JNIEXPORT jint JNI_OnLoad_iterinstcls003(JavaVM *jvm, char *options, void *reser } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -526,7 +526,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { { const char* infoOpt = nsk_jvmti_findOptionValue("info"); - if (infoOpt != NULL) { + if (infoOpt != nullptr) { if (strcmp(infoOpt, "none") == 0) info = INFO_NONE; else if (strcmp(infoOpt, "all") == 0) @@ -551,7 +551,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; { @@ -575,7 +575,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls004/iterinstcls004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls004/iterinstcls004.cpp index 43e378571f4..6790635654c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls004/iterinstcls004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls004/iterinstcls004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ typedef struct ObjectDescStruct { } ObjectDesc; static ObjectDesc *objectDescBuf; -static jvmtiEnv* st_jvmti = NULL; +static jvmtiEnv* st_jvmti = nullptr; static const char debugeeClassSignature[] = "Lnsk/jvmti/IterateOverInstancesOfClass/iterinstcls004;"; /* ============================================================================= */ @@ -99,12 +99,12 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { return; { - jclass debugeeClass = NULL; + jclass debugeeClass = nullptr; do { NSK_DISPLAY1("Find debugee class: %s\n", debugeeClassSignature); debugeeClass = nsk_jvmti_classBySignature(debugeeClassSignature); - if (debugeeClass == NULL) { + if (debugeeClass == nullptr) { nsk_jvmti_setFailStatus(); break; } @@ -167,7 +167,7 @@ JNIEXPORT jint JNI_OnLoad_iterinstcls004(JavaVM *jvm, char *options, void *reser } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -175,7 +175,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* save pointer to environment to use it in callbacks */ @@ -192,7 +192,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls005/iterinstcls005.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls005/iterinstcls005.cpp index 0907650299a..7e7d6ff85be 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls005/iterinstcls005.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls005/iterinstcls005.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { static jlong timeout = 0; static int fakeUserData = 0, objCounter = 0; -static jvmtiEnv* st_jvmti = NULL; +static jvmtiEnv* st_jvmti = nullptr; static const char debugeeClassSignature[] = "Lnsk/jvmti/IterateOverInstancesOfClass/iterinstcls005;"; /* ============================================================================= */ @@ -45,7 +45,7 @@ heapObjectCallback(jlong class_tag, void* user_data) { const char* name = "monitorName"; - jrawMonitorID monitor_ptr = NULL; + jrawMonitorID monitor_ptr = nullptr; objCounter++; @@ -106,11 +106,11 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { return; do { - jclass debugeeClass = NULL; + jclass debugeeClass = nullptr; NSK_DISPLAY1("Find debugee class: %s\n", debugeeClassSignature); debugeeClass = nsk_jvmti_classBySignature(debugeeClassSignature); - if (debugeeClass == NULL) { + if (debugeeClass == nullptr) { nsk_jvmti_setFailStatus(); break; } @@ -152,7 +152,7 @@ JNIEXPORT jint JNI_OnLoad_iterinstcls005(JavaVM *jvm, char *options, void *reser } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -160,7 +160,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* save pointer to environment to use it in callbacks */ @@ -176,7 +176,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls006/iterinstcls006.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls006/iterinstcls006.cpp index 56868adb9b7..9129af82476 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls006/iterinstcls006.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls006/iterinstcls006.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -32,9 +32,9 @@ extern "C" { /* ============================================================================= */ static jlong timeout = 0; -static jvmtiEnv* st_jvmti = NULL; +static jvmtiEnv* st_jvmti = nullptr; static const char *storage_data = "local_storage_data"; -static void *storage_ptr = NULL; +static void *storage_ptr = nullptr; static const char debugeeClassSignature[] = "Lnsk/jvmti/IterateOverInstancesOfClass/iterinstcls006;"; /* ============================================================================= */ @@ -68,11 +68,11 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { return; do { - jclass debugeeClass = NULL; + jclass debugeeClass = nullptr; NSK_DISPLAY1("Find debugee class: %s\n", debugeeClassSignature); debugeeClass = nsk_jvmti_classBySignature(debugeeClassSignature); - if (debugeeClass == NULL) { + if (debugeeClass == nullptr) { nsk_jvmti_setFailStatus(); break; } @@ -121,7 +121,7 @@ JNIEXPORT jint JNI_OnLoad_iterinstcls006(JavaVM *jvm, char *options, void *reser } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -129,7 +129,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* save pointer to environment to use it in callbacks */ @@ -145,7 +145,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls007/iterinstcls007.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls007/iterinstcls007.cpp index 5e93a860167..01026bad68e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls007/iterinstcls007.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverInstancesOfClass/iterinstcls007/iterinstcls007.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -32,7 +32,7 @@ extern "C" { /* ============================================================================= */ static jlong timeout = 0; -static jvmtiEnv* st_jvmti = NULL; +static jvmtiEnv* st_jvmti = nullptr; static int *user_data = 0; static const char debugeeClassSignature[] = "Lnsk/jvmti/IterateOverInstancesOfClass/iterinstcls007;"; static jlong nanos = 0; @@ -109,11 +109,11 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { do { NSK_DISPLAY0("Calling IterateOverInstancesOfClass with filter JVMTI_HEAP_OBJECT_EITHER\n"); { - jclass debugeeClass = NULL; + jclass debugeeClass = nullptr; NSK_DISPLAY1("Find debugee class: %s\n", debugeeClassSignature); debugeeClass = nsk_jvmti_classBySignature(debugeeClassSignature); - if (debugeeClass == NULL) { + if (debugeeClass == nullptr) { nsk_jvmti_setFailStatus(); break; } @@ -148,7 +148,7 @@ JNIEXPORT jint JNI_OnLoad_iterinstcls007(JavaVM *jvm, char *options, void *reser } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -156,7 +156,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* save pointer to environment to use it in callbacks */ @@ -173,7 +173,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverObjectsReachableFromObject/iterobjreachobj001/iterobjreachobj001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverObjectsReachableFromObject/iterobjreachobj001/iterobjreachobj001.cpp index 487ca0fd703..ba158a475ae 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverObjectsReachableFromObject/iterobjreachobj001/iterobjreachobj001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverObjectsReachableFromObject/iterobjreachobj001/iterobjreachobj001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -63,7 +63,7 @@ typedef struct ObjectDescStruct { static int chainLength = 0; static int objectsCount = 0; -static ObjectDesc* objectDescList = NULL; +static ObjectDesc* objectDescList = nullptr; static int fakeUserData = 0; static int userDataError = 0; @@ -76,7 +76,7 @@ static int getChainObjects(jvmtiEnv* jvmti, JNIEnv* jni, jobject firstObject, jfieldID nextField, const char nextFieldName[], int count, ObjectDesc objectDescList[], jlong tag, int reachable) { - jobject obj = NULL; + jobject obj = nullptr; jlong objTag = (reachable ? tag : -tag); if (count <= 0) @@ -85,7 +85,7 @@ static int getChainObjects(jvmtiEnv* jvmti, JNIEnv* jni, jobject firstObject, count--; tag++; - if (!NSK_JNI_VERIFY(jni, (obj = jni->GetObjectField(firstObject, firstField)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (obj = jni->GetObjectField(firstObject, firstField)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -110,14 +110,14 @@ static int getChainObjects(jvmtiEnv* jvmti, JNIEnv* jni, jobject firstObject, static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, int *objectsCount, ObjectDesc* *objectDescList, jobject* rootObject) { - jclass debugeeClass = NULL; - jclass rootObjectClass = NULL; - jclass chainObjectClass = NULL; + jclass debugeeClass = nullptr; + jclass rootObjectClass = nullptr; + jclass chainObjectClass = nullptr; - jfieldID objectField = NULL; - jfieldID reachableChainField = NULL; - jfieldID unreachableChainField = NULL; - jfieldID tailField = NULL; + jfieldID objectField = nullptr; + jfieldID reachableChainField = nullptr; + jfieldID unreachableChainField = nullptr; + jfieldID tailField = nullptr; jlong rootObjectTag = 1; jlong chainObjectTag = 100; @@ -141,14 +141,14 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, } NSK_DISPLAY1("Find debugee class: %s\n", DEBUGEE_CLASS_NAME); - if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } NSK_DISPLAY1(" ... found class: 0x%p\n", (void*)debugeeClass); NSK_DISPLAY1("Find root object class: %s\n", ROOT_OBJECT_CLASS_NAME); - if (!NSK_JNI_VERIFY(jni, (rootObjectClass = jni->FindClass(ROOT_OBJECT_CLASS_NAME)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (rootObjectClass = jni->FindClass(ROOT_OBJECT_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -156,7 +156,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find chain object class: %s\n", CHAIN_OBJECT_CLASS_NAME); if (!NSK_JNI_VERIFY(jni, (chainObjectClass = - jni->FindClass(CHAIN_OBJECT_CLASS_NAME)) != NULL)) { + jni->FindClass(CHAIN_OBJECT_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -164,7 +164,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find static field in debugee class: %s\n", OBJECT_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (objectField = jni->GetStaticFieldID( - debugeeClass, OBJECT_FIELD_NAME, ROOT_OBJECT_CLASS_SIG)) != NULL)) { + debugeeClass, OBJECT_FIELD_NAME, ROOT_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -172,7 +172,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find instance field in root object class: %s\n", REACHABLE_CHAIN_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (reachableChainField = jni->GetFieldID( - rootObjectClass, REACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) { + rootObjectClass, REACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -180,7 +180,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find instance field in root object class: %s\n", UNREACHABLE_CHAIN_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (unreachableChainField = jni->GetFieldID( - rootObjectClass, UNREACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) { + rootObjectClass, UNREACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -188,7 +188,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find instance field in chain object class: %s\n", TAIL_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (tailField = - jni->GetFieldID(chainObjectClass, TAIL_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetFieldID(chainObjectClass, TAIL_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -196,13 +196,13 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Get root object from static field: %s\n", OBJECT_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (*rootObject = - jni->GetStaticObjectField(debugeeClass, objectField)) != NULL)) { + jni->GetStaticObjectField(debugeeClass, objectField)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } NSK_DISPLAY1(" ... got object: 0x%p\n", (void*)*rootObject); - if (!NSK_JNI_VERIFY(jni, (*rootObject = jni->NewGlobalRef(*rootObject)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (*rootObject = jni->NewGlobalRef(*rootObject)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -290,12 +290,12 @@ static int checkTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, /** Release references to the tested objects and free allocated memory. */ static int releaseTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, ObjectDesc* objectDescList, jobject rootObject) { - if (rootObject != NULL) { + if (rootObject != nullptr) { NSK_DISPLAY1("Release object reference to root tested object: 0x%p\n", rootObject); NSK_TRACE(jni->DeleteGlobalRef(rootObject)); } - if (objectDescList != NULL) { + if (objectDescList != nullptr) { NSK_DISPLAY1("Deallocate objects list: 0x%p\n", (void*)objectDescList); if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)objectDescList))) { nsk_jvmti_setFailStatus(); @@ -318,12 +318,12 @@ objectReferenceCallback(jvmtiObjectReferenceKind reference_kind, NSK_DISPLAY6(" objectReferenceCallback: ref_kind=%1d class_tag=%-3ld size=%-3ld" " *tag_ptr=%-5ld ref_tag=%-5ld ref_idx=%d\n", (int)reference_kind, (long)class_tag, (long)size, - (long)(tag_ptr == NULL ? (jlong)0 : *tag_ptr), + (long)(tag_ptr == nullptr ? (jlong)0 : *tag_ptr), (long)refferrer_tag, (int)refferrer_index); } - if (tag_ptr == NULL) { - NSK_COMPLAIN6("NULL tag_ptr is passed to objectReferenceCallback:\n" + if (tag_ptr == nullptr) { + NSK_COMPLAIN6("null tag_ptr is passed to objectReferenceCallback:\n" "# tag_ptr: 0x%p\n" "# reference_kind: %d\n" "# class_tag: %ld\n" @@ -339,7 +339,7 @@ objectReferenceCallback(jvmtiObjectReferenceKind reference_kind, nsk_jvmti_setFailStatus(); } - if (tag_ptr != NULL && *tag_ptr != 0) { + if (tag_ptr != nullptr && *tag_ptr != 0) { int found = 0; int i; @@ -412,7 +412,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { return; { - jobject rootObject = NULL; + jobject rootObject = nullptr; NSK_DISPLAY0(">>> Obtain and tag tested objects from debugee class\n"); { @@ -474,7 +474,7 @@ JNIEXPORT jint JNI_OnLoad_iterobjreachobj001(JavaVM *jvm, char *options, void *r } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -483,7 +483,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { { const char* infoOpt = nsk_jvmti_findOptionValue("info"); - if (infoOpt != NULL) { + if (infoOpt != nullptr) { if (strcmp(infoOpt, "none") == 0) info = INFO_NONE; else if (strcmp(infoOpt, "all") == 0) @@ -508,7 +508,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; { @@ -521,7 +521,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverObjectsReachableFromObject/iterobjreachobj002/iterobjreachobj002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverObjectsReachableFromObject/iterobjreachobj002/iterobjreachobj002.cpp index 2bc628d73d2..9f5e130341d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverObjectsReachableFromObject/iterobjreachobj002/iterobjreachobj002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverObjectsReachableFromObject/iterobjreachobj002/iterobjreachobj002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,7 @@ static jlong timeout = 0; static long objectCount = 0; static int userData = 0, allocationError = 0; -static jvmtiEnv* st_jvmti = NULL; +static jvmtiEnv* st_jvmti = nullptr; static const char* debugeeClassSignature = "Lnsk/jvmti/IterateOverObjectsReachableFromObject/iterobjreachobj002;"; static const char* objectFieldName = "object"; @@ -108,28 +108,28 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { return; { - jclass debugeeClass = NULL; - jfieldID objectField = NULL; - jobject object = NULL; + jclass debugeeClass = nullptr; + jfieldID objectField = nullptr; + jobject object = nullptr; do { NSK_DISPLAY1("Find debugee class: %s\n", debugeeClassSignature); debugeeClass = nsk_jvmti_classBySignature(debugeeClassSignature); - if (debugeeClass == NULL) { + if (debugeeClass == nullptr) { nsk_jvmti_setFailStatus(); break; } NSK_DISPLAY1("Find static field in debugee class: %s\n", objectFieldName); if (!NSK_JNI_VERIFY(jni, (objectField = jni->GetStaticFieldID( - debugeeClass, objectFieldName, debugeeClassSignature)) != NULL)) { + debugeeClass, objectFieldName, debugeeClassSignature)) != nullptr)) { nsk_jvmti_setFailStatus(); break; } NSK_DISPLAY1("Find value of static field in debugee class: %s\n", objectFieldName); if (!NSK_JNI_VERIFY(jni, (object = - jni->GetStaticObjectField(debugeeClass, objectField)) != NULL)) { + jni->GetStaticObjectField(debugeeClass, objectField)) != nullptr)) { nsk_jvmti_setFailStatus(); break; } @@ -190,7 +190,7 @@ JNIEXPORT jint JNI_OnLoad_iterobjreachobj002(JavaVM *jvm, char *options, void *r } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -198,7 +198,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* save pointer to environment to use it in callbacks */ @@ -214,7 +214,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverObjectsReachableFromObject/iterobjreachobj003/iterobjreachobj003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverObjectsReachableFromObject/iterobjreachobj003/iterobjreachobj003.cpp index 0bca38f4ada..0681864d99a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverObjectsReachableFromObject/iterobjreachobj003/iterobjreachobj003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverObjectsReachableFromObject/iterobjreachobj003/iterobjreachobj003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { static jlong timeout = 0; static int fakeUserData = 0, objCounter = 0; -static jvmtiEnv* st_jvmti = NULL; +static jvmtiEnv* st_jvmti = nullptr; static const char* debugeeClassSignature = "Lnsk/jvmti/IterateOverObjectsReachableFromObject/iterobjreachobj003;"; static const char* objectFieldName = "object"; @@ -49,7 +49,7 @@ objectReferenceCallback(jvmtiObjectReferenceKind reference_kind, void* user_data) { const char* name = "monitorName"; - jrawMonitorID monitor_ptr = NULL; + jrawMonitorID monitor_ptr = nullptr; objCounter++; @@ -110,27 +110,27 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { return; do { - jclass debugeeClass = NULL; - jfieldID objectField = NULL; - jobject object = NULL; + jclass debugeeClass = nullptr; + jfieldID objectField = nullptr; + jobject object = nullptr; NSK_DISPLAY1("Find debugee class: %s\n", debugeeClassSignature); debugeeClass = nsk_jvmti_classBySignature(debugeeClassSignature); - if (debugeeClass == NULL) { + if (debugeeClass == nullptr) { nsk_jvmti_setFailStatus(); break; } NSK_DISPLAY1("Find static field in debugee class: %s\n", objectFieldName); if (!NSK_JNI_VERIFY(jni, (objectField = jni->GetStaticFieldID( - debugeeClass, objectFieldName, debugeeClassSignature)) != NULL)) { + debugeeClass, objectFieldName, debugeeClassSignature)) != nullptr)) { nsk_jvmti_setFailStatus(); break; } NSK_DISPLAY1("Find value of static field in debugee class: %s\n", objectFieldName); if (!NSK_JNI_VERIFY(jni, (object = - jni->GetStaticObjectField(debugeeClass, objectField)) != NULL)) { + jni->GetStaticObjectField(debugeeClass, objectField)) != nullptr)) { nsk_jvmti_setFailStatus(); break; } @@ -169,7 +169,7 @@ JNIEXPORT jint JNI_OnLoad_iterobjreachobj003(JavaVM *jvm, char *options, void *r } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -177,7 +177,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* save pointer to environment to use it in callbacks */ @@ -193,7 +193,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverObjectsReachableFromObject/iterobjreachobj004/iterobjreachobj004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverObjectsReachableFromObject/iterobjreachobj004/iterobjreachobj004.cpp index d363e18c754..44ae2c3e327 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverObjectsReachableFromObject/iterobjreachobj004/iterobjreachobj004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverObjectsReachableFromObject/iterobjreachobj004/iterobjreachobj004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,9 +33,9 @@ extern "C" { static jlong timeout = 0; static int fakeUserData = 0, objCounter = 0; -static jvmtiEnv* st_jvmti = NULL; +static jvmtiEnv* st_jvmti = nullptr; static const char *storage_data = "local_storage_data"; -static void *storage_ptr = NULL; +static void *storage_ptr = nullptr; static const char* debugeeClassSignature = "Lnsk/jvmti/IterateOverObjectsReachableFromObject/iterobjreachobj004;"; static const char* objectFieldName = "object"; @@ -75,27 +75,27 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { return; do { - jclass debugeeClass = NULL; - jfieldID objectField = NULL; - jobject object = NULL; + jclass debugeeClass = nullptr; + jfieldID objectField = nullptr; + jobject object = nullptr; NSK_DISPLAY1("Find debugee class: %s\n", debugeeClassSignature); debugeeClass = nsk_jvmti_classBySignature(debugeeClassSignature); - if (debugeeClass == NULL) { + if (debugeeClass == nullptr) { nsk_jvmti_setFailStatus(); break; } NSK_DISPLAY1("Find static field in debugee class: %s\n", objectFieldName); if (!NSK_JNI_VERIFY(jni, (objectField = jni->GetStaticFieldID( - debugeeClass, objectFieldName, debugeeClassSignature)) != NULL)) { + debugeeClass, objectFieldName, debugeeClassSignature)) != nullptr)) { nsk_jvmti_setFailStatus(); break; } NSK_DISPLAY1("Find value of static field in debugee class: %s\n", objectFieldName); if (!NSK_JNI_VERIFY(jni, (object = - jni->GetStaticObjectField(debugeeClass, objectField)) != NULL)) { + jni->GetStaticObjectField(debugeeClass, objectField)) != nullptr)) { nsk_jvmti_setFailStatus(); break; } @@ -146,7 +146,7 @@ JNIEXPORT jint JNI_OnLoad_iterobjreachobj004(JavaVM *jvm, char *options, void *r } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -154,7 +154,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* save pointer to environment to use it in callbacks */ @@ -170,7 +170,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverObjectsReachableFromObject/iterobjreachobj005/iterobjreachobj005.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverObjectsReachableFromObject/iterobjreachobj005/iterobjreachobj005.cpp index cbba7ba2902..5da3d9fa52c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverObjectsReachableFromObject/iterobjreachobj005/iterobjreachobj005.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverObjectsReachableFromObject/iterobjreachobj005/iterobjreachobj005.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -32,7 +32,7 @@ extern "C" { /* ============================================================================= */ static jlong timeout = 0; -static jvmtiEnv* st_jvmti = NULL; +static jvmtiEnv* st_jvmti = nullptr; static int *user_data = 0, objCounter = 0; static jlong nanos = 0; static jvmtiTimerInfo timer_info1, timer_info2; @@ -115,27 +115,27 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { do { NSK_DISPLAY0("Calling IterateOverInstancesOfClass with filter JVMTI_HEAP_OBJECT_EITHER\n"); { - jclass debugeeClass = NULL; - jfieldID objectField = NULL; - jobject object = NULL; + jclass debugeeClass = nullptr; + jfieldID objectField = nullptr; + jobject object = nullptr; NSK_DISPLAY1("Find debugee class: %s\n", debugeeClassSignature); debugeeClass = nsk_jvmti_classBySignature(debugeeClassSignature); - if (debugeeClass == NULL) { + if (debugeeClass == nullptr) { nsk_jvmti_setFailStatus(); break; } NSK_DISPLAY1("Find static field in debugee class: %s\n", objectFieldName); if (!NSK_JNI_VERIFY(jni, (objectField = jni->GetStaticFieldID( - debugeeClass, objectFieldName, debugeeClassSignature)) != NULL)) { + debugeeClass, objectFieldName, debugeeClassSignature)) != nullptr)) { nsk_jvmti_setFailStatus(); break; } NSK_DISPLAY1("Find value of static field in debugee class: %s\n", objectFieldName); if (!NSK_JNI_VERIFY(jni, (object = - jni->GetStaticObjectField(debugeeClass, objectField)) != NULL)) { + jni->GetStaticObjectField(debugeeClass, objectField)) != nullptr)) { nsk_jvmti_setFailStatus(); break; } @@ -175,7 +175,7 @@ JNIEXPORT jint JNI_OnLoad_iterobjreachobj005(JavaVM *jvm, char *options, void *r } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -183,7 +183,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* save pointer to environment to use it in callbacks */ @@ -200,7 +200,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverReachableObjects/iterreachobj001/iterreachobj001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverReachableObjects/iterreachobj001/iterreachobj001.cpp index 9052297cacf..a30d854ee0d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverReachableObjects/iterreachobj001/iterreachobj001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverReachableObjects/iterreachobj001/iterreachobj001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -63,7 +63,7 @@ typedef struct ObjectDescStruct { static int chainLength = 0; static int objectsCount = 0; -static ObjectDesc* objectDescList = NULL; +static ObjectDesc* objectDescList = nullptr; static int fakeUserData = 0; static int userDataError = 0; @@ -78,7 +78,7 @@ static int getChainObjects(jvmtiEnv* jvmti, JNIEnv* jni, jobject firstObject, jlong tag, int reachable) { int success = NSK_TRUE; - jobject obj = NULL; + jobject obj = nullptr; jlong objTag = (reachable ? tag : -tag); if (count <= 0) @@ -87,7 +87,7 @@ static int getChainObjects(jvmtiEnv* jvmti, JNIEnv* jni, jobject firstObject, count--; tag++; - if (!NSK_JNI_VERIFY(jni, (obj = jni->GetObjectField(firstObject, firstField)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (obj = jni->GetObjectField(firstObject, firstField)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -112,16 +112,16 @@ static int getChainObjects(jvmtiEnv* jvmti, JNIEnv* jni, jobject firstObject, /** Obtain all tested objects from debugee class and tag them recursively. */ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, int *objectsCount, ObjectDesc* *objectDescList) { - jclass debugeeClass = NULL; - jclass rootObjectClass = NULL; - jclass chainObjectClass = NULL; + jclass debugeeClass = nullptr; + jclass rootObjectClass = nullptr; + jclass chainObjectClass = nullptr; - jfieldID objectField = NULL; - jfieldID reachableChainField = NULL; - jfieldID unreachableChainField = NULL; - jfieldID tailField = NULL; + jfieldID objectField = nullptr; + jfieldID reachableChainField = nullptr; + jfieldID unreachableChainField = nullptr; + jfieldID tailField = nullptr; - jobject rootObject = NULL; + jobject rootObject = nullptr; jlong rootObjectTag = 1; jlong chainObjectTag = 100; @@ -145,14 +145,14 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, } NSK_DISPLAY1("Find debugee class: %s\n", DEBUGEE_CLASS_NAME); - if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } NSK_DISPLAY1(" ... found class: 0x%p\n", (void*)debugeeClass); NSK_DISPLAY1("Find root object class: %s\n", ROOT_OBJECT_CLASS_NAME); - if (!NSK_JNI_VERIFY(jni, (rootObjectClass = jni->FindClass(ROOT_OBJECT_CLASS_NAME)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (rootObjectClass = jni->FindClass(ROOT_OBJECT_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -160,7 +160,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find chain object class: %s\n", CHAIN_OBJECT_CLASS_NAME); if (!NSK_JNI_VERIFY(jni, (chainObjectClass = - jni->FindClass(CHAIN_OBJECT_CLASS_NAME)) != NULL)) { + jni->FindClass(CHAIN_OBJECT_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -168,7 +168,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find static field in debugee class: %s\n", OBJECT_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (objectField = jni->GetStaticFieldID( - debugeeClass, OBJECT_FIELD_NAME, ROOT_OBJECT_CLASS_SIG)) != NULL)) { + debugeeClass, OBJECT_FIELD_NAME, ROOT_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -176,7 +176,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find instance field in root object class: %s\n", REACHABLE_CHAIN_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (reachableChainField = jni->GetFieldID( - rootObjectClass, REACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) { + rootObjectClass, REACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -184,7 +184,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find instance field in root object class: %s\n", UNREACHABLE_CHAIN_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (unreachableChainField = jni->GetFieldID( - rootObjectClass, UNREACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) { + rootObjectClass, UNREACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -192,7 +192,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Find instance field in chain object class: %s\n", TAIL_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (tailField = - jni->GetFieldID(chainObjectClass, TAIL_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetFieldID(chainObjectClass, TAIL_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -200,7 +200,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, NSK_DISPLAY1("Get root object from static field: %s\n", OBJECT_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (rootObject = - jni->GetStaticObjectField(debugeeClass, objectField)) != NULL)) { + jni->GetStaticObjectField(debugeeClass, objectField)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -276,7 +276,7 @@ static int checkTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, /** Release references to the tested objects and free allocated memory. */ static int releaseTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, ObjectDesc* objectDescList) { - if (objectDescList != NULL) { + if (objectDescList != nullptr) { NSK_DISPLAY1("Deallocate objects list: 0x%p\n", (void*)objectDescList); if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)objectDescList))) { nsk_jvmti_setFailStatus(); @@ -297,11 +297,11 @@ heapRootCallback(jvmtiHeapRootKind root_kind, if (info & INFO_HEAPROOT) { NSK_DISPLAY4(" heapRootCallback: root_kind=%2d class_tag=%-3ld size=%-3ld *tag_ptr=%-5ld\n", (int)root_kind, (long)class_tag, (long)size, - (long)(tag_ptr == NULL ? (jlong)0 : *tag_ptr)); + (long)(tag_ptr == nullptr ? (jlong)0 : *tag_ptr)); } - if (tag_ptr == NULL) { - NSK_COMPLAIN4("NULL tag_ptr is passed to heapRootCallback:\n" + if (tag_ptr == nullptr) { + NSK_COMPLAIN4("null tag_ptr is passed to heapRootCallback:\n" "# tag_ptr: 0x%p\n" "# root_kind: %d\n" "# class_tag: %ld\n" @@ -313,7 +313,7 @@ heapRootCallback(jvmtiHeapRootKind root_kind, nsk_jvmti_setFailStatus(); } - if (tag_ptr != NULL && *tag_ptr != 0) { + if (tag_ptr != nullptr && *tag_ptr != 0) { int found = 0; int i; @@ -389,12 +389,12 @@ stackReferenceCallback(jvmtiHeapRootKind root_kind, NSK_DISPLAY8(" stackReferenceCallback: root_kind=%1d class_tag=%-3ld size=%-3ld" " *tag_ptr=%-5ld thread_tag=%-3ld depth=%3d method=0x%p slot=%d\n", (int)root_kind, (long)class_tag, (long)size, - (long)(tag_ptr == NULL ? (jlong)0 : *tag_ptr), + (long)(tag_ptr == nullptr ? (jlong)0 : *tag_ptr), (long)thread_tag, (int)depth, (void*)method, (int)slot); } - if (tag_ptr == NULL) { - NSK_COMPLAIN8("NULL tag_ptr is passed to stackReferenceCallback:\n" + if (tag_ptr == nullptr) { + NSK_COMPLAIN8("null tag_ptr is passed to stackReferenceCallback:\n" "# tag_ptr: 0x%p\n" "# root_kind: %d\n" "# class_tag: %ld\n" @@ -414,7 +414,7 @@ stackReferenceCallback(jvmtiHeapRootKind root_kind, nsk_jvmti_setFailStatus(); } - if (tag_ptr != NULL && *tag_ptr != 0) { + if (tag_ptr != nullptr && *tag_ptr != 0) { int found = 0; int i; @@ -514,12 +514,12 @@ objectReferenceCallback(jvmtiObjectReferenceKind reference_kind, NSK_DISPLAY6(" objectReferenceCallback: ref_kind=%1d class_tag=%-3ld size=%-3ld" " *tag_ptr=%-5ld ref_tag=%-5ld ref_idx=%d\n", (int)reference_kind, (long)class_tag, (long)size, - (long)(tag_ptr == NULL ? (jlong)0 : *tag_ptr), + (long)(tag_ptr == nullptr ? (jlong)0 : *tag_ptr), (long)refferrer_tag, (int)refferrer_index); } - if (tag_ptr == NULL) { - NSK_COMPLAIN6("NULL tag_ptr is passed to objectReferenceCallback:\n" + if (tag_ptr == nullptr) { + NSK_COMPLAIN6("null tag_ptr is passed to objectReferenceCallback:\n" "# tag_ptr: 0x%p\n" "# reference_kind: %d\n" "# class_tag: %ld\n" @@ -535,7 +535,7 @@ objectReferenceCallback(jvmtiObjectReferenceKind reference_kind, nsk_jvmti_setFailStatus(); } - if (tag_ptr != NULL && *tag_ptr != 0) { + if (tag_ptr != nullptr && *tag_ptr != 0) { int found = 0; int i; @@ -670,7 +670,7 @@ JNIEXPORT jint JNI_OnLoad_iterreachobj001(JavaVM *jvm, char *options, void *rese } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -679,7 +679,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { { const char* infoOpt = nsk_jvmti_findOptionValue("info"); - if (infoOpt != NULL) { + if (infoOpt != nullptr) { if (strcmp(infoOpt, "none") == 0) info = INFO_NONE; else if (strcmp(infoOpt, "all") == 0) @@ -704,7 +704,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; { @@ -717,7 +717,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverReachableObjects/iterreachobj002/iterreachobj002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverReachableObjects/iterreachobj002/iterreachobj002.cpp index f732196a778..549a1f3370f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverReachableObjects/iterreachobj002/iterreachobj002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverReachableObjects/iterreachobj002/iterreachobj002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -29,8 +29,8 @@ extern "C" { -static JNIEnv *jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv *jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jvmtiCapabilities caps; static jlong timeout = 0; @@ -446,7 +446,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; memset(&caps, 0, sizeof(caps)); @@ -477,11 +477,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { NSK_DISPLAY0("enabling JVMTI events ...\n"); if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_OBJECT_FREE, - NULL))) + nullptr))) return JNI_ERR; NSK_DISPLAY0("enabling the events done.\n"); - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverReachableObjects/iterreachobj003/iterreachobj003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverReachableObjects/iterreachobj003/iterreachobj003.cpp index 2f8ba14ad66..296fddccb97 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverReachableObjects/iterreachobj003/iterreachobj003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverReachableObjects/iterreachobj003/iterreachobj003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -35,7 +35,7 @@ static jlong timeout = 0; static long objCounter = 0; static int userData = 0; -static jvmtiEnv* st_jvmti = NULL; +static jvmtiEnv* st_jvmti = nullptr; /* ============================================================================= */ @@ -50,7 +50,7 @@ heapRootCallback(jvmtiHeapRootKind root_kind, jlong* tag_ptr, void* user_data) { - jrawMonitorID monitor_ptr = NULL; + jrawMonitorID monitor_ptr = nullptr; *tag_ptr = (jlong)++objCounter; @@ -114,7 +114,7 @@ stackReferenceCallback(jvmtiHeapRootKind root_kind, jint slot, void* user_data) { - jrawMonitorID monitor_ptr = NULL; + jrawMonitorID monitor_ptr = nullptr; *tag_ptr = (jlong)++objCounter; @@ -177,7 +177,7 @@ objectReferenceCallback(jvmtiObjectReferenceKind reference_kind, jint referrer_index, void* user_data) { - jrawMonitorID monitor_ptr = NULL; + jrawMonitorID monitor_ptr = nullptr; *tag_ptr = (jlong)++objCounter; @@ -285,7 +285,7 @@ JNIEXPORT jint JNI_OnLoad_iterreachobj003(JavaVM *jvm, char *options, void *rese } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -293,7 +293,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* save pointer to environment to use it in callbacks */ @@ -309,7 +309,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverReachableObjects/iterreachobj004/iterreachobj004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverReachableObjects/iterreachobj004/iterreachobj004.cpp index 6557dbf9d5b..b6299fc09cb 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverReachableObjects/iterreachobj004/iterreachobj004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverReachableObjects/iterreachobj004/iterreachobj004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -35,9 +35,9 @@ static jlong timeout = 0; static long objCounter = 0; static int userData = 0; -static jvmtiEnv* st_jvmti = NULL; +static jvmtiEnv* st_jvmti = nullptr; static const char *storage_data = "local_storage_data"; -static void *storage_ptr = NULL; +static void *storage_ptr = nullptr; /* ============================================================================= */ @@ -226,7 +226,7 @@ JNIEXPORT jint JNI_OnLoad_iterreachobj004(JavaVM *jvm, char *options, void *rese } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -234,7 +234,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* save pointer to environment to use it in callbacks */ @@ -250,7 +250,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverReachableObjects/iterreachobj005/iterreachobj005.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverReachableObjects/iterreachobj005/iterreachobj005.cpp index 27137426b19..b3a3a6fc288 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverReachableObjects/iterreachobj005/iterreachobj005.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverReachableObjects/iterreachobj005/iterreachobj005.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -35,7 +35,7 @@ static jlong timeout = 0; static long objCounter = 0; static int userData = 0; -static jvmtiEnv* st_jvmti = NULL; +static jvmtiEnv* st_jvmti = nullptr; static jlong nanos = 0; static jvmtiTimerInfo timer_info1, timer_info2; @@ -295,7 +295,7 @@ JNIEXPORT jint JNI_OnLoad_iterreachobj005(JavaVM *jvm, char *options, void *rese } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -303,7 +303,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* save pointer to environment to use it in callbacks */ @@ -320,7 +320,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateThroughHeap/abort/Abort.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateThroughHeap/abort/Abort.cpp index 9e1bd12bcc1..b019be65f49 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateThroughHeap/abort/Abort.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateThroughHeap/abort/Abort.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, 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 @@ agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { int invocations = 0; NSK_DISPLAY0("Waiting debugee.\n"); - if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, NULL))) { + if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, nullptr))) { return; } if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) { @@ -95,7 +95,7 @@ agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { primitive_callbacks.heap_iteration_callback = &heap_callback; NSK_DISPLAY0("Iterating over reachable objects.\n"); - if (!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(0, NULL, &primitive_callbacks, &invocations))) { + if (!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(0, nullptr, &primitive_callbacks, &invocations))) { nsk_jvmti_setFailStatus(); return; } @@ -127,7 +127,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiEventCallbacks event_callbacks; jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) { + if (!NSK_VERIFY(jvmti != nullptr)) { return JNI_ERR; } @@ -148,7 +148,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agent, NULL))) { + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agent, nullptr))) { return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateThroughHeap/callbacks/Callbacks.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateThroughHeap/callbacks/Callbacks.cpp index 315a07f38e2..b1438acceb0 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateThroughHeap/callbacks/Callbacks.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateThroughHeap/callbacks/Callbacks.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, 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 @@ -368,13 +368,13 @@ int tag_objects(jvmtiEnv *jvmti, JNIEnv *jni) { jobjectArray testObjects; int object; - if (!NSK_VERIFY(NULL != (debugee = jni->FindClass(className)))) + if (!NSK_VERIFY(nullptr != (debugee = jni->FindClass(className)))) return JNI_ERR; - if (!NSK_VERIFY(NULL != (testObjectsField = jni->GetStaticFieldID(debugee, fieldName, fieldSig)))) + if (!NSK_VERIFY(nullptr != (testObjectsField = jni->GetStaticFieldID(debugee, fieldName, fieldSig)))) return JNI_ERR; - if (!NSK_VERIFY(NULL != (testObjects = (jobjectArray)(jni->GetStaticObjectField( + if (!NSK_VERIFY(nullptr != (testObjects = (jobjectArray)(jni->GetStaticObjectField( debugee, testObjectsField))))) return JNI_ERR; @@ -386,13 +386,13 @@ int tag_objects(jvmtiEnv *jvmti, JNIEnv *jni) { jint field; memset(&objects_info[object],0,sizeof(object_info_t)); - if (!NSK_VERIFY(NULL != (target = jni->GetObjectArrayElement(testObjects, object)))) + if (!NSK_VERIFY(nullptr != (target = jni->GetObjectArrayElement(testObjects, object)))) return JNI_ERR; - if (!NSK_VERIFY(NULL != (targetClass = jni->GetObjectClass(target)))) + if (!NSK_VERIFY(nullptr != (targetClass = jni->GetObjectClass(target)))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->GetClassSignature(targetClass, &(objects_info[object].name), NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->GetClassSignature(targetClass, &(objects_info[object].name), nullptr))) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->GetClassFields( @@ -407,7 +407,7 @@ int tag_objects(jvmtiEnv *jvmti, JNIEnv *jni) { targetFields[field], &objects_info[object].fields[field].name, &objects_info[object].fields[field].signature, - NULL))) + nullptr))) return JNI_ERR; if (is_primitive_type(objects_info[object].fields[field].signature)) { objects_info[object].fields[field].primitive = 1; @@ -420,12 +420,12 @@ int tag_objects(jvmtiEnv *jvmti, JNIEnv *jni) { return JNI_ERR; } if (modifiers & STATIC_FIELD) { - if (!NSK_VERIFY(NULL != (value = jni->GetStaticObjectField(targetClass, + if (!NSK_VERIFY(nullptr != (value = jni->GetStaticObjectField(targetClass, targetFields[field])))) { return JNI_ERR; } } else { - if (!NSK_VERIFY(NULL != (value = jni->GetObjectField(target, targetFields[field])))) { + if (!NSK_VERIFY(nullptr != (value = jni->GetObjectField(target, targetFields[field])))) { return JNI_ERR; } } @@ -515,7 +515,7 @@ agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { jvmtiHeapCallbacks primitive_callbacks; NSK_DISPLAY0("Waiting debugee.\n"); - if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, NULL))) { + if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, nullptr))) { return; } if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) { @@ -534,7 +534,7 @@ agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { primitive_callbacks.heap_iteration_callback = &heap_callback; NSK_DISPLAY0("Iterating over reachable objects.\n"); - if (!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(0, NULL, &primitive_callbacks, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(0, nullptr, &primitive_callbacks, nullptr))) { nsk_jvmti_setFailStatus(); return; } @@ -551,7 +551,7 @@ agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { } NSK_DISPLAY0("Iterating over unreachable objects.\n"); - if (!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(0, NULL, &primitive_callbacks, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(0, nullptr, &primitive_callbacks, nullptr))) { nsk_jvmti_setFailStatus(); return; } @@ -559,7 +559,7 @@ agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY0("Verifying that all filds were found.\n"); verify_objects(); - if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_DISABLE, 1, &event, NULL))) { + if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_DISABLE, 1, &event, nullptr))) { return; } @@ -586,7 +586,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiEventCallbacks event_callbacks; jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) { + if (!NSK_VERIFY(jvmti != nullptr)) { return JNI_ERR; } @@ -608,7 +608,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agent, NULL))) { + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agent, nullptr))) { return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateThroughHeap/concrete-klass-filter/ConcreteKlassFilter.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateThroughHeap/concrete-klass-filter/ConcreteKlassFilter.cpp index 599f95bc479..1886e1cc3d6 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateThroughHeap/concrete-klass-filter/ConcreteKlassFilter.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateThroughHeap/concrete-klass-filter/ConcreteKlassFilter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, 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 @@ -152,16 +152,16 @@ int tag_objects(jvmtiEnv *jvmti, JNIEnv *jni) { jobject testObject; jclass testObjectClass; - if (!NSK_VERIFY(NULL != (debugee = jni->FindClass(className)))) + if (!NSK_VERIFY(nullptr != (debugee = jni->FindClass(className)))) return JNI_ERR; - if (!NSK_VERIFY(NULL != (testObjectField = jni->GetStaticFieldID(debugee, fieldName, fieldSig)))) + if (!NSK_VERIFY(nullptr != (testObjectField = jni->GetStaticFieldID(debugee, fieldName, fieldSig)))) return JNI_ERR; - if (!NSK_VERIFY(NULL != (testObject = (jni->GetStaticObjectField(debugee, testObjectField))))) + if (!NSK_VERIFY(nullptr != (testObject = (jni->GetStaticObjectField(debugee, testObjectField))))) return JNI_ERR; - if (!NSK_VERIFY(NULL != (testObjectClass = (jni->GetObjectClass(testObject))))) + if (!NSK_VERIFY(nullptr != (testObjectClass = (jni->GetObjectClass(testObject))))) return JNI_ERR; // tag class and it's instance to pass this tag into primitive field callback @@ -197,14 +197,14 @@ agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { jvmtiHeapCallbacks primitive_callbacks; jclass klass; - if (!NSK_VERIFY(NULL != (klass = jni->FindClass(testClassName)))) { + if (!NSK_VERIFY(nullptr != (klass = jni->FindClass(testClassName)))) { NSK_COMPLAIN1("Can't find class %s.\n",testClassName); nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY0("Waiting debugee.\n"); - if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, NULL))) { + if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, nullptr))) { return; } if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) { @@ -223,7 +223,7 @@ agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { primitive_callbacks.heap_iteration_callback = &heap_callback; NSK_DISPLAY0("Iterating over reachable objects.\n"); - if (!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(0, klass, &primitive_callbacks, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(0, klass, &primitive_callbacks, nullptr))) { nsk_jvmti_setFailStatus(); return; } @@ -240,7 +240,7 @@ agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { } NSK_DISPLAY0("Iterating over unreachable objects.\n"); - if (!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(0, klass, &primitive_callbacks, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(0, klass, &primitive_callbacks, nullptr))) { nsk_jvmti_setFailStatus(); return; } @@ -269,7 +269,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiEventCallbacks event_callbacks; jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) { + if (!NSK_VERIFY(jvmti != nullptr)) { return JNI_ERR; } @@ -291,7 +291,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agent, NULL))) { + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agent, nullptr))) { return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateThroughHeap/filter-tagged/HeapFilter.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateThroughHeap/filter-tagged/HeapFilter.cpp index 983aa4a122d..ea3ad39b92a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateThroughHeap/filter-tagged/HeapFilter.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateThroughHeap/filter-tagged/HeapFilter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, 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 @@ -294,13 +294,13 @@ int tag_objects(jvmtiEnv *jvmti, JNIEnv *jni) { jobjectArray testObjects; int object; - if (!NSK_VERIFY(NULL != (debugee = jni->FindClass(className)))) + if (!NSK_VERIFY(nullptr != (debugee = jni->FindClass(className)))) return JNI_ERR; - if (!NSK_VERIFY(NULL != (testObjectsField = jni->GetStaticFieldID(debugee, fieldName, fieldSig)))) + if (!NSK_VERIFY(nullptr != (testObjectsField = jni->GetStaticFieldID(debugee, fieldName, fieldSig)))) return JNI_ERR; - if (!NSK_VERIFY(NULL != (testObjects = (jobjectArray)(jni->GetStaticObjectField( + if (!NSK_VERIFY(nullptr != (testObjects = (jobjectArray)(jni->GetStaticObjectField( debugee, testObjectsField))))) return JNI_ERR; @@ -313,13 +313,13 @@ int tag_objects(jvmtiEnv *jvmti, JNIEnv *jni) { int tagged = object == 0; memset(&objects_info[object],0,sizeof(object_info_t)); - if (!NSK_VERIFY(NULL != (target = jni->GetObjectArrayElement(testObjects, object)))) + if (!NSK_VERIFY(nullptr != (target = jni->GetObjectArrayElement(testObjects, object)))) return JNI_ERR; - if (!NSK_VERIFY(NULL != (targetClass = jni->GetObjectClass(target)))) + if (!NSK_VERIFY(nullptr != (targetClass = jni->GetObjectClass(target)))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->GetClassSignature(targetClass, &(objects_info[object].name), NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->GetClassSignature(targetClass, &(objects_info[object].name), nullptr))) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->GetClassFields( @@ -337,7 +337,7 @@ int tag_objects(jvmtiEnv *jvmti, JNIEnv *jni) { targetFields[field], &objects_info[object].fields[field].name, &objects_info[object].fields[field].signature, - NULL))) + nullptr))) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->GetFieldModifiers( targetClass, targetFields[field], &modifiers))) { @@ -362,12 +362,12 @@ int tag_objects(jvmtiEnv *jvmti, JNIEnv *jni) { return JNI_ERR; } if (is_static) { - if (!NSK_VERIFY(NULL != (value = jni->GetStaticObjectField( + if (!NSK_VERIFY(nullptr != (value = jni->GetStaticObjectField( targetClass, targetFields[field])))) { return JNI_ERR; } } else { - if (!NSK_VERIFY(NULL != (value = jni->GetObjectField(target, targetFields[field])))) { + if (!NSK_VERIFY(nullptr != (value = jni->GetObjectField(target, targetFields[field])))) { return JNI_ERR; } } @@ -456,7 +456,7 @@ agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { jvmtiEventCallbacks event_callbacks; NSK_DISPLAY0("Waiting debugee.\n"); - if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, NULL))) { + if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, nullptr))) { return; } if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) { @@ -475,7 +475,7 @@ agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { primitive_callbacks.heap_iteration_callback = &heap_callback; NSK_DISPLAY0("Iterating over reachable objects.\n"); - if (!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(filter_type, NULL, &primitive_callbacks, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(filter_type, nullptr, &primitive_callbacks, nullptr))) { nsk_jvmti_setFailStatus(); return; } @@ -492,7 +492,7 @@ agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { } NSK_DISPLAY0("Iterating over unreachable objects.\n"); - if (!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(filter_type, NULL, &primitive_callbacks, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(filter_type, nullptr, &primitive_callbacks, nullptr))) { nsk_jvmti_setFailStatus(); return; } @@ -533,14 +533,14 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { const char *type; jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) { + if (!NSK_VERIFY(jvmti != nullptr)) { return JNI_ERR; } nsk_jvmti_parseOptions(options); type = nsk_jvmti_findOptionValue("filter"); - if (type != NULL) { + if (type != nullptr) { if (0 == strcmp(type, "JVMTI_HEAP_FILTER_TAGGED")) { filter_type = JVMTI_HEAP_FILTER_TAGGED; } else if (0 == strcmp(type, "JVMTI_HEAP_FILTER_UNTAGGED")) { @@ -574,7 +574,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agent, NULL))) { + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agent, nullptr))) { return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateThroughHeap/non-concrete-klass-filter/NonConcreteKlassFilter.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateThroughHeap/non-concrete-klass-filter/NonConcreteKlassFilter.cpp index b0617bce297..20515df1b86 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateThroughHeap/non-concrete-klass-filter/NonConcreteKlassFilter.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateThroughHeap/non-concrete-klass-filter/NonConcreteKlassFilter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, 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 @@ -141,7 +141,7 @@ agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { int i; NSK_DISPLAY0("Waiting debugee.\n"); - if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, NULL))) { + if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, nullptr))) { return; } if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) { @@ -156,13 +156,13 @@ agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { phase = ZERO_INVOCATIONS_PHASE; for (i = 0; i < FILTER_COUNT; i++) { - if (!NSK_VERIFY(NULL != (klass = jni->FindClass(types[i])))) { + if (!NSK_VERIFY(nullptr != (klass = jni->FindClass(types[i])))) { NSK_COMPLAIN1("Can't find class %s.\n",types[i]); nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY1("Iterating through heap with klass-filter '%s'.\n",types[i]); - if (!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(0, klass, &primitive_callbacks, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(0, klass, &primitive_callbacks, nullptr))) { nsk_jvmti_setFailStatus(); return; } @@ -170,12 +170,12 @@ agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { phase = STATIC_FIELDS_FINDING_PHASE; NSK_DISPLAY0("Iterating through heap with klass-filter 'java/lang/Class'.\n"); - if (!NSK_VERIFY(NULL != (klass = jni->FindClass("java/lang/Class")))) { + if (!NSK_VERIFY(nullptr != (klass = jni->FindClass("java/lang/Class")))) { NSK_COMPLAIN0("Can't find class java/lang/Class.\n"); nsk_jvmti_setFailStatus(); return; } - if (!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(0, klass, &primitive_callbacks, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(0, klass, &primitive_callbacks, nullptr))) { nsk_jvmti_setFailStatus(); return; } @@ -209,7 +209,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiEventCallbacks event_callbacks; jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) { + if (!NSK_VERIFY(jvmti != nullptr)) { return JNI_ERR; } @@ -230,7 +230,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agent, NULL))) { + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agent, nullptr))) { return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NotifyFramePop/nframepop001/nframepop001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NotifyFramePop/nframepop001/nframepop001.cpp index 31e569a39aa..50f52d7c0cf 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NotifyFramePop/nframepop001/nframepop001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NotifyFramePop/nframepop001/nframepop001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,15 +33,15 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; static jint result = PASSED; static jmethodID mid1, mid2; -static jthread currThread = NULL, popThread = NULL; -static jclass currClass = NULL, popClass = NULL; -static jmethodID currMethod = NULL, popMethod = NULL; +static jthread currThread = nullptr, popThread = nullptr; +static jclass currClass = nullptr, popClass = nullptr; +static jmethodID currMethod = nullptr, popMethod = nullptr; static jboolean currFlag = JNI_FALSE, popFlag = JNI_FALSE; static jint currLoc = 0, popLoc = 0; @@ -133,7 +133,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -190,7 +190,7 @@ Java_nsk_jvmti_NotifyFramePop_nframepop001_getMethIds(JNIEnv *env, jclass cl) { if (caps.can_generate_frame_pop_events) { err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_FRAME_POP, NULL); + JVMTI_EVENT_FRAME_POP, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable FRAME_POP event: %s (%d)\n", TranslateError(err), err); @@ -200,14 +200,14 @@ Java_nsk_jvmti_NotifyFramePop_nframepop001_getMethIds(JNIEnv *env, jclass cl) { } mid1 = env->GetMethodID(cl, "meth01", "(I)V"); - if (mid1 == NULL) { + if (mid1 == nullptr) { printf("Cannot find method \"meth01\"\n"); result = STATUS_FAILED; return; } mid2 = env->GetMethodID(cl, "meth02", "(I)V"); - if (mid2 == NULL) { + if (mid2 == nullptr) { printf("Cannot find method \"meth02\"\n"); result = STATUS_FAILED; return; @@ -215,7 +215,7 @@ Java_nsk_jvmti_NotifyFramePop_nframepop001_getMethIds(JNIEnv *env, jclass cl) { if (caps.can_generate_exception_events) { err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_EXCEPTION_CATCH, NULL); + JVMTI_EVENT_EXCEPTION_CATCH, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable EXCEPTION_CATCH event: %s (%d)\n", TranslateError(err), err); @@ -245,7 +245,7 @@ Java_nsk_jvmti_NotifyFramePop_nframepop001_setFramePopNotif(JNIEnv *env, currThread = env->NewGlobalRef(thr); currClass = env->FindClass("nsk/jvmti/NotifyFramePop/nframepop001a"); - if (currClass == NULL) { + if (currClass == nullptr) { printf("Cannot find nsk.jvmti.NotifyFramePop.nframepop001a class!\n"); result = STATUS_FAILED; return; @@ -253,7 +253,7 @@ Java_nsk_jvmti_NotifyFramePop_nframepop001_setFramePopNotif(JNIEnv *env, currClass = (jclass) env->NewGlobalRef(currClass); currMethod = env->GetMethodID(currClass, "run", "()V"); - if (currMethod == NULL) { + if (currMethod == nullptr) { printf("Cannot find method \"run\"\n"); result = STATUS_FAILED; } @@ -319,9 +319,9 @@ Java_nsk_jvmti_NotifyFramePop_nframepop001_checkFrame(JNIEnv *env, result = STATUS_FAILED; } - currThread = NULL; popThread = NULL; - currClass = NULL; popClass = NULL; - currMethod = NULL; popMethod = NULL; + currThread = nullptr; popThread = nullptr; + currClass = nullptr; popClass = nullptr; + currMethod = nullptr; popMethod = nullptr; currFlag = JNI_FALSE; popFlag = JNI_FALSE; currLoc = 0; popLoc = 0; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NotifyFramePop/nframepop002/nframepop002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NotifyFramePop/nframepop002/nframepop002.cpp index 8faa9177cb5..09f6da40b33 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NotifyFramePop/nframepop002/nframepop002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NotifyFramePop/nframepop002/nframepop002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; @@ -53,7 +53,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -91,7 +91,7 @@ Java_nsk_jvmti_NotifyFramePop_nframepop002_check(JNIEnv *env, jclass cls, jthread thread) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NotifyFramePop/nframepop003/nframepop003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NotifyFramePop/nframepop003/nframepop003.cpp index 201a7cd26b9..325eb23f3b9 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NotifyFramePop/nframepop003/nframepop003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NotifyFramePop/nframepop003/nframepop003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; @@ -53,7 +53,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -91,7 +91,7 @@ Java_nsk_jvmti_NotifyFramePop_nframepop003_check(JNIEnv *env, jclass cls, jthread thread) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ObjectFree/objfree001/objfree001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ObjectFree/objfree001/objfree001.cpp index 2a14eee0629..b81c2c9a43e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ObjectFree/objfree001/objfree001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ObjectFree/objfree001/objfree001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ extern "C" { static const char *CLASS_SIG = "Lnsk/jvmti/ObjectFree/objfree001u;"; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static volatile jint result = PASSED; @@ -131,7 +131,7 @@ static void memoryFunc(jvmtiEnv *jvmti_env, const char *msg) { } static void envStorageFunc(jvmtiEnv *jvmti_env, const char *msg) { - LocalStorage* obtainedData = NULL; + LocalStorage* obtainedData = nullptr; LocalStorage* storedData = &stor; NSK_DISPLAY2("%s: setting an environment local storage 0x%p ...\n", @@ -253,7 +253,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add capability to generate compiled method events */ @@ -282,11 +282,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { NSK_DISPLAY0("setting event callbacks done\nenabling JVMTI events ...\n"); if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, - NULL))) + nullptr))) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_OBJECT_FREE, - NULL))) + nullptr))) return JNI_ERR; NSK_DISPLAY0("enabling the events done\n\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ObjectFree/objfree002/objfree002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ObjectFree/objfree002/objfree002.cpp index 7e1be9da537..c3fc8621feb 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ObjectFree/objfree002/objfree002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ObjectFree/objfree002/objfree002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ extern "C" { #define MEM_SIZE 1024 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jvmtiCapabilities caps; @@ -161,7 +161,7 @@ static void memoryFunc(jvmtiEnv *jvmti_env, const char *msg) { } static void envStorageFunc(jvmtiEnv *jvmti_env, const char *msg) { - LocalStorage* obtainedData = NULL; + LocalStorage* obtainedData = nullptr; LocalStorage* storedData = &stor; NSK_DISPLAY2("%s: setting an environment local storage 0x%p ...\n", @@ -273,7 +273,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add capability to generate compiled method events */ @@ -302,11 +302,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { NSK_DISPLAY0("setting event callbacks done\nenabling JVMTI events ...\n"); if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, - NULL))) + nullptr))) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_OBJECT_FREE, - NULL))) + nullptr))) return JNI_ERR; NSK_DISPLAY0("enabling the events done\n\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe001/popframe001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe001/popframe001.cpp index 4d3332c2079..661219e3174 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe001/popframe001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe001/popframe001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define STATUS_FAILED 2 #define PASSED 0 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; static int watch_ev = 0; /* ignore JVMTI events by default */ @@ -175,7 +175,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe002/popframe002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe002/popframe002.cpp index 429af71866a..6be72a9ee18 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe002/popframe002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe002/popframe002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -102,12 +102,12 @@ Java_nsk_jvmti_PopFrame_popframe002_doPopFrame(JNIEnv *env, } switch (t_case) { - /* NULL pointer to the thread*/ + /* nullptr pointer to the thread*/ case 1: - printf("\nInvoke PopFrame() with NULL pointer to a thread...\n"); + printf("\nInvoke PopFrame() with null pointer to a thread...\n"); fflush(stdout); set_watch_ev(1); /* watch JVMTI events */ - err = (jvmti->PopFrame(NULL)); /* explode the bomb */ + err = (jvmti->PopFrame(nullptr)); /* explode the bomb */ if (err != JVMTI_ERROR_INVALID_THREAD) { printf("TEST FAILED: the function PopFrame() returned the error %d: %s\n", err, TranslateError(err)); @@ -193,7 +193,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe003/popframe003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe003/popframe003.cpp index f956c01f3aa..958d14a52c2 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe003/popframe003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe003/popframe003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -177,7 +177,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe004/popframe004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe004/popframe004.cpp index 3c8f1743d0d..46457aced4d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe004/popframe004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe004/popframe004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -219,7 +219,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -286,10 +286,10 @@ Java_nsk_jvmti_PopFrame_popframe004_getResult(JNIEnv *env, jclass cls) { void nativeMeth2(JNIEnv *env, jobject obj, jobject frameThr) { jclass cls = env->GetObjectClass(frameThr); - jmethodID mid = NULL; + jmethodID mid = nullptr; mid = env->GetMethodID(cls, "activeMethod", "()V"); - if (mid == NULL) { + if (mid == nullptr) { printf("TEST FAILURE: nativeMeth2(): Unable to get method ID\n"); tot_result = STATUS_FAILED; return; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe005/popframe005.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe005/popframe005.cpp index ca918df7575..089c4dd5514 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe005/popframe005.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe005/popframe005.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -32,7 +32,7 @@ extern "C" { // Deallocate memory region allocated by VM #define DEALLOCATE(p) \ - if (p != NULL) \ + if (p != nullptr) \ if (!NSK_JVMTI_VERIFY(jvmti->Deallocate(p))) \ { \ NSK_COMPLAIN0("Failed to deallocate: ##p##\n"); \ @@ -106,12 +106,12 @@ MethodExit( break; } - if (!NSK_JVMTI_VERIFY(jvmti->GetClassSignature(klass, &class_signature, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->GetClassSignature(klass, &class_signature, nullptr))) { break; } - if (!NSK_JVMTI_VERIFY(jvmti->GetMethodName(method, &entry_name, &entry_sig, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->GetMethodName(method, &entry_name, &entry_sig, nullptr))) { break; } @@ -119,7 +119,7 @@ MethodExit( failure = 0; NSK_COMPLAIN5("#### MethodExit event occurred: (tid: %d), thread: %s, %s %s %s\n" , thread - , thr_info.name == NULL ? "" : thr_info.name + , thr_info.name == nullptr ? "" : thr_info.name , class_signature , entry_name , entry_sig @@ -254,7 +254,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) } if (!NSK_VERIFY( - (jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved)) != NULL + (jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved)) != nullptr )) { return JNI_ERR; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe006/popframe006.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe006/popframe006.cpp index 2c288f29d94..324160b40d7 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe006/popframe006.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe006/popframe006.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -40,7 +40,7 @@ typedef struct { jlocation loc; } check_info; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; static jint result = PASSED; @@ -109,17 +109,17 @@ void check(jvmtiEnv *jvmti_env, jmethodID mid, jlocation loc, int i) { return; } - if (sigClass == NULL || strcmp(sigClass, checks[i].cls) != 0) { + if (sigClass == nullptr || strcmp(sigClass, checks[i].cls) != 0) { printf("(%s, %d) wrong class sig: \"%s\",\n", note, i, sigClass); printf(" expected: \"%s\"\n", checks[i].cls); result = STATUS_FAILED; } - if (name == NULL || strcmp(name, checks[i].name) != 0) { + if (name == nullptr || strcmp(name, checks[i].name) != 0) { printf("(%s, %d) wrong method name: \"%s\",", note, i, name); printf(" expected: \"%s\"\n", checks[i].name); result = STATUS_FAILED; } - if (sig == NULL || strcmp(sig, checks[i].sig) != 0) { + if (sig == nullptr || strcmp(sig, checks[i].sig) != 0) { printf("(%s, %d) wrong method sig: \"%s\",", note, i, sig); printf(" expected: \"%s\"\n", checks[i].sig); result = STATUS_FAILED; @@ -349,12 +349,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -409,7 +409,7 @@ Java_nsk_jvmti_PopFrame_popframe006_getReady(JNIEnv *env, jvmtiError err; jclass clazz; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; @@ -424,35 +424,35 @@ Java_nsk_jvmti_PopFrame_popframe006_getReady(JNIEnv *env, } clazz = env->GetObjectClass(thr); - if (clazz == NULL) { + if (clazz == nullptr) { printf("Cannot get the class of thread object\n"); result = STATUS_FAILED; return; } mid_run = env->GetMethodID(clazz, "run", "()V"); - if (mid_run == NULL) { + if (mid_run == nullptr) { printf("Cannot find Method ID for method \"run\"\n"); result = STATUS_FAILED; return; } mid_A = env->GetStaticMethodID(clazz, "A", "()V"); - if (mid_A == NULL) { + if (mid_A == nullptr) { printf("Cannot find Method ID for method \"A\"\n"); result = STATUS_FAILED; return; } mid_B = env->GetStaticMethodID(clazz, "B", "()V"); - if (mid_B == NULL) { + if (mid_B == nullptr) { printf("Cannot find Method ID for method \"B\"\n"); result = STATUS_FAILED; return; } mid_C = env->GetStaticMethodID(clazz, "C", "()V"); - if (mid_C == NULL) { + if (mid_C == nullptr) { printf("Cannot find Method ID for method \"C\"\n"); result = STATUS_FAILED; return; @@ -467,7 +467,7 @@ Java_nsk_jvmti_PopFrame_popframe006_getReady(JNIEnv *env, } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_BREAKPOINT, NULL); + JVMTI_EVENT_BREAKPOINT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable BREAKPOINT event: %s (%d)\n", TranslateError(err), err); @@ -481,7 +481,7 @@ Java_nsk_jvmti_PopFrame_popframe006_getReady(JNIEnv *env, } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_FRAME_POP, NULL); + JVMTI_EVENT_FRAME_POP, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable FRAME_POP event: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe007/popframe007.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe007/popframe007.cpp index ca4b9004595..db699216695 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe007/popframe007.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe007/popframe007.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; static jint result = PASSED; @@ -86,12 +86,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -142,7 +142,7 @@ Java_nsk_jvmti_PopFrame_popframe007_getReady(JNIEnv *env, jvmtiError err; jclass clazz; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; @@ -153,14 +153,14 @@ Java_nsk_jvmti_PopFrame_popframe007_getReady(JNIEnv *env, } clazz = env->GetObjectClass(thr); - if (clazz == NULL) { + if (clazz == nullptr) { printf("Cannot get class of the thread object\n"); result = STATUS_FAILED; return; } mid = env->GetStaticMethodID(clazz, "C", "()V"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot find Method ID for method \"C\"\n"); result = STATUS_FAILED; return; @@ -175,7 +175,7 @@ Java_nsk_jvmti_PopFrame_popframe007_getReady(JNIEnv *env, } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_BREAKPOINT, NULL); + JVMTI_EVENT_BREAKPOINT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable BREAKPOINT event: %s (%d)\n", TranslateError(err), err); @@ -190,7 +190,7 @@ Java_nsk_jvmti_PopFrame_popframe007_getRes(JNIEnv *env, jclass cls) { JNIEXPORT void JNICALL Java_nsk_jvmti_PopFrame_popframe007_B(JNIEnv *env, jclass cls) { - if (mid != NULL) { + if (mid != nullptr) { env->CallStaticVoidMethod(cls, mid); } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe008/popframe008.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe008/popframe008.cpp index 8c669c20318..430f19624d0 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe008/popframe008.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe008/popframe008.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -40,13 +40,13 @@ typedef struct { jlocation loc; } frame_info; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; static jint result = PASSED; static jboolean printdump = JNI_FALSE; -static jmethodID midD = NULL; -static jmethodID midRun = NULL; +static jmethodID midD = nullptr; +static jmethodID midRun = nullptr; static int framesExpected = 0; static int framesCount = 0; static frame_info frames[] = { @@ -83,17 +83,17 @@ void check(jvmtiEnv *jvmti_env, jmethodID mid, jlocation loc, int i) { result = STATUS_FAILED; } - if (sigClass == NULL || strcmp(sigClass, frames[i].cls) != 0) { + if (sigClass == nullptr || strcmp(sigClass, frames[i].cls) != 0) { printf("(%d) wrong class sig: \"%s\",\n", i, sigClass); printf(" expected: \"%s\"\n", frames[i].cls); result = STATUS_FAILED; } - if (name == NULL || strcmp(name, frames[i].name) != 0) { + if (name == nullptr || strcmp(name, frames[i].name) != 0) { printf("(%d) wrong method name: \"%s\",", i, name); printf(" expected: \"%s\"\n", frames[i].name); result = STATUS_FAILED; } - if (sig == NULL || strcmp(sig, frames[i].sig) != 0) { + if (sig == nullptr || strcmp(sig, frames[i].sig) != 0) { printf("(%d) wrong method sig: \"%s\",", i, sig); printf(" expected: \"%s\"\n", frames[i].sig); result = STATUS_FAILED; @@ -195,12 +195,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -253,7 +253,7 @@ Java_nsk_jvmti_PopFrame_popframe008_getReady(JNIEnv *env, jvmtiError err; jclass clazz; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; @@ -266,21 +266,21 @@ Java_nsk_jvmti_PopFrame_popframe008_getReady(JNIEnv *env, } clazz = env->GetObjectClass(thr); - if (clazz == NULL) { + if (clazz == nullptr) { printf("Cannot get class of the thread object\n"); result = STATUS_FAILED; return; } midD = env->GetMethodID(clazz, "D", "()V"); - if (midD == NULL) { + if (midD == nullptr) { printf("Cannot get Method ID for method \"D\"\n"); result = STATUS_FAILED; return; } midRun = env->GetMethodID(clazz, "run", "()V"); - if (midRun == NULL) { + if (midRun == nullptr) { printf("Cannot get Method ID for method \"run\"\n"); result = STATUS_FAILED; return; @@ -295,7 +295,7 @@ Java_nsk_jvmti_PopFrame_popframe008_getReady(JNIEnv *env, } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_BREAKPOINT, NULL); + JVMTI_EVENT_BREAKPOINT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable BREAKPOINT event: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe009/popframe009.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe009/popframe009.cpp index 2e72d3858b3..c15146e660f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe009/popframe009.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe009/popframe009.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,17 +34,17 @@ extern "C" { #define STATUS_FAILED 2 #define WAIT_FOREVER ((jlong)(3600*1000)) -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; -static jrawMonitorID breakpointLock = NULL; -static jrawMonitorID popFrameLock = NULL; -static jrawMonitorID suspendLock = NULL; +static jrawMonitorID breakpointLock = nullptr; +static jrawMonitorID popFrameLock = nullptr; +static jrawMonitorID suspendLock = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; static jboolean popDone = JNI_FALSE; -static jmethodID midCheckPoint = NULL; -static jmethodID midRun = NULL; +static jmethodID midCheckPoint = nullptr; +static jmethodID midRun = nullptr; static int bpCount = 0; static int framesCount = 0; @@ -165,12 +165,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -225,7 +225,7 @@ JNIEXPORT void JNICALL Java_nsk_jvmti_PopFrame_popframe009_getReady(JNIEnv *env, jclass cls) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; @@ -238,7 +238,7 @@ Java_nsk_jvmti_PopFrame_popframe009_getReady(JNIEnv *env, jclass cls) { } midCheckPoint = env->GetStaticMethodID(cls, "checkPoint", "()V"); - if (midCheckPoint == NULL) { + if (midCheckPoint == nullptr) { printf("Cannot find Method ID for method checkPoint\n"); result = STATUS_FAILED; return; @@ -261,7 +261,7 @@ Java_nsk_jvmti_PopFrame_popframe009_getReady(JNIEnv *env, jclass cls) { } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_BREAKPOINT, NULL); + JVMTI_EVENT_BREAKPOINT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable BREAKPOINT event: %s (%d)\n", TranslateError(err), err); @@ -331,14 +331,14 @@ Java_nsk_jvmti_PopFrame_popframe009_check(JNIEnv *env, jclass cls, jthread thr) jvmtiError err; jmethodID midFibonacci; jclass clazz; - jmethodID method = NULL; + jmethodID method = nullptr; jlocation loc; char *name, *sig, *generic; jlong delayTime = 1; int popCount = 0; int i; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -412,19 +412,19 @@ Java_nsk_jvmti_PopFrame_popframe009_check(JNIEnv *env, jclass cls, jthread thr) } midFibonacci = env->GetStaticMethodID(cls, "fibonacci", "(I)I"); - if (midFibonacci == NULL) { + if (midFibonacci == nullptr) { printf("Cannot get method ID for method \"fibonacci\"\n"); result = STATUS_FAILED; } clazz = env->GetObjectClass(thr); - if (clazz == NULL) { + if (clazz == nullptr) { printf("Cannot get class of thread object\n"); return STATUS_FAILED; } midRun = env->GetMethodID(clazz, "run", "()V"); - if (midRun == NULL) { + if (midRun == nullptr) { printf("Cannot get method ID for \"run\"\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe010/popframe010.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe010/popframe010.cpp index c0b3f8924fd..68e0aa7c7bd 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe010/popframe010.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe010/popframe010.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,13 +33,13 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; static jint result = PASSED; static jboolean printdump = JNI_FALSE; -static jmethodID midCheckPoint = NULL; -static jmethodID midRun = NULL; +static jmethodID midCheckPoint = nullptr; +static jmethodID midRun = nullptr; static jint framesExpected = 0; static jint framesCount = 0; static const char *cls_exp = "Lnsk/jvmti/PopFrame/popframe010$TestThread;"; @@ -52,7 +52,7 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jmethodID mid, jlocation loc, jint jclass cls; jlocation loc_exp = (i == 0) ? 15 : 8; char *sigClass, *name, *sig, *generic; - jvmtiLocalVariableEntry *table = NULL; + jvmtiLocalVariableEntry *table = nullptr; jint entryCount = 0; jint argValue; jint j; @@ -85,7 +85,7 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jmethodID mid, jlocation loc, jint i, TranslateError(err), err); result = STATUS_FAILED; } - if (table != NULL) { + if (table != nullptr) { for (j = 0; j < entryCount; j++) { if (strcmp(table[j].name, argName) == 0) { err = jvmti_env->GetLocalInt(thr, 0, @@ -105,17 +105,17 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jmethodID mid, jlocation loc, jint printf(", arg value: %d\n", argValue); } - if (sigClass == NULL || strcmp(sigClass, cls_exp) != 0) { + if (sigClass == nullptr || strcmp(sigClass, cls_exp) != 0) { printf("(step %d) wrong class sig: \"%s\",\n", i, sigClass); printf(" expected: \"%s\"\n", cls_exp); result = STATUS_FAILED; } - if (name == NULL || strcmp(name, name_exp) != 0) { + if (name == nullptr || strcmp(name, name_exp) != 0) { printf("(step %d) wrong method name: \"%s\",", i, name); printf(" expected: \"%s\"\n", name_exp); result = STATUS_FAILED; } - if (sig == NULL || strcmp(sig, sig_exp) != 0) { + if (sig == nullptr || strcmp(sig, sig_exp) != 0) { printf("(step %d) wrong method sig: \"%s\",", i, sig); printf(" expected: \"%s\"\n", sig_exp); result = STATUS_FAILED; @@ -132,16 +132,16 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jmethodID mid, jlocation loc, jint result = STATUS_FAILED; } - if (sigClass != NULL) { + if (sigClass != nullptr) { jvmti_env->Deallocate((unsigned char*)sigClass); } - if (name != NULL) { + if (name != nullptr) { jvmti_env->Deallocate((unsigned char*)name); } - if (sig != NULL) { + if (sig != nullptr) { jvmti_env->Deallocate((unsigned char*)sig); } - if (table != NULL) { + if (table != nullptr) { for (j = 0; j < entryCount; j++) { jvmti_env->Deallocate((unsigned char*)(table[j].name)); jvmti_env->Deallocate((unsigned char*)(table[j].signature)); @@ -232,12 +232,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -288,7 +288,7 @@ JNIEXPORT void JNICALL Java_nsk_jvmti_PopFrame_popframe010_getReady(JNIEnv *env, jclass c, jclass cls, jint depth) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; @@ -301,14 +301,14 @@ Java_nsk_jvmti_PopFrame_popframe010_getReady(JNIEnv *env, jclass c, jclass cls, } midRun = env->GetMethodID(cls, "run", "()V"); - if (midRun == NULL) { + if (midRun == nullptr) { printf("Cannot find Method ID for method run\n"); result = STATUS_FAILED; return; } midCheckPoint = env->GetMethodID(cls, "checkPoint", "()V"); - if (midCheckPoint == NULL) { + if (midCheckPoint == nullptr) { printf("Cannot find Method ID for method checkPoint\n"); result = STATUS_FAILED; return; @@ -323,7 +323,7 @@ Java_nsk_jvmti_PopFrame_popframe010_getReady(JNIEnv *env, jclass c, jclass cls, } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_BREAKPOINT, NULL); + JVMTI_EVENT_BREAKPOINT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable BREAKPOINT event: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe011/popframe011.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe011/popframe011.cpp index 114f7cd1d71..32bf69ea853 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe011/popframe011.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe011/popframe011.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -111,15 +111,15 @@ Java_nsk_jvmti_PopFrame_popframe011_doPopFrame(JNIEnv *env, } switch (t_case) { -/* NULL pointer to the thread in debug mode */ +/* nullptr pointer to the thread in debug mode */ case 1: - printf("\nInvoke PopFrame() with NULL pointer to a thread...\n"); + printf("\nInvoke PopFrame() with null pointer to a thread...\n"); fflush(stdout); // fallthrough -/* NULL pointer to the thread */ +/* nullptr pointer to the thread */ case 0: set_watch_ev(1); /* watch JVMTI events */ - popframe_err = (jvmti->PopFrame(NULL)); /* explode the bomb */ + popframe_err = (jvmti->PopFrame(nullptr)); /* explode the bomb */ if (popframe_err != JVMTI_ERROR_INVALID_THREAD) { printf("TEST FAILED: the function PopFrame() returned the error %d: %s\n", popframe_err, TranslateError(popframe_err)); @@ -245,7 +245,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorEnter/rawmonenter001/rawmonenter001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorEnter/rawmonenter001/rawmonenter001.cpp index 337de1e3cc8..aeb2f3c4cd7 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorEnter/rawmonenter001/rawmonenter001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorEnter/rawmonenter001/rawmonenter001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ extern "C" { #define STATUS_FAILED 2 #define RAW_MONITORS_NUMBER 1024 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -102,12 +102,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -121,7 +121,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_VM_INIT, NULL); + JVMTI_EVENT_VM_INIT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable JVMTI_EVENT_VM_INIT: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorEnter/rawmonenter002/rawmonenter002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorEnter/rawmonenter002/rawmonenter002.cpp index 8588fa65636..790cafb1cfc 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorEnter/rawmonenter002/rawmonenter002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorEnter/rawmonenter002/rawmonenter002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_rawmonenter002(JavaVM *jvm, char *options, void *reser jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -68,7 +68,7 @@ JNIEXPORT jint JNICALL Java_nsk_jvmti_RawMonitorEnter_rawmonenter002_check(JNIEnv *env, jclass cls) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -77,7 +77,7 @@ Java_nsk_jvmti_RawMonitorEnter_rawmonenter002_check(JNIEnv *env, jclass cls) { printf(">>> invalid monitor check ...\n"); } - err = jvmti->RawMonitorEnter(NULL); + err = jvmti->RawMonitorEnter(nullptr); if (err != JVMTI_ERROR_INVALID_MONITOR) { printf("Error expected: JVMTI_ERROR_INVALID_MONITOR,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorEnter/rawmonenter003/rawmonenter003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorEnter/rawmonenter003/rawmonenter003.cpp index 984c73cb0f7..36aaa1cdbfb 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorEnter/rawmonenter003/rawmonenter003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorEnter/rawmonenter003/rawmonenter003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; static char bad_buf[] = "this is a bad raw monitor"; @@ -53,12 +53,12 @@ JNIEXPORT jint JNI_OnLoad_rawmonenter003(JavaVM *jvm, char *options, void *reser jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -70,7 +70,7 @@ JNIEXPORT jint JNICALL Java_nsk_jvmti_RawMonitorEnter_rawmonenter003_check(JNIEnv *env, jclass cls) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorEnter/rawmonenter004/rawmonenter004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorEnter/rawmonenter004/rawmonenter004.cpp index 2c9fdb8f2f0..b2c5b8a929f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorEnter/rawmonenter004/rawmonenter004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorEnter/rawmonenter004/rawmonenter004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,7 @@ extern "C" { #define INCREMENT_LIMIT 1000 #define DELAY 100 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; static jrawMonitorID monitor; @@ -57,12 +57,12 @@ JNIEXPORT jint JNI_OnLoad_rawmonenter004(JavaVM *jvm, char *options, void *reser jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -104,7 +104,7 @@ Java_nsk_jvmti_RawMonitorEnter_rawmonenter004_check(JNIEnv *env, jclass cls, job jthread thr; jint wait_time = wtime * 60000; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -131,7 +131,7 @@ Java_nsk_jvmti_RawMonitorEnter_rawmonenter004_check(JNIEnv *env, jclass cls, job for (i = 0; i < threads_limit; i++) { thr = env->GetObjectArrayElement(threads, i); - err = jvmti->RunAgentThread(thr, increment_thread, NULL, + err = jvmti->RunAgentThread(thr, increment_thread, nullptr, JVMTI_THREAD_NORM_PRIORITY); if (err != JVMTI_ERROR_NONE) { printf("(RunDebugThread) unexpected error: %s (%d)\n", diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorExit/rawmonexit001/rawmonexit001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorExit/rawmonexit001/rawmonexit001.cpp index 6fcd8db139e..fd1a2c47f6a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorExit/rawmonexit001/rawmonexit001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorExit/rawmonexit001/rawmonexit001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ extern "C" { #define STATUS_FAILED 2 #define RAW_MONITORS_NUMBER 1024 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -115,12 +115,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -134,7 +134,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_VM_INIT, NULL); + JVMTI_EVENT_VM_INIT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable JVMTI_EVENT_VM_INIT: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorExit/rawmonexit002/rawmonexit002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorExit/rawmonexit002/rawmonexit002.cpp index b378bef82df..50fed1c7f1a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorExit/rawmonexit002/rawmonexit002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorExit/rawmonexit002/rawmonexit002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_rawmonexit002(JavaVM *jvm, char *options, void *reserv jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -68,7 +68,7 @@ JNIEXPORT jint JNICALL Java_nsk_jvmti_RawMonitorExit_rawmonexit002_check(JNIEnv *env, jclass cls) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -77,7 +77,7 @@ Java_nsk_jvmti_RawMonitorExit_rawmonexit002_check(JNIEnv *env, jclass cls) { printf(">>> invalid monitor check ...\n"); } - err = jvmti->RawMonitorExit(NULL); + err = jvmti->RawMonitorExit(nullptr); if (err != JVMTI_ERROR_INVALID_MONITOR) { printf("Error expected: JVMTI_ERROR_INVALID_MONITOR,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorExit/rawmonexit003/rawmonexit003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorExit/rawmonexit003/rawmonexit003.cpp index 2c9a1847c3b..31221547a08 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorExit/rawmonexit003/rawmonexit003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorExit/rawmonexit003/rawmonexit003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; static char bad_buf[] = "this is a bad raw monitor"; @@ -53,12 +53,12 @@ JNIEXPORT jint JNI_OnLoad_rawmonexit003(JavaVM *jvm, char *options, void *reserv jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -70,7 +70,7 @@ JNIEXPORT jint JNICALL Java_nsk_jvmti_RawMonitorExit_rawmonexit003_check(JNIEnv *env, jclass cls) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorExit/rawmonexit005/rawmonexit005.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorExit/rawmonexit005/rawmonexit005.cpp index 58c60ca1561..11b8a83e03b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorExit/rawmonexit005/rawmonexit005.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorExit/rawmonexit005/rawmonexit005.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_rawmonexit005(JavaVM *jvm, char *options, void *reserv jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -69,7 +69,7 @@ Java_nsk_jvmti_RawMonitorExit_rawmonexit005_check(JNIEnv *env, jclass cls) { jvmtiError err; jrawMonitorID monitor; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotify/rawmnntfy001/rawmnntfy001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotify/rawmnntfy001/rawmnntfy001.cpp index f0824faf11c..d7070469880 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotify/rawmnntfy001/rawmnntfy001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotify/rawmnntfy001/rawmnntfy001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ extern "C" { #define STATUS_FAILED 2 #define RAW_MONITORS_NUMBER 1024 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -128,12 +128,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -147,7 +147,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_VM_INIT, NULL); + JVMTI_EVENT_VM_INIT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable JVMTI_EVENT_VM_INIT: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotify/rawmnntfy002/rawmnntfy002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotify/rawmnntfy002/rawmnntfy002.cpp index a06fd549572..5900fa46ac8 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotify/rawmnntfy002/rawmnntfy002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotify/rawmnntfy002/rawmnntfy002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_rawmnntfy002(JavaVM *jvm, char *options, void *reserve jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -68,7 +68,7 @@ JNIEXPORT jint JNICALL Java_nsk_jvmti_RawMonitorNotify_rawmnntfy002_check(JNIEnv *env, jclass cls) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -77,7 +77,7 @@ Java_nsk_jvmti_RawMonitorNotify_rawmnntfy002_check(JNIEnv *env, jclass cls) { printf(">>> invalid monitor check ...\n"); } - err = jvmti->RawMonitorNotify(NULL); + err = jvmti->RawMonitorNotify(nullptr); if (err != JVMTI_ERROR_INVALID_MONITOR) { printf("Error expected: JVMTI_ERROR_INVALID_MONITOR,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotify/rawmnntfy003/rawmnntfy003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotify/rawmnntfy003/rawmnntfy003.cpp index 0250ed50ae7..2ab8362bd13 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotify/rawmnntfy003/rawmnntfy003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotify/rawmnntfy003/rawmnntfy003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; static char bad_buf[] = "this is a bad raw monitor"; @@ -53,12 +53,12 @@ JNIEXPORT jint JNI_OnLoad_rawmnntfy003(JavaVM *jvm, char *options, void *reserve jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -70,7 +70,7 @@ JNIEXPORT jint JNICALL Java_nsk_jvmti_RawMonitorNotify_rawmnntfy003_check(JNIEnv *env, jclass cls) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotify/rawmnntfy004/rawmnntfy004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotify/rawmnntfy004/rawmnntfy004.cpp index 5e210000407..259f0b526b3 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotify/rawmnntfy004/rawmnntfy004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotify/rawmnntfy004/rawmnntfy004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_rawmnntfy004(JavaVM *jvm, char *options, void *reserve jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -69,7 +69,7 @@ Java_nsk_jvmti_RawMonitorNotify_rawmnntfy004_check(JNIEnv *env, jclass cls) { jvmtiError err; jrawMonitorID monitor; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotifyAll/rawmnntfyall001/rawmnntfyall001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotifyAll/rawmnntfyall001/rawmnntfyall001.cpp index c669763560d..42da7b3606c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotifyAll/rawmnntfyall001/rawmnntfyall001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotifyAll/rawmnntfyall001/rawmnntfyall001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ extern "C" { #define STATUS_FAILED 2 #define RAW_MONITORS_NUMBER 1024 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -128,12 +128,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -147,7 +147,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_VM_INIT, NULL); + JVMTI_EVENT_VM_INIT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable JVMTI_EVENT_VM_INIT: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotifyAll/rawmnntfyall002/rawmnntfyall002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotifyAll/rawmnntfyall002/rawmnntfyall002.cpp index 6801be39731..74559aefd80 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotifyAll/rawmnntfyall002/rawmnntfyall002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotifyAll/rawmnntfyall002/rawmnntfyall002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_rawmnntfyall002(JavaVM *jvm, char *options, void *rese jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -68,7 +68,7 @@ JNIEXPORT jint JNICALL Java_nsk_jvmti_RawMonitorNotifyAll_rawmnntfyall002_check(JNIEnv *env, jclass cls) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -77,7 +77,7 @@ Java_nsk_jvmti_RawMonitorNotifyAll_rawmnntfyall002_check(JNIEnv *env, jclass cls printf(">>> invalid monitor check ...\n"); } - err = jvmti->RawMonitorNotifyAll(NULL); + err = jvmti->RawMonitorNotifyAll(nullptr); if (err != JVMTI_ERROR_INVALID_MONITOR) { printf("Error expected: JVMTI_ERROR_INVALID_MONITOR,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotifyAll/rawmnntfyall003/rawmnntfyall003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotifyAll/rawmnntfyall003/rawmnntfyall003.cpp index b5bfb676385..71aaa848a74 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotifyAll/rawmnntfyall003/rawmnntfyall003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotifyAll/rawmnntfyall003/rawmnntfyall003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; static char bad_buf[] = "this is a bad raw monitor"; @@ -53,12 +53,12 @@ JNIEXPORT jint JNI_OnLoad_rawmnntfyall003(JavaVM *jvm, char *options, void *rese jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -70,7 +70,7 @@ JNIEXPORT jint JNICALL Java_nsk_jvmti_RawMonitorNotifyAll_rawmnntfyall003_check(JNIEnv *env, jclass cls) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotifyAll/rawmnntfyall004/rawmnntfyall004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotifyAll/rawmnntfyall004/rawmnntfyall004.cpp index 96c0a2545d7..163d46e9e54 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotifyAll/rawmnntfyall004/rawmnntfyall004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorNotifyAll/rawmnntfyall004/rawmnntfyall004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_rawmnntfyall004(JavaVM *jvm, char *options, void *rese jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -69,7 +69,7 @@ Java_nsk_jvmti_RawMonitorNotifyAll_rawmnntfyall004_check(JNIEnv *env, jclass cls jvmtiError err; jrawMonitorID monitor; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait001/rawmnwait001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait001/rawmnwait001.cpp index 155e4e7e513..589090ba211 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait001/rawmnwait001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait001/rawmnwait001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -35,7 +35,7 @@ extern "C" { #define RAW_MONITORS_NUMBER 1024 #define MONITOR_WAIT_TIMEOUT ((jlong)10) -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -129,12 +129,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -148,7 +148,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_VM_INIT, NULL); + JVMTI_EVENT_VM_INIT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable JVMTI_EVENT_VM_INIT: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait002/rawmnwait002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait002/rawmnwait002.cpp index 2b2ad239c16..f0efca275f3 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait002/rawmnwait002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait002/rawmnwait002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ extern "C" { #define STATUS_FAILED 2 #define MONITOR_WAIT_TIMEOUT ((jlong)100) -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -52,12 +52,12 @@ JNIEXPORT jint JNI_OnLoad_rawmnwait002(JavaVM *jvm, char *options, void *reserve jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -69,7 +69,7 @@ JNIEXPORT jint JNICALL Java_nsk_jvmti_RawMonitorWait_rawmnwait002_check(JNIEnv *env, jclass cls) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -78,7 +78,7 @@ Java_nsk_jvmti_RawMonitorWait_rawmnwait002_check(JNIEnv *env, jclass cls) { printf(">>> invalid monitor check ...\n"); } - err = jvmti->RawMonitorWait(NULL, MONITOR_WAIT_TIMEOUT); + err = jvmti->RawMonitorWait(nullptr, MONITOR_WAIT_TIMEOUT); if (err != JVMTI_ERROR_INVALID_MONITOR) { printf("Error expected: JVMTI_ERROR_INVALID_MONITOR,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait003/rawmnwait003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait003/rawmnwait003.cpp index c4d307dbcc7..74778ffcadf 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait003/rawmnwait003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait003/rawmnwait003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ extern "C" { #define STATUS_FAILED 2 #define MONITOR_WAIT_TIMEOUT ((jlong)100) -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; static char bad_buf[] = "this is a bad raw monitor"; @@ -54,12 +54,12 @@ JNIEXPORT jint JNI_OnLoad_rawmnwait003(JavaVM *jvm, char *options, void *reserve jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -71,7 +71,7 @@ JNIEXPORT jint JNICALL Java_nsk_jvmti_RawMonitorWait_rawmnwait003_check(JNIEnv *env, jclass cls) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait004/rawmnwait004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait004/rawmnwait004.cpp index e1e7db5c7b8..c356e9007e6 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait004/rawmnwait004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait004/rawmnwait004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ extern "C" { #define STATUS_FAILED 2 #define MONITOR_WAIT_TIMEOUT ((jlong)100) -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -52,12 +52,12 @@ JNIEXPORT jint JNI_OnLoad_rawmnwait004(JavaVM *jvm, char *options, void *reserve jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -70,7 +70,7 @@ Java_nsk_jvmti_RawMonitorWait_rawmnwait004_check(JNIEnv *env, jclass cls) { jvmtiError err; jrawMonitorID monitor; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait005/rawmnwait005.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait005/rawmnwait005.cpp index ba861bd9757..4df5817fcb5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait005/rawmnwait005.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RawMonitorWait/rawmnwait005/rawmnwait005.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ extern "C" { #define STATUS_FAILED 2 #define MILLIS_PER_MINUTE (60 * 1000) -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_TRUE; @@ -57,12 +57,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -206,7 +206,7 @@ Java_nsk_jvmti_RawMonitorWait_rawmnwait005_check(JNIEnv *env, wait_time = wtime * MILLIS_PER_MINUTE; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -261,7 +261,7 @@ Java_nsk_jvmti_RawMonitorWait_rawmnwait005_check(JNIEnv *env, // before we terminate - else the test will end before it checks // it was interrupted! - err = jvmti->RunAgentThread(thr, test_thread, NULL, + err = jvmti->RunAgentThread(thr, test_thread, nullptr, JVMTI_THREAD_NORM_PRIORITY); if (err != JVMTI_ERROR_NONE) { printf("(RunDebugThread) unexpected error: %s (%d)\n", diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/StressRedefine/stressRedefine.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/StressRedefine/stressRedefine.cpp index e186ee1be6a..56f5e5af1fe 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/StressRedefine/stressRedefine.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/StressRedefine/stressRedefine.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define STATUS_FAILED 2 #define PASSED 0 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { @@ -80,7 +80,7 @@ Java_nsk_jvmti_RedefineClasses_StressRedefine_makeRedefinition(JNIEnv *env, jvmtiClassDefinition classDef; jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -92,7 +92,7 @@ Java_nsk_jvmti_RedefineClasses_StressRedefine_makeRedefinition(JNIEnv *env, /* filling the structure jvmtiClassDefinition */ classDef.klass = redefCls; classDef.class_byte_count = env->GetArrayLength(classBytes); - classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, NULL); + classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, nullptr); if (fl == 2) { printf(">>>>>>>> Invoke RedefineClasses():\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass001/redefclass001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass001/redefclass001.cpp index 0bf04741b57..8b1992d011c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass001/redefclass001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass001/redefclass001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define STATUS_FAILED 2 #define PASSED 0 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; #ifdef STATIC_BUILD @@ -91,7 +91,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass001_makeRedefinition(JNIEnv *env, jvmtiClassDefinition classDef; jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -103,7 +103,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass001_makeRedefinition(JNIEnv *env, /* filling the structure jvmtiClassDefinition */ classDef.klass = redefCls; classDef.class_byte_count = env->GetArrayLength(classBytes); - classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, NULL); + classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, nullptr); if (fl == 2) { printf(">>>>>>>> Invoke RedefineClasses():\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass002/redefclass002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass002/redefclass002.cpp index 2ad16a006bb..31732b1566f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass002/redefclass002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass002/redefclass002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define STATUS_FAILED 2 #define PASSED 0 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; #ifdef STATIC_BUILD @@ -133,7 +133,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass002_makeRedefinition(JNIEnv *env, jclas jvmtiClassDefinition classDef; jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -145,7 +145,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass002_makeRedefinition(JNIEnv *env, jclas /* filling the structure jvmtiClassDefinition */ classDef.klass = redefCls; classDef.class_byte_count = env->GetArrayLength(classBytes); - classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, NULL); + classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, nullptr); if (vrb == 1) printf(">>>>>>>> Invoke RedefineClasses():\n\tnew class byte count=%d\n", diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass003/redefclass003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass003/redefclass003.cpp index 77fbacb64cd..44654ac13ef 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass003/redefclass003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass003/redefclass003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -35,7 +35,7 @@ extern "C" { #define PASSED 0 #define NO_RESULTS 3 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; #ifdef STATIC_BUILD @@ -94,7 +94,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass003_makeRedefinition(JNIEnv *env, jclas jvmtiClassDefinition classDef; int no_results = 0; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -106,7 +106,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass003_makeRedefinition(JNIEnv *env, jclas /* filling the structure jvmtiClassDefinition */ classDef.klass = redefCls; classDef.class_byte_count = env->GetArrayLength(classBytes); - classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, NULL); + classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, nullptr); if (vrb == 1) printf(">>>>>>>> Invoke RedefineClasses():\n\tnew class byte count=%d\n", @@ -140,7 +140,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass003_checkNewFields(JNIEnv *env, jlong longFld; fid = env->GetStaticFieldID(redefCls, "intComplNewFld", "I"); - if (fid == NULL) { + if (fid == nullptr) { printf("%s: Failed to get the field ID for the static field \"intComplNewFld\"\n", __FILE__); return STATUS_FAILED; @@ -148,7 +148,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass003_checkNewFields(JNIEnv *env, intFld = env->GetStaticIntField(redefCls, fid); fid = env->GetStaticFieldID(redefCls, "longComplNewFld", "J"); - if (fid == NULL) { + if (fid == nullptr) { printf("%s: Failed to get the field ID for the static field \"longComplNewFld\"\n", __FILE__); return STATUS_FAILED; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass004/redefclass004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass004/redefclass004.cpp index baef48d901e..68ca36f6959 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass004/redefclass004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass004/redefclass004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -40,7 +40,7 @@ static jint INTFLD = 333; static jlong LONGFLD = 444; #define STRFLD "completely new String field" -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; #ifdef STATIC_BUILD @@ -99,7 +99,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass004_makeRedefinition(JNIEnv *env, jvmtiClassDefinition classDef; int no_results = 0; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -111,7 +111,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass004_makeRedefinition(JNIEnv *env, /* fill the structure jvmtiClassDefinition */ classDef.klass = redefCls; classDef.class_byte_count = env->GetArrayLength(classBytes); - classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, NULL); + classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, nullptr); if (vrb == 1) printf(">>>>>>>> Invoke RedefineClasses():\n\tnew class byte count=%d\n", @@ -146,11 +146,11 @@ Java_nsk_jvmti_RedefineClasses_redefclass004_checkNewFields(JNIEnv *env, jint intFld; jlong longFld; jstring stringObj; - const char *strFld = NULL; + const char *strFld = nullptr; /* get value of new instance field "intComplNewFld" */ fid = env->GetFieldID(redefCls, "intComplNewFld", "I"); - if (fid == NULL) { + if (fid == nullptr) { printf("%s: Failed to get the field ID for the field \"intComplNewFld\"\n", __FILE__); return STATUS_FAILED; @@ -159,7 +159,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass004_checkNewFields(JNIEnv *env, /* get value of new instance field "longComplNewFld" */ fid = env->GetFieldID(redefCls, "longComplNewFld", "J"); - if (fid == NULL) { + if (fid == nullptr) { printf("%s: Failed to get the field ID for the field \"longComplNewFld\"\n", __FILE__); return STATUS_FAILED; @@ -168,7 +168,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass004_checkNewFields(JNIEnv *env, /* get value of new instance field "stringComplNewFld" */ fid = env->GetFieldID(redefCls, "stringComplNewFld", "Ljava/lang/String;"); - if (fid == NULL) { + if (fid == nullptr) { printf("%s: Failed to get the field ID for the field \"stringComplNewFld\"\n", __FILE__); return STATUS_FAILED; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass005/redefclass005.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass005/redefclass005.cpp index 6e932a9551f..0e7d2703eb3 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass005/redefclass005.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass005/redefclass005.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define STATUS_FAILED 2 #define PASSED 0 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; static int watch_ev = 0; /* ignore JVMTI events by default */ @@ -59,7 +59,7 @@ ClassFileLoadHook(jvmtiEnv *jvmti_env, JNIEnv *env, jclass class_being_redefined jvmti->RawMonitorEnter(watch_ev_monitor); - if (watch_ev && class_being_redefined != NULL) { + if (watch_ev && class_being_redefined != nullptr) { printf("#### JVMTI_EVENT_CLASS_FILE_LOAD_HOOK occurred ####\n"); CFLH_gen_ev++; } @@ -164,7 +164,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass005_makeRedefinition(JNIEnv *env, jthread thread; jvmtiClassDefinition classDef; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -180,7 +180,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass005_makeRedefinition(JNIEnv *env, return STATUS_FAILED; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable event JVMTI_EVENT_CLASS_FILE_LOAD_HOOK: %s (%d)\n", TranslateError(err), err); @@ -202,7 +202,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass005_makeRedefinition(JNIEnv *env, /* filling the structure jvmtiClassDefinition */ classDef.klass = redefCls; classDef.class_byte_count = env->GetArrayLength(classBytes); - classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, NULL); + classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, nullptr); set_watch_ev(1); /* watch JVMTI events */ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass006/redefclass006.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass006/redefclass006.cpp index 7f140b73182..9eea0a6e2d7 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass006/redefclass006.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass006/redefclass006.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define STATUS_FAILED 2 #define PASSED 0 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; #ifdef STATIC_BUILD @@ -90,9 +90,9 @@ Java_nsk_jvmti_RedefineClasses_redefclass006_makeRedefinition(JNIEnv *env, jclass cls, jint t_case, jclass redefCls, jbyteArray classBytes) { jvmtiError err; jvmtiClassDefinition classDef; - jvmtiClassDefinition* classDefPtr = NULL; + jvmtiClassDefinition* classDefPtr = nullptr; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -102,25 +102,25 @@ Java_nsk_jvmti_RedefineClasses_redefclass006_makeRedefinition(JNIEnv *env, } switch (t_case) { -/* NULL pointer to the jvmtiClassDefinition */ +/* nullptr pointer to the jvmtiClassDefinition */ case 0: break; -/* NULL pointer to the jvmtiClassDefinition in debug mode */ +/* nullptr pointer to the jvmtiClassDefinition in debug mode */ case 1: - printf("Invoke RedefineClasses() with NULL pointer to the structure jvmtiClassDefinition\n"); + printf("Invoke RedefineClasses() with null pointer to the structure jvmtiClassDefinition\n"); fflush(stdout); break; -/* NULL pointer to the jvmtiClassDefinition->class_bytes in debug mode */ +/* nullptr pointer to the jvmtiClassDefinition->class_bytes in debug mode */ case 3: - printf("Invoke RedefineClasses() with NULL pointer to the field jvmtiClassDefinition->class_bytes\n"); + printf("Invoke RedefineClasses() with null pointer to the field jvmtiClassDefinition->class_bytes\n"); fflush(stdout); // fallthrough -/* NULL pointer to the jvmtiClassDefinition->class_bytes */ +/* nullptr pointer to the jvmtiClassDefinition->class_bytes */ case 2: /* partly fill the structure jvmtiClassDefinition */ classDef.klass = redefCls; classDef.class_byte_count = env->GetArrayLength(classBytes); - classDef.class_bytes = NULL; + classDef.class_bytes = nullptr; classDefPtr = &classDef; break; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass008/redefclass008.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass008/redefclass008.cpp index a5ac03291ab..92094c887bd 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass008/redefclass008.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass008/redefclass008.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -45,16 +45,16 @@ typedef struct { /* list of breakpoints */ static breakpoint breakpoints[] = { - { 1, (char*) "checkIt", (char*) "(Ljava/io/PrintStream;Z)I", 0, NULL }, - { 1, (char*) "finMethod", (char*) "(JIJ)V", 5, NULL }, - { 1, (char*) "finMethod", (char*) "(JIJ)V", 4, NULL }, - { 1, (char*) "checkIt", (char*) "(Ljava/io/PrintStream;Z)I", 1, NULL }, - { 0, (char*) "statMethod", (char*) "(III)I", 1, NULL } + { 1, (char*) "checkIt", (char*) "(Ljava/io/PrintStream;Z)I", 0, nullptr }, + { 1, (char*) "finMethod", (char*) "(JIJ)V", 5, nullptr }, + { 1, (char*) "finMethod", (char*) "(JIJ)V", 4, nullptr }, + { 1, (char*) "checkIt", (char*) "(Ljava/io/PrintStream;Z)I", 1, nullptr }, + { 0, (char*) "statMethod", (char*) "(III)I", 1, nullptr } }; static jclass redefCls; /* JNI's Java class object */ -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; @@ -141,7 +141,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass008_setBreakpoints(JNIEnv *env, if (breakpoints[i].inst) { /* an instance method */ breakpoints[i].mid = env->GetMethodID( redefCls, breakpoints[i].m_name, breakpoints[i].m_sign); - if (breakpoints[i].mid == NULL) { + if (breakpoints[i].mid == nullptr) { printf( "%s: Failed to get the method ID for the instance method \"%s\" with signature \"%s\"\n", __FILE__, breakpoints[i].m_name, breakpoints[i].m_sign); @@ -150,7 +150,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass008_setBreakpoints(JNIEnv *env, } else { /* a static method */ breakpoints[i].mid = env->GetStaticMethodID( redefCls, breakpoints[i].m_name, breakpoints[i].m_sign); - if (breakpoints[i].mid == NULL) { + if (breakpoints[i].mid == nullptr) { printf( "%s: Failed to get the method ID for the static method \"%s\" with signature \"%s\"\n", __FILE__, breakpoints[i].m_name, breakpoints[i].m_sign); @@ -174,7 +174,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass008_setBreakpoints(JNIEnv *env, return STATUS_FAILED; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable BREAKPOINT event: %s (%d)\n", TranslateError(err), err); @@ -193,7 +193,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass008_makeRedefinition(JNIEnv *env, jvmtiError err; jvmtiClassDefinition classDef; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -205,7 +205,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass008_makeRedefinition(JNIEnv *env, /* fill the structure jvmtiClassDefinition */ classDef.klass = redefCls; classDef.class_byte_count = env->GetArrayLength(classBytes); - classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, NULL); + classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, nullptr); if (vrb == 1) printf(">>>>>>>> Invoke RedefineClasses():\n\tnew class byte count=%d\n", @@ -243,7 +243,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass008_getResult(JNIEnv *env, if (breakpoints[i].inst) { /* an instance method */ breakpoints[i].mid = env->GetMethodID( redefCls, breakpoints[i].m_name, breakpoints[i].m_sign); - if (breakpoints[i].mid == NULL) { + if (breakpoints[i].mid == nullptr) { printf( "%s: getResult: Failed to get the method ID for the instance method" "\"%s\" with signature \"%s\"\n", @@ -253,7 +253,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass008_getResult(JNIEnv *env, } else { /* a static method */ breakpoints[i].mid = env->GetStaticMethodID( redefCls, breakpoints[i].m_name, breakpoints[i].m_sign); - if (breakpoints[i].mid == NULL) { + if (breakpoints[i].mid == nullptr) { printf( "%s: getResult: Failed to get the method ID for the static method" "\"%s\" with signature \"%s\"\n", diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass009/redefclass009.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass009/redefclass009.cpp index b324acf12fd..e91f9f5e895 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass009/redefclass009.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass009/redefclass009.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -80,23 +80,23 @@ typedef struct { /* local variables of a method */ jmethodID mid; /* JNI's method ID */ } methInfo; -/* list of original methods with NULL pointers to localVar */ +/* list of original methods with nullptr pointers to localVar */ static methInfo origMethInfo[] = { - { 1, (char*) "", (char*) "()V", 1, NULL, NULL }, - { 1, (char*) "checkIt", (char*) "(Ljava/io/PrintStream;Z)I", 4, NULL, NULL }, - { 1, (char*) "finMethod", (char*) "(CJIJ)V", 5, NULL, NULL }, - { 0, (char*) "statMethod", (char*) "(III)D", 3, NULL, NULL } + { 1, (char*) "", (char*) "()V", 1, nullptr, nullptr }, + { 1, (char*) "checkIt", (char*) "(Ljava/io/PrintStream;Z)I", 4, nullptr, nullptr }, + { 1, (char*) "finMethod", (char*) "(CJIJ)V", 5, nullptr, nullptr }, + { 0, (char*) "statMethod", (char*) "(III)D", 3, nullptr, nullptr } }; /* list of redefined methods */ static methInfo redefMethInfo[] = { - { 1, (char*) "", (char*) "()V", 6, constr_lv, NULL }, - { 1, (char*) "checkIt", (char*) "(Ljava/io/PrintStream;Z)I", 3, checkIt_lv, NULL }, - { 1, (char*) "finMethod", (char*) "(CJIJ)V", 7, finMeth_lv, NULL }, - { 0, (char*) "statMethod", (char*) "(III)D", 5, statMeth_lv, NULL } + { 1, (char*) "", (char*) "()V", 6, constr_lv, nullptr }, + { 1, (char*) "checkIt", (char*) "(Ljava/io/PrintStream;Z)I", 3, checkIt_lv, nullptr }, + { 1, (char*) "finMethod", (char*) "(CJIJ)V", 7, finMeth_lv, nullptr }, + { 0, (char*) "statMethod", (char*) "(III)D", 5, statMeth_lv, nullptr } }; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; #ifdef STATIC_BUILD @@ -174,7 +174,7 @@ int checkAttr(JNIEnv *env, jclass redefCls, methInfo methodsInfo[], methodsInfo[i].mid = env->GetStaticMethodID(redefCls, methodsInfo[i].m_name, methodsInfo[i].m_sign); } - if (methodsInfo[i].mid == NULL) { + if (methodsInfo[i].mid == nullptr) { printf("%s: Failed to get the method ID for the%s%s method \"%s\", signature \"%s\"\n", __FILE__, full ? " " : " original ", methodsInfo[i].inst ? "instance":"static", methodsInfo[i].m_name, methodsInfo[i].m_sign); @@ -250,7 +250,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass009_makeRedefinition(JNIEnv *env, jvmtiError err; jvmtiClassDefinition classDef; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -262,7 +262,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass009_makeRedefinition(JNIEnv *env, /* fill the structure jvmtiClassDefinition */ classDef.klass = redefCls; classDef.class_byte_count = env->GetArrayLength(classBytes); - classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, NULL); + classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, nullptr); if (vrb) printf("\n>>>>>>>> Invoke RedefineClasses():\n\tnew class byte count=%d\n", diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass010/redefclass010.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass010/redefclass010.cpp index 91620d38fe9..8d0831dfcb3 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass010/redefclass010.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass010/redefclass010.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -61,21 +61,21 @@ typedef struct { /* line numbers of a method */ /* list of original methods */ static methInfo origMethInfo[] = { - { 1, (char*) "", (char*) "()V", 1, NULL }, - { 1, (char*) "checkIt", (char*) "(Ljava/io/PrintStream;Z)I", 3, NULL }, - { 1, (char*) "finMethod", (char*) "(CJIJ)V", 1, NULL }, - { 0, (char*) "statMethod", (char*) "(III)D", 5, NULL } + { 1, (char*) "", (char*) "()V", 1, nullptr }, + { 1, (char*) "checkIt", (char*) "(Ljava/io/PrintStream;Z)I", 3, nullptr }, + { 1, (char*) "finMethod", (char*) "(CJIJ)V", 1, nullptr }, + { 0, (char*) "statMethod", (char*) "(III)D", 5, nullptr } }; /* list of redefined methods */ static methInfo redefMethInfo[] = { - { 1, (char*) "", (char*) "()V", 8, NULL }, - { 1, (char*) "checkIt", (char*) "(Ljava/io/PrintStream;Z)I", 3, NULL }, - { 1, (char*) "finMethod", (char*) "(CJIJ)V", 7, NULL }, - { 0, (char*) "statMethod", (char*) "(III)D", 1, NULL } + { 1, (char*) "", (char*) "()V", 8, nullptr }, + { 1, (char*) "checkIt", (char*) "(Ljava/io/PrintStream;Z)I", 3, nullptr }, + { 1, (char*) "finMethod", (char*) "(CJIJ)V", 7, nullptr }, + { 0, (char*) "statMethod", (char*) "(III)D", 1, nullptr } }; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; #ifdef STATIC_BUILD @@ -152,7 +152,7 @@ int checkAttr(JNIEnv *env, jclass redefCls, methInfo methodsInfo[], jint vrb) { methodsInfo[i].mid = env->GetStaticMethodID(redefCls, methodsInfo[i].m_name, methodsInfo[i].m_sign); } - if (methodsInfo[i].mid == NULL) { + if (methodsInfo[i].mid == nullptr) { printf("%s: Failed to get the method ID for the%s%s method \"%s\", signature \"%s\"\n", __FILE__, (vrb == 2) ? " original " : " ", methodsInfo[i].inst ? "instance" : "static", @@ -227,7 +227,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass010_makeRedefinition(JNIEnv *env, jvmtiError err; jvmtiClassDefinition classDef; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -239,7 +239,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass010_makeRedefinition(JNIEnv *env, /* fill the structure jvmtiClassDefinition */ classDef.klass = redefCls; classDef.class_byte_count = env->GetArrayLength(classBytes); - classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, NULL); + classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, nullptr); if (vrb) printf("\n>>>>>>>> Invoke RedefineClasses():\n\tnew class byte count=%d\n", diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass011/redefclass011.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass011/redefclass011.cpp index 2aaef98a0f2..af4ca7ec417 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass011/redefclass011.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass011/redefclass011.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -53,12 +53,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -97,14 +97,14 @@ Java_nsk_jvmti_RedefineClasses_redefclass011_check(JNIEnv *env, jvmtiError err; jvmtiClassDefinition classDef; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } - classDef.klass = NULL; + classDef.klass = nullptr; classDef.class_byte_count = env->GetArrayLength(bytes); - classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(bytes, NULL); + classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(bytes, nullptr); if (printdump == JNI_TRUE) { printf(">>> invalid class check ...\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass012/redefclass012.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass012/redefclass012.cpp index c1a79e1fef9..1fe8077d6b7 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass012/redefclass012.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass012/redefclass012.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -53,12 +53,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -98,14 +98,14 @@ Java_nsk_jvmti_RedefineClasses_redefclass012_check(JNIEnv *env, unsigned char *bytes; jvmtiClassDefinition classDef; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } classDef.klass = cls; classDef.class_byte_count = env->GetArrayLength(jbytes); - bytes = (unsigned char *) env->GetByteArrayElements(jbytes, NULL); + bytes = (unsigned char *) env->GetByteArrayElements(jbytes, nullptr); /* put 0,0 into version fields */ bytes[4] = 0; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass013/redefclass013.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass013/redefclass013.cpp index c525e6c20e3..c3612a7aab1 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass013/redefclass013.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass013/redefclass013.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -53,12 +53,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -98,14 +98,14 @@ Java_nsk_jvmti_RedefineClasses_redefclass013_check(JNIEnv *env, unsigned char *bytes; jvmtiClassDefinition classDef; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } classDef.klass = cls; classDef.class_byte_count = env->GetArrayLength(jbytes); - bytes = (unsigned char *) env->GetByteArrayElements(jbytes, NULL); + bytes = (unsigned char *) env->GetByteArrayElements(jbytes, nullptr); /* put 0 into magic field */ bytes[0] = 0; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass014/redefclass014.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass014/redefclass014.cpp index 9c6170b6904..90080ef43d8 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass014/redefclass014.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass014/redefclass014.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -53,12 +53,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -96,7 +96,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass014_check(JNIEnv *env, jclass cls, jbyt jvmtiError err; jvmtiClassDefinition classDef; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -111,7 +111,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass014_check(JNIEnv *env, jclass cls, jbyt classDef.klass = cls; classDef.class_byte_count = env->GetArrayLength(bytes); - classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(bytes, NULL); + classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(bytes, nullptr); if (printdump == JNI_TRUE) { printf(">>> circularity error check ...\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass015/redefclass015.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass015/redefclass015.cpp index 1df2cb4a1eb..5e18751e53a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass015/redefclass015.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass015/redefclass015.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -53,12 +53,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -97,14 +97,14 @@ Java_nsk_jvmti_RedefineClasses_redefclass015_check(JNIEnv *env, jclass cls, jvmtiError err; jvmtiClassDefinition classDef; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } classDef.klass = clazz; classDef.class_byte_count = env->GetArrayLength(bytes); - classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(bytes, NULL); + classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(bytes, nullptr); if (printdump == JNI_TRUE) { printf(">>> verify error check ...\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass016/redefclass016.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass016/redefclass016.cpp index 4e266edd3db..82e72f8befa 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass016/redefclass016.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass016/redefclass016.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,12 +33,12 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; static jint result = PASSED; static jboolean printdump = JNI_FALSE; -static jmethodID mid = NULL; +static jmethodID mid = nullptr; static jint bpeakpointsExpected = 0; static jint bpeakpointsCount = 0; static jlocation loc = 0; @@ -48,7 +48,7 @@ static jint magicNumber; void check(jvmtiEnv *jvmti_env, jthread thr, jclass cls, jmethodID mid, jint i) { jvmtiError err; char *sigClass, *name, *sig, *generic; - jvmtiLocalVariableEntry *table = NULL; + jvmtiLocalVariableEntry *table = nullptr; jint entryCount = 0; jint varValue = -1; jint j; @@ -77,7 +77,7 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jclass cls, jmethodID mid, jint i) result = STATUS_FAILED; return; } - if (table != NULL) { + if (table != nullptr) { for (j = 0; j < entryCount; j++) { if (strcmp(table[j].name, "localVar") == 0) { err = jvmti_env->GetLocalInt(thr, 0, @@ -102,16 +102,16 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jclass cls, jmethodID mid, jint i) result = STATUS_FAILED; } - if (sigClass != NULL) { + if (sigClass != nullptr) { jvmti_env->Deallocate((unsigned char*)sigClass); } - if (name != NULL) { + if (name != nullptr) { jvmti_env->Deallocate((unsigned char*)name); } - if (sig != NULL) { + if (sig != nullptr) { jvmti_env->Deallocate((unsigned char*)sig); } - if (table != NULL) { + if (table != nullptr) { for (j = 0; j < entryCount; j++) { jvmti_env->Deallocate((unsigned char*)(table[j].name)); jvmti_env->Deallocate((unsigned char*)(table[j].signature)); @@ -148,7 +148,7 @@ void JNICALL Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *env, classDef.klass = klass; classDef.class_byte_count = env->GetArrayLength(classBytes); - bytes = (unsigned char *) env->GetByteArrayElements(classBytes, NULL); + bytes = (unsigned char *) env->GetByteArrayElements(classBytes, nullptr); for (i = 0; i < classDef.class_byte_count - 3; i++) { if (((jint)bytes[i+3] | @@ -202,12 +202,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -264,10 +264,10 @@ JNIEXPORT void JNICALL Java_nsk_jvmti_RedefineClasses_redefclass016_getReady(JNIEnv *env, jclass cls, jclass clazz, jbyteArray bytes, jint magic, jint line) { jvmtiError err; - jvmtiLineNumberEntry *lines = NULL; + jvmtiLineNumberEntry *lines = nullptr; jint i = 0, entryCount = 0; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; @@ -279,7 +279,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass016_getReady(JNIEnv *env, jclass cls, !caps.can_access_local_variables) return; mid = env->GetMethodID(clazz, "run", "()V"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot find Method ID for method run\n"); result = STATUS_FAILED; return; @@ -295,7 +295,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass016_getReady(JNIEnv *env, jclass cls, return; } - if (lines != NULL && entryCount > 0) { + if (lines != nullptr && entryCount > 0) { for (i = 0; i < entryCount; i++) { if (line == lines[i].line_number) { loc = lines[i].start_location; @@ -318,7 +318,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass016_getReady(JNIEnv *env, jclass cls, } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_BREAKPOINT, NULL); + JVMTI_EVENT_BREAKPOINT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable BREAKPOINT event: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass017/redefclass017.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass017/redefclass017.cpp index cd2076cf9a7..65fe8b5572c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass017/redefclass017.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass017/redefclass017.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,12 +33,12 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; static jint result = PASSED; static jboolean printdump = JNI_FALSE; -static jmethodID mid = NULL; +static jmethodID mid = nullptr; static jbyteArray classBytes; void JNICALL Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *env, @@ -64,7 +64,7 @@ void JNICALL Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *env, classDef.klass = klass; classDef.class_byte_count = env->GetArrayLength(classBytes); classDef.class_bytes = (unsigned char *) - env->GetByteArrayElements(classBytes, NULL); + env->GetByteArrayElements(classBytes, nullptr); if (printdump == JNI_TRUE) { printf(">>> bp: about to call RedefineClasses\n"); @@ -93,12 +93,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -148,7 +148,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass017_getReady(JNIEnv *env, jclass cls, jclass clazz, jbyteArray bytes) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; @@ -158,7 +158,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass017_getReady(JNIEnv *env, jclass cls, !caps.can_generate_breakpoint_events) return; mid = env->GetMethodID(clazz, "checkPoint", "()V"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot find Method ID for method run\n"); result = STATUS_FAILED; return; @@ -175,7 +175,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass017_getReady(JNIEnv *env, jclass cls, } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_BREAKPOINT, NULL); + JVMTI_EVENT_BREAKPOINT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable BREAKPOINT event: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass018/redefclass018.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass018/redefclass018.cpp index 68d2ac89263..37fc8d71108 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass018/redefclass018.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass018/redefclass018.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; static jint result = PASSED; @@ -49,7 +49,7 @@ Exception(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread, jvmtiClassDefinition classDef; err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, - JVMTI_EVENT_EXCEPTION, NULL); + JVMTI_EVENT_EXCEPTION, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to disable JVMTI_EVENT_EXCEPTION: %s (%d)\n", TranslateError(err), err); @@ -66,7 +66,7 @@ Exception(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread, classDef.klass = klass; classDef.class_byte_count = env->GetArrayLength(classBytes); - classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, NULL); + classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, nullptr); if (printdump == JNI_TRUE) { printf(">>> about to call RedefineClasses\n"); @@ -95,12 +95,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -151,7 +151,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass018_getReady(JNIEnv *env, jclass cls, jvmtiError err; jthread thread; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass019/redefclass019.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass019/redefclass019.cpp index 414005124eb..ee650ff1914 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass019/redefclass019.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass019/redefclass019.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -48,14 +48,14 @@ typedef struct { var_info *vars; } frame_info; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; static jint result = PASSED; static jboolean printdump = JNI_FALSE; static jbyteArray classBytes; -static jmethodID midCheckPoint = NULL; -static jmethodID midRun = NULL; +static jmethodID midCheckPoint = nullptr; +static jmethodID midRun = nullptr; static jint framesExpected = 0; static jint framesCount = 0; @@ -96,10 +96,10 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jmethodID mid, jint i) { jvmtiError err; jclass cls; jlocation loc; - char *sigClass, *name = NULL, *sig = NULL, *generic; + char *sigClass, *name = nullptr, *sig = nullptr, *generic; jboolean is_obsolete; - jvmtiLineNumberEntry *lines = NULL; - jvmtiLocalVariableEntry *table = NULL; + jvmtiLineNumberEntry *lines = nullptr; + jvmtiLocalVariableEntry *table = nullptr; jint line = -1; jint entryCount = 0; jint varValue = -1; @@ -135,10 +135,10 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jmethodID mid, jint i) { return; } - if (sigClass == NULL || strcmp(sigClass, cls_exp) != 0) { + if (sigClass == nullptr || strcmp(sigClass, cls_exp) != 0) { printf("(pop %d) wrong class sig: \"%s\",", i, sigClass); printf(" expected: \"%s\"\n", cls_exp); - if (sigClass != NULL) { + if (sigClass != nullptr) { jvmti_env->Deallocate((unsigned char*)sigClass); } result = STATUS_FAILED; @@ -167,12 +167,12 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jmethodID mid, jint i) { (is_obsolete == JNI_TRUE) ? "unexpected" : "should be"); result = STATUS_FAILED; } - if (name == NULL || strcmp(name, frames[i].name) != 0) { + if (name == nullptr || strcmp(name, frames[i].name) != 0) { printf("(pop %d) wrong method name: \"%s\",", i, name); printf(" expected: \"%s\"\n", frames[i].name); result = STATUS_FAILED; } - if (sig == NULL || strcmp(sig, frames[i].sig) != 0) { + if (sig == nullptr || strcmp(sig, frames[i].sig) != 0) { printf("(pop %d) wrong method sig: \"%s\",", i, sig); printf(" expected: \"%s\"\n", frames[i].sig); result = STATUS_FAILED; @@ -187,7 +187,7 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jmethodID mid, jint i) { return; } - if (lines != NULL && entryCount > 0) { + if (lines != nullptr && entryCount > 0) { for (k = 0; k < entryCount; k++) { if (loc < lines[k].start_location) { break; @@ -216,7 +216,7 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jmethodID mid, jint i) { result = STATUS_FAILED; } - if (table != NULL) { + if (table != nullptr) { for (k = 0; k < frames[i].count; k++) { for (j = 0; j < entryCount; j++) { if (strcmp(table[j].name, frames[i].vars[k].name) == 0 && @@ -256,19 +256,19 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jmethodID mid, jint i) { } } - if (sigClass != NULL) { + if (sigClass != nullptr) { jvmti_env->Deallocate((unsigned char*)sigClass); } - if (name != NULL) { + if (name != nullptr) { jvmti_env->Deallocate((unsigned char*)name); } - if (sig != NULL) { + if (sig != nullptr) { jvmti_env->Deallocate((unsigned char*)sig); } - if (lines != NULL) { + if (lines != nullptr) { jvmti_env->Deallocate((unsigned char*)lines); } - if (table != NULL) { + if (table != nullptr) { for (j = 0; j < entryCount; j++) { jvmti_env->Deallocate((unsigned char*)(table[j].name)); jvmti_env->Deallocate((unsigned char*)(table[j].signature)); @@ -311,7 +311,7 @@ void JNICALL Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *env, classDef.klass = klass; classDef.class_byte_count = env->GetArrayLength(classBytes); classDef.class_bytes = (unsigned char *) - env->GetByteArrayElements(classBytes, NULL); + env->GetByteArrayElements(classBytes, nullptr); if (printdump == JNI_TRUE) { printf(">>> about to call RedefineClasses\n"); @@ -368,12 +368,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -433,7 +433,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass019_getReady(JNIEnv *env, jclass cls, jclass clazz, jbyteArray bytes, jint depth) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; @@ -448,14 +448,14 @@ Java_nsk_jvmti_RedefineClasses_redefclass019_getReady(JNIEnv *env, jclass cls, classBytes = (jbyteArray) env->NewGlobalRef(bytes); midRun = env->GetMethodID(clazz, "run", "()V"); - if (midRun == NULL) { + if (midRun == nullptr) { printf("Cannot find Method ID for method run\n"); result = STATUS_FAILED; return; } midCheckPoint = env->GetMethodID(clazz, "checkPoint", "()V"); - if (midCheckPoint == NULL) { + if (midCheckPoint == nullptr) { printf("Cannot find Method ID for method checkPoint\n"); result = STATUS_FAILED; return; @@ -470,7 +470,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass019_getReady(JNIEnv *env, jclass cls, } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_BREAKPOINT, NULL); + JVMTI_EVENT_BREAKPOINT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable BREAKPOINT event: %s (%d)\n", TranslateError(err), err); @@ -479,7 +479,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass019_getReady(JNIEnv *env, jclass cls, } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_FRAME_POP, NULL); + JVMTI_EVENT_FRAME_POP, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable FRAME_POP event: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass020/redefclass020.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass020/redefclass020.cpp index 955fd841aaa..c8eee73de4d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass020/redefclass020.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass020/redefclass020.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -53,12 +53,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -97,14 +97,14 @@ Java_nsk_jvmti_RedefineClasses_redefclass020_check(JNIEnv *env, jclass cls, jvmtiError err; jvmtiClassDefinition classDef; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } classDef.klass = clazz; classDef.class_byte_count = env->GetArrayLength(bytes); - classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(bytes, NULL); + classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(bytes, nullptr); if (printdump == JNI_TRUE) { printf(">>> add method capability check ...\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass021/redefclass021.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass021/redefclass021.cpp index e44872125f6..8e8f75e344f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass021/redefclass021.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass021/redefclass021.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -53,12 +53,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -97,14 +97,14 @@ Java_nsk_jvmti_RedefineClasses_redefclass021_check(JNIEnv *env, jclass cls, jvmtiError err; jvmtiClassDefinition classDef; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } classDef.klass = clazz; classDef.class_byte_count = env->GetArrayLength(bytes); - classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(bytes, NULL); + classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(bytes, nullptr); if (printdump == JNI_TRUE) { printf(">>> delete method capability check ...\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass022/redefclass022.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass022/redefclass022.cpp index e931801f560..dfda41c4b84 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass022/redefclass022.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass022/redefclass022.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -53,12 +53,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -97,14 +97,14 @@ Java_nsk_jvmti_RedefineClasses_redefclass022_check(JNIEnv *env, jclass cls, jvmtiError err; jvmtiClassDefinition classDef; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } classDef.klass = clazz; classDef.class_byte_count = env->GetArrayLength(bytes); - classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(bytes, NULL); + classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(bytes, nullptr); if (printdump == JNI_TRUE) { printf(">>> change fields capability check ...\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass023/redefclass023.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass023/redefclass023.cpp index 4d118e726d3..7a10b9dc5ee 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass023/redefclass023.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass023/redefclass023.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -53,12 +53,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -97,14 +97,14 @@ Java_nsk_jvmti_RedefineClasses_redefclass023_check(JNIEnv *env, jclass cls, jvmtiError err; jvmtiClassDefinition classDef; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } classDef.klass = clazz; classDef.class_byte_count = env->GetArrayLength(bytes); - classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(bytes, NULL); + classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(bytes, nullptr); if (printdump == JNI_TRUE) { printf(">>> change implemented interface capability check ...\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass024/redefclass024.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass024/redefclass024.cpp index 41c4a849275..bd877d2e0b3 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass024/redefclass024.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass024/redefclass024.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -53,12 +53,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -97,14 +97,14 @@ Java_nsk_jvmti_RedefineClasses_redefclass024_check(JNIEnv *env, jclass cls, jvmtiError err; jvmtiClassDefinition classDef; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } classDef.klass = clazz; classDef.class_byte_count = env->GetArrayLength(bytes); - classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(bytes, NULL); + classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(bytes, nullptr); if (printdump == JNI_TRUE) { printf(">>> change class modifiers capability check ...\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass025/redefclass025.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass025/redefclass025.cpp index ee5b364dc7e..d992762d4ca 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass025/redefclass025.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass025/redefclass025.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -53,12 +53,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -97,14 +97,14 @@ Java_nsk_jvmti_RedefineClasses_redefclass025_check(JNIEnv *env, jclass cls, jvmtiError err; jvmtiClassDefinition classDef; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } classDef.klass = clazz; classDef.class_byte_count = env->GetArrayLength(bytes); - classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(bytes, NULL); + classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(bytes, nullptr); if (printdump == JNI_TRUE) { printf(">>> change method modifiers capability check ...\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass026/redefclass026.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass026/redefclass026.cpp index 68366880a65..efa2b86fa10 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass026/redefclass026.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass026/redefclass026.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -53,12 +53,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -97,14 +97,14 @@ Java_nsk_jvmti_RedefineClasses_redefclass026_check(JNIEnv *env, jclass cls, jvmtiError err; jvmtiClassDefinition classDef; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } classDef.klass = clazz; classDef.class_byte_count = env->GetArrayLength(bytes); - classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(bytes, NULL); + classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(bytes, nullptr); if (printdump == JNI_TRUE) { printf(">>> changed class name check ...\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass027/redefclass027.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass027/redefclass027.cpp index cdcf5f4868e..badd984de77 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass027/redefclass027.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass027/redefclass027.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -50,17 +50,17 @@ typedef struct { const char *desc; } frame_info; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; static jint result = PASSED; static jboolean printdump = JNI_FALSE; static jbyteArray classBytes; -static jmethodID midRun = NULL; -static jmethodID mid1 = NULL; -static jmethodID mid2 = NULL; -static jfieldID fid1 = NULL; -static jfieldID fid2 = NULL; +static jmethodID midRun = nullptr; +static jmethodID mid1 = nullptr; +static jmethodID mid2 = nullptr; +static jfieldID fid1 = nullptr; +static jfieldID fid2 = nullptr; static jint stepEventsExpected = 0; static jint bpEventsExpected = 0; static jint popEventsExpected = 0; @@ -118,11 +118,11 @@ static frame_info frames[] = { void check(jvmtiEnv *jvmti_env, jthread thr, jclass cls, jmethodID mid, jlocation loc, jint i) { jvmtiError err; - char *sigClass, *name = NULL, *sig = NULL, *generic; + char *sigClass, *name = nullptr, *sig = nullptr, *generic; const char *desc; jboolean is_obsolete; - jvmtiLineNumberEntry *lines = NULL; - jvmtiLocalVariableEntry *table = NULL; + jvmtiLineNumberEntry *lines = nullptr; + jvmtiLocalVariableEntry *table = nullptr; jint line = -1; jint entryCount = 0; jint varValue = -1; @@ -144,10 +144,10 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jclass cls, jmethodID mid, result = STATUS_FAILED; } - if (sigClass == NULL || strcmp(sigClass, cls_exp) != 0) { + if (sigClass == nullptr || strcmp(sigClass, cls_exp) != 0) { printf("(%s) wrong class sig: \"%s\",", desc, sigClass); printf(" expected: \"%s\"\n", cls_exp); - if (sigClass != NULL) { + if (sigClass != nullptr) { jvmti_env->Deallocate((unsigned char *)sigClass); } result = STATUS_FAILED; @@ -176,12 +176,12 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jclass cls, jmethodID mid, (is_obsolete == JNI_TRUE) ? "unexpected" : "should be"); result = STATUS_FAILED; } - if (name == NULL || strcmp(name, frames[i].name) != 0) { + if (name == nullptr || strcmp(name, frames[i].name) != 0) { printf("(%s) wrong method name: \"%s\",", desc, name); printf(" expected: \"%s\"\n", frames[i].name); result = STATUS_FAILED; } - if (sig == NULL || strcmp(sig, frames[i].sig) != 0) { + if (sig == nullptr || strcmp(sig, frames[i].sig) != 0) { printf("(%s) wrong method sig: \"%s\",", desc, sig); printf(" expected: \"%s\"\n", frames[i].sig); result = STATUS_FAILED; @@ -195,7 +195,7 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jclass cls, jmethodID mid, result = STATUS_FAILED; } - if (lines != NULL && entryCount > 0) { + if (lines != nullptr && entryCount > 0) { for (k = 0; k < entryCount; k++) { if (loc < lines[k].start_location) { break; @@ -223,7 +223,7 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jclass cls, jmethodID mid, result = STATUS_FAILED; } - if (table != NULL) { + if (table != nullptr) { for (k = 0; k < frames[i].count; k++) { for (j = 0; j < entryCount; j++) { if (strcmp(table[j].name, frames[i].vars[k].name) == 0 && @@ -272,19 +272,19 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jclass cls, jmethodID mid, } } - if (sigClass != NULL) { + if (sigClass != nullptr) { jvmti_env->Deallocate((unsigned char *)sigClass); } - if (name != NULL) { + if (name != nullptr) { jvmti_env->Deallocate((unsigned char *)name); } - if (sig != NULL) { + if (sig != nullptr) { jvmti_env->Deallocate((unsigned char *)sig); } - if (lines != NULL) { + if (lines != nullptr) { jvmti_env->Deallocate((unsigned char *)lines); } - if (table != NULL) { + if (table != nullptr) { for (j = 0; j < entryCount; j++) { jvmti_env->Deallocate((unsigned char *)(table[j].name)); jvmti_env->Deallocate((unsigned char *)(table[j].signature)); @@ -299,7 +299,7 @@ void redefine(jvmtiEnv *jvmti_env, JNIEnv *env, jclass cls) { classDef.klass = cls; classDef.class_byte_count = env->GetArrayLength(classBytes); - classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, NULL); + classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, nullptr); if (printdump == JNI_TRUE) { printf(">>> about to call RedefineClasses %d\n", redefinesCount); @@ -531,7 +531,7 @@ void JNICALL ExceptionCatch(jvmtiEnv *jvmti_env, JNIEnv *env, if (caps.can_generate_frame_pop_events) { err = jvmti_env->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_FRAME_POP, NULL); + JVMTI_EVENT_FRAME_POP, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable FRAME_POP event: %s (%d)\n", TranslateError(err), err); @@ -596,12 +596,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -687,7 +687,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass027_getReady(JNIEnv *env, jclass cls, jclass clazz, jbyteArray bytes) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; @@ -700,24 +700,24 @@ Java_nsk_jvmti_RedefineClasses_redefclass027_getReady(JNIEnv *env, jclass cls, classBytes = (jbyteArray) env->NewGlobalRef(bytes); midRun = env->GetMethodID(clazz, "run", "()V"); - if (midRun == NULL) { + if (midRun == nullptr) { printf("Cannot find Method ID for method run\n"); result = STATUS_FAILED; } mid1 = env->GetMethodID(clazz, "method1", "(I)V"); - if (mid1 == NULL) { + if (mid1 == nullptr) { printf("Cannot find Method ID for method1\n"); result = STATUS_FAILED; } mid2 = env->GetMethodID(clazz, "method2", "(I)V"); - if (mid2 == NULL) { + if (mid2 == nullptr) { printf("Cannot find Method ID for method2\n"); result = STATUS_FAILED; } - if (caps.can_generate_breakpoint_events && midRun != NULL) { + if (caps.can_generate_breakpoint_events && midRun != nullptr) { err = jvmti->SetBreakpoint(midRun, 0); if (err != JVMTI_ERROR_NONE) { printf("(SetBreakpoint) unexpected error: %s (%d)\n", @@ -725,7 +725,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass027_getReady(JNIEnv *env, jclass cls, result = STATUS_FAILED; } else { err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_BREAKPOINT, NULL); + JVMTI_EVENT_BREAKPOINT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable BREAKPOINT event: %s (%d)\n", TranslateError(err), err); @@ -737,12 +737,12 @@ Java_nsk_jvmti_RedefineClasses_redefclass027_getReady(JNIEnv *env, jclass cls, } fid1 = env->GetStaticFieldID(clazz, "staticInt", "I"); - if (fid1 == NULL) { + if (fid1 == nullptr) { printf("Cannot find Field ID for staticInt\n"); result = STATUS_FAILED; } - if (caps.can_generate_field_modification_events && fid1 != NULL) { + if (caps.can_generate_field_modification_events && fid1 != nullptr) { err = jvmti->SetFieldModificationWatch(clazz, fid1); if (err != JVMTI_ERROR_NONE) { printf("(SetFieldModificationWatch) unexpected error: %s (%d)\n", @@ -750,7 +750,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass027_getReady(JNIEnv *env, jclass cls, result = STATUS_FAILED; } else { err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_FIELD_MODIFICATION, NULL); + JVMTI_EVENT_FIELD_MODIFICATION, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable FIELD_MODIFICATION event: %s (%d)\n", TranslateError(err), err); @@ -762,12 +762,12 @@ Java_nsk_jvmti_RedefineClasses_redefclass027_getReady(JNIEnv *env, jclass cls, } fid2 = env->GetFieldID(clazz, "instanceInt", "I"); - if (fid2 == NULL) { + if (fid2 == nullptr) { printf("Cannot find Field ID for instanceInt\n"); result = STATUS_FAILED; } - if (caps.can_generate_field_access_events && fid2 != NULL) { + if (caps.can_generate_field_access_events && fid2 != nullptr) { err = jvmti->SetFieldAccessWatch(clazz, fid2); if (err != JVMTI_ERROR_NONE) { printf("(SetFieldAccessWatch) unexpected error: %s (%d)\n", @@ -775,7 +775,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass027_getReady(JNIEnv *env, jclass cls, result = STATUS_FAILED; } else { err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_FIELD_ACCESS, NULL); + JVMTI_EVENT_FIELD_ACCESS, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable FIELD_ACCESS event: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass028/redefclass028.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass028/redefclass028.cpp index 09a8467c355..a00888c4d5b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass028/redefclass028.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass028/redefclass028.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ static jvmtiEvent eventsList[EVENTS_COUNT] = { JVMTI_EVENT_COMPILED_METHOD_UNLOAD }; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; static volatile int fire = 0; /* CompiledMethodLoad received for hotspot method */ static jmethodID hsMethodID; /* hotspot method ID */ @@ -100,7 +100,7 @@ CompiledMethodLoad(jvmtiEnv *jvmti_env, jmethodID method, jint code_size, char *sig; NSK_DISPLAY0("CompiledMethodLoad event received for:\n"); - if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &sig, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &sig, nullptr))) { nsk_jvmti_setFailStatus(); return; } @@ -133,7 +133,7 @@ CompiledMethodUnload(jvmtiEnv* jvmti_env, jmethodID method, NSK_DISPLAY0("CompiledMethodUnload event received\n"); // Check for the case that the class has been unloaded - err = jvmti_env->GetMethodName(method, &name, &sig, NULL); + err = jvmti_env->GetMethodName(method, &name, &sig, nullptr); if (err == JVMTI_ERROR_NONE) { NSK_DISPLAY3("for: \tmethod: name=\"%s\" signature=\"%s\"\n\tnative address=0x%p\n", name, sig, code_addr); @@ -188,7 +188,7 @@ agentProc(jvmtiEnv* jvmti_env, JNIEnv* jni_env, void* arg) { nsk_jvmti_resumeSync(); return; } - if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(decl_cls, &cls_sig, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(decl_cls, &cls_sig, nullptr))) { nsk_jvmti_setFailStatus(); nsk_jvmti_resumeSync(); return; @@ -249,7 +249,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add required capabilities */ @@ -269,12 +269,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { NSK_DISPLAY0("setting event callbacks done\nenabling events ...\n"); if (!nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, - eventsList, NULL)) + eventsList, nullptr)) return JNI_ERR; NSK_DISPLAY0("enabling the events done\n\n"); /* register agent proc */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass029/redefclass029.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass029/redefclass029.cpp index 9f7fc1fc5a5..8662e65a4b6 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass029/redefclass029.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass029/redefclass029.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ static jvmtiEvent eventsList[EVENTS_COUNT] = { JVMTI_EVENT_COMPILED_METHOD_UNLOAD }; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; static volatile int fire = 0; /* CompiledMethodLoad received for hotspot method */ static jmethodID hsMethodID; /* hotspot method ID */ @@ -99,7 +99,7 @@ CompiledMethodLoad(jvmtiEnv *jvmti_env, jmethodID method, jint code_size, char *sig; NSK_DISPLAY0("CompiledMethodLoad event received for:\n"); - if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &sig, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &sig, nullptr))) { nsk_jvmti_setFailStatus(); return; } @@ -132,7 +132,7 @@ CompiledMethodUnload(jvmtiEnv* jvmti_env, jmethodID method, NSK_DISPLAY0("CompiledMethodUnload event received\n"); // Check for the case that the class has been unloaded - err = jvmti_env->GetMethodName(method, &name, &sig, NULL); + err = jvmti_env->GetMethodName(method, &name, &sig, nullptr); if (err == JVMTI_ERROR_NONE) { NSK_DISPLAY3("for: \tmethod: name=\"%s\" signature=\"%s\"\n\tnative address=0x%p\n", name, sig, code_addr); @@ -187,7 +187,7 @@ agentProc(jvmtiEnv* jvmti_env, JNIEnv* jni_env, void* arg) { nsk_jvmti_resumeSync(); return; } - if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(decl_cls, &cls_sig, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(decl_cls, &cls_sig, nullptr))) { nsk_jvmti_setFailStatus(); nsk_jvmti_resumeSync(); return; @@ -248,7 +248,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add required capabilities */ @@ -268,12 +268,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { NSK_DISPLAY0("setting event callbacks done\nenabling events ...\n"); if (!nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, - eventsList, NULL)) + eventsList, nullptr)) return JNI_ERR; NSK_DISPLAY0("enabling the events done\n\n"); /* register agent proc */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass030/redefclass030.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass030/redefclass030.cpp index b7d6daafbbd..04d3c1b2361 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass030/redefclass030.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass030/redefclass030.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ static jvmtiEvent eventsList[EVENTS_COUNT] = { JVMTI_EVENT_COMPILED_METHOD_UNLOAD }; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; static volatile int fire = 0; /* CompiledMethodLoad received for hotspot method */ static jmethodID hsMethodID; /* hotspot method ID */ @@ -100,7 +100,7 @@ CompiledMethodLoad(jvmtiEnv *jvmti_env, jmethodID method, jint code_size, char *sig; NSK_DISPLAY0("CompiledMethodLoad event received for:\n"); - if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &sig, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &sig, nullptr))) { nsk_jvmti_setFailStatus(); return; } @@ -133,7 +133,7 @@ CompiledMethodUnload(jvmtiEnv* jvmti_env, jmethodID method, NSK_DISPLAY0("CompiledMethodUnload event received\n"); // Check for the case that the class has been unloaded - err = jvmti_env->GetMethodName(method, &name, &sig, NULL); + err = jvmti_env->GetMethodName(method, &name, &sig, nullptr); if (err == JVMTI_ERROR_NONE) { NSK_DISPLAY3("for: \tmethod: name=\"%s\" signature=\"%s\"\n\tnative address=0x%p\n", name, sig, code_addr); @@ -188,7 +188,7 @@ agentProc(jvmtiEnv* jvmti_env, JNIEnv* jni_env, void* arg) { nsk_jvmti_resumeSync(); return; } - if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(decl_cls, &cls_sig, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(decl_cls, &cls_sig, nullptr))) { nsk_jvmti_setFailStatus(); nsk_jvmti_resumeSync(); return; @@ -249,7 +249,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add required capabilities */ @@ -269,12 +269,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { NSK_DISPLAY0("setting event callbacks done\nenabling events ...\n"); if (!nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, - eventsList, NULL)) + eventsList, nullptr)) return JNI_ERR; NSK_DISPLAY0("enabling the events done\n\n"); /* register agent proc */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass031/redefclass031.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass031/redefclass031.cpp index 9d242130a0f..34a98b5f875 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass031/redefclass031.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass031/redefclass031.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,13 +33,13 @@ extern "C" { #define STATUS_FAILED 2 #define PASSED 0 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; static int watch_ev = 0; /* ignore JVMTI events by default */ static int gen_ev = 0; /* number of generated events */ static int result = PASSED; /* total result of the test */ -static jthread test_thread = NULL; +static jthread test_thread = nullptr; static jrawMonitorID watch_ev_monitor; @@ -54,9 +54,9 @@ static void set_watch_ev(JNIEnv *env, int value) { } else { test_thread = env->NewGlobalRef(test_thread); } - } else if (test_thread != NULL) { + } else if (test_thread != nullptr) { env->DeleteGlobalRef(test_thread); - test_thread = NULL; + test_thread = nullptr; } watch_ev = value; @@ -85,10 +85,10 @@ NativeMethodBind(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thr, jmethodID method } else { printf("got JVMTI_EVENT_NATIVE_METHOD_BIND event on thread '%s', ignoring", inf.name); jvmti_env->Deallocate((unsigned char *)inf.name); - if (inf.thread_group != NULL) { + if (inf.thread_group != nullptr) { env->DeleteLocalRef(inf.thread_group); } - if (inf.context_class_loader != NULL) { + if (inf.context_class_loader != nullptr) { env->DeleteLocalRef(inf.context_class_loader); } } @@ -168,7 +168,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass031_makeRedefinition(JNIEnv *env, jvmtiError err; jvmtiClassDefinition classDef; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -177,7 +177,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass031_makeRedefinition(JNIEnv *env, return PASSED; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_NATIVE_METHOD_BIND, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_NATIVE_METHOD_BIND, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable JVMTI_EVENT_NATIVE_METHOD_BIND: %s (%d)\n", TranslateError(err), err); @@ -187,7 +187,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass031_makeRedefinition(JNIEnv *env, /* filling the structure jvmtiClassDefinition */ classDef.klass = redefCls; classDef.class_byte_count = env->GetArrayLength(classBytes); - classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, NULL); + classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, nullptr); set_watch_ev(env, 1); /* watch JVMTI events */ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RelinquishCapabilities/relcaps001/relcaps001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RelinquishCapabilities/relcaps001/relcaps001.cpp index 736715c2ab6..52e076741a3 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RelinquishCapabilities/relcaps001/relcaps001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RelinquishCapabilities/relcaps001/relcaps001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -302,7 +302,7 @@ callbackVMDeath(jvmtiEnv* jvmti, JNIEnv* jni) { success = checkCapabilities(jvmti, &initCaps, "VM_DEATH callback"); NSK_DISPLAY1("Disable events: %d events\n", EVENTS_COUNT); - if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, NULL)) { + if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, nullptr)) { success = false; } else { NSK_DISPLAY0(" ... disabled\n"); @@ -329,7 +329,7 @@ JNIEXPORT jint JNI_OnLoad_relcaps001(JavaVM *jvm, char *options, void *reserved) } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -337,7 +337,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; { @@ -352,7 +352,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&initCaps, 0, sizeof(jvmtiCapabilities)); @@ -375,7 +375,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } NSK_DISPLAY1("Enable events: %d events\n", EVENTS_COUNT); - if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, NULL)) { + if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, nullptr)) { NSK_DISPLAY0(" ... enabled\n"); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RelinquishCapabilities/relcaps002/relcaps002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RelinquishCapabilities/relcaps002/relcaps002.cpp index 8ff71c76c7a..c5ad887f7f3 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RelinquishCapabilities/relcaps002/relcaps002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RelinquishCapabilities/relcaps002/relcaps002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -301,7 +301,7 @@ callbackVMDeath(jvmtiEnv* jvmti, JNIEnv* jni) { success = checkCapabilities(jvmti, &initCaps, "VM_DEATH callback"); NSK_DISPLAY1("Disable events: %d events\n", EVENTS_COUNT); - if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, NULL)) { + if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, nullptr)) { success = false; } else { NSK_DISPLAY0(" ... disabled\n"); @@ -328,7 +328,7 @@ JNIEXPORT jint JNI_OnLoad_relcaps002(JavaVM *jvm, char *options, void *reserved) } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -336,7 +336,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; { @@ -351,7 +351,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&initCaps, 0, sizeof(jvmtiCapabilities)); @@ -364,7 +364,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } NSK_DISPLAY1("Enable events: %d events\n", EVENTS_COUNT); - if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, NULL)) { + if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, nullptr)) { NSK_DISPLAY0(" ... enabled\n"); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ResourceExhausted/resexhausted.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ResourceExhausted/resexhausted.cpp index b3c6304ee0c..f5a68c17ec7 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ResourceExhausted/resexhausted.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ResourceExhausted/resexhausted.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024, 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 @@ -32,7 +32,7 @@ extern "C" { -static jvmtiEnv* gJvmti = NULL; +static jvmtiEnv* gJvmti = nullptr; static volatile jint gEventFlags = 0; void JNICALL @@ -80,7 +80,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; - if (!NSK_VERIFY((gJvmti = nsk_jvmti_createJVMTIEnv(vm, reserved)) != NULL)) + if (!NSK_VERIFY((gJvmti = nsk_jvmti_createJVMTIEnv(vm, reserved)) != nullptr)) return JNI_ERR; memset(&capabilities, 0, sizeof(jvmtiCapabilities)); @@ -96,7 +96,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) if (!NSK_JVMTI_VERIFY(gJvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_RESOURCE_EXHAUSTED, - NULL))) + nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ResumeThread/resumethrd001/resumethrd001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ResumeThread/resumethrd001/resumethrd001.cpp index 97689802db3..a3e0ee7e80d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ResumeThread/resumethrd001/resumethrd001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ResumeThread/resumethrd001/resumethrd001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,11 +49,11 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { /* perform testing */ { - jthread testedThread = NULL; + jthread testedThread = nullptr; NSK_DISPLAY1("Find thread: %s\n", THREAD_NAME); if (!NSK_VERIFY((testedThread = - nsk_jvmti_threadByName(THREAD_NAME)) != NULL)) + nsk_jvmti_threadByName(THREAD_NAME)) != nullptr)) return; NSK_DISPLAY1(" ... found thread: %p\n", (void*)testedThread); @@ -118,7 +118,7 @@ JNIEXPORT jint JNI_OnLoad_resumethrd001(JavaVM *jvm, char *options, void *reserv } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -128,7 +128,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add specific capabilities for suspending thread */ @@ -141,7 +141,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ResumeThread/resumethrd002/resumethrd002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ResumeThread/resumethrd002/resumethrd002.cpp index 55a06f21bbc..9afbc2a22d9 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ResumeThread/resumethrd002/resumethrd002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ResumeThread/resumethrd002/resumethrd002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,7 @@ static jvmtiEvent eventsList[EVENTS_COUNT] = { }; static volatile int eventsReceived = 0; -static jthread testedThread = NULL; +static jthread testedThread = nullptr; /* ============================================================================= */ @@ -62,13 +62,13 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { { NSK_DISPLAY1("Find thread: %s\n", THREAD_NAME); if (!NSK_VERIFY((testedThread = - nsk_jvmti_threadByName(THREAD_NAME)) != NULL)) + nsk_jvmti_threadByName(THREAD_NAME)) != nullptr)) return; NSK_DISPLAY1(" ... found thread: %p\n", (void*)testedThread); eventsReceived = 0; NSK_DISPLAY1("Enable event: %s\n", "THREAD_END"); - if (!nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, eventsList, NULL)) + if (!nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, eventsList, nullptr)) return; NSK_DISPLAY1("Suspend thread: %p\n", (void*)testedThread); @@ -102,7 +102,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { } NSK_DISPLAY1("Disable event: %s\n", "THREAD_END"); - if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, eventsList, NULL)) + if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, eventsList, nullptr)) return; NSK_DISPLAY0("Wait for thread to finish\n"); @@ -124,7 +124,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { JNIEXPORT void JNICALL callbackThreadEnd(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { /* check if event is for tested thread */ - if (thread != NULL && + if (thread != nullptr && jni->IsSameObject(testedThread, thread)) { NSK_DISPLAY1(" ... received THREAD_END event for tested thread: %p\n", (void*)thread); eventsReceived++; @@ -148,7 +148,7 @@ JNIEXPORT jint JNI_OnLoad_resumethrd002(JavaVM *jvm, char *options, void *reserv } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -158,7 +158,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add specific capabilities for suspending thread */ @@ -180,7 +180,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ResumeThreadList/resumethrdlst001/resumethrdlst001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ResumeThreadList/resumethrdlst001/resumethrdlst001.cpp index b513fa47ec0..f0c21a7643d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ResumeThreadList/resumethrdlst001/resumethrdlst001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ResumeThreadList/resumethrdlst001/resumethrdlst001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,8 +57,8 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { /* perform testing */ { - jthread* threads = NULL; - jvmtiError* results = NULL; + jthread* threads = nullptr; + jvmtiError* results = nullptr; int i; NSK_DISPLAY1("Allocate threads array: %d threads\n", threadsCount); @@ -138,7 +138,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY0("Delete threads references\n"); for (i = 0; i < threadsCount; i++) { - if (threads[i] != NULL) + if (threads[i] != nullptr) NSK_TRACE(jni->DeleteGlobalRef(threads[i])); } @@ -164,14 +164,14 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { static int fillThreadsByName(jvmtiEnv* jvmti, JNIEnv* jni, const char name[], int foundCount, jthread foundThreads[]) { jint count = 0; - jthread* threads = NULL; + jthread* threads = nullptr; size_t len = strlen(name); int found = 0; int i; for (i = 0; i < foundCount; i++) { - foundThreads[i] = NULL; + foundThreads[i] = nullptr; } if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&count, &threads))) { @@ -188,7 +188,7 @@ static int fillThreadsByName(jvmtiEnv* jvmti, JNIEnv* jni, break; } - if (info.name != NULL && strncmp(name, info.name, len) == 0) { + if (info.name != nullptr && strncmp(name, info.name, len) == 0) { NSK_DISPLAY3(" ... found thread #%d: %p (%s)\n", found, threads[i], info.name); if (found < foundCount) @@ -216,7 +216,7 @@ static int fillThreadsByName(jvmtiEnv* jvmti, JNIEnv* jni, NSK_DISPLAY1("Make global references for threads: %d threads\n", foundCount); for (i = 0; i < foundCount; i++) { if (!NSK_JNI_VERIFY(jni, (foundThreads[i] = (jthread) - jni->NewGlobalRef(foundThreads[i])) != NULL)) { + jni->NewGlobalRef(foundThreads[i])) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -241,7 +241,7 @@ JNIEXPORT jint JNI_OnLoad_resumethrdlst001(JavaVM *jvm, char *options, void *res } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -256,7 +256,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add specific capabilities for suspending thread */ @@ -269,7 +269,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ResumeThreadList/resumethrdlst002/resumethrdlst002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ResumeThreadList/resumethrdlst002/resumethrdlst002.cpp index 36caf52c147..f1508b152ce 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ResumeThreadList/resumethrdlst002/resumethrdlst002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ResumeThreadList/resumethrdlst002/resumethrdlst002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,7 +47,7 @@ static jvmtiEvent eventsList[EVENTS_COUNT] = { }; static int threadsCount = 0; -static jthread* threads = NULL; +static jthread* threads = nullptr; static volatile int eventsReceived = 0; static jrawMonitorID eventsReceivedMtx = 0; @@ -67,7 +67,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { /* perform testing */ { - jvmtiError* results = NULL; + jvmtiError* results = nullptr; int i; NSK_DISPLAY1("Allocate threads array: %d threads\n", threadsCount); @@ -106,7 +106,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { eventsReceived = 0; NSK_DISPLAY1("Enable event: %s\n", "THREAD_END"); - if (!nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, eventsList, NULL)) + if (!nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, eventsList, nullptr)) return; NSK_DISPLAY0("Let threads to run and finish\n"); @@ -145,7 +145,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { } NSK_DISPLAY1("Disable event: %s\n", "THREAD_END"); - if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, eventsList, NULL)) + if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, eventsList, nullptr)) return; NSK_DISPLAY0("Wait for thread to finish\n"); @@ -154,7 +154,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY0("Delete threads references\n"); for (i = 0; i < threadsCount; i++) { - if (threads[i] != NULL) + if (threads[i] != nullptr) NSK_TRACE(jni->DeleteGlobalRef(threads[i])); } @@ -180,14 +180,14 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { static int fillThreadsByName(jvmtiEnv* jvmti, JNIEnv* jni, const char name[], int foundCount, jthread foundThreads[]) { jint count = 0; - jthread* threads = NULL; + jthread* threads = nullptr; size_t len = strlen(name); int found = 0; int i; for (i = 0; i < foundCount; i++) { - foundThreads[i] = NULL; + foundThreads[i] = nullptr; } if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&count, &threads))) { @@ -204,7 +204,7 @@ static int fillThreadsByName(jvmtiEnv* jvmti, JNIEnv* jni, break; } - if (info.name != NULL && strncmp(name, info.name, len) == 0) { + if (info.name != nullptr && strncmp(name, info.name, len) == 0) { NSK_DISPLAY3(" ... found thread #%d: %p (%s)\n", found, threads[i], info.name); if (found < foundCount) @@ -232,7 +232,7 @@ static int fillThreadsByName(jvmtiEnv* jvmti, JNIEnv* jni, NSK_DISPLAY1("Make global references for threads: %d threads\n", foundCount); for (i = 0; i < foundCount; i++) { if (!NSK_JNI_VERIFY(jni, (foundThreads[i] = (jthread) - jni->NewGlobalRef(foundThreads[i])) != NULL)) { + jni->NewGlobalRef(foundThreads[i])) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -257,7 +257,7 @@ callbackThreadEnd(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { /* check if event is for tested thread */ for (i = 0; i < threadsCount; i++) { - if (thread != NULL && + if (thread != nullptr && jni->IsSameObject(threads[i], thread)) { NSK_DISPLAY2(" ... received THREAD_END event for thread #%d: %p\n", i, (void*)thread); @@ -285,7 +285,7 @@ JNIEXPORT jint JNI_OnLoad_resumethrdlst002(JavaVM *jvm, char *options, void *res } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -300,7 +300,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add specific capabilities for suspending thread */ @@ -329,7 +329,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RetransformClasses/retransform002/retransform002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RetransformClasses/retransform002/retransform002.cpp index c9078ea5784..e3bb7f6d611 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RetransformClasses/retransform002/retransform002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RetransformClasses/retransform002/retransform002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,7 @@ extern "C" { -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; /* ============================================================================= */ @@ -101,7 +101,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) return JNI_ERR; if (!NSK_VERIFY( - (jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved)) != NULL + (jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved)) != nullptr ) ) return JNI_ERR; @@ -125,7 +125,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) // Enable class retransformation if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, - NULL))) + nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RetransformClasses/retransform003/retransform003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RetransformClasses/retransform003/retransform003.cpp index 4034dc558f8..69800c848e8 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RetransformClasses/retransform003/retransform003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RetransformClasses/retransform003/retransform003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { /* ============================================================================= */ -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; /* Class, which contains the following callback method: * static public void callback(String className, int agentID) */ @@ -93,31 +93,31 @@ ClassFileLoadHook ( jstring class_name_string; // Check whether currently retransformed class belongs to the package we are interested in - if (name == NULL || strncmp(TRIGGER, name,strlen(name) < strlen(TRIGGER) ? strlen(name) : strlen(TRIGGER))) + if (name == nullptr || strncmp(TRIGGER, name,strlen(name) < strlen(TRIGGER) ? strlen(name) : strlen(TRIGGER))) { return; } // Get ant the invoke callback function - if (!NSK_VERIFY((loader_class = jni->GetObjectClass(loader)) != NULL)) + if (!NSK_VERIFY((loader_class = jni->GetObjectClass(loader)) != nullptr)) return; if (!NSK_VERIFY((method_id = jni->GetMethodID( - loader_class, "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;")) != NULL)) + loader_class, "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;")) != nullptr)) return; - if (!NSK_VERIFY((class_name_string = jni->NewStringUTF(CALLBACK_CLASS_NAME)) != NULL)) + if (!NSK_VERIFY((class_name_string = jni->NewStringUTF(CALLBACK_CLASS_NAME)) != nullptr)) return; if (!NSK_VERIFY((callback_class = (jclass) jni->CallObjectMethod( - loader, method_id, class_name_string)) != NULL)) + loader, method_id, class_name_string)) != nullptr)) return; if (!NSK_VERIFY((method_id = jni->GetStaticMethodID( - callback_class, "callback", "(Ljava/lang/String;I)V")) != NULL)) + callback_class, "callback", "(Ljava/lang/String;I)V")) != nullptr)) return; - if (!NSK_VERIFY((class_name_string = jni->NewStringUTF(name)) != NULL)) + if (!NSK_VERIFY((class_name_string = jni->NewStringUTF(name)) != nullptr)) return; jni->CallStaticObjectMethod(callback_class, method_id, class_name_string, agent_id); @@ -151,7 +151,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) agent_id= nsk_jvmti_findOptionIntValue("id", -1); - if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved)) != NULL)) + if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved)) != nullptr)) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->GetCapabilities(&caps))) @@ -179,7 +179,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) if (!NSK_JVMTI_VERIFY( jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, - NULL))) + nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RetransformClasses/retransform004/retransform004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RetransformClasses/retransform004/retransform004.cpp index 78a4b31d36f..f6f6b9136f4 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RetransformClasses/retransform004/retransform004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RetransformClasses/retransform004/retransform004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { /* ============================================================================= */ -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; /* ============================================================================= */ @@ -106,7 +106,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) jvmtiCapabilities caps; if (!NSK_VERIFY( - (jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved)) != NULL + (jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved)) != nullptr ) ) return JNI_ERR; @@ -131,7 +131,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) if (!NSK_JVMTI_VERIFY( jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, - NULL))) + nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RunAgentThread/agentthr001/agentthr001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RunAgentThread/agentthr001/agentthr001.cpp index 775f564f465..bf19ddb4903 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RunAgentThread/agentthr001/agentthr001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RunAgentThread/agentthr001/agentthr001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ extern "C" { #define STATUS_FAILED 2 #define WAIT_TIME (jlong)100 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -92,7 +92,7 @@ sys_thread_1(jvmtiEnv* jvmti, JNIEnv* jni, void *p) { } count |= 0x01; - err = jvmti->RunAgentThread(jthr(jni), sys_thread_4, NULL, + err = jvmti->RunAgentThread(jthr(jni), sys_thread_4, nullptr, JVMTI_THREAD_MAX_PRIORITY); if (err != JVMTI_ERROR_NONE) { printf("(RunAgentThread#4) unexpected error: %s (%d)\n", @@ -178,7 +178,7 @@ void JNICALL VMInit(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thr) { } err = jvmti_env->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_THREAD_START, NULL); + JVMTI_EVENT_THREAD_START, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable JVMTI_EVENT_THREAD_START: %s (%d)\n", TranslateError(err), err); @@ -206,21 +206,21 @@ ThreadStart(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread) { if (strcmp(thrInfo.name, "thr1") == 0 && !thr1_was_started) { thr1_was_started = 1; err = jvmti_env->RunAgentThread(jthr((JNIEnv *)env), - sys_thread_1, NULL, JVMTI_THREAD_MAX_PRIORITY); + sys_thread_1, nullptr, JVMTI_THREAD_MAX_PRIORITY); if (err != JVMTI_ERROR_NONE) { printf("(RunAgentThread#1) unexpected error: %s (%d)\n", TranslateError(err), err); result = STATUS_FAILED; } err = jvmti_env->RunAgentThread(jthr((JNIEnv *)env), - sys_thread_2, NULL, JVMTI_THREAD_NORM_PRIORITY); + sys_thread_2, nullptr, JVMTI_THREAD_NORM_PRIORITY); if (err != JVMTI_ERROR_NONE) { printf("(RunAgentThread#2) unexpected error: %s (%d)\n", TranslateError(err), err); result = STATUS_FAILED; } err = jvmti_env->RunAgentThread(jthr((JNIEnv *)env), - sys_thread_3, NULL, JVMTI_THREAD_MIN_PRIORITY); + sys_thread_3, nullptr, JVMTI_THREAD_MIN_PRIORITY); if (err != JVMTI_ERROR_NONE) { printf("(RunAgentThread#3) unexpected error: %s (%d)\n", TranslateError(err), err); @@ -244,12 +244,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -271,7 +271,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_VM_INIT, NULL); + JVMTI_EVENT_VM_INIT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable JVMTI_EVENT_VM_INIT: %s (%d)\n", TranslateError(err), err); @@ -285,7 +285,7 @@ JNIEXPORT void JNICALL Java_nsk_jvmti_RunAgentThread_agentthr001_startSysThr(JNIEnv *env, jclass cls) { jvmtiError err; - err = jvmti->RunAgentThread(jthr(env), sys_thread_5, NULL, + err = jvmti->RunAgentThread(jthr(env), sys_thread_5, nullptr, JVMTI_THREAD_MAX_PRIORITY); if (err != JVMTI_ERROR_NONE) { printf("(RunAgentThread#5) unexpected error: %s (%d)\n", @@ -308,7 +308,7 @@ Java_nsk_jvmti_RunAgentThread_agentthr001_getRes(JNIEnv *env, jclass cls) { } err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, - JVMTI_EVENT_THREAD_START, NULL); + JVMTI_EVENT_THREAD_START, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to disable JVMTI_EVENT_THREAD_START: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RunAgentThread/agentthr002/agentthr002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RunAgentThread/agentthr002/agentthr002.cpp index b66836e8ed3..f155561f129 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RunAgentThread/agentthr002/agentthr002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RunAgentThread/agentthr002/agentthr002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; static jrawMonitorID wait_lock; @@ -52,12 +52,12 @@ JNIEXPORT jint JNI_OnLoad_agentthr002(JavaVM *jvm, char *options, void *reserved jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -94,7 +94,7 @@ Java_nsk_jvmti_RunAgentThread_agentthr002_check(JNIEnv *env, jclass cls, jthread jvmtiError err; jvmtiThreadInfo inf; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -109,7 +109,7 @@ Java_nsk_jvmti_RunAgentThread_agentthr002_check(JNIEnv *env, jclass cls, jthread if (printdump == JNI_TRUE) { printf(">>> starting debug thread ...\n"); } - err = jvmti->RunAgentThread(thr, debug_thread, NULL, + err = jvmti->RunAgentThread(thr, debug_thread, nullptr, JVMTI_THREAD_NORM_PRIORITY); if (err != JVMTI_ERROR_NONE) { printf("(RunAgentThread) unexpected error: %s (%d)\n", diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RunAgentThread/agentthr003/agentthr003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RunAgentThread/agentthr003/agentthr003.cpp index 607b9f00557..95bb3e30fa1 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RunAgentThread/agentthr003/agentthr003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RunAgentThread/agentthr003/agentthr003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_agentthr003(JavaVM *jvm, char *options, void *reserved jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -75,7 +75,7 @@ JNIEXPORT jint JNICALL Java_nsk_jvmti_RunAgentThread_agentthr003_check(JNIEnv *env, jclass cls, jthread thr) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -83,7 +83,7 @@ Java_nsk_jvmti_RunAgentThread_agentthr003_check(JNIEnv *env, jclass cls, jthread if (printdump == JNI_TRUE) { printf(">>> invalid thread check ...\n"); } - err = jvmti->RunAgentThread(NULL, agent_thread, NULL, + err = jvmti->RunAgentThread(nullptr, agent_thread, nullptr, JVMTI_THREAD_NORM_PRIORITY); if (err != JVMTI_ERROR_INVALID_THREAD) { printf("Error expected: JVMTI_ERROR_INVALID_THREAD,\n"); @@ -94,7 +94,7 @@ Java_nsk_jvmti_RunAgentThread_agentthr003_check(JNIEnv *env, jclass cls, jthread if (printdump == JNI_TRUE) { printf(">>> null pointer check ...\n"); } - err = jvmti->RunAgentThread(thr, NULL, NULL, + err = jvmti->RunAgentThread(thr, nullptr, nullptr, JVMTI_THREAD_NORM_PRIORITY); if (err != JVMTI_ERROR_NULL_POINTER) { printf("Error expected: JVMTI_ERROR_NULL_POINTER,\n"); @@ -105,7 +105,7 @@ Java_nsk_jvmti_RunAgentThread_agentthr003_check(JNIEnv *env, jclass cls, jthread if (printdump == JNI_TRUE) { printf(">>> less than JVMTI_THREAD_MIN_PRIORITY check ...\n"); } - err = jvmti->RunAgentThread(thr, agent_thread, NULL, + err = jvmti->RunAgentThread(thr, agent_thread, nullptr, JVMTI_THREAD_MIN_PRIORITY - 1); if (err != JVMTI_ERROR_INVALID_PRIORITY) { printf("Error expected: JVMTI_ERROR_INVALID_PRIORITY,\n"); @@ -116,7 +116,7 @@ Java_nsk_jvmti_RunAgentThread_agentthr003_check(JNIEnv *env, jclass cls, jthread if (printdump == JNI_TRUE) { printf(">>> greater than JVMTI_THREAD_MAX_PRIORITY check ...\n"); } - err = jvmti->RunAgentThread(thr, agent_thread, NULL, + err = jvmti->RunAgentThread(thr, agent_thread, nullptr, JVMTI_THREAD_MAX_PRIORITY + 1); if (err != JVMTI_ERROR_INVALID_PRIORITY) { printf("Error expected: JVMTI_ERROR_INVALID_PRIORITY,\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetBreakpoint/setbrk002/setbrk002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetBreakpoint/setbrk002/setbrk002.cpp index 5bee6195805..51a2c0ca72c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetBreakpoint/setbrk002/setbrk002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetBreakpoint/setbrk002/setbrk002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -53,12 +53,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -97,7 +97,7 @@ Java_nsk_jvmti_SetBreakpoint_setbrk002_check(JNIEnv *env, jclass cls) { jlocation start; jlocation end; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -107,7 +107,7 @@ Java_nsk_jvmti_SetBreakpoint_setbrk002_check(JNIEnv *env, jclass cls) { } mid = env->GetStaticMethodID(cls, "run", "([Ljava/lang/String;Ljava/io/PrintStream;)I"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot find method run\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetBreakpoint/setbrk003/setbrk003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetBreakpoint/setbrk003/setbrk003.cpp index b996ed3f021..3f61346a1ea 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetBreakpoint/setbrk003/setbrk003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetBreakpoint/setbrk003/setbrk003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -53,12 +53,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -96,7 +96,7 @@ Java_nsk_jvmti_SetBreakpoint_setbrk003_check(JNIEnv *env, jclass cls) { jvmtiError err; jmethodID mid; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -106,7 +106,7 @@ Java_nsk_jvmti_SetBreakpoint_setbrk003_check(JNIEnv *env, jclass cls) { } mid = env->GetStaticMethodID(cls, "check", "()I"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot find method check\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetBreakpoint/setbrk005/setbrk005.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetBreakpoint/setbrk005/setbrk005.cpp index 462cbe0417b..8c6d5051420 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetBreakpoint/setbrk005/setbrk005.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetBreakpoint/setbrk005/setbrk005.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -53,12 +53,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -96,7 +96,7 @@ Java_nsk_jvmti_SetBreakpoint_setbrk005_check(JNIEnv *env, jclass cls) { jvmtiError err; jmethodID mid; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -106,7 +106,7 @@ Java_nsk_jvmti_SetBreakpoint_setbrk005_check(JNIEnv *env, jclass cls) { } mid = env->GetStaticMethodID(cls, "trial", "()I"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot find method trial\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetBreakpoint/setbrk007/setbrk007.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetBreakpoint/setbrk007/setbrk007.cpp index 79b93a9fbf7..60d56f40aae 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetBreakpoint/setbrk007/setbrk007.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetBreakpoint/setbrk007/setbrk007.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -53,12 +53,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -96,7 +96,7 @@ Java_nsk_jvmti_SetBreakpoint_setbrk007_check(JNIEnv *env, jclass cls) { jvmtiError err; jmethodID mid; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -114,7 +114,7 @@ Java_nsk_jvmti_SetBreakpoint_setbrk007_check(JNIEnv *env, jclass cls) { if (printdump == JNI_TRUE) { printf(">>> invalid method check ...\n"); } - err = jvmti->SetBreakpoint(NULL, 0); + err = jvmti->SetBreakpoint(nullptr, 0); if (err != JVMTI_ERROR_INVALID_METHODID) { printf("Error expected: JVMTI_ERROR_INVALID_METHODID,\n"); printf("\tactual: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetBreakpoint/setbrk008/setbrk008.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetBreakpoint/setbrk008/setbrk008.cpp index 7d893b36a50..b002b2ce371 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetBreakpoint/setbrk008/setbrk008.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetBreakpoint/setbrk008/setbrk008.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; static jint result = PASSED; @@ -82,17 +82,17 @@ void JNICALL Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *env, printf(">>> method: \"%s%s\"\n", name, sig); printf(">>> location: 0x%x%08x\n", (jint)(loc >> 32), (jint)loc); } - if (name == NULL || strcmp(cls_sig, exp_csig) != 0) { + if (name == nullptr || strcmp(cls_sig, exp_csig) != 0) { printf("(bp#%d) wrong class: \"%s\"", eventsCount, cls_sig); printf(", expected: \"%s\"\n", exp_csig); result = STATUS_FAILED; } - if (name == NULL || strcmp(name, exp_name) != 0) { + if (name == nullptr || strcmp(name, exp_name) != 0) { printf("(bp#%d) wrong method name: \"%s\"", eventsCount, name); printf(", expected: \"%s\"\n", exp_name); result = STATUS_FAILED; } - if (sig == NULL || strcmp(sig, exp_sig) != 0) { + if (sig == nullptr || strcmp(sig, exp_sig) != 0) { printf("(bp#%d) wrong method sig: \"%s\"", eventsCount, sig); printf(", expected: \"%s\"\n", exp_sig); result = STATUS_FAILED; @@ -119,12 +119,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -171,7 +171,7 @@ Java_nsk_jvmti_SetBreakpoint_setbrk008_getReady(JNIEnv *env, jvmtiError err; jmethodID mid; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; @@ -182,7 +182,7 @@ Java_nsk_jvmti_SetBreakpoint_setbrk008_getReady(JNIEnv *env, } mid = env->GetStaticMethodID(cls, exp_name, exp_sig); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot find Method ID for method checkPoint\n"); result = STATUS_FAILED; return; @@ -201,7 +201,7 @@ Java_nsk_jvmti_SetBreakpoint_setbrk008_getReady(JNIEnv *env, } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_BREAKPOINT, NULL); + JVMTI_EVENT_BREAKPOINT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable BREAKPOINT event: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEnvironmentLocalStorage/setenvstor001/setenvstor001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEnvironmentLocalStorage/setenvstor001/setenvstor001.cpp index 98400d75bf7..265b10c1083 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEnvironmentLocalStorage/setenvstor001/setenvstor001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEnvironmentLocalStorage/setenvstor001/setenvstor001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -85,7 +85,7 @@ static int setEnvStorage(jvmtiEnv* jvmti, StorageStructure* storage, const char * @returns NSK_FALSE if any error occured. */ static int checkEnvStorage(jvmtiEnv* jvmti, StorageStructure* initialStorage, const char where[]) { - StorageStructure* storage = NULL; + StorageStructure* storage = nullptr; NSK_DISPLAY0("Get local storage for current JVMTI env\n"); if (!NSK_JVMTI_VERIFY(jvmti->GetEnvironmentLocalStorage((void**)&storage))) { @@ -170,7 +170,7 @@ callbackVMDeath(jvmtiEnv* jvmti, JNIEnv* jni) { success = checkEnvStorage(jvmti, initialStorage, "VM_DEATH callback"); NSK_DISPLAY1("Disable events: %d events\n", EVENTS_COUNT); - if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, NULL)) { + if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, nullptr)) { success = NSK_FALSE; } else { NSK_DISPLAY0(" ... disabled\n"); @@ -197,7 +197,7 @@ JNIEXPORT jint JNI_OnLoad_setenvstor001(JavaVM *jvm, char *options, void *reserv } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -205,7 +205,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; { @@ -220,7 +220,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; NSK_DISPLAY1(">>> Prepare storage data at pointer: 0x%p\n", initialStorage); @@ -237,7 +237,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } NSK_DISPLAY1("Enable events: %d events\n", EVENTS_COUNT); - if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, NULL)) { + if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, nullptr)) { NSK_DISPLAY0(" ... enabled\n"); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEnvironmentLocalStorage/setenvstor002/setenvstor002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEnvironmentLocalStorage/setenvstor002/setenvstor002.cpp index 9d53a2ad37a..7194016b9aa 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEnvironmentLocalStorage/setenvstor002/setenvstor002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEnvironmentLocalStorage/setenvstor002/setenvstor002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -85,7 +85,7 @@ static int setEnvStorage(jvmtiEnv* jvmti, StorageStructure* storage, const char * @returns NSK_FALSE if any error occured. */ static int checkEnvStorage(jvmtiEnv* jvmti, StorageStructure* initialStorage, const char where[]) { - StorageStructure* storage = NULL; + StorageStructure* storage = nullptr; NSK_DISPLAY0("Get local storage for current JVMTI env\n"); if (!NSK_JVMTI_VERIFY(jvmti->GetEnvironmentLocalStorage((void**)&storage))) { @@ -175,7 +175,7 @@ callbackVMDeath(jvmtiEnv* jvmti, JNIEnv* jni) { success = checkEnvStorage(jvmti, initialStorage, "VM_DEATH callback"); NSK_DISPLAY1("Disable events: %d events\n", EVENTS_COUNT); - if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, NULL)) { + if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, nullptr)) { success = NSK_FALSE; } else { NSK_DISPLAY0(" ... disabled\n"); @@ -202,7 +202,7 @@ JNIEXPORT jint JNI_OnLoad_setenvstor002(JavaVM *jvm, char *options, void *reserv } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -210,7 +210,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; { @@ -225,14 +225,14 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; NSK_DISPLAY1(">>> Prepare storage data at pointer: 0x%p\n", initialStorage); fillEnvStorage(initialStorage); NSK_DISPLAY1("Enable events: %d events\n", EVENTS_COUNT); - if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, NULL)) { + if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, nullptr)) { NSK_DISPLAY0(" ... enabled\n"); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEnvironmentLocalStorage/setenvstor003/setenvstor003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEnvironmentLocalStorage/setenvstor003/setenvstor003.cpp index 6c3ec2145a3..89ee7cc2887 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEnvironmentLocalStorage/setenvstor003/setenvstor003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEnvironmentLocalStorage/setenvstor003/setenvstor003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -85,7 +85,7 @@ static int setEnvStorage(jvmtiEnv* jvmti, StorageStructure* storage, const char * @returns NSK_FALSE if any error occured. */ static int checkEnvStorage(jvmtiEnv* jvmti, StorageStructure* initialStorage, const char where[]) { - StorageStructure* storage = NULL; + StorageStructure* storage = nullptr; NSK_DISPLAY0("Get local storage for current JVMTI env\n"); if (!NSK_JVMTI_VERIFY(jvmti->GetEnvironmentLocalStorage((void**)&storage))) { @@ -178,7 +178,7 @@ callbackVMDeath(jvmtiEnv* jvmti, JNIEnv* jni) { success = checkEnvStorage(jvmti, initialStorage, "VM_DEATH callback"); NSK_DISPLAY1("Disable events: %d events\n", EVENTS_COUNT); - if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, NULL)) { + if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, nullptr)) { success = NSK_FALSE; } else { NSK_DISPLAY0(" ... disabled\n"); @@ -205,7 +205,7 @@ JNIEXPORT jint JNI_OnLoad_setenvstor003(JavaVM *jvm, char *options, void *reserv } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -213,7 +213,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; { @@ -228,14 +228,14 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; NSK_DISPLAY1(">>> Prepare storage data at pointer: 0x%p\n", initialStorage); fillEnvStorage(initialStorage); NSK_DISPLAY1("Enable events: %d events\n", EVENTS_COUNT); - if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, NULL)) { + if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, nullptr)) { NSK_DISPLAY0(" ... enabled\n"); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEventCallbacks/setevntcallb001/setevntcallb001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEventCallbacks/setevntcallb001/setevntcallb001.cpp index 9b15148fe19..06fe61853f5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEventCallbacks/setevntcallb001/setevntcallb001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEventCallbacks/setevntcallb001/setevntcallb001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -101,7 +101,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { } NSK_DISPLAY0("Disable events\n"); - nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, eventsList, NULL); + nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, eventsList, nullptr); NSK_DISPLAY0("Let debugee to finish\n"); if (!nsk_jvmti_resumeSync()) @@ -146,7 +146,7 @@ callbackVMInit(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks)))) { nsk_jvmti_setFailStatus(); } else { - nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT - 1, eventsList + 1, NULL); + nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT - 1, eventsList + 1, nullptr); } } } @@ -166,7 +166,7 @@ JNIEXPORT jint JNI_OnLoad_setevntcallb001(JavaVM *jvm, char *options, void *rese } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -174,10 +174,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; NSK_DISPLAY0(">>> Testcase #1: Set callbacks for VM_INIT event\n"); @@ -191,7 +191,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks)))) { nsk_jvmti_setFailStatus(); } else { - nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, eventsList, NULL); + nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, eventsList, nullptr); } } return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEventCallbacks/setevntcallb002/setevntcallb002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEventCallbacks/setevntcallb002/setevntcallb002.cpp index 65f8a2fd3f4..44535b30c11 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEventCallbacks/setevntcallb002/setevntcallb002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEventCallbacks/setevntcallb002/setevntcallb002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ static int checkEventCounts() { for (i = 1; i < EVENTS_COUNT; i++) { if (eventsCountList[i] > 0) { - NSK_COMPLAIN2("# %s event callback was invoked after SetEventCallbacks(NULL):\n" + NSK_COMPLAIN2("# %s event callback was invoked after SetEventCallbacks(null):\n" "# invoked: %d times\n", eventsNameList[i], eventsCountList[i]); success = NSK_FALSE; @@ -108,7 +108,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { } NSK_DISPLAY0("Disable events\n"); - nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, eventsList, NULL); + nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, eventsList, nullptr); NSK_DISPLAY0("Let debugee to finish\n"); if (!nsk_jvmti_resumeSync()) @@ -143,13 +143,13 @@ callbackVMInit(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { NSK_DISPLAY1(" : thread: 0x%p\n", (void*)thread); eventsCountList[0]++; - NSK_DISPLAY0(">>> Testcase #2: Set NULL for events callbacks\n"); + NSK_DISPLAY0(">>> Testcase #2: Set null for events callbacks\n"); { - if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(NULL, 0))) { + if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(nullptr, 0))) { nsk_jvmti_setFailStatus(); } - nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT - 1, eventsList + 1, NULL); + nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT - 1, eventsList + 1, nullptr); } } @@ -168,7 +168,7 @@ JNIEXPORT jint JNI_OnLoad_setevntcallb002(JavaVM *jvm, char *options, void *rese } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -176,10 +176,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; NSK_DISPLAY0(">>> Testcase #1: Set callbacks for all tested events\n"); @@ -195,7 +195,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks)))) { nsk_jvmti_setFailStatus(); } else { - nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, eventsList, NULL); + nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, eventsList, nullptr); } } return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEventCallbacks/setevntcallb003/setevntcallb003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEventCallbacks/setevntcallb003/setevntcallb003.cpp index 72511c6776d..2b4d9aa05c5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEventCallbacks/setevntcallb003/setevntcallb003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEventCallbacks/setevntcallb003/setevntcallb003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,7 +108,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { } NSK_DISPLAY0("Disable events\n"); - nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, eventsList, NULL); + nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, eventsList, nullptr); NSK_DISPLAY0("Let debugee to finish\n"); if (!nsk_jvmti_resumeSync()) @@ -155,7 +155,7 @@ callbackVMInit(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { nsk_jvmti_setFailStatus(); } - nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT - 1, eventsList + 1, NULL); + nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT - 1, eventsList + 1, nullptr); } } @@ -174,7 +174,7 @@ JNIEXPORT jint JNI_OnLoad_setevntcallb003(JavaVM *jvm, char *options, void *rese } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -182,10 +182,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; NSK_DISPLAY0(">>> Testcase #1: Set callbacks for all tested events\n"); @@ -199,7 +199,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks)))) { nsk_jvmti_setFailStatus(); } else { - nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, eventsList, NULL); + nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, eventsList, nullptr); } } return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEventNotificationMode/setnotif001/setnotif001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEventNotificationMode/setnotif001/setnotif001.cpp index 135f51a86f9..bd2c5ab397e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEventNotificationMode/setnotif001/setnotif001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEventNotificationMode/setnotif001/setnotif001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,11 +34,11 @@ extern "C" { #define STATUS_FAILED 2 #define SCALE_SIZE (JVMTI_MAX_EVENT_TYPE_VAL + 1) -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; static jrawMonitorID access_lock; -static jobject notifyFramePopThread = NULL; +static jobject notifyFramePopThread = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; static int flag = 0; @@ -78,7 +78,7 @@ void disable(jvmtiEnv *jvmti_env, jvmtiEvent kind) { printf(">>> disabling %s\n", TranslateEvent(kind)); } err = jvmti_env->SetEventNotificationMode( - JVMTI_DISABLE, kind, NULL); + JVMTI_DISABLE, kind, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Fail to disable %s: %s (%d)\n", TranslateEvent(kind), TranslateError(err), err); @@ -99,7 +99,7 @@ void enable(jvmtiEnv *jvmti_env, jvmtiEvent kind) { result = STATUS_FAILED; } err = jvmti_env->SetEventNotificationMode( - JVMTI_ENABLE, kind, NULL); + JVMTI_ENABLE, kind, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Fail to enable %s: %s (%d)\n", TranslateEvent(kind), TranslateError(err), err); @@ -121,8 +121,8 @@ void setWatches(jvmtiEnv *jvmti_env, JNIEnv *env, jclass cls) { jmethodID mid; mid = env->GetStaticMethodID(cls, "meth01", "(I)V"); - if (mid == NULL) { - printf("(GetStaticMethodID) returns NULL"); + if (mid == nullptr) { + printf("(GetStaticMethodID) returns null"); result = STATUS_FAILED; return; } @@ -309,7 +309,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } @@ -317,7 +317,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { memset(ev_scale, 0, SCALE_SIZE); res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetExtensionEventCallback/setextevent001/setextevent001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetExtensionEventCallback/setextevent001/setextevent001.cpp index 9088e6047f2..fc32a11a0ad 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetExtensionEventCallback/setextevent001/setextevent001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetExtensionEventCallback/setextevent001/setextevent001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ callbackExtensionEvent(jvmtiEnv* jvmti, ...) { static int checkExtensions(jvmtiEnv* jvmti, const char phase[]) { int success = NSK_TRUE; jint extCount = 0; - jvmtiExtensionEventInfo* extList = NULL; + jvmtiExtensionEventInfo* extList = nullptr; int i; NSK_DISPLAY0("Get extension events list\n"); @@ -58,7 +58,7 @@ static int checkExtensions(jvmtiEnv* jvmti, const char phase[]) { NSK_DISPLAY1("# WARNING: No extension events implemented to check: %d\n", extCount); } else { - if (!NSK_VERIFY(extList != NULL)) + if (!NSK_VERIFY(extList != nullptr)) return NSK_FALSE; NSK_DISPLAY1("Set/clear callback for each extension event: %d events\n", (int)extCount); @@ -76,9 +76,9 @@ static int checkExtensions(jvmtiEnv* jvmti, const char phase[]) { } NSK_DISPLAY0(" ... done\n"); - NSK_DISPLAY1(" ... clearing callback: 0x%p\n", (void*)NULL); + NSK_DISPLAY1(" ... clearing callback: 0x%p\n", nullptr); if (!NSK_JVMTI_VERIFY( - jvmti->SetExtensionEventCallback(extList[i].extension_event_index, NULL))) { + jvmti->SetExtensionEventCallback(extList[i].extension_event_index, nullptr))) { success = NSK_FALSE; } NSK_DISPLAY0(" ... done\n"); @@ -130,7 +130,7 @@ JNIEXPORT jint JNI_OnLoad_setextevent001(JavaVM *jvm, char *options, void *reser } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -138,7 +138,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; NSK_DISPLAY0(">>> Testcase #1: Check setting extension event callbacks in OnLoad phase\n"); @@ -148,7 +148,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw001/setfldw001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw001/setfldw001.cpp index ddd5ed6e82c..e28cffa3bc0 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw001/setfldw001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw001/setfldw001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -48,12 +48,12 @@ static jvmtiEventCallbacks callbacks; static jvmtiCapabilities caps; static jint result = PASSED; static field fields[] = { - { "nsk/jvmti/SetFieldAccessWatch/setfldw001", "fld0", "I", 0, NULL, NULL }, - { "nsk/jvmti/SetFieldAccessWatch/setfldw001", "fld1", "I", 1, NULL, NULL }, + { "nsk/jvmti/SetFieldAccessWatch/setfldw001", "fld0", "I", 0, nullptr, nullptr }, + { "nsk/jvmti/SetFieldAccessWatch/setfldw001", "fld1", "I", 1, nullptr, nullptr }, { "nsk/jvmti/SetFieldAccessWatch/setfldw001", "fld2", - "Lnsk/jvmti/SetFieldAccessWatch/setfldw001a;", 0, NULL, NULL }, - { "nsk/jvmti/SetFieldAccessWatch/setfldw001a", "fld3", "[I", 0, NULL, NULL }, - { "nsk/jvmti/SetFieldAccessWatch/setfldw001b", "fld4", "F", 0, NULL, NULL }, + "Lnsk/jvmti/SetFieldAccessWatch/setfldw001a;", 0, nullptr, nullptr }, + { "nsk/jvmti/SetFieldAccessWatch/setfldw001a", "fld3", "[I", 0, nullptr, nullptr }, + { "nsk/jvmti/SetFieldAccessWatch/setfldw001b", "fld4", "F", 0, nullptr, nullptr }, }; void setWatch(JNIEnv *env, jint ind) { @@ -62,12 +62,12 @@ void setWatch(JNIEnv *env, jint ind) { field fld = fields[ind]; cls = env->FindClass(fld.klass); - if (cls == NULL) { + if (cls == nullptr) { printf("Cannot find class \"%s\"\n", fld.klass); result = STATUS_FAILED; return; } - if (fld.fid == NULL) { + if (fld.fid == nullptr) { if (fld.stat) { fields[ind].fid = env->GetStaticFieldID(cls, fld.name, fld.sig); } else { @@ -90,18 +90,18 @@ void JNICALL FieldAccess(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thr, jmethodID method, jlocation location, jclass field_klass, jobject obj, jfieldID field) { - char *fld_name = NULL; + char *fld_name = nullptr; jint fld_ind = 0; size_t len = 0; jvmtiError err = jvmti_env->GetFieldName(field_klass, field, - &fld_name, NULL, NULL); + &fld_name, nullptr, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Error in GetFieldName: %s (%d)\n", TranslateError(err), err); result = STATUS_FAILED; return; } - if (fld_name == NULL) { - printf("GetFieldName returned NULL field name\n"); + if (fld_name == nullptr) { + printf("GetFieldName returned null field name\n"); result = STATUS_FAILED; return; } @@ -133,7 +133,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } @@ -169,7 +169,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_FIELD_ACCESS, NULL); + JVMTI_EVENT_FIELD_ACCESS, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable JVMTI_EVENT_FIELD_ACCESS: %s (%d)\n", TranslateError(err), err); @@ -203,7 +203,7 @@ Java_nsk_jvmti_SetFieldAccessWatch_setfldw001_check(JNIEnv *env, jfieldID thrown_fid = fields[fld_ind].thrown_fid; if (caps.can_generate_field_access_events) { - if (flag == JNI_FALSE && thrown_fid != NULL) { + if (flag == JNI_FALSE && thrown_fid != nullptr) { result = STATUS_FAILED; printf("(Field %d) FIELD_ACCESS event without access watch set\n", fld_ind); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw002/setfldw002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw002/setfldw002.cpp index 11161cffd8a..db4b0c401e3 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw002/setfldw002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw002/setfldw002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -59,7 +59,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } @@ -95,7 +95,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_FIELD_ACCESS, NULL); + JVMTI_EVENT_FIELD_ACCESS, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable JVMTI_EVENT_FIELD_ACCESS: %s (%d)\n", TranslateError(err), err); @@ -123,14 +123,14 @@ Java_nsk_jvmti_SetFieldAccessWatch_setfldw002_check(JNIEnv *env, jclass cls) { printf(" %s (%d)\n", TranslateError(err), err); } } else { - err = jvmti->SetFieldAccessWatch(NULL, fid); + err = jvmti->SetFieldAccessWatch(nullptr, fid); if (err != JVMTI_ERROR_INVALID_CLASS) { result = STATUS_FAILED; printf("Failed to return JVMTI_ERROR_INVALID_CLASS: %s (%d)\n", TranslateError(err), err); } - err = jvmti->SetFieldAccessWatch(cls, NULL); + err = jvmti->SetFieldAccessWatch(cls, nullptr); if (err != JVMTI_ERROR_INVALID_FIELDID) { result = STATUS_FAILED; printf("Failed to return JVMTI_ERROR_INVALID_FIELDID: %s (%d)\n", diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw003/setfldw003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw003/setfldw003.cpp index 303888a53cc..058cc381622 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw003/setfldw003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw003/setfldw003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,8 +39,8 @@ static jvmtiEventCallbacks callbacks; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; -static jfieldID actual_fid = NULL; -static jfieldID fids[4] = { NULL, NULL, NULL, NULL }; +static jfieldID actual_fid = nullptr; +static jfieldID fids[4] = { nullptr, nullptr, nullptr, nullptr }; void JNICALL FieldAccess(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thr, jmethodID method, @@ -66,12 +66,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } @@ -126,7 +126,7 @@ Java_nsk_jvmti_SetFieldAccessWatch_setfldw003_getReady(JNIEnv *env, jclass cls) fids[2] = env->GetFieldID(cls, "fld2", "I"); fids[3] = env->GetFieldID(cls, "fld3", "I"); for (i = 0; i < sizeof(fids) / sizeof(jfieldID); i++) { - if (fids[i] == NULL) { + if (fids[i] == nullptr) { printf("Unable to set field access watch on fld%" PRIuPTR ", fieldID=0", i); } else { if (printdump == JNI_TRUE) { @@ -142,7 +142,7 @@ Java_nsk_jvmti_SetFieldAccessWatch_setfldw003_getReady(JNIEnv *env, jclass cls) } } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_FIELD_ACCESS, NULL); + JVMTI_EVENT_FIELD_ACCESS, nullptr); if (err != JVMTI_ERROR_NONE) { printf("(SetEventNotificationMode) unexpected error: %s (%d)\n", TranslateError(err), err); @@ -161,7 +161,7 @@ Java_nsk_jvmti_SetFieldAccessWatch_setfldw003_check(JNIEnv *env, printf("Field fld%d: thrown field ID expected=0x%p, actual=0x%p\n", ind, fids[ind], actual_fid); } - actual_fid = NULL; + actual_fid = nullptr; } JNIEXPORT jint JNICALL diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw004/setfldw004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw004/setfldw004.cpp index a09bc425576..7474fd97c1a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw004/setfldw004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw004/setfldw004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,8 +39,8 @@ static jvmtiEventCallbacks callbacks; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; -static jfieldID actual_fid = NULL; -static jfieldID fids[4] = { NULL, NULL, NULL, NULL }; +static jfieldID actual_fid = nullptr; +static jfieldID fids[4] = { nullptr, nullptr, nullptr, nullptr }; void JNICALL FieldAccess(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thr, jmethodID method, @@ -66,12 +66,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } @@ -133,7 +133,7 @@ Java_nsk_jvmti_SetFieldAccessWatch_setfldw004_getReady(JNIEnv *env, jclass cls) fids[2] = env->GetFieldID(cls, "fld2", "I"); fids[3] = env->GetFieldID(cls, "fld3", "I"); for (i = 0; i < sizeof(fids) / sizeof(jfieldID); i++) { - if (fids[i] == NULL) { + if (fids[i] == nullptr) { printf("Unable to set field access watch on fld%" PRIuPTR ", fieldID=0", i); } else { if (printdump == JNI_TRUE) { @@ -149,7 +149,7 @@ Java_nsk_jvmti_SetFieldAccessWatch_setfldw004_getReady(JNIEnv *env, jclass cls) } } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_FIELD_ACCESS, NULL); + JVMTI_EVENT_FIELD_ACCESS, nullptr); if (err != JVMTI_ERROR_NONE) { printf("(SetEventNotificationMode) unexpected error: %s (%d)\n", TranslateError(err), err); @@ -168,7 +168,7 @@ Java_nsk_jvmti_SetFieldAccessWatch_setfldw004_check(JNIEnv *env, printf("Field %d: thrown field ID expected=0x%p, actual=0x%p\n", ind, fids[ind], actual_fid); } - actual_fid = NULL; + actual_fid = nullptr; } JNIEXPORT jint JNICALL diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw005/setfldw005.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw005/setfldw005.cpp index bc7daad4c70..910cc4ec9dd 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw005/setfldw005.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw005/setfldw005.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,24 +47,24 @@ static jvmtiEventCallbacks callbacks; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; -static jfieldID actual_fid = NULL; +static jfieldID actual_fid = nullptr; static field fields[] = { - { "fld0", "J", JNI_TRUE, NULL, "static long" }, - { "fld1", "J", JNI_FALSE, NULL, "long" }, - { "fld2", "F", JNI_TRUE, NULL, "static float" }, - { "fld3", "F", JNI_FALSE, NULL, "float" }, - { "fld4", "D", JNI_TRUE, NULL, "static double" }, - { "fld5", "D", JNI_FALSE, NULL, "double" }, - { "fld6", "Ljava/lang/Object;", JNI_TRUE, NULL, "static Object" }, - { "fld7", "Ljava/lang/Object;", JNI_FALSE, NULL, "Object" }, - { "fld8", "Z", JNI_TRUE, NULL, "static boolean" }, - { "fld9", "Z", JNI_FALSE, NULL, "boolean" }, - { "fld10", "B", JNI_TRUE, NULL, "static byte" }, - { "fld11", "B", JNI_FALSE, NULL, "byte" }, - { "fld12", "S", JNI_TRUE, NULL, "static short" }, - { "fld13", "S", JNI_FALSE, NULL, "short" }, - { "fld14", "C", JNI_TRUE, NULL, "static char" }, - { "fld15", "C", JNI_FALSE, NULL, "char" } + { "fld0", "J", JNI_TRUE, nullptr, "static long" }, + { "fld1", "J", JNI_FALSE, nullptr, "long" }, + { "fld2", "F", JNI_TRUE, nullptr, "static float" }, + { "fld3", "F", JNI_FALSE, nullptr, "float" }, + { "fld4", "D", JNI_TRUE, nullptr, "static double" }, + { "fld5", "D", JNI_FALSE, nullptr, "double" }, + { "fld6", "Ljava/lang/Object;", JNI_TRUE, nullptr, "static Object" }, + { "fld7", "Ljava/lang/Object;", JNI_FALSE, nullptr, "Object" }, + { "fld8", "Z", JNI_TRUE, nullptr, "static boolean" }, + { "fld9", "Z", JNI_FALSE, nullptr, "boolean" }, + { "fld10", "B", JNI_TRUE, nullptr, "static byte" }, + { "fld11", "B", JNI_FALSE, nullptr, "byte" }, + { "fld12", "S", JNI_TRUE, nullptr, "static short" }, + { "fld13", "S", JNI_FALSE, nullptr, "short" }, + { "fld14", "C", JNI_TRUE, nullptr, "static char" }, + { "fld15", "C", JNI_FALSE, nullptr, "char" } }; void JNICALL FieldAccess(jvmtiEnv *jvmti_env, JNIEnv *env, @@ -91,12 +91,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } @@ -159,7 +159,7 @@ Java_nsk_jvmti_SetFieldAccessWatch_setfldw005_getReady(JNIEnv *env, jclass cls) } else { fields[i].fid = env->GetFieldID(cls, fields[i].name, fields[i].sig); } - if (fields[i].fid == NULL) { + if (fields[i].fid == nullptr) { printf("Unable to set access watch on %s fld%" PRIuPTR ", fieldID=0", fields[i].descr, i); } else { @@ -176,7 +176,7 @@ Java_nsk_jvmti_SetFieldAccessWatch_setfldw005_getReady(JNIEnv *env, jclass cls) } } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_FIELD_ACCESS, NULL); + JVMTI_EVENT_FIELD_ACCESS, nullptr); if (err != JVMTI_ERROR_NONE) { printf("(SetEventNotificationMode) unexpected error: %s (%d)\n", TranslateError(err), err); @@ -195,7 +195,7 @@ Java_nsk_jvmti_SetFieldAccessWatch_setfldw005_check(JNIEnv *env, printf("Field %s fld%d: thrown field ID expected=0x%p, actual=0x%p\n", fields[ind].descr, ind, fields[ind].fid, actual_fid); } - actual_fid = NULL; + actual_fid = nullptr; } JNIEXPORT jint JNICALL diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw006/setfldw006.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw006/setfldw006.cpp index c70c9176a97..ac838cd5c5a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw006/setfldw006.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw006/setfldw006.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,34 +43,34 @@ typedef struct { jint count; } watch_info; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; static int missesCount = 0; static watch_info watches[] = { - { NULL, "staticBoolean", "Z", JNI_TRUE, 0, 0 }, - { NULL, "staticByte", "B", JNI_TRUE, 0, 0 }, - { NULL, "staticShort", "S", JNI_TRUE, 0, 0 }, - { NULL, "staticInt", "I", JNI_TRUE, 0, 0 }, - { NULL, "staticLong", "J", JNI_TRUE, 0, 0 }, - { NULL, "staticFloat", "F", JNI_TRUE, 0, 0 }, - { NULL, "staticDouble", "D", JNI_TRUE, 0, 0 }, - { NULL, "staticChar", "C", JNI_TRUE, 0, 0 }, - { NULL, "staticObject", "Ljava/lang/Object;", JNI_TRUE, 0, 0 }, - { NULL, "staticArrInt", "[I", JNI_TRUE, 0, 0 }, - - { NULL, "instanceBoolean", "Z", JNI_FALSE, 0, 0 }, - { NULL, "instanceByte", "B", JNI_FALSE, 0, 0 }, - { NULL, "instanceShort", "S", JNI_FALSE, 0, 0 }, - { NULL, "instanceInt", "I", JNI_FALSE, 0, 0 }, - { NULL, "instanceLong", "J", JNI_FALSE, 0, 0 }, - { NULL, "instanceFloat", "F", JNI_FALSE, 0, 0 }, - { NULL, "instanceDouble", "D", JNI_FALSE, 0, 0 }, - { NULL, "instanceChar", "C", JNI_FALSE, 0, 0 }, - { NULL, "instanceObject", "Ljava/lang/Object;", JNI_FALSE, 0, 0 }, - { NULL, "instanceArrInt", "[I", JNI_FALSE, 0, 0 } + { nullptr, "staticBoolean", "Z", JNI_TRUE, 0, 0 }, + { nullptr, "staticByte", "B", JNI_TRUE, 0, 0 }, + { nullptr, "staticShort", "S", JNI_TRUE, 0, 0 }, + { nullptr, "staticInt", "I", JNI_TRUE, 0, 0 }, + { nullptr, "staticLong", "J", JNI_TRUE, 0, 0 }, + { nullptr, "staticFloat", "F", JNI_TRUE, 0, 0 }, + { nullptr, "staticDouble", "D", JNI_TRUE, 0, 0 }, + { nullptr, "staticChar", "C", JNI_TRUE, 0, 0 }, + { nullptr, "staticObject", "Ljava/lang/Object;", JNI_TRUE, 0, 0 }, + { nullptr, "staticArrInt", "[I", JNI_TRUE, 0, 0 }, + + { nullptr, "instanceBoolean", "Z", JNI_FALSE, 0, 0 }, + { nullptr, "instanceByte", "B", JNI_FALSE, 0, 0 }, + { nullptr, "instanceShort", "S", JNI_FALSE, 0, 0 }, + { nullptr, "instanceInt", "I", JNI_FALSE, 0, 0 }, + { nullptr, "instanceLong", "J", JNI_FALSE, 0, 0 }, + { nullptr, "instanceFloat", "F", JNI_FALSE, 0, 0 }, + { nullptr, "instanceDouble", "D", JNI_FALSE, 0, 0 }, + { nullptr, "instanceChar", "C", JNI_FALSE, 0, 0 }, + { nullptr, "instanceObject", "Ljava/lang/Object;", JNI_FALSE, 0, 0 }, + { nullptr, "instanceArrInt", "[I", JNI_FALSE, 0, 0 } }; @@ -103,12 +103,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -162,7 +162,7 @@ Java_nsk_jvmti_SetFieldAccessWatch_setfldw006_getReady(JNIEnv *env, jvmtiError err; size_t i; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; @@ -191,7 +191,7 @@ Java_nsk_jvmti_SetFieldAccessWatch_setfldw006_getReady(JNIEnv *env, } } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_FIELD_ACCESS, NULL); + JVMTI_EVENT_FIELD_ACCESS, nullptr); if (err != JVMTI_ERROR_NONE) { printf("(SetEventNotificationMode) unexpected error: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw001/setfmodw001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw001/setfmodw001.cpp index c7ec0e65035..42317001d0c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw001/setfmodw001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw001/setfmodw001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -48,12 +48,12 @@ static jvmtiEventCallbacks callbacks; static jvmtiCapabilities caps; static jint result = PASSED; static field fields[] = { - { "nsk/jvmti/SetFieldModificationWatch/setfmodw001", "fld0", "I", 0, NULL, NULL }, - { "nsk/jvmti/SetFieldModificationWatch/setfmodw001", "fld1", "I", 1, NULL, NULL }, + { "nsk/jvmti/SetFieldModificationWatch/setfmodw001", "fld0", "I", 0, nullptr, nullptr }, + { "nsk/jvmti/SetFieldModificationWatch/setfmodw001", "fld1", "I", 1, nullptr, nullptr }, { "nsk/jvmti/SetFieldModificationWatch/setfmodw001", "fld2", - "Lnsk/jvmti/SetFieldModificationWatch/setfmodw001a;", 0, NULL, NULL }, - { "nsk/jvmti/SetFieldModificationWatch/setfmodw001a", "fld3", "[I", 0, NULL, NULL }, - { "nsk/jvmti/SetFieldModificationWatch/setfmodw001b", "fld4", "F", 0, NULL, NULL }, + "Lnsk/jvmti/SetFieldModificationWatch/setfmodw001a;", 0, nullptr, nullptr }, + { "nsk/jvmti/SetFieldModificationWatch/setfmodw001a", "fld3", "[I", 0, nullptr, nullptr }, + { "nsk/jvmti/SetFieldModificationWatch/setfmodw001b", "fld4", "F", 0, nullptr, nullptr }, }; void setWatch(JNIEnv *env, jint ind) { @@ -61,7 +61,7 @@ void setWatch(JNIEnv *env, jint ind) { jvmtiError err; cls = env->FindClass(fields[ind].klass); - if (fields[ind].fid == NULL) { + if (fields[ind].fid == nullptr) { if (fields[ind].stat) { fields[ind].fid = env->GetStaticFieldID(cls, fields[ind].name, fields[ind].sig); } else { @@ -84,18 +84,18 @@ void JNICALL FieldModification(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thr, jmethodID method, jlocation location, jclass field_klass, jobject obj, jfieldID field, char sig, jvalue new_value) { - char *fld_name = NULL; + char *fld_name = nullptr; jint fld_ind = 0; size_t len = 0; jvmtiError err = jvmti_env->GetFieldName(field_klass, field, - &fld_name, NULL, NULL); + &fld_name, nullptr, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Error in GetFieldName: %s (%d)\n", TranslateError(err), err); result = STATUS_FAILED; return; } - if (fld_name == NULL) { - printf("GetFieldName returned NULL field name\n"); + if (fld_name == nullptr) { + printf("GetFieldName returned null field name\n"); result = STATUS_FAILED; return; } @@ -127,7 +127,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } @@ -163,7 +163,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_FIELD_MODIFICATION, NULL); + JVMTI_EVENT_FIELD_MODIFICATION, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable JVMTI_EVENT_FIELD_MODIFICATION: %s (%d)\n", TranslateError(err), err); @@ -195,7 +195,7 @@ Java_nsk_jvmti_SetFieldModificationWatch_setfmodw001_check(JNIEnv *env, jfieldID thrown_fid = fields[fld_ind].thrown_fid; if (caps.can_generate_field_modification_events) { - if (flag == JNI_FALSE && thrown_fid != NULL) { + if (flag == JNI_FALSE && thrown_fid != nullptr) { result = STATUS_FAILED; printf("(Field %d) FieldModification without modification watch set\n", fld_ind); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw002/setfmodw002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw002/setfmodw002.cpp index 3f33f677991..230d02d14f1 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw002/setfmodw002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw002/setfmodw002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -59,7 +59,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } @@ -95,7 +95,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_FIELD_MODIFICATION, NULL); + JVMTI_EVENT_FIELD_MODIFICATION, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable JVMTI_EVENT_FIELD_MODIFICATION: %s (%d)\n", TranslateError(err), err); @@ -115,8 +115,8 @@ Java_nsk_jvmti_SetFieldModificationWatch_setfmodw002_check(JNIEnv *env, jfieldID fid; fid = env->GetStaticFieldID(cls, "fld1", "I"); - if (fid == NULL) { - printf("(GetStaticFieldID) returns NULL"); + if (fid == nullptr) { + printf("(GetStaticFieldID) returns null"); result = STATUS_FAILED; return result; } @@ -129,14 +129,14 @@ Java_nsk_jvmti_SetFieldModificationWatch_setfmodw002_check(JNIEnv *env, printf(" %s (%d)\n", TranslateError(err), err); } } else { - err = jvmti->SetFieldModificationWatch(NULL, fid); + err = jvmti->SetFieldModificationWatch(nullptr, fid); if (err != JVMTI_ERROR_INVALID_CLASS) { result = STATUS_FAILED; printf("Failed to return JVMTI_ERROR_INVALID_CLASS: %s (%d)\n", TranslateError(err), err); } - err = jvmti->SetFieldModificationWatch(cls, NULL); + err = jvmti->SetFieldModificationWatch(cls, nullptr); if (err != JVMTI_ERROR_INVALID_FIELDID) { result = STATUS_FAILED; printf("Failed to return JVMTI_ERROR_INVALID_FIELDID: %s (%d)\n", diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw003/setfmodw003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw003/setfmodw003.cpp index 987fb90913a..c105b647d32 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw003/setfmodw003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw003/setfmodw003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,14 +47,14 @@ static jvmtiEventCallbacks callbacks; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; -static jfieldID actual_fid = NULL; +static jfieldID actual_fid = nullptr; static char actual_sig = '\0'; static jint actual_val = 0; static field flds[] = { - { "fld0", 'I', JNI_TRUE, 42, NULL }, - { "fld1", 'I', JNI_TRUE, 43, NULL }, - { "fld2", 'I', JNI_FALSE, 44, NULL }, - { "fld3", 'I', JNI_FALSE, 45, NULL } + { "fld0", 'I', JNI_TRUE, 42, nullptr }, + { "fld1", 'I', JNI_TRUE, 43, nullptr }, + { "fld2", 'I', JNI_FALSE, 44, nullptr }, + { "fld3", 'I', JNI_FALSE, 45, nullptr } }; void JNICALL FieldModification(jvmtiEnv *jvmti_env, JNIEnv *env, @@ -84,12 +84,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } @@ -146,7 +146,7 @@ Java_nsk_jvmti_SetFieldModificationWatch_setfmodw003_getReady(JNIEnv *env, } else { flds[i].fid = env->GetFieldID(cls, flds[i].name, "I"); } - if (flds[i].fid == NULL) { + if (flds[i].fid == nullptr) { printf("Unable to set field modif. watch on fld%" PRIuPTR ", fieldID=0", i); } else { if (printdump == JNI_TRUE) { @@ -162,7 +162,7 @@ Java_nsk_jvmti_SetFieldModificationWatch_setfmodw003_getReady(JNIEnv *env, } } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_FIELD_MODIFICATION, NULL); + JVMTI_EVENT_FIELD_MODIFICATION, nullptr); if (err != JVMTI_ERROR_NONE) { printf("(SetEventNotificationMode) unexpected error: %s (%d)\n", TranslateError(err), err); @@ -195,7 +195,7 @@ Java_nsk_jvmti_SetFieldModificationWatch_setfmodw003_check(JNIEnv *env, printf("Field %s: thrown new value expected=%d, actual=%d\n", flds[ind].name, flds[ind].val, actual_val); } - actual_fid = NULL; + actual_fid = nullptr; actual_sig = '\0'; actual_val = 0; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw004/setfmodw004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw004/setfmodw004.cpp index 403e2c1eda8..54759a984df 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw004/setfmodw004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw004/setfmodw004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,14 +47,14 @@ static jvmtiEventCallbacks callbacks; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; -static jfieldID actual_fid = NULL; +static jfieldID actual_fid = nullptr; static char actual_sig = '\0'; static jint actual_val = 0; static field flds[] = { - { "fld0", 'I', JNI_TRUE, 96, NULL }, - { "fld1", 'I', JNI_TRUE, 97, NULL }, - { "fld2", 'I', JNI_FALSE, 98, NULL }, - { "fld3", 'I', JNI_FALSE, 99, NULL } + { "fld0", 'I', JNI_TRUE, 96, nullptr }, + { "fld1", 'I', JNI_TRUE, 97, nullptr }, + { "fld2", 'I', JNI_FALSE, 98, nullptr }, + { "fld3", 'I', JNI_FALSE, 99, nullptr } }; void JNICALL FieldModification(jvmtiEnv *jvmti_env, JNIEnv *env, @@ -84,12 +84,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } @@ -144,7 +144,7 @@ JNIEXPORT void JNICALL Java_nsk_jvmti_SetFieldModificationWatch_setfmodw004_getR } else { flds[i].fid = env->GetFieldID(cls, flds[i].name, "I"); } - if (flds[i].fid == NULL) { + if (flds[i].fid == nullptr) { printf("Unable to set field modif. watch on fld%" PRIuPTR ", fieldID=0", i); } else { if (printdump == JNI_TRUE) { @@ -160,7 +160,7 @@ JNIEXPORT void JNICALL Java_nsk_jvmti_SetFieldModificationWatch_setfmodw004_getR } } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_FIELD_MODIFICATION, NULL); + JVMTI_EVENT_FIELD_MODIFICATION, nullptr); if (err != JVMTI_ERROR_NONE) { printf("(SetEventNotificationMode) unexpected error: %s (%d)\n", TranslateError(err), err); @@ -193,7 +193,7 @@ Java_nsk_jvmti_SetFieldModificationWatch_setfmodw004_check(JNIEnv *env, printf("Field %s: thrown new value expected=%d, actual=%d\n", flds[ind].name, flds[ind].val, actual_val); } - actual_fid = NULL; + actual_fid = nullptr; actual_sig = '\0'; actual_val = 0; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw005/setfmodw005.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw005/setfmodw005.cpp index 42e22ede75a..34cfdf628b4 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw005/setfmodw005.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw005/setfmodw005.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -48,26 +48,26 @@ static jvmtiEventCallbacks callbacks; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; -static jfieldID actual_fid = NULL; +static jfieldID actual_fid = nullptr; static char actual_sig = '\0'; static jvalue actual_val = {}; static field flds[] = { - { "fld0", "J", JNI_TRUE, "static long", NULL, {} }, - { "fld1", "J", JNI_FALSE, "long", NULL, {} }, - { "fld2", "F", JNI_TRUE, "static float", NULL, {} }, - { "fld3", "F", JNI_FALSE, "float", NULL, {} }, - { "fld4", "D", JNI_TRUE, "static double", NULL, {} }, - { "fld5", "D", JNI_FALSE, "double", NULL, {} }, - { "fld6", "Ljava/lang/Object;", JNI_TRUE, "static Object", NULL, {} }, - { "fld7", "Ljava/lang/Object;", JNI_FALSE, "Object", NULL, {} }, - { "fld8", "Z", JNI_TRUE, "static boolean", NULL, {} }, - { "fld9", "Z", JNI_FALSE, "boolean", NULL, {} }, - { "fld10", "B", JNI_TRUE, "static byte", NULL, {} }, - { "fld11", "B", JNI_FALSE, "byte", NULL, {} }, - { "fld12", "S", JNI_TRUE, "static short", NULL, {} }, - { "fld13", "S", JNI_FALSE, "short", NULL, {} }, - { "fld14", "C", JNI_TRUE, "static char", NULL, {} }, - { "fld15", "C", JNI_FALSE, "char", NULL, {} } + { "fld0", "J", JNI_TRUE, "static long", nullptr, {} }, + { "fld1", "J", JNI_FALSE, "long", nullptr, {} }, + { "fld2", "F", JNI_TRUE, "static float", nullptr, {} }, + { "fld3", "F", JNI_FALSE, "float", nullptr, {} }, + { "fld4", "D", JNI_TRUE, "static double", nullptr, {} }, + { "fld5", "D", JNI_FALSE, "double", nullptr, {} }, + { "fld6", "Ljava/lang/Object;", JNI_TRUE, "static Object", nullptr, {} }, + { "fld7", "Ljava/lang/Object;", JNI_FALSE, "Object", nullptr, {} }, + { "fld8", "Z", JNI_TRUE, "static boolean", nullptr, {} }, + { "fld9", "Z", JNI_FALSE, "boolean", nullptr, {} }, + { "fld10", "B", JNI_TRUE, "static byte", nullptr, {} }, + { "fld11", "B", JNI_FALSE, "byte", nullptr, {} }, + { "fld12", "S", JNI_TRUE, "static short", nullptr, {} }, + { "fld13", "S", JNI_FALSE, "short", nullptr, {} }, + { "fld14", "C", JNI_TRUE, "static char", nullptr, {} }, + { "fld15", "C", JNI_FALSE, "char", nullptr, {} } }; void JNICALL FieldModification(jvmtiEnv *jvmti_env, JNIEnv *env, @@ -133,12 +133,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } @@ -216,7 +216,7 @@ Java_nsk_jvmti_SetFieldModificationWatch_setfmodw005_getReady(JNIEnv *env, } else { flds[i].fid = env->GetFieldID(cls, flds[i].name, flds[i].sig); } - if (flds[i].fid == NULL) { + if (flds[i].fid == nullptr) { printf("Unable to set modification watch on %s fld%" PRIuPTR ", fieldID=0", flds[i].descr, i); } else { @@ -233,7 +233,7 @@ Java_nsk_jvmti_SetFieldModificationWatch_setfmodw005_getReady(JNIEnv *env, } } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_FIELD_MODIFICATION, NULL); + JVMTI_EVENT_FIELD_MODIFICATION, nullptr); if (err != JVMTI_ERROR_NONE) { printf("(SetEventNotificationMode) unexpected error: %s (%d)\n", TranslateError(err), err); @@ -366,7 +366,7 @@ Java_nsk_jvmti_SetFieldModificationWatch_setfmodw005_check(JNIEnv *env, default: break; } - actual_fid = NULL; + actual_fid = nullptr; actual_sig = '\0'; actual_val.j = 0L; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw006/setfmodw006.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw006/setfmodw006.cpp index da74e1a92ca..d4f78706563 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw006/setfmodw006.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw006/setfmodw006.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,34 +43,34 @@ typedef struct { jint count; } watch_info; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; static int missesCount = 0; static watch_info watches[] = { - { NULL, "staticBoolean", "Z", JNI_TRUE, 0, 0 }, - { NULL, "staticByte", "B", JNI_TRUE, 0, 0 }, - { NULL, "staticShort", "S", JNI_TRUE, 0, 0 }, - { NULL, "staticInt", "I", JNI_TRUE, 0, 0 }, - { NULL, "staticLong", "J", JNI_TRUE, 0, 0 }, - { NULL, "staticFloat", "F", JNI_TRUE, 0, 0 }, - { NULL, "staticDouble", "D", JNI_TRUE, 0, 0 }, - { NULL, "staticChar", "C", JNI_TRUE, 0, 0 }, - { NULL, "staticObject", "Ljava/lang/Object;", JNI_TRUE, 0, 0 }, - { NULL, "staticArrInt", "[I", JNI_TRUE, 0, 0 }, - - { NULL, "instanceBoolean", "Z", JNI_FALSE, 0, 0 }, - { NULL, "instanceByte", "B", JNI_FALSE, 0, 0 }, - { NULL, "instanceShort", "S", JNI_FALSE, 0, 0 }, - { NULL, "instanceInt", "I", JNI_FALSE, 0, 0 }, - { NULL, "instanceLong", "J", JNI_FALSE, 0, 0 }, - { NULL, "instanceFloat", "F", JNI_FALSE, 0, 0 }, - { NULL, "instanceDouble", "D", JNI_FALSE, 0, 0 }, - { NULL, "instanceChar", "C", JNI_FALSE, 0, 0 }, - { NULL, "instanceObject", "Ljava/lang/Object;", JNI_FALSE, 0, 0 }, - { NULL, "instanceArrInt", "[I", JNI_FALSE, 0, 0 } + { nullptr, "staticBoolean", "Z", JNI_TRUE, 0, 0 }, + { nullptr, "staticByte", "B", JNI_TRUE, 0, 0 }, + { nullptr, "staticShort", "S", JNI_TRUE, 0, 0 }, + { nullptr, "staticInt", "I", JNI_TRUE, 0, 0 }, + { nullptr, "staticLong", "J", JNI_TRUE, 0, 0 }, + { nullptr, "staticFloat", "F", JNI_TRUE, 0, 0 }, + { nullptr, "staticDouble", "D", JNI_TRUE, 0, 0 }, + { nullptr, "staticChar", "C", JNI_TRUE, 0, 0 }, + { nullptr, "staticObject", "Ljava/lang/Object;", JNI_TRUE, 0, 0 }, + { nullptr, "staticArrInt", "[I", JNI_TRUE, 0, 0 }, + + { nullptr, "instanceBoolean", "Z", JNI_FALSE, 0, 0 }, + { nullptr, "instanceByte", "B", JNI_FALSE, 0, 0 }, + { nullptr, "instanceShort", "S", JNI_FALSE, 0, 0 }, + { nullptr, "instanceInt", "I", JNI_FALSE, 0, 0 }, + { nullptr, "instanceLong", "J", JNI_FALSE, 0, 0 }, + { nullptr, "instanceFloat", "F", JNI_FALSE, 0, 0 }, + { nullptr, "instanceDouble", "D", JNI_FALSE, 0, 0 }, + { nullptr, "instanceChar", "C", JNI_FALSE, 0, 0 }, + { nullptr, "instanceObject", "Ljava/lang/Object;", JNI_FALSE, 0, 0 }, + { nullptr, "instanceArrInt", "[I", JNI_FALSE, 0, 0 } }; @@ -103,12 +103,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -155,7 +155,7 @@ Java_nsk_jvmti_SetFieldModificationWatch_setfmodw006_getReady(JNIEnv *env, jvmtiError err; size_t i; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; @@ -185,7 +185,7 @@ Java_nsk_jvmti_SetFieldModificationWatch_setfmodw006_getReady(JNIEnv *env, } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_FIELD_MODIFICATION, NULL); + JVMTI_EVENT_FIELD_MODIFICATION, nullptr); if (err != JVMTI_ERROR_NONE) { printf("(SetEventNotificationMode) unexpected error: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetJNIFunctionTable/setjniftab001/setjniftab001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetJNIFunctionTable/setjniftab001/setjniftab001.cpp index 2e6490e34f7..ebe28d895a5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetJNIFunctionTable/setjniftab001/setjniftab001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetJNIFunctionTable/setjniftab001/setjniftab001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,7 @@ static const char *classSig = "Lnsk/jvmti/SetJNIFunctionTable/setjniftab001a;"; static JavaVM *vm; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static volatile int verbose = 0; @@ -59,10 +59,10 @@ static volatile jobject clsObj; static jrawMonitorID countLock; /* the original JNI function table */ -static jniNativeInterface *orig_jni_functions = NULL; +static jniNativeInterface *orig_jni_functions = nullptr; /* the redirected JNI function table */ -static jniNativeInterface *redir_jni_functions = NULL; +static jniNativeInterface *redir_jni_functions = nullptr; /* number of the redirected JNI function calls */ static volatile int monent_calls = 0; @@ -278,7 +278,7 @@ void startThreads() { thrStarted[i] = 0; waitContElem[i] = i+1; waitThr[i] = THREAD_new(waitingThread, &waitContElem[i]); - if (THREAD_start(waitThr[i]) == NULL) { + if (THREAD_start(waitThr[i]) == nullptr) { printf("TEST FAILURE: cannot start waiting thread #%d\n", i+1); result = STATUS_FAILED; @@ -323,16 +323,16 @@ JNIEXPORT jint JNICALL Java_nsk_jvmti_SetJNIFunctionTable_setjniftab001_check(JNIEnv *env, jobject obj) { int exitCode = PASSED; jint res; - JNIEnv *nextEnv = NULL; /* JNI env used to verify the assertion */ + JNIEnv *nextEnv = nullptr; /* JNI env used to verify the assertion */ - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("(%s,%d): TEST FAILURE: JVMTI client was not properly loaded\n", __FILE__, __LINE__); return STATUS_FAILED; } clsObj = env->NewGlobalRef(getObjectFromField(env, obj)); - if (clsObj == NULL) { + if (clsObj == nullptr) { printf("(%s,%d): TEST FAILURE: cannot create a new global reference of class \"%s\"\n", __FILE__, __LINE__, classSig); env->FatalError("failed to create a new global reference"); @@ -382,10 +382,10 @@ Java_nsk_jvmti_SetJNIFunctionTable_setjniftab001_check(JNIEnv *env, jobject obj) and check the assertion with current thread and new threads */ if (verbose) printf("\nc) Checking the restored JNI function table ...\n"); - doRestore((nextEnv == NULL) ? env : nextEnv); + doRestore((nextEnv == nullptr) ? env : nextEnv); zeroCounter(); - doExec((nextEnv == NULL) ? env : nextEnv, 0); + doExec((nextEnv == nullptr) ? env : nextEnv, 0); checkCall(2, 0, "main thread"); zeroCounter(); @@ -413,14 +413,14 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "-verbose") == 0) + if (options != nullptr && strcmp(options, "-verbose") == 0) verbose = 1; if (verbose) printf("verbose mode on\n"); res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("(%s,%d): Failed to call GetEnv\n", __FILE__, __LINE__); return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetJNIFunctionTable/setjniftab002/setjniftab002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetJNIFunctionTable/setjniftab002/setjniftab002.cpp index 467c7abbb1f..4e3df55cbc8 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetJNIFunctionTable/setjniftab002/setjniftab002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetJNIFunctionTable/setjniftab002/setjniftab002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define STATUS_FAILED 2 static JavaVM *vm; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static int verbose = 0; static jint result = PASSED; @@ -45,7 +45,7 @@ void redirect(JNIEnv *env, jvmtiError exError) { printf("\ntrying to overwrite the JNI function table expecting the error %s to be returned ...\n", TranslateError(exError)); - err = jvmti->SetJNIFunctionTable(NULL); + err = jvmti->SetJNIFunctionTable(nullptr); if (err != exError) { result = STATUS_FAILED; printf("(%s,%d): TEST FAILED: SetJNIFunctionTable() returns %s instead of %s as expected\n", @@ -60,9 +60,9 @@ void redirect(JNIEnv *env, jvmtiError exError) { JNIEXPORT jint JNICALL Java_nsk_jvmti_SetJNIFunctionTable_setjniftab002_check(JNIEnv *env, jobject obj) { jint res; - JNIEnv *nextEnv = NULL; + JNIEnv *nextEnv = nullptr; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("(%s,%d): TEST FAILURE: JVMTI client was not properly loaded\n", __FILE__, __LINE__); return STATUS_FAILED; @@ -114,14 +114,14 @@ JNIEXPORT jint JNI_OnLoad_setjniftab002(JavaVM *jvm, char *options, void *reserv jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "-verbose") == 0) + if (options != nullptr && strcmp(options, "-verbose") == 0) verbose = 1; if (verbose) printf("verbose mode on\n"); res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("(%s,%d): Failed to call GetEnv\n", __FILE__, __LINE__); return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal001/setlocal001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal001/setlocal001.cpp index e882233178c..52a6e89f175 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal001/setlocal001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal001/setlocal001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; static jint result = PASSED; @@ -50,7 +50,7 @@ void JNICALL Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *env, jmethodID mid; jlocation loc; jint entryCount; - jvmtiLocalVariableEntry *table = NULL; + jvmtiLocalVariableEntry *table = nullptr; int i; err = jvmti_env->GetFrameLocation(thr, 1, &mid, &loc); @@ -234,7 +234,7 @@ void JNICALL Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *env, result = STATUS_FAILED; } - if (table != NULL) { + if (table != nullptr) { for (i = 0; i < entryCount; i++) { jvmti_env->Deallocate((unsigned char*)table[i].name); jvmti_env->Deallocate((unsigned char*)table[i].signature); @@ -259,7 +259,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv !\n"); return JNI_ERR; } @@ -308,7 +308,7 @@ Java_nsk_jvmti_SetLocalVariable_setlocal001_getMethReady(JNIEnv *env, jvmtiError err; jmethodID mid; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; @@ -338,7 +338,7 @@ Java_nsk_jvmti_SetLocalVariable_setlocal001_getMethReady(JNIEnv *env, } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_BREAKPOINT, NULL); + JVMTI_EVENT_BREAKPOINT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable BREAKPOINT event: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal002/setlocal002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal002/setlocal002.cpp index a2dbb7b9698..9ff5b3601f3 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal002/setlocal002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal002/setlocal002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -53,12 +53,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -99,7 +99,7 @@ Java_nsk_jvmti_SetLocalVariable_setlocal002_check(JNIEnv *env, jclass cls, jthre jvmtiLocalVariableEntry *table; int i; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -109,7 +109,7 @@ Java_nsk_jvmti_SetLocalVariable_setlocal002_check(JNIEnv *env, jclass cls, jthre } mid = env->GetStaticMethodID(cls, "run", "([Ljava/lang/String;Ljava/io/PrintStream;)I"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot find method \"run\"\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal003/setlocal003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal003/setlocal003.cpp index 144a6614a9e..fa0324b1563 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal003/setlocal003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal003/setlocal003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ extern "C" { #define STATUS_FAILED 2 #define INV_SLOT (-1) -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; static jint result = PASSED; @@ -139,12 +139,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -192,7 +192,7 @@ Java_nsk_jvmti_SetLocalVariable_setlocal003_getReady(JNIEnv *env, jclass cls) { jvmtiError err; jmethodID mid; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; @@ -202,7 +202,7 @@ Java_nsk_jvmti_SetLocalVariable_setlocal003_getReady(JNIEnv *env, jclass cls) { !caps.can_generate_breakpoint_events) return; mid = env->GetStaticMethodID(cls, "checkPoint", "()V"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot find Method ID for method checkPoint\n"); result = STATUS_FAILED; return; @@ -216,7 +216,7 @@ Java_nsk_jvmti_SetLocalVariable_setlocal003_getReady(JNIEnv *env, jclass cls) { } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_BREAKPOINT, NULL); + JVMTI_EVENT_BREAKPOINT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable BREAKPOINT event: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal004/setlocal004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal004/setlocal004.cpp index 397d6e787b4..5ed6e9c5588 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal004/setlocal004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal004/setlocal004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ extern "C" { #define STATUS_FAILED 2 #define INV_SLOT (-1) -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; static jint result = PASSED; @@ -145,12 +145,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -198,7 +198,7 @@ Java_nsk_jvmti_SetLocalVariable_setlocal004_getReady(JNIEnv *env, jclass cls) { jvmtiError err; jmethodID mid; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; @@ -222,7 +222,7 @@ Java_nsk_jvmti_SetLocalVariable_setlocal004_getReady(JNIEnv *env, jclass cls) { } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_BREAKPOINT, NULL); + JVMTI_EVENT_BREAKPOINT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable BREAKPOINT event: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetNativeMethodPrefix/SetNativeMethodPrefix001/SetNativeMethodPrefix001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetNativeMethodPrefix/SetNativeMethodPrefix001/SetNativeMethodPrefix001.cpp index d9631096901..c18485d4115 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetNativeMethodPrefix/SetNativeMethodPrefix001/SetNativeMethodPrefix001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetNativeMethodPrefix/SetNativeMethodPrefix001/SetNativeMethodPrefix001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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,7 +108,7 @@ static const void *METHODS [METHODS_COUNT] = { /* ============================================================================= */ -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; /* ============================================================================= */ @@ -120,17 +120,17 @@ Java_nsk_jvmti_SetNativeMethodPrefix_Binder_setMethodPrefix ( ) { jboolean result = JNI_TRUE; - char *str = NULL; + char *str = nullptr; - if (prefix != NULL) { - if (!NSK_VERIFY((str = (char *) jni->GetStringUTFChars(prefix, 0)) != NULL)) + if (prefix != nullptr) { + if (!NSK_VERIFY((str = (char *) jni->GetStringUTFChars(prefix, 0)) != nullptr)) { result = JNI_FALSE; goto finally; } } if (!NSK_JVMTI_VERIFY(jvmti->SetNativeMethodPrefix(str))) { result = JNI_FALSE; goto finally; } - if (str != NULL) { + if (str != nullptr) { NSK_DISPLAY1("New PREFIX is set: %s\n" , str ); @@ -139,7 +139,7 @@ Java_nsk_jvmti_SetNativeMethodPrefix_Binder_setMethodPrefix ( } finally: - if (str != NULL) { + if (str != nullptr) { jni->ReleaseStringUTFChars(prefix, str); } @@ -156,10 +156,10 @@ Java_nsk_jvmti_SetNativeMethodPrefix_Binder_setMultiplePrefixes ( ) { jboolean result = JNI_TRUE; - char *str = NULL; + char *str = nullptr; - if (prefix != NULL) { - if (!NSK_VERIFY((str = (char *) jni->GetStringUTFChars(prefix, 0)) != NULL)) + if (prefix != nullptr) { + if (!NSK_VERIFY((str = (char *) jni->GetStringUTFChars(prefix, 0)) != nullptr)) { result = JNI_FALSE; goto finally; } if (!NSK_JVMTI_VERIFY(jvmti->SetNativeMethodPrefixes(1, (char **) &str))) @@ -170,7 +170,7 @@ Java_nsk_jvmti_SetNativeMethodPrefix_Binder_setMultiplePrefixes ( ); } else { char* prefixes[1]; - prefixes[0] = NULL; + prefixes[0] = nullptr; if (!NSK_JVMTI_VERIFY(jvmti->SetNativeMethodPrefixes(0, (char **)&prefixes))) { result = JNI_FALSE; goto finally; } @@ -179,7 +179,7 @@ Java_nsk_jvmti_SetNativeMethodPrefix_Binder_setMultiplePrefixes ( } finally: - if (str != NULL) { + if (str != nullptr) { jni->ReleaseStringUTFChars(prefix, str); } @@ -209,11 +209,11 @@ Java_nsk_jvmti_SetNativeMethodPrefix_Binder_registerMethod ( return JNI_FALSE; } - if (!NSK_VERIFY((method.name = (char *) jni->GetStringUTFChars(method_name_obj, 0)) != NULL)) { + if (!NSK_VERIFY((method.name = (char *) jni->GetStringUTFChars(method_name_obj, 0)) != nullptr)) { goto finally; } - if (!NSK_VERIFY((method.signature = (char *) jni->GetStringUTFChars(method_sig_obj, 0)) != NULL)) { + if (!NSK_VERIFY((method.signature = (char *) jni->GetStringUTFChars(method_sig_obj, 0)) != nullptr)) { goto finally; } @@ -226,7 +226,7 @@ Java_nsk_jvmti_SetNativeMethodPrefix_Binder_registerMethod ( if (jni->RegisterNatives(bound_klass, (const JNINativeMethod*) &method, 1) != 0) { - if (jni->ExceptionOccurred() != NULL) { + if (jni->ExceptionOccurred() != nullptr) { jni->ExceptionClear(); } @@ -237,11 +237,11 @@ Java_nsk_jvmti_SetNativeMethodPrefix_Binder_registerMethod ( result = JNI_TRUE; finally: - if (method.name != NULL) { + if (method.name != nullptr) { jni->ReleaseStringUTFChars(method_name_obj, method.name); } - if (method.signature != NULL) { + if (method.signature != nullptr) { jni->ReleaseStringUTFChars(method_sig_obj, method.signature); } @@ -273,7 +273,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) return JNI_ERR; if (!NSK_VERIFY( - (jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved)) != NULL + (jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved)) != nullptr ) ) return JNI_ERR; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetNativeMethodPrefix/SetNativeMethodPrefix002/SetNativeMethodPrefix002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetNativeMethodPrefix/SetNativeMethodPrefix002/SetNativeMethodPrefix002.cpp index 7addf0cf052..d4f6e157e64 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetNativeMethodPrefix/SetNativeMethodPrefix002/SetNativeMethodPrefix002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetNativeMethodPrefix/SetNativeMethodPrefix002/SetNativeMethodPrefix002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,11 +38,11 @@ extern "C" { /* ============================================================================= */ -static char *prefix = NULL; +static char *prefix = nullptr; /* ============================================================================= */ -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; /* ============================================================================= */ @@ -95,7 +95,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) // Specify native method prefix prefix = (char *)nsk_jvmti_findOptionValue("prefix"); - if (prefix != NULL) { + if (prefix != nullptr) { NSK_DISPLAY1("Prefix: %s\n", prefix); } @@ -103,7 +103,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) apply = nsk_jvmti_findOptionIntValue("apply", 1); if (!NSK_VERIFY( - (jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved)) != NULL + (jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved)) != nullptr ) ) return JNI_ERR; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetSystemProperty/setsysprop002/setsysprop002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetSystemProperty/setsysprop002/setsysprop002.cpp index 0026afe9461..fc622764303 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetSystemProperty/setsysprop002/setsysprop002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetSystemProperty/setsysprop002/setsysprop002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -73,7 +73,7 @@ static PropertyDesc propDescList[PROPERTIES_COUNT] = { static int checkPropertyValue(jvmtiEnv* jvmti, const char phase[], const char name[], const char* expectedValue) { int success = NSK_TRUE; - char* value = NULL; + char* value = nullptr; NSK_DISPLAY1(" property: %s\n", name); if (!NSK_JVMTI_VERIFY(jvmti->GetSystemProperty(name, &value))) { @@ -81,7 +81,7 @@ static int checkPropertyValue(jvmtiEnv* jvmti, const char phase[], } NSK_DISPLAY1(" value: \"%s\"\n", nsk_null_string(value)); - if (value == NULL + if (value == nullptr || strcmp(value, expectedValue) != 0) { NSK_COMPLAIN4("In %s phase GetSystemProperty() returned unexpected value for property:\n" "# property name: %s\n" @@ -174,7 +174,7 @@ JNIEXPORT jint JNI_OnLoad_setsysprop002(JavaVM *jvm, char *options, void *reserv } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -182,7 +182,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; NSK_DISPLAY0(">>> Check setting defined system properties in OnLoad phase\n"); @@ -190,7 +190,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { nsk_jvmti_setFailStatus(); } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetSystemProperty/setsysprop003/setsysprop003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetSystemProperty/setsysprop003/setsysprop003.cpp index 841a15c3da9..8d6f9ab12c1 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetSystemProperty/setsysprop003/setsysprop003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetSystemProperty/setsysprop003/setsysprop003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ JNIEXPORT jint JNI_OnLoad_setsysprop003(JavaVM *jvm, char *options, void *reserv } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -87,7 +87,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; NSK_DISPLAY0(">>> Set new values for defined system properties in OnLoad phase\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetTag/settag001/settag001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetTag/settag001/settag001.cpp index 3c19fb28ee9..f6f700d7004 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetTag/settag001/settag001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetTag/settag001/settag001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,17 +51,17 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { /* perform testing */ { - jobject testedObject = NULL; + jobject testedObject = nullptr; jlong objectTag = 111; NSK_DISPLAY0(">>> Obtain tested object from a static field of debugee class\n"); { - jclass debugeeClass = NULL; - jfieldID objectField = NULL; + jclass debugeeClass = nullptr; + jfieldID objectField = nullptr; NSK_DISPLAY1("Find debugee class: %s\n", DEBUGEE_CLASS_NAME); if (!NSK_JNI_VERIFY(jni, (debugeeClass = - jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) { + jni->FindClass(DEBUGEE_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -69,7 +69,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY1("Find static field: %s\n", OBJECT_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (objectField = - jni->GetStaticFieldID(debugeeClass, OBJECT_FIELD_NAME, OBJECT_CLASS_SIG)) != NULL)) { + jni->GetStaticFieldID(debugeeClass, OBJECT_FIELD_NAME, OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -77,14 +77,14 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY1("Get object from static field: %s\n", OBJECT_FIELD_NAME); if (!NSK_JNI_VERIFY(jni, (testedObject = - jni->GetStaticObjectField(debugeeClass, objectField)) != NULL)) { + jni->GetStaticObjectField(debugeeClass, objectField)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY1(" ... got object: 0x%p\n", (void*)testedObject); NSK_DISPLAY1("Create global reference for object: 0x%p\n", (void*)testedObject); - if (!NSK_JNI_VERIFY(jni, (testedObject = jni->NewGlobalRef(testedObject)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (testedObject = jni->NewGlobalRef(testedObject)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -180,7 +180,7 @@ JNIEXPORT jint JNI_OnLoad_settag001(JavaVM *jvm, char *options, void *reserved) } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -190,7 +190,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add required capabilities */ @@ -205,7 +205,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetThreadLocalStorage/setthrdstor001/setthrdstor001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetThreadLocalStorage/setthrdstor001/setthrdstor001.cpp index c04094a47c6..10b0ab40792 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetThreadLocalStorage/setthrdstor001/setthrdstor001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetThreadLocalStorage/setthrdstor001/setthrdstor001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,16 +58,16 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { /* perform testing */ { - jthread testedThread = NULL; + jthread testedThread = nullptr; StorageStructure storageData; StorageStructure* initialStorage = &storageData; - StorageStructure* obtainedStorage = NULL; + StorageStructure* obtainedStorage = nullptr; memset(storageData.data, STORAGE_DATA_CHAR, STORAGE_DATA_SIZE); NSK_DISPLAY1("Find thread: %s\n", THREAD_NAME); if (!NSK_VERIFY((testedThread = - nsk_jvmti_threadByName(THREAD_NAME)) != NULL)) + nsk_jvmti_threadByName(THREAD_NAME)) != nullptr)) return; NSK_DISPLAY1(" ... found thread: %p\n", (void*)testedThread); @@ -148,7 +148,7 @@ JNIEXPORT jint JNI_OnLoad_setthrdstor001(JavaVM *jvm, char *options, void *reser } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -158,11 +158,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetThreadLocalStorage/setthrdstor002/setthrdstor002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetThreadLocalStorage/setthrdstor002/setthrdstor002.cpp index 9528052c9ab..baf6a2a33c7 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetThreadLocalStorage/setthrdstor002/setthrdstor002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetThreadLocalStorage/setthrdstor002/setthrdstor002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -60,13 +60,13 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { { StorageStructure storageData; StorageStructure* initialStorage = &storageData; - StorageStructure* obtainedStorage = NULL; + StorageStructure* obtainedStorage = nullptr; memset(storageData.data, STORAGE_DATA_CHAR, STORAGE_DATA_SIZE); NSK_DISPLAY1("SetThreadLocalStorage() for current agent thread with pointer: %p\n", (void*)initialStorage); - if (!NSK_JVMTI_VERIFY(jvmti->SetThreadLocalStorage(NULL, (void*)initialStorage))) { + if (!NSK_JVMTI_VERIFY(jvmti->SetThreadLocalStorage(nullptr, (void*)initialStorage))) { nsk_jvmti_setFailStatus(); return; } @@ -80,7 +80,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { return; NSK_DISPLAY0("GetThreadLocalStorage() for current agent thread\n"); - if (!NSK_JVMTI_VERIFY(jvmti->GetThreadLocalStorage(NULL, (void**)&obtainedStorage))) { + if (!NSK_JVMTI_VERIFY(jvmti->GetThreadLocalStorage(nullptr, (void**)&obtainedStorage))) { nsk_jvmti_setFailStatus(); return; } @@ -133,7 +133,7 @@ JNIEXPORT jint JNI_OnLoad_setthrdstor002(JavaVM *jvm, char *options, void *reser } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -143,11 +143,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetThreadLocalStorage/setthrdstor003/setthrdstor003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetThreadLocalStorage/setthrdstor003/setthrdstor003.cpp index ff49c9d060a..74514d40d8d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetThreadLocalStorage/setthrdstor003/setthrdstor003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetThreadLocalStorage/setthrdstor003/setthrdstor003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -78,7 +78,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { eventsStart = 0; eventsEnd = 0; NSK_DISPLAY1("Enable events: %d events\n", EVENTS_COUNT); - if (!nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, eventsList, NULL)) + if (!nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, eventsList, nullptr)) return; NSK_DISPLAY0("Let tested thread to run\n"); @@ -90,7 +90,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { return; NSK_DISPLAY1("Disable events: %d events\n", EVENTS_COUNT); - if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, eventsList, NULL)) + if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, eventsList, nullptr)) return; NSK_DISPLAY1("Check if all expected events received for tested thread: %s\n", @@ -117,7 +117,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { JNIEXPORT void JNICALL callbackThreadStart(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { /* check if event is for tested thread */ - if (thread != NULL) { + if (thread != nullptr) { jvmtiThreadInfo info; if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(thread, &info))) { @@ -125,14 +125,14 @@ callbackThreadStart(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { return; } - if (info.name != NULL && strcmp(info.name, THREAD_NAME) == 0) { + if (info.name != nullptr && strcmp(info.name, THREAD_NAME) == 0) { NSK_DISPLAY2(" ... received THREAD_START event for tested thread: %p (%s)\n", (void*)thread, info.name); eventsStart++; NSK_DISPLAY1("SetThreadLocalStorage() for current thread with pointer: %p\n", (void*)initialStorage); - if (!NSK_JVMTI_VERIFY(jvmti->SetThreadLocalStorage(NULL, (void*)initialStorage))) { + if (!NSK_JVMTI_VERIFY(jvmti->SetThreadLocalStorage(nullptr, (void*)initialStorage))) { nsk_jvmti_setFailStatus(); return; } @@ -145,7 +145,7 @@ callbackThreadStart(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { JNIEXPORT void JNICALL callbackThreadEnd(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { /* check if event is for tested thread */ - if (thread != NULL) { + if (thread != nullptr) { jvmtiThreadInfo info; if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(thread, &info))) { @@ -153,18 +153,18 @@ callbackThreadEnd(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { return; } - if (info.name != NULL && strcmp(info.name, THREAD_NAME) == 0) { + if (info.name != nullptr && strcmp(info.name, THREAD_NAME) == 0) { NSK_DISPLAY2(" ... received THREAD_END event for tested thread: %p (%s)\n", (void*)thread, info.name); eventsEnd++; /* get storage data */ { - StorageStructure* obtainedStorage = NULL; + StorageStructure* obtainedStorage = nullptr; NSK_DISPLAY0("GetThreadLocalStorage() for current thread\n"); if (!NSK_JVMTI_VERIFY( - jvmti->GetThreadLocalStorage(NULL, (void**)&obtainedStorage))) { + jvmti->GetThreadLocalStorage(nullptr, (void**)&obtainedStorage))) { nsk_jvmti_setFailStatus(); return; } @@ -219,7 +219,7 @@ JNIEXPORT jint JNI_OnLoad_setthrdstor003(JavaVM *jvm, char *options, void *reser } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -229,7 +229,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* set callbacks for thread events */ @@ -243,7 +243,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetVerboseFlag/setvrbflag001/setvrbflag001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetVerboseFlag/setvrbflag001/setvrbflag001.cpp index bc254115f5d..075cdf9a5d4 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetVerboseFlag/setvrbflag001/setvrbflag001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetVerboseFlag/setvrbflag001/setvrbflag001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -157,7 +157,7 @@ JNIEXPORT jint JNI_OnLoad_setvrbflag001(JavaVM *jvm, char *options, void *reserv } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv *jvmti = NULL; + jvmtiEnv *jvmti = nullptr; jvmtiEventCallbacks callbacks; /* init framework and parse options */ @@ -169,7 +169,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* Create data access lock */ @@ -194,16 +194,16 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* enable VMInit event */ if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL))) + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, nullptr))) return JNI_ERR; /* enable ClassFileLoadHook event */ if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL))) + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, nullptr))) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetVerboseFlag/setvrbflag002/setvrbflag002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetVerboseFlag/setvrbflag002/setvrbflag002.cpp index 8e43f0cb58b..a00da5d1226 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetVerboseFlag/setvrbflag002/setvrbflag002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetVerboseFlag/setvrbflag002/setvrbflag002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -70,7 +70,7 @@ JNIEXPORT jint JNI_OnLoad_setvrbflag002(JavaVM *jvm, char *options, void *reserv } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv *jvmti = NULL; + jvmtiEnv *jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -83,11 +83,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/StopThread/stopthrd006/stopthrd006.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/StopThread/stopthrd006/stopthrd006.cpp index 89f43810c1f..f479cc966a6 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/StopThread/stopthrd006/stopthrd006.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/StopThread/stopthrd006/stopthrd006.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -53,12 +53,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -96,7 +96,7 @@ Java_nsk_jvmti_StopThread_stopthrd006_check(JNIEnv *env, jclass cls, jthread thr, jobject ex) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -104,7 +104,7 @@ Java_nsk_jvmti_StopThread_stopthrd006_check(JNIEnv *env, if (printdump == JNI_TRUE) { printf(">>> invalid thread check ...\n"); } - err = jvmti->StopThread(NULL, ex); + err = jvmti->StopThread(nullptr, ex); if (err == JVMTI_ERROR_MUST_POSSESS_CAPABILITY && !caps.can_signal_thread) { /* It is OK */ @@ -117,7 +117,7 @@ Java_nsk_jvmti_StopThread_stopthrd006_check(JNIEnv *env, if (printdump == JNI_TRUE) { printf(">>> null pointer check ...\n"); } - err = jvmti->StopThread(thr, NULL); + err = jvmti->StopThread(thr, nullptr); if (err == JVMTI_ERROR_MUST_POSSESS_CAPABILITY && !caps.can_signal_thread) { /* It is OK */ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/StopThread/stopthrd007/stopthrd007.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/StopThread/stopthrd007/stopthrd007.cpp index da23414ab5c..bf5d20fc8fd 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/StopThread/stopthrd007/stopthrd007.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/StopThread/stopthrd007/stopthrd007.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,10 +38,10 @@ extern "C" { static jlong timeout = 0; /* test objects */ -static jobject threadDeath = NULL; -static jthread runningThread = NULL; -static jthread waitingThread = NULL; -static jthread sleepingThread = NULL; +static jobject threadDeath = nullptr; +static jthread runningThread = nullptr; +static jthread waitingThread = nullptr; +static jthread sleepingThread = nullptr; /* ========================================================================== */ @@ -53,10 +53,10 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { const char* THREAD_DEATH_CTOR_NAME = ""; const char* THREAD_DEATH_CTOR_SIGNATURE = "()V"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; - jclass cls = NULL; - jmethodID ctor = NULL; + jclass cls = nullptr; + jmethodID ctor = nullptr; int i; NSK_DISPLAY0("Prepare: find tested threads\n"); @@ -65,12 +65,12 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -80,7 +80,7 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL) { + if (info.name != nullptr) { if (strcmp(info.name, RUNNING_THREAD_NAME) == 0) { runningThread = threads[i]; } else if (strcmp(info.name, WAITING_THREAD_NAME) == 0) { @@ -96,14 +96,14 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { NSK_DISPLAY0("Prepare: create new instance of ThreadDeath exception\n"); - if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (ctor = - jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != NULL)) + jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (threadDeath = jni->NewObject(cls, ctor)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (threadDeath = jni->NewObject(cls, ctor)) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -124,7 +124,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { } NSK_DISPLAY0("Testcase #1: call StopThread for runningThread\n"); - if (!NSK_VERIFY(runningThread != NULL)) { + if (!NSK_VERIFY(runningThread != nullptr)) { nsk_jvmti_setFailStatus(); } else { if (!NSK_JVMTI_VERIFY(jvmti->StopThread(runningThread, threadDeath))) @@ -132,7 +132,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { } NSK_DISPLAY0("Testcase #2: call StopThread for waitingThread\n"); - if (!NSK_VERIFY(waitingThread != NULL)) { + if (!NSK_VERIFY(waitingThread != nullptr)) { nsk_jvmti_setFailStatus(); } else { if (!NSK_JVMTI_VERIFY(jvmti->StopThread(waitingThread, threadDeath))) @@ -140,7 +140,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { } NSK_DISPLAY0("Testcase #3: call StopThread for sleepingThread\n"); - if (!NSK_VERIFY(sleepingThread != NULL)) { + if (!NSK_VERIFY(sleepingThread != nullptr)) { nsk_jvmti_setFailStatus(); } else { if (!NSK_JVMTI_VERIFY(jvmti->StopThread(sleepingThread, threadDeath))) @@ -166,7 +166,7 @@ JNIEXPORT jint JNI_OnLoad_stopthrd007(JavaVM *jvm, char *options, void *reserved } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiCapabilities caps; NSK_DISPLAY0("Agent_OnLoad\n"); @@ -177,10 +177,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&caps, 0, sizeof(caps)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SuspendThread/suspendthrd001/suspendthrd001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SuspendThread/suspendthrd001/suspendthrd001.cpp index 5d346b9bf98..97da3e1dec1 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SuspendThread/suspendthrd001/suspendthrd001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SuspendThread/suspendthrd001/suspendthrd001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,11 +49,11 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { /* perform testing */ { - jthread testedThread = NULL; + jthread testedThread = nullptr; NSK_DISPLAY1("Find thread: %s\n", THREAD_NAME); if (!NSK_VERIFY((testedThread = - nsk_jvmti_threadByName(THREAD_NAME)) != NULL)) + nsk_jvmti_threadByName(THREAD_NAME)) != nullptr)) return; NSK_DISPLAY1(" ... found thread: %p\n", (void*)testedThread); @@ -118,7 +118,7 @@ JNIEXPORT jint JNI_OnLoad_suspendthrd001(JavaVM *jvm, char *options, void *reser } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -128,7 +128,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add specific capabilities for suspending thread */ @@ -141,7 +141,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SuspendThread/suspendthrd002/suspendthrd002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SuspendThread/suspendthrd002/suspendthrd002.cpp index 98a415315b4..d9eff84b63f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SuspendThread/suspendthrd002/suspendthrd002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SuspendThread/suspendthrd002/suspendthrd002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ static jvmtiEvent eventsList[EVENTS_COUNT] = { }; static volatile int eventsReceived = 0; -static jthread testedThread = NULL; +static jthread testedThread = nullptr; /* ============================================================================= */ @@ -65,13 +65,13 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { { NSK_DISPLAY1("Find thread: %s\n", THREAD_NAME); if (!NSK_VERIFY((testedThread = - nsk_jvmti_threadByName(THREAD_NAME)) != NULL)) + nsk_jvmti_threadByName(THREAD_NAME)) != nullptr)) return; NSK_DISPLAY1(" ... found thread: %p\n", (void*)testedThread); eventsReceived = 0; NSK_DISPLAY1("Enable event: %s\n", "THREAD_END"); - if (!nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, eventsList, NULL)) + if (!nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, eventsList, nullptr)) return; NSK_DISPLAY1("Suspend thread: %p\n", (void*)testedThread); @@ -99,7 +99,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { } NSK_DISPLAY1("Disable event: %s\n", "THREAD_END"); - if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, eventsList, NULL)) + if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, eventsList, nullptr)) return; NSK_DISPLAY1("Resume thread: %p\n", (void*)testedThread); @@ -126,7 +126,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { JNIEXPORT void JNICALL callbackThreadEnd(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { /* check if event is for tested thread */ - if (thread != NULL && + if (thread != nullptr && jni->IsSameObject(testedThread, thread)) { NSK_DISPLAY1(" ... received THREAD_END event for tested thread: %p\n", (void*)thread); eventsReceived++; @@ -150,7 +150,7 @@ JNIEXPORT jint JNI_OnLoad_suspendthrd002(JavaVM *jvm, char *options, void *reser } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -160,7 +160,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add specific capabilities for suspending thread */ @@ -182,7 +182,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SuspendThread/suspendthrd003/suspendthrd003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SuspendThread/suspendthrd003/suspendthrd003.cpp index 265d6b3d358..e172af654c8 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SuspendThread/suspendthrd003/suspendthrd003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SuspendThread/suspendthrd003/suspendthrd003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,11 +52,11 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { /* perform testing */ { - jthread testedThread = NULL; + jthread testedThread = nullptr; NSK_DISPLAY1("Find thread: %s\n", THREAD_NAME); if (!NSK_VERIFY((testedThread = - nsk_jvmti_threadByName(THREAD_NAME)) != NULL)) + nsk_jvmti_threadByName(THREAD_NAME)) != nullptr)) return; NSK_DISPLAY1(" ... found thread: %p\n", (void*)testedThread); @@ -150,7 +150,7 @@ JNIEXPORT jint JNI_OnLoad_suspendthrd003(JavaVM *jvm, char *options, void *reser } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -160,7 +160,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add specific capabilities for suspending thread */ @@ -173,7 +173,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SuspendThreadList/suspendthrdlst001/suspendthrdlst001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SuspendThreadList/suspendthrdlst001/suspendthrdlst001.cpp index bf17ed9a711..514dcbd43e9 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SuspendThreadList/suspendthrdlst001/suspendthrdlst001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SuspendThreadList/suspendthrdlst001/suspendthrdlst001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,8 +57,8 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { /* perform testing */ { - jthread* threads = NULL; - jvmtiError* results = NULL; + jthread* threads = nullptr; + jvmtiError* results = nullptr; int i; NSK_DISPLAY1("Allocate threads array: %d threads\n", threadsCount); @@ -130,7 +130,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY0("Delete threads references\n"); for (i = 0; i < threadsCount; i++) { - if (threads[i] != NULL) + if (threads[i] != nullptr) NSK_TRACE(jni->DeleteGlobalRef(threads[i])); } @@ -156,14 +156,14 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { static int fillThreadsByName(jvmtiEnv* jvmti, JNIEnv* jni, const char name[], int foundCount, jthread foundThreads[]) { jint count = 0; - jthread* threads = NULL; + jthread* threads = nullptr; size_t len = strlen(name); int found = 0; int i; for (i = 0; i < foundCount; i++) { - foundThreads[i] = NULL; + foundThreads[i] = nullptr; } if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&count, &threads))) { @@ -180,7 +180,7 @@ static int fillThreadsByName(jvmtiEnv* jvmti, JNIEnv* jni, break; } - if (info.name != NULL && strncmp(name, info.name, len) == 0) { + if (info.name != nullptr && strncmp(name, info.name, len) == 0) { NSK_DISPLAY3(" ... found thread #%d: %p (%s)\n", found, threads[i], info.name); if (found < foundCount) @@ -208,7 +208,7 @@ static int fillThreadsByName(jvmtiEnv* jvmti, JNIEnv* jni, NSK_DISPLAY1("Make global references for threads: %d threads\n", foundCount); for (i = 0; i < foundCount; i++) { if (!NSK_JNI_VERIFY(jni, (foundThreads[i] = (jthread) - jni->NewGlobalRef(foundThreads[i])) != NULL)) { + jni->NewGlobalRef(foundThreads[i])) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -233,7 +233,7 @@ JNIEXPORT jint JNI_OnLoad_suspendthrdlst001(JavaVM *jvm, char *options, void *re } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -248,7 +248,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add specific capabilities for suspending thread */ @@ -261,7 +261,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SuspendThreadList/suspendthrdlst002/suspendthrdlst002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SuspendThreadList/suspendthrdlst002/suspendthrdlst002.cpp index 1145bb3c1cb..31406434c49 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SuspendThreadList/suspendthrdlst002/suspendthrdlst002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SuspendThreadList/suspendthrdlst002/suspendthrdlst002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -50,7 +50,7 @@ static jvmtiEvent eventsList[EVENTS_COUNT] = { }; static int threadsCount = 0; -static jthread* threads = NULL; +static jthread* threads = nullptr; static volatile int eventsReceived = 0; @@ -69,7 +69,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { /* perform testing */ { - jvmtiError* results = NULL; + jvmtiError* results = nullptr; int i; NSK_DISPLAY1("Allocate threads array: %d threads\n", threadsCount); @@ -108,7 +108,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { eventsReceived = 0; NSK_DISPLAY1("Enable event: %s\n", "THREAD_END"); - if (!nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, eventsList, NULL)) + if (!nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, eventsList, nullptr)) return; NSK_DISPLAY0("Let threads to run and finish\n"); @@ -131,7 +131,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { } NSK_DISPLAY1("Disable event: %s\n", "THREAD_END"); - if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, eventsList, NULL)) + if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, eventsList, nullptr)) return; NSK_DISPLAY0("Resume threads list\n"); @@ -146,7 +146,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY0("Delete threads references\n"); for (i = 0; i < threadsCount; i++) { - if (threads[i] != NULL) + if (threads[i] != nullptr) NSK_TRACE(jni->DeleteGlobalRef(threads[i])); } @@ -172,14 +172,14 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { static int fillThreadsByName(jvmtiEnv* jvmti, JNIEnv* jni, const char name[], int foundCount, jthread foundThreads[]) { jint count = 0; - jthread* threads = NULL; + jthread* threads = nullptr; size_t len = strlen(name); int found = 0; int i; for (i = 0; i < foundCount; i++) { - foundThreads[i] = NULL; + foundThreads[i] = nullptr; } if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&count, &threads))) { @@ -196,7 +196,7 @@ static int fillThreadsByName(jvmtiEnv* jvmti, JNIEnv* jni, break; } - if (info.name != NULL && strncmp(name, info.name, len) == 0) { + if (info.name != nullptr && strncmp(name, info.name, len) == 0) { NSK_DISPLAY3(" ... found thread #%d: %p (%s)\n", found, threads[i], info.name); if (found < foundCount) @@ -224,7 +224,7 @@ static int fillThreadsByName(jvmtiEnv* jvmti, JNIEnv* jni, NSK_DISPLAY1("Make global references for threads: %d threads\n", foundCount); for (i = 0; i < foundCount; i++) { if (!NSK_JNI_VERIFY(jni, (foundThreads[i] = (jthread) - jni->NewGlobalRef(foundThreads[i])) != NULL)) { + jni->NewGlobalRef(foundThreads[i])) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -243,7 +243,7 @@ callbackThreadEnd(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { /* check if event is for tested thread */ for (i = 0; i < threadsCount; i++) { - if (thread != NULL && + if (thread != nullptr && jni->IsSameObject(threads[i], thread)) { NSK_DISPLAY2(" ... received THREAD_END event for thread #%d: %p\n", i, (void*)thread); @@ -269,7 +269,7 @@ JNIEXPORT jint JNI_OnLoad_suspendthrdlst002(JavaVM *jvm, char *options, void *re } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -284,7 +284,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add specific capabilities for suspending thread */ @@ -306,7 +306,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/VMDeath/vmdeath001/vmdeath001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/VMDeath/vmdeath001/vmdeath001.cpp index 887b217608d..4eabc000abf 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/VMDeath/vmdeath001/vmdeath001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/VMDeath/vmdeath001/vmdeath001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; /** callback functions **/ @@ -81,7 +81,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; NSK_DISPLAY0("setting event callbacks ...\n"); @@ -91,7 +91,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; NSK_DISPLAY0("setting event callbacks done\nenabling VMDeath event ...\n"); - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, nullptr))) return JNI_ERR; NSK_DISPLAY0("enabling VMDeath event done\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/VMInit/vminit001/vminit001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/VMInit/vminit001/vminit001.cpp index 7480242377a..5346f1b41fa 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/VMInit/vminit001/vminit001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/VMInit/vminit001/vminit001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ extern "C" { #define STATUS_FAILED 2 #define WAIT_TIME 1000 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -52,7 +52,7 @@ void JNICALL VMInit(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thr) { } err = jvmti_env->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_THREAD_START, NULL); + JVMTI_EVENT_THREAD_START, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable JVMTI_EVENT_THREAD_START: %s (%d)\n", TranslateError(err), err); @@ -107,7 +107,7 @@ void JNICALL ThreadStart(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread) { if (printdump == JNI_TRUE) { printf(">>> thread start: %s\n", inf.name); } - if (inf.name != NULL && strcmp(name, inf.name) == 0) { + if (inf.name != nullptr && strcmp(name, inf.name) == 0) { mainStarted++; if (eventsCount == 0) { printf("ThreadStart event for the main thread occurs\n"); @@ -132,12 +132,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -152,7 +152,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_VM_INIT, NULL); + JVMTI_EVENT_VM_INIT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable JVMTI_EVENT_VM_INIT: %s (%d)\n", TranslateError(err), err); @@ -164,7 +164,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { JNIEXPORT jint JNICALL Java_nsk_jvmti_VMInit_vminit001_check(JNIEnv *env, jclass cls) { - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP01/ap01t001/ap01t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP01/ap01t001/ap01t001.cpp index 667396da93e..e2210d23b64 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP01/ap01t001/ap01t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP01/ap01t001/ap01t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,8 +39,8 @@ extern "C" { #define EXP_OBJ_NUMBER 7 -static JNIEnv *jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv *jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jvmtiCapabilities caps; @@ -146,17 +146,17 @@ Java_nsk_jvmti_scenarios_allocation_AP01_ap01t001_newObject(JNIEnv* jni, jclass jmethodID cid; jobject result; - if (!NSK_JNI_VERIFY(jni, (cid = jni->GetMethodID(cls, "", "()V")) != NULL)) { - NSK_COMPLAIN0("newObject: GetMethodID returned NULL\n\n"); + if (!NSK_JNI_VERIFY(jni, (cid = jni->GetMethodID(cls, "", "()V")) != nullptr)) { + NSK_COMPLAIN0("newObject: GetMethodID returned null\n\n"); nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } - if (!NSK_JNI_VERIFY(jni, (result = jni->NewObject(cls, cid)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (result = jni->NewObject(cls, cid)) != nullptr)) { - NSK_COMPLAIN0("newObject: NewObject returned NULL\n\n"); + NSK_COMPLAIN0("newObject: NewObject returned null\n\n"); nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } return result; @@ -167,25 +167,25 @@ Java_nsk_jvmti_scenarios_allocation_AP01_ap01t001_allocObject(JNIEnv* jni, jclas jmethodID cid; jobject result; - if (!NSK_JNI_VERIFY(jni, (cid = jni->GetMethodID(cls, "", "()V")) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (cid = jni->GetMethodID(cls, "", "()V")) != nullptr)) { - NSK_COMPLAIN0("allocObject: GetMethodID returned NULL\n\n"); + NSK_COMPLAIN0("allocObject: GetMethodID returned null\n\n"); nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } - if (!NSK_JNI_VERIFY(jni, (result = jni->AllocObject(cls)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (result = jni->AllocObject(cls)) != nullptr)) { - NSK_COMPLAIN0("allocObject: AllocObject returned NULL\n\n"); + NSK_COMPLAIN0("allocObject: AllocObject returned null\n\n"); nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } if (!NSK_JNI_VERIFY_VOID(jni,jni->CallNonvirtualVoidMethod(result, cls, cid))) { NSK_COMPLAIN0("newObject: CallNonvirtualVoidMethod failed\n\n"); nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } return result; @@ -196,7 +196,7 @@ Java_nsk_jvmti_scenarios_allocation_AP01_ap01t001_flushObjectFreeEvents(JNIEnv* // Already enabled, but this triggers flush of pending events. if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_OBJECT_FREE, - NULL))) { + nullptr))) { nsk_jvmti_setFailStatus(); } } @@ -204,7 +204,7 @@ Java_nsk_jvmti_scenarios_allocation_AP01_ap01t001_flushObjectFreeEvents(JNIEnv* static void JNICALL agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { - jclass debugeeClass = NULL; + jclass debugeeClass = nullptr; NSK_DISPLAY0("Wait for debugee start\n\n"); if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) @@ -212,7 +212,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY1("Find debugee class: %s\n", DEBUGEE_SIGNATURE); debugeeClass = nsk_jvmti_classBySignature(DEBUGEE_SIGNATURE); - if (debugeeClass == NULL) { + if (debugeeClass == nullptr) { nsk_jvmti_setFailStatus(); return; } @@ -313,7 +313,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; memset(&caps, 0, sizeof(jvmtiCapabilities)); @@ -343,15 +343,15 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { NSK_DISPLAY0("setting event callbacks done\nenabling JVMTI events ...\n"); if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_OBJECT_FREE, - NULL))) + nullptr))) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, - NULL))) + nullptr))) return JNI_ERR; NSK_DISPLAY0("enabling the events done\n\n"); - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; NSK_DISPLAY0("agentProc has been set\n\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP02/ap02t001/ap02t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP02/ap02t001/ap02t001.cpp index 409784d43ea..9697e1d1ef6 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP02/ap02t001/ap02t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP02/ap02t001/ap02t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,8 +38,8 @@ extern "C" { #define TESTED_CLASS "ap02t001Exception" -static JNIEnv *jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv *jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jvmtiCapabilities caps; @@ -50,7 +50,7 @@ static jlong timeout = 0; static int user_data = 0; static const char* TESTED_CLASS_SIGNATURE = "Lnsk/jvmti/scenarios/allocation/AP02/ap02t001Exception;"; static const jlong TESTED_CLASS_TAG = (jlong)1024; -static jclass testedClass = NULL; +static jclass testedClass = nullptr; jvmtiIterationControl JNICALL heapObjectCallback(jlong class_tag, @@ -142,9 +142,9 @@ static void runIterations (jvmtiEnv* jvmti, jclass testedClass, jint exp_count) NSK_DISPLAY0("Calling IterateOverReachableObjects\n"); obj_count = 0; - if (!NSK_JVMTI_VERIFY(jvmti->IterateOverReachableObjects(NULL /*heapRootCallback*/, + if (!NSK_JVMTI_VERIFY(jvmti->IterateOverReachableObjects(nullptr /*heapRootCallback*/, stackReferenceCallback, - NULL /*objectReferenceCallback*/, + nullptr /*objectReferenceCallback*/, &user_data))) { nsk_jvmti_setFailStatus(); return; @@ -173,12 +173,12 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY1("Find tested class: %s\n", TESTED_CLASS_SIGNATURE); testedClass = nsk_jvmti_classBySignature(TESTED_CLASS_SIGNATURE); - if (testedClass == NULL) { + if (testedClass == nullptr) { nsk_jvmti_setFailStatus(); return; } - if (!NSK_JNI_VERIFY(jni, (testedClass = (jclass)jni->NewGlobalRef(testedClass)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (testedClass = (jclass)jni->NewGlobalRef(testedClass)) != nullptr)) return; NSK_DISPLAY0("Set tag for tested class\n\n"); @@ -222,7 +222,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; memset(&caps, 0, sizeof(jvmtiCapabilities)); @@ -236,7 +236,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!caps.can_tag_objects) NSK_DISPLAY0("Warning: tagging objects is not implemented\n"); - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; NSK_DISPLAY0("agentProc has been set\n\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP03/ap03t001/ap03t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP03/ap03t001/ap03t001.cpp index 0ebfdadeafc..4e7473be5b6 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP03/ap03t001/ap03t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP03/ap03t001/ap03t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -35,8 +35,8 @@ extern "C" { #define EXP_OBJ_NUMBER 1 -static JNIEnv *jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv *jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jvmtiCapabilities caps; @@ -98,7 +98,7 @@ Java_nsk_jvmti_scenarios_allocation_AP03_ap03t001_setTag(JNIEnv* jni, jobject ob static void JNICALL agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { - jclass debugeeClass = NULL; + jclass debugeeClass = nullptr; NSK_DISPLAY0("Wait for debugee start\n\n"); if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) @@ -110,7 +110,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY1("Find debugee class: %s\n", DEBUGEE_SIGNATURE); debugeeClass = nsk_jvmti_classBySignature(DEBUGEE_SIGNATURE); - if (debugeeClass == NULL) { + if (debugeeClass == nullptr) { nsk_jvmti_setFailStatus(); break; } @@ -160,14 +160,14 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { } if (!NSK_JNI_VERIFY(jni, (fid = - jni->GetStaticFieldID(debugeeClass, "catcher", DEBUGEE_SIGNATURE)) != NULL)) { + jni->GetStaticFieldID(debugeeClass, "catcher", DEBUGEE_SIGNATURE)) != nullptr)) { nsk_jvmti_setFailStatus(); break; } if (!NSK_JNI_VERIFY(jni, (catcher = - jni->GetStaticObjectField(debugeeClass, fid)) != NULL)) { - NSK_COMPLAIN0("GetStaticObjectField returned NULL for 'catcher' field value\n\n"); + jni->GetStaticObjectField(debugeeClass, fid)) != nullptr)) { + NSK_COMPLAIN0("GetStaticObjectField returned null for 'catcher' field value\n\n"); nsk_jvmti_setFailStatus(); break; } @@ -215,7 +215,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; memset(&caps, 0, sizeof(jvmtiCapabilities)); @@ -244,11 +244,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { NSK_DISPLAY0("setting event callbacks done\nenabling JVMTI events ...\n"); if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_OBJECT_FREE, - NULL))) + nullptr))) return JNI_ERR; NSK_DISPLAY0("enabling the events done\n\n"); - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; NSK_DISPLAY0("agentProc has been set\n\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP04/ap04t001/ap04t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP04/ap04t001/ap04t001.cpp index cf79fe945a1..eea3e881ccd 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP04/ap04t001/ap04t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP04/ap04t001/ap04t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -35,8 +35,8 @@ extern "C" { #define OBJ_MAX_COUNT 100000 -static JNIEnv *jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv *jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jvmtiCapabilities caps; @@ -52,9 +52,9 @@ static jvmtiEvent events[] = { JVMTI_EVENT_GARBAGE_COLLECTION_FINISH }; -static jclass debugeeClass = NULL; -static jfieldID rootFieldID = NULL; -static jmethodID unlockSecondaryID = NULL; +static jclass debugeeClass = nullptr; +static jfieldID rootFieldID = nullptr; +static jmethodID unlockSecondaryID = nullptr; static volatile int eventCount = 0; static volatile int iterationCount = 0; @@ -62,7 +62,7 @@ static volatile int errorCount = 0; /***********************************************************************/ -static jrawMonitorID counterMonitor_ptr = NULL; +static jrawMonitorID counterMonitor_ptr = nullptr; static void increaseCounter(volatile int* counterPtr) { @@ -269,7 +269,7 @@ Java_nsk_jvmti_scenarios_allocation_AP04_ap04t001_runIterateOverHeap(JNIEnv* jni NSK_DISPLAY0("Calling IterateOverHeap...\n"); if (!NSK_JVMTI_VERIFY(jvmti->IterateOverHeap(JVMTI_HEAP_OBJECT_TAGGED, heapObjectCallback, - NULL /*user_data*/))) { + nullptr /*user_data*/))) { nsk_jvmti_setFailStatus(); } NSK_DISPLAY0("IterateOverHeap finished.\n"); @@ -298,7 +298,7 @@ Java_nsk_jvmti_scenarios_allocation_AP04_ap04t001_runIterateOverReachableObjects if (!NSK_JVMTI_VERIFY(jvmti->IterateOverReachableObjects(heapRootCallback, stackReferenceCallback, objectReferenceCallback, - NULL /*user_data*/))) { + nullptr /*user_data*/))) { nsk_jvmti_setFailStatus(); } NSK_DISPLAY0("IterateOverReachableObjects finished.\n"); @@ -327,7 +327,7 @@ Java_nsk_jvmti_scenarios_allocation_AP04_ap04t001_runIterateOverInstancesOfClass if (!NSK_JVMTI_VERIFY(jvmti->IterateOverInstancesOfClass(debugeeClass, JVMTI_HEAP_OBJECT_TAGGED, heapObjectCallback, - NULL /*user_data*/))) { + nullptr /*user_data*/))) { nsk_jvmti_setFailStatus(); } NSK_DISPLAY0("IterateOverInstancesOfClass finished.\n"); @@ -347,12 +347,12 @@ JNIEXPORT void JNICALL Java_nsk_jvmti_scenarios_allocation_AP04_ap04t001_runIterateOverObjectsReachableFromObject(JNIEnv* jni, jclass klass) { - jobject root = NULL; + jobject root = nullptr; int count = 0; if (!NSK_JNI_VERIFY(jni, (root = - jni->GetStaticObjectField(debugeeClass, rootFieldID)) != NULL)) { - NSK_COMPLAIN0("GetStaticObjectField returned NULL for 'root' field value\n\n"); + jni->GetStaticObjectField(debugeeClass, rootFieldID)) != nullptr)) { + NSK_COMPLAIN0("GetStaticObjectField returned null for 'root' field value\n\n"); nsk_jvmti_setFailStatus(); return; } @@ -367,7 +367,7 @@ Java_nsk_jvmti_scenarios_allocation_AP04_ap04t001_runIterateOverObjectsReachable NSK_DISPLAY0("Calling IterateOverObjectsReachableFromObject...\n"); if (!NSK_JVMTI_VERIFY(jvmti->IterateOverObjectsReachableFromObject(root, objectReferenceCallback, - NULL /*user_data*/))) { + nullptr /*user_data*/))) { nsk_jvmti_setFailStatus(); } NSK_DISPLAY0("IterateOverObjectsReachableFromObject finished.\n"); @@ -392,24 +392,24 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY1("Find debugee class: %s\n", DEBUGEE_SIGNATURE); debugeeClass = nsk_jvmti_classBySignature(DEBUGEE_SIGNATURE); - if (debugeeClass == NULL) { + if (debugeeClass == nullptr) { nsk_jvmti_setFailStatus(); return; } - if (!NSK_JNI_VERIFY(jni, (debugeeClass = (jclass)jni->NewGlobalRef(debugeeClass)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (debugeeClass = (jclass)jni->NewGlobalRef(debugeeClass)) != nullptr)) return; NSK_DISPLAY1("Find ID of 'root' field: %s\n", ROOT_SIGNATURE); if (!NSK_JNI_VERIFY(jni, (rootFieldID = - jni->GetStaticFieldID(debugeeClass, "root", ROOT_SIGNATURE)) != NULL)) { + jni->GetStaticFieldID(debugeeClass, "root", ROOT_SIGNATURE)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY1("Find ID of 'unlockSecondary' method: %s\n", ROOT_SIGNATURE); if (!NSK_JNI_VERIFY(jni, (unlockSecondaryID = - jni->GetStaticMethodID(debugeeClass, "unlockSecondary", "()V")) != NULL)) { + jni->GetStaticMethodID(debugeeClass, "unlockSecondary", "()V")) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -423,7 +423,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) return; - nsk_jvmti_enableEvents(JVMTI_DISABLE, eventsCount, events, NULL); + nsk_jvmti_enableEvents(JVMTI_DISABLE, eventsCount, events, nullptr); NSK_TRACE(jni->DeleteGlobalRef(debugeeClass)); NSK_TRACE(jvmti->DestroyRawMonitor(counterMonitor_ptr)); @@ -451,7 +451,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("counterMonitor", &counterMonitor_ptr))) { @@ -489,12 +489,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { NSK_DISPLAY0("setting event callbacks done.\n"); NSK_DISPLAY0("enabling JVMTI events ...\n"); - if (!nsk_jvmti_enableEvents(JVMTI_ENABLE, eventsCount, events, NULL)) { + if (!nsk_jvmti_enableEvents(JVMTI_ENABLE, eventsCount, events, nullptr)) { return JNI_ERR; } NSK_DISPLAY0("enabling the events done.\n"); - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; NSK_DISPLAY0("agentProc has been set\n\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP04/ap04t002/ap04t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP04/ap04t002/ap04t002.cpp index f42bb0d8680..e9f43a1cbaf 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP04/ap04t002/ap04t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP04/ap04t002/ap04t002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -35,8 +35,8 @@ extern "C" { #define OBJ_MAX_COUNT 100000 -static JNIEnv *jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv *jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jvmtiCapabilities caps; @@ -49,13 +49,13 @@ static volatile int modificationCount = 0; static volatile int iterationCount = 0; static volatile int errorCount = 0; -static jclass debugeeClass = NULL; +static jclass debugeeClass = nullptr; static jfieldID rootFieldID; static jfieldID modifiedFieldID; /***********************************************************************/ -static jrawMonitorID counterMonitor_ptr = NULL; +static jrawMonitorID counterMonitor_ptr = nullptr; static void increaseCounter(volatile int* counterPtr) { @@ -249,7 +249,7 @@ Java_nsk_jvmti_scenarios_allocation_AP04_ap04t002_runIterateOverHeap(JNIEnv* jni NSK_DISPLAY0("Calling IterateOverHeap...\n"); if (!NSK_JVMTI_VERIFY(jvmti->IterateOverHeap(JVMTI_HEAP_OBJECT_TAGGED, heapObjectCallback, - NULL /*user_data*/))) { + nullptr /*user_data*/))) { nsk_jvmti_setFailStatus(); } NSK_DISPLAY0("IterateOverHeap finished.\n"); @@ -279,7 +279,7 @@ Java_nsk_jvmti_scenarios_allocation_AP04_ap04t002_runIterateOverReachableObjects if (!NSK_JVMTI_VERIFY(jvmti->IterateOverReachableObjects(heapRootCallback, stackReferenceCallback, objectReferenceCallback, - NULL /*user_data*/))) { + nullptr /*user_data*/))) { nsk_jvmti_setFailStatus(); } NSK_DISPLAY0("IterateOverReachableObjects finished.\n"); @@ -309,7 +309,7 @@ Java_nsk_jvmti_scenarios_allocation_AP04_ap04t002_runIterateOverInstancesOfClass if (!NSK_JVMTI_VERIFY(jvmti->IterateOverInstancesOfClass(debugeeClass, JVMTI_HEAP_OBJECT_TAGGED, heapObjectCallback, - NULL /*user_data*/))) { + nullptr /*user_data*/))) { nsk_jvmti_setFailStatus(); } NSK_DISPLAY0("IterateOverInstancesOfClass finished.\n"); @@ -329,12 +329,12 @@ Java_nsk_jvmti_scenarios_allocation_AP04_ap04t002_runIterateOverInstancesOfClass JNIEXPORT void JNICALL Java_nsk_jvmti_scenarios_allocation_AP04_ap04t002_runIterateOverObjectsReachableFromObject(JNIEnv* jni, jclass klass) { - jobject root = NULL; + jobject root = nullptr; int count = 0; if (!NSK_JNI_VERIFY(jni, (root = - jni->GetStaticObjectField(debugeeClass, rootFieldID)) != NULL)) { - NSK_COMPLAIN0("GetStaticObjectField returned NULL for 'root' field value\n\n"); + jni->GetStaticObjectField(debugeeClass, rootFieldID)) != nullptr)) { + NSK_COMPLAIN0("GetStaticObjectField returned null for 'root' field value\n\n"); nsk_jvmti_setFailStatus(); return; } @@ -346,7 +346,7 @@ Java_nsk_jvmti_scenarios_allocation_AP04_ap04t002_runIterateOverObjectsReachable NSK_DISPLAY0("Calling IterateOverObjectsReachableFromObject...\n"); if (!NSK_JVMTI_VERIFY(jvmti->IterateOverObjectsReachableFromObject(root, objectReferenceCallback, - NULL /*user_data*/))) { + nullptr /*user_data*/))) { nsk_jvmti_setFailStatus(); } NSK_DISPLAY0("IterateOverObjectsReachableFromObject finished.\n"); @@ -372,24 +372,24 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY1("Find debugee class: %s\n", DEBUGEE_SIGNATURE); debugeeClass = nsk_jvmti_classBySignature(DEBUGEE_SIGNATURE); - if (debugeeClass == NULL) { + if (debugeeClass == nullptr) { nsk_jvmti_setFailStatus(); return; } - if (!NSK_JNI_VERIFY(jni, (debugeeClass = (jclass)jni->NewGlobalRef(debugeeClass)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (debugeeClass = (jclass)jni->NewGlobalRef(debugeeClass)) != nullptr)) return; NSK_DISPLAY1("Find ID of 'root' field: %s\n", ROOT_SIGNATURE); if (!NSK_JNI_VERIFY(jni, (rootFieldID = - jni->GetStaticFieldID(debugeeClass, "root", ROOT_SIGNATURE)) != NULL)) { + jni->GetStaticFieldID(debugeeClass, "root", ROOT_SIGNATURE)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY0("Find ID of 'modified' field\n"); if (!NSK_JNI_VERIFY(jni, (modifiedFieldID = - jni->GetStaticFieldID(debugeeClass, "modified", "I")) != NULL)) { + jni->GetStaticFieldID(debugeeClass, "modified", "I")) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -434,7 +434,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("counterMonitor", &counterMonitor_ptr))) { @@ -469,11 +469,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { NSK_DISPLAY0("enabling JVMTI events ...\n"); if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FIELD_MODIFICATION, - NULL))) + nullptr))) return JNI_ERR; NSK_DISPLAY0("enabling the events done.\n"); - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; NSK_DISPLAY0("agentProc has been set\n\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP04/ap04t003/ap04t003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP04/ap04t003/ap04t003.cpp index 99f4ec37019..4e0673b608d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP04/ap04t003/ap04t003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP04/ap04t003/ap04t003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -35,8 +35,8 @@ extern "C" { #define OBJ_MAX_COUNT 100000 -static JNIEnv *jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv *jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jvmtiCapabilities caps; @@ -45,19 +45,19 @@ static jlong timeout = 0; static const char* DEBUGEE_SIGNATURE = "Lnsk/jvmti/scenarios/allocation/AP04/ap04t003;"; static const char* ROOT_SIGNATURE = "[Lnsk/jvmti/scenarios/allocation/AP04/ap04t003;"; -static jclass debugeeClass = NULL; +static jclass debugeeClass = nullptr; static jfieldID rootFieldID; -static jrawMonitorID startLock = NULL; -static jrawMonitorID runLock = NULL; -static jrawMonitorID endLock = NULL; +static jrawMonitorID startLock = nullptr; +static jrawMonitorID runLock = nullptr; +static jrawMonitorID endLock = nullptr; static volatile int iterationCount = 0; static volatile int objectCount = 0; /***********************************************************************/ -static jrawMonitorID counterMonitor_ptr = NULL; +static jrawMonitorID counterMonitor_ptr = nullptr; static void increaseCounter(volatile int* counterPtr) { @@ -210,7 +210,7 @@ objectReferenceCallback(jvmtiObjectReferenceKind reference_kind, void JNICALL agent_start(jvmtiEnv* jvmti, JNIEnv* jni, void *p) { jint taggedObjectsCount = 0; - jobject* taggedObjectsList = NULL; + jobject* taggedObjectsList = nullptr; NSK_DISPLAY0("Agent thread: started.\n"); @@ -219,7 +219,7 @@ void JNICALL agent_start(jvmtiEnv* jvmti, JNIEnv* jni, void *p) { jlong tag = (jlong)1; if (!NSK_JVMTI_VERIFY(jvmti->GetObjectsWithTags( - 1, &tag, &taggedObjectsCount, &taggedObjectsList, NULL))) { + 1, &tag, &taggedObjectsCount, &taggedObjectsList, nullptr))) { nsk_jvmti_setFailStatus(); return; } @@ -315,7 +315,7 @@ static int startThread(jthread threadObj) { /* start thread */ if (!NSK_JVMTI_VERIFY( - jvmti->RunAgentThread(threadObj, agent_start, NULL, JVMTI_THREAD_NORM_PRIORITY))) { + jvmti->RunAgentThread(threadObj, agent_start, nullptr, JVMTI_THREAD_NORM_PRIORITY))) { success = NSK_FALSE; nsk_jvmti_setFailStatus(); } else { @@ -348,7 +348,7 @@ static jthread newThreadObj(JNIEnv* jni_env) { /** Clean counters and start new agent thread with agent_start() body. */ static int prepareToIteration(JNIEnv* jni) { - jthread threadObj = NULL; + jthread threadObj = nullptr; setCounter(&iterationCount, 0); setCounter(&objectCount, 0); @@ -408,7 +408,7 @@ Java_nsk_jvmti_scenarios_allocation_AP04_ap04t003_runIterateOverHeap(JNIEnv* jni NSK_DISPLAY0("Calling IterateOverHeap...\n"); if (!NSK_JVMTI_VERIFY(jvmti->IterateOverHeap(JVMTI_HEAP_OBJECT_TAGGED, heapObjectCallback, - NULL /*user_data*/))) { + nullptr /*user_data*/))) { nsk_jvmti_setFailStatus(); } NSK_DISPLAY0("IterateOverHeap finished.\n"); @@ -439,7 +439,7 @@ Java_nsk_jvmti_scenarios_allocation_AP04_ap04t003_runIterateOverReachableObjects if (!NSK_JVMTI_VERIFY(jvmti->IterateOverReachableObjects(heapRootCallback, stackReferenceCallback, objectReferenceCallback, - NULL /*user_data*/))) { + nullptr /*user_data*/))) { nsk_jvmti_setFailStatus(); } NSK_DISPLAY0("IterateOverReachableObjects finished.\n"); @@ -470,7 +470,7 @@ Java_nsk_jvmti_scenarios_allocation_AP04_ap04t003_runIterateOverInstancesOfClass if (!NSK_JVMTI_VERIFY(jvmti->IterateOverInstancesOfClass(debugeeClass, JVMTI_HEAP_OBJECT_TAGGED, heapObjectCallback, - NULL /*user_data*/))) { + nullptr /*user_data*/))) { nsk_jvmti_setFailStatus(); } NSK_DISPLAY0("IterateOverInstancesOfClass finished.\n"); @@ -492,7 +492,7 @@ JNIEXPORT void JNICALL Java_nsk_jvmti_scenarios_allocation_AP04_ap04t003_runIterateOverObjectsReachableFromObject(JNIEnv* jni_env, jclass klass) { ExceptionCheckingJniEnvPtr ec_jni(jni_env); - jobject root = NULL; + jobject root = nullptr; int modified = 0; int found = 0; @@ -504,7 +504,7 @@ Java_nsk_jvmti_scenarios_allocation_AP04_ap04t003_runIterateOverObjectsReachable NSK_DISPLAY0("Calling IterateOverObjectsReachableFromObject...\n"); if (!NSK_JVMTI_VERIFY(jvmti->IterateOverObjectsReachableFromObject(root, objectReferenceCallback, - NULL /*user_data*/))) { + nullptr /*user_data*/))) { nsk_jvmti_setFailStatus(); } NSK_DISPLAY0("IterateOverObjectsReachableFromObject finished.\n"); @@ -531,7 +531,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni_env, void* arg) { NSK_DISPLAY1("Find debugee class: %s\n", DEBUGEE_SIGNATURE); debugeeClass = nsk_jvmti_classBySignature(DEBUGEE_SIGNATURE); - if (debugeeClass == NULL) { + if (debugeeClass == nullptr) { nsk_jvmti_setFailStatus(); return; } @@ -579,7 +579,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("counterMonitor", &counterMonitor_ptr))) { @@ -608,7 +608,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!caps.can_tag_objects) NSK_DISPLAY0("Warning: tagging objects is not available\n"); - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; NSK_DISPLAY0("agentProc has been set\n\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP05/ap05t001/ap05t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP05/ap05t001/ap05t001.cpp index b2b5f5cbb1b..64cd66bac55 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP05/ap05t001/ap05t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP05/ap05t001/ap05t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -35,13 +35,13 @@ extern "C" { #define EXP_OBJ_NUMBER 1 -static JNIEnv *jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv *jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jvmtiCapabilities caps; static jlong timeout = 0; -static jobject referrer = NULL; +static jobject referrer = nullptr; static const char* SUBCLASS_SIGNATURE = "Lnsk/jvmti/scenarios/allocation/AP05/ap05t001Subclass;"; static const int EXPECTED_STATIC_FIELDS_COUNT = 8; /* 8 ones declared in ap05t001Superclass + 8 ones declared in ap05t001Subclass */ @@ -112,14 +112,14 @@ Java_nsk_jvmti_scenarios_allocation_AP05_ap05t001_setTag(JNIEnv* jni, JNIEXPORT void JNICALL Java_nsk_jvmti_scenarios_allocation_AP05_ap05t001_setReferrer(JNIEnv* jni, jclass klass, jobject ref) { - if (!NSK_JNI_VERIFY(jni, (referrer = jni->NewGlobalRef(ref)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (referrer = jni->NewGlobalRef(ref)) != nullptr)) nsk_jvmti_setFailStatus(); } static void JNICALL agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { - jclass debugeeClass = NULL; + jclass debugeeClass = nullptr; NSK_DISPLAY0("Wait for debugee start\n\n"); if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) @@ -132,7 +132,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { if (!NSK_JVMTI_VERIFY(jvmti->IterateOverReachableObjects(heapRootCallback, stackReferenceCallback, objectReferenceCallback, - NULL /*user_data*/))) { + nullptr /*user_data*/))) { nsk_jvmti_setFailStatus(); break; } @@ -154,7 +154,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY0("\nCalling IterateOverObjectsReachableFromObject\n"); { if (!NSK_JVMTI_VERIFY(jvmti->IterateOverObjectsReachableFromObject( - referrer, objectReferenceCallback, NULL /*user_data*/))) { + referrer, objectReferenceCallback, nullptr /*user_data*/))) { nsk_jvmti_setFailStatus(); break; } @@ -200,7 +200,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; memset(&caps, 0, sizeof(jvmtiCapabilities)); @@ -215,7 +215,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!caps.can_tag_objects) NSK_DISPLAY0("Warning: tagging objects is not implemented\n"); - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; NSK_DISPLAY0("agentProc has been set\n\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP05/ap05t002/ap05t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP05/ap05t002/ap05t002.cpp index 2d625ee9e96..b3e5fe567f6 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP05/ap05t002/ap05t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP05/ap05t002/ap05t002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -35,13 +35,13 @@ extern "C" { #define EXP_OBJ_NUMBER 1 -static JNIEnv *jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv *jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jvmtiCapabilities caps; static jlong timeout = 0; -static jobject referrer = NULL; +static jobject referrer = nullptr; static const char* SUBCLASS_SIGNATURE = "Lnsk/jvmti/scenarios/allocation/AP05/ap05t002Subclass;"; static const long TAG1 = 1l, TAG2 = 2l; static int caseNumber = 0, forthRef = 0, backRef = 0; @@ -111,7 +111,7 @@ Java_nsk_jvmti_scenarios_allocation_AP05_ap05t002_setTag(JNIEnv* jni, JNIEXPORT void JNICALL Java_nsk_jvmti_scenarios_allocation_AP05_ap05t002_setReferrer(JNIEnv* jni, jclass klass, jobject ref, jint caseNum) { caseNumber = caseNum; - if (!NSK_JNI_VERIFY(jni, (referrer = jni->NewGlobalRef(ref)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (referrer = jni->NewGlobalRef(ref)) != nullptr)) nsk_jvmti_setFailStatus(); } @@ -122,7 +122,7 @@ static void runCase() { if (!NSK_JVMTI_VERIFY(jvmti->IterateOverReachableObjects(heapRootCallback, stackReferenceCallback, objectReferenceCallback, - NULL /*user_data*/))) { + nullptr /*user_data*/))) { nsk_jvmti_setFailStatus(); } if (forthRef != 1) { @@ -141,7 +141,7 @@ static void runCase() { backRef = 0; if (!NSK_JVMTI_VERIFY(jvmti->IterateOverObjectsReachableFromObject(referrer, objectReferenceCallback, - NULL /*user_data*/))) { + nullptr /*user_data*/))) { nsk_jvmti_setFailStatus(); } if (forthRef != 1) { @@ -159,7 +159,7 @@ static void runCase() { static void JNICALL agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { - jclass debugeeClass = NULL; + jclass debugeeClass = nullptr; NSK_DISPLAY0("Wait for debugee start\n\n"); if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) @@ -204,7 +204,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; memset(&caps, 0, sizeof(jvmtiCapabilities)); @@ -219,7 +219,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!caps.can_tag_objects) NSK_DISPLAY0("Warning: tagging objects is not implemented\n"); - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; NSK_DISPLAY0("agentProc has been set\n\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP06/ap06t001/ap06t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP06/ap06t001/ap06t001.cpp index b624c673683..dafd0a59b1e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP06/ap06t001/ap06t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP06/ap06t001/ap06t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -35,8 +35,8 @@ extern "C" { #define EXP_OBJ_NUMBER 1 -static JNIEnv *jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv *jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jvmtiCapabilities caps; @@ -134,7 +134,7 @@ Java_nsk_jvmti_scenarios_allocation_AP06_ap06t001Thread_setTag(JNIEnv* jni, jobj static void JNICALL agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { - jclass debugeeClass = NULL; + jclass debugeeClass = nullptr; NSK_DISPLAY0("Wait for debugee start\n\n"); if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) @@ -147,32 +147,32 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY1("Find debugee class: %s\n", DEBUGEE_SIGNATURE); debugeeClass = nsk_jvmti_classBySignature(DEBUGEE_SIGNATURE); - if (debugeeClass == NULL) { + if (debugeeClass == nullptr) { nsk_jvmti_setFailStatus(); break; } if (!NSK_JNI_VERIFY(jni, (fid = - jni->GetStaticFieldID(debugeeClass, "thread", THREAD_CLS_SIGNATURE)) != NULL)) { + jni->GetStaticFieldID(debugeeClass, "thread", THREAD_CLS_SIGNATURE)) != nullptr)) { nsk_jvmti_setFailStatus(); break; } if (!NSK_JNI_VERIFY(jni, (localRefThread = - jni->GetStaticObjectField(debugeeClass, fid)) != NULL)) { - NSK_COMPLAIN0("GetStaticObjectField returned NULL for 'thread' field value\n\n"); + jni->GetStaticObjectField(debugeeClass, fid)) != nullptr)) { + NSK_COMPLAIN0("GetStaticObjectField returned null for 'thread' field value\n\n"); nsk_jvmti_setFailStatus(); break; } - if (!NSK_JNI_VERIFY(jni, (globalRefThread = jni->NewGlobalRef(localRefThread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (globalRefThread = jni->NewGlobalRef(localRefThread)) != nullptr)) return; NSK_DISPLAY0("Calling IterateOverReachableObjects\n"); if (!NSK_JVMTI_VERIFY(jvmti->IterateOverReachableObjects(heapRootCallback, stackReferenceCallback, objectReferenceCallback, - NULL /*user_data*/))) { + nullptr /*user_data*/))) { nsk_jvmti_setFailStatus(); break; } @@ -220,7 +220,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; memset(&caps, 0, sizeof(jvmtiCapabilities)); @@ -235,7 +235,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!caps.can_tag_objects) NSK_DISPLAY0("Warning: tagging objects is not implemented\n"); - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; NSK_DISPLAY0("agentProc has been set\n\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP07/ap07t001/ap07t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP07/ap07t001/ap07t001.cpp index 52988ac2469..16831e35524 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP07/ap07t001/ap07t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP07/ap07t001/ap07t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -35,13 +35,13 @@ extern "C" { #define EXP_OBJ_NUMBER 1 -static JNIEnv *jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv *jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jvmtiCapabilities caps; static jlong timeout = 0; -static jobject root = NULL; +static jobject root = nullptr; static const char* DEBUGEE_SIGNATURE = "Lnsk/jvmti/scenarios/allocation/AP07/ap07t001;"; static const jlong IGNORE_TAG = (jlong)10l; @@ -118,14 +118,14 @@ Java_nsk_jvmti_scenarios_allocation_AP07_ap07t001_setTag(JNIEnv* jni, JNIEXPORT void JNICALL Java_nsk_jvmti_scenarios_allocation_AP07_ap07t001_setRoot(JNIEnv* jni, jobject obj) { - if (!NSK_JNI_VERIFY(jni, (root = jni->NewGlobalRef(obj)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (root = jni->NewGlobalRef(obj)) != nullptr)) nsk_jvmti_setFailStatus(); } static void JNICALL agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { - jclass debugeeClass = NULL; + jclass debugeeClass = nullptr; NSK_DISPLAY0("Wait for debugee start\n\n"); if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) @@ -137,7 +137,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { if (!NSK_JVMTI_VERIFY(jvmti->IterateOverReachableObjects(heapRootCallback, stackReferenceCallback, objectReferenceCallback, - NULL /*user_data*/))) { + nullptr /*user_data*/))) { nsk_jvmti_setFailStatus(); break; } @@ -145,7 +145,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY0("Calling IterateOverObjectsReachableFromObject\n"); { if (!NSK_JVMTI_VERIFY(jvmti->IterateOverObjectsReachableFromObject( - root, objectReferenceCallback, NULL /*user_data*/))) { + root, objectReferenceCallback, nullptr /*user_data*/))) { nsk_jvmti_setFailStatus(); break; } @@ -178,7 +178,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; memset(&caps, 0, sizeof(jvmtiCapabilities)); @@ -193,7 +193,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!caps.can_tag_objects) NSK_DISPLAY0("Warning: tagging objects is not implemented\n"); - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; NSK_DISPLAY0("agentProc has been set\n\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP07/ap07t002/ap07t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP07/ap07t002/ap07t002.cpp index 4b5e95344f1..01fbb9471ac 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP07/ap07t002/ap07t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP07/ap07t002/ap07t002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -35,13 +35,13 @@ extern "C" { #define EXP_OBJ_NUMBER 1 -static JNIEnv *jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv *jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jvmtiCapabilities caps; static jlong timeout = 0; -static jobject root = NULL; +static jobject root = nullptr; static const char* DEBUGEE_SIGNATURE = "Lnsk/jvmti/scenarios/allocation/AP07/ap07t002;"; static const jlong IGNORE_TAG = (jlong)10l; @@ -119,7 +119,7 @@ Java_nsk_jvmti_scenarios_allocation_AP07_ap07t002_setTag(JNIEnv* jni, static void JNICALL agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { - jclass debugeeClass = NULL; + jclass debugeeClass = nullptr; NSK_DISPLAY0("Wait for debugee start\n\n"); if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) @@ -131,7 +131,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { if (!NSK_JVMTI_VERIFY(jvmti->IterateOverReachableObjects(heapRootCallback, stackReferenceCallback, objectReferenceCallback, - NULL /*user_data*/))) { + nullptr /*user_data*/))) { nsk_jvmti_setFailStatus(); break; } @@ -161,7 +161,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; memset(&caps, 0, sizeof(jvmtiCapabilities)); @@ -176,7 +176,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!caps.can_tag_objects) NSK_DISPLAY0("Warning: tagging objects is not implemented\n"); - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; NSK_DISPLAY0("agentProc has been set\n\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP09/ap09t001/ap09t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP09/ap09t001/ap09t001.cpp index 00b866d1e92..229f7dba9b7 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP09/ap09t001/ap09t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP09/ap09t001/ap09t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -35,13 +35,13 @@ extern "C" { #define EXP_OBJ_NUMBER 1 -static JNIEnv *jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv *jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jvmtiCapabilities caps; static jlong timeout = 0; -static jobject referrer = NULL; +static jobject referrer = nullptr; static const char* DEBUGEE_SIGNATURE = "Lnsk/jvmti/scenarios/allocation/AP09/ap09t001;"; static const long OBJECT_TAG = 1l; static const long CLASS_TAG = 2l; @@ -139,14 +139,14 @@ Java_nsk_jvmti_scenarios_allocation_AP09_ap09t001_setTag(JNIEnv* jni, JNIEXPORT void JNICALL Java_nsk_jvmti_scenarios_allocation_AP09_ap09t001_setReferrer(JNIEnv* jni, jclass klass, jobject ref) { - if (!NSK_JNI_VERIFY(jni, (referrer = jni->NewGlobalRef(ref)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (referrer = jni->NewGlobalRef(ref)) != nullptr)) nsk_jvmti_setFailStatus(); } static void JNICALL agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { - jclass debugeeClass = NULL; + jclass debugeeClass = nullptr; NSK_DISPLAY0("Wait for debugee start\n\n"); if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) @@ -156,7 +156,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { NSK_DISPLAY0("\nCalling IterateOverObjectsReachableFromObject\n"); if (!NSK_JVMTI_VERIFY(jvmti->IterateOverObjectsReachableFromObject(referrer, objectReferenceCallback, - NULL /*user_data*/))) { + nullptr /*user_data*/))) { nsk_jvmti_setFailStatus(); } if (!classFound) { @@ -214,7 +214,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; memset(&caps, 0, sizeof(jvmtiCapabilities)); @@ -231,7 +231,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; NSK_DISPLAY0("agentProc has been set\n\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP10/ap10t001/ap10t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP10/ap10t001/ap10t001.cpp index d4977a45a26..fdc0e50273c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP10/ap10t001/ap10t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP10/ap10t001/ap10t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ extern "C" { #define MAX_SIZE 256 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jvmtiCapabilities caps; @@ -56,7 +56,7 @@ typedef struct _LocalStorage { static LocalStorage stor; static void envStorageFunc(jvmtiEnv *jvmti_env, const char *msg) { - LocalStorage* obtainedData = NULL; + LocalStorage* obtainedData = nullptr; LocalStorage* storedData = &stor; NSK_DISPLAY2("%s: setting an environment local storage 0x%p ...\n", @@ -259,7 +259,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add capability to generate compiled method events */ @@ -296,19 +296,19 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { NSK_DISPLAY0("setting event callbacks done\nenabling JVMTI events ...\n"); if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_START, - NULL))) + nullptr))) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_FINISH, - NULL))) + nullptr))) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_OBJECT_FREE, - NULL))) + nullptr))) return JNI_ERR; NSK_DISPLAY0("enabling the events done\n\n"); - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP11/ap11t001/ap11t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP11/ap11t001/ap11t001.cpp index 8f9d67ac6cf..59b35902bad 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP11/ap11t001/ap11t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP11/ap11t001/ap11t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,14 +46,14 @@ static int lookup(jvmtiEnv* jvmti, if (!NSK_JVMTI_VERIFY(jvmti->GetClassSignature(classes[i], &signature, &generic))) break; - if (signature != NULL && strcmp(signature, exp_sig) == 0) { + if (signature != nullptr && strcmp(signature, exp_sig) == 0) { found = NSK_TRUE; } - if (signature != NULL) + if (signature != nullptr) jvmti->Deallocate((unsigned char*)signature); - if (generic != NULL) + if (generic != nullptr) jvmti->Deallocate((unsigned char*)generic); } @@ -141,7 +141,7 @@ VMObjectAlloc(jvmtiEnv *jvmti, JNIEnv* jni, jthread thread, jobject object, return; } - if (classes != NULL) + if (classes != nullptr) jvmti->Deallocate((unsigned char*)classes); } while (0); @@ -174,10 +174,10 @@ VMObjectAlloc(jvmtiEnv *jvmti, JNIEnv* jni, jthread thread, jobject object, } } while (0); - if (signature != NULL) + if (signature != nullptr) jvmti->Deallocate((unsigned char*)signature); - if (generic != NULL) + if (generic != nullptr) jvmti->Deallocate((unsigned char*)generic); } @@ -210,7 +210,7 @@ JNIEXPORT jint JNI_OnLoad_ap11t001(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiCapabilities caps; jvmtiEventCallbacks callbacks; @@ -223,7 +223,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; memset(&caps, 0, sizeof(caps)); @@ -239,11 +239,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* enable VMObjectAlloc event */ if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_OBJECT_ALLOC, NULL))) + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_OBJECT_ALLOC, nullptr))) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP12/ap12t001/ap12t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP12/ap12t001/ap12t001.cpp index b5236d993c1..c34bb8891f6 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP12/ap12t001/ap12t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP12/ap12t001/ap12t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,8 +39,8 @@ extern "C" { #define EXP_OBJ_FREE 2 -static JNIEnv *jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv *jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jvmtiCapabilities caps; @@ -89,7 +89,7 @@ Java_nsk_jvmti_scenarios_allocation_AP12_ap12t001_flushObjectFreeEvents(JNIEnv* // Already enabled, but this triggers flush of pending events. if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_OBJECT_FREE, - NULL))) { + nullptr))) { nsk_jvmti_setFailStatus(); } } @@ -97,7 +97,7 @@ Java_nsk_jvmti_scenarios_allocation_AP12_ap12t001_flushObjectFreeEvents(JNIEnv* static void JNICALL agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { - jclass debugeeClass = NULL; + jclass debugeeClass = nullptr; NSK_DISPLAY0("Wait for debugee start\n\n"); if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) @@ -132,7 +132,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; memset(&caps, 0, sizeof(jvmtiCapabilities)); @@ -162,15 +162,15 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { NSK_DISPLAY0("setting event callbacks done\nenabling JVMTI events ...\n"); if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_OBJECT_FREE, - NULL))) + nullptr))) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, - NULL))) + nullptr))) return JNI_ERR; NSK_DISPLAY0("enabling the events done\n\n"); - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; NSK_DISPLAY0("agentProc has been set\n\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI01/bi01t001/bi01t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI01/bi01t001/bi01t001.cpp index 0ba4c3c442d..951d0c6c7c9 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI01/bi01t001/bi01t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI01/bi01t001/bi01t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ extern "C" { /* scaffold objects */ -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; #define TESTED_CLASS_NAME "nsk/jvmti/scenarios/bcinstr/BI01/bi01t001a" @@ -106,7 +106,7 @@ cbClassFileLoadHook(jvmtiEnv *jvmti_env, JNIEnv* jni_env, const unsigned char* class_data, jint* new_class_data_len, unsigned char** new_class_data) { - if (name == NULL || strcmp(name, TESTED_CLASS_NAME)) { + if (name == nullptr || strcmp(name, TESTED_CLASS_NAME)) { return; } @@ -175,7 +175,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* agentJNI, void* arg) { NSK_DISPLAY0("Notification disabled for CLASS_FILE_LOAD_HOOK event\n"); if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, - NULL))) { + nullptr))) { nsk_jvmti_setFailStatus(); return; } @@ -240,7 +240,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; { @@ -267,12 +267,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { NSK_DISPLAY0("Set notification enabled for CLASS_FILE_LOAD_HOOK event\n"); if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, - NULL))) { + nullptr))) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI01/bi01t002/bi01t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI01/bi01t002/bi01t002.cpp index ca26caaa89b..2a3aab3a08d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI01/bi01t002/bi01t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI01/bi01t002/bi01t002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ extern "C" { /* scaffold objects */ -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; #define TESTED_CLASS_NAME "nsk/jvmti/scenarios/bcinstr/BI01/bi01t002a" @@ -109,7 +109,7 @@ cbClassFileLoadHook(jvmtiEnv *jvmti_env, JNIEnv* jni_env, const unsigned char* class_data, jint* new_class_data_len, unsigned char** new_class_data) { - if (name == NULL || strcmp(name, TESTED_CLASS_NAME)) { + if (name == nullptr || strcmp(name, TESTED_CLASS_NAME)) { return; } @@ -183,7 +183,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* agentJNI, void* arg) { NSK_DISPLAY0("Notification disabled for CLASS_FILE_LOAD_HOOK event\n"); if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, - NULL))) { + nullptr))) { nsk_jvmti_setFailStatus(); return; } @@ -253,7 +253,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; { @@ -280,12 +280,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { NSK_DISPLAY0("Set notification enabled for CLASS_FILE_LOAD_HOOK event\n"); if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, - NULL))) { + nullptr))) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI02/bi02t001/bi02t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI02/bi02t001/bi02t001.cpp index 66347ffdfef..6e732377021 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI02/bi02t001/bi02t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI02/bi02t001/bi02t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,8 +38,8 @@ extern "C" { static jlong timeout = 0; /* test objects */ -static jclass debugeeClass = NULL; -static jbyteArray classBytes = NULL; +static jclass debugeeClass = nullptr; +static jbyteArray classBytes = nullptr; static int ClassFileLoadHookEventFlag = NSK_FALSE; const char* CLASS_NAME = "nsk/jvmti/scenarios/bcinstr/BI02/bi02t001a"; @@ -55,11 +55,11 @@ ClassFileLoadHook(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jint class_data_len, const unsigned char* class_data, jint *new_class_data_len, unsigned char** new_class_data) { - if (name != NULL && (strcmp(name, CLASS_NAME) == 0)) { + if (name != nullptr && (strcmp(name, CLASS_NAME) == 0)) { ClassFileLoadHookEventFlag = NSK_TRUE; NSK_DISPLAY0("ClassFileLoadHook event\n"); - if (class_being_redefined == NULL) { + if (class_being_redefined == nullptr) { /* sent by class load */ if (!NSK_JNI_VERIFY(jni_env, (*new_class_data_len = @@ -69,7 +69,7 @@ ClassFileLoadHook(jvmtiEnv *jvmti_env, JNIEnv *jni_env, } if (!NSK_JNI_VERIFY(jni_env, (*new_class_data = (unsigned char*) - jni_env->GetByteArrayElements(classBytes, NULL)) != NULL)) { + jni_env->GetByteArrayElements(classBytes, nullptr)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -82,29 +82,29 @@ ClassFileLoadHook(jvmtiEnv *jvmti_env, JNIEnv *jni_env, static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { const char* DEBUGEE_CLASS_NAME = "nsk/jvmti/scenarios/bcinstr/BI02/bi02t001"; - jfieldID field = NULL; + jfieldID field = nullptr; NSK_DISPLAY1("Find class: %s\n", DEBUGEE_CLASS_NAME); - if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (debugeeClass = (jclass)jni->NewGlobalRef(debugeeClass)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (debugeeClass = (jclass)jni->NewGlobalRef(debugeeClass)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (field = - jni->GetStaticFieldID(debugeeClass, "newClassBytes", "[B")) != NULL)) + jni->GetStaticFieldID(debugeeClass, "newClassBytes", "[B")) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (classBytes = (jbyteArray) - jni->GetStaticObjectField(debugeeClass, field)) != NULL)) + jni->GetStaticObjectField(debugeeClass, field)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (classBytes = (jbyteArray)jni->NewGlobalRef(classBytes)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (classBytes = (jbyteArray)jni->NewGlobalRef(classBytes)) != nullptr)) return NSK_FALSE; if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, - NULL))) + nullptr))) return JNI_ERR; return NSK_TRUE; @@ -137,7 +137,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, - NULL))) + nullptr))) nsk_jvmti_setFailStatus(); NSK_TRACE(jni->DeleteGlobalRef(debugeeClass)); @@ -162,7 +162,7 @@ JNIEXPORT jint JNI_OnLoad_bi02t001(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiEventCallbacks callbacks; jvmtiCapabilities caps; @@ -174,7 +174,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; memset(&caps, 0, sizeof(caps)); @@ -182,7 +182,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&callbacks, 0, sizeof(callbacks)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI02/bi02t002/bi02t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI02/bi02t002/bi02t002.cpp index 2b594da6407..197d776cb45 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI02/bi02t002/bi02t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI02/bi02t002/bi02t002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,9 +38,9 @@ extern "C" { static jlong timeout = 0; /* test objects */ -static jclass debugeeClass = NULL; -static jclass testedClass = NULL; -static jbyteArray classBytes = NULL; +static jclass debugeeClass = nullptr; +static jclass testedClass = nullptr; +static jbyteArray classBytes = nullptr; const char* CLASS_NAME = "nsk/jvmti/scenarios/bcinstr/BI02/bi02t002a"; @@ -49,31 +49,31 @@ const char* CLASS_NAME = "nsk/jvmti/scenarios/bcinstr/BI02/bi02t002a"; static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { const char* DEBUGEE_CLASS_NAME = "nsk/jvmti/scenarios/bcinstr/BI02/bi02t002"; - jfieldID field = NULL; + jfieldID field = nullptr; NSK_DISPLAY1("Find class: %s\n", DEBUGEE_CLASS_NAME); - if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (debugeeClass = (jclass)jni->NewGlobalRef(debugeeClass)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (debugeeClass = (jclass)jni->NewGlobalRef(debugeeClass)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (field = - jni->GetStaticFieldID(debugeeClass, "newClassBytes", "[B")) != NULL)) + jni->GetStaticFieldID(debugeeClass, "newClassBytes", "[B")) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (classBytes = (jbyteArray) - jni->GetStaticObjectField(debugeeClass, field)) != NULL)) + jni->GetStaticObjectField(debugeeClass, field)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (classBytes = (jbyteArray)jni->NewGlobalRef(classBytes)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (classBytes = (jbyteArray)jni->NewGlobalRef(classBytes)) != nullptr)) return NSK_FALSE; NSK_DISPLAY1("Find class: %s\n", CLASS_NAME); - if (!NSK_JNI_VERIFY(jni, (testedClass = jni->FindClass(CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (testedClass = jni->FindClass(CLASS_NAME)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (testedClass = (jclass)jni->NewGlobalRef(testedClass)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (testedClass = (jclass)jni->NewGlobalRef(testedClass)) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -90,7 +90,7 @@ static int redefine(jvmtiEnv* jvmti, JNIEnv* jni) { return NSK_TRUE; if (!NSK_JNI_VERIFY(jni, (class_def.class_bytes = (unsigned char*) - jni->GetByteArrayElements(classBytes, NULL)) != NULL)) + jni->GetByteArrayElements(classBytes, nullptr)) != nullptr)) return NSK_TRUE; class_def.klass = testedClass; @@ -146,7 +146,7 @@ JNIEXPORT jint JNI_OnLoad_bi02t002(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiCapabilities caps; NSK_DISPLAY0("Agent_OnLoad\n"); @@ -157,7 +157,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; memset(&caps, 0, sizeof(caps)); @@ -165,7 +165,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI03/bi03t001/bi03t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI03/bi03t001/bi03t001.cpp index f7e91f623e0..b302186df58 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI03/bi03t001/bi03t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI03/bi03t001/bi03t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,8 +38,8 @@ extern "C" { static jlong timeout = 0; /* test objects */ -static jclass debugeeClass = NULL; -static jbyteArray classBytes = NULL; +static jclass debugeeClass = nullptr; +static jbyteArray classBytes = nullptr; static int ClassFileLoadHookEventFlag = NSK_FALSE; const char* CLASS_NAME = "nsk/jvmti/scenarios/bcinstr/BI03/bi03t001a"; @@ -55,11 +55,11 @@ ClassFileLoadHook(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jint class_data_len, const unsigned char* class_data, jint *new_class_data_len, unsigned char** new_class_data) { - if (name != NULL && (strcmp(name, CLASS_NAME) == 0)) { + if (name != nullptr && (strcmp(name, CLASS_NAME) == 0)) { ClassFileLoadHookEventFlag = NSK_TRUE; NSK_DISPLAY0("ClassFileLoadHook event\n"); - if (class_being_redefined == NULL) { + if (class_being_redefined == nullptr) { /* sent by class load */ if (!NSK_JNI_VERIFY(jni_env, (*new_class_data_len = @@ -69,7 +69,7 @@ ClassFileLoadHook(jvmtiEnv *jvmti_env, JNIEnv *jni_env, } if (!NSK_JNI_VERIFY(jni_env, (*new_class_data = (unsigned char*) - jni_env->GetByteArrayElements(classBytes, NULL)) != NULL)) { + jni_env->GetByteArrayElements(classBytes, nullptr)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -82,29 +82,29 @@ ClassFileLoadHook(jvmtiEnv *jvmti_env, JNIEnv *jni_env, static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { const char* DEBUGEE_CLASS_NAME = "nsk/jvmti/scenarios/bcinstr/BI03/bi03t001"; - jfieldID field = NULL; + jfieldID field = nullptr; NSK_DISPLAY1("Find class: %s\n", DEBUGEE_CLASS_NAME); - if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (debugeeClass = (jclass)jni->NewGlobalRef(debugeeClass)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (debugeeClass = (jclass)jni->NewGlobalRef(debugeeClass)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (field = - jni->GetStaticFieldID(debugeeClass, "newClassBytes", "[B")) != NULL)) + jni->GetStaticFieldID(debugeeClass, "newClassBytes", "[B")) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (classBytes = (jbyteArray) - jni->GetStaticObjectField(debugeeClass, field)) != NULL)) + jni->GetStaticObjectField(debugeeClass, field)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (classBytes = (jbyteArray)jni->NewGlobalRef(classBytes)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (classBytes = (jbyteArray)jni->NewGlobalRef(classBytes)) != nullptr)) return NSK_FALSE; if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, - NULL))) + nullptr))) return JNI_ERR; return NSK_TRUE; @@ -137,7 +137,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, - NULL))) + nullptr))) nsk_jvmti_setFailStatus(); NSK_TRACE(jni->DeleteGlobalRef(debugeeClass)); @@ -162,7 +162,7 @@ JNIEXPORT jint JNI_OnLoad_bi03t001(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiEventCallbacks callbacks; jvmtiCapabilities caps; @@ -174,7 +174,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; memset(&caps, 0, sizeof(caps)); @@ -182,7 +182,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&callbacks, 0, sizeof(callbacks)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI03/bi03t002/bi03t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI03/bi03t002/bi03t002.cpp index 07adb527a71..575ebead06e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI03/bi03t002/bi03t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI03/bi03t002/bi03t002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,9 +38,9 @@ extern "C" { static jlong timeout = 0; /* test objects */ -static jclass debugeeClass = NULL; -static jclass testedClass = NULL; -static jbyteArray classBytes = NULL; +static jclass debugeeClass = nullptr; +static jclass testedClass = nullptr; +static jbyteArray classBytes = nullptr; const char* CLASS_NAME = "nsk/jvmti/scenarios/bcinstr/BI03/bi03t002a"; @@ -49,31 +49,31 @@ const char* CLASS_NAME = "nsk/jvmti/scenarios/bcinstr/BI03/bi03t002a"; static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { const char* DEBUGEE_CLASS_NAME = "nsk/jvmti/scenarios/bcinstr/BI03/bi03t002"; - jfieldID field = NULL; + jfieldID field = nullptr; NSK_DISPLAY1("Find class: %s\n", DEBUGEE_CLASS_NAME); - if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (debugeeClass = (jclass)jni->NewGlobalRef(debugeeClass)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (debugeeClass = (jclass)jni->NewGlobalRef(debugeeClass)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (field = - jni->GetStaticFieldID(debugeeClass, "newClassBytes", "[B")) != NULL)) + jni->GetStaticFieldID(debugeeClass, "newClassBytes", "[B")) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (classBytes = (jbyteArray) - jni->GetStaticObjectField(debugeeClass, field)) != NULL)) + jni->GetStaticObjectField(debugeeClass, field)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (classBytes = (jbyteArray)jni->NewGlobalRef(classBytes)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (classBytes = (jbyteArray)jni->NewGlobalRef(classBytes)) != nullptr)) return NSK_FALSE; NSK_DISPLAY1("Find class: %s\n", CLASS_NAME); - if (!NSK_JNI_VERIFY(jni, (testedClass = jni->FindClass(CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (testedClass = jni->FindClass(CLASS_NAME)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (testedClass = (jclass)jni->NewGlobalRef(testedClass)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (testedClass = (jclass)jni->NewGlobalRef(testedClass)) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -90,7 +90,7 @@ static int redefine(jvmtiEnv* jvmti, JNIEnv* jni) { return NSK_TRUE; if (!NSK_JNI_VERIFY(jni, (class_def.class_bytes = (unsigned char*) - jni->GetByteArrayElements(classBytes, NULL)) != NULL)) + jni->GetByteArrayElements(classBytes, nullptr)) != nullptr)) return NSK_TRUE; class_def.klass = testedClass; @@ -146,7 +146,7 @@ JNIEXPORT jint JNI_OnLoad_bi03t002(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiCapabilities caps; NSK_DISPLAY0("Agent_OnLoad\n"); @@ -157,7 +157,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; memset(&caps, 0, sizeof(caps)); @@ -165,7 +165,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI04/bi04t002/bi04t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI04/bi04t002/bi04t002.cpp index c87fc546b90..6bb7ba83406 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI04/bi04t002/bi04t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI04/bi04t002/bi04t002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -61,7 +61,7 @@ int readNewBytecode(jvmtiEnv* jvmti) { filename); bytecode = fopen(filename, "rb"); - if (bytecode == NULL) { + if (bytecode == nullptr) { NSK_COMPLAIN0("error opening file\n"); return NSK_FALSE; } @@ -137,7 +137,7 @@ JNIEXPORT jint JNI_OnLoad_bi04t002(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv *jvmti = NULL; + jvmtiEnv *jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -145,7 +145,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; { @@ -161,7 +161,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!NSK_VERIFY(readNewBytecode(jvmti))) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t001/cm01t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t001/cm01t001.cpp index a59b82a5c5c..2d6978c2a0e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t001/cm01t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t001/cm01t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,22 +57,22 @@ extern "C" { /* ========================================================================== */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* test objects */ -static jthread thread = NULL; -static jclass klass = NULL; -static jmethodID method = NULL; -static jfieldID field = NULL; +static jthread thread = nullptr; +static jclass klass = nullptr; +static jmethodID method = nullptr; +static jfieldID field = nullptr; /* ========================================================================== */ static int prepare() { const char* THREAD_NAME = "Debuggee Thread"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; int i; @@ -82,12 +82,12 @@ static int prepare() { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -97,7 +97,7 @@ static int prepare() { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) { + if (info.name != nullptr && (strcmp(info.name, THREAD_NAME) == 0)) { thread = threads[i]; } } @@ -107,16 +107,16 @@ static int prepare() { return NSK_FALSE; /* get tested thread class */ - if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != nullptr)) return NSK_FALSE; /* get tested thread method 'run' */ - if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != NULL)) + if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != nullptr)) return NSK_FALSE; /* get tested thread field 'waitingMonitor' */ if (!NSK_JNI_VERIFY(jni, (field = - jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != NULL)) + jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -156,18 +156,18 @@ static int checkSignalThread() { const char* THREAD_DEATH_CLASS_NAME = "java/lang/ThreadDeath"; const char* THREAD_DEATH_CTOR_NAME = ""; const char* THREAD_DEATH_CTOR_SIGNATURE = "()V"; - jclass cls = NULL; - jmethodID ctor = NULL; - jobject exception = NULL; + jclass cls = nullptr; + jmethodID ctor = nullptr; + jobject exception = nullptr; - if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (ctor = - jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != NULL)) + jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != nullptr)) return NSK_FALSE; NSK_DISPLAY0("Checking negative: StopThread\n"); @@ -186,7 +186,7 @@ static int checkSignalThread() { */ static int checkGetOwnedMonitorInfo() { jint count; - jobject *monitors = NULL; + jobject *monitors = nullptr; NSK_DISPLAY0("Checking negative: GetOwnedMonitorInfo\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -199,7 +199,7 @@ static int checkGetOwnedMonitorInfo() { /* Check "can_get_current_contended_monitor" function */ static int checkGetCurrentContendedMonitor() { - jobject monitor = NULL; + jobject monitor = nullptr; NSK_DISPLAY0("Checking negative: GetCurrentContendedMonitor\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -251,8 +251,8 @@ static int checkHeapFunctions() { const jlong TAG_VALUE = (123456789L); jlong tag; jint count; - jobject *res_objects = NULL; - jlong *res_tags = NULL; + jobject *res_objects = nullptr; + jlong *res_tags = nullptr; jint dummy_user_data = 0; NSK_DISPLAY0("Checking positive: SetTag\n"); @@ -295,7 +295,7 @@ static int checkHeapFunctions() { */ static int checkLocalVariableFunctions() { jint count; - jvmtiLocalVariableEntry *local_variable_table = NULL; + jvmtiLocalVariableEntry *local_variable_table = nullptr; jobject object_value; jint int_value; jlong long_value; @@ -365,7 +365,7 @@ static int checkLocalVariableFunctions() { static int checkSourceInfoFunctions() { char *name; jint count; - jvmtiLineNumberEntry *line_number_table = NULL; + jvmtiLineNumberEntry *line_number_table = nullptr; NSK_DISPLAY0("Checking negative: GetSourceFileName\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -393,7 +393,7 @@ static int checkRedefineClasses() { NSK_DISPLAY0("Checking negative: RedefineClasses\n"); class_def.klass = klass; class_def.class_byte_count = 0; - class_def.class_bytes = NULL; + class_def.class_bytes = nullptr; if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, jvmti->RedefineClasses(1, &class_def))) return NSK_FALSE; @@ -565,11 +565,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; /* testcase #1: check GetPotentialCapabilities */ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t002/cm01t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t002/cm01t002.cpp index 63252c7765c..45761319f04 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t002/cm01t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t002/cm01t002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -50,22 +50,22 @@ extern "C" { /* ========================================================================== */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* test objects */ -static jthread thread = NULL; -static jclass klass = NULL; -static jmethodID method = NULL; -static jfieldID field = NULL; +static jthread thread = nullptr; +static jclass klass = nullptr; +static jmethodID method = nullptr; +static jfieldID field = nullptr; /* ========================================================================== */ static int prepare() { const char* THREAD_NAME = "Debuggee Thread"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; int i; @@ -75,12 +75,12 @@ static int prepare() { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -90,7 +90,7 @@ static int prepare() { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) { + if (info.name != nullptr && (strcmp(info.name, THREAD_NAME) == 0)) { thread = threads[i]; } } @@ -99,22 +99,22 @@ static int prepare() { if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threads))) return NSK_FALSE; - if (thread == NULL) { + if (thread == nullptr) { nsk_lcomplain(__FILE__, __LINE__, "tested thread not found\n"); return NSK_FALSE; } /* get tested thread class */ - if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != nullptr)) return NSK_FALSE; /* get tested thread method 'run' */ - if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != NULL)) + if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != nullptr)) return NSK_FALSE; /* get tested thread field 'waitingMonitor' */ if (!NSK_JNI_VERIFY(jni, (field = - jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != NULL)) + jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -154,18 +154,18 @@ static int checkSignalThread() { const char* THREAD_DEATH_CLASS_NAME = "java/lang/ThreadDeath"; const char* THREAD_DEATH_CTOR_NAME = ""; const char* THREAD_DEATH_CTOR_SIGNATURE = "()V"; - jclass cls = NULL; - jmethodID ctor = NULL; - jobject exception = NULL; + jclass cls = nullptr; + jmethodID ctor = nullptr; + jobject exception = nullptr; - if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (ctor = - jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != NULL)) + jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != nullptr)) return NSK_FALSE; NSK_DISPLAY0("Checking negative: StopThread\n"); @@ -184,7 +184,7 @@ static int checkSignalThread() { */ static int checkGetOwnedMonitorInfo() { jint count; - jobject *monitors = NULL; + jobject *monitors = nullptr; NSK_DISPLAY0("Checking negative: GetOwnedMonitorInfo\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -197,7 +197,7 @@ static int checkGetOwnedMonitorInfo() { /* Check "can_get_current_contended_monitor" function */ static int checkGetCurrentContendedMonitor() { - jobject monitor = NULL; + jobject monitor = nullptr; NSK_DISPLAY0("Checking negative: GetCurrentContendedMonitor\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -249,8 +249,8 @@ static int checkHeapFunctions() { const jlong TAG_VALUE = (123456789L); jlong tag; jint count; - jobject *res_objects = NULL; - jlong *res_tags = NULL; + jobject *res_objects = nullptr; + jlong *res_tags = nullptr; jint dummy_user_data = 0; NSK_DISPLAY0("Checking negative: SetTag\n"); @@ -303,7 +303,7 @@ static int checkHeapFunctions() { */ static int checkLocalVariableFunctions() { jint count; - jvmtiLocalVariableEntry *local_variable_table = NULL; + jvmtiLocalVariableEntry *local_variable_table = nullptr; jobject object_value; jint int_value; jlong long_value; @@ -373,7 +373,7 @@ static int checkLocalVariableFunctions() { static int checkSourceInfoFunctions() { char *name; jint count; - jvmtiLineNumberEntry *line_number_table = NULL; + jvmtiLineNumberEntry *line_number_table = nullptr; NSK_DISPLAY0("Checking negative: GetSourceFileName\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -401,7 +401,7 @@ static int checkRedefineClasses() { NSK_DISPLAY0("Checking negative: RedefineClasses\n"); class_def.klass = klass; class_def.class_byte_count = 0; - class_def.class_bytes = NULL; + class_def.class_bytes = nullptr; if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, jvmti->RedefineClasses(1, &class_def))) return NSK_FALSE; @@ -574,11 +574,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; /* testcase #1: check GetPotentialCapabilities */ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t003/cm01t003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t003/cm01t003.cpp index f92d0d29805..7580d3f6a93 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t003/cm01t003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t003/cm01t003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,22 +52,22 @@ extern "C" { /* ========================================================================== */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* test objects */ -static jthread thread = NULL; -static jclass klass = NULL; -static jmethodID method = NULL; -static jfieldID field = NULL; +static jthread thread = nullptr; +static jclass klass = nullptr; +static jmethodID method = nullptr; +static jfieldID field = nullptr; /* ========================================================================== */ static int prepare() { const char* THREAD_NAME = "Debuggee Thread"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; int i; @@ -77,12 +77,12 @@ static int prepare() { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -92,7 +92,7 @@ static int prepare() { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) { + if (info.name != nullptr && (strcmp(info.name, THREAD_NAME) == 0)) { thread = threads[i]; } } @@ -102,16 +102,16 @@ static int prepare() { return NSK_FALSE; /* get tested thread class */ - if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != nullptr)) return NSK_FALSE; /* get tested thread method 'run' */ - if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != NULL)) + if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != nullptr)) return NSK_FALSE; /* get tested thread field 'waitingMonitor' */ if (!NSK_JNI_VERIFY(jni, (field = - jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != NULL)) + jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -151,18 +151,18 @@ static int checkSignalThread() { const char* THREAD_DEATH_CLASS_NAME = "java/lang/ThreadDeath"; const char* THREAD_DEATH_CTOR_NAME = ""; const char* THREAD_DEATH_CTOR_SIGNATURE = "()V"; - jclass cls = NULL; - jmethodID ctor = NULL; - jobject exception = NULL; + jclass cls = nullptr; + jmethodID ctor = nullptr; + jobject exception = nullptr; - if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (ctor = - jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != NULL)) + jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != nullptr)) return NSK_FALSE; NSK_DISPLAY0("Checking negative: StopThread\n"); @@ -181,7 +181,7 @@ static int checkSignalThread() { */ static int checkGetOwnedMonitorInfo() { jint count; - jobject *monitors = NULL; + jobject *monitors = nullptr; NSK_DISPLAY0("Checking negative: GetOwnedMonitorInfo\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -194,7 +194,7 @@ static int checkGetOwnedMonitorInfo() { /* Check "can_get_current_contended_monitor" function */ static int checkGetCurrentContendedMonitor() { - jobject monitor = NULL; + jobject monitor = nullptr; NSK_DISPLAY0("Checking negative: GetCurrentContendedMonitor\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -246,8 +246,8 @@ static int checkHeapFunctions() { const jlong TAG_VALUE = (123456789L); jlong tag; jint count; - jobject *res_objects = NULL; - jlong *res_tags = NULL; + jobject *res_objects = nullptr; + jlong *res_tags = nullptr; jint dummy_user_data = 0; NSK_DISPLAY0("Checking negative: SetTag\n"); @@ -300,7 +300,7 @@ static int checkHeapFunctions() { */ static int checkLocalVariableFunctions() { jint count; - jvmtiLocalVariableEntry *local_variable_table = NULL; + jvmtiLocalVariableEntry *local_variable_table = nullptr; jobject object_value; jint int_value; jlong long_value; @@ -370,7 +370,7 @@ static int checkLocalVariableFunctions() { static int checkSourceInfoFunctions() { char *name; jint count; - jvmtiLineNumberEntry *line_number_table = NULL; + jvmtiLineNumberEntry *line_number_table = nullptr; NSK_DISPLAY0("Checking negative: GetSourceFileName\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -398,7 +398,7 @@ static int checkRedefineClasses() { NSK_DISPLAY0("Checking negative: RedefineClasses\n"); class_def.klass = klass; class_def.class_byte_count = 0; - class_def.class_bytes = NULL; + class_def.class_bytes = nullptr; if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, jvmti->RedefineClasses(1, &class_def))) return NSK_FALSE; @@ -568,11 +568,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; /* testcase #1: check GetPotentialCapabilities */ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t004/cm01t004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t004/cm01t004.cpp index 6b52f4c9695..a5b7072692a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t004/cm01t004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t004/cm01t004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -50,22 +50,22 @@ extern "C" { /* ========================================================================== */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* test objects */ -static jthread thread = NULL; -static jclass klass = NULL; -static jmethodID method = NULL; -static jfieldID field = NULL; +static jthread thread = nullptr; +static jclass klass = nullptr; +static jmethodID method = nullptr; +static jfieldID field = nullptr; /* ========================================================================== */ static int prepare() { const char* THREAD_NAME = "Debuggee Thread"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; int i; @@ -75,12 +75,12 @@ static int prepare() { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -90,7 +90,7 @@ static int prepare() { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) { + if (info.name != nullptr && (strcmp(info.name, THREAD_NAME) == 0)) { thread = threads[i]; } } @@ -100,16 +100,16 @@ static int prepare() { return NSK_FALSE; /* get tested thread class */ - if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != nullptr)) return NSK_FALSE; /* get tested thread method 'run' */ - if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != NULL)) + if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != nullptr)) return NSK_FALSE; /* get tested thread field 'waitingMonitor' */ if (!NSK_JNI_VERIFY(jni, (field = - jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != NULL)) + jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -149,18 +149,18 @@ static int checkSignalThread() { const char* THREAD_DEATH_CLASS_NAME = "java/lang/ThreadDeath"; const char* THREAD_DEATH_CTOR_NAME = ""; const char* THREAD_DEATH_CTOR_SIGNATURE = "()V"; - jclass cls = NULL; - jmethodID ctor = NULL; - jobject exception = NULL; + jclass cls = nullptr; + jmethodID ctor = nullptr; + jobject exception = nullptr; - if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (ctor = - jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != NULL)) + jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != nullptr)) return NSK_FALSE; NSK_DISPLAY0("Checking negative: StopThread\n"); @@ -179,7 +179,7 @@ static int checkSignalThread() { */ static int checkGetOwnedMonitorInfo() { jint count; - jobject *monitors = NULL; + jobject *monitors = nullptr; NSK_DISPLAY0("Checking positive: GetOwnedMonitorInfo\n"); if (!NSK_JVMTI_VERIFY(jvmti->GetOwnedMonitorInfo(thread, &count, &monitors))) @@ -191,7 +191,7 @@ static int checkGetOwnedMonitorInfo() { /* Check "can_get_current_contended_monitor" function */ static int checkGetCurrentContendedMonitor() { - jobject monitor = NULL; + jobject monitor = nullptr; NSK_DISPLAY0("Checking negative: GetCurrentContendedMonitor\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -243,8 +243,8 @@ static int checkHeapFunctions() { const jlong TAG_VALUE = (123456789L); jlong tag; jint count; - jobject *res_objects = NULL; - jlong *res_tags = NULL; + jobject *res_objects = nullptr; + jlong *res_tags = nullptr; jint dummy_user_data = 0; NSK_DISPLAY0("Checking negative: SetTag\n"); @@ -297,7 +297,7 @@ static int checkHeapFunctions() { */ static int checkLocalVariableFunctions() { jint count; - jvmtiLocalVariableEntry *local_variable_table = NULL; + jvmtiLocalVariableEntry *local_variable_table = nullptr; jobject object_value; jint int_value; jlong long_value; @@ -367,7 +367,7 @@ static int checkLocalVariableFunctions() { static int checkSourceInfoFunctions() { char *name; jint count; - jvmtiLineNumberEntry *line_number_table = NULL; + jvmtiLineNumberEntry *line_number_table = nullptr; NSK_DISPLAY0("Checking negative: GetSourceFileName\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -395,7 +395,7 @@ static int checkRedefineClasses() { NSK_DISPLAY0("Checking negative: RedefineClasses\n"); class_def.klass = klass; class_def.class_byte_count = 0; - class_def.class_bytes = NULL; + class_def.class_bytes = nullptr; if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, jvmti->RedefineClasses(1, &class_def))) return NSK_FALSE; @@ -567,11 +567,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; /* testcase #1: check GetPotentialCapabilities */ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t005/cm01t005.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t005/cm01t005.cpp index adbb0d83cba..b91e949a8c1 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t005/cm01t005.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t005/cm01t005.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -50,22 +50,22 @@ extern "C" { /* ========================================================================== */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* test objects */ -static jthread thread = NULL; -static jclass klass = NULL; -static jmethodID method = NULL; -static jfieldID field = NULL; +static jthread thread = nullptr; +static jclass klass = nullptr; +static jmethodID method = nullptr; +static jfieldID field = nullptr; /* ========================================================================== */ static int prepare() { const char* THREAD_NAME = "Debuggee Thread"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; int i; @@ -75,12 +75,12 @@ static int prepare() { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -90,7 +90,7 @@ static int prepare() { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) { + if (info.name != nullptr && (strcmp(info.name, THREAD_NAME) == 0)) { thread = threads[i]; } } @@ -100,16 +100,16 @@ static int prepare() { return NSK_FALSE; /* get tested thread class */ - if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != nullptr)) return NSK_FALSE; /* get tested thread method 'run' */ - if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != NULL)) + if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != nullptr)) return NSK_FALSE; /* get tested thread field 'waitingMonitor' */ if (!NSK_JNI_VERIFY(jni, (field = - jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != NULL)) + jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -149,18 +149,18 @@ static int checkSignalThread() { const char* THREAD_DEATH_CLASS_NAME = "java/lang/ThreadDeath"; const char* THREAD_DEATH_CTOR_NAME = ""; const char* THREAD_DEATH_CTOR_SIGNATURE = "()V"; - jclass cls = NULL; - jmethodID ctor = NULL; - jobject exception = NULL; + jclass cls = nullptr; + jmethodID ctor = nullptr; + jobject exception = nullptr; - if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (ctor = - jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != NULL)) + jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != nullptr)) return NSK_FALSE; NSK_DISPLAY0("Checking negative: StopThread\n"); @@ -179,7 +179,7 @@ static int checkSignalThread() { */ static int checkGetOwnedMonitorInfo() { jint count; - jobject *monitors = NULL; + jobject *monitors = nullptr; NSK_DISPLAY0("Checking negative: GetOwnedMonitorInfo\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -192,7 +192,7 @@ static int checkGetOwnedMonitorInfo() { /* Check "can_get_current_contended_monitor" function */ static int checkGetCurrentContendedMonitor() { - jobject monitor = NULL; + jobject monitor = nullptr; NSK_DISPLAY0("Checking positive: GetCurrentContendedMonitor\n"); if (!NSK_JVMTI_VERIFY(jvmti->GetCurrentContendedMonitor(thread, &monitor))) @@ -243,8 +243,8 @@ static int checkHeapFunctions() { const jlong TAG_VALUE = (123456789L); jlong tag; jint count; - jobject *res_objects = NULL; - jlong *res_tags = NULL; + jobject *res_objects = nullptr; + jlong *res_tags = nullptr; jint dummy_user_data = 0; NSK_DISPLAY0("Checking negative: SetTag\n"); @@ -297,7 +297,7 @@ static int checkHeapFunctions() { */ static int checkLocalVariableFunctions() { jint count; - jvmtiLocalVariableEntry *local_variable_table = NULL; + jvmtiLocalVariableEntry *local_variable_table = nullptr; jobject object_value; jint int_value; jlong long_value; @@ -367,7 +367,7 @@ static int checkLocalVariableFunctions() { static int checkSourceInfoFunctions() { char *name; jint count; - jvmtiLineNumberEntry *line_number_table = NULL; + jvmtiLineNumberEntry *line_number_table = nullptr; NSK_DISPLAY0("Checking negative: GetSourceFileName\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -395,7 +395,7 @@ static int checkRedefineClasses() { NSK_DISPLAY0("Checking negative: RedefineClasses\n"); class_def.klass = klass; class_def.class_byte_count = 0; - class_def.class_bytes = NULL; + class_def.class_bytes = nullptr; if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, jvmti->RedefineClasses(1, &class_def))) return NSK_FALSE; @@ -567,11 +567,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; /* testcase #1: check GetPotentialCapabilities */ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t006/cm01t006.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t006/cm01t006.cpp index 011c53aa0c9..325d6d725dd 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t006/cm01t006.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t006/cm01t006.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -50,22 +50,22 @@ extern "C" { /* ========================================================================== */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* test objects */ -static jthread thread = NULL; -static jclass klass = NULL; -static jmethodID method = NULL; -static jfieldID field = NULL; +static jthread thread = nullptr; +static jclass klass = nullptr; +static jmethodID method = nullptr; +static jfieldID field = nullptr; /* ========================================================================== */ static int prepare() { const char* THREAD_NAME = "Debuggee Thread"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; int i; @@ -75,12 +75,12 @@ static int prepare() { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -90,7 +90,7 @@ static int prepare() { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) { + if (info.name != nullptr && (strcmp(info.name, THREAD_NAME) == 0)) { thread = threads[i]; } } @@ -100,16 +100,16 @@ static int prepare() { return NSK_FALSE; /* get tested thread class */ - if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != nullptr)) return NSK_FALSE; /* get tested thread method 'run' */ - if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != NULL)) + if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != nullptr)) return NSK_FALSE; /* get tested thread field 'waitingMonitor' */ if (!NSK_JNI_VERIFY(jni, (field = - jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != NULL)) + jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -149,18 +149,18 @@ static int checkSignalThread() { const char* THREAD_DEATH_CLASS_NAME = "java/lang/ThreadDeath"; const char* THREAD_DEATH_CTOR_NAME = ""; const char* THREAD_DEATH_CTOR_SIGNATURE = "()V"; - jclass cls = NULL; - jmethodID ctor = NULL; - jobject exception = NULL; + jclass cls = nullptr; + jmethodID ctor = nullptr; + jobject exception = nullptr; - if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (ctor = - jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != NULL)) + jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != nullptr)) return NSK_FALSE; NSK_DISPLAY0("Checking negative: StopThread\n"); @@ -179,7 +179,7 @@ static int checkSignalThread() { */ static int checkGetOwnedMonitorInfo() { jint count; - jobject *monitors = NULL; + jobject *monitors = nullptr; NSK_DISPLAY0("Checking negative: GetOwnedMonitorInfo\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -192,7 +192,7 @@ static int checkGetOwnedMonitorInfo() { /* Check "can_get_current_contended_monitor" function */ static int checkGetCurrentContendedMonitor() { - jobject monitor = NULL; + jobject monitor = nullptr; NSK_DISPLAY0("Checking negative: GetCurrentContendedMonitor\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -244,8 +244,8 @@ static int checkHeapFunctions() { const jlong TAG_VALUE = (123456789L); jlong tag; jint count; - jobject *res_objects = NULL; - jlong *res_tags = NULL; + jobject *res_objects = nullptr; + jlong *res_tags = nullptr; jint dummy_user_data = 0; NSK_DISPLAY0("Checking negative: SetTag\n"); @@ -298,7 +298,7 @@ static int checkHeapFunctions() { */ static int checkLocalVariableFunctions() { jint count; - jvmtiLocalVariableEntry *local_variable_table = NULL; + jvmtiLocalVariableEntry *local_variable_table = nullptr; jobject object_value; jint int_value; jlong long_value; @@ -368,7 +368,7 @@ static int checkLocalVariableFunctions() { static int checkSourceInfoFunctions() { char *name; jint count; - jvmtiLineNumberEntry *line_number_table = NULL; + jvmtiLineNumberEntry *line_number_table = nullptr; NSK_DISPLAY0("Checking negative: GetSourceFileName\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -396,7 +396,7 @@ static int checkRedefineClasses() { NSK_DISPLAY0("Checking negative: RedefineClasses\n"); class_def.klass = klass; class_def.class_byte_count = 0; - class_def.class_bytes = NULL; + class_def.class_bytes = nullptr; if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, jvmti->RedefineClasses(1, &class_def))) return NSK_FALSE; @@ -567,11 +567,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; /* testcase #1: check GetPotentialCapabilities */ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t007/cm01t007.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t007/cm01t007.cpp index b9519d59054..4576bcd2f68 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t007/cm01t007.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t007/cm01t007.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -50,22 +50,22 @@ extern "C" { /* ========================================================================== */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* test objects */ -static jthread thread = NULL; -static jclass klass = NULL; -static jmethodID method = NULL; -static jfieldID field = NULL; +static jthread thread = nullptr; +static jclass klass = nullptr; +static jmethodID method = nullptr; +static jfieldID field = nullptr; /* ========================================================================== */ static int prepare() { const char* THREAD_NAME = "Debuggee Thread"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; int i; @@ -75,12 +75,12 @@ static int prepare() { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -90,7 +90,7 @@ static int prepare() { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) { + if (info.name != nullptr && (strcmp(info.name, THREAD_NAME) == 0)) { thread = threads[i]; } } @@ -100,15 +100,15 @@ static int prepare() { return NSK_FALSE; /* get tested thread class */ - if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != nullptr)) return NSK_FALSE; /* get tested thread method 'run' */ - if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != NULL)) + if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != nullptr)) return NSK_FALSE; /* get tested thread field 'waitingFlag' */ - if (!NSK_JNI_VERIFY(jni, (field = jni->GetFieldID(klass, "waitingFlag", "Z")) != NULL)) + if (!NSK_JNI_VERIFY(jni, (field = jni->GetFieldID(klass, "waitingFlag", "Z")) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -148,18 +148,18 @@ static int checkSignalThread() { const char* THREAD_DEATH_CLASS_NAME = "java/lang/ThreadDeath"; const char* THREAD_DEATH_CTOR_NAME = ""; const char* THREAD_DEATH_CTOR_SIGNATURE = "()V"; - jclass cls = NULL; - jmethodID ctor = NULL; - jobject exception = NULL; + jclass cls = nullptr; + jmethodID ctor = nullptr; + jobject exception = nullptr; - if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (ctor = - jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != NULL)) + jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != nullptr)) return NSK_FALSE; NSK_DISPLAY0("Checking negative: StopThread\n"); @@ -178,7 +178,7 @@ static int checkSignalThread() { */ static int checkGetOwnedMonitorInfo() { jint count; - jobject *monitors = NULL; + jobject *monitors = nullptr; NSK_DISPLAY0("Checking negative: GetOwnedMonitorInfo\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -191,7 +191,7 @@ static int checkGetOwnedMonitorInfo() { /* Check "can_get_current_contended_monitor" function */ static int checkGetCurrentContendedMonitor() { - jobject monitor = NULL; + jobject monitor = nullptr; NSK_DISPLAY0("Checking negative: GetCurrentContendedMonitor\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -265,8 +265,8 @@ static int checkHeapFunctions() { const jlong TAG_VALUE = (123456789L); jlong tag; jint count; - jobject *res_objects = NULL; - jlong *res_tags = NULL; + jobject *res_objects = nullptr; + jlong *res_tags = nullptr; jint dummy_user_data = 0; NSK_DISPLAY0("Checking negative: SetTag\n"); @@ -321,7 +321,7 @@ static int checkHeapFunctions() { */ static int checkLocalVariableFunctions() { jint count; - jvmtiLocalVariableEntry *local_variable_table = NULL; + jvmtiLocalVariableEntry *local_variable_table = nullptr; jobject object_value; jint int_value; jlong long_value; @@ -391,7 +391,7 @@ static int checkLocalVariableFunctions() { static int checkSourceInfoFunctions() { char *name; jint count; - jvmtiLineNumberEntry *line_number_table = NULL; + jvmtiLineNumberEntry *line_number_table = nullptr; NSK_DISPLAY0("Checking negative: GetSourceFileName\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -419,7 +419,7 @@ static int checkRedefineClasses() { NSK_DISPLAY0("Checking negative: RedefineClasses\n"); class_def.klass = klass; class_def.class_byte_count = 0; - class_def.class_bytes = NULL; + class_def.class_bytes = nullptr; if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, jvmti->RedefineClasses(1, &class_def))) return NSK_FALSE; @@ -591,11 +591,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; /* testcase #1: check GetPotentialCapabilities */ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t008/cm01t008.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t008/cm01t008.cpp index 8f35fd2bf20..6783905f6b8 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t008/cm01t008.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t008/cm01t008.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,24 +52,24 @@ extern "C" { /* ========================================================================== */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* test objects */ -static jthread thread = NULL; -static jclass klass = NULL; -static jmethodID method = NULL; -static jfieldID field = NULL; +static jthread thread = nullptr; +static jclass klass = nullptr; +static jmethodID method = nullptr; +static jfieldID field = nullptr; static jint klass_byte_count = 0; -static unsigned char *klass_bytes = NULL; +static unsigned char *klass_bytes = nullptr; /* ========================================================================== */ static int prepare() { const char* THREAD_NAME = "Debuggee Thread"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; int i; @@ -79,12 +79,12 @@ static int prepare() { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -94,7 +94,7 @@ static int prepare() { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) { + if (info.name != nullptr && (strcmp(info.name, THREAD_NAME) == 0)) { thread = threads[i]; } } @@ -104,16 +104,16 @@ static int prepare() { return NSK_FALSE; /* get tested thread class */ - if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != nullptr)) return NSK_FALSE; /* get tested thread method 'run' */ - if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != NULL)) + if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != nullptr)) return NSK_FALSE; /* get tested thread field 'waitingMonitor' */ if (!NSK_JNI_VERIFY(jni, (field = - jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != NULL)) + jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -153,18 +153,18 @@ static int checkSignalThread() { const char* THREAD_DEATH_CLASS_NAME = "java/lang/ThreadDeath"; const char* THREAD_DEATH_CTOR_NAME = ""; const char* THREAD_DEATH_CTOR_SIGNATURE = "()V"; - jclass cls = NULL; - jmethodID ctor = NULL; - jobject exception = NULL; + jclass cls = nullptr; + jmethodID ctor = nullptr; + jobject exception = nullptr; - if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (ctor = - jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != NULL)) + jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != nullptr)) return NSK_FALSE; NSK_DISPLAY0("Checking negative: StopThread\n"); @@ -183,7 +183,7 @@ static int checkSignalThread() { */ static int checkGetOwnedMonitorInfo() { jint count; - jobject *monitors = NULL; + jobject *monitors = nullptr; NSK_DISPLAY0("Checking negative: GetOwnedMonitorInfo\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -196,7 +196,7 @@ static int checkGetOwnedMonitorInfo() { /* Check "can_get_current_contended_monitor" function */ static int checkGetCurrentContendedMonitor() { - jobject monitor = NULL; + jobject monitor = nullptr; NSK_DISPLAY0("Checking negative: GetCurrentContendedMonitor\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -248,8 +248,8 @@ static int checkHeapFunctions() { const jlong TAG_VALUE = (123456789L); jlong tag; jint count; - jobject *res_objects = NULL; - jlong *res_tags = NULL; + jobject *res_objects = nullptr; + jlong *res_tags = nullptr; jint dummy_user_data = 0; NSK_DISPLAY0("Checking negative: SetTag\n"); @@ -302,7 +302,7 @@ static int checkHeapFunctions() { */ static int checkLocalVariableFunctions() { jint count; - jvmtiLocalVariableEntry *local_variable_table = NULL; + jvmtiLocalVariableEntry *local_variable_table = nullptr; jobject object_value; jint int_value; jlong long_value; @@ -372,7 +372,7 @@ static int checkLocalVariableFunctions() { static int checkSourceInfoFunctions() { char *name; jint count; - jvmtiLineNumberEntry *line_number_table = NULL; + jvmtiLineNumberEntry *line_number_table = nullptr; NSK_DISPLAY0("Checking negative: GetSourceFileName\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -505,7 +505,7 @@ ClassFileLoadHook(jvmtiEnv *jvmti_env, JNIEnv *env, jclass class_beeing_redefine jint class_data_len, const unsigned char* class_data, jint *new_class_data_len, unsigned char** new_class_data) { - if (name != NULL && (strcmp(name, CLASS_NAME) == 0)) { + if (name != nullptr && (strcmp(name, CLASS_NAME) == 0)) { NSK_DISPLAY1("ClassFileLoadHook: %s\n", name); if (!NSK_JVMTI_VERIFY(jvmti->Allocate(class_data_len, &klass_bytes))) nsk_jvmti_setFailStatus(); @@ -514,7 +514,7 @@ ClassFileLoadHook(jvmtiEnv *jvmti_env, JNIEnv *env, jclass class_beeing_redefine klass_byte_count = class_data_len; } NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL)); + jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, nullptr)); } } @@ -600,11 +600,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; /* testcase #1: check GetPotentialCapabilities */ @@ -674,7 +674,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks)))) return JNI_ERR; if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL))) + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t009/cm01t009.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t009/cm01t009.cpp index 535398b2a96..307d1045bf6 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t009/cm01t009.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t009/cm01t009.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,22 +52,22 @@ extern "C" { /* ========================================================================== */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* test objects */ -static jthread thread = NULL; -static jclass klass = NULL; -static jmethodID method = NULL; -static jfieldID field = NULL; +static jthread thread = nullptr; +static jclass klass = nullptr; +static jmethodID method = nullptr; +static jfieldID field = nullptr; /* ========================================================================== */ static int prepare() { const char* THREAD_NAME = "Debuggee Thread"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; int i; @@ -77,12 +77,12 @@ static int prepare() { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -92,7 +92,7 @@ static int prepare() { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) { + if (info.name != nullptr && (strcmp(info.name, THREAD_NAME) == 0)) { thread = threads[i]; } } @@ -102,16 +102,16 @@ static int prepare() { return NSK_FALSE; /* get tested thread class */ - if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != nullptr)) return NSK_FALSE; /* get tested thread method 'run' */ - if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != NULL)) + if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != nullptr)) return NSK_FALSE; /* get tested thread field 'waitingMonitor' */ if (!NSK_JNI_VERIFY(jni, (field = - jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != NULL)) + jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -151,18 +151,18 @@ static int checkSignalThread() { const char* THREAD_DEATH_CLASS_NAME = "java/lang/ThreadDeath"; const char* THREAD_DEATH_CTOR_NAME = ""; const char* THREAD_DEATH_CTOR_SIGNATURE = "()V"; - jclass cls = NULL; - jmethodID ctor = NULL; - jobject exception = NULL; + jclass cls = nullptr; + jmethodID ctor = nullptr; + jobject exception = nullptr; - if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (ctor = - jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != NULL)) + jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != nullptr)) return NSK_FALSE; NSK_DISPLAY0("Checking positive: InterruptThread\n"); @@ -180,7 +180,7 @@ static int checkSignalThread() { */ static int checkGetOwnedMonitorInfo() { jint count; - jobject *monitors = NULL; + jobject *monitors = nullptr; NSK_DISPLAY0("Checking negative: GetOwnedMonitorInfo\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -193,7 +193,7 @@ static int checkGetOwnedMonitorInfo() { /* Check "can_get_current_contended_monitor" function */ static int checkGetCurrentContendedMonitor() { - jobject monitor = NULL; + jobject monitor = nullptr; NSK_DISPLAY0("Checking negative: GetCurrentContendedMonitor\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -245,8 +245,8 @@ static int checkHeapFunctions() { const jlong TAG_VALUE = (123456789L); jlong tag; jint count; - jobject *res_objects = NULL; - jlong *res_tags = NULL; + jobject *res_objects = nullptr; + jlong *res_tags = nullptr; jint dummy_user_data = 0; NSK_DISPLAY0("Checking negative: SetTag\n"); @@ -299,7 +299,7 @@ static int checkHeapFunctions() { */ static int checkLocalVariableFunctions() { jint count; - jvmtiLocalVariableEntry *local_variable_table = NULL; + jvmtiLocalVariableEntry *local_variable_table = nullptr; jobject object_value; jint int_value; jlong long_value; @@ -369,7 +369,7 @@ static int checkLocalVariableFunctions() { static int checkSourceInfoFunctions() { char *name; jint count; - jvmtiLineNumberEntry *line_number_table = NULL; + jvmtiLineNumberEntry *line_number_table = nullptr; NSK_DISPLAY0("Checking negative: GetSourceFileName\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -397,7 +397,7 @@ static int checkRedefineClasses() { NSK_DISPLAY0("Checking negative: RedefineClasses\n"); class_def.klass = klass; class_def.class_byte_count = 0; - class_def.class_bytes = NULL; + class_def.class_bytes = nullptr; if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, jvmti->RedefineClasses(1, &class_def))) return NSK_FALSE; @@ -569,11 +569,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; /* testcase #1: check GetPotentialCapabilities */ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t010/cm01t010.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t010/cm01t010.cpp index f7e8c060772..143cc6127e9 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t010/cm01t010.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t010/cm01t010.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,22 +51,22 @@ extern "C" { /* ========================================================================== */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* test objects */ -static jthread thread = NULL; -static jclass klass = NULL; -static jmethodID method = NULL; -static jfieldID field = NULL; +static jthread thread = nullptr; +static jclass klass = nullptr; +static jmethodID method = nullptr; +static jfieldID field = nullptr; /* ========================================================================== */ static int prepare() { const char* THREAD_NAME = "Debuggee Thread"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; int i; @@ -76,12 +76,12 @@ static int prepare() { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -91,7 +91,7 @@ static int prepare() { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) { + if (info.name != nullptr && (strcmp(info.name, THREAD_NAME) == 0)) { thread = threads[i]; } } @@ -101,16 +101,16 @@ static int prepare() { return NSK_FALSE; /* get tested thread class */ - if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != nullptr)) return NSK_FALSE; /* get tested thread method 'run' */ - if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != NULL)) + if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != nullptr)) return NSK_FALSE; /* get tested thread field 'waitingMonitor' */ if (!NSK_JNI_VERIFY(jni, (field = - jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != NULL)) + jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -150,18 +150,18 @@ static int checkSignalThread() { const char* THREAD_DEATH_CLASS_NAME = "java/lang/ThreadDeath"; const char* THREAD_DEATH_CTOR_NAME = ""; const char* THREAD_DEATH_CTOR_SIGNATURE = "()V"; - jclass cls = NULL; - jmethodID ctor = NULL; - jobject exception = NULL; + jclass cls = nullptr; + jmethodID ctor = nullptr; + jobject exception = nullptr; - if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (ctor = - jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != NULL)) + jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != nullptr)) return NSK_FALSE; NSK_DISPLAY0("Checking negative: StopThread\n"); @@ -180,7 +180,7 @@ static int checkSignalThread() { */ static int checkGetOwnedMonitorInfo() { jint count; - jobject *monitors = NULL; + jobject *monitors = nullptr; NSK_DISPLAY0("Checking negative: GetOwnedMonitorInfo\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -193,7 +193,7 @@ static int checkGetOwnedMonitorInfo() { /* Check "can_get_current_contended_monitor" function */ static int checkGetCurrentContendedMonitor() { - jobject monitor = NULL; + jobject monitor = nullptr; NSK_DISPLAY0("Checking negative: GetCurrentContendedMonitor\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -245,8 +245,8 @@ static int checkHeapFunctions() { const jlong TAG_VALUE = (123456789L); jlong tag; jint count; - jobject *res_objects = NULL; - jlong *res_tags = NULL; + jobject *res_objects = nullptr; + jlong *res_tags = nullptr; jint dummy_user_data = 0; NSK_DISPLAY0("Checking negative: SetTag\n"); @@ -299,7 +299,7 @@ static int checkHeapFunctions() { */ static int checkLocalVariableFunctions() { jint count; - jvmtiLocalVariableEntry *local_variable_table = NULL; + jvmtiLocalVariableEntry *local_variable_table = nullptr; jobject object_value; jint int_value; jlong long_value; @@ -369,7 +369,7 @@ static int checkLocalVariableFunctions() { static int checkSourceInfoFunctions() { char *name; jint count; - jvmtiLineNumberEntry *line_number_table = NULL; + jvmtiLineNumberEntry *line_number_table = nullptr; NSK_DISPLAY0("Checking positive: GetSourceFileName\n"); if (!NSK_JVMTI_VERIFY(jvmti->GetSourceFileName(klass, &name))) @@ -396,7 +396,7 @@ static int checkRedefineClasses() { NSK_DISPLAY0("Checking negative: RedefineClasses\n"); class_def.klass = klass; class_def.class_byte_count = 0; - class_def.class_bytes = NULL; + class_def.class_bytes = nullptr; if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, jvmti->RedefineClasses(1, &class_def))) return NSK_FALSE; @@ -568,11 +568,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; /* testcase #1: check GetPotentialCapabilities */ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t011/cm01t011.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t011/cm01t011.cpp index fdd3e7207da..075c7e1bb27 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t011/cm01t011.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t011/cm01t011.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -61,22 +61,22 @@ extern "C" { /* ========================================================================== */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* test objects */ -static jthread thread = NULL; -static jclass klass = NULL; -static jmethodID method = NULL; -static jfieldID field = NULL; +static jthread thread = nullptr; +static jclass klass = nullptr; +static jmethodID method = nullptr; +static jfieldID field = nullptr; /* ========================================================================== */ static int prepare() { const char* THREAD_NAME = "Debuggee Thread"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; int i; @@ -86,12 +86,12 @@ static int prepare() { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -101,7 +101,7 @@ static int prepare() { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) { + if (info.name != nullptr && (strcmp(info.name, THREAD_NAME) == 0)) { thread = threads[i]; } } @@ -111,16 +111,16 @@ static int prepare() { return NSK_FALSE; /* get tested thread class */ - if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != nullptr)) return NSK_FALSE; /* get tested thread method 'run' */ - if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != NULL)) + if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != nullptr)) return NSK_FALSE; /* get tested thread field 'waitingMonitor' */ if (!NSK_JNI_VERIFY(jni, (field = - jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != NULL)) + jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -160,18 +160,18 @@ static int checkSignalThread() { const char* THREAD_DEATH_CLASS_NAME = "java/lang/ThreadDeath"; const char* THREAD_DEATH_CTOR_NAME = ""; const char* THREAD_DEATH_CTOR_SIGNATURE = "()V"; - jclass cls = NULL; - jmethodID ctor = NULL; - jobject exception = NULL; + jclass cls = nullptr; + jmethodID ctor = nullptr; + jobject exception = nullptr; - if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (ctor = - jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != NULL)) + jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != nullptr)) return NSK_FALSE; NSK_DISPLAY0("Checking negative: StopThread\n"); @@ -190,7 +190,7 @@ static int checkSignalThread() { */ static int checkGetOwnedMonitorInfo() { jint count; - jobject *monitors = NULL; + jobject *monitors = nullptr; NSK_DISPLAY0("Checking negative: GetOwnedMonitorInfo\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -203,7 +203,7 @@ static int checkGetOwnedMonitorInfo() { /* Check "can_get_current_contended_monitor" function */ static int checkGetCurrentContendedMonitor() { - jobject monitor = NULL; + jobject monitor = nullptr; NSK_DISPLAY0("Checking negative: GetCurrentContendedMonitor\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -255,8 +255,8 @@ static int checkHeapFunctions() { const jlong TAG_VALUE = (123456789L); jlong tag; jint count; - jobject *res_objects = NULL; - jlong *res_tags = NULL; + jobject *res_objects = nullptr; + jlong *res_tags = nullptr; jint dummy_user_data = 0; NSK_DISPLAY0("Checking negative: SetTag\n"); @@ -309,7 +309,7 @@ static int checkHeapFunctions() { */ static int checkLocalVariableFunctions() { jint count; - jvmtiLocalVariableEntry *local_variable_table = NULL; + jvmtiLocalVariableEntry *local_variable_table = nullptr; jobject object_value; jint int_value; jlong long_value; @@ -399,7 +399,7 @@ static int checkLocalVariableFunctions() { static int checkSourceInfoFunctions() { char *name; jint count; - jvmtiLineNumberEntry *line_number_table = NULL; + jvmtiLineNumberEntry *line_number_table = nullptr; NSK_DISPLAY0("Checking negative: GetSourceFileName\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -427,7 +427,7 @@ static int checkRedefineClasses() { NSK_DISPLAY0("Checking negative: RedefineClasses\n"); class_def.klass = klass; class_def.class_byte_count = 0; - class_def.class_bytes = NULL; + class_def.class_bytes = nullptr; if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, jvmti->RedefineClasses(1, &class_def))) return NSK_FALSE; @@ -599,11 +599,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; /* testcase #1: check GetPotentialCapabilities */ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t012/cm01t012.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t012/cm01t012.cpp index 68b6461161c..b8a18cf6179 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t012/cm01t012.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t012/cm01t012.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -54,22 +54,22 @@ extern "C" { /* ========================================================================== */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* test objects */ -static jthread thread = NULL; -static jclass klass = NULL; -static jmethodID method = NULL; -static jfieldID field = NULL; +static jthread thread = nullptr; +static jclass klass = nullptr; +static jmethodID method = nullptr; +static jfieldID field = nullptr; /* ========================================================================== */ static int prepare() { const char* THREAD_NAME = "Debuggee Thread"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; int i; @@ -79,12 +79,12 @@ static int prepare() { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -94,7 +94,7 @@ static int prepare() { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) { + if (info.name != nullptr && (strcmp(info.name, THREAD_NAME) == 0)) { thread = threads[i]; } } @@ -104,16 +104,16 @@ static int prepare() { return NSK_FALSE; /* get tested thread class */ - if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != nullptr)) return NSK_FALSE; /* get tested thread method 'run' */ - if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != NULL)) + if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != nullptr)) return NSK_FALSE; /* get tested thread field 'waitingMonitor' */ if (!NSK_JNI_VERIFY(jni, (field = - jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != NULL)) + jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -151,18 +151,18 @@ static int checkSignalThread() { const char* THREAD_DEATH_CLASS_NAME = "java/lang/ThreadDeath"; const char* THREAD_DEATH_CTOR_NAME = ""; const char* THREAD_DEATH_CTOR_SIGNATURE = "()V"; - jclass cls = NULL; - jmethodID ctor = NULL; - jobject exception = NULL; + jclass cls = nullptr; + jmethodID ctor = nullptr; + jobject exception = nullptr; - if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (ctor = - jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != NULL)) + jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != nullptr)) return NSK_FALSE; NSK_DISPLAY0("Checking negative: StopThread\n"); @@ -181,7 +181,7 @@ static int checkSignalThread() { */ static int checkGetOwnedMonitorInfo() { jint count; - jobject *monitors = NULL; + jobject *monitors = nullptr; NSK_DISPLAY0("Checking negative: GetOwnedMonitorInfo\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -194,7 +194,7 @@ static int checkGetOwnedMonitorInfo() { /* Check "can_get_current_contended_monitor" function */ static int checkGetCurrentContendedMonitor() { - jobject monitor = NULL; + jobject monitor = nullptr; NSK_DISPLAY0("Checking negative: GetCurrentContendedMonitor\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -246,8 +246,8 @@ static int checkHeapFunctions() { const jlong TAG_VALUE = (123456789L); jlong tag; jint count; - jobject *res_objects = NULL; - jlong *res_tags = NULL; + jobject *res_objects = nullptr; + jlong *res_tags = nullptr; jint dummy_user_data = 0; NSK_DISPLAY0("Checking negative: SetTag\n"); @@ -300,7 +300,7 @@ static int checkHeapFunctions() { */ static int checkLocalVariableFunctions() { jint count; - jvmtiLocalVariableEntry *local_variable_table = NULL; + jvmtiLocalVariableEntry *local_variable_table = nullptr; jobject object_value; jint int_value; jlong long_value; @@ -370,7 +370,7 @@ static int checkLocalVariableFunctions() { static int checkSourceInfoFunctions() { char *name; jint count; - jvmtiLineNumberEntry *line_number_table = NULL; + jvmtiLineNumberEntry *line_number_table = nullptr; NSK_DISPLAY0("Checking negative: GetSourceFileName\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -398,7 +398,7 @@ static int checkRedefineClasses() { NSK_DISPLAY0("Checking negative: RedefineClasses\n"); class_def.klass = klass; class_def.class_byte_count = 0; - class_def.class_bytes = NULL; + class_def.class_bytes = nullptr; if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, jvmti->RedefineClasses(1, &class_def))) return NSK_FALSE; @@ -570,11 +570,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; /* testcase #1: check GetPotentialCapabilities */ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t013/cm01t013.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t013/cm01t013.cpp index b6ce11d590e..aebd93910f6 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t013/cm01t013.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t013/cm01t013.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,22 +51,22 @@ extern "C" { /* ========================================================================== */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* test objects */ -static jthread thread = NULL; -static jclass klass = NULL; -static jmethodID method = NULL; -static jfieldID field = NULL; +static jthread thread = nullptr; +static jclass klass = nullptr; +static jmethodID method = nullptr; +static jfieldID field = nullptr; /* ========================================================================== */ static int prepare() { const char* THREAD_NAME = "Debuggee Thread"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; int i; @@ -76,12 +76,12 @@ static int prepare() { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -91,7 +91,7 @@ static int prepare() { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) { + if (info.name != nullptr && (strcmp(info.name, THREAD_NAME) == 0)) { thread = threads[i]; } } @@ -101,16 +101,16 @@ static int prepare() { return NSK_FALSE; /* get tested thread class */ - if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != nullptr)) return NSK_FALSE; /* get tested thread method 'run' */ - if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != NULL)) + if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != nullptr)) return NSK_FALSE; /* get tested thread field 'waitingMonitor' */ if (!NSK_JNI_VERIFY(jni, (field = - jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != NULL)) + jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -150,18 +150,18 @@ static int checkSignalThread() { const char* THREAD_DEATH_CLASS_NAME = "java/lang/ThreadDeath"; const char* THREAD_DEATH_CTOR_NAME = ""; const char* THREAD_DEATH_CTOR_SIGNATURE = "()V"; - jclass cls = NULL; - jmethodID ctor = NULL; - jobject exception = NULL; + jclass cls = nullptr; + jmethodID ctor = nullptr; + jobject exception = nullptr; - if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (ctor = - jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != NULL)) + jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != nullptr)) return NSK_FALSE; NSK_DISPLAY0("Checking negative: StopThread\n"); @@ -180,7 +180,7 @@ static int checkSignalThread() { */ static int checkGetOwnedMonitorInfo() { jint count; - jobject *monitors = NULL; + jobject *monitors = nullptr; NSK_DISPLAY0("Checking negative: GetOwnedMonitorInfo\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -193,7 +193,7 @@ static int checkGetOwnedMonitorInfo() { /* Check "can_get_current_contended_monitor" function */ static int checkGetCurrentContendedMonitor() { - jobject monitor = NULL; + jobject monitor = nullptr; NSK_DISPLAY0("Checking negative: GetCurrentContendedMonitor\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -245,8 +245,8 @@ static int checkHeapFunctions() { const jlong TAG_VALUE = (123456789L); jlong tag; jint count; - jobject *res_objects = NULL; - jlong *res_tags = NULL; + jobject *res_objects = nullptr; + jlong *res_tags = nullptr; jint dummy_user_data = 0; NSK_DISPLAY0("Checking negative: SetTag\n"); @@ -299,7 +299,7 @@ static int checkHeapFunctions() { */ static int checkLocalVariableFunctions() { jint count; - jvmtiLocalVariableEntry *local_variable_table = NULL; + jvmtiLocalVariableEntry *local_variable_table = nullptr; jobject object_value; jint int_value; jlong long_value; @@ -369,7 +369,7 @@ static int checkLocalVariableFunctions() { static int checkSourceInfoFunctions() { char *name; jint count; - jvmtiLineNumberEntry *line_number_table = NULL; + jvmtiLineNumberEntry *line_number_table = nullptr; NSK_DISPLAY0("Checking negative: GetSourceFileName\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -396,7 +396,7 @@ static int checkRedefineClasses() { NSK_DISPLAY0("Checking negative: RedefineClasses\n"); class_def.klass = klass; class_def.class_byte_count = 0; - class_def.class_bytes = NULL; + class_def.class_bytes = nullptr; if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, jvmti->RedefineClasses(1, &class_def))) return NSK_FALSE; @@ -568,11 +568,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; /* testcase #1: check GetPotentialCapabilities */ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t014/cm01t014.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t014/cm01t014.cpp index 58d80995614..7875901b8aa 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t014/cm01t014.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t014/cm01t014.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,22 +52,22 @@ extern "C" { /* ========================================================================== */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* test objects */ -static jthread thread = NULL; -static jclass klass = NULL; -static jmethodID method = NULL; -static jfieldID field = NULL; +static jthread thread = nullptr; +static jclass klass = nullptr; +static jmethodID method = nullptr; +static jfieldID field = nullptr; /* ========================================================================== */ static int prepare() { const char* THREAD_NAME = "Debuggee Thread"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; int i; @@ -77,12 +77,12 @@ static int prepare() { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -92,7 +92,7 @@ static int prepare() { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) { + if (info.name != nullptr && (strcmp(info.name, THREAD_NAME) == 0)) { thread = threads[i]; } } @@ -102,16 +102,16 @@ static int prepare() { return NSK_FALSE; /* get tested thread class */ - if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != nullptr)) return NSK_FALSE; /* get tested thread method 'run' */ - if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != NULL)) + if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != nullptr)) return NSK_FALSE; /* get tested thread field 'waitingMonitor' */ if (!NSK_JNI_VERIFY(jni, (field = - jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != NULL)) + jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -216,18 +216,18 @@ static int checkSignalThread() { const char* THREAD_DEATH_CLASS_NAME = "java/lang/ThreadDeath"; const char* THREAD_DEATH_CTOR_NAME = ""; const char* THREAD_DEATH_CTOR_SIGNATURE = "()V"; - jclass cls = NULL; - jmethodID ctor = NULL; - jobject exception = NULL; + jclass cls = nullptr; + jmethodID ctor = nullptr; + jobject exception = nullptr; - if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (ctor = - jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != NULL)) + jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != nullptr)) return NSK_FALSE; NSK_DISPLAY0("Checking negative: StopThread\n"); @@ -246,7 +246,7 @@ static int checkSignalThread() { */ static int checkGetOwnedMonitorInfo() { jint count; - jobject *monitors = NULL; + jobject *monitors = nullptr; NSK_DISPLAY0("Checking negative: GetOwnedMonitorInfo\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -259,7 +259,7 @@ static int checkGetOwnedMonitorInfo() { /* Check "can_get_current_contended_monitor" function */ static int checkGetCurrentContendedMonitor() { - jobject monitor = NULL; + jobject monitor = nullptr; NSK_DISPLAY0("Checking negative: GetCurrentContendedMonitor\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -311,8 +311,8 @@ static int checkHeapFunctions() { const jlong TAG_VALUE = (123456789L); jlong tag; jint count; - jobject *res_objects = NULL; - jlong *res_tags = NULL; + jobject *res_objects = nullptr; + jlong *res_tags = nullptr; jint dummy_user_data = 0; NSK_DISPLAY0("Checking negative: SetTag\n"); @@ -365,7 +365,7 @@ static int checkHeapFunctions() { */ static int checkLocalVariableFunctions() { jint count; - jvmtiLocalVariableEntry *local_variable_table = NULL; + jvmtiLocalVariableEntry *local_variable_table = nullptr; jobject object_value; jint int_value; jlong long_value; @@ -435,7 +435,7 @@ static int checkLocalVariableFunctions() { static int checkSourceInfoFunctions() { char *name; jint count; - jvmtiLineNumberEntry *line_number_table = NULL; + jvmtiLineNumberEntry *line_number_table = nullptr; NSK_DISPLAY0("Checking negative: GetSourceFileName\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -463,7 +463,7 @@ static int checkRedefineClasses() { NSK_DISPLAY0("Checking negative: RedefineClasses\n"); class_def.klass = klass; class_def.class_byte_count = 0; - class_def.class_bytes = NULL; + class_def.class_bytes = nullptr; if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, jvmti->RedefineClasses(1, &class_def))) return NSK_FALSE; @@ -694,11 +694,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t015/cm01t015.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t015/cm01t015.cpp index 4919c2874dc..aab9c8f47a1 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t015/cm01t015.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t015/cm01t015.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -54,22 +54,22 @@ extern "C" { /* ========================================================================== */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* test objects */ -static jthread thread = NULL; -static jclass klass = NULL; -static jmethodID method = NULL; -static jfieldID field = NULL; +static jthread thread = nullptr; +static jclass klass = nullptr; +static jmethodID method = nullptr; +static jfieldID field = nullptr; /* ========================================================================== */ static int prepare() { const char* THREAD_NAME = "Debuggee Thread"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; int i; @@ -79,12 +79,12 @@ static int prepare() { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -94,7 +94,7 @@ static int prepare() { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) { + if (info.name != nullptr && (strcmp(info.name, THREAD_NAME) == 0)) { thread = threads[i]; } } @@ -104,16 +104,16 @@ static int prepare() { return NSK_FALSE; /* get tested thread class */ - if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != nullptr)) return NSK_FALSE; /* get tested thread method 'run' */ - if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != NULL)) + if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != nullptr)) return NSK_FALSE; /* get tested thread field 'waitingMonitor' */ if (!NSK_JNI_VERIFY(jni, (field = - jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != NULL)) + jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -218,18 +218,18 @@ static int checkSignalThread() { const char* THREAD_DEATH_CLASS_NAME = "java/lang/ThreadDeath"; const char* THREAD_DEATH_CTOR_NAME = ""; const char* THREAD_DEATH_CTOR_SIGNATURE = "()V"; - jclass cls = NULL; - jmethodID ctor = NULL; - jobject exception = NULL; + jclass cls = nullptr; + jmethodID ctor = nullptr; + jobject exception = nullptr; - if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (ctor = - jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != NULL)) + jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != nullptr)) return NSK_FALSE; NSK_DISPLAY0("Checking negative: StopThread\n"); @@ -248,7 +248,7 @@ static int checkSignalThread() { */ static int checkGetOwnedMonitorInfo() { jint count; - jobject *monitors = NULL; + jobject *monitors = nullptr; NSK_DISPLAY0("Checking negative: GetOwnedMonitorInfo\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -261,7 +261,7 @@ static int checkGetOwnedMonitorInfo() { /* Check "can_get_current_contended_monitor" function */ static int checkGetCurrentContendedMonitor() { - jobject monitor = NULL; + jobject monitor = nullptr; NSK_DISPLAY0("Checking negative: GetCurrentContendedMonitor\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -313,8 +313,8 @@ static int checkHeapFunctions() { const jlong TAG_VALUE = (123456789L); jlong tag; jint count; - jobject *res_objects = NULL; - jlong *res_tags = NULL; + jobject *res_objects = nullptr; + jlong *res_tags = nullptr; jint dummy_user_data = 0; NSK_DISPLAY0("Checking negative: SetTag\n"); @@ -367,7 +367,7 @@ static int checkHeapFunctions() { */ static int checkLocalVariableFunctions() { jint count; - jvmtiLocalVariableEntry *local_variable_table = NULL; + jvmtiLocalVariableEntry *local_variable_table = nullptr; jobject object_value; jint int_value; jlong long_value; @@ -437,7 +437,7 @@ static int checkLocalVariableFunctions() { static int checkSourceInfoFunctions() { char *name; jint count; - jvmtiLineNumberEntry *line_number_table = NULL; + jvmtiLineNumberEntry *line_number_table = nullptr; NSK_DISPLAY0("Checking negative: GetSourceFileName\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -465,7 +465,7 @@ static int checkRedefineClasses() { NSK_DISPLAY0("Checking negative: RedefineClasses\n"); class_def.klass = klass; class_def.class_byte_count = 0; - class_def.class_bytes = NULL; + class_def.class_bytes = nullptr; if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, jvmti->RedefineClasses(1, &class_def))) return NSK_FALSE; @@ -698,11 +698,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t016/cm01t016.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t016/cm01t016.cpp index 0952ff8d3dc..59d23a8e373 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t016/cm01t016.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t016/cm01t016.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,22 +52,22 @@ extern "C" { /* ========================================================================== */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* test objects */ -static jthread thread = NULL; -static jclass klass = NULL; -static jmethodID method = NULL; -static jfieldID field = NULL; +static jthread thread = nullptr; +static jclass klass = nullptr; +static jmethodID method = nullptr; +static jfieldID field = nullptr; /* ========================================================================== */ static int prepare() { const char* THREAD_NAME = "Debuggee Thread"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; int i; @@ -77,12 +77,12 @@ static int prepare() { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -92,7 +92,7 @@ static int prepare() { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) { + if (info.name != nullptr && (strcmp(info.name, THREAD_NAME) == 0)) { thread = threads[i]; } } @@ -102,16 +102,16 @@ static int prepare() { return NSK_FALSE; /* get tested thread class */ - if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != nullptr)) return NSK_FALSE; /* get tested thread method 'run' */ - if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != NULL)) + if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != nullptr)) return NSK_FALSE; /* get tested thread field 'waitingMonitor' */ if (!NSK_JNI_VERIFY(jni, (field = - jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != NULL)) + jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -216,18 +216,18 @@ static int checkSignalThread() { const char* THREAD_DEATH_CLASS_NAME = "java/lang/ThreadDeath"; const char* THREAD_DEATH_CTOR_NAME = ""; const char* THREAD_DEATH_CTOR_SIGNATURE = "()V"; - jclass cls = NULL; - jmethodID ctor = NULL; - jobject exception = NULL; + jclass cls = nullptr; + jmethodID ctor = nullptr; + jobject exception = nullptr; - if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (ctor = - jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != NULL)) + jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != nullptr)) return NSK_FALSE; NSK_DISPLAY0("Checking negative: StopThread\n"); @@ -246,7 +246,7 @@ static int checkSignalThread() { */ static int checkGetOwnedMonitorInfo() { jint count; - jobject *monitors = NULL; + jobject *monitors = nullptr; NSK_DISPLAY0("Checking negative: GetOwnedMonitorInfo\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -259,7 +259,7 @@ static int checkGetOwnedMonitorInfo() { /* Check "can_get_current_contended_monitor" function */ static int checkGetCurrentContendedMonitor() { - jobject monitor = NULL; + jobject monitor = nullptr; NSK_DISPLAY0("Checking negative: GetCurrentContendedMonitor\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -311,8 +311,8 @@ static int checkHeapFunctions() { const jlong TAG_VALUE = (123456789L); jlong tag; jint count; - jobject *res_objects = NULL; - jlong *res_tags = NULL; + jobject *res_objects = nullptr; + jlong *res_tags = nullptr; jint dummy_user_data = 0; NSK_DISPLAY0("Checking negative: SetTag\n"); @@ -365,7 +365,7 @@ static int checkHeapFunctions() { */ static int checkLocalVariableFunctions() { jint count; - jvmtiLocalVariableEntry *local_variable_table = NULL; + jvmtiLocalVariableEntry *local_variable_table = nullptr; jobject object_value; jint int_value; jlong long_value; @@ -435,7 +435,7 @@ static int checkLocalVariableFunctions() { static int checkSourceInfoFunctions() { char *name; jint count; - jvmtiLineNumberEntry *line_number_table = NULL; + jvmtiLineNumberEntry *line_number_table = nullptr; NSK_DISPLAY0("Checking negative: GetSourceFileName\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -463,7 +463,7 @@ static int checkRedefineClasses() { NSK_DISPLAY0("Checking negative: RedefineClasses\n"); class_def.klass = klass; class_def.class_byte_count = 0; - class_def.class_bytes = NULL; + class_def.class_bytes = nullptr; if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, jvmti->RedefineClasses(1, &class_def))) return NSK_FALSE; @@ -692,11 +692,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t017/cm01t017.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t017/cm01t017.cpp index 13804681b1a..dc7ad64d8d5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t017/cm01t017.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t017/cm01t017.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -54,22 +54,22 @@ extern "C" { /* ========================================================================== */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* test objects */ -static jthread thread = NULL; -static jclass klass = NULL; -static jmethodID method = NULL; -static jfieldID field = NULL; +static jthread thread = nullptr; +static jclass klass = nullptr; +static jmethodID method = nullptr; +static jfieldID field = nullptr; /* ========================================================================== */ static int prepare() { const char* THREAD_NAME = "Debuggee Thread"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; int i; @@ -79,12 +79,12 @@ static int prepare() { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -94,7 +94,7 @@ static int prepare() { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) { + if (info.name != nullptr && (strcmp(info.name, THREAD_NAME) == 0)) { thread = threads[i]; } } @@ -104,16 +104,16 @@ static int prepare() { return NSK_FALSE; /* get tested thread class */ - if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != nullptr)) return NSK_FALSE; /* get tested thread method 'run' */ - if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != NULL)) + if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != nullptr)) return NSK_FALSE; /* get tested thread field 'waitingMonitor' */ if (!NSK_JNI_VERIFY(jni, (field = - jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != NULL)) + jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -218,18 +218,18 @@ static int checkSignalThread(int positive) { const char* THREAD_DEATH_CLASS_NAME = "java/lang/ThreadDeath"; const char* THREAD_DEATH_CTOR_NAME = ""; const char* THREAD_DEATH_CTOR_SIGNATURE = "()V"; - jclass cls = NULL; - jmethodID ctor = NULL; - jobject exception = NULL; + jclass cls = nullptr; + jmethodID ctor = nullptr; + jobject exception = nullptr; - if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (ctor = - jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != NULL)) + jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != nullptr)) return NSK_FALSE; if (positive) { @@ -259,7 +259,7 @@ static int checkSignalThread(int positive) { */ static int checkGetOwnedMonitorInfo() { jint count; - jobject *monitors = NULL; + jobject *monitors = nullptr; NSK_DISPLAY0("Checking negative: GetOwnedMonitorInfo\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -272,7 +272,7 @@ static int checkGetOwnedMonitorInfo() { /* Check "can_get_current_contended_monitor" function */ static int checkGetCurrentContendedMonitor() { - jobject monitor = NULL; + jobject monitor = nullptr; NSK_DISPLAY0("Checking negative: GetCurrentContendedMonitor\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -324,8 +324,8 @@ static int checkHeapFunctions() { const jlong TAG_VALUE = (123456789L); jlong tag; jint count; - jobject *res_objects = NULL; - jlong *res_tags = NULL; + jobject *res_objects = nullptr; + jlong *res_tags = nullptr; jint dummy_user_data = 0; NSK_DISPLAY0("Checking negative: SetTag\n"); @@ -378,7 +378,7 @@ static int checkHeapFunctions() { */ static int checkLocalVariableFunctions() { jint count; - jvmtiLocalVariableEntry *local_variable_table = NULL; + jvmtiLocalVariableEntry *local_variable_table = nullptr; jobject object_value; jint int_value; jlong long_value; @@ -448,7 +448,7 @@ static int checkLocalVariableFunctions() { static int checkSourceInfoFunctions() { char *name; jint count; - jvmtiLineNumberEntry *line_number_table = NULL; + jvmtiLineNumberEntry *line_number_table = nullptr; NSK_DISPLAY0("Checking negative: GetSourceFileName\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -476,7 +476,7 @@ static int checkRedefineClasses() { NSK_DISPLAY0("Checking negative: RedefineClasses\n"); class_def.klass = klass; class_def.class_byte_count = 0; - class_def.class_bytes = NULL; + class_def.class_bytes = nullptr; if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, jvmti->RedefineClasses(1, &class_def))) return NSK_FALSE; @@ -699,11 +699,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t018/cm01t018.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t018/cm01t018.cpp index 7e53745ccac..bd22d800877 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t018/cm01t018.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t018/cm01t018.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,22 +56,22 @@ extern "C" { /* ========================================================================== */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* test objects */ -static jthread thread = NULL; -static jclass klass = NULL; -static jmethodID method = NULL; -static jfieldID field = NULL; +static jthread thread = nullptr; +static jclass klass = nullptr; +static jmethodID method = nullptr; +static jfieldID field = nullptr; /* ========================================================================== */ static int prepare() { const char* THREAD_NAME = "Debuggee Thread"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; int i; @@ -81,12 +81,12 @@ static int prepare() { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -96,7 +96,7 @@ static int prepare() { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) { + if (info.name != nullptr && (strcmp(info.name, THREAD_NAME) == 0)) { thread = threads[i]; } } @@ -106,16 +106,16 @@ static int prepare() { return NSK_FALSE; /* get tested thread class */ - if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != nullptr)) return NSK_FALSE; /* get tested thread method 'run' */ - if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != NULL)) + if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != nullptr)) return NSK_FALSE; /* get tested thread field 'waitingMonitor' */ if (!NSK_JNI_VERIFY(jni, (field = - jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != NULL)) + jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -240,18 +240,18 @@ static int checkSignalThread() { const char* THREAD_DEATH_CLASS_NAME = "java/lang/ThreadDeath"; const char* THREAD_DEATH_CTOR_NAME = ""; const char* THREAD_DEATH_CTOR_SIGNATURE = "()V"; - jclass cls = NULL; - jmethodID ctor = NULL; - jobject exception = NULL; + jclass cls = nullptr; + jmethodID ctor = nullptr; + jobject exception = nullptr; - if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (ctor = - jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != NULL)) + jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != nullptr)) return NSK_FALSE; NSK_DISPLAY0("Checking negative: StopThread\n"); @@ -270,7 +270,7 @@ static int checkSignalThread() { */ static int checkGetOwnedMonitorInfo() { jint count; - jobject *monitors = NULL; + jobject *monitors = nullptr; NSK_DISPLAY0("Checking negative: GetOwnedMonitorInfo\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -283,7 +283,7 @@ static int checkGetOwnedMonitorInfo() { /* Check "can_get_current_contended_monitor" function */ static int checkGetCurrentContendedMonitor() { - jobject monitor = NULL; + jobject monitor = nullptr; NSK_DISPLAY0("Checking negative: GetCurrentContendedMonitor\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -335,8 +335,8 @@ static int checkHeapFunctions() { const jlong TAG_VALUE = (123456789L); jlong tag; jint count; - jobject *res_objects = NULL; - jlong *res_tags = NULL; + jobject *res_objects = nullptr; + jlong *res_tags = nullptr; jint dummy_user_data = 0; NSK_DISPLAY0("Checking negative: SetTag\n"); @@ -389,7 +389,7 @@ static int checkHeapFunctions() { */ static int checkLocalVariableFunctions() { jint count; - jvmtiLocalVariableEntry *local_variable_table = NULL; + jvmtiLocalVariableEntry *local_variable_table = nullptr; jobject object_value; jint int_value; jlong long_value; @@ -459,7 +459,7 @@ static int checkLocalVariableFunctions() { static int checkSourceInfoFunctions() { char *name; jint count; - jvmtiLineNumberEntry *line_number_table = NULL; + jvmtiLineNumberEntry *line_number_table = nullptr; NSK_DISPLAY0("Checking negative: GetSourceFileName\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -487,7 +487,7 @@ static int checkRedefineClasses() { NSK_DISPLAY0("Checking negative: RedefineClasses\n"); class_def.klass = klass; class_def.class_byte_count = 0; - class_def.class_bytes = NULL; + class_def.class_bytes = nullptr; if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, jvmti->RedefineClasses(1, &class_def))) return NSK_FALSE; @@ -710,11 +710,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t019/cm01t019.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t019/cm01t019.cpp index 9fe8b204387..89475b798f5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t019/cm01t019.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t019/cm01t019.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,22 +51,22 @@ extern "C" { /* ========================================================================== */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* test objects */ -static jthread thread = NULL; -static jclass klass = NULL; -static jmethodID method = NULL; -static jfieldID field = NULL; +static jthread thread = nullptr; +static jclass klass = nullptr; +static jmethodID method = nullptr; +static jfieldID field = nullptr; /* ========================================================================== */ static int prepare() { const char* THREAD_NAME = "Debuggee Thread"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; int i; @@ -76,12 +76,12 @@ static int prepare() { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -91,7 +91,7 @@ static int prepare() { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) { + if (info.name != nullptr && (strcmp(info.name, THREAD_NAME) == 0)) { thread = threads[i]; } } @@ -101,16 +101,16 @@ static int prepare() { return NSK_FALSE; /* get tested thread class */ - if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != nullptr)) return NSK_FALSE; /* get tested thread method 'run' */ - if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != NULL)) + if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != nullptr)) return NSK_FALSE; /* get tested thread field 'waitingMonitor' */ if (!NSK_JNI_VERIFY(jni, (field = - jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != NULL)) + jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -150,18 +150,18 @@ static int checkSignalThread() { const char* THREAD_DEATH_CLASS_NAME = "java/lang/ThreadDeath"; const char* THREAD_DEATH_CTOR_NAME = ""; const char* THREAD_DEATH_CTOR_SIGNATURE = "()V"; - jclass cls = NULL; - jmethodID ctor = NULL; - jobject exception = NULL; + jclass cls = nullptr; + jmethodID ctor = nullptr; + jobject exception = nullptr; - if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (ctor = - jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != NULL)) + jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != nullptr)) return NSK_FALSE; NSK_DISPLAY0("Checking negative: StopThread\n"); @@ -180,7 +180,7 @@ static int checkSignalThread() { */ static int checkGetOwnedMonitorInfo() { jint count; - jobject *monitors = NULL; + jobject *monitors = nullptr; NSK_DISPLAY0("Checking negative: GetOwnedMonitorInfo\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -193,7 +193,7 @@ static int checkGetOwnedMonitorInfo() { /* Check "can_get_current_contended_monitor" function */ static int checkGetCurrentContendedMonitor() { - jobject monitor = NULL; + jobject monitor = nullptr; NSK_DISPLAY0("Checking negative: GetCurrentContendedMonitor\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -245,8 +245,8 @@ static int checkHeapFunctions() { const jlong TAG_VALUE = (123456789L); jlong tag; jint count; - jobject *res_objects = NULL; - jlong *res_tags = NULL; + jobject *res_objects = nullptr; + jlong *res_tags = nullptr; jint dummy_user_data = 0; NSK_DISPLAY0("Checking negative: SetTag\n"); @@ -299,7 +299,7 @@ static int checkHeapFunctions() { */ static int checkLocalVariableFunctions() { jint count; - jvmtiLocalVariableEntry *local_variable_table = NULL; + jvmtiLocalVariableEntry *local_variable_table = nullptr; jobject object_value; jint int_value; jlong long_value; @@ -369,7 +369,7 @@ static int checkLocalVariableFunctions() { static int checkSourceInfoFunctions() { char *name; jint count; - jvmtiLineNumberEntry *line_number_table = NULL; + jvmtiLineNumberEntry *line_number_table = nullptr; NSK_DISPLAY0("Checking negative: GetSourceFileName\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -397,7 +397,7 @@ static int checkRedefineClasses() { NSK_DISPLAY0("Checking negative: RedefineClasses\n"); class_def.klass = klass; class_def.class_byte_count = 0; - class_def.class_bytes = NULL; + class_def.class_bytes = nullptr; if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, jvmti->RedefineClasses(1, &class_def))) return NSK_FALSE; @@ -569,11 +569,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; /* testcase #1: check GetPotentialCapabilities */ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t020/cm01t020.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t020/cm01t020.cpp index 25d4ed9a06e..ccb3a84ea32 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t020/cm01t020.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t020/cm01t020.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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,22 +52,22 @@ extern "C" { /* ========================================================================== */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* test objects */ -static jthread thread = NULL; -static jclass klass = NULL; -static jmethodID method = NULL; -static jfieldID field = NULL; +static jthread thread = nullptr; +static jclass klass = nullptr; +static jmethodID method = nullptr; +static jfieldID field = nullptr; /* ========================================================================== */ static int prepare() { const char* THREAD_NAME = "Debuggee Thread"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; int i; @@ -77,12 +77,12 @@ static int prepare() { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -92,7 +92,7 @@ static int prepare() { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) { + if (info.name != nullptr && (strcmp(info.name, THREAD_NAME) == 0)) { thread = threads[i]; } } @@ -102,16 +102,16 @@ static int prepare() { return NSK_FALSE; /* get tested thread class */ - if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != nullptr)) return NSK_FALSE; /* get tested thread method 'run' */ - if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != NULL)) + if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != nullptr)) return NSK_FALSE; /* get tested thread field 'waitingMonitor' */ if (!NSK_JNI_VERIFY(jni, (field = - jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != NULL)) + jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -151,18 +151,18 @@ static int checkSignalThread() { const char* THREAD_DEATH_CLASS_NAME = "java/lang/ThreadDeath"; const char* THREAD_DEATH_CTOR_NAME = ""; const char* THREAD_DEATH_CTOR_SIGNATURE = "()V"; - jclass cls = NULL; - jmethodID ctor = NULL; - jobject exception = NULL; + jclass cls = nullptr; + jmethodID ctor = nullptr; + jobject exception = nullptr; - if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (ctor = - jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != NULL)) + jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != nullptr)) return NSK_FALSE; NSK_DISPLAY0("Checking negative: StopThread\n"); @@ -181,7 +181,7 @@ static int checkSignalThread() { */ static int checkGetOwnedMonitorInfo() { jint count; - jobject *monitors = NULL; + jobject *monitors = nullptr; NSK_DISPLAY0("Checking negative: GetOwnedMonitorInfo\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -194,7 +194,7 @@ static int checkGetOwnedMonitorInfo() { /* Check "can_get_current_contended_monitor" function */ static int checkGetCurrentContendedMonitor() { - jobject monitor = NULL; + jobject monitor = nullptr; NSK_DISPLAY0("Checking negative: GetCurrentContendedMonitor\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -246,8 +246,8 @@ static int checkHeapFunctions() { const jlong TAG_VALUE = (123456789L); jlong tag; jint count; - jobject *res_objects = NULL; - jlong *res_tags = NULL; + jobject *res_objects = nullptr; + jlong *res_tags = nullptr; jint dummy_user_data = 0; NSK_DISPLAY0("Checking negative: SetTag\n"); @@ -300,7 +300,7 @@ static int checkHeapFunctions() { */ static int checkLocalVariableFunctions() { jint count; - jvmtiLocalVariableEntry *local_variable_table = NULL; + jvmtiLocalVariableEntry *local_variable_table = nullptr; jobject object_value; jint int_value; jlong long_value; @@ -370,7 +370,7 @@ static int checkLocalVariableFunctions() { static int checkSourceInfoFunctions() { char *name; jint count; - jvmtiLineNumberEntry *line_number_table = NULL; + jvmtiLineNumberEntry *line_number_table = nullptr; NSK_DISPLAY0("Checking negative: GetSourceFileName\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -398,7 +398,7 @@ static int checkRedefineClasses() { NSK_DISPLAY0("Checking negative: RedefineClasses\n"); class_def.klass = klass; class_def.class_byte_count = 0; - class_def.class_bytes = NULL; + class_def.class_bytes = nullptr; if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, jvmti->RedefineClasses(1, &class_def))) return NSK_FALSE; @@ -568,11 +568,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; /* testcase #1: check GetPotentialCapabilities */ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t021/cm01t021.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t021/cm01t021.cpp index 829a7c8f3dd..3f6bf3fd92b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t021/cm01t021.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t021/cm01t021.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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,22 +52,22 @@ extern "C" { /* ========================================================================== */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* test objects */ -static jthread thread = NULL; -static jclass klass = NULL; -static jmethodID method = NULL; -static jfieldID field = NULL; +static jthread thread = nullptr; +static jclass klass = nullptr; +static jmethodID method = nullptr; +static jfieldID field = nullptr; /* ========================================================================== */ static int prepare() { const char* THREAD_NAME = "Debuggee Thread"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; int i; @@ -77,12 +77,12 @@ static int prepare() { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -92,7 +92,7 @@ static int prepare() { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) { + if (info.name != nullptr && (strcmp(info.name, THREAD_NAME) == 0)) { thread = threads[i]; } } @@ -102,16 +102,16 @@ static int prepare() { return NSK_FALSE; /* get tested thread class */ - if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != nullptr)) return NSK_FALSE; /* get tested thread method 'run' */ - if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != NULL)) + if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != nullptr)) return NSK_FALSE; /* get tested thread field 'waitingMonitor' */ if (!NSK_JNI_VERIFY(jni, (field = - jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != NULL)) + jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -151,18 +151,18 @@ static int checkSignalThread() { const char* THREAD_DEATH_CLASS_NAME = "java/lang/ThreadDeath"; const char* THREAD_DEATH_CTOR_NAME = ""; const char* THREAD_DEATH_CTOR_SIGNATURE = "()V"; - jclass cls = NULL; - jmethodID ctor = NULL; - jobject exception = NULL; + jclass cls = nullptr; + jmethodID ctor = nullptr; + jobject exception = nullptr; - if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (ctor = - jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != NULL)) + jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != nullptr)) return NSK_FALSE; NSK_DISPLAY0("Checking negative: StopThread\n"); @@ -181,7 +181,7 @@ static int checkSignalThread() { */ static int checkGetOwnedMonitorInfo() { jint count; - jobject *monitors = NULL; + jobject *monitors = nullptr; NSK_DISPLAY0("Checking negative: GetOwnedMonitorInfo\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -194,7 +194,7 @@ static int checkGetOwnedMonitorInfo() { /* Check "can_get_current_contended_monitor" function */ static int checkGetCurrentContendedMonitor() { - jobject monitor = NULL; + jobject monitor = nullptr; NSK_DISPLAY0("Checking negative: GetCurrentContendedMonitor\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -246,8 +246,8 @@ static int checkHeapFunctions() { const jlong TAG_VALUE = (123456789L); jlong tag; jint count; - jobject *res_objects = NULL; - jlong *res_tags = NULL; + jobject *res_objects = nullptr; + jlong *res_tags = nullptr; jint dummy_user_data = 0; NSK_DISPLAY0("Checking negative: SetTag\n"); @@ -300,7 +300,7 @@ static int checkHeapFunctions() { */ static int checkLocalVariableFunctions() { jint count; - jvmtiLocalVariableEntry *local_variable_table = NULL; + jvmtiLocalVariableEntry *local_variable_table = nullptr; jobject object_value; jint int_value; jlong long_value; @@ -370,7 +370,7 @@ static int checkLocalVariableFunctions() { static int checkSourceInfoFunctions() { char *name; jint count; - jvmtiLineNumberEntry *line_number_table = NULL; + jvmtiLineNumberEntry *line_number_table = nullptr; NSK_DISPLAY0("Checking negative: GetSourceFileName\n"); if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, @@ -398,7 +398,7 @@ static int checkRedefineClasses() { NSK_DISPLAY0("Checking negative: RedefineClasses\n"); class_def.klass = klass; class_def.class_byte_count = 0; - class_def.class_bytes = NULL; + class_def.class_bytes = nullptr; if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, jvmti->RedefineClasses(1, &class_def))) return NSK_FALSE; @@ -568,11 +568,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; /* testcase #1: check GetPotentialCapabilities */ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM02/cm02t001/cm02t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM02/cm02t001/cm02t001.cpp index d9037173ae3..94e16b7e98d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM02/cm02t001/cm02t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM02/cm02t001/cm02t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,9 +58,9 @@ extern "C" { static jlong timeout = 0; /* test objects */ -static jthread thread = NULL; -static jclass klass = NULL; -static jobject testedObject = NULL; +static jthread thread = nullptr; +static jclass klass = nullptr; +static jobject testedObject = nullptr; const jlong TESTED_TAG_VALUE = 5555555L; static bool testedObjectNotified = false; @@ -98,34 +98,34 @@ static void JNICALL CompiledMethodLoad(jvmtiEnv *jvmti_env, jmethodID method, jint code_size, const void* code_addr, jint map_length, const jvmtiAddrLocationMap* map, const void* compile_info) { - char *name = NULL; - char *signature = NULL; + char *name = nullptr; + char *signature = nullptr; CompiledMethodLoadEventsCount++; - if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, nullptr))) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY3("CompiledMethodLoad event: %s%s (0x%p)\n", name, signature, code_addr); - if (name != NULL) + if (name != nullptr) jvmti_env->Deallocate((unsigned char*)name); - if (signature != NULL) + if (signature != nullptr) jvmti_env->Deallocate((unsigned char*)signature); } static void JNICALL CompiledMethodUnload(jvmtiEnv *jvmti_env, jmethodID method, const void* code_addr) { - char *name = NULL; - char *sig = NULL; + char *name = nullptr; + char *sig = nullptr; jvmtiError err; CompiledMethodUnloadEventsCount++; NSK_DISPLAY0("CompiledMethodUnload event received\n"); // Check for the case that the class has been unloaded - err = jvmti_env->GetMethodName(method, &name, &sig, NULL); + err = jvmti_env->GetMethodName(method, &name, &sig, nullptr); if (err == JVMTI_ERROR_NONE) { NSK_DISPLAY3("for: \tmethod: name=\"%s\" signature=\"%s\"\n\tnative address=0x%p\n", name, sig, code_addr); @@ -206,12 +206,12 @@ VMObjectAlloc(jvmtiEnv *jvmti_env, JNIEnv* jni_env, VMObjectAllocEventsCount++; - if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(object_klass, &signature, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(object_klass, &signature, nullptr))) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY2("VMObjectAlloc: \"%s\", size=%d\n", signature, size); - if (signature != NULL) + if (signature != nullptr) jvmti_env->Deallocate((unsigned char*)signature); } @@ -219,8 +219,8 @@ static void JNICALL NativeMethodBind(jvmtiEnv* jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method, void* func, void** func_ptr) { jvmtiPhase phase; - char *name = NULL; - char *signature = NULL; + char *name = nullptr; + char *signature = nullptr; NativeMethodBindEventsCount++; @@ -232,16 +232,16 @@ NativeMethodBind(jvmtiEnv* jvmti_env, JNIEnv *jni_env, if (phase != JVMTI_PHASE_START && phase != JVMTI_PHASE_LIVE) return; - if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, nullptr))) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY2("NativeMethodBind event: %s%s\n", name, signature); - if (name != NULL) + if (name != nullptr) jvmti_env->Deallocate((unsigned char*)name); - if (signature != NULL) + if (signature != nullptr) jvmti_env->Deallocate((unsigned char*)signature); } @@ -274,7 +274,7 @@ ObjectFree(jvmtiEnv *jvmti_env, jlong tag) { static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { const char* THREAD_NAME = "Debuggee Thread"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; int i; @@ -284,12 +284,12 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -299,12 +299,12 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) { + if (info.name != nullptr && (strcmp(info.name, THREAD_NAME) == 0)) { thread = threads[i]; } } - if (!NSK_JNI_VERIFY(jni, (thread = jni->NewGlobalRef(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (thread = jni->NewGlobalRef(thread)) != nullptr)) return NSK_FALSE; /* deallocate threads list */ @@ -312,7 +312,7 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { return NSK_FALSE; /* get tested thread class */ - if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -366,7 +366,7 @@ static int checkGetCapabilities(jvmtiEnv* jvmti) { */ static int checkGetOwnedMonitorInfo(jvmtiEnv* jvmti) { jint count; - jobject *monitors = NULL; + jobject *monitors = nullptr; NSK_DISPLAY0("Checking positive: GetOwnedMonitorInfo\n"); if (!NSK_JVMTI_VERIFY(jvmti->GetOwnedMonitorInfo(thread, &count, &monitors))) @@ -378,7 +378,7 @@ static int checkGetOwnedMonitorInfo(jvmtiEnv* jvmti) { /* Check "can_get_current_contended_monitor" function */ static int checkGetCurrentContendedMonitor(jvmtiEnv* jvmti) { - jobject monitor = NULL; + jobject monitor = nullptr; NSK_DISPLAY0("Checking positive: GetCurrentContendedMonitor\n"); if (!NSK_JVMTI_VERIFY(jvmti->GetCurrentContendedMonitor(thread, &monitor))) @@ -433,20 +433,20 @@ class NewFrame { _jni->PushLocalFrame(16); } ~NewFrame() { - _jni->PopLocalFrame(NULL); + _jni->PopLocalFrame(nullptr); } }; static int checkObjectTagEvent(jvmtiEnv* jvmti, JNIEnv* jni) { jlong tag = TESTED_TAG_VALUE; jint count; - jobject *res_objects = NULL; - jlong *res_tags = NULL; + jobject *res_objects = nullptr; + jlong *res_tags = nullptr; NewFrame local_frame(jni); // Create a tested object to tag. - if (!NSK_JNI_VERIFY(jni, (testedObject = jni->NewStringUTF("abcde")) != NULL)) + if (!NSK_JNI_VERIFY(jni, (testedObject = jni->NewStringUTF("abcde")) != nullptr)) return NSK_FALSE; NSK_DISPLAY0("Checking positive: SetTag\n"); @@ -468,8 +468,8 @@ static int checkObjectTagEvent(jvmtiEnv* jvmti, JNIEnv* jni) { static int checkObjectFreeEvent(jvmtiEnv* jvmti) { jlong tag = TESTED_TAG_VALUE; jint count; - jobject *res_objects = NULL; - jlong *res_tags = NULL; + jobject *res_objects = nullptr; + jlong *res_tags = nullptr; // Make some GCs happen for (int i = 0; i < 5; i++) { @@ -493,8 +493,8 @@ static int checkHeapFunctions(jvmtiEnv* jvmti) { const jlong TAG_VALUE = (123456789L); jlong tag; jint count; - jobject *res_objects = NULL; - jlong *res_tags = NULL; + jobject *res_objects = nullptr; + jlong *res_tags = nullptr; jint dummy_user_data = 0; NSK_DISPLAY0("Checking positive: SetTag\n"); @@ -737,7 +737,7 @@ JNIEXPORT jint JNI_OnLoad_cm02t001(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiCapabilities caps; jvmtiEventCallbacks callbacks; @@ -750,7 +750,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add capabilities */ @@ -791,44 +791,44 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* enable events */ if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode( - JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL))) + JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, nullptr))) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode( - JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_LOAD, NULL))) + JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_LOAD, nullptr))) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode( - JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_UNLOAD, NULL))) + JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_UNLOAD, nullptr))) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode( - JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTER, NULL))) + JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTER, nullptr))) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode( - JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTERED, NULL))) + JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTERED, nullptr))) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode( - JVMTI_ENABLE, JVMTI_EVENT_MONITOR_WAIT, NULL))) + JVMTI_ENABLE, JVMTI_EVENT_MONITOR_WAIT, nullptr))) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode( - JVMTI_ENABLE, JVMTI_EVENT_MONITOR_WAITED, NULL))) + JVMTI_ENABLE, JVMTI_EVENT_MONITOR_WAITED, nullptr))) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode( - JVMTI_ENABLE, JVMTI_EVENT_VM_OBJECT_ALLOC, NULL))) + JVMTI_ENABLE, JVMTI_EVENT_VM_OBJECT_ALLOC, nullptr))) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode( - JVMTI_ENABLE, JVMTI_EVENT_NATIVE_METHOD_BIND, NULL))) + JVMTI_ENABLE, JVMTI_EVENT_NATIVE_METHOD_BIND, nullptr))) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode( - JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_START, NULL))) + JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_START, nullptr))) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode( - JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_FINISH, NULL))) + JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_FINISH, nullptr))) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode( - JVMTI_ENABLE, JVMTI_EVENT_OBJECT_FREE, NULL))) + JVMTI_ENABLE, JVMTI_EVENT_OBJECT_FREE, nullptr))) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM03/cm03t001/cm03t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM03/cm03t001/cm03t001.cpp index 40e03426cc0..2c70abc9cb4 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM03/cm03t001/cm03t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM03/cm03t001/cm03t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -62,12 +62,12 @@ extern "C" { static jlong timeout = 0; /* test objects */ -static jthread thread = NULL; -static jclass klass = NULL; -static jmethodID method = NULL; -static jfieldID field = NULL; +static jthread thread = nullptr; +static jclass klass = nullptr; +static jmethodID method = nullptr; +static jfieldID field = nullptr; static jint klass_byte_count = 0; -static unsigned char *klass_bytes = NULL; +static unsigned char *klass_bytes = nullptr; /* event counts */ static int FieldAccessEventsCount = 0; @@ -93,7 +93,7 @@ ClassFileLoadHook(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jint class_data_len, const unsigned char* class_data, jint *new_class_data_len, unsigned char** new_class_data) { - if (name != NULL && (strcmp(name, CLASS_NAME) == 0)) { + if (name != nullptr && (strcmp(name, CLASS_NAME) == 0)) { NSK_DISPLAY1("ClassFileLoadHook: %s\n", name); if (!NSK_JVMTI_VERIFY(jvmti_env->Allocate(class_data_len, &klass_bytes))) nsk_jvmti_setFailStatus(); @@ -103,7 +103,7 @@ ClassFileLoadHook(jvmtiEnv *jvmti_env, JNIEnv *jni_env, } NSK_JVMTI_VERIFY( jvmti_env->SetEventNotificationMode( - JVMTI_DISABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL)); + JVMTI_DISABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, nullptr)); } } @@ -111,22 +111,22 @@ static void JNICALL FieldAccess(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method, jlocation location, jclass field_klass, jobject object, jfieldID field) { - char *name = NULL; - char *signature = NULL; + char *name = nullptr; + char *signature = nullptr; FieldAccessEventsCount++; if (!NSK_JVMTI_VERIFY(jvmti_env->ClearFieldAccessWatch(klass, field))) return; - if (!NSK_JVMTI_VERIFY(jvmti_env->GetFieldName(field_klass, field, &name, &signature, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetFieldName(field_klass, field, &name, &signature, nullptr))) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY2("FieldAccess event: %s:%s\n", name, signature); - if (name != NULL) + if (name != nullptr) jvmti_env->Deallocate((unsigned char*)name); - if (signature != NULL) + if (signature != nullptr) jvmti_env->Deallocate((unsigned char*)signature); } @@ -135,42 +135,42 @@ FieldModification(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method, jlocation location, jclass field_klass, jobject object, jfieldID field, char sig, jvalue new_value) { - char *name = NULL; - char *signature = NULL; + char *name = nullptr; + char *signature = nullptr; FieldModificationEventsCount++; - if (!NSK_JVMTI_VERIFY(jvmti_env->GetFieldName(field_klass, field, &name, &signature, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetFieldName(field_klass, field, &name, &signature, nullptr))) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY2("FieldModification event: %s:%s\n", name, signature); - if (name != NULL) + if (name != nullptr) jvmti_env->Deallocate((unsigned char*)name); - if (signature != NULL) + if (signature != nullptr) jvmti_env->Deallocate((unsigned char*)signature); } static void JNICALL SingleStep(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, jmethodID method, jlocation location) { - char *name = NULL; - char *signature = NULL; + char *name = nullptr; + char *signature = nullptr; SingleStepEventsCount++; NSK_JVMTI_VERIFY( jvmti_env->SetEventNotificationMode( - JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, NULL)); + JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, nullptr)); - if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, nullptr))) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY2("SingleStep event: %s%s\n", name, signature); - if (name != NULL) + if (name != nullptr) jvmti_env->Deallocate((unsigned char*)name); - if (signature != NULL) + if (signature != nullptr) jvmti_env->Deallocate((unsigned char*)signature); } @@ -178,60 +178,60 @@ static void JNICALL Exception(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method, jlocation location, jobject exception, jmethodID catch_method, jlocation catch_location) { - jclass klass = NULL; - char *signature = NULL; + jclass klass = nullptr; + char *signature = nullptr; ExceptionEventsCount++; - if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(exception)) != NULL)) { + if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(exception)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } - if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &signature, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &signature, nullptr))) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY1("Exception event: %s\n", signature); - if (signature != NULL) + if (signature != nullptr) jvmti_env->Deallocate((unsigned char*)signature); } void JNICALL ExceptionCatch(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method, jlocation location, jobject exception) { - jclass klass = NULL; - char *signature = NULL; + jclass klass = nullptr; + char *signature = nullptr; ExceptionCatchEventsCount++; - if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(exception)) != NULL)) { + if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(exception)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } - if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &signature, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &signature, nullptr))) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY1("ExceptionCatch event: %s\n", signature); - if (signature != NULL) + if (signature != nullptr) jvmti_env->Deallocate((unsigned char*)signature); } static void JNICALL Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method, jlocation location) { - char *name = NULL; - char *signature = NULL; + char *name = nullptr; + char *signature = nullptr; BreakpointEventsCount++; - if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, nullptr))) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY2("Breakpoint event: %s%s\n", name, signature); - if (name != NULL) + if (name != nullptr) jvmti_env->Deallocate((unsigned char*)name); - if (signature != NULL) + if (signature != nullptr) jvmti_env->Deallocate((unsigned char*)signature); jvmti_env->NotifyFramePop(thread, 0); @@ -241,36 +241,36 @@ static void JNICALL FramePop(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method, jboolean wasPopedByException) { - char *name = NULL; - char *signature = NULL; + char *name = nullptr; + char *signature = nullptr; FramePopEventsCount++; - if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, nullptr))) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY2("FramePop event: %s%s\n", name, signature); - if (name != NULL) + if (name != nullptr) jvmti_env->Deallocate((unsigned char*)name); - if (signature != NULL) + if (signature != nullptr) jvmti_env->Deallocate((unsigned char*)signature); } static void JNICALL MethodEntry(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method) { - char *name = NULL; - char *signature = NULL; + char *name = nullptr; + char *signature = nullptr; MethodEntryEventsCount++; - if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, nullptr))) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY2("MethodEntry event: %s%s\n", name, signature); - if (name != NULL) + if (name != nullptr) jvmti_env->Deallocate((unsigned char*)name); - if (signature != NULL) + if (signature != nullptr) jvmti_env->Deallocate((unsigned char*)signature); } @@ -278,18 +278,18 @@ static void JNICALL MethodExit(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method, jboolean was_poped_by_exception, jvalue return_value) { - char *name = NULL; - char *signature = NULL; + char *name = nullptr; + char *signature = nullptr; MethodExitEventsCount++; - if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, nullptr))) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY2("MethodExit event: %s%s\n", name, signature); - if (name != NULL) + if (name != nullptr) jvmti_env->Deallocate((unsigned char*)name); - if (signature != NULL) + if (signature != nullptr) jvmti_env->Deallocate((unsigned char*)signature); } @@ -298,7 +298,7 @@ MethodExit(jvmtiEnv *jvmti_env, JNIEnv *jni_env, static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { const char* THREAD_NAME = "Debuggee Thread"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; int i; @@ -308,12 +308,12 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -323,12 +323,12 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) { + if (info.name != nullptr && (strcmp(info.name, THREAD_NAME) == 0)) { thread = threads[i]; } } - if (!NSK_JNI_VERIFY(jni, (thread = jni->NewGlobalRef(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (thread = jni->NewGlobalRef(thread)) != nullptr)) return NSK_FALSE; /* deallocate threads list */ @@ -336,19 +336,19 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { return NSK_FALSE; /* get tested thread class */ - if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != nullptr)) return NSK_FALSE; /* klass is used by other threads - convert to global handle */ - if (!NSK_JNI_VERIFY(jni, (klass = (jclass)jni->NewGlobalRef(klass)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (klass = (jclass)jni->NewGlobalRef(klass)) != nullptr)) return NSK_FALSE; /* get tested thread method 'delay' */ - if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "delay", "()V")) != NULL)) + if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "delay", "()V")) != nullptr)) return NSK_FALSE; /* get tested thread field 'waitingFlag' */ - if (!NSK_JNI_VERIFY(jni, (field = jni->GetFieldID(klass, "waitingFlag", "Z")) != NULL)) + if (!NSK_JNI_VERIFY(jni, (field = jni->GetFieldID(klass, "waitingFlag", "Z")) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -358,11 +358,11 @@ static int prepareEvents(jvmtiEnv* jvmti, JNIEnv* jni) { NSK_DISPLAY0("Prepare events ...\n"); /* get tested thread method 'letItGo' */ - if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "letItGo", "()V")) != NULL)) + if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "letItGo", "()V")) != nullptr)) return NSK_FALSE; /* get tested thread field 'waitingFlag' */ - if (!NSK_JNI_VERIFY(jni, (field = jni->GetFieldID(klass, "waitingFlag", "Z")) != NULL)) + if (!NSK_JNI_VERIFY(jni, (field = jni->GetFieldID(klass, "waitingFlag", "Z")) != nullptr)) return NSK_FALSE; if (!NSK_JVMTI_VERIFY(jvmti->SetFieldAccessWatch(klass, field))) @@ -376,13 +376,13 @@ static int prepareEvents(jvmtiEnv* jvmti, JNIEnv* jni) { /* enable events */ if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, NULL))) + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, nullptr))) return JNI_ERR; if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION, NULL))) + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION, nullptr))) return JNI_ERR; if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION_CATCH, NULL))) + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION_CATCH, nullptr))) return JNI_ERR; if (!NSK_JVMTI_VERIFY( jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_ENTRY, thread))) @@ -483,7 +483,7 @@ static int checkRedefineClasses(jvmtiEnv* jvmti) { jvmtiClassDefinition class_def; jboolean is_obsolete; - if (!NSK_VERIFY(klass_byte_count != 0 && klass_bytes != NULL)) + if (!NSK_VERIFY(klass_byte_count != 0 && klass_bytes != nullptr)) return NSK_FALSE; NSK_DISPLAY0("Checking positive: RedefineClasses\n"); @@ -516,7 +516,7 @@ static int checkGetSourceFileName(jvmtiEnv* jvmti) { */ static int checkGetLineNumberTable(jvmtiEnv* jvmti) { jint count; - jvmtiLineNumberEntry *line_number_table = NULL; + jvmtiLineNumberEntry *line_number_table = nullptr; NSK_DISPLAY0("Checking positive: GetLineNumberTable\n"); if (!NSK_JVMTI_VERIFY(jvmti->GetLineNumberTable(method, &count, &line_number_table))) @@ -542,7 +542,7 @@ static int checkGetSourceDebugExtension(jvmtiEnv* jvmti) { */ static int checkLocalVariableFunctions(jvmtiEnv* jvmti) { jint count; - jvmtiLocalVariableEntry *local_variable_table = NULL; + jvmtiLocalVariableEntry *local_variable_table = nullptr; jobject object_value; jint int_value; jlong long_value; @@ -680,18 +680,18 @@ static int checkSignalThread(jvmtiEnv* jvmti, JNIEnv* jni) { const char* THREAD_DEATH_CLASS_NAME = "java/lang/ThreadDeath"; const char* THREAD_DEATH_CTOR_NAME = ""; const char* THREAD_DEATH_CTOR_SIGNATURE = "()V"; - jclass cls = NULL; - jmethodID ctor = NULL; - jobject exception = NULL; + jclass cls = nullptr; + jmethodID ctor = nullptr; + jobject exception = nullptr; - if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (ctor = - jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != NULL)) + jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != nullptr)) return NSK_FALSE; NSK_DISPLAY0("Checking positive: InterruptThread\n"); @@ -848,7 +848,7 @@ JNIEXPORT jint JNI_OnLoad_cm03t001(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiCapabilities caps; jvmtiEventCallbacks callbacks; @@ -861,7 +861,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add capabilities */ @@ -904,23 +904,23 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* enable events */ if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL))) + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, nullptr))) return JNI_ERR; if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FIELD_ACCESS, NULL))) + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FIELD_ACCESS, nullptr))) return JNI_ERR; if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FIELD_MODIFICATION, NULL))) + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FIELD_MODIFICATION, nullptr))) return JNI_ERR; if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL))) + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, nullptr))) return JNI_ERR; if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FRAME_POP, NULL))) + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FRAME_POP, nullptr))) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC01/tc01t001/tc01t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC01/tc01t001/tc01t001.cpp index 852c148dc6d..c744347213e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC01/tc01t001/tc01t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC01/tc01t001/tc01t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -35,9 +35,9 @@ extern "C" { static jlong timeout = 0; /* test objects */ -static jthread thread = NULL; -static jobject object_M1 = NULL; -static jobject object_M2 = NULL; +static jthread thread = nullptr; +static jobject object_M1 = nullptr; +static jobject object_M2 = nullptr; /* ========================================================================== */ @@ -45,10 +45,10 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { const char* THREAD_NAME = "Debuggee Thread"; const char* FIELD_SIG = "Ljava/lang/Object;"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; - jfieldID field = NULL; - jclass klass = NULL; + jfieldID field = nullptr; + jclass klass = nullptr; int i; NSK_DISPLAY0("Prepare: find tested thread\n"); @@ -57,12 +57,12 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -72,11 +72,11 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) { + if (info.name != nullptr && (strcmp(info.name, THREAD_NAME) == 0)) { thread = threads[i]; } - if (info.name != NULL) { + if (info.name != nullptr) { if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)info.name))) return NSK_FALSE; } @@ -87,21 +87,21 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { return NSK_FALSE; /* get tested thread class */ - if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != nullptr)) return NSK_FALSE; /* get tested thread field 'M1' */ - if (!NSK_JNI_VERIFY(jni, (field = jni->GetFieldID(klass, "M1", FIELD_SIG)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (field = jni->GetFieldID(klass, "M1", FIELD_SIG)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (object_M1 = jni->GetObjectField(thread, field)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (object_M1 = jni->GetObjectField(thread, field)) != nullptr)) return NSK_FALSE; /* get tested thread field 'M2' */ - if (!NSK_JNI_VERIFY(jni, (field = jni->GetFieldID(klass, "M2", FIELD_SIG)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (field = jni->GetFieldID(klass, "M2", FIELD_SIG)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (object_M2 = jni->GetObjectField(thread, field)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (object_M2 = jni->GetObjectField(thread, field)) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -121,14 +121,14 @@ static int checkGetObjectMonitorUsage(jvmtiEnv* jvmti, JNIEnv* jni, return NSK_FALSE; if (nsk_getVerboseMode()) { - if (inf.owner == NULL) { + if (inf.owner == nullptr) { NSK_DISPLAY0("\towner: none (0x0)\n"); } else { if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(inf.owner, &tinf))) { result = NSK_FALSE; } else { NSK_DISPLAY2("\towner: %s (0x%p)\n", tinf.name, inf.owner); - if (tinf.name != NULL) { + if (tinf.name != nullptr) { if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)tinf.name))) result = NSK_FALSE; } @@ -145,7 +145,7 @@ static int checkGetObjectMonitorUsage(jvmtiEnv* jvmti, JNIEnv* jni, } else { NSK_DISPLAY3("\t\t%2d: %s (0x%p)\n", i, tinf.name, inf.waiters[i]); - if (tinf.name != NULL) { + if (tinf.name != nullptr) { if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)tinf.name))) result = NSK_FALSE; } @@ -162,7 +162,7 @@ static int checkGetObjectMonitorUsage(jvmtiEnv* jvmti, JNIEnv* jni, } else { NSK_DISPLAY3("\t\t%2d: %s (0x%p)\n", i, tinf.name, inf.notify_waiters[i]); - if (tinf.name != NULL) { + if (tinf.name != nullptr) { if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)tinf.name))) result = NSK_FALSE; } @@ -185,11 +185,11 @@ static int checkGetObjectMonitorUsage(jvmtiEnv* jvmti, JNIEnv* jni, result = NSK_FALSE; /* deallocate monitor waiters arrays */ - if (inf.waiters != NULL) { + if (inf.waiters != nullptr) { if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)inf.waiters))) result = NSK_FALSE; } - if (inf.notify_waiters != NULL) { + if (inf.notify_waiters != nullptr) { if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)inf.notify_waiters))) result = NSK_FALSE; } @@ -242,7 +242,7 @@ JNIEXPORT jint JNI_OnLoad_tc01t001(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiCapabilities caps; /* init framework and parse options */ @@ -254,7 +254,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add capabilities */ @@ -264,7 +264,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC02/tc02t001/tc02t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC02/tc02t001/tc02t001.cpp index 0c3fbf88cb1..e3e4a244ba8 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC02/tc02t001/tc02t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC02/tc02t001/tc02t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -35,8 +35,8 @@ extern "C" { static jlong timeout = 0; /* test objects */ -static jthread thread = NULL; -static jobject object_M = NULL; +static jthread thread = nullptr; +static jobject object_M = nullptr; /* line numbers of "synchronized (M)" clauses in java part of the test */ static jint lines[] = { 48, 53, 58 }; static volatile int enterEventsCount = 0; @@ -45,9 +45,9 @@ static volatile int enteredEventsCount = 0; /* ========================================================================== */ static jint findLineNumber(jvmtiEnv *jvmti, jthread thread) { - jmethodID method = NULL; + jmethodID method = nullptr; jlocation location; - jvmtiLineNumberEntry* table = NULL; + jvmtiLineNumberEntry* table = nullptr; jint count = 0; jint line = 0; int i; @@ -55,7 +55,7 @@ static jint findLineNumber(jvmtiEnv *jvmti, jthread thread) { if (!NSK_JVMTI_VERIFY(jvmti->GetFrameLocation(thread, 0, &method, &location))) return 0; - if (!NSK_VERIFY(method != NULL)) + if (!NSK_VERIFY(method != nullptr)) return 0; if (!NSK_VERIFY(location != -1)) @@ -64,7 +64,7 @@ static jint findLineNumber(jvmtiEnv *jvmti, jthread thread) { if (!NSK_JVMTI_VERIFY(jvmti->GetLineNumberTable(method, &count, &table))) return 0; - if (!NSK_VERIFY(table != NULL)) + if (!NSK_VERIFY(table != nullptr)) return 0; if (!NSK_VERIFY(count > 0)) @@ -78,7 +78,7 @@ static jint findLineNumber(jvmtiEnv *jvmti, jthread thread) { line = table[i-1].line_number; - if (table != NULL) { + if (table != nullptr) { if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)table))) return 0; } @@ -92,13 +92,13 @@ void JNICALL MonitorContendedEnter(jvmtiEnv *jvmti, JNIEnv* jni, jthread thr, jobject obj) { jint line = 0; - if (!NSK_VERIFY(thr != NULL)) { + if (!NSK_VERIFY(thr != nullptr)) { nsk_jvmti_setFailStatus(); NSK_COMPLAIN1("MonitorContendedEnter event: thread=%p\n", thr); return; } - if (!NSK_VERIFY(obj != NULL)) { + if (!NSK_VERIFY(obj != nullptr)) { nsk_jvmti_setFailStatus(); NSK_COMPLAIN1("MonitorContendedEnter event: object=%p\n", obj); return; @@ -137,13 +137,13 @@ void JNICALL MonitorContendedEntered(jvmtiEnv *jvmti, JNIEnv* jni, jthread thr, jobject obj) { jint line = 0; - if (!NSK_VERIFY(thr != NULL)) { + if (!NSK_VERIFY(thr != nullptr)) { nsk_jvmti_setFailStatus(); NSK_COMPLAIN1("MonitorContendedEntered event: thread=%p\n", thr); return; } - if (!NSK_VERIFY(obj != NULL)) { + if (!NSK_VERIFY(obj != nullptr)) { nsk_jvmti_setFailStatus(); NSK_COMPLAIN1("MonitorContendedEntered event: object=%p\n", obj); return; @@ -184,10 +184,10 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { const char* THREAD_NAME = "Debuggee Thread"; const char* FIELD_SIG = "Ljava/lang/Object;"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; - jfieldID field = NULL; - jclass klass = NULL; + jfieldID field = nullptr; + jclass klass = nullptr; int i; NSK_DISPLAY0("Prepare: find tested thread\n"); @@ -196,12 +196,12 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -211,11 +211,11 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) { + if (info.name != nullptr && (strcmp(info.name, THREAD_NAME) == 0)) { thread = threads[i]; } - if (info.name != NULL) { + if (info.name != nullptr) { if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)info.name))) return NSK_FALSE; } @@ -225,40 +225,40 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threads))) return NSK_FALSE; - if (thread == NULL) { + if (thread == nullptr) { NSK_COMPLAIN0("Debuggee thread not found"); return NSK_FALSE; } /* make thread accessable for a long time */ - if (!NSK_JNI_VERIFY(jni, (thread = jni->NewGlobalRef(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (thread = jni->NewGlobalRef(thread)) != nullptr)) return NSK_FALSE; /* get tested thread class */ - if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != nullptr)) return NSK_FALSE; /* get tested thread field 'M' */ - if (!NSK_JNI_VERIFY(jni, (field = jni->GetFieldID(klass, "M", FIELD_SIG)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (field = jni->GetFieldID(klass, "M", FIELD_SIG)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (object_M = jni->GetObjectField(thread, field)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (object_M = jni->GetObjectField(thread, field)) != nullptr)) return NSK_FALSE; /* make object accessable for a long time */ - if (!NSK_JNI_VERIFY(jni, (object_M = jni->NewGlobalRef(object_M)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (object_M = jni->NewGlobalRef(object_M)) != nullptr)) return NSK_FALSE; /* enable MonitorContendedEntered event */ if (!NSK_JVMTI_VERIFY( jvmti->SetEventNotificationMode( - JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTER, NULL))) + JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTER, nullptr))) return NSK_FALSE; /* enable MonitorContendedEntered event */ if (!NSK_JVMTI_VERIFY( jvmti->SetEventNotificationMode( - JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTERED, NULL))) + JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTERED, nullptr))) return NSK_FALSE; return NSK_TRUE; @@ -269,7 +269,7 @@ static int clean(jvmtiEnv* jvmti, JNIEnv* jni) { /* disable MonitorContendedEntered event */ if (!NSK_JVMTI_VERIFY( jvmti->SetEventNotificationMode( - JVMTI_DISABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTERED, NULL))) + JVMTI_DISABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTERED, nullptr))) nsk_jvmti_setFailStatus(); return NSK_TRUE; @@ -334,7 +334,7 @@ JNIEXPORT jint JNI_OnLoad_tc02t001(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiCapabilities caps; jvmtiEventCallbacks callbacks; @@ -347,7 +347,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add capabilities */ @@ -364,7 +364,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp index 9760e0c0207..73d8ef539a6 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t001/tc03t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,15 +41,15 @@ typedef struct { static jlong timeout = 0; /* test objects */ -static threadDesc *threadList = NULL; +static threadDesc *threadList = nullptr; static jint threads_count = 0; static int numberOfDeadlocks = 0; /* ========================================================================== */ static int printDeadlock(jvmtiEnv* jvmti, JNIEnv* jni, int dThread) { - jobject monitor = NULL; - jclass klass = NULL; + jobject monitor = nullptr; + jclass klass = nullptr; jvmtiMonitorUsage usageInfo; int pThread, cThread; char* name; @@ -60,10 +60,10 @@ static int printDeadlock(jvmtiEnv* jvmti, JNIEnv* jni, int dThread) { if (!NSK_JVMTI_VERIFY( jvmti->GetCurrentContendedMonitor(threadList[pThread].thread, &monitor))) return NSK_FALSE; - if (monitor != NULL) { - if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(monitor)) != NULL)) + if (monitor != nullptr) { + if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(monitor)) != nullptr)) return NSK_FALSE; - if (!NSK_JVMTI_VERIFY(jvmti->GetClassSignature(klass, &name, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->GetClassSignature(klass, &name, nullptr))) return NSK_FALSE; NSK_DISPLAY2(" waiting to lock %p (%s),\n", monitor, name); jvmti->Deallocate((unsigned char*)name); @@ -72,16 +72,16 @@ static int printDeadlock(jvmtiEnv* jvmti, JNIEnv* jni, int dThread) { } if (!NSK_JVMTI_VERIFY(jvmti->GetObjectMonitorUsage(monitor, &usageInfo))) return NSK_FALSE; - if (usageInfo.owner == NULL) + if (usageInfo.owner == nullptr) break; for (cThread = 0; cThread < threads_count; cThread++) { if (jni->IsSameObject(threadList[cThread].thread, usageInfo.owner)) break; } - if (usageInfo.waiters != NULL) { + if (usageInfo.waiters != nullptr) { jvmti->Deallocate((unsigned char*)usageInfo.waiters); } - if (usageInfo.notify_waiters != NULL) { + if (usageInfo.notify_waiters != nullptr) { jvmti->Deallocate((unsigned char*)usageInfo.notify_waiters); } if (!NSK_VERIFY(cThread != threads_count)) @@ -97,8 +97,8 @@ static int printDeadlock(jvmtiEnv* jvmti, JNIEnv* jni, int dThread) { static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { jvmtiThreadInfo info; - jthread *threads = NULL; - jobject monitor = NULL; + jthread *threads = nullptr; + jobject monitor = nullptr; jvmtiMonitorUsage usageInfo; int tDfn = 0, gDfn = 0; int pThread, cThread; @@ -110,7 +110,7 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; if (!NSK_JVMTI_VERIFY( @@ -118,7 +118,7 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { return NSK_FALSE; for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -144,20 +144,20 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { if (!NSK_JVMTI_VERIFY( jvmti->GetCurrentContendedMonitor(threadList[pThread].thread, &monitor))) return NSK_FALSE; - if (monitor == NULL) + if (monitor == nullptr) break; if (!NSK_JVMTI_VERIFY(jvmti->GetObjectMonitorUsage(monitor, &usageInfo))) return NSK_FALSE; - if (usageInfo.owner == NULL) + if (usageInfo.owner == nullptr) break; for (cThread = 0; cThread < threads_count; cThread++) { if (jni->IsSameObject(threadList[cThread].thread, usageInfo.owner)) break; } - if (usageInfo.waiters != NULL) { + if (usageInfo.waiters != nullptr) { jvmti->Deallocate((unsigned char*)usageInfo.waiters); } - if (usageInfo.notify_waiters != NULL) { + if (usageInfo.notify_waiters != nullptr) { jvmti->Deallocate((unsigned char*)usageInfo.notify_waiters); } if (!NSK_VERIFY(cThread != threads_count)) @@ -180,7 +180,7 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { /* deallocate thread names */ for (i = 0; i < threads_count; i++) { - if (threadList[i].name != NULL) { + if (threadList[i].name != nullptr) { if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threadList[i].name))) return NSK_FALSE; } @@ -228,7 +228,7 @@ JNIEXPORT jint JNI_OnLoad_tc03t001(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiCapabilities caps; /* init framework and parse options */ @@ -240,7 +240,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add capabilities */ @@ -251,7 +251,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t002/tc03t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t002/tc03t002.cpp index f98c80c34c1..9740919cdcd 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t002/tc03t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC03/tc03t002/tc03t002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,15 +41,15 @@ typedef struct { static jlong timeout = 0; /* test objects */ -static threadDesc *threadList = NULL; +static threadDesc *threadList = nullptr; static jint threads_count = 0; static int numberOfDeadlocks = 0; /* ========================================================================== */ static int printDeadlock(jvmtiEnv* jvmti, JNIEnv* jni, int dThread) { - jobject monitor = NULL; - jclass klass = NULL; + jobject monitor = nullptr; + jclass klass = nullptr; jvmtiMonitorUsage usageInfo; int pThread, cThread; char* name; @@ -60,10 +60,10 @@ static int printDeadlock(jvmtiEnv* jvmti, JNIEnv* jni, int dThread) { if (!NSK_JVMTI_VERIFY( jvmti->GetCurrentContendedMonitor(threadList[pThread].thread, &monitor))) return NSK_FALSE; - if (monitor != NULL) { - if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(monitor)) != NULL)) + if (monitor != nullptr) { + if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(monitor)) != nullptr)) return NSK_FALSE; - if (!NSK_JVMTI_VERIFY(jvmti->GetClassSignature(klass, &name, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->GetClassSignature(klass, &name, nullptr))) return NSK_FALSE; NSK_DISPLAY2(" waiting to lock %p (%s),\n", monitor, name); jvmti->Deallocate((unsigned char*)name); @@ -72,16 +72,16 @@ static int printDeadlock(jvmtiEnv* jvmti, JNIEnv* jni, int dThread) { } if (!NSK_JVMTI_VERIFY(jvmti->GetObjectMonitorUsage(monitor, &usageInfo))) return NSK_FALSE; - if (usageInfo.owner == NULL) + if (usageInfo.owner == nullptr) break; for (cThread = 0; cThread < threads_count; cThread++) { if (jni->IsSameObject(threadList[cThread].thread, usageInfo.owner)) break; } - if (usageInfo.waiters != NULL) { + if (usageInfo.waiters != nullptr) { jvmti->Deallocate((unsigned char*)usageInfo.waiters); } - if (usageInfo.notify_waiters != NULL) { + if (usageInfo.notify_waiters != nullptr) { jvmti->Deallocate((unsigned char*)usageInfo.notify_waiters); } if (!NSK_VERIFY(cThread != threads_count)) @@ -97,8 +97,8 @@ static int printDeadlock(jvmtiEnv* jvmti, JNIEnv* jni, int dThread) { static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { jvmtiThreadInfo info; - jthread *threads = NULL; - jobject monitor = NULL; + jthread *threads = nullptr; + jobject monitor = nullptr; jvmtiMonitorUsage usageInfo; int tDfn = 0, gDfn = 0; int pThread, cThread; @@ -110,7 +110,7 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; if (!NSK_JVMTI_VERIFY( @@ -118,7 +118,7 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { return NSK_FALSE; for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -144,20 +144,20 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { if (!NSK_JVMTI_VERIFY( jvmti->GetCurrentContendedMonitor(threadList[pThread].thread, &monitor))) return NSK_FALSE; - if (monitor == NULL) + if (monitor == nullptr) break; if (!NSK_JVMTI_VERIFY(jvmti->GetObjectMonitorUsage(monitor, &usageInfo))) return NSK_FALSE; - if (usageInfo.owner == NULL) + if (usageInfo.owner == nullptr) break; for (cThread = 0; cThread < threads_count; cThread++) { if (jni->IsSameObject(threadList[cThread].thread, usageInfo.owner)) break; } - if (usageInfo.waiters != NULL) { + if (usageInfo.waiters != nullptr) { jvmti->Deallocate((unsigned char*)usageInfo.waiters); } - if (usageInfo.notify_waiters != NULL) { + if (usageInfo.notify_waiters != nullptr) { jvmti->Deallocate((unsigned char*)usageInfo.notify_waiters); } if (!NSK_VERIFY(cThread != threads_count)) @@ -180,7 +180,7 @@ static int findDeadlockThreads(jvmtiEnv* jvmti, JNIEnv* jni) { /* deallocate thread names */ for (i = 0; i < threads_count; i++) { - if (threadList[i].name != NULL) { + if (threadList[i].name != nullptr) { if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threadList[i].name))) return NSK_FALSE; } @@ -228,7 +228,7 @@ JNIEXPORT jint JNI_OnLoad_tc03t002(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiCapabilities caps; /* init framework and parse options */ @@ -240,7 +240,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add capabilities */ @@ -251,7 +251,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC04/tc04t001/tc04t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC04/tc04t001/tc04t001.cpp index 6000051f1ad..f850b0d89f4 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC04/tc04t001/tc04t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC04/tc04t001/tc04t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -35,12 +35,12 @@ extern "C" { static jlong timeout = 0; /* test objects */ -static jclass object_M = NULL; +static jclass object_M = nullptr; static volatile int waitEventsCount = 0; static volatile int waitedEventsCount = 0; static volatile int enterEventsCount = 0; static volatile int enteredEventsCount = 0; -static jrawMonitorID syncLock = NULL; +static jrawMonitorID syncLock = nullptr; static jboolean lockSyncLock(jvmtiEnv* jvmti) { @@ -62,12 +62,12 @@ void JNICALL MonitorWait(jvmtiEnv *jvmti, JNIEnv* jni, jthread thr, jobject obj, jlong tout) { - if (!NSK_VERIFY(thr != NULL)) { + if (!NSK_VERIFY(thr != nullptr)) { nsk_jvmti_setFailStatus(); return; } - if (!NSK_VERIFY(obj != NULL)) { + if (!NSK_VERIFY(obj != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -85,12 +85,12 @@ void JNICALL MonitorWaited(jvmtiEnv *jvmti, JNIEnv* jni, jthread thr, jobject obj, jboolean timed_out) { - if (!NSK_VERIFY(thr != NULL)) { + if (!NSK_VERIFY(thr != nullptr)) { nsk_jvmti_setFailStatus(); return; } - if (!NSK_VERIFY(obj != NULL)) { + if (!NSK_VERIFY(obj != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -107,12 +107,12 @@ MonitorWaited(jvmtiEnv *jvmti, JNIEnv* jni, void JNICALL MonitorContendedEnter(jvmtiEnv *jvmti, JNIEnv* jni, jthread thr, jobject obj) { - if (!NSK_VERIFY(thr != NULL)) { + if (!NSK_VERIFY(thr != nullptr)) { nsk_jvmti_setFailStatus(); return; } - if (!NSK_VERIFY(obj != NULL)) { + if (!NSK_VERIFY(obj != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -129,12 +129,12 @@ MonitorContendedEnter(jvmtiEnv *jvmti, JNIEnv* jni, jthread thr, jobject obj) { void JNICALL MonitorContendedEntered(jvmtiEnv *jvmti, JNIEnv* jni, jthread thr, jobject obj) { - if (!NSK_VERIFY(thr != NULL)) { + if (!NSK_VERIFY(thr != nullptr)) { nsk_jvmti_setFailStatus(); return; } - if (!NSK_VERIFY(obj != NULL)) { + if (!NSK_VERIFY(obj != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -155,10 +155,10 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { NSK_DISPLAY0("Obtain tested object from debugee thread class\n"); - if (!NSK_JNI_VERIFY(jni, (object_M = jni->FindClass(CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (object_M = jni->FindClass(CLASS_NAME)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (object_M = (jclass)jni->NewGlobalRef(object_M)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (object_M = (jclass)jni->NewGlobalRef(object_M)) != nullptr)) return NSK_FALSE; if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("_syncLock", &syncLock))) @@ -166,24 +166,24 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { /* enable MonitorWait event */ if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_WAIT, NULL))) + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_WAIT, nullptr))) nsk_jvmti_setFailStatus(); /* enable MonitorWaited event */ if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_WAITED, NULL))) + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_WAITED, nullptr))) nsk_jvmti_setFailStatus(); /* enable MonitorContendedEnter event */ if (!NSK_JVMTI_VERIFY( jvmti->SetEventNotificationMode( - JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTER, NULL))) + JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTER, nullptr))) nsk_jvmti_setFailStatus(); /* enable MonitorContendedEntered event */ if (!NSK_JVMTI_VERIFY( jvmti->SetEventNotificationMode( - JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTERED, NULL))) + JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTERED, nullptr))) nsk_jvmti_setFailStatus(); return NSK_TRUE; @@ -193,24 +193,24 @@ static int clean(jvmtiEnv* jvmti, JNIEnv* jni) { /* disable MonitorWait event */ if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_MONITOR_WAIT, NULL))) + jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_MONITOR_WAIT, nullptr))) nsk_jvmti_setFailStatus(); /* disable MonitorWaited event */ if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_MONITOR_WAITED, NULL))) + jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_MONITOR_WAITED, nullptr))) nsk_jvmti_setFailStatus(); /* disable MonitorContendedEnter event */ if (!NSK_JVMTI_VERIFY( jvmti->SetEventNotificationMode( - JVMTI_DISABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTER, NULL))) + JVMTI_DISABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTER, nullptr))) nsk_jvmti_setFailStatus(); /* disable MonitorContendedEntered event */ if (!NSK_JVMTI_VERIFY( jvmti->SetEventNotificationMode( - JVMTI_DISABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTERED, NULL))) + JVMTI_DISABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTERED, nullptr))) nsk_jvmti_setFailStatus(); if (!NSK_JVMTI_VERIFY(jvmti->DestroyRawMonitor(syncLock))) @@ -296,7 +296,7 @@ JNIEXPORT jint JNI_OnLoad_tc04t001(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiCapabilities caps; jvmtiEventCallbacks callbacks; @@ -309,7 +309,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add capabilities */ @@ -329,7 +329,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC05/tc05t001/tc05t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC05/tc05t001/tc05t001.cpp index aead5a92589..3c3c0e37703 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC05/tc05t001/tc05t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC05/tc05t001/tc05t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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,8 +49,8 @@ static const jlong EXPECTED_ACCURACY = 10; // high frequency clock updates expec static jlong timeout = 0; /* test objects */ -static jthread thread = NULL; -static jobject object_M = NULL; +static jthread thread = nullptr; +static jobject object_M = nullptr; static volatile int waitEventsCount = 0; static volatile int waitedEventsCount = 0; static jlong waitTime = 0; @@ -65,12 +65,12 @@ MonitorWait(jvmtiEnv *jvmti, JNIEnv* jni, jthread thr, jobject obj, jlong tout) { char buffer[32]; - if (!NSK_VERIFY(thr != NULL)) { + if (!NSK_VERIFY(thr != nullptr)) { nsk_jvmti_setFailStatus(); return; } - if (!NSK_VERIFY(obj != NULL)) { + if (!NSK_VERIFY(obj != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -104,12 +104,12 @@ MonitorWaited(jvmtiEnv *jvmti, JNIEnv* jni, jthread thr, jobject obj, jboolean timed_out) { char buffer[32]; - if (!NSK_VERIFY(thr != NULL)) { + if (!NSK_VERIFY(thr != nullptr)) { nsk_jvmti_setFailStatus(); return; } - if (!NSK_VERIFY(obj != NULL)) { + if (!NSK_VERIFY(obj != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -140,10 +140,10 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { const char* THREAD_NAME = "Debuggee Thread"; const char* FIELD_SIG = "Ljava/lang/Object;"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; - jfieldID field = NULL; - jclass klass = NULL; + jfieldID field = nullptr; + jclass klass = nullptr; int i; NSK_DISPLAY0("Prepare: find tested thread\n"); @@ -152,12 +152,12 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -167,11 +167,11 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) { + if (info.name != nullptr && (strcmp(info.name, THREAD_NAME) == 0)) { thread = threads[i]; } - if (info.name != NULL) { + if (info.name != nullptr) { if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)info.name))) return NSK_FALSE; } @@ -181,38 +181,38 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threads))) return NSK_FALSE; - if (thread == NULL) { + if (thread == nullptr) { NSK_COMPLAIN0("Debuggee thread not found"); return NSK_FALSE; } /* make thread accessable for a long time */ - if (!NSK_JNI_VERIFY(jni, (thread = jni->NewGlobalRef(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (thread = jni->NewGlobalRef(thread)) != nullptr)) return NSK_FALSE; /* get tested thread class */ - if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != nullptr)) return NSK_FALSE; /* get tested thread field 'M' */ - if (!NSK_JNI_VERIFY(jni, (field = jni->GetFieldID(klass, "M", FIELD_SIG)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (field = jni->GetFieldID(klass, "M", FIELD_SIG)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (object_M = jni->GetObjectField(thread, field)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (object_M = jni->GetObjectField(thread, field)) != nullptr)) return NSK_FALSE; /* make object accessable for a long time */ - if (!NSK_JNI_VERIFY(jni, (object_M = jni->NewGlobalRef(object_M)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (object_M = jni->NewGlobalRef(object_M)) != nullptr)) return NSK_FALSE; /* enable MonitorWait event */ if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_WAIT, NULL))) + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_WAIT, nullptr))) return NSK_FALSE; /* enable MonitorWaited event */ if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_WAITED, NULL))) + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_WAITED, nullptr))) return NSK_FALSE; return NSK_TRUE; @@ -222,12 +222,12 @@ static int clean(jvmtiEnv* jvmti, JNIEnv* jni) { /* disable MonitorWait event */ if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_MONITOR_WAIT, NULL))) + jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_MONITOR_WAIT, nullptr))) nsk_jvmti_setFailStatus(); /* disable MonitorWaited event */ if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_MONITOR_WAITED, NULL))) + jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_MONITOR_WAITED, nullptr))) nsk_jvmti_setFailStatus(); return NSK_TRUE; @@ -310,7 +310,7 @@ JNIEXPORT jint JNI_OnLoad_tc05t001(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiCapabilities caps; jvmtiEventCallbacks callbacks; @@ -323,7 +323,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add capabilities */ @@ -340,7 +340,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM01/em01t001/em01t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM01/em01t001/em01t001.cpp index 500f4ca655f..55a97693008 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM01/em01t001/em01t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM01/em01t001/em01t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ extern "C" { /* ============================================================================= */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; -static jrawMonitorID syncLock = NULL; +static jrawMonitorID syncLock = nullptr; /* constant names */ #define JVMTI_EVENT_COUNT (int)(JVMTI_MAX_EVENT_TYPE_VAL - JVMTI_MIN_EVENT_TYPE_VAL + 1) @@ -127,7 +127,7 @@ classEventsHandler(jvmtiEvent event, jvmtiEnv* jvmti_env, JNIEnv* jni_env, if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)className))) { nsk_jvmti_setFailStatus(); } - if (generic != NULL) + if (generic != nullptr) if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)generic))) { nsk_jvmti_setFailStatus(); } @@ -178,7 +178,7 @@ threadEventHandler(jvmtiEvent event, jvmtiEnv* jvmti_env, JNIEnv* jni_env, if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)className))) { nsk_jvmti_setFailStatus(); } - if (generic != NULL) + if (generic != nullptr) if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)generic))) { nsk_jvmti_setFailStatus(); } @@ -282,7 +282,7 @@ cbThreadEnd(jvmtiEnv* jvmti_env, JNIEnv* jni_env, jthread thread) { static int enableEvent(jvmtiEventMode enable, jvmtiEvent event) { NSK_DISPLAY1("enabling %s\n", TranslateEvent(event)); - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(enable, event, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(enable, event, nullptr))) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -427,7 +427,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { classLoaderCount = nsk_jvmti_findOptionIntValue(CLASS_LOADER_COUNT_PARAM, 10); jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("_syncLock", &syncLock))) { @@ -452,7 +452,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; currentPhase = JVMTI_PHASE_PRIMORDIAL; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM01/em01t002/em01t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM01/em01t002/em01t002.cpp index d314b16ce2e..7a3700c0863 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM01/em01t002/em01t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM01/em01t002/em01t002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ extern "C" { /* ============================================================================= */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; -static jrawMonitorID syncLock = NULL; +static jrawMonitorID syncLock = nullptr; /* constant names */ #define JVMTI_EVENT_COUNT (int)(JVMTI_MAX_EVENT_TYPE_VAL - JVMTI_MIN_EVENT_TYPE_VAL + 1) @@ -187,7 +187,7 @@ classEventsHandler(jvmtiEvent event, jvmtiEnv* jvmti_env, JNIEnv* jni_env, if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)className))) { nsk_jvmti_setFailStatus(); } - if (generic != NULL) + if (generic != nullptr) if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)generic))) { nsk_jvmti_setFailStatus(); } @@ -239,7 +239,7 @@ threadEventHandler(jvmtiEvent event, jvmtiEnv* jvmti_env, JNIEnv* jni_env, if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)className))) { nsk_jvmti_setFailStatus(); } - if (generic != NULL) + if (generic != nullptr) if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)generic))) { nsk_jvmti_setFailStatus(); } @@ -350,7 +350,7 @@ enableEvent(jvmtiEventMode enable, jvmtiEvent event) { } - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(enable, event, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(enable, event, nullptr))) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -494,7 +494,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { classLoaderCount = nsk_jvmti_findOptionIntValue(CLASS_LOADER_COUNT_PARAM, 10); jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("_syncLock", &syncLock))) { @@ -519,7 +519,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; currentPhase = JVMTI_PHASE_PRIMORDIAL; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t001/em02t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t001/em02t001.cpp index 0314850e4f7..5bc4a5c7b2f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t001/em02t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t001/em02t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ extern "C" { /* ============================================================================= */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; -static jrawMonitorID syncLock = NULL; +static jrawMonitorID syncLock = nullptr; /* constant names */ #define DEBUGEE_CLASS_NAME "nsk/jvmti/scenarios/events/EM02/em02t001" @@ -48,10 +48,10 @@ static jrawMonitorID syncLock = NULL; #define OBJECT_FIELD_SIG "Ljava/lang/Object;" #define THREAD_FIELD_SIG "Ljava/lang/Thread;" -static jthread mainThread = NULL; -static jthread debuggeeThread = NULL; -static jobject startObject = NULL; -static jobject endObject = NULL; +static jthread mainThread = nullptr; +static jthread debuggeeThread = nullptr; +static jobject startObject = nullptr; +static jobject endObject = nullptr; #define STEP_AMOUNT 3 #define JVMTI_EVENT_COUNT (int)(JVMTI_MAX_EVENT_TYPE_VAL - JVMTI_MIN_EVENT_TYPE_VAL + 1) @@ -63,21 +63,21 @@ static int newEventCount[JVMTI_EVENT_COUNT]; static jthread findThread(const char *threadName) { jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; - jthread returnValue = NULL; + jthread returnValue = nullptr; int i; /* get all live threads */ if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) - return NULL; + return nullptr; - if (!NSK_VERIFY(threads != NULL)) - return NULL; + if (!NSK_VERIFY(threads != nullptr)) + return nullptr; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) break; /* get thread information */ @@ -85,14 +85,14 @@ findThread(const char *threadName) { break; /* find by name */ - if (info.name != NULL && (strcmp(info.name, threadName) == 0)) { + if (info.name != nullptr && (strcmp(info.name, threadName) == 0)) { returnValue = threads[i]; } } /* deallocate threads list */ if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threads))) - return NULL; + return nullptr; return returnValue; } @@ -105,7 +105,7 @@ getStaticObjField(const char* className, const char* objFieldName, ExceptionCheckingJniEnvPtr ec_jni(jni); jfieldID fieldID; - jclass klass = NULL; + jclass klass = nullptr; klass = ec_jni->FindClass(className, TRACE_JNI_CALL); fieldID = ec_jni->GetStaticFieldID(klass, objFieldName, signature, TRACE_JNI_CALL); @@ -118,7 +118,7 @@ static bool prepare() { ExceptionCheckingJniEnvPtr ec_jni(jni); mainThread = findThread(MAIN_THREAD_NAME); - if (!NSK_VERIFY(mainThread != NULL)) { + if (!NSK_VERIFY(mainThread != nullptr)) { NSK_COMPLAIN1("<%s> thread not found\n", MAIN_THREAD_NAME); return false; } @@ -126,14 +126,14 @@ static bool prepare() { /* make thread accessable for a long time */ mainThread = ec_jni->NewGlobalRef(mainThread, TRACE_JNI_CALL); startObject = getStaticObjField(DEBUGEE_CLASS_NAME, START_FIELD_NAME, OBJECT_FIELD_SIG); - if (!NSK_VERIFY(startObject != NULL)) + if (!NSK_VERIFY(startObject != nullptr)) return false; /*make object accessable for a long time*/ startObject = ec_jni->NewGlobalRef(startObject, TRACE_JNI_CALL); endObject = getStaticObjField(DEBUGEE_CLASS_NAME, END_FIELD_NAME, OBJECT_FIELD_SIG); - if (!NSK_VERIFY(endObject != NULL)) + if (!NSK_VERIFY(endObject != nullptr)) return false; /*make object accessable for a long time*/ @@ -142,7 +142,7 @@ static bool prepare() { debuggeeThread = (jthread) getStaticObjField(DEBUGEE_CLASS_NAME, THREAD_FIELD_NAME, THREAD_FIELD_SIG); - if (!NSK_VERIFY(debuggeeThread != NULL)) + if (!NSK_VERIFY(debuggeeThread != nullptr)) return false; /* make thread accessable for a long time */ @@ -158,7 +158,7 @@ static bool clean() { /* disable MonitorContendedEnter event */ if (!NSK_JVMTI_VERIFY( jvmti->SetEventNotificationMode( - JVMTI_DISABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTER, NULL))) + JVMTI_DISABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTER, nullptr))) nsk_jvmti_setFailStatus(); /* dispose global references */ @@ -167,10 +167,10 @@ static bool clean() { ec_jni->DeleteGlobalRef(debuggeeThread, TRACE_JNI_CALL); ec_jni->DeleteGlobalRef(mainThread, TRACE_JNI_CALL); - startObject = NULL; - endObject = NULL; - debuggeeThread = NULL; - mainThread = NULL; + startObject = nullptr; + endObject = nullptr; + debuggeeThread = nullptr; + mainThread = nullptr; return true; } @@ -396,7 +396,7 @@ handlerMC1(jvmtiEvent event, jvmtiEnv* jvmti, JNIEnv* jni_env, jthread expectedThread, jobject expectedObject) { ExceptionCheckingJniEnvPtr ec_jni(jni_env); - if (expectedThread == NULL || expectedObject == NULL) + if (expectedThread == nullptr || expectedObject == nullptr) return; /* check if event is for tested thread and for tested object */ @@ -483,7 +483,7 @@ handlerMC2(jvmtiEvent event, jvmtiEnv* jvmti, JNIEnv* jni_env, jthread expectedThread, jobject expectedObject) { ExceptionCheckingJniEnvPtr ec_jni(jni_env); - if (expectedThread == NULL || expectedObject == NULL) + if (expectedThread == nullptr || expectedObject == nullptr) return; /* check if event is for tested thread and for tested object */ @@ -553,13 +553,13 @@ static bool enableEvent(jvmtiEvent event) { && (event != JVMTI_EVENT_MONITOR_WAIT) && (event != JVMTI_EVENT_MONITOR_WAITED)) { if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, - jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, NULL))) { + jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, nullptr))) { NSK_COMPLAIN1("Unexpected error enabling %s\n", TranslateEvent(event)); return false; } } else { - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, nullptr))) { NSK_COMPLAIN1("Unexpected error enabling %s\n", TranslateEvent(event)); return false; @@ -743,7 +743,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("_syncLock", &syncLock))) { @@ -770,7 +770,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t002/em02t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t002/em02t002.cpp index 5f30ac4e1e7..1c6f88ea41a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t002/em02t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t002/em02t002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,9 +33,9 @@ extern "C" { /* ============================================================================= */ /* scaffold objects */ -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; -static jrawMonitorID syncLock = NULL; +static jrawMonitorID syncLock = nullptr; /* constant names */ #define STEP_AMOUNT 3 @@ -344,13 +344,13 @@ static bool enableEvent(jvmtiEvent event) { && (event != JVMTI_EVENT_GARBAGE_COLLECTION_START) && (event != JVMTI_EVENT_GARBAGE_COLLECTION_FINISH)) { if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, - jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, NULL))) { + jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, nullptr))) { NSK_COMPLAIN1("Unexpected error enabling %s\n", TranslateEvent(event)); return false; } } else { - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, nullptr))) { NSK_COMPLAIN1("Unexpected error enabling %s\n", TranslateEvent(event)); return false; @@ -509,7 +509,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("_syncLock", &syncLock))) { @@ -536,7 +536,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t003/em02t003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t003/em02t003.cpp index d5cae3e3a75..a1c1aa85a10 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t003/em02t003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t003/em02t003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,9 +33,9 @@ extern "C" { /* ============================================================================= */ /* scaffold objects */ -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; -static jrawMonitorID syncLock = NULL; +static jrawMonitorID syncLock = nullptr; /* constant names */ #define STEP_AMOUNT 3 @@ -280,7 +280,7 @@ handlerMC1(jvmtiEvent event, jvmtiEnv* jvmti, jmethodID method) { if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)sign))) { nsk_jvmti_setFailStatus(); } - if (genc != NULL) + if (genc != nullptr) if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)genc))) { nsk_jvmti_setFailStatus(); } @@ -346,7 +346,7 @@ handlerMC2(jvmtiEvent event, jvmtiEnv* jvmti, jmethodID method) { if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)sign))) { nsk_jvmti_setFailStatus(); } - if (genc != NULL) + if (genc != nullptr) if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)genc))) { nsk_jvmti_setFailStatus(); } @@ -378,13 +378,13 @@ static bool enableEvent(jvmtiEvent event) { && (event != JVMTI_EVENT_COMPILED_METHOD_LOAD) && (event != JVMTI_EVENT_COMPILED_METHOD_UNLOAD)) { if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, - jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, NULL))) { + jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, nullptr))) { NSK_COMPLAIN1("Unexpected error enabling %s\n", TranslateEvent(event)); return false; } } else { - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, nullptr))) { NSK_COMPLAIN1("Unexpected error enabling %s\n", TranslateEvent(event)); return false; @@ -548,7 +548,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("_syncLock", &syncLock))) { @@ -575,7 +575,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t004/em02t004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t004/em02t004.cpp index a3ecd17cf1f..b00713b7fe8 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t004/em02t004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t004/em02t004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,9 +33,9 @@ extern "C" { /* ============================================================================= */ /* scaffold objects */ -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; -static jrawMonitorID syncLock = NULL; +static jrawMonitorID syncLock = nullptr; /* constant names */ #define STEP_AMOUNT 3 @@ -334,7 +334,7 @@ cbNativeMethodBind(jvmtiEnv *jvmti_env, JNIEnv* jni_env,jthread thread, if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)sign))) { nsk_jvmti_setFailStatus(); } - if (genc != NULL) + if (genc != nullptr) if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)genc))) { nsk_jvmti_setFailStatus(); } @@ -374,7 +374,7 @@ cbNewNativeMethodBind(jvmtiEnv *jvmti_env, JNIEnv* jni_env,jthread thread, if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)sign))) { nsk_jvmti_setFailStatus(); } - if (genc != NULL) + if (genc != nullptr) if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)genc))) { nsk_jvmti_setFailStatus(); } @@ -387,13 +387,13 @@ static bool enableEvent(jvmtiEvent event) { if (nsk_jvmti_isOptionalEvent(event) && (event != JVMTI_EVENT_NATIVE_METHOD_BIND)) { if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, - jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, NULL))) { + jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, nullptr))) { NSK_COMPLAIN1("Unexpected error enabling %s\n", TranslateEvent(event)); return false; } } else { - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, nullptr))) { NSK_COMPLAIN1("Unexpected error enabling %s\n", TranslateEvent(event)); return false; @@ -554,7 +554,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("_syncLock", &syncLock))) { @@ -581,7 +581,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t005/em02t005.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t005/em02t005.cpp index 66d46a31062..a1b74a56a76 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t005/em02t005.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t005/em02t005.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,9 +33,9 @@ extern "C" { /* ============================================================================= */ /* scaffold objects */ -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; -static jrawMonitorID syncLock = NULL; +static jrawMonitorID syncLock = nullptr; /* constant names */ #define STEP_NUMBER 3 @@ -326,7 +326,7 @@ cbVMObjectAlloc(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)sign_ptr))) { nsk_jvmti_setFailStatus(); } - if (gen_ptr != NULL) + if (gen_ptr != nullptr) if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)gen_ptr))) { nsk_jvmti_setFailStatus(); } @@ -366,7 +366,7 @@ cbNewVMObjectAlloc(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)sign_ptr))) { nsk_jvmti_setFailStatus(); } - if (gen_ptr != NULL) + if (gen_ptr != nullptr) if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)gen_ptr))) { nsk_jvmti_setFailStatus(); } @@ -379,13 +379,13 @@ static bool enableEvent(jvmtiEvent event) { if (nsk_jvmti_isOptionalEvent(event) && (event != JVMTI_EVENT_VM_OBJECT_ALLOC)) { if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, - jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, NULL))) { + jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, nullptr))) { NSK_COMPLAIN1("Unexpected error enabling %s\n", TranslateEvent(event)); return false; } } else { - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, nullptr))) { NSK_COMPLAIN1("Unexpected error enabling %s\n", TranslateEvent(event)); return false; @@ -534,7 +534,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; @@ -560,7 +560,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t006/em02t006.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t006/em02t006.cpp index 415cbbcc5ed..c4b65118b1a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t006/em02t006.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t006/em02t006.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,9 +33,9 @@ extern "C" { /* ============================================================================= */ /* scaffold objects */ -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; -static jrawMonitorID syncLock = NULL; +static jrawMonitorID syncLock = nullptr; /* constant names */ #define STEP_NUMBER 3 @@ -328,13 +328,13 @@ static bool enableEvent(jvmtiEvent event) { if (nsk_jvmti_isOptionalEvent(event) && (event != JVMTI_EVENT_OBJECT_FREE)) { if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, - jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, NULL))) { + jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, nullptr))) { NSK_COMPLAIN1("Unexpected error enabling %s\n", TranslateEvent(event)); return false; } } else { - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, nullptr))) { NSK_COMPLAIN1("Unexpected error enabling %s\n", TranslateEvent(event)); return false; @@ -485,7 +485,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("_syncLock", &syncLock))) { @@ -511,7 +511,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t007/em02t007.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t007/em02t007.cpp index 0b19c1d0f85..b344a6f438e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t007/em02t007.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t007/em02t007.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,9 +33,9 @@ extern "C" { /* ============================================================================= */ /* scaffold objects */ -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; -static jrawMonitorID syncLock = NULL; +static jrawMonitorID syncLock = nullptr; /* constant names */ #define STEP_NUMBER 3 @@ -200,7 +200,7 @@ cbSingleStep(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)sign))) { nsk_jvmti_setFailStatus(); } - if (genc != NULL) + if (genc != nullptr) if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)genc))) { nsk_jvmti_setFailStatus(); } @@ -230,7 +230,7 @@ cbNewSingleStep(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)sign))) { nsk_jvmti_setFailStatus(); } - if (genc != NULL) + if (genc != nullptr) if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)genc))) { nsk_jvmti_setFailStatus(); } @@ -357,13 +357,13 @@ static bool enableEvent(jvmtiEvent event) { if (nsk_jvmti_isOptionalEvent(event) && (event != JVMTI_EVENT_SINGLE_STEP)) { if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, - jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, NULL))) { + jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, nullptr))) { NSK_COMPLAIN1("Unexpected error enabling %s\n", TranslateEvent(event)); return false; } } else { - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, nullptr))) { NSK_COMPLAIN1("Unexpected error enabling %s\n", TranslateEvent(event)); return false; @@ -521,7 +521,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("_syncLock", &syncLock))) { @@ -546,7 +546,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t008/em02t008.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t008/em02t008.cpp index 5c7edf432d3..89434116744 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t008/em02t008.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t008/em02t008.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,9 +33,9 @@ extern "C" { /* ============================================================================= */ /* scaffold objects */ -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; -static jrawMonitorID syncLock = NULL; +static jrawMonitorID syncLock = nullptr; /* constant names */ #define STEP_NUMBER 3 @@ -377,13 +377,13 @@ static bool enableEvent(jvmtiEvent event) { && (event != JVMTI_EVENT_EXCEPTION) && (event != JVMTI_EVENT_EXCEPTION_CATCH)) { if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, - jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, NULL))) { + jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, nullptr))) { NSK_COMPLAIN1("Unexpected error enabling %s\n", TranslateEvent(event)); return false; } } else { - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, nullptr))) { NSK_COMPLAIN1("Unexpected error enabling %s\n", TranslateEvent(event)); return false; @@ -533,7 +533,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("_syncLock", &syncLock))) { @@ -558,7 +558,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t009/em02t009.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t009/em02t009.cpp index 1ee810210db..f50cb3388da 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t009/em02t009.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t009/em02t009.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,9 +33,9 @@ extern "C" { /* ============================================================================= */ /* scaffold objects */ -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; -static jrawMonitorID syncLock = NULL; +static jrawMonitorID syncLock = nullptr; /* constant names */ #define STEP_NUMBER 3 @@ -243,7 +243,7 @@ void handler1(jvmtiEnv *jvmti_env, jvmtiEvent event, jmethodID method) { if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)sign))) { nsk_jvmti_setFailStatus(); } - if (genc != NULL) + if (genc != nullptr) if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)genc))) { nsk_jvmti_setFailStatus(); } @@ -285,7 +285,7 @@ void handler2(jvmtiEnv *jvmti_env, jvmtiEvent event, jmethodID method) { if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)sign))) { nsk_jvmti_setFailStatus(); } - if (genc != NULL) + if (genc != nullptr) if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)genc))) { nsk_jvmti_setFailStatus(); } @@ -384,13 +384,13 @@ static bool enableEvent(jvmtiEvent event) { && (event != JVMTI_EVENT_METHOD_ENTRY) && (event != JVMTI_EVENT_METHOD_EXIT)) { if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, - jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, NULL))) { + jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, nullptr))) { NSK_COMPLAIN1("Unexpected error enabling %s\n", TranslateEvent(event)); return false; } } else { - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, nullptr))) { NSK_COMPLAIN1("Unexpected error enabling %s\n", TranslateEvent(event)); return false; @@ -540,7 +540,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("_syncLock", &syncLock))) { @@ -566,7 +566,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t010/em02t010.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t010/em02t010.cpp index 5a181180b86..a3257281f0d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t010/em02t010.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t010/em02t010.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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,9 +34,9 @@ extern "C" { /* ============================================================================= */ /* scaffold objects */ -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; -static jrawMonitorID syncLock = NULL; +static jrawMonitorID syncLock = nullptr; /* constant names */ #define STEP_NUMBER 3 @@ -340,13 +340,13 @@ static bool enableEvent(jvmtiEvent event) { && (event != JVMTI_EVENT_FIELD_MODIFICATION) && (event != JVMTI_EVENT_FIELD_ACCESS)) { if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, - jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, NULL))) { + jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, nullptr))) { NSK_COMPLAIN1("Unexpected error enabling %s\n", TranslateEvent(event)); return false; } } else { - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, nullptr))) { NSK_COMPLAIN1("Unexpected error enabling %s\n", TranslateEvent(event)); return false; @@ -516,7 +516,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("_syncLock", &syncLock))) { @@ -542,7 +542,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t011/em02t011.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t011/em02t011.cpp index 626e2500a9a..1e0f043d087 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t011/em02t011.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t011/em02t011.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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,9 +34,9 @@ extern "C" { /* ============================================================================= */ /* scaffold objects */ -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; -static jrawMonitorID syncLock = NULL; +static jrawMonitorID syncLock = nullptr; /* constant names */ #define STEP_NUMBER 3 @@ -326,13 +326,13 @@ static bool enableEvent(jvmtiEvent event) { if (nsk_jvmti_isOptionalEvent(event) && (event != JVMTI_EVENT_BREAKPOINT)) { if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, - jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, NULL))) { + jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, nullptr))) { NSK_COMPLAIN1("Unexpected error enabling %s\n", TranslateEvent(event)); return false; } } else { - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, nullptr))) { NSK_COMPLAIN1("Unexpected error enabling %s\n", TranslateEvent(event)); return false; @@ -497,7 +497,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("_syncLock", &syncLock))) { @@ -522,7 +522,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t012/em02t012.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t012/em02t012.cpp index ad7dfc5e0e8..eb83f542853 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t012/em02t012.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t012/em02t012.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ extern "C" { /* ============================================================================= */ /* scaffold objects */ -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jthread testedThread; static jlong timeout = 0; -static jrawMonitorID syncLock = NULL; +static jrawMonitorID syncLock = nullptr; /* constant names */ #define STEP_NUMBER 3 @@ -330,13 +330,13 @@ static bool enableEvent(jvmtiEvent event) { if (nsk_jvmti_isOptionalEvent(event) && (event != JVMTI_EVENT_FRAME_POP)) { if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, - jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, NULL))) { + jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, nullptr))) { NSK_COMPLAIN1("Unexpected error enabling %s\n", TranslateEvent(event)); return false; } } else { - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, nullptr))) { NSK_COMPLAIN1("Unexpected error enabling %s\n", TranslateEvent(event)); return false; @@ -503,7 +503,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("_syncLock", &syncLock))) { @@ -529,7 +529,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM04/em04t001/em04t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM04/em04t001/em04t001.cpp index 86ca654d2cd..825391d9576 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM04/em04t001/em04t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM04/em04t001/em04t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -35,9 +35,9 @@ extern "C" { /* ============================================================================= */ /* scaffold objects */ -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; -const void *plist = NULL; +const void *plist = nullptr; #define NAME_LENGTH 50 @@ -48,7 +48,7 @@ typedef struct nsk_jvmti_DCG_paramsStruct { int sign; } nsk_jvmti_DCG_params; -static jrawMonitorID syncLock = NULL; +static jrawMonitorID syncLock = nullptr; static volatile int callbacksEnabled = NSK_TRUE; /* ============================================================================= */ @@ -122,7 +122,7 @@ cbDynamicCodeGenerated2(jvmtiEnv *jvmti_env, const char *name, static int enableEvent(jvmtiEventMode enable, jvmtiEvent event) { - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(enable, event, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(enable, event, nullptr))) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -212,7 +212,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved); - if (!NSK_VERIFY(jvmti != NULL)) + if (!NSK_VERIFY(jvmti != nullptr)) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("_syncLock", &syncLock))) { @@ -221,7 +221,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } plist = (const void *)nsk_list_create(); - if (!NSK_VERIFY(plist != NULL)) + if (!NSK_VERIFY(plist != nullptr)) return JNI_ERR; NSK_DISPLAY1("plist = 0x%p\n", plist); @@ -236,7 +236,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM05/em05t001/em05t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM05/em05t001/em05t001.cpp index 09646218439..8cd0f4c957f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM05/em05t001/em05t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM05/em05t001/em05t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -32,8 +32,8 @@ extern "C" { /* ============================================================================= */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* constant names */ @@ -65,8 +65,8 @@ typedef struct { /* descriptions of tested methods */ static MethodDesc methodsDesc[METHODS_COUNT] = { - { "javaMethod", "(I)I", NULL, 0, 0, 0 }, - { "nativeMethod", "(I)I", NULL, 0, 0, 0 } + { "javaMethod", "(I)I", nullptr, 0, 0, 0 }, + { "nativeMethod", "(I)I", nullptr, 0, 0, 0 } }; /* ============================================================================= */ @@ -127,7 +127,7 @@ static int enableEvents(jvmtiEventMode enable) { int i; for (i = 0; i < EVENTS_COUNT; i++) { - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(enable, eventsList[i], NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(enable, eventsList[i], nullptr))) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -142,43 +142,43 @@ static int enableEvents(jvmtiEventMode enable) { * - enable events */ static int prepare() { - jclass debugeeClass = NULL; - jclass threadClass = NULL; - jfieldID threadFieldID = NULL; - jthread thread = NULL; + jclass debugeeClass = nullptr; + jclass threadClass = nullptr; + jfieldID threadFieldID = nullptr; + jthread thread = nullptr; int i; for (i = 0; i < METHODS_COUNT; i++) { - methodsDesc[i].method = (jmethodID)NULL; + methodsDesc[i].method = (jmethodID)nullptr; methodsDesc[i].loadEvents = 0; methodsDesc[i].unloadEvents = 0; } - if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (threadFieldID = - jni->GetStaticFieldID(debugeeClass, THREAD_FIELD_NAME, THREAD_FIELD_SIG)) != NULL)) + jni->GetStaticFieldID(debugeeClass, THREAD_FIELD_NAME, THREAD_FIELD_SIG)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (thread = (jthread) - jni->GetStaticObjectField(debugeeClass, threadFieldID)) != NULL)) + jni->GetStaticObjectField(debugeeClass, threadFieldID)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (threadClass = jni->GetObjectClass(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (threadClass = jni->GetObjectClass(thread)) != nullptr)) return NSK_FALSE; NSK_DISPLAY0("Find tested methods:\n"); for (i = 0; i < METHODS_COUNT; i++) { if (!NSK_JNI_VERIFY(jni, (methodsDesc[i].method = - jni->GetMethodID(threadClass, methodsDesc[i].methodName, methodsDesc[i].methodSig)) != NULL)) + jni->GetMethodID(threadClass, methodsDesc[i].methodName, methodsDesc[i].methodSig)) != nullptr)) return NSK_FALSE; NSK_DISPLAY3(" method #%d (%s): 0x%p\n", i, methodsDesc[i].methodName, (void*)methodsDesc[i].method); } NSK_DISPLAY0("Enable events\n"); - if (!nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, eventsList, NULL)) + if (!nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, eventsList, nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -220,7 +220,7 @@ static int checkEvents() { */ static int clean() { NSK_DISPLAY0("Disable events\n"); - if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, eventsList, NULL)) + if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, eventsList, nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -314,7 +314,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; { @@ -334,7 +334,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM05/em05t002/em05t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM05/em05t002/em05t002.cpp index 9f1b86471b2..01eaf82f214 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM05/em05t002/em05t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM05/em05t002/em05t002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -32,8 +32,8 @@ extern "C" { /* ============================================================================= */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* constant names */ @@ -71,8 +71,8 @@ typedef struct { /* descriptions of tested methods */ static MethodDesc methodsDesc[METHODS_COUNT] = { - { "javaMethod", "(I)I", NULL, 0, {}, {} }, - { "nativeMethod", "(I)I", NULL, 0, {}, {} } + { "javaMethod", "(I)I", nullptr, 0, {}, {} }, + { "nativeMethod", "(I)I", nullptr, 0, {}, {} } }; /* current compilation moment */ @@ -166,15 +166,15 @@ static int generateEvents() { * - enable events */ static int prepare() { - jclass debugeeClass = NULL; - jclass threadClass = NULL; - jfieldID threadFieldID = NULL; - jthread thread = NULL; + jclass debugeeClass = nullptr; + jclass threadClass = nullptr; + jfieldID threadFieldID = nullptr; + jthread thread = nullptr; int i; for (i = 0; i < METHODS_COUNT; i++) { int j; - methodsDesc[i].method = (jmethodID)NULL; + methodsDesc[i].method = (jmethodID)nullptr; methodsDesc[i].compiled = NSK_FALSE; for (j = 0; j < MOMENTS_COUNT; j++) { methodsDesc[i].loadEvents[j] = 0; @@ -182,31 +182,31 @@ static int prepare() { } } - if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (threadFieldID = - jni->GetStaticFieldID(debugeeClass, THREAD_FIELD_NAME, THREAD_FIELD_SIG)) != NULL)) + jni->GetStaticFieldID(debugeeClass, THREAD_FIELD_NAME, THREAD_FIELD_SIG)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (thread = (jthread) - jni->GetStaticObjectField(debugeeClass, threadFieldID)) != NULL)) + jni->GetStaticObjectField(debugeeClass, threadFieldID)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (threadClass = jni->GetObjectClass(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (threadClass = jni->GetObjectClass(thread)) != nullptr)) return NSK_FALSE; NSK_DISPLAY0("Find tested methods:\n"); for (i = 0; i < METHODS_COUNT; i++) { if (!NSK_JNI_VERIFY(jni, (methodsDesc[i].method = - jni->GetMethodID(threadClass, methodsDesc[i].methodName, methodsDesc[i].methodSig)) != NULL)) + jni->GetMethodID(threadClass, methodsDesc[i].methodName, methodsDesc[i].methodSig)) != nullptr)) return NSK_FALSE; NSK_DISPLAY3(" method #%d (%s): 0x%p\n", i, methodsDesc[i].methodName, (void*)methodsDesc[i].method); } NSK_DISPLAY0("Enable events\n"); - if (!nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, eventsList, NULL)) + if (!nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, eventsList, nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -282,7 +282,7 @@ static int checkEvents() { */ static int clean() { NSK_DISPLAY0("Disable events\n"); - if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, eventsList, NULL)) + if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, eventsList, nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -383,7 +383,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; { @@ -403,7 +403,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM06/em06t001/em06t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM06/em06t001/em06t001.cpp index 87ad1da13f7..ccd0b42a8a6 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM06/em06t001/em06t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM06/em06t001/em06t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,10 +33,10 @@ extern "C" { /* ============================================================================= */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; -static jrawMonitorID syncLock = NULL; +static jrawMonitorID syncLock = nullptr; /* constant names */ #define JVMTI_EVENT_COUNT (int)(JVMTI_MAX_EVENT_TYPE_VAL - JVMTI_MIN_EVENT_TYPE_VAL + 1) @@ -60,13 +60,13 @@ handler(jvmtiEvent event, jvmtiEnv* jvmti, JNIEnv* jni_env, jstring jclassName; const char *className; - if (!NSK_JNI_VERIFY(jni_env, (classObject = jni_env->GetObjectClass(klass)) != NULL)) { + if (!NSK_JNI_VERIFY(jni_env, (classObject = jni_env->GetObjectClass(klass)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } if (!NSK_JNI_VERIFY(jni_env, (methodID = - jni_env->GetMethodID(classObject, "getName", "()Ljava/lang/String;")) != NULL)) { + jni_env->GetMethodID(classObject, "getName", "()Ljava/lang/String;")) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -75,7 +75,7 @@ handler(jvmtiEvent event, jvmtiEnv* jvmti, JNIEnv* jni_env, className = jni_env->GetStringUTFChars(jclassName, 0); - if (className != NULL && (strcmp(className, EXPECTED_CLASS_NAME) == 0)) { + if (className != nullptr && (strcmp(className, EXPECTED_CLASS_NAME) == 0)) { if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorEnter(syncLock))) nsk_jvmti_setFailStatus(); @@ -114,7 +114,7 @@ cbClassPrepare(jvmtiEnv* jvmti, JNIEnv* jni_env, jthread thread, jclass klass) { static int enableEvent(jvmtiEventMode enable, jvmtiEvent event) { - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(enable, event, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(enable, event, nullptr))) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -249,10 +249,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; classLoaderCount = nsk_jvmti_findOptionIntValue(CLASS_LOADER_COUNT_PARAM, 100); - if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM07/em07t001/em07t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM07/em07t001/em07t001.cpp index 4aa814611d9..b3236df4208 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM07/em07t001/em07t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM07/em07t001/em07t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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,8 +34,8 @@ extern "C" { /* scaffold objects */ static jlong timeout = 0; -static jvmtiEnv *jvmti = NULL; -static jrawMonitorID syncLock = NULL; +static jvmtiEnv *jvmti = nullptr; +static jrawMonitorID syncLock = nullptr; /* constant names */ #define JVMTI_EVENT_COUNT (int)(JVMTI_MAX_EVENT_TYPE_VAL - JVMTI_MIN_EVENT_TYPE_VAL + 1) @@ -233,7 +233,7 @@ int enableOptionalEvents(jvmtiEnv *jvmti) { jvmtiEvent event = (jvmtiEvent)(i + JVMTI_MIN_EVENT_TYPE_VAL); if (nsk_jvmti_isOptionalEvent(event)) if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, - jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, NULL))) { + jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, nullptr))) { NSK_COMPLAIN1("Unexpected error enabling %s\n", TranslateEvent(event)); result = NSK_FALSE; @@ -355,7 +355,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; - if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("_syncLock", &syncLock))) { @@ -373,7 +373,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM07/em07t002/em07t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM07/em07t002/em07t002.cpp index 2800ce8116b..a9f0321c3bd 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM07/em07t002/em07t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM07/em07t002/em07t002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -35,15 +35,15 @@ extern "C" { /* ============================================================================= */ /* scaffold objects */ -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; -static jrawMonitorID syncLock = NULL; +static jrawMonitorID syncLock = nullptr; static int methodLoadCount = 0; static int methodUnloadCount = 0; #define NAME_LENGTH 50 -const void *plist = NULL; +const void *plist = nullptr; static volatile int callbacksEnabled = NSK_TRUE; typedef struct nsk_jvmti_CompiledMethodIDStruct { @@ -109,7 +109,7 @@ cbCompiledMethodLoad(jvmtiEnv *jvmti_env, jmethodID method, jint code_size, if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)sign))) { nsk_jvmti_setFailStatus(); } - if (genc != NULL) + if (genc != nullptr) if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)genc))) { nsk_jvmti_setFailStatus(); } @@ -155,7 +155,7 @@ cbCompiledMethodUnload(jvmtiEnv *jvmti_env, jmethodID method, static int enableEvent(jvmtiEventMode enable, jvmtiEvent event) { - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(enable, event, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(enable, event, nullptr))) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -264,7 +264,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; - if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("_syncLock", &syncLock))) { @@ -272,7 +272,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY((plist = (const void *)nsk_list_create()) != NULL)) + if (!NSK_VERIFY((plist = (const void *)nsk_list_create()) != nullptr)) return JNI_ERR; { @@ -293,7 +293,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/extension/EX03/ex03t001/ex03t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/extension/EX03/ex03t001/ex03t001.cpp index 810e1b1f47c..a2855dc742a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/extension/EX03/ex03t001/ex03t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/extension/EX03/ex03t001/ex03t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -29,8 +29,8 @@ extern "C" { -static JNIEnv *jni = NULL; -static jvmtiEnv* jvmti = NULL; +static JNIEnv *jni = nullptr; +static jvmtiEnv* jvmti = nullptr; static jlong timeout = 0; static jboolean eventEnabled = JNI_FALSE; static volatile jboolean eventReceived1 = JNI_FALSE, eventReceived2 = JNI_FALSE; @@ -42,7 +42,7 @@ static jrawMonitorID eventMon; static void JNICALL ClassUnload(jvmtiEnv* jvmti_env, ...) { - JNIEnv *jni_env = NULL; + JNIEnv *jni_env = nullptr; va_list ap; va_start(ap, jvmti_env); @@ -51,9 +51,9 @@ ClassUnload(jvmtiEnv* jvmti_env, ...) { va_end(ap); // The name argument should never be null - if (name == NULL) { + if (name == nullptr) { nsk_jvmti_setFailStatus(); - NSK_COMPLAIN0("ClassUnload: 'name' input parameter is NULL.\n"); + NSK_COMPLAIN0("ClassUnload: 'name' input parameter is null.\n"); } else { NSK_DISPLAY1("Class unloaded %s\n", name); } @@ -152,12 +152,12 @@ jboolean enableClassUnloadEvent (jboolean enable) { if (!NSK_JVMTI_VERIFY( jvmti->SetExtensionEventCallback(extList[i].extension_event_index, - enable ? (jvmtiExtensionEvent)ClassUnload : NULL))) { + enable ? (jvmtiExtensionEvent)ClassUnload : nullptr))) { nsk_jvmti_setFailStatus(); return JNI_FALSE; } if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(mode, (jvmtiEvent)extList[i].extension_event_index, NULL))) { + jvmti->SetEventNotificationMode(mode, (jvmtiEvent)extList[i].extension_event_index, nullptr))) { nsk_jvmti_setFailStatus(); return JNI_FALSE; } @@ -281,14 +281,14 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("eventMon", &eventMon))) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/general_functions/GF01/gf01t001/gf01t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/general_functions/GF01/gf01t001/gf01t001.cpp index 430f8b27160..252cd19b7ac 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/general_functions/GF01/gf01t001/gf01t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/general_functions/GF01/gf01t001/gf01t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,7 +172,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; NSK_DISPLAY0("setting event callbacks ...\n"); @@ -185,9 +185,9 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { NSK_DISPLAY0("setting event callbacks done\nenabling events ...\n"); - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, nullptr))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, nullptr))) return JNI_ERR; NSK_DISPLAY0("enabling events done\n\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/general_functions/GF04/gf04t001/gf04t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/general_functions/GF04/gf04t001/gf04t001.cpp index a2937f86155..bdd20e8951b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/general_functions/GF04/gf04t001/gf04t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/general_functions/GF04/gf04t001/gf04t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,7 @@ extern "C" { /* ============================================================================= */ static jlong timeout = 0; -static const char* segment = NULL; +static const char* segment = nullptr; static const char* EXP_CLASS_SIGNATURE = "Lnsk/jvmti/scenarios/general_functions/GF04/gf04t001;"; static jrawMonitorID countLock; static jboolean classLoadReceived = JNI_FALSE, classPrepareReceived = JNI_FALSE; @@ -49,7 +49,7 @@ static jint result = PASSED; * @returns NSK_FALSE if any error occured. */ static int addSegment(jvmtiEnv* jvmti, const char segment[], const char where[]) { - void* storage = NULL; + void* storage = nullptr; NSK_DISPLAY1("Add segment: %s\n", segment); if (!NSK_JVMTI_VERIFY(jvmti->AddToBootstrapClassLoaderSearch(segment))) { @@ -97,7 +97,7 @@ ClassLoad(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread, jclass klass) { sig); classLoadReceived = JNI_TRUE; - if (!NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_CLASS_LOAD, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_CLASS_LOAD, nullptr))) { result = STATUS_FAILED; } else { NSK_DISPLAY0("ClassLoad event disabled\n"); @@ -123,7 +123,7 @@ ClassPrepare(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread, jclass klass) { sig); classPrepareReceived = JNI_TRUE; - if (!NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_CLASS_PREPARE, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_CLASS_PREPARE, nullptr))) { result = STATUS_FAILED; } else { NSK_DISPLAY0("ClassPrepare event disabled\n"); @@ -148,19 +148,19 @@ JNIEXPORT jint JNI_OnLoad_gf04t001(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; timeout = nsk_jvmti_getWaitTime() * 60 * 1000; - segment = nsk_jvmti_findOptionStringValue("segment", NULL); - if (!NSK_VERIFY(segment != NULL)) + segment = nsk_jvmti_findOptionStringValue("segment", nullptr); + if (!NSK_VERIFY(segment != nullptr)) return JNI_ERR; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("eventLock", &countLock))) @@ -186,12 +186,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { NSK_DISPLAY0(" ... set\n"); NSK_DISPLAY0("Enabling events: \n"); - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, nullptr))) { return JNI_ERR; } else { NSK_DISPLAY0(" ... ClassLoad enabled\n"); } - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_PREPARE, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_PREPARE, nullptr))) { return JNI_ERR; } else { NSK_DISPLAY0(" ... ClassPrepare enabled\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/general_functions/GF06/gf06t001/gf06t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/general_functions/GF06/gf06t001/gf06t001.cpp index 355f30c51c6..876b3a8464c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/general_functions/GF06/gf06t001/gf06t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/general_functions/GF06/gf06t001/gf06t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -72,7 +72,7 @@ static void fillEnvStorage(StorageStructure* storage) { * @returns NSK_FALSE if any error occured. */ static int checkEnvStorage(jvmtiEnv* jvmti, const char where[]) { - void* storage = NULL; + void* storage = nullptr; NSK_DISPLAY0("Calling GetEnvironmentLocalStorage():"); if (!NSK_JVMTI_VERIFY(jvmti->GetEnvironmentLocalStorage(&storage))) { @@ -80,8 +80,8 @@ static int checkEnvStorage(jvmtiEnv* jvmti, const char where[]) { } NSK_DISPLAY1(" ... got storage: 0x%p\n", (void*)storage); - if (storage != NULL) { - NSK_COMPLAIN2("GetEnvironmentLocalStorage() returned NOT NULL storage in %s:\n" + if (storage != nullptr) { + NSK_COMPLAIN2("GetEnvironmentLocalStorage() returned NOT null storage in %s:\n" "# storage pointer: 0x%p\n", where, (void*)storage); return NSK_FALSE; @@ -134,7 +134,7 @@ callbackVMInit(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { } NSK_DISPLAY0("Set agentProc for second JVMTI env.\n"); - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) nsk_jvmti_setFailStatus(); } @@ -149,7 +149,7 @@ callbackVMDeath(jvmtiEnv* jvmti, JNIEnv* jni) { success = checkEnvStorage(jvmti, "VM_DEATH callback"); NSK_DISPLAY1("Disable events: %d events\n", EVENTS_COUNT); - if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, NULL)) { + if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, nullptr)) { success = NSK_FALSE; } else { NSK_DISPLAY0(" ... disabled\n"); @@ -177,7 +177,7 @@ JNIEXPORT jint JNI_OnLoad_gf06t001(JavaVM *jvm, char *options, void *reserved) { #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - jvmtiEnv* jvmti_1 = NULL; + jvmtiEnv* jvmti_1 = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -199,7 +199,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* Create second environment */ if (!NSK_VERIFY((jvmti_2 = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* Set callbacks for second environment */ @@ -226,7 +226,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } NSK_DISPLAY1("Enable events: %d events\n", EVENTS_COUNT); - if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, NULL)) { + if (nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, events, nullptr)) { NSK_DISPLAY0(" ... enabled\n"); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/general_functions/GF08/gf08t001/gf08t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/general_functions/GF08/gf08t001/gf08t001.cpp index d5d830e6d9b..7dd894afb8d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/general_functions/GF08/gf08t001/gf08t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/general_functions/GF08/gf08t001/gf08t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ static jlong timeout = 0; /* test objects */ static jrawMonitorID access_lock; static jvmtiPhase phase; -static const char* setVerboseMode = NULL; +static const char* setVerboseMode = nullptr; /* ========================================================================== */ @@ -54,7 +54,7 @@ JNIEXPORT jint JNI_OnLoad_gf08t001(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv *jvmti = NULL; + jvmtiEnv *jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -64,10 +64,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - setVerboseMode = nsk_jvmti_findOptionStringValue("setVerboseMode", NULL); + setVerboseMode = nsk_jvmti_findOptionStringValue("setVerboseMode", nullptr); if (strcmp(setVerboseMode, "y") == 0 || strcmp(setVerboseMode, "yes") == 0) { if (!NSK_JVMTI_VERIFY(jvmti->SetVerboseFlag(JVMTI_VERBOSE_GC, JNI_TRUE))) { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/general_functions/GF08/gf08t002/gf08t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/general_functions/GF08/gf08t002/gf08t002.cpp index 4b2455a4f46..ae930eb0805 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/general_functions/GF08/gf08t002/gf08t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/general_functions/GF08/gf08t002/gf08t002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ static jlong timeout = 0; /* test objects */ static jrawMonitorID access_lock; static jvmtiPhase phase; -static const char* setVerboseMode = NULL; +static const char* setVerboseMode = nullptr; /* ========================================================================== */ @@ -54,7 +54,7 @@ JNIEXPORT jint JNI_OnLoad_gf08t002(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv *jvmti = NULL; + jvmtiEnv *jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -64,10 +64,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - setVerboseMode = nsk_jvmti_findOptionStringValue("setVerboseMode", NULL); + setVerboseMode = nsk_jvmti_findOptionStringValue("setVerboseMode", nullptr); if (strcmp(setVerboseMode, "y") == 0 || strcmp(setVerboseMode, "yes") == 0) { if (!NSK_JVMTI_VERIFY(jvmti->SetVerboseFlag(JVMTI_VERBOSE_CLASS, JNI_TRUE))) { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/general_functions/GF08/gf08t003/gf08t003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/general_functions/GF08/gf08t003/gf08t003.cpp index ee6e7bf9f73..5c792635968 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/general_functions/GF08/gf08t003/gf08t003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/general_functions/GF08/gf08t003/gf08t003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ static jlong timeout = 0; /* test objects */ static jrawMonitorID access_lock; static jvmtiPhase phase; -static const char* setVerboseMode = NULL; +static const char* setVerboseMode = nullptr; /* ========================================================================== */ @@ -54,7 +54,7 @@ JNIEXPORT jint JNI_OnLoad_gf08t003(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv *jvmti = NULL; + jvmtiEnv *jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -64,10 +64,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - setVerboseMode = nsk_jvmti_findOptionStringValue("setVerboseMode", NULL); + setVerboseMode = nsk_jvmti_findOptionStringValue("setVerboseMode", nullptr); if (strcmp(setVerboseMode, "y") == 0 || strcmp(setVerboseMode, "yes") == 0) { if (!NSK_JVMTI_VERIFY(jvmti->SetVerboseFlag(JVMTI_VERBOSE_JNI, JNI_TRUE))) { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS103/hs103t002/hs103t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS103/hs103t002/hs103t002.cpp index 634a4d351fa..a903074cd01 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS103/hs103t002/hs103t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS103/hs103t002/hs103t002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,13 +57,13 @@ JNIEXPORT void JNICALL doRedefineInNativeThread(jvmtiEnv * jvmti, testClass = jni->FindClass(MAIN_CLASS); if (!NSK_JNI_VERIFY(jni, ( - setRedefinitionFailed = jni->GetStaticMethodID(testClass, "setRedefinitionFailed", "()V")) != NULL)) + setRedefinitionFailed = jni->GetStaticMethodID(testClass, "setRedefinitionFailed", "()V")) != nullptr)) { jni->FatalError("TEST FAILED: while getting setRedefinitionFailed()\n"); } if (!NSK_JNI_VERIFY(jni, ( - setRedefinitionDone = jni->GetStaticMethodID(testClass, "setRedefinitionDone", "()V")) != NULL)) + setRedefinitionDone = jni->GetStaticMethodID(testClass, "setRedefinitionDone", "()V")) != nullptr)) { jni->FatalError("TEST FAILED: while getting setRedefinitionDone()\n"); } @@ -142,14 +142,14 @@ Java_nsk_jvmti_scenarios_hotswap_HS103_hs103t002_hs103t002_startAgentThread(JNIE name = jni->NewStringUTF(threadName); clas = jni->FindClass("java/lang/Thread"); - if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(clas, "", "(Ljava/lang/String;)V")) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(clas, "", "(Ljava/lang/String;)V")) != nullptr)) { jni->FatalError("failed to get ID for the java method\n"); } thread = (jthread) jni->NewObject(clas,method,name); testAgentThread = jni->NewGlobalRef(thread); err = JVMTI_ERROR_NONE; - err = jvmti->RunAgentThread(testAgentThread, &doRedefineInNativeThread, NULL, + err = jvmti->RunAgentThread(testAgentThread, &doRedefineInNativeThread, nullptr, JVMTI_THREAD_NORM_PRIORITY); if (err == JVMTI_ERROR_INVALID_PRIORITY) { nsk_printf(" JVMTI_ERROR_INVALID_PRIORITY ..\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS104/hs104t001/hs104t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS104/hs104t001/hs104t001.cpp index 72987808f3e..0044aec284e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS104/hs104t001/hs104t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS104/hs104t001/hs104t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -48,7 +48,7 @@ JNIEXPORT void JNICALL sizeof(fileName)/sizeof(char)); if (nsk_jvmti_redefineClass(jvmti, klass, fileName)) { nsk_printf("Agent:: Successfully redefined.."); - if (nsk_jvmti_disableNotification(jvmti,JVMTI_EVENT_CLASS_PREPARE, NULL)) { + if (nsk_jvmti_disableNotification(jvmti,JVMTI_EVENT_CLASS_PREPARE, nullptr)) { nsk_printf(" Agent :: NOTIFICATIONS ARE DISABLED \n"); } else { nsk_printf(" Agent :: Failed to disabled \n"); @@ -96,7 +96,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { nsk_printf(" Agent:: Error occured while setting event call back \n"); return JNI_ERR; } - if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, NULL)) { + if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, nullptr)) { nsk_printf("Agent :: NOTIFICATIONS ARE ENABLED \n"); } else { nsk_printf(" Error in Eanableing Notifications.."); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS104/hs104t002/hs104t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS104/hs104t002/hs104t002.cpp index 5f107e31b90..670b48bfeab 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS104/hs104t002/hs104t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS104/hs104t002/hs104t002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -74,7 +74,7 @@ Java_nsk_jvmti_scenarios_hotswap_HS104_hs104t002_hs104t002_redefineClasses( jclass cla; char fileName[512]; - if (!NSK_JNI_VERIFY(jni, (cla = jni->FindClass(SEARCH_NAME)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (cla = jni->FindClass(SEARCH_NAME)) != nullptr)) { nsk_printf(" Agent :: Failed to get class.\n"); nsk_jvmti_agentFailed(); return; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t001/hs201t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t001/hs201t001.cpp index 5883c17f5b4..200df590244 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t001/hs201t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t001/hs201t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -32,8 +32,8 @@ extern "C" { /* ============================================================================= */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* constant names */ @@ -64,7 +64,7 @@ void setCurrentStep(JNIEnv* jni_env, int value) { jfieldID fld; if (!NSK_JNI_VERIFY(jni_env, (fld = - jni_env->GetStaticFieldID(testClass, "currentStep", "I")) != NULL)) { + jni_env->GetStaticFieldID(testClass, "currentStep", "I")) != nullptr)) { jni_env->FatalError("TEST FAILED: while getting currentStep fieldID\n"); } @@ -102,7 +102,7 @@ void redefineClass(jvmtiEnv *jvmti_env, jclass klass) { char *className; - if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &className, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &className, nullptr))) { nsk_jvmti_setFailStatus(); return; } @@ -165,7 +165,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* agentJNI, void* arg) { void setBreakPoint(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jclass klass) { jmethodID mid; - if (!NSK_JNI_VERIFY(jni_env, (mid = jni_env->GetMethodID(klass, METHOD_NAME, METHOD_SIG)) != NULL)) + if (!NSK_JNI_VERIFY(jni_env, (mid = jni_env->GetMethodID(klass, METHOD_NAME, METHOD_SIG)) != nullptr)) jni_env->FatalError("[agent] failed to get ID for the java method\n"); if (!NSK_JVMTI_VERIFY(jvmti_env->SetBreakpoint(mid, 1))) @@ -200,7 +200,7 @@ callbackClassLoad(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, nsk_jvmti_setFailStatus(); } - if (generic != NULL) + if (generic != nullptr) if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)generic))) { nsk_jvmti_setFailStatus(); } @@ -232,7 +232,7 @@ callbackSingleStep(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, char *methodName; - if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &methodName, NULL, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &methodName, nullptr, nullptr))) { NSK_COMPLAIN0("TEST FAILED: unable to get method name during Breakpoint callback\n\n"); } @@ -244,7 +244,7 @@ callbackSingleStep(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, NSK_COMPLAIN0("TEST FAILED: unable to get method name during Breakpoint callback\n\n"); } - if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(declaringClass, &declaringClassName, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(declaringClass, &declaringClassName, nullptr))) { NSK_COMPLAIN0("TEST FAILED: unable to get method name during Breakpoint callback\n\n"); } @@ -335,7 +335,7 @@ callbackException(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, className, getThreadName(jni_env, thread)); testStep++; - if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(exception)) != NULL)) { + if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(exception)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -366,7 +366,7 @@ callbackExceptionCatch(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, className, getThreadName(jni_env, thread)); testStep++; - if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(exception)) != NULL)) { + if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(exception)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -397,7 +397,7 @@ int readNewBytecode(jvmtiEnv* jvmti, int testcase) { filename); bytecode = fopen(filename, "rb"); - if (bytecode == NULL) { + if (bytecode == nullptr) { NSK_COMPLAIN0("TEST FAILED: error opening file\n"); return NSK_FALSE; } @@ -430,13 +430,13 @@ const char* getThreadName(JNIEnv* jni_env, jthread thread) { strcpy(chbuffer, ""); - if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(thread)) != NULL)) { + if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(thread)) != nullptr)) { nsk_jvmti_setFailStatus(); return chbuffer; } if (!NSK_JNI_VERIFY(jni_env, (methodID = - jni_env->GetMethodID(klass, "getName", "()Ljava/lang/String;")) != NULL)) { + jni_env->GetMethodID(klass, "getName", "()Ljava/lang/String;")) != nullptr)) { nsk_jvmti_setFailStatus(); return chbuffer; } @@ -462,7 +462,7 @@ const char* getClassName(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jobject object) { strcpy(chbuffer, ""); - if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(object)) != NULL)) { + if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(object)) != nullptr)) { nsk_jvmti_setFailStatus(); return chbuffer; } @@ -478,7 +478,7 @@ const char* getClassName(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jobject object) { nsk_jvmti_setFailStatus(); } - if (generic != NULL) + if (generic != nullptr) if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)generic))) { nsk_jvmti_setFailStatus(); } @@ -491,7 +491,7 @@ const char* getClassName(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jobject object) { int getLocalVariableValue(jvmtiEnv *jvmti_env, jthread thread, jmethodID method) { - jvmtiLocalVariableEntry *table = NULL; + jvmtiLocalVariableEntry *table = nullptr; jint entryCount = 0; int i; jint value = -1; @@ -501,7 +501,7 @@ int getLocalVariableValue(jvmtiEnv *jvmti_env, jthread thread, NSK_COMPLAIN0("TEST FAILED: unable to get local variable table\n\n"); } - if (table != NULL) { + if (table != nullptr) { jvmtiError error; for (i = 0; i < entryCount; i++) { @@ -540,10 +540,10 @@ JNIEXPORT void JNICALL Java_nsk_jvmti_scenarios_hotswap_HS201_hs201t001_setThread(JNIEnv *env, jclass cls, jthread thread) { - if (!NSK_JNI_VERIFY(env, (testClass = (jclass) env->NewGlobalRef(cls)) != NULL)) + if (!NSK_JNI_VERIFY(env, (testClass = (jclass) env->NewGlobalRef(cls)) != nullptr)) nsk_jvmti_setFailStatus(); - if (!NSK_JNI_VERIFY(env, (testedThread = env->NewGlobalRef(thread)) != NULL)) + if (!NSK_JNI_VERIFY(env, (testedThread = env->NewGlobalRef(thread)) != nullptr)) nsk_jvmti_setFailStatus(); } @@ -632,7 +632,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; { @@ -670,7 +670,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { enableEvent(jvmti, JVMTI_EVENT_EXCEPTION, testedThread); enableEvent(jvmti, JVMTI_EVENT_EXCEPTION_CATCH, testedThread); - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t002/hs201t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t002/hs201t002.cpp index 43cd4463139..8c369dd1d55 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t002/hs201t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t002/hs201t002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -32,8 +32,8 @@ extern "C" { /* ============================================================================= */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* constant names */ @@ -66,7 +66,7 @@ void setCurrentStep(JNIEnv* jni_env, int value) { jfieldID fld; if (!NSK_JNI_VERIFY(jni_env, (fld = - jni_env->GetStaticFieldID(testClass, "currentStep", "I")) != NULL)) { + jni_env->GetStaticFieldID(testClass, "currentStep", "I")) != nullptr)) { jni_env->FatalError("TEST FAILED: while getting currentStep fieldID\n"); } @@ -105,7 +105,7 @@ void redefineClass(jvmtiEnv *jvmti_env, jclass klass) { jint newClassSize; unsigned char* newClassBytes; - if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &className, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &className, nullptr))) { nsk_jvmti_setFailStatus(); return; } @@ -170,7 +170,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* agentJNI, void* arg) { void setBreakPoint(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jclass klass) { jmethodID mid; - if (!NSK_JNI_VERIFY(jni_env, (mid = jni_env->GetMethodID(klass, METHOD_NAME, METHOD_SIG)) != NULL)) + if (!NSK_JNI_VERIFY(jni_env, (mid = jni_env->GetMethodID(klass, METHOD_NAME, METHOD_SIG)) != nullptr)) jni_env->FatalError("[agent] failed to get ID for the java method\n"); if (!NSK_JVMTI_VERIFY(jvmti_env->SetBreakpoint(mid, 1))) @@ -189,7 +189,7 @@ callbackClassLoad(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, char *className; - if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &className, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &className, nullptr))) { nsk_jvmti_setFailStatus(); return; } @@ -230,7 +230,7 @@ callbackSingleStep(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, char *methodName; - if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &methodName, NULL, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &methodName, nullptr, nullptr))) { NSK_COMPLAIN0("TEST FAILED: unable to get method name during Breakpoint callback\n\n"); } @@ -242,7 +242,7 @@ callbackSingleStep(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, NSK_COMPLAIN0("TEST FAILED: unable to get method name during Breakpoint callback\n\n"); } - if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(declaringClass, &declaringClassName, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(declaringClass, &declaringClassName, nullptr))) { NSK_COMPLAIN0("TEST FAILED: unable to get method name during Breakpoint callback\n\n"); } @@ -347,19 +347,19 @@ void handleException(bool isCatch, jobject exception) { const char* className = getClassName(jvmti_env, jni_env, exception); - if (className != NULL && strcmp(EXPECTED_CLASS_SIGN, className) == 0) { + if (className != nullptr && strcmp(EXPECTED_CLASS_SIGN, className) == 0) { jclass klass; const char* threadName = getThreadName(jvmti_env, jni_env, thread); NSK_DISPLAY3(">>>> %s %s in thread - %s\n", isCatch ? "Caught exception" : "Exception", - className, threadName != NULL ? threadName : "NULL"); + className, threadName != nullptr ? threadName : "null"); jvmti->Deallocate((unsigned char*)className); - if (threadName != NULL) { + if (threadName != nullptr) { jvmti->Deallocate((unsigned char*)threadName); } testStep++; - if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(exception)) != NULL)) { + if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(exception)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -390,7 +390,7 @@ int readNewBytecode(jvmtiEnv* jvmti, jint *newClassSize, unsigned char* *newClas filename); bytecode = fopen(filename, "rb"); - if (bytecode == NULL) { + if (bytecode == nullptr) { NSK_COMPLAIN0("TEST FAILED: error opening file\n"); return NSK_FALSE; } @@ -408,7 +408,7 @@ int readNewBytecode(jvmtiEnv* jvmti, jint *newClassSize, unsigned char* *newClas if (read_bytes != *newClassSize) { NSK_COMPLAIN0("TEST FAILED: error reading file\n"); jvmti->Deallocate(*newClassBytes); - *newClassBytes = NULL; + *newClassBytes = nullptr; return NSK_FALSE; } @@ -422,18 +422,18 @@ const char* getThreadName(jvmtiEnv* jvmti_env, JNIEnv* jni_env, jthread thread) jclass klass; jstring jthreadName; jsize jthreadNameLen; - unsigned char *result = NULL; + unsigned char *result = nullptr; const char *threadName; - if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(thread)) != NULL)) { + if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(thread)) != nullptr)) { nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } if (!NSK_JNI_VERIFY(jni_env, (methodID = - jni_env->GetMethodID(klass, "getName", "()Ljava/lang/String;")) != NULL)) { + jni_env->GetMethodID(klass, "getName", "()Ljava/lang/String;")) != nullptr)) { nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } jthreadName = (jstring) jni_env->CallObjectMethod(thread, methodID); @@ -442,7 +442,7 @@ const char* getThreadName(jvmtiEnv* jvmti_env, JNIEnv* jni_env, jthread thread) if (!NSK_JVMTI_VERIFY(jvmti_env->Allocate(jthreadNameLen + 1, &result))) { NSK_COMPLAIN0("buffer couldn't be allocated\n"); - return NULL; + return nullptr; } threadName = jni_env->GetStringUTFChars(jthreadName, 0); @@ -461,14 +461,14 @@ const char* getClassName(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jobject object) { char *className; jclass klass; - if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(object)) != NULL)) { + if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(object)) != nullptr)) { nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } - if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &className, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &className, nullptr))) { nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } return className; @@ -479,7 +479,7 @@ const char* getClassName(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jobject object) { int getLocalVariableValue(jvmtiEnv *jvmti_env, jthread thread, jmethodID method) { - jvmtiLocalVariableEntry *table = NULL; + jvmtiLocalVariableEntry *table = nullptr; jint entryCount = 0; int i; jint value = -1; @@ -489,7 +489,7 @@ int getLocalVariableValue(jvmtiEnv *jvmti_env, jthread thread, NSK_COMPLAIN0("TEST FAILED: unable to get local variable table\n\n"); } - if (table != NULL) { + if (table != nullptr) { jvmtiError error; for (i = 0; i < entryCount; i++) { @@ -528,10 +528,10 @@ JNIEXPORT void JNICALL Java_nsk_jvmti_scenarios_hotswap_HS201_hs201t002_setThread(JNIEnv *env, jclass cls, jthread thread) { - if (!NSK_JNI_VERIFY(env, (testClass = (jclass) env->NewGlobalRef(cls)) != NULL)) + if (!NSK_JNI_VERIFY(env, (testClass = (jclass) env->NewGlobalRef(cls)) != nullptr)) nsk_jvmti_setFailStatus(); - if (!NSK_JNI_VERIFY(env, (testedThread = env->NewGlobalRef(thread)) != NULL)) + if (!NSK_JNI_VERIFY(env, (testedThread = env->NewGlobalRef(thread)) != nullptr)) nsk_jvmti_setFailStatus(); enableEvent(jvmti, JVMTI_EVENT_CLASS_LOAD, testedThread); @@ -624,7 +624,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; { @@ -657,7 +657,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { NSK_DISPLAY0("Enable events\n"); - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t003/hs201t003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t003/hs201t003.cpp index 97b247a3d62..f848d717183 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t003/hs201t003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS201/hs201t003/hs201t003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -50,7 +50,7 @@ static jvmtiEvent eventsList[EVENTS_COUNT] = { JVMTI_EVENT_FRAME_POP }; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; static jint bytesCount; /* number of bytes of a redefining class */ @@ -74,7 +74,7 @@ static int expectedMeth(jvmtiEnv *jvmti_env, const char *event, char *sig; int methFound = 0; - if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &sig, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &sig, nullptr))) { nsk_jvmti_setFailStatus(); return 0; } @@ -107,7 +107,7 @@ static void doHotSwap(jvmtiEnv *jvmti_env, nsk_jvmti_setFailStatus(); return; } - if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(decl_cls, &cls_sig, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(decl_cls, &cls_sig, nullptr))) { nsk_jvmti_setFailStatus(); return; } @@ -143,7 +143,7 @@ static void doChecks(jvmtiEnv *jvmti_env, jint methBytesCount; /* number of bytes of a method */ unsigned char *methBytes; /* bytes defining a method */ - if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(tMethodID, &name, &sig, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(tMethodID, &name, &sig, nullptr))) { nsk_jvmti_setFailStatus(); return; } @@ -196,7 +196,7 @@ void JNICALL MethodEntry(jvmtiEnv *jvmti_env, JNIEnv *env, nsk_jvmti_setFailStatus(); } - if (!NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_METHOD_ENTRY, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_METHOD_ENTRY, nullptr))) nsk_jvmti_setFailStatus(); } } @@ -298,7 +298,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add required capabilities */ @@ -324,13 +324,13 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { NSK_DISPLAY0("setting event callbacks done\nenabling events ...\n"); if (!nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, - eventsList, NULL)) + eventsList, nullptr)) return JNI_ERR; NSK_DISPLAY0("enabling the events done\n\n"); /* register agent proc */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS202/hs202t001/hs202t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS202/hs202t001/hs202t001.cpp index 6b284a54bbc..e7936fda8c5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS202/hs202t001/hs202t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS202/hs202t001/hs202t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,7 +56,7 @@ JNIEXPORT void JNICALL callbackClassPrepare(jvmtiEnv *jvmti, if (strcmp(className,CLASS_NAME) == 0) { jmethodID method; method = jni->GetMethodID(klass, METHOD_NAME, METHOD_SIGN); - if (method == NULL) { + if (method == nullptr) { nsk_printf("Agent:: Method is null "); } else { jlocation start; @@ -73,7 +73,7 @@ JNIEXPORT void JNICALL callbackClassPrepare(jvmtiEnv *jvmti, nsk_printf(" ## Error occured %s \n",TranslateError(err)); } else { nsk_printf(" NO ERRORS "); - if (nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_BREAKPOINT, NULL)) { + if (nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_BREAKPOINT, nullptr)) { nsk_printf(" Enabled.. notification event ..\n"); } } @@ -116,11 +116,11 @@ void JNICALL callbackBreakpoint(jvmtiEnv *jvmti_env, jlocation location) { jvmtiError err; err = JVMTI_ERROR_NONE; - if (nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_SINGLE_STEP, NULL)) { + if (nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_SINGLE_STEP, nullptr)) { nsk_printf(" Enabled.. notification event .."); } err= jvmti->SetEventNotificationMode(JVMTI_DISABLE, - JVMTI_EVENT_BREAKPOINT, NULL); + JVMTI_EVENT_BREAKPOINT, nullptr); if (err == JVMTI_ERROR_NONE) { nsk_printf(" Disabled notification.."); } @@ -172,7 +172,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { nsk_printf(" ## Error occured %s \n",TranslateError(rc)); return JNI_ERR; } - if (nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_CLASS_PREPARE, NULL)) { + if (nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_CLASS_PREPARE, nullptr)) { nsk_printf("Agent :: NOTIFICATIONS ARE ENABLED \n"); } else { nsk_printf(" Error in Eanableing Notifications.."); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS202/hs202t002/hs202t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS202/hs202t002/hs202t002.cpp index 12f4cc3fb4e..493e23da000 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS202/hs202t002/hs202t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS202/hs202t002/hs202t002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ extern "C" { #define METHOD_NAME "display" static jint redefineNumber = 0; -static jvmtiEnv * jvmti = NULL; +static jvmtiEnv * jvmti = nullptr; static volatile bool thread_suspend_error = false; @@ -119,7 +119,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { nsk_printf(" Agent:: Error occured while setting event callbacks \n"); return JNI_ERR; } - if (nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_METHOD_EXIT, NULL)) { + if (nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_METHOD_EXIT, nullptr)) { nsk_printf(" Agent :: NOTIFICATIONS ARE ENABLED \n"); } else { nsk_printf(" Agent :: Error Enabling Notifications.."); @@ -160,7 +160,7 @@ Java_nsk_jvmti_scenarios_hotswap_HS202_hs202t002_hs202t002_resumeThread(JNIEnv * // disable notifications before resuming thread // to avoid recursion on PopFrame issued reinvoke - if (nsk_jvmti_disableNotification(jvmti,JVMTI_EVENT_METHOD_EXIT, NULL)) { + if (nsk_jvmti_disableNotification(jvmti,JVMTI_EVENT_METHOD_EXIT, nullptr)) { nsk_printf("Agent :: nsk_jvmti_disabled notifications..\n"); } else { nsk_printf("Agent :: Failed to disable notifications.."); @@ -194,7 +194,7 @@ Java_nsk_jvmti_scenarios_hotswap_HS202_hs202t002_hs202t002_isThreadSuspended(JNI // this again until we see thread_suspend_error is true. jint state = 0; - // No errors possible here: thread is valid, and state is not NULL + // No errors possible here: thread is valid, and state is not nullptr jvmti->GetThreadState(thread, &state); return (state & JVMTI_THREAD_STATE_SUSPENDED) != 0; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS203/hs203t001/hs203t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS203/hs203t001/hs203t001.cpp index 2e95e5e7e70..4104656aa25 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS203/hs203t001/hs203t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS203/hs203t001/hs203t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -63,7 +63,7 @@ JNIEXPORT void JNICALL if (strcmp(className,CLASS_NAME) == 0) { jmethodID method; method = jni->GetMethodID(klass,METHOD_NAME,METHOD_SIGN); - if (method != NULL) { + if (method != nullptr) { jlocation start; jlocation end; jvmtiError err ; @@ -166,8 +166,8 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { nsk_printf(" Agent:: Error occured while setting event call back \n"); return JNI_ERR; } - if (nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_CLASS_LOAD, NULL) && - nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_BREAKPOINT,NULL)) { + if (nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_CLASS_LOAD, nullptr) && + nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_BREAKPOINT,nullptr)) { nsk_printf("Agent :: NOTIFICATIONS ARE ENABLED \n"); } else { nsk_printf(" Error in Eanableing Notifications.."); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS203/hs203t002/hs203t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS203/hs203t002/hs203t002.cpp index b1b3b42164f..3328e730f08 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS203/hs203t002/hs203t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS203/hs203t002/hs203t002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -65,7 +65,7 @@ callbackClassLoad(jvmtiEnv *jvmti, if (strcmp(className,CLASS_NAME) == 0) { jmethodID method; method = jni->GetMethodID(klass,METHOD_NAME,METHOD_SIGN); - if (method != NULL) { + if (method != nullptr) { jlocation start; jlocation end; jvmtiError err ; @@ -168,8 +168,8 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { nsk_printf(" Agent:: Error occured while setting event call back \n"); return JNI_ERR; } - if (nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_CLASS_LOAD, NULL) && - nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_BREAKPOINT, NULL)) { + if (nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_CLASS_LOAD, nullptr) && + nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_BREAKPOINT, nullptr)) { nsk_printf("Agent :: NOTIFICATIONS ARE ENABLED \n"); } else { nsk_printf(" Error in Eanableing Notifications.."); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS203/hs203t003/hs203t003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS203/hs203t003/hs203t003.cpp index a162fa0270c..3f067dd4e9a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS203/hs203t003/hs203t003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS203/hs203t003/hs203t003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,8 +58,8 @@ JNIEXPORT void JNICALL callbackClassPrepare(jvmtiEnv *jvmti_env, char * className; char * generic; redefineNumber=0; - className=NULL; - generic=NULL; + className=nullptr; + generic=nullptr; if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &className, &generic))) { nsk_printf("#error Agent :: while getting classname Signature.\n"); nsk_jvmti_agentFailed(); @@ -67,7 +67,7 @@ JNIEXPORT void JNICALL callbackClassPrepare(jvmtiEnv *jvmti_env, if (strcmp(className,CLASS_NAME) == 0) { jfieldID field; /* get the field id and set watch on that .*/ - if (!NSK_JNI_VERIFY(jni, (field = jni->GetFieldID(klass, FIELDNAME, TYPE)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (field = jni->GetFieldID(klass, FIELDNAME, TYPE)) != nullptr)) { nsk_printf(" Agent :: (*JNI)->GetFieldID(jni, ...) returns `null`.\n"); nsk_jvmti_agentFailed(); } else if (!NSK_JVMTI_VERIFY(jvmti_env->SetFieldAccessWatch(klass, field))) { @@ -93,7 +93,7 @@ JNIEXPORT void JNICALL callbackFieldAccess(jvmtiEnv *jvmti_env, return; } redefineNumber=0; - if (!NSK_JNI_VERIFY(jni, (clas = jni->FindClass(SEARCH_NAME)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (clas = jni->FindClass(SEARCH_NAME)) != nullptr)) { nsk_printf(" Agent :: (*JNI)->FindClass(jni, %s) returns `null`.\n",SEARCH_NAME); nsk_jvmti_agentFailed(); } else { @@ -155,8 +155,8 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { nsk_printf("#error Agent :: while setting event callbacks.\n"); return JNI_ERR; } - if (nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_CLASS_PREPARE, NULL) && - nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_FIELD_ACCESS, NULL)) { + if (nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_CLASS_PREPARE, nullptr) && + nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_FIELD_ACCESS, nullptr)) { nsk_printf(" Agent :: Notifications are enabled.\n"); } else { nsk_printf("#error Agent :: Eanableing Notifications.\n"); @@ -202,7 +202,7 @@ Java_nsk_jvmti_scenarios_hotswap_HS203_hs203t003_hs203t003_popThreadFrame(JNIEnv } else { nsk_printf(" Agent :: poped thread frame.\n"); if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_FIELD_ACCESS, NULL))) { + jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_FIELD_ACCESS, nullptr))) { nsk_printf("#error Agent :: failed to disable notification JVMTI_EVENT_FIELD ACCESS.\n"); nsk_jvmti_agentFailed(); } else { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS203/hs203t004/hs203t004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS203/hs203t004/hs203t004.cpp index e29d7563d43..7a0e59b7206 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS203/hs203t004/hs203t004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS203/hs203t004/hs203t004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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,14 +43,14 @@ JNIEXPORT void JNICALL callbackClassPrepare(jvmtiEnv *jvmti_env, jthread thread, jclass klass) { char * className; - className=NULL; + className=nullptr; - if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &className, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &className, nullptr))) { NSK_COMPLAIN0("#error Agent :: while getting classname.\n"); nsk_jvmti_agentFailed(); } else { if (strcmp(className, CLASS_NAME) == 0) { - if (nsk_jvmti_enableNotification(jvmti_env, JVMTI_EVENT_COMPILED_METHOD_LOAD, NULL)) { + if (nsk_jvmti_enableNotification(jvmti_env, JVMTI_EVENT_COMPILED_METHOD_LOAD, nullptr)) { NSK_DISPLAY0(" Agent :: notification enabled for COMPILED_METHOD_LOAD.\n"); if (!NSK_JVMTI_VERIFY(jvmti_env->GenerateEvents(JVMTI_EVENT_COMPILED_METHOD_LOAD))) { NSK_COMPLAIN0("#error Agent :: occured while enabling compiled method events.\n"); @@ -83,16 +83,16 @@ JNIEXPORT void JNICALL callbackCompiledMethodLoad(jvmtiEnv *jvmti_env, char *className; char *methodName; - className = NULL; - methodName = NULL; + className = nullptr; + methodName = nullptr; - if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(threadClass, &className, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(threadClass, &className, nullptr))) { NSK_COMPLAIN0("#error Agent :: while getting classname.\n"); nsk_jvmti_agentFailed(); return; } - if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &methodName, NULL, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &methodName, nullptr, nullptr))) { NSK_COMPLAIN0("#error Agent :: while getting methodname.\n"); nsk_jvmti_agentFailed(); return; @@ -115,13 +115,13 @@ JNIEXPORT void JNICALL callbackCompiledMethodLoad(jvmtiEnv *jvmti_env, } } - if (className != NULL) { + if (className != nullptr) { if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char *)className))) { NSK_COMPLAIN1("#error Agent :: failed to Deallocate className = %s.", className); nsk_jvmti_agentFailed(); } } - if (methodName != NULL) { + if (methodName != nullptr) { if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char *)methodName))) { NSK_COMPLAIN1("#error Agent :: failed to Deallocate methodName = %s.", methodName); nsk_jvmti_agentFailed(); @@ -171,7 +171,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { NSK_COMPLAIN0("#error Agent :: occured while setting event callback.\n"); return JNI_ERR; } - if (nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_CLASS_PREPARE, NULL)) { + if (nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_CLASS_PREPARE, nullptr)) { NSK_DISPLAY0(" Agent :: Notifications are enabled.\n"); } else { NSK_COMPLAIN0("#error Agent :: Error in enableing Notifications.\n"); @@ -214,7 +214,7 @@ Java_nsk_jvmti_scenarios_hotswap_HS203_hs203t004_hs203t004_popThreadFrame(JNIEnv } else { if (NSK_JVMTI_VERIFY( jvmti->SetEventNotificationMode(JVMTI_DISABLE, - JVMTI_EVENT_COMPILED_METHOD_LOAD, NULL))) { + JVMTI_EVENT_COMPILED_METHOD_LOAD, nullptr))) { NSK_DISPLAY0(" Agent :: Disabled JVMTI_EVENT_COMPILED_METHOD_LOAD.\n"); retvalue = JNI_TRUE; } else { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS204/hs204t002/hs204t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS204/hs204t002/hs204t002.cpp index 1f1d3f9db09..bc080f2d882 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS204/hs204t002/hs204t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS204/hs204t002/hs204t002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,12 +57,12 @@ callbackClassPrepare(jvmtiEnv *jvmti, if ((strcmp(className, CLASS_NAME) == 0)) { jclass cls; cls = jni->FindClass(SEARCH_NAME); - if (cls == NULL) { + if (cls == nullptr) { printf("Agent::CLS is null"); } else { jmethodID method; method = jni->GetMethodID(cls, METHOD_NAME,METHOD_SIGNATURE); - if (method == NULL) { + if (method == nullptr) { printf("Agent::Method is null "); } else { jlocation start; @@ -158,8 +158,8 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { return JNI_ERR; } - nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE , NULL); - nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_BREAKPOINT, NULL); + nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE , nullptr); + nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_BREAKPOINT, nullptr); } return JNI_OK; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS204/hs204t003/hs204t003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS204/hs204t003/hs204t003.cpp index 4980cd40473..3b182cb616d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS204/hs204t003/hs204t003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS204/hs204t003/hs204t003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -48,8 +48,8 @@ JNIEXPORT void JNICALL callbackClassPrepare(jvmtiEnv *jvmti_env, char * className; char * generic; - className = NULL; - generic = NULL; + className = nullptr; + generic = nullptr; redefineNumber=0; if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &className, &generic))) { NSK_DISPLAY0(" Agent :: Failed get class signature.\n"); @@ -57,7 +57,7 @@ JNIEXPORT void JNICALL callbackClassPrepare(jvmtiEnv *jvmti_env, } else { if ((strcmp(className, CLASS_NAME) == 0)) { jfieldID fieldId; - if (!NSK_JNI_VERIFY(jni, (fieldId = jni->GetStaticFieldID(klass, FIELDNAME, TYPE)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (fieldId = jni->GetStaticFieldID(klass, FIELDNAME, TYPE)) != nullptr)) { NSK_DISPLAY0(" Agent :: Failed to get FieldId.\n"); nsk_jvmti_agentFailed(); } else { @@ -65,8 +65,8 @@ JNIEXPORT void JNICALL callbackClassPrepare(jvmtiEnv *jvmti_env, NSK_DISPLAY0(" Agent :: Failed to set watch point on a field.\n"); nsk_jvmti_agentFailed(); } else { - nsk_jvmti_enableNotification(jvmti_env, JVMTI_EVENT_FIELD_ACCESS, NULL); - if (!NSK_JNI_VERIFY(jni, (watchFieldClass = (jclass) jni->NewGlobalRef(klass)) != NULL)) { + nsk_jvmti_enableNotification(jvmti_env, JVMTI_EVENT_FIELD_ACCESS, nullptr); + if (!NSK_JNI_VERIFY(jni, (watchFieldClass = (jclass) jni->NewGlobalRef(klass)) != nullptr)) { NSK_DISPLAY0(" Agent :: Failed to get global reference for class.\n"); nsk_jvmti_agentFailed(); } @@ -77,14 +77,14 @@ JNIEXPORT void JNICALL callbackClassPrepare(jvmtiEnv *jvmti_env, } } - if (className != NULL) { + if (className != nullptr) { if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char *)className))) { NSK_DISPLAY1(" Agent :: #error failed to Deallocate className = %s.", className); nsk_jvmti_agentFailed(); } } - if (generic != NULL) { + if (generic != nullptr) { if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char *)generic))) { NSK_DISPLAY1(" Agent :: #error failed to Deallocate class signature = %s.", generic); nsk_jvmti_agentFailed(); @@ -105,8 +105,8 @@ JNIEXPORT void JNICALL callbackFieldAccess(jvmtiEnv *jvmti_env, char * className; char * generic; - className = NULL; - generic = NULL; + className = nullptr; + generic = nullptr; if (redefineNumber != 0) { return; } @@ -139,14 +139,14 @@ JNIEXPORT void JNICALL callbackFieldAccess(jvmtiEnv *jvmti_env, } } - if (className != NULL) { + if (className != nullptr) { if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char *)className))) { NSK_DISPLAY1(" Agent :: #error failed to Deallocate className = %s.", className); nsk_jvmti_agentFailed(); } } - if (generic != NULL) { + if (generic != nullptr) { if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char *)generic))) { NSK_DISPLAY1(" Agent :: #error failed to Deallocate class signature = %s.", generic); nsk_jvmti_agentFailed(); @@ -192,7 +192,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { NSK_DISPLAY0(" Agent :: Error occured while setting event call back \n"); return JNI_ERR; } - nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, NULL); + nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, nullptr); } return JNI_OK; } @@ -219,7 +219,7 @@ Java_nsk_jvmti_scenarios_hotswap_HS204_hs204t003_hs204t003_popFrame(JNIEnv * jni nsk_jvmti_agentFailed(); } else { jfieldID fieldId = jni->GetStaticFieldID(watchFieldClass, FIELDNAME, TYPE); - if (!NSK_JNI_VERIFY(jni, fieldId != NULL)) { + if (!NSK_JNI_VERIFY(jni, fieldId != nullptr)) { NSK_DISPLAY0(" Agent :: Failed to get FieldId before droping watchers.\n"); nsk_jvmti_agentFailed(); } else { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS204/hs204t004/hs204t004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS204/hs204t004/hs204t004.cpp index 09178bac4a1..e8141386cb0 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS204/hs204t004/hs204t004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS204/hs204t004/hs204t004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -55,11 +55,11 @@ callbackClassLoad(jvmtiEnv *jvmti_env, redefineNumber=0; jvmti->GetClassSignature(klass, &className, &generic); if (strcmp(className, CLASS_LOADER_CLASS_NAME) == 0) { - if (klass != NULL) { + if (klass != nullptr) { jmethodID method; cloader = klass; method = jni->GetMethodID(klass,METHOD_NAME,SIGNATURE); - if (method != NULL) { + if (method != nullptr) { jlocation start; jlocation end; jvmtiError err ; @@ -158,8 +158,8 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { nsk_printf(" Agent:: Error occured while setting event call back \n"); return JNI_ERR; } - nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_CLASS_LOAD, NULL); - nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_BREAKPOINT, NULL); + nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_CLASS_LOAD, nullptr); + nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_BREAKPOINT, nullptr); } return JNI_OK; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS301/hs301t001/hs301t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS301/hs301t001/hs301t001.cpp index c98c93e6702..d94ce73a3cf 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS301/hs301t001/hs301t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS301/hs301t001/hs301t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -84,7 +84,7 @@ Java_nsk_jvmti_scenarios_hotswap_HS301_hs301t001_hs301t001_redefine(JNIEnv * jni redefineNumber=0; cls = jni->FindClass(SEARCH_NAME); - if (!NSK_JNI_VERIFY(jni, cls != NULL)) { + if (!NSK_JNI_VERIFY(jni, cls != nullptr)) { nsk_printf("Agent:: (*JNI)->FindClass(jni, %s) returns `null`.\n",SEARCH_NAME); return NSK_FALSE; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS301/hs301t002/hs301t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS301/hs301t002/hs301t002.cpp index 3684e060946..6f84921286a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS301/hs301t002/hs301t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS301/hs301t002/hs301t002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -84,7 +84,7 @@ Java_nsk_jvmti_scenarios_hotswap_HS301_hs301t002_hs301t002_redefine(JNIEnv * jni redefineNumber=0; ret = JNI_FALSE; - if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(SEARCH_NAME)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(SEARCH_NAME)) != nullptr)) { nsk_printf("Agent:: (*JNI)->FindClass(jni, %s) returns `null`.\n", SEARCH_NAME); return NSK_FALSE; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS301/hs301t003/hs301t003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS301/hs301t003/hs301t003.cpp index a36ddd49fd2..076c885b622 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS301/hs301t003/hs301t003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS301/hs301t003/hs301t003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -45,7 +45,7 @@ void JNICALL callbackClassPrepare(jvmtiEnv *jvmti_env, nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName, sizeof(fileName)/sizeof(char)); nsk_jvmti_disableNotification(jvmti_env, - JVMTI_EVENT_CLASS_LOAD, NULL); + JVMTI_EVENT_CLASS_LOAD, nullptr); if (nsk_jvmti_redefineClass(jvmti_env, klass, fileName)) { nsk_printf("\n Redefine successful.\n"); } else { @@ -92,7 +92,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { nsk_printf(" Agent:: Error occured while setting event call back.\n"); return JNI_ERR; } - if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, NULL)) { + if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, nullptr)) { nsk_printf(" Agent:: Enabled notification.\n"); } else { nsk_printf(" Agent:: Failed to enable notification.\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS301/hs301t004/hs301t004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS301/hs301t004/hs301t004.cpp index 0a7ab069738..7c8c6af414c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS301/hs301t004/hs301t004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS301/hs301t004/hs301t004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ void JNICALL callbackClassPrepare(jvmtiEnv *jvmti_env, if (strcmp(className, CLASS_NAME) == 0) { int redefineNumber =0; char fileName[512]; - nsk_jvmti_disableNotification(jvmti_env, JVMTI_EVENT_CLASS_PREPARE, NULL); + nsk_jvmti_disableNotification(jvmti_env, JVMTI_EVENT_CLASS_PREPARE, nullptr); nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName, sizeof(fileName)/sizeof(char)); if (nsk_jvmti_redefineClass(jvmti_env, klass, fileName)) { @@ -93,7 +93,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { nsk_printf(" Agent:: Error occured while setting event call back \n"); return JNI_ERR; } - if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, NULL)) { + if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, nullptr)) { nsk_printf(" Enabled notification.\n"); } else { nsk_printf(" Failed to enable notifications.\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS301/hs301t005/hs301t005.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS301/hs301t005/hs301t005.cpp index a6bfbae8bd4..7a04fa7c333 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS301/hs301t005/hs301t005.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS301/hs301t005/hs301t005.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ void JNICALL callbackClassPrepare(jvmtiEnv *jvmti, if (strcmp(className,CLASS_NAME) == 0) { int redefineNumber =0; char fileName[512]; - nsk_jvmti_disableNotification(jvmti, JVMTI_EVENT_CLASS_LOAD, NULL); + nsk_jvmti_disableNotification(jvmti, JVMTI_EVENT_CLASS_LOAD, nullptr); nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName, sizeof(fileName)/sizeof(char)); if (nsk_jvmti_redefineClass(jvmti, klass, fileName)) { nsk_printf("\n Redefine successful ..\n"); @@ -88,7 +88,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { nsk_printf(" Agent:: Error occured while setting event call back \n"); return JNI_ERR; } - if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, NULL)) { + if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, nullptr)) { nsk_printf(" Enabled. noftification.."); } else { nsk_printf(" Failed to Enable .."); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t001/hs302t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t001/hs302t001.cpp index cd474e6a71d..883c197533b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t001/hs302t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t001/hs302t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ void JNICALL callbackClassPrepare(jvmtiEnv *jvmti_env, if (strcmp(className,CLASS_NAME) == 0) { char fileName[512]; nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName, sizeof(fileName)/sizeof(char)); - nsk_jvmti_disableNotification(jvmti_env, JVMTI_EVENT_CLASS_PREPARE, NULL); + nsk_jvmti_disableNotification(jvmti_env, JVMTI_EVENT_CLASS_PREPARE, nullptr); if (nsk_jvmti_redefineClass(jvmti_env, klass, fileName)) { nsk_printf("Redefine successful ..\n"); } else { @@ -88,7 +88,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { nsk_printf(" Agent:: Error occured while setting event call back \n"); return JNI_ERR; } - if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, NULL)) { + if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, nullptr)) { nsk_printf(" Enabled. noftification.."); } else { nsk_printf(" Failed to Enable .."); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t002/hs302t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t002/hs302t002.cpp index 14fa9aef071..9cd0e4006cc 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t002/hs302t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t002/hs302t002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ void JNICALL callbackClassPrepare(jvmtiEnv *jvmti_env, jvmti_env->GetClassSignature(klass, &className, &generic); if (strcmp(className,CLASS_NAME) == 0) { char fileName[512]; - nsk_jvmti_disableNotification(jvmti_env, JVMTI_EVENT_CLASS_PREPARE, NULL); + nsk_jvmti_disableNotification(jvmti_env, JVMTI_EVENT_CLASS_PREPARE, nullptr); nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName, sizeof(fileName)/sizeof(char)); if (nsk_jvmti_redefineClass(jvmti_env, klass, fileName)) { nsk_printf("Redefine successful ..\n"); @@ -94,7 +94,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { nsk_printf(" Agent:: Error occured while setting event call back \n"); return JNI_ERR; } - if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, NULL)) { + if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, nullptr)) { nsk_printf(" Enabled. noftification.."); } else { nsk_printf(" Failed to Enable .."); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t003/hs302t003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t003/hs302t003.cpp index 2625b7fcb4c..217a27bb5b5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t003/hs302t003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t003/hs302t003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 JNICALL callbackClassPrepare(jvmtiEnv *jvmti_env, char fileName[512]; nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName, sizeof(fileName)/sizeof(char)); - nsk_jvmti_disableNotification(jvmti_env, JVMTI_EVENT_CLASS_PREPARE, NULL); + nsk_jvmti_disableNotification(jvmti_env, JVMTI_EVENT_CLASS_PREPARE, nullptr); if (nsk_jvmti_redefineClass(jvmti_env, klass, fileName)) { nsk_printf("Redefine successful ..\n"); } else { @@ -93,7 +93,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { nsk_printf(" Agent:: Error occured while setting event call back \n"); return JNI_ERR; } - if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, NULL)) { + if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, nullptr)) { nsk_printf(" Enabled. noftification.."); } else { nsk_printf(" Failed to Enable .."); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t004/hs302t004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t004/hs302t004.cpp index 9c7d26fd543..5cf83fbd4a7 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t004/hs302t004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t004/hs302t004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ void JNICALL callbackClassPrepare(jvmtiEnv *jvmti_env, char fileName[512]; nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName, sizeof(fileName)/sizeof(char)); - nsk_jvmti_disableNotification(jvmti_env, JVMTI_EVENT_CLASS_PREPARE, NULL); + nsk_jvmti_disableNotification(jvmti_env, JVMTI_EVENT_CLASS_PREPARE, nullptr); if (nsk_jvmti_redefineClass(jvmti_env, klass,fileName)) { nsk_printf("Redefine successful ..\n"); } else { @@ -88,7 +88,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { nsk_printf(" Agent:: Error occured while setting event call back \n"); return JNI_ERR; } - if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, NULL)) { + if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, nullptr)) { nsk_printf(" Enabled. noftification.."); } else { nsk_printf(" Failed to Enable .."); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t005/hs302t005.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t005/hs302t005.cpp index ac0b3ca62e1..c6b9a3d0833 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t005/hs302t005.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t005/hs302t005.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ void JNICALL callbackClassPrepare(jvmtiEnv *jvmti_env, jvmti_env->GetClassSignature(klass, &className, &generic); if (strcmp(className,CLASS_NAME) == 0) { char fileName[512]; - nsk_jvmti_disableNotification(jvmti_env, JVMTI_EVENT_CLASS_PREPARE, NULL); + nsk_jvmti_disableNotification(jvmti_env, JVMTI_EVENT_CLASS_PREPARE, nullptr); nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName, sizeof(fileName)/sizeof(char)); if (nsk_jvmti_redefineClass(jvmti_env, klass,fileName)) { @@ -90,7 +90,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { nsk_printf(" Agent:: Error occured while setting event call back \n"); return JNI_ERR; } - if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, NULL)) { + if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, nullptr)) { nsk_printf(" Enabled. noftification.."); } else { nsk_printf(" Failed to Enable .."); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t006/hs302t006.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t006/hs302t006.cpp index 4e896c79c5b..ef5d37e6659 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t006/hs302t006.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t006/hs302t006.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ void JNICALL callbackClassPrepare(jvmtiEnv *jvmti_env, jvmti_env->GetClassSignature(klass, &className, &generic); if (strcmp(className,CLASS_NAME) == 0) { char fileName[512]; - nsk_jvmti_disableNotification(jvmti_env, JVMTI_EVENT_CLASS_PREPARE, NULL); + nsk_jvmti_disableNotification(jvmti_env, JVMTI_EVENT_CLASS_PREPARE, nullptr); nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName, sizeof(fileName)/sizeof(char)); if (nsk_jvmti_redefineClass(jvmti_env, klass, fileName)) { @@ -89,7 +89,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { nsk_printf(" Agent:: Error occured while setting event call back \n"); return JNI_ERR; } - if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, NULL)) { + if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, nullptr)) { nsk_printf(" Enabled. noftification.."); } else { nsk_printf(" Failed to Enable .."); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t007/hs302t007.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t007/hs302t007.cpp index f1dd8720697..81d83405929 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t007/hs302t007.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t007/hs302t007.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ void JNICALL callbackClassPrepare(jvmtiEnv *jvmti_env, jvmti_env->GetClassSignature(klass, &className, &generic); if (strcmp(className,CLASS_NAME) == 0) { char fileName[512]; - nsk_jvmti_disableNotification(jvmti_env, JVMTI_EVENT_CLASS_PREPARE, NULL); + nsk_jvmti_disableNotification(jvmti_env, JVMTI_EVENT_CLASS_PREPARE, nullptr); nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName, sizeof(fileName)/sizeof(char)); if (nsk_jvmti_redefineClass(jvmti_env, klass, fileName)) { @@ -86,7 +86,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { nsk_printf(" Agent:: Error occured while setting event call back \n"); return JNI_ERR; } - if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, NULL)) { + if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, nullptr)) { nsk_printf(" Enabled. noftification.."); } else { nsk_printf(" Failed to Enable .."); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t008/hs302t008.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t008/hs302t008.cpp index 1f11ca27d3b..54506880d09 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t008/hs302t008.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t008/hs302t008.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ void JNICALL callbackClassPrepare(jvmtiEnv *jvmti_env, jvmti_env->GetClassSignature(klass, &className, &generic); if (strcmp(className,CLASS_NAME) == 0) { char fileName[512]; - nsk_jvmti_disableNotification(jvmti_env, JVMTI_EVENT_CLASS_PREPARE, NULL); + nsk_jvmti_disableNotification(jvmti_env, JVMTI_EVENT_CLASS_PREPARE, nullptr); nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName, sizeof(fileName)/sizeof(char)); if (nsk_jvmti_redefineClass(jvmti_env, klass, fileName)) { @@ -89,7 +89,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { nsk_printf(" Agent:: Error occured while setting event call back \n"); return JNI_ERR; } - if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, NULL)) { + if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, nullptr)) { nsk_printf(" Enabled. noftification.."); } else { nsk_printf(" Failed to Enable .."); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t009/hs302t009.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t009/hs302t009.cpp index dbcf4290b22..95fce3ff410 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t009/hs302t009.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t009/hs302t009.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ void JNICALL callbackClassPrepare(jvmtiEnv *jvmti_env, if (strcmp(className,CLASS_NAME) == 0) { char fileName[512]; - nsk_jvmti_disableNotification(jvmti_env, JVMTI_EVENT_CLASS_PREPARE, NULL); + nsk_jvmti_disableNotification(jvmti_env, JVMTI_EVENT_CLASS_PREPARE, nullptr); nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName, sizeof(fileName)/sizeof(char)); if (nsk_jvmti_redefineClass(jvmti_env, klass,fileName)) { @@ -89,7 +89,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { nsk_printf(" Agent:: Error occured while setting event call back \n"); return JNI_ERR; } - if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, NULL)) { + if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, nullptr)) { nsk_printf(" Enabled. noftification.."); } else { nsk_printf(" Failed to Enable .."); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t010/hs302t010.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t010/hs302t010.cpp index fd15976ab42..0d8525c8f6e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t010/hs302t010.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t010/hs302t010.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ void JNICALL callbackClassPrepare(jvmtiEnv *jvmti_env, jvmti_env->GetClassSignature(klass, &className, &generic); if (strcmp(className,CLASS_NAME) == 0) { char fileName[512]; - nsk_jvmti_disableNotification(jvmti_env, JVMTI_EVENT_CLASS_PREPARE, NULL); + nsk_jvmti_disableNotification(jvmti_env, JVMTI_EVENT_CLASS_PREPARE, nullptr); nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName, sizeof(fileName)/sizeof(char)); if (nsk_jvmti_redefineClass(jvmti_env, klass, fileName)) { @@ -88,7 +88,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { nsk_printf(" Agent:: Error occured while setting event call back \n"); return JNI_ERR; } - if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, NULL)) { + if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, nullptr)) { nsk_printf(" Enabled. noftification.."); } else { nsk_printf(" Failed to Enable .."); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t011/hs302t011.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t011/hs302t011.cpp index eb9a17c1791..b48aae2a391 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t011/hs302t011.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t011/hs302t011.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ void JNICALL callbackClassPrepare(jvmtiEnv *jvmti_env, jvmti_env->GetClassSignature(klass, &className, &generic); if (strcmp(className,CLASS_NAME) == 0) { char fileName[512]; - nsk_jvmti_disableNotification(jvmti_env, JVMTI_EVENT_CLASS_PREPARE, NULL); + nsk_jvmti_disableNotification(jvmti_env, JVMTI_EVENT_CLASS_PREPARE, nullptr); nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName, sizeof(fileName)/sizeof(char)); if (nsk_jvmti_redefineClass(jvmti_env, klass, fileName)) { @@ -89,7 +89,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { nsk_printf(" Agent:: Error occured while setting event call back \n"); return JNI_ERR; } - if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, NULL)) { + if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, nullptr)) { nsk_printf(" Enabled. noftification.."); } else { nsk_printf(" Failed to Enable .."); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t012/hs302t012.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t012/hs302t012.cpp index 4324a18dc73..2bcc8da5020 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t012/hs302t012.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t012/hs302t012.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 JNICALL callbackClassPrepare(jvmtiEnv *jvmti_env, jvmti_env->GetClassSignature(klass, &className, &generic); if (strcmp(className,CLASS_NAME) == 0) { char fileName[512]; - nsk_jvmti_disableNotification(jvmti_env, JVMTI_EVENT_CLASS_PREPARE, NULL); + nsk_jvmti_disableNotification(jvmti_env, JVMTI_EVENT_CLASS_PREPARE, nullptr); nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName, sizeof(fileName)/sizeof(char)); if (nsk_jvmti_redefineClass(jvmti_env, klass, fileName)) { @@ -91,7 +91,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { nsk_printf(" Agent:: Error occured while setting event call back \n"); return JNI_ERR; } - if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, NULL)) { + if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, nullptr)) { nsk_printf(" Enabled. noftification.."); } else { nsk_printf(" Failed to Enable .."); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/jni_interception/JI01/ji01t001/ji01t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/jni_interception/JI01/ji01t001/ji01t001.cpp index d3d6ea40c8c..2c9f095737c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/jni_interception/JI01/ji01t001/ji01t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/jni_interception/JI01/ji01t001/ji01t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -40,36 +40,36 @@ extern "C" { static const char *classSig = "Lnsk/jvmti/scenarios/jni_interception/JI01/ji01t001;"; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jrawMonitorID eventLock; static jvmtiEventCallbacks callbacks; static jint result = NSK_STATUS_PASSED; // test thread -static jthread testThread = NULL; +static jthread testThread = nullptr; /* the original JNI function table */ -static jniNativeInterface *orig_jni_functions = NULL; +static jniNativeInterface *orig_jni_functions = nullptr; /* the redirected JNI function table */ -static jniNativeInterface *redir_jni_functions = NULL; +static jniNativeInterface *redir_jni_functions = nullptr; /* number of the redirected JNI function calls */ static volatile int fnd_calls = 0; void setTestThread(JNIEnv *env) { - jthread curThread = NULL; + jthread curThread = nullptr; NSK_JVMTI_VERIFY(jvmti->GetCurrentThread(&curThread)); testThread = env->NewGlobalRef(curThread); } void resetTestThread(JNIEnv *env) { env->DeleteGlobalRef(testThread); - testThread = NULL; + testThread = nullptr; } bool isOnTestThread(JNIEnv *env) { - jthread curThread = NULL; + jthread curThread = nullptr; NSK_JVMTI_VERIFY(jvmti->GetCurrentThread(&curThread)); return env->IsSameObject(testThread, curThread); } @@ -329,7 +329,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; - if (!NSK_VERIFY(jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1) == JNI_OK && jvmti != NULL)) + if (!NSK_VERIFY(jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1) == JNI_OK && jvmti != nullptr)) return JNI_ERR; @@ -354,11 +354,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { NSK_DISPLAY0("Event callbacks are set\nEnabling events...\n"); - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, nullptr))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, nullptr))) return JNI_ERR; NSK_DISPLAY0("Events are enabled\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/jni_interception/JI03/ji03t001/ji03t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/jni_interception/JI03/ji03t001/ji03t001.cpp index 1d452892f2c..f55c48c218f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/jni_interception/JI03/ji03t001/ji03t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/jni_interception/JI03/ji03t001/ji03t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -35,15 +35,15 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static int verbose = 0; /* the original JNI function table */ -static jniNativeInterface *orig_jni_functions = NULL; +static jniNativeInterface *orig_jni_functions = nullptr; /* the redirected JNI function table */ -static jniNativeInterface *redir_jni_functions = NULL; +static jniNativeInterface *redir_jni_functions = nullptr; /* number of the redirected JNI function calls */ int call_count = 0; @@ -115,7 +115,7 @@ JNIEXPORT jint JNICALL Java_nsk_jvmti_scenarios_jni_1interception_JI03_ji03t001_check(JNIEnv *env, jclass cls) { jint ver; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("(%s,%d): TEST FAILURE: JVMTI client was not properly loaded\n", __FILE__, __LINE__); return STATUS_FAILED; @@ -183,14 +183,14 @@ JNIEXPORT jint JNI_OnLoad_ji03t001(JavaVM *jvm, char *options, void *reserved) { jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "-verbose") == 0) + if (options != nullptr && strcmp(options, "-verbose") == 0) verbose = 1; if (verbose) printf("verbose mode on\n"); res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("(%s,%d): Failed to call GetEnv\n", __FILE__, __LINE__); return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/jni_interception/JI03/ji03t002/ji03t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/jni_interception/JI03/ji03t002/ji03t002.cpp index 0ed3d60a31e..e7350dac3af 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/jni_interception/JI03/ji03t002/ji03t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/jni_interception/JI03/ji03t002/ji03t002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static int verbose = 0; @@ -53,15 +53,15 @@ typedef struct { /* line numbers of a method */ } methInfo; static methInfo meth_info[] = { - { 0, "statMeth", "(I)D", NULL, "statMeth_calls", NULL, 0, 0 }, - { 1, "voidMeth", "()V", NULL, "voidMeth_calls", NULL, 0, 0 } + { 0, "statMeth", "(I)D", nullptr, "statMeth_calls", nullptr, 0, 0 }, + { 1, "voidMeth", "()V", nullptr, "voidMeth_calls", nullptr, 0, 0 } }; /* the original JNI function table */ -static jniNativeInterface *orig_jni_functions = NULL; +static jniNativeInterface *orig_jni_functions = nullptr; /* the redirected JNI function table */ -static jniNativeInterface *redir_jni_functions = NULL; +static jniNativeInterface *redir_jni_functions = nullptr; /** redirected JNI functions **/ jdouble JNICALL MyCallStaticDoubleMethodV(JNIEnv *env, jclass cls, jmethodID mid, va_list args) { @@ -127,7 +127,7 @@ void doRedirect(JNIEnv *env, jclass cls) { meth_info[i].mid = env->GetStaticMethodID( cls, meth_info[i].m_name, meth_info[i].m_sign); } - if (meth_info[i].mid == NULL) { + if (meth_info[i].mid == nullptr) { result = STATUS_FAILED; printf("(%s,%d): TEST FAILURE: failed to get the ID for the method \"%s %s\"\n", __FILE__, __LINE__, meth_info[i].m_name, meth_info[i].m_sign); @@ -270,7 +270,7 @@ JNIEXPORT jint JNICALL Java_nsk_jvmti_scenarios_jni_1interception_JI03_ji03t002_check(JNIEnv *env, jobject obj) { jclass objCls; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("(%s,%d): TEST FAILURE: JVMTI client was not properly loaded\n", __FILE__, __LINE__); return STATUS_FAILED; @@ -309,14 +309,14 @@ JNIEXPORT jint JNI_OnLoad_ji03t002(JavaVM *jvm, char *options, void *reserved) { jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "-verbose") == 0) + if (options != nullptr && strcmp(options, "-verbose") == 0) verbose = 1; if (verbose) printf("verbose mode on\n"); res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("(%s,%d): Failed to call GetEnv\n", __FILE__, __LINE__); return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/jni_interception/JI03/ji03t003/ji03t003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/jni_interception/JI03/ji03t003/ji03t003.cpp index 4bb4e45fb07..9b6f70525ea 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/jni_interception/JI03/ji03t003/ji03t003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/jni_interception/JI03/ji03t003/ji03t003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,21 +36,21 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static int verbose = 0; // test thread -static jthread testThread = NULL; +static jthread testThread = nullptr; static const char *javaField = "exc"; static const char *excClassSig = "Lnsk/jvmti/scenarios/jni_interception/JI03/ji03t003Exc;"; /* the original JNI function table */ -static jniNativeInterface *orig_jni_functions = NULL; +static jniNativeInterface *orig_jni_functions = nullptr; /* the redirected JNI function table */ -static jniNativeInterface *redir_jni_functions = NULL; +static jniNativeInterface *redir_jni_functions = nullptr; /* number of the redirected JNI function calls */ int throw_calls = 0; @@ -58,18 +58,18 @@ int thrownew_calls = 0; int excoccur_calls = 0; void setTestThread(JNIEnv *env) { - jthread curThread = NULL; + jthread curThread = nullptr; NSK_JVMTI_VERIFY(jvmti->GetCurrentThread(&curThread)); testThread = env->NewGlobalRef(curThread); } void resetTestThread(JNIEnv *env) { env->DeleteGlobalRef(testThread); - testThread = NULL; + testThread = nullptr; } bool isOnTestThread(JNIEnv *env) { - jthread curThread = NULL; + jthread curThread = nullptr; NSK_JVMTI_VERIFY(jvmti->GetCurrentThread(&curThread)); return env->IsSameObject(testThread, curThread); } @@ -290,7 +290,7 @@ Java_nsk_jvmti_scenarios_jni_1interception_JI03_ji03t003_check(JNIEnv *env, jobj jclass thrw; jclass objCls; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("(%s,%d): TEST FAILURE: JVMTI client was not properly loaded\n", __FILE__, __LINE__); return STATUS_FAILED; @@ -357,14 +357,14 @@ JNIEXPORT jint JNI_OnLoad_ji03t003(JavaVM *jvm, char *options, void *reserved) { jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "-verbose") == 0) + if (options != nullptr && strcmp(options, "-verbose") == 0) verbose = 1; if (verbose) printf("verbose mode on\n"); res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("(%s,%d): Failed to call GetEnv\n", __FILE__, __LINE__); return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/jni_interception/JI03/ji03t004/ji03t004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/jni_interception/JI03/ji03t004/ji03t004.cpp index ffbe992669e..d25d2c9fcc1 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/jni_interception/JI03/ji03t004/ji03t004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/jni_interception/JI03/ji03t004/ji03t004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static int verbose = 0; @@ -44,10 +44,10 @@ static const char *classSig = "Lnsk/jvmti/scenarios/jni_interception/JI03/ji03t004a;"; /* the original JNI function table */ -static jniNativeInterface *orig_jni_functions = NULL; +static jniNativeInterface *orig_jni_functions = nullptr; /* the redirected JNI function table */ -static jniNativeInterface *redir_jni_functions = NULL; +static jniNativeInterface *redir_jni_functions = nullptr; /* number of the redirected JNI function calls */ int allobj_calls = 0; @@ -134,7 +134,7 @@ void doExec(JNIEnv *env, jclass allCls, jmethodID ctorId, const char *msg, ...) va_list args; va_start(args, msg); allObj = env->AllocObject(allCls); - if (allObj == NULL) { + if (allObj == nullptr) { result = STATUS_FAILED; printf("(%s,%d): TEST FAILED: failed to call %s AllocObject()\n", __FILE__, __LINE__, msg); @@ -150,7 +150,7 @@ void doExec(JNIEnv *env, jclass allCls, jmethodID ctorId, const char *msg, ...) } newObj = env->NewObjectV(allCls, ctorId, args); - if (newObj == NULL) { + if (newObj == nullptr) { result = STATUS_FAILED; printf("(%s,%d): TEST FAILED: failed to call %s NewObjectV()\n", __FILE__, __LINE__, msg); @@ -208,21 +208,21 @@ Java_nsk_jvmti_scenarios_jni_1interception_JI03_ji03t004_check(JNIEnv *env, jobj jmethodID ctorId; jclass objCls; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("(%s,%d): TEST FAILURE: JVMTI client was not properly loaded\n", __FILE__, __LINE__); return STATUS_FAILED; } objCls = env->FindClass(classSig); - if (objCls == NULL) { + if (objCls == nullptr) { printf("(%s,%d): TEST FAILED: failed to call FindClass() for \"%s\"\n", __FILE__, __LINE__, classSig); return STATUS_FAILED; } ctorId = env->GetMethodID(objCls, "", "()V"); - if (ctorId == NULL) { + if (ctorId == nullptr) { printf("(%s,%d): TEST FAILED: failed to call GetMethodID() for a constructor\n", __FILE__, __LINE__); return STATUS_FAILED; @@ -259,14 +259,14 @@ JNIEXPORT jint JNI_OnLoad_ji03t004(JavaVM *jvm, char *options, void *reserved) { jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "-verbose") == 0) + if (options != nullptr && strcmp(options, "-verbose") == 0) verbose = 1; if (verbose) printf("verbose mode on\n"); res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("(%s,%d): Failed to call GetEnv\n", __FILE__, __LINE__); return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/jni_interception/JI05/ji05t001/ji05t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/jni_interception/JI05/ji05t001/ji05t001.cpp index a38d73ba821..3db35166c6c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/jni_interception/JI05/ji05t001/ji05t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/jni_interception/JI05/ji05t001/ji05t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -179,7 +179,7 @@ static int initAgent(int indx) { NSK_DISPLAY1("\nagent %s initializer: obtaining the JVMTI env ...\n", (indx == 0) ? "A" : "B"); res = vm->GetEnv((void **) &jvmti[indx], JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti[indx] == NULL) { + if (res != JNI_OK || jvmti[indx] == nullptr) { NSK_COMPLAIN1("TEST FAILURE: failed to call GetEnv for the agent %s\n", (indx == 0) ? "A" : "B"); result = STATUS_FAILED; @@ -207,7 +207,7 @@ static int initAgent(int indx) { NSK_DISPLAY1("\nagent %s initializer: setting event callbacks done\n\tenabling events ...\n", (indx == 0) ? "A" : "B"); - err = jvmti[indx]->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL); + err = jvmti[indx]->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, nullptr); if (err != JVMTI_ERROR_NONE) { /* enable event globally */ NSK_COMPLAIN2("TEST FAILURE: failed to enable JVMTI_EVENT_VM_INIT event for the agent %s: %s\n", (indx == 0) ? "A" : "B", TranslateError(err)); @@ -227,7 +227,7 @@ static void startAgent(int indx) { (indx == 0) ? "A" : "B"); void* context = (void*) ((indx == 0) ? "agent A" : "agent B"); agentThr[indx] = THREAD_new((indx == 0) ? agentA : agentB, context); - if (THREAD_start(agentThr[indx]) == NULL) { + if (THREAD_start(agentThr[indx]) == nullptr) { NSK_COMPLAIN1("TEST FAILURE: cannot start the agent %s thread\n", (indx == 0) ? "A" : "B"); exit(STATUS_FAILED); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/jni_interception/JI06/ji06t001/ji06t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/jni_interception/JI06/ji06t001/ji06t001.cpp index d5dfc829d1b..3a2e82c3d3a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/jni_interception/JI06/ji06t001/ji06t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/jni_interception/JI06/ji06t001/ji06t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -59,7 +59,7 @@ static const char *classSig = "Lnsk/jvmti/scenarios/jni_interception/JI06/ji06t001a;"; static JavaVM *vm; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static volatile int verbose = 0; @@ -72,10 +72,10 @@ static volatile jobject clsObj; static jrawMonitorID countLock; /* the original JNI function table */ -static jniNativeInterface *orig_jni_functions = NULL; +static jniNativeInterface *orig_jni_functions = nullptr; /* the redirected JNI function table */ -static jniNativeInterface *redir_jni_functions = NULL; +static jniNativeInterface *redir_jni_functions = nullptr; /* number of the redirected JNI function calls */ static volatile int monent_calls = 0; @@ -315,21 +315,21 @@ Java_nsk_jvmti_scenarios_jni_1interception_JI06_ji06t001_check(JNIEnv *env, jobj char *ownContext = (char*) "ownerThr"; char *redirContext = (char*) "redirectorThr"; int exitCode = PASSED; - void *ownThr = NULL; - void *redirThr = NULL; + void *ownThr = nullptr; + void *redirThr = nullptr; void *waitThr[MAX_THREADS]; int waitContElem[MAX_THREADS]; /* context of a particular waiting thread */ int i; int tries = 0; - if (jvmti == NULL) { + if (jvmti == nullptr) { NSK_COMPLAIN0("TEST FAILURE: JVMTI client was not properly loaded\n"); return STATUS_FAILED; } /* prepare the testing */ clsObj = env->NewGlobalRef(getObjectFromField(env, obj)); - if (clsObj == NULL) { + if (clsObj == nullptr) { NSK_COMPLAIN1("TEST FAILURE: cannot create a new global reference of class \"%s\"\n", classSig); env->FatalError("failed to create a new global reference"); @@ -337,7 +337,7 @@ Java_nsk_jvmti_scenarios_jni_1interception_JI06_ji06t001_check(JNIEnv *env, jobj NSK_DISPLAY0("starting monitor owner thread ...\n"); ownThr = THREAD_new(ownerThread, ownContext); - if (THREAD_start(ownThr) == NULL) { + if (THREAD_start(ownThr) == nullptr) { NSK_COMPLAIN0("TEST FAILURE: cannot start monitor owner thread\n"); exit(STATUS_FAILED); } @@ -360,7 +360,7 @@ Java_nsk_jvmti_scenarios_jni_1interception_JI06_ji06t001_check(JNIEnv *env, jobj waitContElem[i] = i+1; /* 4932877 fix in accordance with ANSI C: thread context of type int -> int* -> void* */ waitThr[i] = THREAD_new(waitingThread, (void *) &(waitContElem[i])); - if (THREAD_start(waitThr[i]) == NULL) { + if (THREAD_start(waitThr[i]) == nullptr) { NSK_COMPLAIN1("TEST FAILURE: cannot start waiting thread #%d\n", i+1); exit(STATUS_FAILED); @@ -384,7 +384,7 @@ Java_nsk_jvmti_scenarios_jni_1interception_JI06_ji06t001_check(JNIEnv *env, jobj NSK_DISPLAY0(">>> TEST CASE a) Trying to redirect the JNI function ...\n\n" "starting redirector thread ...\n"); redirThr = THREAD_new(redirectorThread, redirContext); - if (THREAD_start(redirThr) == NULL) { + if (THREAD_start(redirThr) == nullptr) { NSK_COMPLAIN0("TEST FAILURE: cannot start redirector thread\n"); exit(STATUS_FAILED); } @@ -431,7 +431,7 @@ Java_nsk_jvmti_scenarios_jni_1interception_JI06_ji06t001_check(JNIEnv *env, jobj /* 4932877 fix in accordance with ANSI C: thread context of type int -> int* -> void* */ waitThr[MAX_THREADS-1] = THREAD_new(waitingThread, (void *) &(waitContElem[MAX_THREADS-1])); - if (THREAD_start(waitThr[MAX_THREADS-1]) == NULL) { + if (THREAD_start(waitThr[MAX_THREADS-1]) == nullptr) { NSK_COMPLAIN0("TEST FAILURE: cannot start verification thread\n"); exit(STATUS_FAILED); } @@ -482,7 +482,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; vm = jvm; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA01/ma01t001/ma01t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA01/ma01t001/ma01t001.cpp index 56bf54b2a94..f0771daa56a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA01/ma01t001/ma01t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA01/ma01t001/ma01t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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,9 +69,9 @@ JNIEXPORT jint JNI_OnLoad_ma01t001(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiEventCallbacks callbacks; - const char* name = NULL; + const char* name = nullptr; int found = NSK_FALSE; int i, count; @@ -97,10 +97,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&callbacks, 0, sizeof(callbacks)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA01/ma01t001/ma01t001a.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA01/ma01t001/ma01t001a.cpp index 800aebecd87..959a26465e5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA01/ma01t001/ma01t001a.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA01/ma01t001/ma01t001a.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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,9 +69,9 @@ JNIEXPORT jint JNI_OnLoad_ma01t001a(JavaVM *jvm, char *options, void *reserved) } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiEventCallbacks callbacks; - const char* name = NULL; + const char* name = nullptr; int found = NSK_FALSE; int i, count; @@ -97,10 +97,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&callbacks, 0, sizeof(callbacks)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA02/ma02t001/ma02t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA02/ma02t001/ma02t001.cpp index 464a8186b51..0d7a1f5fe1a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA02/ma02t001/ma02t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA02/ma02t001/ma02t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ JNIEXPORT jint JNI_OnLoad_ma02t001(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiEventCallbacks callbacks; NSK_DISPLAY0("Agent_OnLoad\n"); @@ -102,10 +102,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&callbacks, 0, sizeof(callbacks)); @@ -114,10 +114,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!NSK_VERIFY(nsk_jvmti_init_MA(&callbacks))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, nullptr))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA02/ma02t001/ma02t001a.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA02/ma02t001/ma02t001a.cpp index 2d850db5d8c..77e0ff05f50 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA02/ma02t001/ma02t001a.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA02/ma02t001/ma02t001a.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ JNIEXPORT jint JNI_OnLoad_ma02t001a(JavaVM *jvm, char *options, void *reserved) } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiEventCallbacks callbacks; NSK_DISPLAY0("Agent_OnLoad\n"); @@ -102,10 +102,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&callbacks, 0, sizeof(callbacks)); @@ -114,10 +114,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!NSK_VERIFY(nsk_jvmti_init_MA(&callbacks))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, nullptr))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA03/ma03t001/ma03t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA03/ma03t001/ma03t001.cpp index cb10b246b30..6b1d29f4991 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA03/ma03t001/ma03t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA03/ma03t001/ma03t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -102,7 +102,7 @@ JNIEXPORT jint JNI_OnLoad_ma03t001(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiEventCallbacks callbacks; NSK_DISPLAY0("Agent_OnLoad\n"); @@ -113,10 +113,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&callbacks, 0, sizeof(callbacks)); @@ -126,13 +126,13 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!NSK_VERIFY(nsk_jvmti_init_MA(&callbacks))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, nullptr))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, nullptr))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA03/ma03t001/ma03t001a.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA03/ma03t001/ma03t001a.cpp index ec744e3bdde..38fa0bb8e1f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA03/ma03t001/ma03t001a.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA03/ma03t001/ma03t001a.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -103,7 +103,7 @@ JNIEXPORT jint JNI_OnLoad_ma03t001a(JavaVM *jvm, char *options, void *reserved) } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiEventCallbacks callbacks; NSK_DISPLAY0("Agent_OnLoad\n"); @@ -114,10 +114,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&callbacks, 0, sizeof(callbacks)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA04/ma04t001/ma04t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA04/ma04t001/ma04t001.cpp index 937daddbd39..a3f28659bae 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA04/ma04t001/ma04t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA04/ma04t001/ma04t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ extern "C" { static jlong timeout = 0; /* test objects */ -static jobject testedObject = NULL; +static jobject testedObject = nullptr; /* ========================================================================== */ @@ -47,24 +47,24 @@ static int prepare(JNIEnv* jni) { const char* CLASS_NAME = "nsk/jvmti/scenarios/multienv/MA04/ma04t001"; const char* FIELD_NAME = "testedObject"; const char* FIELD_SIGNATURE = "Ljava/lang/Object;"; - jclass cls = NULL; - jfieldID fid = NULL; + jclass cls = nullptr; + jfieldID fid = nullptr; NSK_DISPLAY0("Obtain tested object from a static field of debugee class\n"); NSK_DISPLAY1("Find class: %s\n", CLASS_NAME); - if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(CLASS_NAME)) != nullptr)) return NSK_FALSE; NSK_DISPLAY2("Find field: %s:%s\n", FIELD_NAME, FIELD_SIGNATURE); if (!NSK_JNI_VERIFY(jni, (fid = - jni->GetStaticFieldID(cls, FIELD_NAME, FIELD_SIGNATURE)) != NULL)) + jni->GetStaticFieldID(cls, FIELD_NAME, FIELD_SIGNATURE)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (testedObject = jni->GetStaticObjectField(cls, fid)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (testedObject = jni->GetStaticObjectField(cls, fid)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (testedObject = jni->NewGlobalRef(testedObject)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (testedObject = jni->NewGlobalRef(testedObject)) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -200,7 +200,7 @@ JNIEXPORT jint JNI_OnLoad_ma04t001(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiEventCallbacks callbacks; jvmtiCapabilities caps; @@ -212,7 +212,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; memset(&caps, 0, sizeof(caps)); @@ -221,7 +221,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&callbacks, 0, sizeof(callbacks)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA04/ma04t001/ma04t001a.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA04/ma04t001/ma04t001a.cpp index cbc5bc9054f..1f07af5da4e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA04/ma04t001/ma04t001a.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA04/ma04t001/ma04t001a.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ extern "C" { static jlong timeout = 0; /* test objects */ -static jobject testedObject = NULL; +static jobject testedObject = nullptr; /* ========================================================================== */ @@ -47,24 +47,24 @@ static int prepare(JNIEnv* jni) { const char* CLASS_NAME = "nsk/jvmti/scenarios/multienv/MA04/ma04t001"; const char* FIELD_NAME = "testedObject"; const char* FIELD_SIGNATURE = "Ljava/lang/Object;"; - jclass cls = NULL; - jfieldID fid = NULL; + jclass cls = nullptr; + jfieldID fid = nullptr; NSK_DISPLAY0("Obtain tested object from a static field of debugee class\n"); NSK_DISPLAY1("Find class: %s\n", CLASS_NAME); - if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(CLASS_NAME)) != nullptr)) return NSK_FALSE; NSK_DISPLAY2("Find field: %s:%s\n", FIELD_NAME, FIELD_SIGNATURE); if (!NSK_JNI_VERIFY(jni, (fid = - jni->GetStaticFieldID(cls, FIELD_NAME, FIELD_SIGNATURE)) != NULL)) + jni->GetStaticFieldID(cls, FIELD_NAME, FIELD_SIGNATURE)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (testedObject = jni->GetStaticObjectField(cls, fid)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (testedObject = jni->GetStaticObjectField(cls, fid)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (testedObject = jni->NewGlobalRef(testedObject)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (testedObject = jni->NewGlobalRef(testedObject)) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -200,7 +200,7 @@ JNIEXPORT jint JNI_OnLoad_ma04t001a(JavaVM *jvm, char *options, void *reserved) } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiEventCallbacks callbacks; jvmtiCapabilities caps; @@ -212,7 +212,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; memset(&caps, 0, sizeof(caps)); @@ -221,7 +221,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&callbacks, 0, sizeof(callbacks)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA04/ma04t002/ma04t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA04/ma04t002/ma04t002.cpp index 2091ef57ca6..c4bff40748c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA04/ma04t002/ma04t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA04/ma04t002/ma04t002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,9 +39,9 @@ extern "C" { static jlong timeout = 0; /* test objects */ -static jobject testedObject = NULL; -static jobject testedInstance = NULL; -static jclass testedClass = NULL; +static jobject testedObject = nullptr; +static jobject testedInstance = nullptr; +static jclass testedClass = nullptr; static int ObjectsCount = 0; /* ========================================================================== */ @@ -76,33 +76,33 @@ static int prepare(JNIEnv* jni) { const char* FIELD_SIGNATURE = "Ljava/lang/Object;"; const char* INSTANCE_NAME = "testedInstance1"; const char* INSTANCE_SIGNATURE = "Lnsk/jvmti/scenarios/multienv/MA04/ma04t002;"; - jfieldID fid = NULL; + jfieldID fid = nullptr; NSK_DISPLAY0("Obtain tested object from a static field of debugee class\n"); NSK_DISPLAY1("Find class: %s\n", CLASS_NAME); - if (!NSK_JNI_VERIFY(jni, (testedClass = jni->FindClass(CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (testedClass = jni->FindClass(CLASS_NAME)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (testedClass = (jclass) jni->NewGlobalRef(testedClass)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (testedClass = (jclass) jni->NewGlobalRef(testedClass)) != nullptr)) return NSK_FALSE; NSK_DISPLAY2("Find field: %s:%s\n", FIELD_NAME, FIELD_SIGNATURE); if (!NSK_JNI_VERIFY(jni, (fid = - jni->GetStaticFieldID(testedClass, FIELD_NAME, FIELD_SIGNATURE)) != NULL)) + jni->GetStaticFieldID(testedClass, FIELD_NAME, FIELD_SIGNATURE)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (testedObject = jni->GetStaticObjectField(testedClass, fid)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (testedObject = jni->GetStaticObjectField(testedClass, fid)) != nullptr)) return NSK_FALSE; NSK_DISPLAY2("Find class instance: %s:%s\n", INSTANCE_NAME, INSTANCE_SIGNATURE); if (!NSK_JNI_VERIFY(jni, (fid = - jni->GetStaticFieldID(testedClass, INSTANCE_NAME, INSTANCE_SIGNATURE)) != NULL)) + jni->GetStaticFieldID(testedClass, INSTANCE_NAME, INSTANCE_SIGNATURE)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (testedInstance = - jni->GetStaticObjectField(testedClass, fid)) != NULL)) + jni->GetStaticObjectField(testedClass, fid)) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -305,7 +305,7 @@ JNIEXPORT jint JNI_OnLoad_ma04t002(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiEventCallbacks callbacks; jvmtiCapabilities caps; @@ -317,7 +317,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; memset(&caps, 0, sizeof(caps)); @@ -327,14 +327,14 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&callbacks, 0, sizeof(callbacks)); if (!NSK_VERIFY(nsk_jvmti_init_MA(&callbacks))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_OBJECT_FREE, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_OBJECT_FREE, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA04/ma04t002/ma04t002a.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA04/ma04t002/ma04t002a.cpp index cd639c1fd78..0834d306a1c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA04/ma04t002/ma04t002a.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA04/ma04t002/ma04t002a.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,9 +39,9 @@ extern "C" { static jlong timeout = 0; /* test objects */ -static jobject testedObject = NULL; -static jobject testedInstance = NULL; -static jclass testedClass = NULL; +static jobject testedObject = nullptr; +static jobject testedInstance = nullptr; +static jclass testedClass = nullptr; static int ObjectsCount = 0; /* ========================================================================== */ @@ -76,33 +76,33 @@ static int prepare(JNIEnv* jni) { const char* FIELD_SIGNATURE = "Ljava/lang/Object;"; const char* INSTANCE_NAME = "testedInstance2"; const char* INSTANCE_SIGNATURE = "Lnsk/jvmti/scenarios/multienv/MA04/ma04t002;"; - jfieldID fid = NULL; + jfieldID fid = nullptr; NSK_DISPLAY0("Obtain tested object from a static field of debugee class\n"); NSK_DISPLAY1("Find class: %s\n", CLASS_NAME); - if (!NSK_JNI_VERIFY(jni, (testedClass = jni->FindClass(CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (testedClass = jni->FindClass(CLASS_NAME)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (testedClass = (jclass) jni->NewGlobalRef(testedClass)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (testedClass = (jclass) jni->NewGlobalRef(testedClass)) != nullptr)) return NSK_FALSE; NSK_DISPLAY2("Find field: %s:%s\n", FIELD_NAME, FIELD_SIGNATURE); if (!NSK_JNI_VERIFY(jni, (fid = - jni->GetStaticFieldID(testedClass, FIELD_NAME, FIELD_SIGNATURE)) != NULL)) + jni->GetStaticFieldID(testedClass, FIELD_NAME, FIELD_SIGNATURE)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (testedObject = jni->GetStaticObjectField(testedClass, fid)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (testedObject = jni->GetStaticObjectField(testedClass, fid)) != nullptr)) return NSK_FALSE; NSK_DISPLAY2("Find class instance: %s:%s\n", INSTANCE_NAME, INSTANCE_SIGNATURE); if (!NSK_JNI_VERIFY(jni, (fid = - jni->GetStaticFieldID(testedClass, INSTANCE_NAME, INSTANCE_SIGNATURE)) != NULL)) + jni->GetStaticFieldID(testedClass, INSTANCE_NAME, INSTANCE_SIGNATURE)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (testedInstance = - jni->GetStaticObjectField(testedClass, fid)) != NULL)) + jni->GetStaticObjectField(testedClass, fid)) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -303,7 +303,7 @@ JNIEXPORT jint JNI_OnLoad_ma04t002a(JavaVM *jvm, char *options, void *reserved) } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiEventCallbacks callbacks; jvmtiCapabilities caps; @@ -315,7 +315,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; memset(&caps, 0, sizeof(caps)); @@ -325,14 +325,14 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&callbacks, 0, sizeof(callbacks)); if (!NSK_VERIFY(nsk_jvmti_init_MA(&callbacks))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_OBJECT_FREE, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_OBJECT_FREE, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA04/ma04t003/ma04t003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA04/ma04t003/ma04t003.cpp index af2922e055b..d6eb01b18b8 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA04/ma04t003/ma04t003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA04/ma04t003/ma04t003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ extern "C" { static jlong timeout = 0; /* test objects */ -static jobject testedObject = NULL; +static jobject testedObject = nullptr; static int ObjectFreeEventsCount = 0; /* ========================================================================== */ @@ -82,24 +82,24 @@ static int prepare(JNIEnv* jni) { const char* CLASS_NAME = "nsk/jvmti/scenarios/multienv/MA04/ma04t003"; const char* FIELD_NAME = "testedObject1"; const char* FIELD_SIGNATURE = "Ljava/lang/Object;"; - jclass cls = NULL; - jfieldID fid = NULL; + jclass cls = nullptr; + jfieldID fid = nullptr; NSK_DISPLAY0("Obtain tested object from a static field of debugee class\n"); NSK_DISPLAY1("Find class: %s\n", CLASS_NAME); - if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(CLASS_NAME)) != nullptr)) return NSK_FALSE; NSK_DISPLAY2("Find field: %s:%s\n", FIELD_NAME, FIELD_SIGNATURE); if (!NSK_JNI_VERIFY(jni, (fid = - jni->GetStaticFieldID(cls, FIELD_NAME, FIELD_SIGNATURE)) != NULL)) + jni->GetStaticFieldID(cls, FIELD_NAME, FIELD_SIGNATURE)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (testedObject = jni->GetStaticObjectField(cls, fid)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (testedObject = jni->GetStaticObjectField(cls, fid)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (testedObject = jni->NewGlobalRef(testedObject)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (testedObject = jni->NewGlobalRef(testedObject)) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -146,7 +146,7 @@ JNIEXPORT jint JNI_OnLoad_ma04t003(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiEventCallbacks callbacks; jvmtiCapabilities caps; @@ -158,7 +158,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; memset(&caps, 0, sizeof(caps)); @@ -168,7 +168,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&callbacks, 0, sizeof(callbacks)); @@ -177,10 +177,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!NSK_VERIFY(nsk_jvmti_init_MA(&callbacks))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_OBJECT_FREE, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_OBJECT_FREE, nullptr))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA04/ma04t003/ma04t003a.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA04/ma04t003/ma04t003a.cpp index 3df2bf2c0b9..5a42cd21e95 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA04/ma04t003/ma04t003a.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA04/ma04t003/ma04t003a.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ extern "C" { static jlong timeout = 0; /* test objects */ -static jobject testedObject = NULL; +static jobject testedObject = nullptr; static int ObjectFreeEventsCount = 0; /* ========================================================================== */ @@ -82,24 +82,24 @@ static int prepare(JNIEnv* jni) { const char* CLASS_NAME = "nsk/jvmti/scenarios/multienv/MA04/ma04t003"; const char* FIELD_NAME = "testedObject2"; const char* FIELD_SIGNATURE = "Ljava/lang/Object;"; - jclass cls = NULL; - jfieldID fid = NULL; + jclass cls = nullptr; + jfieldID fid = nullptr; NSK_DISPLAY0("Obtain tested object from a static field of debugee class\n"); NSK_DISPLAY1("Find class: %s\n", CLASS_NAME); - if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(CLASS_NAME)) != nullptr)) return NSK_FALSE; NSK_DISPLAY2("Find field: %s:%s\n", FIELD_NAME, FIELD_SIGNATURE); if (!NSK_JNI_VERIFY(jni, (fid = - jni->GetStaticFieldID(cls, FIELD_NAME, FIELD_SIGNATURE)) != NULL)) + jni->GetStaticFieldID(cls, FIELD_NAME, FIELD_SIGNATURE)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (testedObject = jni->GetStaticObjectField(cls, fid)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (testedObject = jni->GetStaticObjectField(cls, fid)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (testedObject = jni->NewGlobalRef(testedObject)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (testedObject = jni->NewGlobalRef(testedObject)) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -146,7 +146,7 @@ JNIEXPORT jint JNI_OnLoad_ma04t003a(JavaVM *jvm, char *options, void *reserved) } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiEventCallbacks callbacks; jvmtiCapabilities caps; @@ -158,7 +158,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; memset(&caps, 0, sizeof(caps)); @@ -168,7 +168,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&callbacks, 0, sizeof(callbacks)); @@ -177,10 +177,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!NSK_VERIFY(nsk_jvmti_init_MA(&callbacks))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_OBJECT_FREE, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_OBJECT_FREE, nullptr))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA05/ma05t001/ma05t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA05/ma05t001/ma05t001.cpp index 6c07c02a5d1..c57c7cebb4d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA05/ma05t001/ma05t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA05/ma05t001/ma05t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,8 +38,8 @@ extern "C" { static jlong timeout = 0; /* test objects */ -static jthread thread = NULL; -static jmethodID method = NULL; +static jthread thread = nullptr; +static jmethodID method = nullptr; static int BreakpointEventsCount = 0; static int FramePopEventsCount = 0; @@ -50,19 +50,19 @@ static int FramePopEventsCount = 0; static void JNICALL Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method, jlocation location) { - char *name = NULL; - char *signature = NULL; + char *name = nullptr; + char *signature = nullptr; BreakpointEventsCount++; - if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, nullptr))) { nsk_jvmti_setFailStatus(); } NSK_DISPLAY2("Breakpoint event: %s%s\n", name, signature); - if (name != NULL) + if (name != nullptr) jvmti_env->Deallocate((unsigned char*)name); - if (signature != NULL) + if (signature != nullptr) jvmti_env->Deallocate((unsigned char*)signature); switch (BreakpointEventsCount) { @@ -93,20 +93,20 @@ static void JNICALL FramePop(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method, jboolean wasPopedByException) { - char *name = NULL; - char *signature = NULL; + char *name = nullptr; + char *signature = nullptr; FramePopEventsCount++; - if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, nullptr))) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY2("FramePop event: %s%s\n", name, signature); - if (name != NULL) + if (name != nullptr) jvmti_env->Deallocate((unsigned char*)name); - if (signature != NULL) + if (signature != nullptr) jvmti_env->Deallocate((unsigned char*)signature); } @@ -115,8 +115,8 @@ FramePop(jvmtiEnv *jvmti_env, JNIEnv *jni_env, static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { const char* THREAD_NAME = "Debuggee Thread"; jvmtiThreadInfo info; - jthread *threads = NULL; - jclass klass = NULL; + jthread *threads = nullptr; + jclass klass = nullptr; jint threads_count = 0; int i; @@ -126,12 +126,12 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -141,11 +141,11 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) { + if (info.name != nullptr && (strcmp(info.name, THREAD_NAME) == 0)) { thread = threads[i]; } - if (info.name != NULL) { + if (info.name != nullptr) { if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)info.name))) return NSK_FALSE; } @@ -155,29 +155,29 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threads))) return NSK_FALSE; - if (thread == NULL) { + if (thread == nullptr) { NSK_COMPLAIN0("Debuggee thread not found"); return NSK_FALSE; } - if (!NSK_JNI_VERIFY(jni, (thread = jni->NewGlobalRef(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (thread = jni->NewGlobalRef(thread)) != nullptr)) return NSK_FALSE; /* get tested thread class */ - if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != nullptr)) return NSK_FALSE; /* get tested thread method 'checkPoint' */ - if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "checkPoint", "()V")) != NULL)) + if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "checkPoint", "()V")) != nullptr)) return NSK_FALSE; if (!NSK_JVMTI_VERIFY(jvmti->SetBreakpoint(method, 0))) return NSK_FALSE; /* enable events */ - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, nullptr))) return NSK_FALSE; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FRAME_POP, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FRAME_POP, nullptr))) return NSK_FALSE; return NSK_TRUE; @@ -212,7 +212,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { nsk_jvmti_setFailStatus(); } - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_FRAME_POP, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_FRAME_POP, nullptr))) nsk_jvmti_setFailStatus(); NSK_TRACE(jvmti->ClearBreakpoint(method, 0)); @@ -237,7 +237,7 @@ JNIEXPORT jint JNI_OnLoad_ma05t001(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiEventCallbacks callbacks; jvmtiCapabilities caps; @@ -249,7 +249,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; memset(&caps, 0, sizeof(caps)); @@ -258,7 +258,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&callbacks, 0, sizeof(callbacks)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA05/ma05t001/ma05t001a.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA05/ma05t001/ma05t001a.cpp index 785cdeb6018..19f6e52837e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA05/ma05t001/ma05t001a.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA05/ma05t001/ma05t001a.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,8 +38,8 @@ extern "C" { static jlong timeout = 0; /* test objects */ -static jthread thread = NULL; -static jmethodID midCheckPoint = NULL; +static jthread thread = nullptr; +static jmethodID midCheckPoint = nullptr; static int MethodEntryEventsCount = 0; static int FramePopEventsCount = 0; @@ -50,23 +50,23 @@ static int FramePopEventsCount = 0; static void JNICALL MethodEntry(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method) { - char *name = NULL; - char *signature = NULL; + char *name = nullptr; + char *signature = nullptr; if (method != midCheckPoint) return; MethodEntryEventsCount++; - if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, nullptr))) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY2("MethodEntry event: %s%s\n", name, signature); - if (name != NULL) + if (name != nullptr) jvmti_env->Deallocate((unsigned char*)name); - if (signature != NULL) + if (signature != nullptr) jvmti_env->Deallocate((unsigned char*)signature); switch (MethodEntryEventsCount) { @@ -82,7 +82,7 @@ MethodEntry(jvmtiEnv *jvmti_env, JNIEnv *jni_env, case 3: NSK_DISPLAY0("Testcase #3: FramePop disabled in 2nd agent\n"); - if (!NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_FRAME_POP, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_FRAME_POP, nullptr))) nsk_jvmti_setFailStatus(); if (!NSK_JVMTI_VERIFY(jvmti_env->NotifyFramePop(thread, 0))) nsk_jvmti_setFailStatus(); @@ -99,20 +99,20 @@ static void JNICALL FramePop(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method, jboolean wasPopedByException) { - char *name = NULL; - char *signature = NULL; + char *name = nullptr; + char *signature = nullptr; FramePopEventsCount++; - if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, nullptr))) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY2("FramePop event: %s%s\n", name, signature); - if (name != NULL) + if (name != nullptr) jvmti_env->Deallocate((unsigned char*)name); - if (signature != NULL) + if (signature != nullptr) jvmti_env->Deallocate((unsigned char*)signature); switch (MethodEntryEventsCount) { @@ -142,8 +142,8 @@ FramePop(jvmtiEnv *jvmti_env, JNIEnv *jni_env, static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { const char* THREAD_NAME = "Debuggee Thread"; jvmtiThreadInfo info; - jthread *threads = NULL; - jclass klass = NULL; + jthread *threads = nullptr; + jclass klass = nullptr; jint threads_count = 0; int i; @@ -153,12 +153,12 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -168,11 +168,11 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) { + if (info.name != nullptr && (strcmp(info.name, THREAD_NAME) == 0)) { thread = threads[i]; } - if (info.name != NULL) { + if (info.name != nullptr) { if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)info.name))) return NSK_FALSE; } @@ -182,26 +182,26 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threads))) return NSK_FALSE; - if (thread == NULL) { + if (thread == nullptr) { NSK_COMPLAIN0("Debuggee thread not found"); return NSK_FALSE; } - if (!NSK_JNI_VERIFY(jni, (thread = jni->NewGlobalRef(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (thread = jni->NewGlobalRef(thread)) != nullptr)) return NSK_FALSE; /* get tested thread class */ - if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != nullptr)) return NSK_FALSE; /* get tested thread method 'checkPoint' */ - if (!NSK_JNI_VERIFY(jni, (midCheckPoint = jni->GetMethodID(klass, "checkPoint", "()V")) != NULL)) + if (!NSK_JNI_VERIFY(jni, (midCheckPoint = jni->GetMethodID(klass, "checkPoint", "()V")) != nullptr)) return NSK_FALSE; /* enable events */ - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_ENTRY, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_ENTRY, nullptr))) return NSK_FALSE; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FRAME_POP, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FRAME_POP, nullptr))) return NSK_FALSE; return NSK_TRUE; @@ -233,7 +233,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { } NSK_TRACE(jni->DeleteGlobalRef(thread)); - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_METHOD_ENTRY, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_METHOD_ENTRY, nullptr))) nsk_jvmti_setFailStatus(); if (!nsk_jvmti_resumeSync()) @@ -255,7 +255,7 @@ JNIEXPORT jint JNI_OnLoad_ma05t001a(JavaVM *jvm, char *options, void *reserved) } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiEventCallbacks callbacks; jvmtiCapabilities caps; @@ -267,7 +267,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; memset(&caps, 0, sizeof(caps)); @@ -276,7 +276,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&callbacks, 0, sizeof(callbacks)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA06/ma06t001/ma06t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA06/ma06t001/ma06t001.cpp index 812d8e09ab9..6d6be2d9b8a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA06/ma06t001/ma06t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA06/ma06t001/ma06t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,9 +38,9 @@ extern "C" { static jlong timeout = 0; /* test objects */ -static jclass testedClass = NULL; +static jclass testedClass = nullptr; static jint klass_byte_count = 0; -static unsigned char *klass_bytes = NULL; +static unsigned char *klass_bytes = nullptr; static int magicIndex = 0; static int ClassFileLoadHookEventFlag = NSK_FALSE; @@ -59,11 +59,11 @@ ClassFileLoadHook(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jint *new_class_data_len, unsigned char** new_class_data) { jint i; - if (name != NULL && (strcmp(name, CLASS_NAME) == 0)) { + if (name != nullptr && (strcmp(name, CLASS_NAME) == 0)) { ClassFileLoadHookEventFlag = NSK_TRUE; NSK_DISPLAY0("ClassFileLoadHook event\n"); - if (class_being_redefined == NULL) { + if (class_being_redefined == nullptr) { /* sent by class load */ if (!NSK_JVMTI_VERIFY(jvmti_env->Allocate(class_data_len, &klass_bytes))) nsk_jvmti_setFailStatus(); @@ -93,10 +93,10 @@ ClassFileLoadHook(jvmtiEnv *jvmti_env, JNIEnv *jni_env, static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { NSK_DISPLAY1("Find class: %s\n", CLASS_NAME); - if (!NSK_JNI_VERIFY(jni, (testedClass = jni->FindClass(CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (testedClass = jni->FindClass(CLASS_NAME)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (testedClass = (jclass) jni->NewGlobalRef(testedClass)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (testedClass = (jclass) jni->NewGlobalRef(testedClass)) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -107,7 +107,7 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { static int redefine(jvmtiEnv* jvmti, jint value) { jvmtiClassDefinition class_def; - if (!NSK_VERIFY(klass_byte_count != 0 && klass_bytes != NULL)) + if (!NSK_VERIFY(klass_byte_count != 0 && klass_bytes != nullptr)) return NSK_FALSE; if (!NSK_VERIFY(magicIndex != 0)) @@ -178,7 +178,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { nsk_jvmti_setFailStatus(); } - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, nullptr))) nsk_jvmti_setFailStatus(); NSK_TRACE(jni->DeleteGlobalRef(testedClass)); @@ -202,7 +202,7 @@ JNIEXPORT jint JNI_OnLoad_ma06t001(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiEventCallbacks callbacks; jvmtiCapabilities caps; @@ -214,7 +214,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; memset(&caps, 0, sizeof(caps)); @@ -222,7 +222,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&callbacks, 0, sizeof(callbacks)); @@ -230,7 +230,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!NSK_VERIFY(nsk_jvmti_init_MA(&callbacks))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA06/ma06t001/ma06t001a.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA06/ma06t001/ma06t001a.cpp index 9d97aa5f2cb..daf92c53ac4 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA06/ma06t001/ma06t001a.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA06/ma06t001/ma06t001a.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,9 +38,9 @@ extern "C" { static jlong timeout = 0; /* test objects */ -static jclass testedClass = NULL; +static jclass testedClass = nullptr; static jint klass_byte_count = 0; -static unsigned char *klass_bytes = NULL; +static unsigned char *klass_bytes = nullptr; static int magicIndex = 0; static int ClassFileLoadHookEventFlag = NSK_FALSE; @@ -59,11 +59,11 @@ ClassFileLoadHook(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jint *new_class_data_len, unsigned char** new_class_data) { jint i; - if (name != NULL && (strcmp(name, CLASS_NAME) == 0)) { + if (name != nullptr && (strcmp(name, CLASS_NAME) == 0)) { ClassFileLoadHookEventFlag = NSK_TRUE; NSK_DISPLAY0("ClassFileLoadHook event\n"); - if (class_being_redefined == NULL) { + if (class_being_redefined == nullptr) { /* sent by class load */ if (!NSK_JVMTI_VERIFY(jvmti_env->Allocate(class_data_len, &klass_bytes))) nsk_jvmti_setFailStatus(); @@ -93,10 +93,10 @@ ClassFileLoadHook(jvmtiEnv *jvmti_env, JNIEnv *jni_env, static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { NSK_DISPLAY1("Find class: %s\n", CLASS_NAME); - if (!NSK_JNI_VERIFY(jni, (testedClass = jni->FindClass(CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (testedClass = jni->FindClass(CLASS_NAME)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (testedClass = (jclass) jni->NewGlobalRef(testedClass)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (testedClass = (jclass) jni->NewGlobalRef(testedClass)) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -107,7 +107,7 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { static int redefine(jvmtiEnv* jvmti, jint value) { jvmtiClassDefinition class_def; - if (!NSK_VERIFY(klass_byte_count != 0 && klass_bytes != NULL)) + if (!NSK_VERIFY(klass_byte_count != 0 && klass_bytes != nullptr)) return NSK_FALSE; if (!NSK_VERIFY(magicIndex != 0)) @@ -178,7 +178,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { nsk_jvmti_setFailStatus(); } - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, nullptr))) nsk_jvmti_setFailStatus(); NSK_TRACE(jni->DeleteGlobalRef(testedClass)); @@ -202,7 +202,7 @@ JNIEXPORT jint JNI_OnLoad_ma06t001a(JavaVM *jvm, char *options, void *reserved) } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiEventCallbacks callbacks; jvmtiCapabilities caps; @@ -214,7 +214,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; memset(&caps, 0, sizeof(caps)); @@ -222,7 +222,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&callbacks, 0, sizeof(callbacks)); @@ -230,7 +230,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!NSK_VERIFY(nsk_jvmti_init_MA(&callbacks))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA07/ma07t001/ma07t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA07/ma07t001/ma07t001.cpp index 0fa045ead94..cb21bce2ee7 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA07/ma07t001/ma07t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA07/ma07t001/ma07t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ static jlong timeout = 0; /* test objects */ static jint klass_byte_count = 0; -static unsigned char *klass_bytes = NULL; +static unsigned char *klass_bytes = nullptr; static int ClassFileLoadHookEventFlag = NSK_FALSE; const char* CLASS_NAME = "nsk/jvmti/scenarios/multienv/MA07/ma07t001a"; @@ -62,11 +62,11 @@ ClassFileLoadHook(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jint magicIndex = 0; jint i; - if (name != NULL && (strcmp(name, CLASS_NAME) == 0)) { + if (name != nullptr && (strcmp(name, CLASS_NAME) == 0)) { ClassFileLoadHookEventFlag = NSK_TRUE; NSK_DISPLAY0("ClassFileLoadHook event\n"); - if (!NSK_VERIFY(class_being_redefined == NULL)) { + if (!NSK_VERIFY(class_being_redefined == nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -151,7 +151,7 @@ JNIEXPORT jint JNI_OnLoad_ma07t001(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiEventCallbacks callbacks; NSK_DISPLAY0("Agent_OnLoad\n"); @@ -162,10 +162,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&callbacks, 0, sizeof(callbacks)); @@ -173,7 +173,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!NSK_VERIFY(nsk_jvmti_init_MA(&callbacks))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA07/ma07t001/ma07t001a.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA07/ma07t001/ma07t001a.cpp index fe5965ba627..e5410c9394c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA07/ma07t001/ma07t001a.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA07/ma07t001/ma07t001a.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ static jlong timeout = 0; /* test objects */ static jint klass_byte_count = 0; -static unsigned char *klass_bytes = NULL; +static unsigned char *klass_bytes = nullptr; static int ClassFileLoadHookEventFlag = NSK_FALSE; const char* CLASS_NAME = "nsk/jvmti/scenarios/multienv/MA07/ma07t001a"; @@ -62,11 +62,11 @@ ClassFileLoadHook(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jint magicIndex = 0; jint i; - if (name != NULL && (strcmp(name, CLASS_NAME) == 0)) { + if (name != nullptr && (strcmp(name, CLASS_NAME) == 0)) { ClassFileLoadHookEventFlag = NSK_TRUE; NSK_DISPLAY0("ClassFileLoadHook event\n"); - if (!NSK_VERIFY(class_being_redefined == NULL)) { + if (!NSK_VERIFY(class_being_redefined == nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -152,7 +152,7 @@ JNIEXPORT jint JNI_OnLoad_ma07t001a(JavaVM *jvm, char *options, void *reserved) } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiEventCallbacks callbacks; NSK_DISPLAY0("Agent_OnLoad\n"); @@ -163,10 +163,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&callbacks, 0, sizeof(callbacks)); @@ -174,7 +174,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!NSK_VERIFY(nsk_jvmti_init_MA(&callbacks))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA08/ma08t001/ma08t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA08/ma08t001/ma08t001.cpp index fd6d56029d3..375a1c944b2 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA08/ma08t001/ma08t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA08/ma08t001/ma08t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,9 +38,9 @@ extern "C" { static jlong timeout = 0; /* test objects */ -static jobject threadDeath = NULL; -static jthread threadForStop = NULL; -static jthread threadForInterrupt = NULL; +static jobject threadDeath = nullptr; +static jthread threadForStop = nullptr; +static jthread threadForInterrupt = nullptr; /* ========================================================================== */ @@ -51,10 +51,10 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { const char* THREAD_DEATH_CTOR_NAME = ""; const char* THREAD_DEATH_CTOR_SIGNATURE = "()V"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; - jclass cls = NULL; - jmethodID ctor = NULL; + jclass cls = nullptr; + jmethodID ctor = nullptr; int i; NSK_DISPLAY0("Prepare: find tested thread\n"); @@ -63,12 +63,12 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -78,7 +78,7 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL) { + if (info.name != nullptr) { if (strcmp(info.name, STOP_THREAD_NAME) == 0) { threadForStop = threads[i]; } else if (strcmp(info.name, INTERRUPT_THREAD_NAME) == 0) { @@ -91,26 +91,26 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threads))) return NSK_FALSE; - if (threadForStop == NULL) { + if (threadForStop == nullptr) { NSK_COMPLAIN0("DebuggeeThreadForStop not found"); return NSK_FALSE; } - if (threadForInterrupt == NULL) { + if (threadForInterrupt == nullptr) { NSK_COMPLAIN0("DebuggeeThreadForInterrupt not found"); return NSK_FALSE; } NSK_DISPLAY0("Prepare: create new instance of ThreadDeath exception\n"); - if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (ctor = - jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != NULL)) + jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (threadDeath = jni->NewObject(cls, ctor)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (threadDeath = jni->NewObject(cls, ctor)) != nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -131,7 +131,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { } NSK_DISPLAY0("Testcase #1: call StopThread\n"); - if (!NSK_VERIFY(threadForStop != NULL)) { + if (!NSK_VERIFY(threadForStop != nullptr)) { nsk_jvmti_setFailStatus(); } else { if (!NSK_JVMTI_VERIFY(jvmti->StopThread(threadForStop, threadDeath))) @@ -139,7 +139,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { } NSK_DISPLAY0("Testcase #2: call InterruptThread\n"); - if (!NSK_VERIFY(threadForInterrupt != NULL)) { + if (!NSK_VERIFY(threadForInterrupt != nullptr)) { nsk_jvmti_setFailStatus(); } else { if (!NSK_JVMTI_VERIFY(jvmti->InterruptThread(threadForInterrupt))) @@ -171,7 +171,7 @@ JNIEXPORT jint JNI_OnLoad_ma08t001(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiCapabilities caps; jvmtiEventCallbacks callbacks; @@ -183,10 +183,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&caps, 0, sizeof(caps)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA08/ma08t001/ma08t001a.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA08/ma08t001/ma08t001a.cpp index 2253e5a088d..c77b118941a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA08/ma08t001/ma08t001a.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA08/ma08t001/ma08t001a.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,8 +38,8 @@ extern "C" { static jlong timeout = 0; /* test objects */ -static jthread threadForStop = NULL; -static jthread threadForInterrupt = NULL; +static jthread threadForStop = nullptr; +static jthread threadForInterrupt = nullptr; static int ThreadDeathFlag = 0; static int InterruptedExceptionFlag = 0; @@ -53,20 +53,20 @@ static void JNICALL Exception(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method, jlocation location, jobject exception, jmethodID catch_method, jlocation catch_location) { - jclass klass = NULL; - char *signature = NULL; + jclass klass = nullptr; + char *signature = nullptr; - if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(exception)) != NULL)) { + if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(exception)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } - if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &signature, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &signature, nullptr))) { nsk_jvmti_setFailStatus(); return; } - if (!NSK_VERIFY(signature != NULL)) { + if (!NSK_VERIFY(signature != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -100,7 +100,7 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { const char* STOP_THREAD_NAME = "DebuggeeThreadForStop"; const char* INTERRUPT_THREAD_NAME = "DebuggeeThreadForInterrupt"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; int i; @@ -110,12 +110,12 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -125,7 +125,7 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL) { + if (info.name != nullptr) { if (strcmp(info.name, STOP_THREAD_NAME) == 0) { threadForStop = threads[i]; } else if (strcmp(info.name, INTERRUPT_THREAD_NAME) == 0) { @@ -138,24 +138,24 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threads))) return NSK_FALSE; - if (threadForStop == NULL) { + if (threadForStop == nullptr) { NSK_COMPLAIN0("DebuggeeThreadForStop not found"); return NSK_FALSE; } - if (threadForInterrupt == NULL) { + if (threadForInterrupt == nullptr) { NSK_COMPLAIN0("DebuggeeThreadForInterrupt not found"); return NSK_FALSE; } - if (!NSK_JNI_VERIFY(jni, (threadForStop = jni->NewGlobalRef(threadForStop)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (threadForStop = jni->NewGlobalRef(threadForStop)) != nullptr)) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (threadForInterrupt = jni->NewGlobalRef(threadForInterrupt)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (threadForInterrupt = jni->NewGlobalRef(threadForInterrupt)) != nullptr)) return NSK_FALSE; /* enable event */ - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION, nullptr))) return NSK_FALSE; return NSK_TRUE; @@ -191,7 +191,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { nsk_jvmti_setFailStatus(); /* disable event */ - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_EXCEPTION, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_EXCEPTION, nullptr))) nsk_jvmti_setFailStatus(); NSK_TRACE(jni->DeleteGlobalRef(threadForStop)); @@ -216,7 +216,7 @@ JNIEXPORT jint JNI_OnLoad_ma08t001a(JavaVM *jvm, char *options, void *reserved) } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiCapabilities caps; jvmtiEventCallbacks callbacks; @@ -228,10 +228,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&caps, 0, sizeof(caps)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t001/ma10t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t001/ma10t001.cpp index 330b7b713a6..5c45e75a167 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t001/ma10t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t001/ma10t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -48,10 +48,10 @@ static const char *testThreadName = "Debuggee Thread"; void releaseThreadInfo(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jvmtiThreadInfo *info) { jvmti_env->Deallocate((unsigned char *)info->name); - if (info->thread_group != NULL) { + if (info->thread_group != nullptr) { jni_env->DeleteLocalRef(info->thread_group); } - if (info->context_class_loader != NULL) { + if (info->context_class_loader != nullptr) { jni_env->DeleteLocalRef(info->context_class_loader); } } @@ -80,8 +80,8 @@ static void JNICALL Exception(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method, jlocation location, jobject exception, jmethodID catch_method, jlocation catch_location) { - jclass klass = NULL; - char *signature = NULL; + jclass klass = nullptr; + char *signature = nullptr; if (!isTestThread("Exception", jvmti_env, jni_env, thread)) { return; @@ -89,24 +89,24 @@ Exception(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, ExceptionEventsCount++; - if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(exception)) != NULL)) { + if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(exception)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } - if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &signature, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &signature, nullptr))) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY1("Exception event: %s\n", signature); - if (signature != NULL) + if (signature != nullptr) jvmti_env->Deallocate((unsigned char*)signature); } void JNICALL ExceptionCatch(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method, jlocation location, jobject exception) { - jclass klass = NULL; - char *signature = NULL; + jclass klass = nullptr; + char *signature = nullptr; if (!isTestThread("ExceptionCatch", jvmti_env, jni_env, thread)) { return; @@ -114,16 +114,16 @@ ExceptionCatch(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, ExceptionCatchEventsCount++; - if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(exception)) != NULL)) { + if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(exception)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } - if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &signature, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &signature, nullptr))) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY1("ExceptionCatch event: %s\n", signature); - if (signature != NULL) + if (signature != nullptr) jvmti_env->Deallocate((unsigned char*)signature); } @@ -136,9 +136,9 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { if (!nsk_jvmti_waitForSync(timeout)) return; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION, nullptr))) nsk_jvmti_setFailStatus(); - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION_CATCH, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION_CATCH, nullptr))) nsk_jvmti_setFailStatus(); /* resume debugee and wait for sync */ @@ -147,9 +147,9 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { if (!nsk_jvmti_waitForSync(timeout)) return; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_EXCEPTION, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_EXCEPTION, nullptr))) nsk_jvmti_setFailStatus(); - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_EXCEPTION_CATCH, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_EXCEPTION_CATCH, nullptr))) nsk_jvmti_setFailStatus(); NSK_DISPLAY1("Exception events received: %d\n", @@ -181,7 +181,7 @@ JNIEXPORT jint JNI_OnLoad_ma10t001(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiCapabilities caps; jvmtiEventCallbacks callbacks; @@ -193,10 +193,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&caps, 0, sizeof(caps)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t001/ma10t001a.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t001/ma10t001a.cpp index 29863b2c2c1..8ce327c18a0 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t001/ma10t001a.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t001/ma10t001a.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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,42 +49,42 @@ static void JNICALL Exception(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method, jlocation location, jobject exception, jmethodID catch_method, jlocation catch_location) { - jclass klass = NULL; - char *signature = NULL; + jclass klass = nullptr; + char *signature = nullptr; ExceptionEventsCount++; - if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(exception)) != NULL)) { + if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(exception)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } - if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &signature, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &signature, nullptr))) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY1("Exception event: %s\n", signature); - if (signature != NULL) + if (signature != nullptr) jvmti_env->Deallocate((unsigned char*)signature); } void JNICALL ExceptionCatch(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method, jlocation location, jobject exception) { - jclass klass = NULL; - char *signature = NULL; + jclass klass = nullptr; + char *signature = nullptr; ExceptionCatchEventsCount++; - if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(exception)) != NULL)) { + if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(exception)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } - if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &signature, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &signature, nullptr))) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY1("ExceptionCatch event: %s\n", signature); - if (signature != NULL) + if (signature != nullptr) jvmti_env->Deallocate((unsigned char*)signature); } @@ -132,7 +132,7 @@ JNIEXPORT jint JNI_OnLoad_ma10t001a(JavaVM *jvm, char *options, void *reserved) } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiCapabilities caps; jvmtiEventCallbacks callbacks; @@ -144,10 +144,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&caps, 0, sizeof(caps)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t002/ma10t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t002/ma10t002.cpp index c9b34e0eb49..3e9e15d92f1 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t002/ma10t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t002/ma10t002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ extern "C" { static jlong timeout = 0; /* test objects */ -static jthread thread = NULL; +static jthread thread = nullptr; /* event counts */ static int MethodEntryEventsCount = 0; @@ -50,18 +50,18 @@ static int MethodEntryEventsCount = 0; static void JNICALL MethodEntry(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method) { - char *name = NULL; - char *signature = NULL; + char *name = nullptr; + char *signature = nullptr; MethodEntryEventsCount++; - if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, nullptr))) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY2("MethodEntry event: %s%s\n", name, signature); - if (name != NULL) + if (name != nullptr) jvmti_env->Deallocate((unsigned char*)name); - if (signature != NULL) + if (signature != nullptr) jvmti_env->Deallocate((unsigned char*)signature); } @@ -70,7 +70,7 @@ MethodEntry(jvmtiEnv *jvmti_env, JNIEnv *jni_env, static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { const char* THREAD_NAME = "Debuggee Thread"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; int i; @@ -80,12 +80,12 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -95,12 +95,12 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) { + if (info.name != nullptr && (strcmp(info.name, THREAD_NAME) == 0)) { thread = threads[i]; } } - if (!NSK_JNI_VERIFY(jni, (thread = jni->NewGlobalRef(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (thread = jni->NewGlobalRef(thread)) != nullptr)) return NSK_FALSE; /* deallocate threads list */ @@ -159,7 +159,7 @@ JNIEXPORT jint JNI_OnLoad_ma10t002(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiCapabilities caps; jvmtiEventCallbacks callbacks; @@ -171,10 +171,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&caps, 0, sizeof(caps)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t002/ma10t002a.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t002/ma10t002a.cpp index e8256ff6dc1..9bf090dbbc4 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t002/ma10t002a.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t002/ma10t002a.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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,18 +47,18 @@ static int MethodEntryEventsCount = 0; static void JNICALL MethodEntry(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method) { - char *name = NULL; - char *signature = NULL; + char *name = nullptr; + char *signature = nullptr; MethodEntryEventsCount++; - if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, nullptr))) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY2("MethodEntry event: %s%s\n", name, signature); - if (name != NULL) + if (name != nullptr) jvmti_env->Deallocate((unsigned char*)name); - if (signature != NULL) + if (signature != nullptr) jvmti_env->Deallocate((unsigned char*)signature); } @@ -101,7 +101,7 @@ JNIEXPORT jint JNI_OnLoad_ma10t002a(JavaVM *jvm, char *options, void *reserved) } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiCapabilities caps; jvmtiEventCallbacks callbacks; @@ -113,10 +113,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&caps, 0, sizeof(caps)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t003/ma10t003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t003/ma10t003.cpp index 2b75f45a6ae..78857457350 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t003/ma10t003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t003/ma10t003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ extern "C" { static jlong timeout = 0; /* test objects */ -static jthread thread = NULL; +static jthread thread = nullptr; /* event counts */ static int MethodExitEventsCount = 0; @@ -51,18 +51,18 @@ static void JNICALL MethodExit(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method, jboolean was_poped_by_exception, jvalue return_value) { - char *name = NULL; - char *signature = NULL; + char *name = nullptr; + char *signature = nullptr; MethodExitEventsCount++; - if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, nullptr))) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY2("MethodExit event: %s%s\n", name, signature); - if (name != NULL) + if (name != nullptr) jvmti_env->Deallocate((unsigned char*)name); - if (signature != NULL) + if (signature != nullptr) jvmti_env->Deallocate((unsigned char*)signature); } @@ -71,7 +71,7 @@ MethodExit(jvmtiEnv *jvmti_env, JNIEnv *jni_env, static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { const char* THREAD_NAME = "Debuggee Thread"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; int i; @@ -81,12 +81,12 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -96,12 +96,12 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) { + if (info.name != nullptr && (strcmp(info.name, THREAD_NAME) == 0)) { thread = threads[i]; } } - if (!NSK_JNI_VERIFY(jni, (thread = jni->NewGlobalRef(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (thread = jni->NewGlobalRef(thread)) != nullptr)) return NSK_FALSE; /* deallocate threads list */ @@ -160,7 +160,7 @@ JNIEXPORT jint JNI_OnLoad_ma10t003(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiCapabilities caps; jvmtiEventCallbacks callbacks; @@ -172,10 +172,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&caps, 0, sizeof(caps)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t003/ma10t003a.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t003/ma10t003a.cpp index 98a8f8287fb..356d71c7202 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t003/ma10t003a.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t003/ma10t003a.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -48,18 +48,18 @@ static void JNICALL MethodExit(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method, jboolean was_poped_by_exception, jvalue return_value) { - char *name = NULL; - char *signature = NULL; + char *name = nullptr; + char *signature = nullptr; MethodExitEventsCount++; - if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, nullptr))) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY2("MethodExit event: %s%s\n", name, signature); - if (name != NULL) + if (name != nullptr) jvmti_env->Deallocate((unsigned char*)name); - if (signature != NULL) + if (signature != nullptr) jvmti_env->Deallocate((unsigned char*)signature); } @@ -102,7 +102,7 @@ JNIEXPORT jint JNI_OnLoad_ma10t003a(JavaVM *jvm, char *options, void *reserved) } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiCapabilities caps; jvmtiEventCallbacks callbacks; @@ -114,10 +114,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&caps, 0, sizeof(caps)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t004/ma10t004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t004/ma10t004.cpp index 329da7c919c..578d167a15c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t004/ma10t004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t004/ma10t004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ extern "C" { static jlong timeout = 0; /* test objects */ -static jthread thread = NULL; +static jthread thread = nullptr; /* event counts */ static int SingleStepEventsCount = 0; @@ -50,23 +50,23 @@ static int SingleStepEventsCount = 0; static void JNICALL SingleStep(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, jmethodID method, jlocation location) { - char *name = NULL; - char *signature = NULL; + char *name = nullptr; + char *signature = nullptr; char buffer[32]; SingleStepEventsCount++; - NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, NULL)); + NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, nullptr)); - if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, nullptr))) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY3("SingleStep event: %s%s, location=%s\n", name, signature, jlong_to_string(location, buffer)); - if (name != NULL) + if (name != nullptr) jvmti_env->Deallocate((unsigned char*)name); - if (signature != NULL) + if (signature != nullptr) jvmti_env->Deallocate((unsigned char*)signature); } @@ -75,7 +75,7 @@ SingleStep(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { const char* THREAD_NAME = "Debuggee Thread"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; int i; @@ -85,12 +85,12 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -100,12 +100,12 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) { + if (info.name != nullptr && (strcmp(info.name, THREAD_NAME) == 0)) { thread = threads[i]; } } - if (!NSK_JNI_VERIFY(jni, (thread = jni->NewGlobalRef(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (thread = jni->NewGlobalRef(thread)) != nullptr)) return NSK_FALSE; /* deallocate threads list */ @@ -164,7 +164,7 @@ JNIEXPORT jint JNI_OnLoad_ma10t004(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiCapabilities caps; jvmtiEventCallbacks callbacks; @@ -176,10 +176,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&caps, 0, sizeof(caps)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t004/ma10t004a.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t004/ma10t004a.cpp index 4f97e7c7926..15819c71e54 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t004/ma10t004a.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t004/ma10t004a.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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,23 +47,23 @@ static int SingleStepEventsCount = 0; static void JNICALL SingleStep(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, jmethodID method, jlocation location) { - char *name = NULL; - char *signature = NULL; + char *name = nullptr; + char *signature = nullptr; char buffer[32]; SingleStepEventsCount++; - NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, NULL)); + NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, nullptr)); - if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, nullptr))) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY3("SingleStep event: %s%s, location=%s\n", name, signature, jlong_to_string(location, buffer)); - if (name != NULL) + if (name != nullptr) jvmti_env->Deallocate((unsigned char*)name); - if (signature != NULL) + if (signature != nullptr) jvmti_env->Deallocate((unsigned char*)signature); } @@ -106,7 +106,7 @@ JNIEXPORT jint JNI_OnLoad_ma10t004a(JavaVM *jvm, char *options, void *reserved) } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiCapabilities caps; jvmtiEventCallbacks callbacks; @@ -118,10 +118,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&caps, 0, sizeof(caps)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t005/ma10t005.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t005/ma10t005.cpp index 2f49fe219f4..c736ec86063 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t005/ma10t005.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t005/ma10t005.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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,12 +52,12 @@ VMObjectAlloc(jvmtiEnv *jvmti_env, JNIEnv* jni_env, VMObjectAllocEventsCount++; - if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(object_klass, &signature, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(object_klass, &signature, nullptr))) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY2("VMObjectAlloc: \"%s\", size=%d\n", signature, size); - if (signature != NULL) + if (signature != nullptr) jvmti_env->Deallocate((unsigned char*)signature); } @@ -94,7 +94,7 @@ JNIEXPORT jint JNI_OnLoad_ma10t005(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiCapabilities caps; jvmtiEventCallbacks callbacks; @@ -106,10 +106,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&caps, 0, sizeof(caps)); @@ -123,7 +123,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!NSK_VERIFY(nsk_jvmti_init_MA(&callbacks))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_OBJECT_ALLOC, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_OBJECT_ALLOC, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t005/ma10t005a.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t005/ma10t005a.cpp index 418f082f280..592f9d6af07 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t005/ma10t005a.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t005/ma10t005a.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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,12 +52,12 @@ VMObjectAlloc(jvmtiEnv *jvmti_env, JNIEnv* jni_env, VMObjectAllocEventsCount++; - if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(object_klass, &signature, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(object_klass, &signature, nullptr))) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY2("VMObjectAlloc: \"%s\", size=%d\n", signature, size); - if (signature != NULL) + if (signature != nullptr) jvmti_env->Deallocate((unsigned char*)signature); } @@ -94,7 +94,7 @@ JNIEXPORT jint JNI_OnLoad_ma10t005a(JavaVM *jvm, char *options, void *reserved) } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiCapabilities caps; jvmtiEventCallbacks callbacks; @@ -106,10 +106,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&caps, 0, sizeof(caps)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t006/ma10t006.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t006/ma10t006.cpp index ac2d54a16ab..886675712c0 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t006/ma10t006.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t006/ma10t006.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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,34 +49,34 @@ static void JNICALL CompiledMethodLoad(jvmtiEnv *jvmti_env, jmethodID method, jint code_size, const void* code_addr, jint map_length, const jvmtiAddrLocationMap* map, const void* compile_info) { - char *name = NULL; - char *signature = NULL; + char *name = nullptr; + char *signature = nullptr; CompiledMethodLoadEventsCount++; - if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, nullptr))) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY3("CompiledMethodLoad event: %s%s (0x%p)\n", name, signature, code_addr); - if (name != NULL) + if (name != nullptr) jvmti_env->Deallocate((unsigned char*)name); - if (signature != NULL) + if (signature != nullptr) jvmti_env->Deallocate((unsigned char*)signature); } static void JNICALL CompiledMethodUnload(jvmtiEnv *jvmti_env, jmethodID method, const void* code_addr) { - char *name = NULL; - char *sig = NULL; + char *name = nullptr; + char *sig = nullptr; jvmtiError err; CompiledMethodUnloadEventsCount++; NSK_DISPLAY0("CompiledMethodUnload event received\n"); // Check for the case that the class has been unloaded - err = jvmti_env->GetMethodName(method, &name, &sig, NULL); + err = jvmti_env->GetMethodName(method, &name, &sig, nullptr); if (err == JVMTI_ERROR_NONE) { NSK_DISPLAY3("for: \tmethod: name=\"%s\" signature=\"%s\"\n\tnative address=0x%p\n", name, sig, code_addr); @@ -127,7 +127,7 @@ JNIEXPORT jint JNI_OnLoad_ma10t006(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiCapabilities caps; jvmtiEventCallbacks callbacks; @@ -139,10 +139,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&caps, 0, sizeof(caps)); @@ -157,9 +157,9 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!NSK_VERIFY(nsk_jvmti_init_MA(&callbacks))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_LOAD, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_LOAD, nullptr))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_UNLOAD, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_UNLOAD, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t006/ma10t006a.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t006/ma10t006a.cpp index 2ddf7ec6d9c..96993ef79cc 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t006/ma10t006a.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t006/ma10t006a.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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,35 +49,35 @@ static void JNICALL CompiledMethodLoad(jvmtiEnv *jvmti_env, jmethodID method, jint code_size, const void* code_addr, jint map_length, const jvmtiAddrLocationMap* map, const void* compile_info) { - char *name = NULL; - char *signature = NULL; + char *name = nullptr; + char *signature = nullptr; CompiledMethodLoadEventsCount++; - if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, nullptr))) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY3("CompiledMethodLoad event: %s%s (0x%p)\n", name, signature, code_addr); - if (name != NULL) + if (name != nullptr) jvmti_env->Deallocate((unsigned char*)name); - if (signature != NULL) + if (signature != nullptr) jvmti_env->Deallocate((unsigned char*)signature); } static void JNICALL CompiledMethodUnload(jvmtiEnv *jvmti_env, jmethodID method, const void* code_addr) { - char *name = NULL; - char *sig = NULL; + char *name = nullptr; + char *sig = nullptr; jvmtiError err; CompiledMethodUnloadEventsCount++; NSK_DISPLAY0("CompiledMethodUnload event received\n"); // Check for the case that the class has been unloaded - err = jvmti_env->GetMethodName(method, &name, &sig, NULL); + err = jvmti_env->GetMethodName(method, &name, &sig, nullptr); if (err == JVMTI_ERROR_NONE) { NSK_DISPLAY3("for: \tmethod: name=\"%s\" signature=\"%s\"\n\tnative address=0x%p\n", name, sig, code_addr); @@ -124,7 +124,7 @@ JNIEXPORT jint JNI_OnLoad_ma10t006a(JavaVM *jvm, char *options, void *reserved) } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiCapabilities caps; jvmtiEventCallbacks callbacks; @@ -136,10 +136,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&caps, 0, sizeof(caps)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t007/ma10t007.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t007/ma10t007.cpp index cee84708ed6..4f94aa4c430 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t007/ma10t007.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t007/ma10t007.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -95,7 +95,7 @@ JNIEXPORT jint JNI_OnLoad_ma10t007(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiCapabilities caps; jvmtiEventCallbacks callbacks; @@ -107,10 +107,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&caps, 0, sizeof(caps)); @@ -125,9 +125,9 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!NSK_VERIFY(nsk_jvmti_init_MA(&callbacks))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_START, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_START, nullptr))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_FINISH, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_FINISH, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t007/ma10t007a.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t007/ma10t007a.cpp index e86e00fbc23..ebd5a6569d9 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t007/ma10t007a.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t007/ma10t007a.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -95,7 +95,7 @@ JNIEXPORT jint JNI_OnLoad_ma10t007a(JavaVM *jvm, char *options, void *reserved) } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiCapabilities caps; jvmtiEventCallbacks callbacks; @@ -107,10 +107,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&caps, 0, sizeof(caps)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t008/ma10t008.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t008/ma10t008.cpp index 449f94e64b0..ebf76643958 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t008/ma10t008.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t008/ma10t008.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -165,7 +165,7 @@ JNIEXPORT jint JNI_OnLoad_ma10t008(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiCapabilities caps; jvmtiEventCallbacks callbacks; @@ -177,10 +177,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&caps, 0, sizeof(caps)); @@ -198,13 +198,13 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; /* enable events */ - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTER, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTER, nullptr))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTERED, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTERED, nullptr))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_WAIT, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_WAIT, nullptr))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_WAITED, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_WAITED, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t008/ma10t008a.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t008/ma10t008a.cpp index 9d4c0d81c07..9638dfdd48b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t008/ma10t008a.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t008/ma10t008a.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -165,7 +165,7 @@ JNIEXPORT jint JNI_OnLoad_ma10t008a(JavaVM *jvm, char *options, void *reserved) } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiCapabilities caps; jvmtiEventCallbacks callbacks; @@ -177,10 +177,10 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; memset(&caps, 0, sizeof(caps)); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP01/sp01t001/sp01t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP01/sp01t001/sp01t001.cpp index f0f3bc4a0a3..d3779929295 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP01/sp01t001/sp01t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP01/sp01t001/sp01t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,8 +39,8 @@ extern "C" { #define THREADS_FIELD_SIG "[L" THREAD_CLASS_NAME ";" /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* number of tested threads */ @@ -114,24 +114,24 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* agentJNI, void* arg) { * - make global refs */ static int prepare() { - jclass debugeeClass = NULL; - jfieldID threadsFieldID = NULL; - jobjectArray threadsArray = NULL; + jclass debugeeClass = nullptr; + jfieldID threadsFieldID = nullptr; + jobjectArray threadsArray = nullptr; jsize threadsArrayLength = 0; jsize i; /* find debugee class */ - if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != nullptr)) return NSK_FALSE; /* find static field with threads array */ if (!NSK_JNI_VERIFY(jni, (threadsFieldID = - jni->GetStaticFieldID(debugeeClass, THREADS_FIELD_NAME, THREADS_FIELD_SIG)) != NULL)) + jni->GetStaticFieldID(debugeeClass, THREADS_FIELD_NAME, THREADS_FIELD_SIG)) != nullptr)) return NSK_FALSE; /* get threads array from static field */ if (!NSK_JNI_VERIFY(jni, (threadsArray = (jobjectArray) - jni->GetStaticObjectField(debugeeClass, threadsFieldID)) != NULL)) + jni->GetStaticObjectField(debugeeClass, threadsFieldID)) != nullptr)) return NSK_FALSE; /* check array length */ @@ -142,14 +142,14 @@ static int prepare() { /* get each thread from array */ for (i = 0; i < THREADS_COUNT; i++) { if (!NSK_JNI_VERIFY(jni, (threadsList[i] = (jthread) - jni->GetObjectArrayElement(threadsArray, i)) != NULL)) + jni->GetObjectArrayElement(threadsArray, i)) != nullptr)) return NSK_FALSE; } /* make global references to threads */ for (i = 0; i < THREADS_COUNT; i++) { if (!NSK_JNI_VERIFY(jni, (threadsList[i] = (jthread) - jni->NewGlobalRef(threadsList[i])) != NULL)) + jni->NewGlobalRef(threadsList[i])) != nullptr)) return NSK_FALSE; } @@ -260,11 +260,11 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP01/sp01t002/sp01t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP01/sp01t002/sp01t002.cpp index 99b3dcc7a38..4fe02129060 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP01/sp01t002/sp01t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP01/sp01t002/sp01t002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -32,8 +32,8 @@ extern "C" { /* ============================================================================= */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* number of tested threads */ @@ -142,7 +142,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* agentJNI, void* arg) { * - make global refs */ static int prepare() { - jthread *allThreadsList = NULL; + jthread *allThreadsList = nullptr; jint allThreadsCount = 0; int found = 0; int i; @@ -151,21 +151,21 @@ static int prepare() { /* clean threads list */ for (i = 0; i < THREADS_COUNT; i++) { - threadsList[i] = NULL; + threadsList[i] = nullptr; } /* get all live threads */ if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&allThreadsCount, &allThreadsList))) return NSK_FALSE; - if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != NULL)) + if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != nullptr)) return NSK_FALSE; /* find tested threads */ for (i = 0; i < allThreadsCount; i++) { jvmtiThreadInfo threadInfo; - if (!NSK_VERIFY(allThreadsList[i] != NULL)) + if (!NSK_VERIFY(allThreadsList[i] != nullptr)) return NSK_FALSE; /* get thread name (info) */ @@ -173,7 +173,7 @@ static int prepare() { return NSK_FALSE; /* find by name */ - if (threadInfo.name != NULL) { + if (threadInfo.name != nullptr) { int j; for (j = 0; j < THREADS_COUNT; j++) { @@ -193,7 +193,7 @@ static int prepare() { /* check if all tested threads found */ found = 0; for (i = 0; i < THREADS_COUNT; i++) { - if (threadsList[i] == NULL) { + if (threadsList[i] == nullptr) { NSK_COMPLAIN2("Not found tested thread #%d (%s)\n", i, threadsName[i]); } else { found++; @@ -205,7 +205,7 @@ static int prepare() { /* make global refs */ for (i = 0; i < THREADS_COUNT; i++) { - if (!NSK_JNI_VERIFY(jni, (threadsList[i] = jni->NewGlobalRef(threadsList[i])) != NULL)) + if (!NSK_JNI_VERIFY(jni, (threadsList[i] = jni->NewGlobalRef(threadsList[i])) != nullptr)) return NSK_FALSE; } @@ -434,7 +434,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add specific capabilities for suspending thread */ @@ -447,7 +447,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP01/sp01t003/sp01t003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP01/sp01t003/sp01t003.cpp index 814b4bf3a1e..504f965adca 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP01/sp01t003/sp01t003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP01/sp01t003/sp01t003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -32,8 +32,8 @@ extern "C" { /* ============================================================================= */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* number of tested threads */ @@ -142,7 +142,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* agentJNI, void* arg) { * - make global refs */ static int prepare() { - jthread *allThreadsList = NULL; + jthread *allThreadsList = nullptr; jint allThreadsCount = 0; int found = 0; int i; @@ -151,21 +151,21 @@ static int prepare() { /* clean threads list */ for (i = 0; i < THREADS_COUNT; i++) { - threadsList[i] = NULL; + threadsList[i] = nullptr; } /* get all live threads */ if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&allThreadsCount, &allThreadsList))) return NSK_FALSE; - if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != NULL)) + if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != nullptr)) return NSK_FALSE; /* find tested threads */ for (i = 0; i < allThreadsCount; i++) { jvmtiThreadInfo threadInfo; - if (!NSK_VERIFY(allThreadsList[i] != NULL)) + if (!NSK_VERIFY(allThreadsList[i] != nullptr)) return NSK_FALSE; /* get thread name (info) */ @@ -173,7 +173,7 @@ static int prepare() { return NSK_FALSE; /* find by name */ - if (threadInfo.name != NULL) { + if (threadInfo.name != nullptr) { int j; for (j = 0; j < THREADS_COUNT; j++) { @@ -193,7 +193,7 @@ static int prepare() { /* check if all tested threads found */ found = 0; for (i = 0; i < THREADS_COUNT; i++) { - if (threadsList[i] == NULL) { + if (threadsList[i] == nullptr) { NSK_COMPLAIN2("Not found tested thread #%d (%s)\n", i, threadsName[i]); } else { found++; @@ -205,7 +205,7 @@ static int prepare() { /* make global refs */ for (i = 0; i < THREADS_COUNT; i++) { - if (!NSK_JNI_VERIFY(jni, (threadsList[i] = jni->NewGlobalRef(threadsList[i])) != NULL)) + if (!NSK_JNI_VERIFY(jni, (threadsList[i] = jni->NewGlobalRef(threadsList[i])) != nullptr)) return NSK_FALSE; } @@ -445,7 +445,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add specific capabilities for suspending thread */ @@ -458,7 +458,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t001/sp02t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t001/sp02t001.cpp index 491d7f04928..9dc696c7d88 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t001/sp02t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t001/sp02t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -32,8 +32,8 @@ extern "C" { /* ============================================================================= */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* constants */ @@ -50,12 +50,12 @@ typedef struct { /* descriptions of tested threads */ static ThreadDesc threadsDesc[THREADS_COUNT] = { - { "threadRunning", 2, NULL }, - { "threadEntering", 2, NULL }, - { "threadWaiting", 2, NULL }, - { "threadSleeping", 2, NULL }, - { "threadRunningInterrupted", 2, NULL }, - { "threadRunningNative", 2, NULL } + { "threadRunning", 2, nullptr }, + { "threadEntering", 2, nullptr }, + { "threadWaiting", 2, nullptr }, + { "threadSleeping", 2, nullptr }, + { "threadRunningInterrupted", 2, nullptr }, + { "threadRunningNative", 2, nullptr } }; /* ============================================================================= */ @@ -123,7 +123,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* agentJNI, void* arg) { * - make global refs */ static int prepare() { - jthread *allThreadsList = NULL; + jthread *allThreadsList = nullptr; jint allThreadsCount = 0; int found = 0; int i; @@ -132,21 +132,21 @@ static int prepare() { /* clean threads list */ for (i = 0; i < THREADS_COUNT; i++) { - threadsDesc[i].thread = (jthread)NULL; + threadsDesc[i].thread = (jthread)nullptr; } /* get all live threads */ if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&allThreadsCount, &allThreadsList))) return NSK_FALSE; - if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != NULL)) + if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != nullptr)) return NSK_FALSE; /* find tested threads */ for (i = 0; i < allThreadsCount; i++) { jvmtiThreadInfo threadInfo; - if (!NSK_VERIFY(allThreadsList[i] != NULL)) + if (!NSK_VERIFY(allThreadsList[i] != nullptr)) return NSK_FALSE; /* get thread name (info) */ @@ -154,7 +154,7 @@ static int prepare() { return NSK_FALSE; /* find by name */ - if (threadInfo.name != NULL) { + if (threadInfo.name != nullptr) { int j; for (j = 0; j < THREADS_COUNT; j++) { @@ -174,7 +174,7 @@ static int prepare() { /* check if all tested threads found */ found = 0; for (i = 0; i < THREADS_COUNT; i++) { - if (threadsDesc[i].thread == NULL) { + if (threadsDesc[i].thread == nullptr) { NSK_COMPLAIN2("Not found tested thread #%d (%s)\n", i, threadsDesc[i].threadName); } else { found++; @@ -187,7 +187,7 @@ static int prepare() { /* make global refs */ for (i = 0; i < THREADS_COUNT; i++) { if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].thread = (jthread) - jni->NewGlobalRef(threadsDesc[i].thread)) != NULL)) + jni->NewGlobalRef(threadsDesc[i].thread)) != nullptr)) return NSK_FALSE; } @@ -356,7 +356,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add specific capabilities for suspending thread */ @@ -369,7 +369,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t002/sp02t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t002/sp02t002.cpp index 00aa34f3fdb..eadc3fa3cc6 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t002/sp02t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t002/sp02t002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -32,8 +32,8 @@ extern "C" { /* ============================================================================= */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* constants */ @@ -54,12 +54,12 @@ typedef struct { /* descriptions of tested threads */ static ThreadDesc threadsDesc[THREADS_COUNT] = { - { "threadRunning", "testedMethod", "()V", NULL, NULL, NULL, NSK_JVMTI_INVALID_JLOCATION }, - { "threadEntering", "testedMethod", "()V", NULL, NULL, NULL, NSK_JVMTI_INVALID_JLOCATION }, - { "threadWaiting", "testedMethod", "()V", NULL, NULL, NULL, NSK_JVMTI_INVALID_JLOCATION }, - { "threadSleeping", "testedMethod", "()V", NULL, NULL, NULL, NSK_JVMTI_INVALID_JLOCATION }, - { "threadRunningInterrupted", "testedMethod", "()V", NULL, NULL, NULL, NSK_JVMTI_INVALID_JLOCATION }, - { "threadRunningNative", "testedMethod", "()V", NULL, NULL, NULL, NSK_JVMTI_INVALID_JLOCATION } + { "threadRunning", "testedMethod", "()V", nullptr, nullptr, nullptr, NSK_JVMTI_INVALID_JLOCATION }, + { "threadEntering", "testedMethod", "()V", nullptr, nullptr, nullptr, NSK_JVMTI_INVALID_JLOCATION }, + { "threadWaiting", "testedMethod", "()V", nullptr, nullptr, nullptr, NSK_JVMTI_INVALID_JLOCATION }, + { "threadSleeping", "testedMethod", "()V", nullptr, nullptr, nullptr, NSK_JVMTI_INVALID_JLOCATION }, + { "threadRunningInterrupted", "testedMethod", "()V", nullptr, nullptr, nullptr, NSK_JVMTI_INVALID_JLOCATION }, + { "threadRunningNative", "testedMethod", "()V", nullptr, nullptr, nullptr, NSK_JVMTI_INVALID_JLOCATION } }; /* indexes of known threads */ @@ -143,7 +143,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* agentJNI, void* arg) { * - make global refs */ static int prepare() { - jthread *allThreadsList = NULL; + jthread *allThreadsList = nullptr; jint allThreadsCount = 0; int found = 0; int i; @@ -152,8 +152,8 @@ static int prepare() { /* clean threads list */ for (i = 0; i < THREADS_COUNT; i++) { - threadsDesc[i].thread = (jthread)NULL; - threadsDesc[i].method = (jmethodID)NULL; + threadsDesc[i].thread = (jthread)nullptr; + threadsDesc[i].method = (jmethodID)nullptr; threadsDesc[i].location = NSK_JVMTI_INVALID_JLOCATION; } @@ -161,14 +161,14 @@ static int prepare() { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&allThreadsCount, &allThreadsList))) return NSK_FALSE; - if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != NULL)) + if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != nullptr)) return NSK_FALSE; /* find tested threads */ for (i = 0; i < allThreadsCount; i++) { jvmtiThreadInfo threadInfo; - if (!NSK_VERIFY(allThreadsList[i] != NULL)) + if (!NSK_VERIFY(allThreadsList[i] != nullptr)) return NSK_FALSE; /* get thread name (info) */ @@ -176,7 +176,7 @@ static int prepare() { return NSK_FALSE; /* find by name */ - if (threadInfo.name != NULL) { + if (threadInfo.name != nullptr) { int j; for (j = 0; j < THREADS_COUNT; j++) { @@ -196,7 +196,7 @@ static int prepare() { /* check if all tested threads found */ found = 0; for (i = 0; i < THREADS_COUNT; i++) { - if (threadsDesc[i].thread == NULL) { + if (threadsDesc[i].thread == nullptr) { NSK_COMPLAIN2("Not found tested thread #%d (%s)\n", i, threadsDesc[i].threadName); } else { found++; @@ -211,11 +211,11 @@ static int prepare() { for (i = 0; i < THREADS_COUNT; i++) { /* get thread class */ if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].cls = - jni->GetObjectClass(threadsDesc[i].thread)) != NULL)) + jni->GetObjectClass(threadsDesc[i].thread)) != nullptr)) return NSK_FALSE; /* get frame method */ if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].method = - jni->GetMethodID(threadsDesc[i].cls, threadsDesc[i].methodName, threadsDesc[i].methodSig)) != NULL)) + jni->GetMethodID(threadsDesc[i].cls, threadsDesc[i].methodName, threadsDesc[i].methodSig)) != nullptr)) return NSK_FALSE; NSK_DISPLAY4(" thread #%d (%s): %p (%s)\n", @@ -227,10 +227,10 @@ static int prepare() { /* make global refs */ for (i = 0; i < THREADS_COUNT; i++) { if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].thread = (jthread) - jni->NewGlobalRef(threadsDesc[i].thread)) != NULL)) + jni->NewGlobalRef(threadsDesc[i].thread)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].cls = (jclass) - jni->NewGlobalRef(threadsDesc[i].cls)) != NULL)) + jni->NewGlobalRef(threadsDesc[i].cls)) != nullptr)) return NSK_FALSE; } @@ -313,8 +313,8 @@ static int checkThreads(int suspended, const char* kind) { j, (void*)frameStack[j].method, (long)frameStack[j].location); /* check frame method */ - if (frameStack[j].method == NULL) { - NSK_COMPLAIN3("NULL methodID in stack for %s thread #%d (%s)\n", + if (frameStack[j].method == nullptr) { + NSK_COMPLAIN3("null methodID in stack for %s thread #%d (%s)\n", kind, i, threadsDesc[i].threadName); nsk_jvmti_setFailStatus(); } else if (frameStack[j].method == threadsDesc[i].method) { @@ -419,7 +419,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add specific capabilities for suspending thread */ @@ -432,7 +432,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t003/sp02t003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t003/sp02t003.cpp index 20c758aed6c..0916f392a8b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t003/sp02t003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP02/sp02t003/sp02t003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -32,8 +32,8 @@ extern "C" { /* ============================================================================= */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* constants */ @@ -54,12 +54,12 @@ typedef struct { /* descriptions of tested threads */ static ThreadDesc threadsDesc[THREADS_COUNT] = { - { "threadRunning", "testedMethod", "()V", NULL, NULL, NULL, NSK_JVMTI_INVALID_JLOCATION }, - { "threadEntering", "testedMethod", "()V", NULL, NULL, NULL, NSK_JVMTI_INVALID_JLOCATION }, - { "threadWaiting", "testedMethod", "()V", NULL, NULL, NULL, NSK_JVMTI_INVALID_JLOCATION }, - { "threadSleeping", "testedMethod", "()V", NULL, NULL, NULL, NSK_JVMTI_INVALID_JLOCATION }, - { "threadRunningInterrupted", "testedMethod", "()V", NULL, NULL, NULL, NSK_JVMTI_INVALID_JLOCATION }, - { "threadRunningNative", "testedMethod", "()V", NULL, NULL, NULL, NSK_JVMTI_INVALID_JLOCATION } + { "threadRunning", "testedMethod", "()V", nullptr, nullptr, nullptr, NSK_JVMTI_INVALID_JLOCATION }, + { "threadEntering", "testedMethod", "()V", nullptr, nullptr, nullptr, NSK_JVMTI_INVALID_JLOCATION }, + { "threadWaiting", "testedMethod", "()V", nullptr, nullptr, nullptr, NSK_JVMTI_INVALID_JLOCATION }, + { "threadSleeping", "testedMethod", "()V", nullptr, nullptr, nullptr, NSK_JVMTI_INVALID_JLOCATION }, + { "threadRunningInterrupted", "testedMethod", "()V", nullptr, nullptr, nullptr, NSK_JVMTI_INVALID_JLOCATION }, + { "threadRunningNative", "testedMethod", "()V", nullptr, nullptr, nullptr, NSK_JVMTI_INVALID_JLOCATION } }; /* indexes of known threads */ @@ -144,7 +144,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* agentJNI, void* arg) { * - make global refs */ static int prepare() { - jthread *allThreadsList = NULL; + jthread *allThreadsList = nullptr; jint allThreadsCount = 0; int found = 0; int i; @@ -153,8 +153,8 @@ static int prepare() { /* clean threads list */ for (i = 0; i < THREADS_COUNT; i++) { - threadsDesc[i].thread = (jthread)NULL; - threadsDesc[i].method = (jmethodID)NULL; + threadsDesc[i].thread = (jthread)nullptr; + threadsDesc[i].method = (jmethodID)nullptr; threadsDesc[i].location = NSK_JVMTI_INVALID_JLOCATION; } @@ -162,14 +162,14 @@ static int prepare() { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&allThreadsCount, &allThreadsList))) return NSK_FALSE; - if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != NULL)) + if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != nullptr)) return NSK_FALSE; /* find tested threads */ for (i = 0; i < allThreadsCount; i++) { jvmtiThreadInfo threadInfo; - if (!NSK_VERIFY(allThreadsList[i] != NULL)) + if (!NSK_VERIFY(allThreadsList[i] != nullptr)) return NSK_FALSE; /* get thread name (info) */ @@ -177,7 +177,7 @@ static int prepare() { return NSK_FALSE; /* find by name */ - if (threadInfo.name != NULL) { + if (threadInfo.name != nullptr) { int j; for (j = 0; j < THREADS_COUNT; j++) { @@ -197,7 +197,7 @@ static int prepare() { /* check if all tested threads found */ found = 0; for (i = 0; i < THREADS_COUNT; i++) { - if (threadsDesc[i].thread == NULL) { + if (threadsDesc[i].thread == nullptr) { NSK_COMPLAIN2("Not found tested thread #%d (%s)\n", i, threadsDesc[i].threadName); } else { found++; @@ -212,11 +212,11 @@ static int prepare() { for (i = 0; i < THREADS_COUNT; i++) { /* get thread class */ if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].cls = - jni->GetObjectClass(threadsDesc[i].thread)) != NULL)) + jni->GetObjectClass(threadsDesc[i].thread)) != nullptr)) return NSK_FALSE; /* get frame method */ if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].method = - jni->GetMethodID(threadsDesc[i].cls, threadsDesc[i].methodName, threadsDesc[i].methodSig)) != NULL)) + jni->GetMethodID(threadsDesc[i].cls, threadsDesc[i].methodName, threadsDesc[i].methodSig)) != nullptr)) return NSK_FALSE; NSK_DISPLAY4(" thread #%d (%s): %p (%s)\n", @@ -228,10 +228,10 @@ static int prepare() { /* make global refs */ for (i = 0; i < THREADS_COUNT; i++) { if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].thread = (jthread) - jni->NewGlobalRef(threadsDesc[i].thread)) != NULL)) + jni->NewGlobalRef(threadsDesc[i].thread)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].cls = (jclass) - jni->NewGlobalRef(threadsDesc[i].cls)) != NULL)) + jni->NewGlobalRef(threadsDesc[i].cls)) != nullptr)) return NSK_FALSE; } @@ -297,7 +297,7 @@ static int checkThreads(int suspended, const char* kind) { found = 0; for (j = 0; j < frameStackSize; j++) { - jmethodID qMethod = (jmethodID)NULL; + jmethodID qMethod = (jmethodID)nullptr; jlocation qLocation = NSK_JVMTI_INVALID_JLOCATION; NSK_DISPLAY3(" %d frame: method: %p, location: %ld\n", @@ -432,7 +432,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add specific capabilities for suspending thread */ { @@ -444,7 +444,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP03/sp03t001/sp03t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP03/sp03t001/sp03t001.cpp index b0560a13a1f..8ce99cf73a1 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP03/sp03t001/sp03t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP03/sp03t001/sp03t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -32,8 +32,8 @@ extern "C" { /* ============================================================================= */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* number of tested threads */ @@ -146,7 +146,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* agentJNI, void* arg) { * - make global refs */ static int prepare() { - jthread *allThreadsList = NULL; + jthread *allThreadsList = nullptr; jint allThreadsCount = 0; int notfound = 0; int i, j; @@ -156,14 +156,14 @@ static int prepare() { /* allocate and clean threads list */ for (i = 0; i < THREADS_KINDS; i++) { threadsCounts[i] = 0; - threadsList[i] = NULL; + threadsList[i] = nullptr; if (!NSK_JVMTI_VERIFY(jvmti->Allocate(threadsCount * sizeof(jthread), (unsigned char**)&threadsList[i]))) return NSK_FALSE; for (j = 0; j < threadsCount; j++) { - threadsList[i][j] = NULL; + threadsList[i][j] = nullptr; } } @@ -171,14 +171,14 @@ static int prepare() { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&allThreadsCount, &allThreadsList))) return NSK_FALSE; - if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != NULL)) + if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != nullptr)) return NSK_FALSE; /* find tested threads */ for (i = 0; i < allThreadsCount; i++) { jvmtiThreadInfo threadInfo; - if (!NSK_VERIFY(allThreadsList[i] != NULL)) + if (!NSK_VERIFY(allThreadsList[i] != nullptr)) return NSK_FALSE; /* get thread name (info) */ @@ -186,7 +186,7 @@ static int prepare() { return NSK_FALSE; /* find by name */ - if (threadInfo.name != NULL) { + if (threadInfo.name != nullptr) { for (j = 0; j < THREADS_KINDS; j++) { if (strcmp(threadInfo.name, threadsName[j]) == 0) { int k = threadsCounts[j]; @@ -222,7 +222,7 @@ static int prepare() { for (i = 0; i < THREADS_KINDS; i++) { for (j = 0; j < threadsCount; j++) { if (!NSK_JNI_VERIFY(jni, (threadsList[i][j] = - jni->NewGlobalRef(threadsList[i][j])) != NULL)) + jni->NewGlobalRef(threadsList[i][j])) != nullptr)) return NSK_FALSE; } } @@ -235,7 +235,7 @@ static int prepare() { */ static int suspendThreadsList(int suspend) { jlong resultsSize = threadsCount * sizeof(jvmtiError); - jvmtiError* results = NULL; + jvmtiError* results = nullptr; const char* kind = (suspend ? "suspending" : "resuming"); int i, j; @@ -368,7 +368,7 @@ static int clean() { for (i = 0; i < THREADS_KINDS; i++) { if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threadsList[i]))) return NSK_FALSE; - threadsList[i] = NULL; + threadsList[i] = nullptr; } return NSK_TRUE; @@ -443,7 +443,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add specific capabilities for suspending thread */ @@ -456,7 +456,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP03/sp03t002/sp03t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP03/sp03t002/sp03t002.cpp index 986d1113fc6..3001cb25902 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP03/sp03t002/sp03t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP03/sp03t002/sp03t002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -32,8 +32,8 @@ extern "C" { /* ============================================================================= */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* number of tested threads */ @@ -149,7 +149,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* agentJNI, void* arg) { * - make global refs */ static int prepare() { - jthread *allThreadsList = NULL; + jthread *allThreadsList = nullptr; jint allThreadsCount = 0; int notfound = 0; int i, j; @@ -159,14 +159,14 @@ static int prepare() { /* allocate and clean threads list */ for (i = 0; i < THREADS_KINDS; i++) { threadsCounts[i] = 0; - threadsList[i] = NULL; + threadsList[i] = nullptr; if (!NSK_JVMTI_VERIFY(jvmti->Allocate(threadsCount * sizeof(jthread), (unsigned char**)&threadsList[i]))) return NSK_FALSE; for (j = 0; j < threadsCount; j++) { - threadsList[i][j] = NULL; + threadsList[i][j] = nullptr; } } @@ -174,14 +174,14 @@ static int prepare() { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&allThreadsCount, &allThreadsList))) return NSK_FALSE; - if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != NULL)) + if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != nullptr)) return NSK_FALSE; /* find tested threads */ for (i = 0; i < allThreadsCount; i++) { jvmtiThreadInfo threadInfo; - if (!NSK_VERIFY(allThreadsList[i] != NULL)) + if (!NSK_VERIFY(allThreadsList[i] != nullptr)) return NSK_FALSE; /* get thread name (info) */ @@ -189,7 +189,7 @@ static int prepare() { return NSK_FALSE; /* find by name */ - if (threadInfo.name != NULL) { + if (threadInfo.name != nullptr) { for (j = 0; j < THREADS_KINDS; j++) { if (strcmp(threadInfo.name, threadsName[j]) == 0) { int k = threadsCounts[j]; @@ -225,7 +225,7 @@ static int prepare() { for (i = 0; i < THREADS_KINDS; i++) { for (j = 0; j < threadsCount; j++) { if (!NSK_JNI_VERIFY(jni, (threadsList[i][j] = - jni->NewGlobalRef(threadsList[i][j])) != NULL)) + jni->NewGlobalRef(threadsList[i][j])) != nullptr)) return NSK_FALSE; } } @@ -238,7 +238,7 @@ static int prepare() { */ static int suspendThreadsList(int suspend) { jlong resultsSize = threadsCount * sizeof(jvmtiError); - jvmtiError* results = NULL; + jvmtiError* results = nullptr; const char* kind = (suspend ? "suspending" : "resuming"); int i, j; @@ -371,7 +371,7 @@ static int clean() { for (i = 0; i < THREADS_KINDS; i++) { if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threadsList[i]))) return NSK_FALSE; - threadsList[i] = NULL; + threadsList[i] = nullptr; } return NSK_TRUE; @@ -446,7 +446,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add specific capabilities for suspending thread */ @@ -459,7 +459,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP04/sp04t001/sp04t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP04/sp04t001/sp04t001.cpp index 45657600f9e..f05ae7e81f8 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP04/sp04t001/sp04t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP04/sp04t001/sp04t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -32,8 +32,8 @@ extern "C" { /* ============================================================================= */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* number of tested threads */ @@ -146,7 +146,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* agentJNI, void* arg) { * - make global refs */ static int prepare() { - jthread *allThreadsList = NULL; + jthread *allThreadsList = nullptr; jint allThreadsCount = 0; int notfound = 0; int i, j; @@ -156,14 +156,14 @@ static int prepare() { /* allocate and clean threads list */ for (i = 0; i < THREADS_KINDS; i++) { threadsCounts[i] = 0; - threadsList[i] = NULL; + threadsList[i] = nullptr; if (!NSK_JVMTI_VERIFY(jvmti->Allocate(threadsCount * sizeof(jthread), (unsigned char**)&threadsList[i]))) return NSK_FALSE; for (j = 0; j < threadsCount; j++) { - threadsList[i][j] = NULL; + threadsList[i][j] = nullptr; } } @@ -171,14 +171,14 @@ static int prepare() { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&allThreadsCount, &allThreadsList))) return NSK_FALSE; - if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != NULL)) + if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != nullptr)) return NSK_FALSE; /* find tested threads */ for (i = 0; i < allThreadsCount; i++) { jvmtiThreadInfo threadInfo; - if (!NSK_VERIFY(allThreadsList[i] != NULL)) + if (!NSK_VERIFY(allThreadsList[i] != nullptr)) return NSK_FALSE; /* get thread name (info) */ @@ -186,7 +186,7 @@ static int prepare() { return NSK_FALSE; /* find by name */ - if (threadInfo.name != NULL) { + if (threadInfo.name != nullptr) { for (j = 0; j < THREADS_KINDS; j++) { if (strcmp(threadInfo.name, threadsName[j]) == 0) { int k = threadsCounts[j]; @@ -222,7 +222,7 @@ static int prepare() { for (i = 0; i < THREADS_KINDS; i++) { for (j = 0; j < threadsCount; j++) { if (!NSK_JNI_VERIFY(jni, (threadsList[i][j] = - jni->NewGlobalRef(threadsList[i][j])) != NULL)) + jni->NewGlobalRef(threadsList[i][j])) != nullptr)) return NSK_FALSE; } } @@ -235,7 +235,7 @@ static int prepare() { */ static int suspendThreadsList(int suspend) { jlong resultsSize = threadsCount * sizeof(jvmtiError); - jvmtiError* results = NULL; + jvmtiError* results = nullptr; const char* kind = (suspend ? "suspending" : "resuming"); int i, j; @@ -368,7 +368,7 @@ static int clean() { for (i = 0; i < THREADS_KINDS; i++) { if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threadsList[i]))) return NSK_FALSE; - threadsList[i] = NULL; + threadsList[i] = nullptr; } return NSK_TRUE; @@ -443,7 +443,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add specific capabilities for suspending thread */ @@ -456,7 +456,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP04/sp04t002/sp04t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP04/sp04t002/sp04t002.cpp index 5122bd4fe55..dcd2cdfb176 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP04/sp04t002/sp04t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP04/sp04t002/sp04t002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -32,8 +32,8 @@ extern "C" { /* ============================================================================= */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* number of tested threads */ @@ -146,7 +146,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* agentJNI, void* arg) { * - make global refs */ static int prepare() { - jthread *allThreadsList = NULL; + jthread *allThreadsList = nullptr; jint allThreadsCount = 0; int notfound = 0; int i, j; @@ -156,14 +156,14 @@ static int prepare() { /* allocate and clean threads list */ for (i = 0; i < THREADS_KINDS; i++) { threadsCounts[i] = 0; - threadsList[i] = NULL; + threadsList[i] = nullptr; if (!NSK_JVMTI_VERIFY(jvmti->Allocate(threadsCount * sizeof(jthread), (unsigned char**)&threadsList[i]))) return NSK_FALSE; for (j = 0; j < threadsCount; j++) { - threadsList[i][j] = NULL; + threadsList[i][j] = nullptr; } } @@ -171,14 +171,14 @@ static int prepare() { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&allThreadsCount, &allThreadsList))) return NSK_FALSE; - if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != NULL)) + if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != nullptr)) return NSK_FALSE; /* find tested threads */ for (i = 0; i < allThreadsCount; i++) { jvmtiThreadInfo threadInfo; - if (!NSK_VERIFY(allThreadsList[i] != NULL)) + if (!NSK_VERIFY(allThreadsList[i] != nullptr)) return NSK_FALSE; /* get thread name (info) */ @@ -186,7 +186,7 @@ static int prepare() { return NSK_FALSE; /* find by name */ - if (threadInfo.name != NULL) { + if (threadInfo.name != nullptr) { for (j = 0; j < THREADS_KINDS; j++) { if (strcmp(threadInfo.name, threadsName[j]) == 0) { int k = threadsCounts[j]; @@ -222,7 +222,7 @@ static int prepare() { for (i = 0; i < THREADS_KINDS; i++) { for (j = 0; j < threadsCount; j++) { if (!NSK_JNI_VERIFY(jni, (threadsList[i][j] = - jni->NewGlobalRef(threadsList[i][j])) != NULL)) + jni->NewGlobalRef(threadsList[i][j])) != nullptr)) return NSK_FALSE; } } @@ -235,7 +235,7 @@ static int prepare() { */ static int suspendThreadsList(int suspend) { jlong resultsSize = threadsCount * sizeof(jvmtiError); - jvmtiError* results = NULL; + jvmtiError* results = nullptr; const char* kind = (suspend ? "suspending" : "resuming"); int i, j; @@ -368,7 +368,7 @@ static int clean() { for (i = 0; i < THREADS_KINDS; i++) { if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threadsList[i]))) return NSK_FALSE; - threadsList[i] = NULL; + threadsList[i] = nullptr; } return NSK_TRUE; @@ -443,7 +443,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add specific capabilities for suspending thread */ @@ -456,7 +456,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP05/sp05t002/sp05t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP05/sp05t002/sp05t002.cpp index 04a3b498e3f..94dfb9ead45 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP05/sp05t002/sp05t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP05/sp05t002/sp05t002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,8 +38,8 @@ extern "C" { #define THREADS_FIELD_SIG "[L" THREAD_CLASS_NAME ";" /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* number of tested threads and events */ @@ -143,7 +143,7 @@ static int enableEvents(jvmtiEventMode enable) { int i; for (i = 0; i < EVENTS_COUNT; i++) { - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(enable, eventsList[i], NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(enable, eventsList[i], nullptr))) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -159,24 +159,24 @@ static int enableEvents(jvmtiEventMode enable) { * - enable events */ static int prepare() { - jclass debugeeClass = NULL; - jfieldID threadsFieldID = NULL; - jobjectArray threadsArray = NULL; + jclass debugeeClass = nullptr; + jfieldID threadsFieldID = nullptr; + jobjectArray threadsArray = nullptr; jsize threadsArrayLength = 0; jsize i; /* find debugee class */ - if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != nullptr)) return NSK_FALSE; /* find static field with threads array */ if (!NSK_JNI_VERIFY(jni, (threadsFieldID = - jni->GetStaticFieldID(debugeeClass, THREADS_FIELD_NAME, THREADS_FIELD_SIG)) != NULL)) + jni->GetStaticFieldID(debugeeClass, THREADS_FIELD_NAME, THREADS_FIELD_SIG)) != nullptr)) return NSK_FALSE; /* get threads array from static field */ if (!NSK_JNI_VERIFY(jni, (threadsArray = (jobjectArray) - jni->GetStaticObjectField(debugeeClass, threadsFieldID)) != NULL)) + jni->GetStaticObjectField(debugeeClass, threadsFieldID)) != nullptr)) return NSK_FALSE; /* check array length */ @@ -187,14 +187,14 @@ static int prepare() { /* get each thread from array */ for (i = 0; i < THREADS_COUNT; i++) { if (!NSK_JNI_VERIFY(jni, (threadsList[i] = (jthread) - jni->GetObjectArrayElement(threadsArray, i)) != NULL)) + jni->GetObjectArrayElement(threadsArray, i)) != nullptr)) return NSK_FALSE; } /* make global references to threads */ for (i = 0; i < THREADS_COUNT; i++) { if (!NSK_JNI_VERIFY(jni, (threadsList[i] = (jthread) - jni->NewGlobalRef(threadsList[i])) != NULL)) + jni->NewGlobalRef(threadsList[i])) != nullptr)) return NSK_FALSE; } @@ -279,8 +279,8 @@ JNIEXPORT void JNICALL callbackThreadStart(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { int i; - /* check if thread is not NULL */ - if (!NSK_VERIFY(thread != NULL)) { + /* check if thread is not nullptr */ + if (!NSK_VERIFY(thread != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -306,8 +306,8 @@ JNIEXPORT void JNICALL callbackThreadEnd(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { int i; - /* check if thread is not NULL */ - if (!NSK_VERIFY(thread != NULL)) { + /* check if thread is not nullptr */ + if (!NSK_VERIFY(thread != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -388,7 +388,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* set events callbacks */ @@ -402,7 +402,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP05/sp05t003/sp05t003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP05/sp05t003/sp05t003.cpp index 455f88db20c..392ff86cb21 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP05/sp05t003/sp05t003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP05/sp05t003/sp05t003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,8 +41,8 @@ extern "C" { #define TIMEOUT_DELTA 1000 /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* number of tested threads and events */ @@ -100,7 +100,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* agentJNI, void* arg) { { eventsStart = 0; if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, NULL))) { + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, nullptr))) { nsk_jvmti_setFailStatus(); return; } @@ -121,7 +121,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* agentJNI, void* arg) { } if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_THREAD_START, NULL))) { + jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_THREAD_START, nullptr))) { nsk_jvmti_setFailStatus(); } @@ -150,7 +150,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* agentJNI, void* arg) { { eventsEnd = 0; if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_END, NULL))) { + jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_END, nullptr))) { nsk_jvmti_setFailStatus(); return; } @@ -171,7 +171,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* agentJNI, void* arg) { } if (!NSK_JVMTI_VERIFY( - jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_THREAD_END, NULL))) { + jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_THREAD_END, nullptr))) { nsk_jvmti_setFailStatus(); } @@ -231,24 +231,24 @@ static int resumeThreads(const char* kind) { * - make global refs */ static int prepare() { - jclass debugeeClass = NULL; - jfieldID threadsFieldID = NULL; - jobjectArray threadsArray = NULL; + jclass debugeeClass = nullptr; + jfieldID threadsFieldID = nullptr; + jobjectArray threadsArray = nullptr; jsize threadsArrayLength = 0; jsize i; /* find debugee class */ - if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != nullptr)) return NSK_FALSE; /* find static field with threads array */ if (!NSK_JNI_VERIFY(jni, (threadsFieldID = - jni->GetStaticFieldID(debugeeClass, THREADS_FIELD_NAME, THREADS_FIELD_SIG)) != NULL)) + jni->GetStaticFieldID(debugeeClass, THREADS_FIELD_NAME, THREADS_FIELD_SIG)) != nullptr)) return NSK_FALSE; /* get threads array from static field */ if (!NSK_JNI_VERIFY(jni, (threadsArray = (jobjectArray) - jni->GetStaticObjectField(debugeeClass, threadsFieldID)) != NULL)) + jni->GetStaticObjectField(debugeeClass, threadsFieldID)) != nullptr)) return NSK_FALSE; /* check array length */ @@ -259,14 +259,14 @@ static int prepare() { /* get each thread from array */ for (i = 0; i < THREADS_COUNT; i++) { if (!NSK_JNI_VERIFY(jni, (threadsList[i] = (jthread) - jni->GetObjectArrayElement(threadsArray, i)) != NULL)) + jni->GetObjectArrayElement(threadsArray, i)) != nullptr)) return NSK_FALSE; } /* make global references to threads */ for (i = 0; i < THREADS_COUNT; i++) { if (!NSK_JNI_VERIFY(jni, (threadsList[i] = (jthread) - jni->NewGlobalRef(threadsList[i])) != NULL)) + jni->NewGlobalRef(threadsList[i])) != nullptr)) return NSK_FALSE; } @@ -362,8 +362,8 @@ JNIEXPORT void JNICALL callbackThreadStart(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { int i; - /* check if thread is not NULL */ - if (!NSK_VERIFY(thread != NULL)) { + /* check if thread is not nullptr */ + if (!NSK_VERIFY(thread != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -397,8 +397,8 @@ JNIEXPORT void JNICALL callbackThreadEnd(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) { int i; - /* check if thread is not NULL */ - if (!NSK_VERIFY(thread != NULL)) { + /* check if thread is not nullptr */ + if (!NSK_VERIFY(thread != nullptr)) { nsk_jvmti_setFailStatus(); return; } @@ -487,7 +487,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* add capabilities for suspending thread */ @@ -510,7 +510,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t001/sp06t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t001/sp06t001.cpp index 4f46a0fd08e..cde5a717c8c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t001/sp06t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t001/sp06t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -32,8 +32,8 @@ extern "C" { /* ============================================================================= */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* constants */ @@ -62,12 +62,12 @@ typedef struct { /* descriptions of tested threads */ static ThreadDesc threadsDesc[THREADS_COUNT] = { - { "threadRunning", "testedMethod", "(ZI)V", 2, NULL, NULL, NULL, NSK_FALSE }, - { "threadEntering", "testedMethod", "(ZI)V", 2, NULL, NULL, NULL, NSK_FALSE }, - { "threadWaiting", "testedMethod", "(ZI)V", 2, NULL, NULL, NULL, NSK_FALSE }, - { "threadSleeping", "testedMethod", "(ZI)V", 2, NULL, NULL, NULL, NSK_FALSE }, - { "threadRunningInterrupted", "testedMethod", "(ZI)V", 2, NULL, NULL, NULL, NSK_FALSE }, - { "threadRunningNative", "testedMethod", "(ZI)V", 2, NULL, NULL, NULL, NSK_FALSE } + { "threadRunning", "testedMethod", "(ZI)V", 2, nullptr, nullptr, nullptr, NSK_FALSE }, + { "threadEntering", "testedMethod", "(ZI)V", 2, nullptr, nullptr, nullptr, NSK_FALSE }, + { "threadWaiting", "testedMethod", "(ZI)V", 2, nullptr, nullptr, nullptr, NSK_FALSE }, + { "threadSleeping", "testedMethod", "(ZI)V", 2, nullptr, nullptr, nullptr, NSK_FALSE }, + { "threadRunningInterrupted", "testedMethod", "(ZI)V", 2, nullptr, nullptr, nullptr, NSK_FALSE }, + { "threadRunningNative", "testedMethod", "(ZI)V", 2, nullptr, nullptr, nullptr, NSK_FALSE } }; /* indexes of known threads */ @@ -152,7 +152,7 @@ static int generateEvents() { * - enable events */ static int prepare() { - jthread *allThreadsList = NULL; + jthread *allThreadsList = nullptr; jint allThreadsCount = 0; int found = 0; int i; @@ -161,8 +161,8 @@ static int prepare() { /* clean threads list */ for (i = 0; i < THREADS_COUNT; i++) { - threadsDesc[i].thread = (jthread)NULL; - threadsDesc[i].method = (jmethodID)NULL; + threadsDesc[i].thread = (jthread)nullptr; + threadsDesc[i].method = (jmethodID)nullptr; threadsDesc[i].methodCompiled = NSK_FALSE; } @@ -170,20 +170,20 @@ static int prepare() { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&allThreadsCount, &allThreadsList))) return NSK_FALSE; - if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != NULL)) + if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != nullptr)) return NSK_FALSE; /* find tested threads */ for (i = 0; i < allThreadsCount; i++) { jvmtiThreadInfo threadInfo; - if (!NSK_VERIFY(allThreadsList[i] != NULL)) + if (!NSK_VERIFY(allThreadsList[i] != nullptr)) return NSK_FALSE; if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(allThreadsList[i], &threadInfo))) return NSK_FALSE; - if (threadInfo.name != NULL) { + if (threadInfo.name != nullptr) { int j; for (j = 0; j < THREADS_COUNT; j++) { @@ -203,7 +203,7 @@ static int prepare() { /* check if all tested threads found */ found = 0; for (i = 0; i < THREADS_COUNT; i++) { - if (threadsDesc[i].thread == NULL) { + if (threadsDesc[i].thread == nullptr) { NSK_COMPLAIN2("Not found tested thread #%d (%s)\n", i, threadsDesc[i].threadName); } else { found++; @@ -218,11 +218,11 @@ static int prepare() { for (i = 0; i < THREADS_COUNT; i++) { if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].cls = - jni->GetObjectClass(threadsDesc[i].thread)) != NULL)) + jni->GetObjectClass(threadsDesc[i].thread)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].method = - jni->GetMethodID(threadsDesc[i].cls, threadsDesc[i].methodName, threadsDesc[i].methodSig)) != NULL)) + jni->GetMethodID(threadsDesc[i].cls, threadsDesc[i].methodName, threadsDesc[i].methodSig)) != nullptr)) return NSK_FALSE; NSK_DISPLAY4(" thread #%d (%s): 0x%p (%s)\n", @@ -234,15 +234,15 @@ static int prepare() { /* make global refs */ for (i = 0; i < THREADS_COUNT; i++) { if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].thread = (jthread) - jni->NewGlobalRef(threadsDesc[i].thread)) != NULL)) + jni->NewGlobalRef(threadsDesc[i].thread)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].cls = (jclass) - jni->NewGlobalRef(threadsDesc[i].cls)) != NULL)) + jni->NewGlobalRef(threadsDesc[i].cls)) != nullptr)) return NSK_FALSE; } NSK_DISPLAY0("Enable tested events\n"); - if (!nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, eventsList, NULL)) + if (!nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, eventsList, nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -343,7 +343,7 @@ static int clean() { int i; NSK_DISPLAY0("Disable events\n"); - if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, eventsList, NULL)) + if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, eventsList, nullptr)) return NSK_FALSE; NSK_DISPLAY0("Dispose global references to threads\n"); @@ -474,7 +474,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; { @@ -495,7 +495,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t002/sp06t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t002/sp06t002.cpp index d8600af0d67..43e55d53988 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t002/sp06t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t002/sp06t002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -32,8 +32,8 @@ extern "C" { /* ============================================================================= */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* constants */ @@ -62,12 +62,12 @@ typedef struct { /* descriptions of tested threads */ static ThreadDesc threadsDesc[THREADS_COUNT] = { - { "threadRunning", "testedMethod", "(ZI)V", NULL, NULL, NULL, NSK_JVMTI_INVALID_JLOCATION, NSK_FALSE }, - { "threadEntering", "testedMethod", "(ZI)V", NULL, NULL, NULL, NSK_JVMTI_INVALID_JLOCATION, NSK_FALSE }, - { "threadWaiting", "testedMethod", "(ZI)V", NULL, NULL, NULL, NSK_JVMTI_INVALID_JLOCATION, NSK_FALSE }, - { "threadSleeping", "testedMethod", "(ZI)V", NULL, NULL, NULL, NSK_JVMTI_INVALID_JLOCATION, NSK_FALSE }, - { "threadRunningInterrupted", "testedMethod", "(ZI)V", NULL, NULL, NULL, NSK_JVMTI_INVALID_JLOCATION, NSK_FALSE }, - { "threadRunningNative", "testedMethod", "(ZI)V", NULL, NULL, NULL, NSK_JVMTI_INVALID_JLOCATION, NSK_FALSE } + { "threadRunning", "testedMethod", "(ZI)V", nullptr, nullptr, nullptr, NSK_JVMTI_INVALID_JLOCATION, NSK_FALSE }, + { "threadEntering", "testedMethod", "(ZI)V", nullptr, nullptr, nullptr, NSK_JVMTI_INVALID_JLOCATION, NSK_FALSE }, + { "threadWaiting", "testedMethod", "(ZI)V", nullptr, nullptr, nullptr, NSK_JVMTI_INVALID_JLOCATION, NSK_FALSE }, + { "threadSleeping", "testedMethod", "(ZI)V", nullptr, nullptr, nullptr, NSK_JVMTI_INVALID_JLOCATION, NSK_FALSE }, + { "threadRunningInterrupted", "testedMethod", "(ZI)V", nullptr, nullptr, nullptr, NSK_JVMTI_INVALID_JLOCATION, NSK_FALSE }, + { "threadRunningNative", "testedMethod", "(ZI)V", nullptr, nullptr, nullptr, NSK_JVMTI_INVALID_JLOCATION, NSK_FALSE } }; /* indexes of known threads */ @@ -160,7 +160,7 @@ static int generateEvents() { * - enable events */ static int prepare() { - jthread *allThreadsList = NULL; + jthread *allThreadsList = nullptr; jint allThreadsCount = 0; int found = 0; int i; @@ -169,8 +169,8 @@ static int prepare() { /* clean threads list */ for (i = 0; i < THREADS_COUNT; i++) { - threadsDesc[i].thread = (jthread)NULL; - threadsDesc[i].method = (jmethodID)NULL; + threadsDesc[i].thread = (jthread)nullptr; + threadsDesc[i].method = (jmethodID)nullptr; threadsDesc[i].location = NSK_JVMTI_INVALID_JLOCATION; threadsDesc[i].methodCompiled = NSK_FALSE; } @@ -179,20 +179,20 @@ static int prepare() { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&allThreadsCount, &allThreadsList))) return NSK_FALSE; - if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != NULL)) + if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != nullptr)) return NSK_FALSE; /* find tested threads */ for (i = 0; i < allThreadsCount; i++) { jvmtiThreadInfo threadInfo; - if (!NSK_VERIFY(allThreadsList[i] != NULL)) + if (!NSK_VERIFY(allThreadsList[i] != nullptr)) return NSK_FALSE; if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(allThreadsList[i], &threadInfo))) return NSK_FALSE; - if (threadInfo.name != NULL) { + if (threadInfo.name != nullptr) { int j; for (j = 0; j < THREADS_COUNT; j++) { @@ -212,7 +212,7 @@ static int prepare() { /* check if all tested threads found */ found = 0; for (i = 0; i < THREADS_COUNT; i++) { - if (threadsDesc[i].thread == NULL) { + if (threadsDesc[i].thread == nullptr) { NSK_COMPLAIN2("Not found tested thread #%d (%s)\n", i, threadsDesc[i].threadName); } else { found++; @@ -227,11 +227,11 @@ static int prepare() { for (i = 0; i < THREADS_COUNT; i++) { if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].cls = - jni->GetObjectClass(threadsDesc[i].thread)) != NULL)) + jni->GetObjectClass(threadsDesc[i].thread)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].method = - jni->GetMethodID(threadsDesc[i].cls, threadsDesc[i].methodName, threadsDesc[i].methodSig)) != NULL)) + jni->GetMethodID(threadsDesc[i].cls, threadsDesc[i].methodName, threadsDesc[i].methodSig)) != nullptr)) return NSK_FALSE; NSK_DISPLAY4(" thread #%d (%s): 0x%p (%s)\n", @@ -243,15 +243,15 @@ static int prepare() { /* make global refs */ for (i = 0; i < THREADS_COUNT; i++) { if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].thread = (jthread) - jni->NewGlobalRef(threadsDesc[i].thread)) != NULL)) + jni->NewGlobalRef(threadsDesc[i].thread)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].cls = (jclass) - jni->NewGlobalRef(threadsDesc[i].cls)) != NULL)) + jni->NewGlobalRef(threadsDesc[i].cls)) != nullptr)) return NSK_FALSE; } NSK_DISPLAY0("Enable tested events\n"); - if (!nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, eventsList, NULL)) + if (!nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, eventsList, nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -337,8 +337,8 @@ static int checkThreads(int suspended, const char* kind0) { j, (void*)frameStack[j].method, (long)frameStack[j].location); /* check frame method */ - if (frameStack[j].method == NULL) { - NSK_COMPLAIN3("NULL methodID in stack for %s thread #%d (%s)\n", + if (frameStack[j].method == nullptr) { + NSK_COMPLAIN3("null methodID in stack for %s thread #%d (%s)\n", kind, i, threadsDesc[i].threadName); nsk_jvmti_setFailStatus(); } else if (frameStack[j].method == threadsDesc[i].method) { @@ -372,7 +372,7 @@ static int clean() { int i; NSK_DISPLAY0("Disable events\n"); - if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, eventsList, NULL)) + if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, eventsList, nullptr)) return NSK_FALSE; NSK_DISPLAY0("Dispose global references to threads\n"); @@ -503,7 +503,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; { @@ -524,7 +524,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t003/sp06t003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t003/sp06t003.cpp index 5c06270a977..c396f623610 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t003/sp06t003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t003/sp06t003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -32,8 +32,8 @@ extern "C" { /* ============================================================================= */ /* scaffold objects */ -static JNIEnv* jni = NULL; -static jvmtiEnv *jvmti = NULL; +static JNIEnv* jni = nullptr; +static jvmtiEnv *jvmti = nullptr; static jlong timeout = 0; /* constants */ @@ -62,12 +62,12 @@ typedef struct { /* descriptions of tested threads */ static ThreadDesc threadsDesc[THREADS_COUNT] = { - { "threadRunning", "testedMethod", "(ZI)V", NULL, NULL, NULL, NSK_JVMTI_INVALID_JLOCATION, NSK_FALSE }, - { "threadEntering", "testedMethod", "(ZI)V", NULL, NULL, NULL, NSK_JVMTI_INVALID_JLOCATION, NSK_FALSE }, - { "threadWaiting", "testedMethod", "(ZI)V", NULL, NULL, NULL, NSK_JVMTI_INVALID_JLOCATION, NSK_FALSE }, - { "threadSleeping", "testedMethod", "(ZI)V", NULL, NULL, NULL, NSK_JVMTI_INVALID_JLOCATION, NSK_FALSE }, - { "threadRunningInterrupted", "testedMethod", "(ZI)V", NULL, NULL, NULL, NSK_JVMTI_INVALID_JLOCATION, NSK_FALSE }, - { "threadRunningNative", "testedMethod", "(ZI)V", NULL, NULL, NULL, NSK_JVMTI_INVALID_JLOCATION, NSK_FALSE } + { "threadRunning", "testedMethod", "(ZI)V", nullptr, nullptr, nullptr, NSK_JVMTI_INVALID_JLOCATION, NSK_FALSE }, + { "threadEntering", "testedMethod", "(ZI)V", nullptr, nullptr, nullptr, NSK_JVMTI_INVALID_JLOCATION, NSK_FALSE }, + { "threadWaiting", "testedMethod", "(ZI)V", nullptr, nullptr, nullptr, NSK_JVMTI_INVALID_JLOCATION, NSK_FALSE }, + { "threadSleeping", "testedMethod", "(ZI)V", nullptr, nullptr, nullptr, NSK_JVMTI_INVALID_JLOCATION, NSK_FALSE }, + { "threadRunningInterrupted", "testedMethod", "(ZI)V", nullptr, nullptr, nullptr, NSK_JVMTI_INVALID_JLOCATION, NSK_FALSE }, + { "threadRunningNative", "testedMethod", "(ZI)V", nullptr, nullptr, nullptr, NSK_JVMTI_INVALID_JLOCATION, NSK_FALSE } }; /* indexes of known threads */ @@ -160,7 +160,7 @@ static int generateEvents() { * - enable events */ static int prepare() { - jthread *allThreadsList = NULL; + jthread *allThreadsList = nullptr; jint allThreadsCount = 0; int found = 0; int i; @@ -169,8 +169,8 @@ static int prepare() { /* clean threads list */ for (i = 0; i < THREADS_COUNT; i++) { - threadsDesc[i].thread = (jthread)NULL; - threadsDesc[i].method = (jmethodID)NULL; + threadsDesc[i].thread = (jthread)nullptr; + threadsDesc[i].method = (jmethodID)nullptr; threadsDesc[i].location = NSK_JVMTI_INVALID_JLOCATION; threadsDesc[i].methodCompiled = NSK_FALSE; } @@ -179,20 +179,20 @@ static int prepare() { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&allThreadsCount, &allThreadsList))) return NSK_FALSE; - if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != NULL)) + if (!NSK_VERIFY(allThreadsCount > 0 && allThreadsList != nullptr)) return NSK_FALSE; /* find tested threads */ for (i = 0; i < allThreadsCount; i++) { jvmtiThreadInfo threadInfo; - if (!NSK_VERIFY(allThreadsList[i] != NULL)) + if (!NSK_VERIFY(allThreadsList[i] != nullptr)) return NSK_FALSE; if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(allThreadsList[i], &threadInfo))) return NSK_FALSE; - if (threadInfo.name != NULL) { + if (threadInfo.name != nullptr) { int j; for (j = 0; j < THREADS_COUNT; j++) { @@ -212,7 +212,7 @@ static int prepare() { /* check if all tested threads found */ found = 0; for (i = 0; i < THREADS_COUNT; i++) { - if (threadsDesc[i].thread == NULL) { + if (threadsDesc[i].thread == nullptr) { NSK_COMPLAIN2("Not found tested thread #%d (%s)\n", i, threadsDesc[i].threadName); } else { found++; @@ -227,11 +227,11 @@ static int prepare() { for (i = 0; i < THREADS_COUNT; i++) { if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].cls = - jni->GetObjectClass(threadsDesc[i].thread)) != NULL)) + jni->GetObjectClass(threadsDesc[i].thread)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].method = - jni->GetMethodID(threadsDesc[i].cls, threadsDesc[i].methodName, threadsDesc[i].methodSig)) != NULL)) + jni->GetMethodID(threadsDesc[i].cls, threadsDesc[i].methodName, threadsDesc[i].methodSig)) != nullptr)) return NSK_FALSE; NSK_DISPLAY4(" thread #%d (%s): 0x%p (%s)\n", @@ -243,15 +243,15 @@ static int prepare() { /* make global refs */ for (i = 0; i < THREADS_COUNT; i++) { if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].thread = (jthread) - jni->NewGlobalRef(threadsDesc[i].thread)) != NULL)) + jni->NewGlobalRef(threadsDesc[i].thread)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (threadsDesc[i].cls = (jclass) - jni->NewGlobalRef(threadsDesc[i].cls)) != NULL)) + jni->NewGlobalRef(threadsDesc[i].cls)) != nullptr)) return NSK_FALSE; } NSK_DISPLAY0("Enable tested events\n"); - if (!nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, eventsList, NULL)) + if (!nsk_jvmti_enableEvents(JVMTI_ENABLE, EVENTS_COUNT, eventsList, nullptr)) return NSK_FALSE; return NSK_TRUE; @@ -320,7 +320,7 @@ static int checkThreads(int suspended, const char* kind0) { found = 0; for (j = 0; j < frameStackSize; j++) { - jmethodID qMethod = (jmethodID)NULL; + jmethodID qMethod = (jmethodID)nullptr; jlocation qLocation = NSK_JVMTI_INVALID_JLOCATION; NSK_DISPLAY3(" %d frame: method: 0x%p, location: %ld\n", @@ -384,7 +384,7 @@ static int clean() { int i; NSK_DISPLAY0("Disable events\n"); - if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, eventsList, NULL)) + if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, eventsList, nullptr)) return NSK_FALSE; NSK_DISPLAY0("Dispose global references to threads\n"); @@ -515,7 +515,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { timeout = nsk_jvmti_getWaitTime() * 60 * 1000; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; { @@ -536,7 +536,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP07/sp07t001/sp07t001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP07/sp07t001/sp07t001.cpp index 0a9125332e0..eaf871eb405 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP07/sp07t001/sp07t001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP07/sp07t001/sp07t001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,9 +41,9 @@ static const jlong SAMPLING_INTERVAL = 10; static jlong timeout = 0; /* test objects */ -static jthread thread = NULL; -static jrawMonitorID waitLock = NULL; -static jrawMonitorID frameLock = NULL; +static jthread thread = nullptr; +static jrawMonitorID waitLock = nullptr; +static jrawMonitorID frameLock = nullptr; static int sampleCount = 0; static volatile int depth = 0; static jvmtiFrameInfo sampleStack[MAX_DEPTH]; @@ -55,7 +55,7 @@ static jvmtiFrameInfo frameBuffer[MAX_DEPTH]; static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { const char* THREAD_NAME = "Debuggee Thread"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; int i; @@ -65,12 +65,12 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -80,11 +80,11 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) { + if (info.name != nullptr && (strcmp(info.name, THREAD_NAME) == 0)) { thread = threads[i]; } - if (info.name != NULL) { + if (info.name != nullptr) { if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)info.name))) return NSK_FALSE; } @@ -94,7 +94,7 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threads))) return NSK_FALSE; - if (thread == NULL) { + if (thread == nullptr) { NSK_COMPLAIN0("Debuggee thread not found"); return NSK_FALSE; } @@ -123,27 +123,27 @@ static int wait_for(jvmtiEnv* jvmti, jlong millis) { static int displayFrameInfo(jvmtiEnv* jvmti, jint i) { char buffer[32]; - char *name = NULL; - char *signature = NULL; + char *name = nullptr; + char *signature = nullptr; - if (!NSK_JVMTI_VERIFY(jvmti->GetMethodName(frameBuffer[frameCount-1-i].method, &name, &signature, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->GetMethodName(frameBuffer[frameCount-1-i].method, &name, &signature, nullptr))) return NSK_FALSE; NSK_DISPLAY4(" got[%d] method: %s%s, location: %s\n", i, name, signature, jlong_to_string(frameBuffer[frameCount-1-i].location, buffer)); - if (name != NULL) + if (name != nullptr) jvmti->Deallocate((unsigned char*)name); - if (signature != NULL) + if (signature != nullptr) jvmti->Deallocate((unsigned char*)signature); - if (!NSK_JVMTI_VERIFY(jvmti->GetMethodName(sampleStack[i].method, &name, &signature, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->GetMethodName(sampleStack[i].method, &name, &signature, nullptr))) return NSK_FALSE; NSK_DISPLAY4(" exp[%d] method: %s%s, location: %s\n", i, name, signature, jlong_to_string(sampleStack[i].location, buffer)); - if (name != NULL) + if (name != nullptr) jvmti->Deallocate((unsigned char*)name); - if (signature != NULL) + if (signature != nullptr) jvmti->Deallocate((unsigned char*)signature); return NSK_TRUE; @@ -151,27 +151,27 @@ static int displayFrameInfo(jvmtiEnv* jvmti, jint i) { static int complainFrameInfo(jvmtiEnv* jvmti, jint i) { char buffer[32]; - char *name = NULL; - char *signature = NULL; + char *name = nullptr; + char *signature = nullptr; - if (!NSK_JVMTI_VERIFY(jvmti->GetMethodName(frameBuffer[frameCount-1-i].method, &name, &signature, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->GetMethodName(frameBuffer[frameCount-1-i].method, &name, &signature, nullptr))) return NSK_FALSE; NSK_COMPLAIN3(" got: method=%s%s, location=%s\n", name, signature, jlong_to_string(frameBuffer[frameCount-1-i].location, buffer)); - if (name != NULL) + if (name != nullptr) jvmti->Deallocate((unsigned char*)name); - if (signature != NULL) + if (signature != nullptr) jvmti->Deallocate((unsigned char*)signature); - if (!NSK_JVMTI_VERIFY(jvmti->GetMethodName(sampleStack[i].method, &name, &signature, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->GetMethodName(sampleStack[i].method, &name, &signature, nullptr))) return NSK_FALSE; NSK_COMPLAIN3(" expected: method=%s%s, location=%s\n", name, signature, jlong_to_string(sampleStack[i].location, buffer)); - if (name != NULL) + if (name != nullptr) jvmti->Deallocate((unsigned char*)name); - if (signature != NULL) + if (signature != nullptr) jvmti->Deallocate((unsigned char*)signature); return NSK_TRUE; @@ -257,8 +257,8 @@ JNIEXPORT jint JNICALL Java_nsk_jvmti_scenarios_sampling_SP07_sp07t001Thread_wrapper(JNIEnv* jni, jobject obj, jint i) { jint result = 0; - jclass klass = NULL; - jmethodID method = NULL; + jclass klass = nullptr; + jmethodID method = nullptr; jvmtiEnv* jvmti = nsk_jvmti_getAgentJVMTIEnv(); if (!NSK_VERIFY(depth < MAX_DEPTH)) { @@ -269,14 +269,14 @@ Java_nsk_jvmti_scenarios_sampling_SP07_sp07t001Thread_wrapper(JNIEnv* jni, if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorEnter(frameLock))) return NSK_FALSE; - if (!NSK_JVMTI_VERIFY(jvmti->GetFrameLocation(NULL, 1, &sampleStack[depth].method, &sampleStack[depth].location))) { + if (!NSK_JVMTI_VERIFY(jvmti->GetFrameLocation(nullptr, 1, &sampleStack[depth].method, &sampleStack[depth].location))) { nsk_jvmti_setFailStatus(); return 0; } depth++; - if (!NSK_JVMTI_VERIFY(jvmti->GetFrameLocation(NULL, 0, &sampleStack[depth].method, &sampleStack[depth].location))) { + if (!NSK_JVMTI_VERIFY(jvmti->GetFrameLocation(nullptr, 0, &sampleStack[depth].method, &sampleStack[depth].location))) { nsk_jvmti_setFailStatus(); return 0; } @@ -286,12 +286,12 @@ Java_nsk_jvmti_scenarios_sampling_SP07_sp07t001Thread_wrapper(JNIEnv* jni, if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorExit(frameLock))) return NSK_FALSE; - if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(obj)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(obj)) != nullptr)) { nsk_jvmti_setFailStatus(); return 0; } - if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "fibonacci", "(I)I")) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "fibonacci", "(I)I")) != nullptr)) { nsk_jvmti_setFailStatus(); return 0; } @@ -325,7 +325,7 @@ JNIEXPORT jint JNI_OnLoad_sp07t001(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; /* init framework and parse options */ if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) @@ -336,14 +336,14 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("frameLock", &frameLock))) return NSK_FALSE; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP07/sp07t002/sp07t002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP07/sp07t002/sp07t002.cpp index a83af49dc47..d256d87bdff 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP07/sp07t002/sp07t002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP07/sp07t002/sp07t002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,12 +41,12 @@ static const jlong SAMPLING_INTERVAL = 10; static jlong timeout = 0; /* test objects */ -static jthread thread = NULL; -static jrawMonitorID waitLock = NULL; -static jfieldID field = NULL; -static jmethodID methodRun = NULL; -static jmethodID methodCatcher = NULL; -static jmethodID methodThrower = NULL; +static jthread thread = nullptr; +static jrawMonitorID waitLock = nullptr; +static jfieldID field = nullptr; +static jmethodID methodRun = nullptr; +static jmethodID methodCatcher = nullptr; +static jmethodID methodThrower = nullptr; static jint MAX_LADDER = 0; static int sampleCount = 0; static jint frameCount = 0; @@ -57,10 +57,10 @@ static jvmtiFrameInfo frameBuffer[MAX_DEPTH]; static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { const char* THREAD_NAME = "Debuggee Thread"; jvmtiThreadInfo info; - jthread *threads = NULL; + jthread *threads = nullptr; jint threads_count = 0; - jclass klass = NULL; - jfieldID fid = NULL; + jclass klass = nullptr; + jfieldID fid = nullptr; int i; NSK_DISPLAY0("Prepare: find tested thread\n"); @@ -69,12 +69,12 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads))) return NSK_FALSE; - if (!NSK_VERIFY(threads_count > 0 && threads != NULL)) + if (!NSK_VERIFY(threads_count > 0 && threads != nullptr)) return NSK_FALSE; /* find tested thread */ for (i = 0; i < threads_count; i++) { - if (!NSK_VERIFY(threads[i] != NULL)) + if (!NSK_VERIFY(threads[i] != nullptr)) return NSK_FALSE; /* get thread information */ @@ -84,11 +84,11 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { NSK_DISPLAY3(" thread #%d (%s): %p\n", i, info.name, threads[i]); /* find by name */ - if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) { + if (info.name != nullptr && (strcmp(info.name, THREAD_NAME) == 0)) { thread = threads[i]; } - if (info.name != NULL) { + if (info.name != nullptr) { if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)info.name))) return NSK_FALSE; } @@ -98,37 +98,37 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threads))) return NSK_FALSE; - if (thread == NULL) { + if (thread == nullptr) { NSK_COMPLAIN0("Debuggee thread not found"); return NSK_FALSE; } /* get tested thread class */ - if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != nullptr)) return NSK_FALSE; /* get tested thread field 'MAX_LADDER' */ - if (!NSK_JNI_VERIFY(jni, (fid = jni->GetStaticFieldID(klass, "MAX_LADDER", "I")) != NULL)) + if (!NSK_JNI_VERIFY(jni, (fid = jni->GetStaticFieldID(klass, "MAX_LADDER", "I")) != nullptr)) return NSK_FALSE; MAX_LADDER = jni->GetStaticIntField(klass, fid); NSK_DISPLAY1("MAX_LADDER: %d\n", MAX_LADDER); /* get tested thread field 'depth' */ - if (!NSK_JNI_VERIFY(jni, (field = jni->GetFieldID(klass, "depth", "I")) != NULL)) + if (!NSK_JNI_VERIFY(jni, (field = jni->GetFieldID(klass, "depth", "I")) != nullptr)) return NSK_FALSE; /* get tested thread method 'run' */ - if (!NSK_JNI_VERIFY(jni, (methodRun = jni->GetMethodID(klass, "run", "()V")) != NULL)) + if (!NSK_JNI_VERIFY(jni, (methodRun = jni->GetMethodID(klass, "run", "()V")) != nullptr)) return NSK_FALSE; /* get tested thread method 'catcher' */ if (!NSK_JNI_VERIFY(jni, (methodCatcher = - jni->GetMethodID(klass, "catcher", "(II)V")) != NULL)) + jni->GetMethodID(klass, "catcher", "(II)V")) != nullptr)) return NSK_FALSE; /* get tested thread method 'thrower' */ - if (!NSK_JNI_VERIFY(jni, (methodThrower= jni->GetMethodID(klass, "thrower", "(I)V")) != NULL)) + if (!NSK_JNI_VERIFY(jni, (methodThrower= jni->GetMethodID(klass, "thrower", "(I)V")) != nullptr)) return NSK_FALSE; if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("waitLock", &waitLock))) @@ -155,17 +155,17 @@ static int wait_for(jvmtiEnv* jvmti, jlong millis) { static int displayFrameInfo(jvmtiEnv* jvmti, jint i) { char buffer[32]; - char *name = NULL; - char *signature = NULL; + char *name = nullptr; + char *signature = nullptr; - if (!NSK_JVMTI_VERIFY(jvmti->GetMethodName(frameBuffer[frameCount-1-i].method, &name, &signature, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->GetMethodName(frameBuffer[frameCount-1-i].method, &name, &signature, nullptr))) return NSK_FALSE; NSK_DISPLAY4(" [%d] method: %s%s, location: %s\n", i, name, signature, jlong_to_string(frameBuffer[frameCount-1-i].location, buffer)); - if (name != NULL) + if (name != nullptr) jvmti->Deallocate((unsigned char*)name); - if (signature != NULL) + if (signature != nullptr) jvmti->Deallocate((unsigned char*)signature); return NSK_TRUE; @@ -173,20 +173,20 @@ static int displayFrameInfo(jvmtiEnv* jvmti, jint i) { static int complainFrameInfo(jvmtiEnv* jvmti, jint i, jmethodID method) { char buffer[32]; - char *name = NULL; - char *signature = NULL; + char *name = nullptr; + char *signature = nullptr; - if (!NSK_JVMTI_VERIFY(jvmti->GetMethodName(frameBuffer[frameCount-1-i].method, &name, &signature, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->GetMethodName(frameBuffer[frameCount-1-i].method, &name, &signature, nullptr))) return NSK_FALSE; NSK_COMPLAIN3(" got method: %s%s, location: %s\n", name, signature, jlong_to_string(frameBuffer[frameCount-1-i].location, buffer)); - if (name != NULL) + if (name != nullptr) jvmti->Deallocate((unsigned char*)name); - if (signature != NULL) + if (signature != nullptr) jvmti->Deallocate((unsigned char*)signature); - if (!NSK_JVMTI_VERIFY(jvmti->GetMethodName(method, &name, &signature, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->GetMethodName(method, &name, &signature, nullptr))) return NSK_FALSE; NSK_COMPLAIN2(" expected method: %s%s\n", name, signature); @@ -196,7 +196,7 @@ static int complainFrameInfo(jvmtiEnv* jvmti, jint i, jmethodID method) { static int checkStackTrace(jvmtiEnv* jvmti, JNIEnv* jni) { int res = NSK_TRUE; - jmethodID method = NULL; + jmethodID method = nullptr; jint depth; jint i; int displayFlag = @@ -288,7 +288,7 @@ JNIEXPORT jint JNI_OnLoad_sp07t002(JavaVM *jvm, char *options, void *reserved) { } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiCapabilities caps; /* init framework and parse options */ @@ -300,7 +300,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; memset(&caps, 0, sizeof(caps)); @@ -309,7 +309,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/FollowReferences/followref001/followref001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/FollowReferences/followref001/followref001.cpp index 08661336a14..e09e0040823 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/FollowReferences/followref001/followref001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/FollowReferences/followref001/followref001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -62,7 +62,7 @@ static int objectsCount = 0; static int fakeUserData = 0; static int userDataError = 0; -static ObjectDesc* objectDescList = NULL; +static ObjectDesc* objectDescList = nullptr; static const jlong ROOT_CLASS_TAG = 9; static const jlong CHAIN_CLASS_TAG = 99; @@ -95,8 +95,6 @@ static const char* ref_kind_str[28] = { "JVMTI_HEAP_REFERENCE_OTHER" }; -#define DEREF(ptr) (((ptr) == NULL ? 0 : *(ptr))) - /* ============================================================================= */ @@ -175,7 +173,7 @@ static bool getAndTagClasses(jvmtiEnv* jvmti, jclass* rootObjectClass, jclass* chainObjectClass) { - if (!NSK_JNI_VERIFY(jni, (*debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (*debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return false; } @@ -184,7 +182,7 @@ static bool getAndTagClasses(jvmtiEnv* jvmti, fflush(0); if (!NSK_JNI_VERIFY(jni, (*rootObjectClass = - jni->FindClass(ROOT_OBJECT_CLASS_NAME)) != NULL)) { + jni->FindClass(ROOT_OBJECT_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return false; } @@ -200,7 +198,7 @@ static bool getAndTagClasses(jvmtiEnv* jvmti, if (!NSK_JNI_VERIFY(jni, (*chainObjectClass = - jni->FindClass(CHAIN_OBJECT_CLASS_NAME)) != NULL)) { + jni->FindClass(CHAIN_OBJECT_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return false; } @@ -227,10 +225,10 @@ static bool getFieldsAndObjects(jvmtiEnv* jvmti, jfieldID* reachableChainField, jfieldID* unreachableChainField, jfieldID* nextField) { - jfieldID rootObjectField = NULL; + jfieldID rootObjectField = nullptr; if (!NSK_JNI_VERIFY(jni, (rootObjectField = - jni->GetStaticFieldID(debugeeClass, OBJECT_FIELD_NAME, ROOT_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetStaticFieldID(debugeeClass, OBJECT_FIELD_NAME, ROOT_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return false; } @@ -239,7 +237,7 @@ static bool getFieldsAndObjects(jvmtiEnv* jvmti, fflush(0); if (!NSK_JNI_VERIFY(jni, (*reachableChainField = - jni->GetFieldID(rootObjectClass, REACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetFieldID(rootObjectClass, REACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return false; } @@ -248,7 +246,7 @@ static bool getFieldsAndObjects(jvmtiEnv* jvmti, fflush(0); if (!NSK_JNI_VERIFY(jni, (*unreachableChainField = - jni->GetFieldID(rootObjectClass, UNREACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetFieldID(rootObjectClass, UNREACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return false; } @@ -258,7 +256,7 @@ static bool getFieldsAndObjects(jvmtiEnv* jvmti, fflush(0); if (!NSK_JNI_VERIFY(jni, (*nextField = - jni->GetFieldID(chainObjectClass, NEXT_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetFieldID(chainObjectClass, NEXT_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return false; } @@ -267,14 +265,14 @@ static bool getFieldsAndObjects(jvmtiEnv* jvmti, fflush(0); if (!NSK_JNI_VERIFY(jni, (*rootObjectPtr = - jni->GetStaticObjectField(debugeeClass, rootObjectField)) != NULL)) { + jni->GetStaticObjectField(debugeeClass, rootObjectField)) != nullptr)) { nsk_jvmti_setFailStatus(); return false; } printf("\nFound root object: 0x%p\n", (void*) *rootObjectPtr); fflush(0); - if (!NSK_JNI_VERIFY(jni, (*rootObjectPtr = jni->NewGlobalRef(*rootObjectPtr)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (*rootObjectPtr = jni->NewGlobalRef(*rootObjectPtr)) != nullptr)) { nsk_jvmti_setFailStatus(); return false; } @@ -296,7 +294,7 @@ static bool getAndTagChainObjects( ObjectDesc objectDescList[], jlong tag, bool reachable) { - jobject nextObj = NULL; + jobject nextObj = nullptr; jlong objTag = (reachable ? tag : -tag); if (count <= 0) { @@ -306,7 +304,7 @@ static bool getAndTagChainObjects( count--; tag++; - if (!NSK_JNI_VERIFY(jni, (nextObj = jni->GetObjectField(currObj, refField)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (nextObj = jni->GetObjectField(currObj, refField)) != nullptr)) { nsk_jvmti_setFailStatus(); return false; } @@ -350,13 +348,13 @@ static int getAndTagTestedObjects( ObjectDesc** objectDescList, jobject* rootObjectPtr) { - jclass debugeeClass = NULL; - jclass rootObjectClass = NULL; - jclass chainObjectClass = NULL; + jclass debugeeClass = nullptr; + jclass rootObjectClass = nullptr; + jclass chainObjectClass = nullptr; - jfieldID reachableChainField = NULL; - jfieldID unreachableChainField = NULL; - jfieldID nextField = NULL; + jfieldID reachableChainField = nullptr; + jfieldID unreachableChainField = nullptr; + jfieldID nextField = nullptr; if (!initObjectDescList(jvmti, chainLength, @@ -504,12 +502,12 @@ static void releaseTestedObjects(jvmtiEnv* jvmti, ObjectDesc* objectDescList, jobject rootObject) { - if (rootObject != NULL) { + if (rootObject != nullptr) { printf("Release object reference to root tested object: 0x%p\n", rootObject); NSK_TRACE(jni->DeleteGlobalRef(rootObject)); } - if (objectDescList != NULL) { + if (objectDescList != nullptr) { printf("Deallocate objects list: 0x%p\n", (void*)objectDescList); if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)objectDescList))) { nsk_jvmti_setFailStatus(); @@ -577,7 +575,7 @@ jint JNICALL heapReferenceCallback( nsk_jvmti_setFailStatus(); } - if (tag_ptr != NULL && *tag_ptr != 0) { + if (tag_ptr != nullptr && *tag_ptr != 0) { int found = 0; int i; @@ -724,7 +722,7 @@ jint JNICALL stringPrimitiveValueCallback( /** Agent algorithm. */ static void JNICALL agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { - jobject rootObject = NULL; + jobject rootObject = nullptr; printf("Wait for tested objects created\n"); fflush(0); @@ -760,7 +758,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { fflush(0); if (!NSK_JVMTI_VERIFY(jvmti->FollowReferences((jint) 0, /* heap_filter */ - (jclass) NULL, /* class */ + (jclass) nullptr, /* class */ rootObject, /* initial_object */ &heapCallbacks, (const void *) &fakeUserData))) { @@ -803,7 +801,7 @@ JNIEXPORT jint JNI_OnLoad_followref001(JavaVM *jvm, char *options, void *reserve } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) { return JNI_ERR; @@ -814,7 +812,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!NSK_VERIFY(chainLength > 0)) return JNI_ERR; - if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) { + if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) { return JNI_ERR; } @@ -829,13 +827,13 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } /* Setting Heap Callbacks */ - heapCallbacks.heap_iteration_callback = NULL; + heapCallbacks.heap_iteration_callback = nullptr; heapCallbacks.heap_reference_callback = heapReferenceCallback; heapCallbacks.primitive_field_callback = primitiveFieldCallback; heapCallbacks.array_primitive_value_callback = arrayPrimitiveValueCallback; heapCallbacks.string_primitive_value_callback = stringPrimitiveValueCallback; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) { + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) { return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/FollowReferences/followref002/followref002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/FollowReferences/followref002/followref002.cpp index ee1eff158d6..d84b3b37624 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/FollowReferences/followref002/followref002.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/FollowReferences/followref002/followref002.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -60,7 +60,7 @@ static int objectsCount = 0; static int fakeUserData = 0; static int userDataError = 0; -static ObjectDesc* objectDescList = NULL; +static ObjectDesc* objectDescList = nullptr; static jlong rootClassTag = 9; static jlong chainClassTag = 99; @@ -92,8 +92,6 @@ static const char* ref_kind_str[28] = { "JVMTI_HEAP_REFERENCE_OTHER" }; -#define DEREF(ptr) (((ptr) == NULL ? 0 : *(ptr))) - /* ============================================================================= */ /** Obtain chain of tested objects and tag them recursively. */ @@ -110,7 +108,7 @@ static int getAndTagChainObjects( jlong tag, int reachable) { - jobject obj = NULL; + jobject obj = nullptr; jlong objTag = (reachable ? tag : -tag); if (count <= 0) @@ -119,7 +117,7 @@ static int getAndTagChainObjects( count--; tag++; - if (!NSK_JNI_VERIFY(jni, (obj = jni->GetObjectField(firstObject, firstField)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (obj = jni->GetObjectField(firstObject, firstField)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -159,14 +157,14 @@ static int getAndTagTestedObjects( ObjectDesc** objectDescList, jobject* rootObject) { - jclass debugeeClass = NULL; - jclass rootObjectClass = NULL; - jclass chainObjectClass = NULL; + jclass debugeeClass = nullptr; + jclass rootObjectClass = nullptr; + jclass chainObjectClass = nullptr; - jfieldID objectField = NULL; - jfieldID reachableChainField = NULL; - jfieldID unreachableChainField = NULL; - jfieldID tailField = NULL; + jfieldID objectField = nullptr; + jfieldID reachableChainField = nullptr; + jfieldID unreachableChainField = nullptr; + jfieldID tailField = nullptr; /* root object + reachable and unreachable object chains */ *objectsCount = 1 + 2 * chainLength; @@ -194,7 +192,7 @@ static int getAndTagTestedObjects( printf("Find debugee class: %s\n", DEBUGEE_CLASS_NAME); fflush(0); - if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -202,7 +200,7 @@ static int getAndTagTestedObjects( printf("Find root object class: %s\n", ROOT_OBJECT_CLASS_NAME); fflush(0); - if (!NSK_JNI_VERIFY(jni, (rootObjectClass = jni->FindClass(ROOT_OBJECT_CLASS_NAME)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (rootObjectClass = jni->FindClass(ROOT_OBJECT_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -216,7 +214,7 @@ static int getAndTagTestedObjects( printf("Find chain object class: %s\n", CHAIN_OBJECT_CLASS_NAME); fflush(0); if (!NSK_JNI_VERIFY(jni, (chainObjectClass = - jni->FindClass(CHAIN_OBJECT_CLASS_NAME)) != NULL)) { + jni->FindClass(CHAIN_OBJECT_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -230,7 +228,7 @@ static int getAndTagTestedObjects( printf("Find static field in debugee class: %s\n", OBJECT_FIELD_NAME); fflush(0); if (!NSK_JNI_VERIFY(jni, (objectField = - jni->GetStaticFieldID(debugeeClass, OBJECT_FIELD_NAME, ROOT_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetStaticFieldID(debugeeClass, OBJECT_FIELD_NAME, ROOT_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -239,7 +237,7 @@ static int getAndTagTestedObjects( printf("Find instance field in root object class: %s\n", REACHABLE_CHAIN_FIELD_NAME); fflush(0); if (!NSK_JNI_VERIFY(jni, (reachableChainField = - jni->GetFieldID(rootObjectClass, REACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetFieldID(rootObjectClass, REACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -248,7 +246,7 @@ static int getAndTagTestedObjects( printf("Find instance field in root object class: %s\n", UNREACHABLE_CHAIN_FIELD_NAME); fflush(0); if (!NSK_JNI_VERIFY(jni, (unreachableChainField = - jni->GetFieldID(rootObjectClass, UNREACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetFieldID(rootObjectClass, UNREACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -257,7 +255,7 @@ static int getAndTagTestedObjects( printf("Find instance field in chain object class: %s\n", TAIL_FIELD_NAME); fflush(0); if (!NSK_JNI_VERIFY(jni, (tailField = - jni->GetFieldID(chainObjectClass, TAIL_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetFieldID(chainObjectClass, TAIL_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -266,14 +264,14 @@ static int getAndTagTestedObjects( printf("Get root object from static field: %s\n", OBJECT_FIELD_NAME); fflush(0); if (!NSK_JNI_VERIFY(jni, (*rootObject = - jni->GetStaticObjectField(debugeeClass, objectField)) != NULL)) { + jni->GetStaticObjectField(debugeeClass, objectField)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } printf(" ... got object: 0x%p\n", (void*)*rootObject); fflush(0); - if (!NSK_JNI_VERIFY(jni, (*rootObject = jni->NewGlobalRef(*rootObject)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (*rootObject = jni->NewGlobalRef(*rootObject)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -394,12 +392,12 @@ static int checkTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, /** Release references to the tested objects and free allocated memory. */ static int releaseTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, ObjectDesc* objectDescList, jobject rootObject) { - if (rootObject != NULL) { + if (rootObject != nullptr) { printf("Release object reference to root tested object: 0x%p\n", rootObject); NSK_TRACE(jni->DeleteGlobalRef(rootObject)); } - if (objectDescList != NULL) { + if (objectDescList != nullptr) { printf("Deallocate objects list: 0x%p\n", (void*)objectDescList); if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)objectDescList))) { nsk_jvmti_setFailStatus(); @@ -460,13 +458,13 @@ jint JNICALL heapReferenceCallback( (int) referrer_index); fflush(0); - if (tag_ptr == NULL) { - NSK_COMPLAIN1("NULL tag_ptr is passed to heapReferenceCallback:" + if (tag_ptr == nullptr) { + NSK_COMPLAIN1("null tag_ptr is passed to heapReferenceCallback:" " tag_ptr=0x%p\n", (void*)tag_ptr); nsk_jvmti_setFailStatus(); } - if (tag_ptr != NULL && *tag_ptr != 0) { + if (tag_ptr != nullptr && *tag_ptr != 0) { int found = 0; int i; @@ -601,7 +599,7 @@ jint JNICALL stringPrimitiveValueCallback( /** Agent algorithm. */ static void JNICALL agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { - jobject rootObject = NULL; + jobject rootObject = nullptr; printf("Wait for tested objects created\n"); fflush(0); @@ -635,7 +633,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { { jint heap_filter = JVMTI_HEAP_FILTER_UNTAGGED | JVMTI_HEAP_FILTER_CLASS_UNTAGGED; if (!NSK_JVMTI_VERIFY(jvmti->FollowReferences(heap_filter, - (jclass) NULL, /* class */ + (jclass) nullptr, /* class */ rootObject, /* initial_object */ &heapCallbacks, (const void *) &fakeUserData))) { @@ -668,7 +666,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { jint heap_filter = JVMTI_HEAP_FILTER_UNTAGGED | JVMTI_HEAP_FILTER_CLASS_UNTAGGED | JVMTI_HEAP_FILTER_TAGGED | JVMTI_HEAP_FILTER_CLASS_TAGGED; if (!NSK_JVMTI_VERIFY(jvmti->FollowReferences(heap_filter, - (jclass) NULL, /* class */ + (jclass) nullptr, /* class */ rootObject, /* initial_object */ &heapCallbacks, (const void *) &fakeUserData))) { @@ -714,7 +712,7 @@ JNIEXPORT jint JNI_OnLoad_followref002(JavaVM *jvm, char *options, void *reserve } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -726,7 +724,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; { @@ -740,13 +738,13 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } /* Setting Heap Callbacks */ - heapCallbacks.heap_iteration_callback = NULL; + heapCallbacks.heap_iteration_callback = nullptr; heapCallbacks.heap_reference_callback = heapReferenceCallback; heapCallbacks.primitive_field_callback = primitiveFieldCallback; heapCallbacks.array_primitive_value_callback = arrayPrimitiveValueCallback; heapCallbacks.string_primitive_value_callback = stringPrimitiveValueCallback; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/FollowReferences/followref003/followref003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/FollowReferences/followref003/followref003.cpp index 22892f71a36..197a50cea1f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/FollowReferences/followref003/followref003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/FollowReferences/followref003/followref003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ static int objectsCount = 0; static int fakeUserData = 0; static int userDataError = 0; -static ObjectDesc* objectDescList = NULL; +static ObjectDesc* objectDescList = nullptr; #define TARG_THREAD_TAG 11 #define FIRST_THREAD_TAG (TARG_THREAD_TAG + 1) @@ -118,9 +118,6 @@ static const char* ref_kind_str[28] = { }; -#define DEREF(ptr) (((ptr) == NULL ? 0 : *(ptr))) - - /* ============================================================================= */ /** Obtain chain of tested objects and tag them recursively. */ @@ -129,7 +126,7 @@ static int getChainObjects(jvmtiEnv* jvmti, JNIEnv* jni, jobject firstObject, jfieldID nextField, const char nextFieldName[], int count, ObjectDesc objectDescList[], jlong tag, int reachable) { - jobject obj = NULL; + jobject obj = nullptr; jlong objTag = (reachable ? tag : -tag); if (count <= 0) @@ -138,7 +135,7 @@ static int getChainObjects(jvmtiEnv* jvmti, JNIEnv* jni, jobject firstObject, count--; tag++; - if (!NSK_JNI_VERIFY(jni, (obj = jni->GetObjectField(firstObject, firstField)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (obj = jni->GetObjectField(firstObject, firstField)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -164,14 +161,14 @@ static int getChainObjects(jvmtiEnv* jvmti, JNIEnv* jni, jobject firstObject, static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, int *objectsCount, ObjectDesc* *objectDescList, jobject* rootObject) { - jclass debugeeClass = NULL; - jclass rootObjectClass = NULL; - jclass chainObjectClass = NULL; + jclass debugeeClass = nullptr; + jclass rootObjectClass = nullptr; + jclass chainObjectClass = nullptr; - jfieldID objectField = NULL; - jfieldID reachableChainField = NULL; - jfieldID unreachableChainField = NULL; - jfieldID tailField = NULL; + jfieldID objectField = nullptr; + jfieldID reachableChainField = nullptr; + jfieldID unreachableChainField = nullptr; + jfieldID tailField = nullptr; *objectsCount = 1 + 2 * chainLength; @@ -198,7 +195,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, printf("Find debugee class: %s\n", DEBUGEE_CLASS_NAME); fflush(0); - if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (debugeeClass = jni->FindClass(DEBUGEE_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -206,7 +203,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, printf("Find root object class: %s\n", ROOT_OBJECT_CLASS_NAME); fflush(0); - if (!NSK_JNI_VERIFY(jni, (rootObjectClass = jni->FindClass(ROOT_OBJECT_CLASS_NAME)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (rootObjectClass = jni->FindClass(ROOT_OBJECT_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -221,7 +218,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, printf("Find chain object class: %s\n", CHAIN_OBJECT_CLASS_NAME); fflush(0); if (!NSK_JNI_VERIFY(jni, (chainObjectClass = - jni->FindClass(CHAIN_OBJECT_CLASS_NAME)) != NULL)) { + jni->FindClass(CHAIN_OBJECT_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -237,7 +234,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, printf("Find static field in debugee class: %s\n", OBJECT_FIELD_NAME); fflush(0); if (!NSK_JNI_VERIFY(jni, (objectField = - jni->GetStaticFieldID(debugeeClass, OBJECT_FIELD_NAME, ROOT_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetStaticFieldID(debugeeClass, OBJECT_FIELD_NAME, ROOT_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -246,7 +243,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, printf("Find instance field in root object class: %s\n", REACHABLE_CHAIN_FIELD_NAME); fflush(0); if (!NSK_JNI_VERIFY(jni, (reachableChainField = - jni->GetFieldID(rootObjectClass, REACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetFieldID(rootObjectClass, REACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -255,7 +252,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, printf("Find instance field in root object class: %s\n", UNREACHABLE_CHAIN_FIELD_NAME); fflush(0); if (!NSK_JNI_VERIFY(jni, (unreachableChainField = - jni->GetFieldID(rootObjectClass, UNREACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetFieldID(rootObjectClass, UNREACHABLE_CHAIN_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -264,7 +261,7 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, printf("Find instance field in chain object class: %s\n", TAIL_FIELD_NAME); fflush(0); if (!NSK_JNI_VERIFY(jni, (tailField = - jni->GetFieldID(chainObjectClass, TAIL_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != NULL)) { + jni->GetFieldID(chainObjectClass, TAIL_FIELD_NAME, CHAIN_OBJECT_CLASS_SIG)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -273,14 +270,14 @@ static int getTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, printf("Get root object from static field: %s\n", OBJECT_FIELD_NAME); fflush(0); if (!NSK_JNI_VERIFY(jni, (*rootObject = - jni->GetStaticObjectField(debugeeClass, objectField)) != NULL)) { + jni->GetStaticObjectField(debugeeClass, objectField)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } printf(" ... got object: 0x%p\n", (void*)*rootObject); fflush(0); - if (!NSK_JNI_VERIFY(jni, (*rootObject = jni->NewGlobalRef(*rootObject)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (*rootObject = jni->NewGlobalRef(*rootObject)) != nullptr)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -394,12 +391,12 @@ static int checkTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, /** Release references to the tested objects and free allocated memory. */ static int releaseTestedObjects(jvmtiEnv* jvmti, JNIEnv* jni, int chainLength, ObjectDesc* objectDescList, jobject rootObject) { - if (rootObject != NULL) { + if (rootObject != nullptr) { printf("Release object reference to root tested object: 0x%p\n", rootObject); NSK_TRACE(jni->DeleteGlobalRef(rootObject)); } - if (objectDescList != NULL) { + if (objectDescList != nullptr) { printf("Deallocate objects list: 0x%p\n", (void*)objectDescList); if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)objectDescList))) { nsk_jvmti_setFailStatus(); @@ -469,8 +466,8 @@ static int registerFrame(jlong thr_id, jint depth, jmethodID method, * (Do we have to clarify this in the JVMTI spec?) * Do not consider the test as failing in such a case. */ - if (method == NULL && ref_kind != JVMTI_HEAP_REFERENCE_JNI_LOCAL) { - NSK_COMPLAIN0("methodID must not be NULL\n"); + if (method == nullptr && ref_kind != JVMTI_HEAP_REFERENCE_JNI_LOCAL) { + NSK_COMPLAIN0("methodID must not be null\n"); failed = 1; } if (failed) { @@ -590,7 +587,7 @@ jint JNICALL heapReferenceCallback( jint depth = -1; jint slot = -1; jint index = -1; - jmethodID method = (jmethodID) NULL; + jmethodID method = (jmethodID) nullptr; jlocation location = (jlocation)(-1); jlong tag = DEREF(tag_ptr); jlong ref_tag = DEREF(referrer_tag_ptr); @@ -670,13 +667,13 @@ jint JNICALL heapReferenceCallback( (int) index); fflush(0); - if (tag_ptr == NULL) { - NSK_COMPLAIN1("NULL tag_ptr is passed to heapReferenceCallback:" + if (tag_ptr == nullptr) { + NSK_COMPLAIN1("null tag_ptr is passed to heapReferenceCallback:" " tag_ptr=0x%p\n", (void*)tag_ptr); nsk_jvmti_setFailStatus(); } - if (tag_ptr != NULL && tag != 0) { + if (tag_ptr != nullptr && tag != 0) { int found = 0; int i; @@ -878,7 +875,7 @@ static jthread getTargetThread(jvmtiEnv *jvmti) { static const char *target_thread_name = "main"; jint i; jint thread_count = -1; - jthread *threads = NULL; + jthread *threads = nullptr; jvmti->GetAllThreads(&thread_count, &threads); @@ -891,7 +888,7 @@ static jthread getTargetThread(jvmtiEnv *jvmti) { } } - return NULL; + return nullptr; } static jvmtiError setTagForTargetThread(jvmtiEnv *jvmti, jlong tag) { @@ -902,7 +899,7 @@ static jvmtiError setTagForTargetThread(jvmtiEnv *jvmti, jlong tag) { /** Agent algorithm. */ static void JNICALL agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { - jobject rootObject = NULL; + jobject rootObject = nullptr; printf("Wait for tested objects created\n"); fflush(0); @@ -939,8 +936,8 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { fflush(0); { if (!NSK_JVMTI_VERIFY(jvmti->FollowReferences((jint) 0, /* heap_filter */ - (jclass) NULL, /* class */ - (jobject) NULL, /* initial_object */ + (jclass) nullptr, /* class */ + (jobject) nullptr, /* initial_object */ &heapCallbacks, (const void *) &fakeUserData))) { nsk_jvmti_setFailStatus(); @@ -977,8 +974,8 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { jint heap_filter = JVMTI_HEAP_FILTER_UNTAGGED | JVMTI_HEAP_FILTER_CLASS_UNTAGGED; if (!NSK_JVMTI_VERIFY(jvmti->FollowReferences(heap_filter, - (jclass) NULL, /* class */ - (jobject) NULL, /* initial_object */ + (jclass) nullptr, /* class */ + (jobject) nullptr, /* initial_object */ &heapCallbacks, (const void *) &fakeUserData))) { nsk_jvmti_setFailStatus(); @@ -1026,7 +1023,7 @@ JNIEXPORT jint JNI_OnLoad_followref003(JavaVM *jvm, char *options, void *reserve } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; @@ -1035,7 +1032,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { { const char* infoOpt = nsk_jvmti_findOptionValue("info"); - if (infoOpt != NULL) { + if (infoOpt != nullptr) { if (strcmp(infoOpt, "none") == 0) info = INFO_NONE; else if (strcmp(infoOpt, "all") == 0) @@ -1061,7 +1058,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; { @@ -1075,13 +1072,13 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } /* Setting Heap Callbacks */ - heapCallbacks.heap_iteration_callback = NULL; + heapCallbacks.heap_iteration_callback = nullptr; heapCallbacks.heap_reference_callback = heapReferenceCallback; heapCallbacks.primitive_field_callback = primitiveFieldCallback; heapCallbacks.array_primitive_value_callback = arrayPrimitiveValueCallback; heapCallbacks.string_primitive_value_callback = stringPrimitiveValueCallback; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/FollowReferences/followref004/followref004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/FollowReferences/followref004/followref004.cpp index a1831044057..c6c24999441 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/FollowReferences/followref004/followref004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/FollowReferences/followref004/followref004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -146,16 +146,16 @@ static void createGlobalRefs(JNIEnv * jni) { jclass klass; - if (!NSK_JNI_VERIFY(jni, (klass = jni->FindClass(JAVA_LANG_STRING_CLASS_NAME)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (klass = jni->FindClass(JAVA_LANG_STRING_CLASS_NAME)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } - if (!NSK_JNI_VERIFY(jni, (g_jniGlobalRef = jni->NewGlobalRef(klass)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (g_jniGlobalRef = jni->NewGlobalRef(klass)) != nullptr)) { nsk_jvmti_setFailStatus(); } - if (!NSK_JNI_VERIFY(jni, (g_jniWeakGlobalRef = jni->NewWeakGlobalRef(klass)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (g_jniWeakGlobalRef = jni->NewWeakGlobalRef(klass)) != nullptr)) { nsk_jvmti_setFailStatus(); } @@ -180,8 +180,8 @@ static void JNICALL agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) createGlobalRefs(jni); retCode = jvmti->FollowReferences((jint) 0, /* heap filter */ - NULL, /* class */ - NULL, /* inital object */ + nullptr, /* class */ + nullptr, /* inital object */ &g_heapCallbacks, (const void *) &g_fakeUserData); @@ -218,7 +218,7 @@ JNIEXPORT jint JNI_OnLoad_followref004(JavaVM *jvm, char *options, void *reserve #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) { return JNI_ERR; @@ -226,13 +226,13 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) g_timeout = nsk_jvmti_getWaitTime() * 60 * 1000; - if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) { + if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) { return JNI_ERR; } /* Setting Heap Callbacks */ memset(&g_heapCallbacks, 0, sizeof(g_heapCallbacks)); - g_heapCallbacks.heap_iteration_callback = NULL; + g_heapCallbacks.heap_iteration_callback = nullptr; g_heapCallbacks.heap_reference_callback = heapReferenceCallback; g_heapCallbacks.primitive_field_callback = primitiveFieldCallback; g_heapCallbacks.array_primitive_value_callback = arrayPrimitiveValueCallback; @@ -250,7 +250,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) } } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) { + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) { return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/FollowReferences/followref005/followref005.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/FollowReferences/followref005/followref005.cpp index 52b313b51c4..a8df86c3273 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/FollowReferences/followref005/followref005.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/FollowReferences/followref005/followref005.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,8 +46,8 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { " return an error if env. doesn't possess can_tag_objects capability\n"); retCode = jvmti->FollowReferences((jint) 0, /* heap filter */ - NULL, /* class */ - NULL, /* inital object */ + nullptr, /* class */ + nullptr, /* inital object */ &g_wrongHeapCallbacks, (const void *) &g_fakeUserData); @@ -57,7 +57,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { } retCode = jvmti->IterateThroughHeap((jint) 0, /* heap filter */ - NULL, /* class */ + nullptr, /* class */ &g_wrongHeapCallbacks, (const void *) &g_fakeUserData); @@ -115,7 +115,7 @@ JNIEXPORT jint JNI_OnLoad_followref005(JavaVM *jvm, char *options, void *reserve } #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) { return JNI_ERR; @@ -123,7 +123,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { g_timeout = nsk_jvmti_getWaitTime() * 60 * 1000; - if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) { + if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) { return JNI_ERR; } @@ -137,7 +137,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) { + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) { return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/FollowReferences/followref006/followref006.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/FollowReferences/followref006/followref006.cpp index cabd4696827..d161739de62 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/FollowReferences/followref006/followref006.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/FollowReferences/followref006/followref006.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ static void verifyReturnCodes(JNIEnv* jni, jvmtiEnv* jvmti) retCode = jvmti->FollowReferences((jint) 0, /* heap filter */ (jclass) &g_wrongHeapCallbacks , /* invalid class, but valid memory address */ - NULL, /* inital object */ + nullptr, /* inital object */ &g_wrongHeapCallbacks, (const void *) &g_fakeUserData); @@ -63,18 +63,18 @@ static void verifyReturnCodes(JNIEnv* jni, jvmtiEnv* jvmti) // When FollowReferences() is called with an invalid initial object // the behaviour according to the jvmti spec is optional. // It may return JVMTI_ERROR_INVALID_OBJECT and not follow any references. - // Or it may treat the object as NULL, and follow all references. + // Or it may treat the object as nullptr, and follow all references. // // We will accept both behaviours. We use empty callbacks since the existing // callback marks the test as failed. - emptyHeapCallbacks.heap_iteration_callback = NULL; - emptyHeapCallbacks.heap_reference_callback = NULL; - emptyHeapCallbacks.primitive_field_callback = NULL; - emptyHeapCallbacks.array_primitive_value_callback = NULL; - emptyHeapCallbacks.string_primitive_value_callback = NULL; + emptyHeapCallbacks.heap_iteration_callback = nullptr; + emptyHeapCallbacks.heap_reference_callback = nullptr; + emptyHeapCallbacks.primitive_field_callback = nullptr; + emptyHeapCallbacks.array_primitive_value_callback = nullptr; + emptyHeapCallbacks.string_primitive_value_callback = nullptr; retCode = jvmti->FollowReferences((jint) 0, // heap filter - NULL, // class + nullptr, // class (jobject) &g_wrongHeapCallbacks, // invalid inital object &emptyHeapCallbacks, // No callbacks (const void *) &g_fakeUserData); @@ -87,9 +87,9 @@ static void verifyReturnCodes(JNIEnv* jni, jvmtiEnv* jvmti) NSK_DISPLAY0("FollowReferences: Invalid callbacks:"); retCode = jvmti->FollowReferences((jint) 0, /* heap filter */ - NULL, /* class */ - NULL, /* inital object */ - NULL, + nullptr, /* class */ + nullptr, /* inital object */ + nullptr, (const void *) &g_fakeUserData); if (!NSK_VERIFY(retCode == JVMTI_ERROR_NULL_POINTER)) { @@ -105,17 +105,17 @@ static void verifyReturnCodes(JNIEnv* jni, jvmtiEnv* jvmti) nsk_jvmti_setFailStatus(); } - NSK_DISPLAY0("GetTag: NULL object pointer:"); + NSK_DISPLAY0("GetTag: null object pointer:"); - retCode = jvmti->GetTag(NULL, &tag); + retCode = jvmti->GetTag(nullptr, &tag); if (!NSK_VERIFY(retCode == JVMTI_ERROR_INVALID_OBJECT)) { nsk_jvmti_setFailStatus(); } - NSK_DISPLAY0("GetTag: NULL tag pointer:"); + NSK_DISPLAY0("GetTag: null tag pointer:"); - retCode = jvmti->GetTag((jobject) &g_wrongHeapCallbacks, NULL); + retCode = jvmti->GetTag((jobject) &g_wrongHeapCallbacks, nullptr); if (!NSK_VERIFY(retCode == JVMTI_ERROR_NULL_POINTER)) { nsk_jvmti_setFailStatus(); @@ -131,15 +131,15 @@ static void verifyReturnCodes(JNIEnv* jni, jvmtiEnv* jvmti) nsk_jvmti_setFailStatus(); } - NSK_DISPLAY0("SetTag: NULL object pointer:"); + NSK_DISPLAY0("SetTag: null object pointer:"); - retCode = jvmti->GetTag(NULL, &tag); + retCode = jvmti->GetTag(nullptr, &tag); if (!NSK_VERIFY(retCode == JVMTI_ERROR_INVALID_OBJECT)) { nsk_jvmti_setFailStatus(); } - NSK_DISPLAY0("GetTag: NULL tag pointer:"); + NSK_DISPLAY0("GetTag: null tag pointer:"); } /* verifyReturnCodes */ @@ -151,14 +151,14 @@ static void checkNoObjIterated(JNIEnv* jni, jvmtiEnv* jvmti, const char * szClas jclass klass; NSK_DISPLAY1("Verify, that no objects are returned if initial object is %s", szClassName); - if (!NSK_JNI_VERIFY(jni, (klass = jni->FindClass(szClassName)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (klass = jni->FindClass(szClassName)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } retCode = jvmti->FollowReferences((jint) 0, /* heap filter */ klass, /* class */ - NULL, /* inital object */ + nullptr, /* inital object */ &g_wrongHeapCallbacks, (const void *) &g_fakeUserData); @@ -211,7 +211,7 @@ JNIEXPORT jint JNI_OnLoad_followref006(JavaVM *jvm, char *options, void *reserve #endif jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) { return JNI_ERR; @@ -219,7 +219,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) g_timeout = nsk_jvmti_getWaitTime() * 60 * 1000; - if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) { + if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) { return JNI_ERR; } @@ -235,7 +235,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) } } - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) { + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) { return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretbase/earlyretbase.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretbase/earlyretbase.cpp index 9bca3a9c004..faa370694b4 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretbase/earlyretbase.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretbase/earlyretbase.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -35,7 +35,7 @@ extern "C" { #define RETURN_FAILED errCode = STATUS_FAILED; fflush(0); return errCode -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; @@ -51,7 +51,7 @@ static int errCode = PASSED; static const char *sig_exp = "()J"; static const char *name_exp = "activeMethod"; -static jmethodID midActiveMethod = NULL; +static jmethodID midActiveMethod = nullptr; void JNICALL MethodExit(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thr, @@ -84,13 +84,13 @@ Java_nsk_jvmti_unit_ForceEarlyReturn_earlyretbase_suspThread(JNIEnv *env, } jclass clazz = env->GetObjectClass(earlyretThr); - if (clazz == NULL) { + if (clazz == nullptr) { printf("Cannot get class of thread object\n"); RETURN_FAILED; } midActiveMethod = env->GetMethodID(clazz, name_exp, sig_exp); - if (midActiveMethod == NULL) { + if (midActiveMethod == nullptr) { printf("Cannot find Method ID for method %s\n", name_exp); RETURN_FAILED; } @@ -137,7 +137,7 @@ Java_nsk_jvmti_unit_ForceEarlyReturn_earlyretbase_doForceEarlyReturn(JNIEnv *env * that ForceEarlyReturn correctly generates them */ err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_METHOD_EXIT, NULL); + JVMTI_EVENT_METHOD_EXIT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable METHOD_EXIT event: %s (%d)\n", TranslateError(err), err); @@ -147,7 +147,7 @@ Java_nsk_jvmti_unit_ForceEarlyReturn_earlyretbase_doForceEarlyReturn(JNIEnv *env } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_FRAME_POP, NULL); + JVMTI_EVENT_FRAME_POP, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable FRAME_POP event: %s (%d)\n", TranslateError(err), err); @@ -197,7 +197,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong error code from a valid call to GetEnv!\n"); return JNI_ERR; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretfp/earlyretfp.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretfp/earlyretfp.cpp index 0feb076932d..d4353eb9dce 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretfp/earlyretfp.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretfp/earlyretfp.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,15 +36,15 @@ extern "C" { #define RETURN_FAILED errCode = STATUS_FAILED; fflush(0); return #define METHCNT 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; static jint errCode = PASSED; static jboolean printdump = JNI_TRUE; -static jmethodID midCheckPoint = NULL; -static jmethodID midRun = NULL; -static jmethodID midCountDownFloat = NULL; -static jmethodID midCountDownDouble = NULL; +static jmethodID midCheckPoint = nullptr; +static jmethodID midRun = nullptr; +static jmethodID midCountDownFloat = nullptr; +static jmethodID midCountDownDouble = nullptr; /* There is no synchronization for the counters because * they are incremented in single threaded mode. @@ -70,7 +70,7 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jmethodID mid, jclass cls; jlocation loc_exp = (i == 0) ? 0x16 : 0xd; char *sigClass, *name, *sig, *generic; - jvmtiLocalVariableEntry *table = NULL; + jvmtiLocalVariableEntry *table = nullptr; jint entryCount = 0; jint argValue; jint j; @@ -105,7 +105,7 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jmethodID mid, i, TranslateError(err), err); RETURN_FAILED; } - if (table != NULL) { + if (table != nullptr) { for (j = 0; j < entryCount; j++) { if (strcmp(table[j].name, argName) == 0) { err = jvmti_env->GetLocalInt(thr, 0, @@ -125,17 +125,17 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jmethodID mid, printf(", arg value: %d\n", argValue); } - if (sigClass == NULL || strcmp(sigClass, cls_exp) != 0) { + if (sigClass == nullptr || strcmp(sigClass, cls_exp) != 0) { printf("(step %d) wrong class sig: \"%s\",\n", i, sigClass); printf(" expected: \"%s\"\n", cls_exp); RETURN_FAILED; } - if (name == NULL || strcmp(name, name_exp[methidx]) != 0) { + if (name == nullptr || strcmp(name, name_exp[methidx]) != 0) { printf("(step %d) wrong method name: \"%s\",", i, name); printf(" expected: \"%s\"\n", name_exp[methidx]); RETURN_FAILED; } - if (sig == NULL || strcmp(sig, sig_exp[methidx]) != 0) { + if (sig == nullptr || strcmp(sig, sig_exp[methidx]) != 0) { printf("(step %d) wrong method sig: \"%s\",", i, sig); printf(" expected: \"%s\"\n", sig_exp[methidx]); RETURN_FAILED; @@ -153,16 +153,16 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jmethodID mid, RETURN_FAILED; } - if (sigClass != NULL) { + if (sigClass != nullptr) { jvmti_env->Deallocate((unsigned char*)sigClass); } - if (name != NULL) { + if (name != nullptr) { jvmti_env->Deallocate((unsigned char*)name); } - if (sig != NULL) { + if (sig != nullptr) { jvmti_env->Deallocate((unsigned char*)sig); } - if (table != NULL) { + if (table != nullptr) { for (j = 0; j < entryCount; j++) { jvmti_env->Deallocate((unsigned char*)(table[j].name)); jvmti_env->Deallocate((unsigned char*)(table[j].signature)); @@ -307,14 +307,14 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printf("Printdump is turned on!\n"); printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong error code from a valid call to GetEnv!\n"); return JNI_ERR; } @@ -370,7 +370,7 @@ Java_nsk_jvmti_unit_ForceEarlyReturn_earlyretfp_getReady( JNIEnv *env, jclass c, jclass cls, jint depth, jdouble retval) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); RETURN_FAILED; } @@ -383,25 +383,25 @@ Java_nsk_jvmti_unit_ForceEarlyReturn_earlyretfp_getReady( } midRun = env->GetMethodID(cls, "run", "()V"); - if (midRun == NULL) { + if (midRun == nullptr) { printf("Cannot find Method ID for method run\n"); RETURN_FAILED; } midCheckPoint = env->GetMethodID(cls, "checkPoint", "()V"); - if (midCheckPoint == NULL) { + if (midCheckPoint == nullptr) { printf("Cannot find Method ID for method checkPoint\n"); RETURN_FAILED; } midCountDownFloat = env->GetMethodID(cls, "countDownFloat", "(I)F"); - if (midCountDownFloat == NULL) { + if (midCountDownFloat == nullptr) { printf("Cannot find Method ID for method countDownFloat\n"); RETURN_FAILED; } midCountDownDouble = env->GetMethodID(cls, "countDownDouble", "(I)D"); - if (midCountDownDouble == NULL) { + if (midCountDownDouble == nullptr) { printf("Cannot find Method ID for method countDownDouble\n"); RETURN_FAILED; } @@ -414,7 +414,7 @@ Java_nsk_jvmti_unit_ForceEarlyReturn_earlyretfp_getReady( } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_BREAKPOINT, NULL); + JVMTI_EVENT_BREAKPOINT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable BREAKPOINT event: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretint/earlyretint.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretint/earlyretint.cpp index 071aa1db1f3..81c0a1e5ec8 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretint/earlyretint.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretint/earlyretint.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -35,20 +35,20 @@ extern "C" { #define RETURN_FAILED errCode = STATUS_FAILED; fflush(0); return -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; static jint errCode = PASSED; static jboolean printdump = JNI_TRUE; -static jmethodID midCheckPoint = NULL; -static jmethodID midRun = NULL; +static jmethodID midCheckPoint = nullptr; +static jmethodID midRun = nullptr; -static jmethodID midCountDownInt = NULL; -static jmethodID midCountDownShort = NULL; -static jmethodID midCountDownChar = NULL; -static jmethodID midCountDownByte = NULL; -static jmethodID midCountDownBoolean = NULL; +static jmethodID midCountDownInt = nullptr; +static jmethodID midCountDownShort = nullptr; +static jmethodID midCountDownChar = nullptr; +static jmethodID midCountDownByte = nullptr; +static jmethodID midCountDownBoolean = nullptr; static jint framesExpected = 0; static jint framesCount = 0; @@ -78,7 +78,7 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jmethodID mid, jclass cls; jlocation loc_exp = (i == 0) ? 0x21 : 0xd; char *sigClass, *name, *sig, *generic; - jvmtiLocalVariableEntry *table = NULL; + jvmtiLocalVariableEntry *table = nullptr; jint entryCount = 0; jint argValue = -i; jint j; @@ -106,17 +106,17 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jmethodID mid, RETURN_FAILED; } - if (sigClass == NULL || strcmp(sigClass, cls_exp) != 0) { + if (sigClass == nullptr || strcmp(sigClass, cls_exp) != 0) { printf("(step %d) Wrong class sig: \"%s\",\n", i, sigClass); printf(" expected: \"%s\"\n", cls_exp); RETURN_FAILED; } - if (name == NULL || strcmp(name, name_exp[methidx]) != 0) { + if (name == nullptr || strcmp(name, name_exp[methidx]) != 0) { printf("(step %d) wrong method name: \"%s\",", i, name); printf(" expected: \"%s\"\n", name_exp[methidx]); RETURN_FAILED; } - if (sig == NULL || strcmp(sig, sign_exp[methidx]) != 0) { + if (sig == nullptr || strcmp(sig, sign_exp[methidx]) != 0) { printf("(step %d) wrong method sig: \"%s\",", i, sig); printf(" expected: \"%s\"\n", sign_exp[methidx]); RETURN_FAILED; @@ -136,7 +136,7 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jmethodID mid, i, TranslateError(err), err); RETURN_FAILED; } - if (table != NULL) { + if (table != nullptr) { for (j = 0; j < entryCount; j++) { if (strcmp(table[j].name, argName) == 0) { err = jvmti_env->GetLocalInt(thr, 0, @@ -162,16 +162,16 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jmethodID mid, RETURN_FAILED; } - if (sigClass != NULL) { + if (sigClass != nullptr) { jvmti_env->Deallocate((unsigned char*)sigClass); } - if (name != NULL) { + if (name != nullptr) { jvmti_env->Deallocate((unsigned char*)name); } - if (sig != NULL) { + if (sig != nullptr) { jvmti_env->Deallocate((unsigned char*)sig); } - if (table != NULL) { + if (table != nullptr) { for (j = 0; j < entryCount; j++) { jvmti_env->Deallocate((unsigned char*)(table[j].name)); jvmti_env->Deallocate((unsigned char*)(table[j].signature)); @@ -313,14 +313,14 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printf("Printdump is turned on!\n"); printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong error code from a valid call to GetEnv!\n"); return JNI_ERR; } @@ -375,7 +375,7 @@ Java_nsk_jvmti_unit_ForceEarlyReturn_earlyretint_getReady( JNIEnv *env, jclass c, jclass cls, jint depth) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); RETURN_FAILED; } @@ -388,43 +388,43 @@ Java_nsk_jvmti_unit_ForceEarlyReturn_earlyretint_getReady( } midRun = env->GetMethodID(cls, "run", "()V"); - if (midRun == NULL) { + if (midRun == nullptr) { printf("Cannot find Method ID for method run\n"); RETURN_FAILED; } midCheckPoint = env->GetMethodID(cls, "checkPoint", "()V"); - if (midCheckPoint == NULL) { + if (midCheckPoint == nullptr) { printf("Cannot find Method ID for method checkPoint\n"); RETURN_FAILED; } midCountDownInt = env->GetMethodID(cls, "countDownInt", "(I)I"); - if (midCheckPoint == NULL) { + if (midCheckPoint == nullptr) { printf("Cannot find Method ID for method countDownInt\n"); RETURN_FAILED; } midCountDownShort = env->GetMethodID(cls, "countDownShort", "(I)S"); - if (midCountDownShort == NULL) { + if (midCountDownShort == nullptr) { printf("Cannot find Method ID for method countDownShort\n"); RETURN_FAILED; } midCountDownChar = env->GetMethodID(cls, "countDownChar", "(I)C"); - if (midCountDownChar == NULL) { + if (midCountDownChar == nullptr) { printf("Cannot find Method ID for method countDownChar\n"); RETURN_FAILED; } midCountDownByte = env->GetMethodID(cls, "countDownByte", "(I)B"); - if (midCountDownByte == NULL) { + if (midCountDownByte == nullptr) { printf("Cannot find Method ID for method countDownByte\n"); RETURN_FAILED; } midCountDownBoolean = env->GetMethodID(cls, "countDownBoolean", "(I)Z"); - if (midCountDownBoolean == NULL) { + if (midCountDownBoolean == nullptr) { printf("Cannot find Method ID for method countDownBoolean\n"); RETURN_FAILED; } @@ -437,7 +437,7 @@ Java_nsk_jvmti_unit_ForceEarlyReturn_earlyretint_getReady( } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_BREAKPOINT, NULL); + JVMTI_EVENT_BREAKPOINT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable BREAKPOINT event: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretlong/earlyretlong.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretlong/earlyretlong.cpp index 74f358e924b..7261fe3f621 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretlong/earlyretlong.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretlong/earlyretlong.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,15 +36,15 @@ extern "C" { #define RETURN_FAILED errCode = STATUS_FAILED; fflush(0); return -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; static jint errCode = PASSED; static jboolean printdump = JNI_TRUE; -static jmethodID midRun = NULL; -static jmethodID midCountDownLong = NULL; -static jmethodID midCheckPoint = NULL; +static jmethodID midRun = nullptr; +static jmethodID midCountDownLong = nullptr; +static jmethodID midCheckPoint = nullptr; static jint framesExpected = 0; static jint framesCount = 0; @@ -64,7 +64,7 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jmethodID mid, jclass cls; jlocation loc_exp = (frame_no == 0) ? 0x15 : 0xd; char *sigClass, *name, *sig, *generic; - jvmtiLocalVariableEntry *table = NULL; + jvmtiLocalVariableEntry *table = nullptr; jint entryCount = 0; jint argValue; jint j; @@ -99,7 +99,7 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jmethodID mid, frame_no, TranslateError(err), err); RETURN_FAILED; } - if (table != NULL) { + if (table != nullptr) { for (j = 0; j < entryCount; j++) { if (strcmp(table[j].name, argName) == 0) { err = jvmti_env->GetLocalInt(thr, 0, @@ -119,17 +119,17 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jmethodID mid, printf(", arg value: %d\n", argValue); } - if (sigClass == NULL || strcmp(sigClass, cls_exp) != 0) { + if (sigClass == nullptr || strcmp(sigClass, cls_exp) != 0) { printf("(step %d) Wrong class sig: \"%s\",\n", frame_no, sigClass); printf(" expected: \"%s\"\n", cls_exp); RETURN_FAILED; } - if (name == NULL || strcmp(name, name_exp) != 0) { + if (name == nullptr || strcmp(name, name_exp) != 0) { printf("(step %d) wrong method name: \"%s\",", frame_no, name); printf(" expected: \"%s\"\n", name_exp); RETURN_FAILED; } - if (sig == NULL || strcmp(sig, sig_exp) != 0) { + if (sig == nullptr || strcmp(sig, sig_exp) != 0) { printf("(step %d) wrong method sig: \"%s\",", frame_no, sig); printf(" expected: \"%s\"\n", sig_exp); RETURN_FAILED; @@ -146,16 +146,16 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jmethodID mid, RETURN_FAILED; } - if (sigClass != NULL) { + if (sigClass != nullptr) { jvmti_env->Deallocate((unsigned char*)sigClass); } - if (name != NULL) { + if (name != nullptr) { jvmti_env->Deallocate((unsigned char*)name); } - if (sig != NULL) { + if (sig != nullptr) { jvmti_env->Deallocate((unsigned char*)sig); } - if (table != NULL) { + if (table != nullptr) { for (j = 0; j < entryCount; j++) { jvmti_env->Deallocate((unsigned char*)(table[j].name)); jvmti_env->Deallocate((unsigned char*)(table[j].signature)); @@ -294,14 +294,14 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printf("Printdump is turned on!\n"); printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong error code from a valid call to GetEnv!\n"); return JNI_ERR; } @@ -357,7 +357,7 @@ Java_nsk_jvmti_unit_ForceEarlyReturn_earlyretlong_getReady( jvmtiError err; val_exp = retval_base; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); RETURN_FAILED; } @@ -370,19 +370,19 @@ Java_nsk_jvmti_unit_ForceEarlyReturn_earlyretlong_getReady( } midRun = env->GetMethodID(cls, "run", "()V"); - if (midRun == NULL) { + if (midRun == nullptr) { printf("Cannot find Method ID for method run\n"); RETURN_FAILED; } midCheckPoint = env->GetMethodID(cls, "checkPoint", "()V"); - if (midCheckPoint == NULL) { + if (midCheckPoint == nullptr) { printf("Cannot find Method ID for method checkPoint\n"); RETURN_FAILED; } midCountDownLong = env->GetMethodID(cls, "countDownLong", "(I)J"); - if (midCountDownLong == NULL) { + if (midCountDownLong == nullptr) { printf("Cannot find Method ID for method countDownLong\n"); RETURN_FAILED; } @@ -395,7 +395,7 @@ Java_nsk_jvmti_unit_ForceEarlyReturn_earlyretlong_getReady( } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_BREAKPOINT, NULL); + JVMTI_EVENT_BREAKPOINT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable BREAKPOINT event: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretobj/earlyretobj.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretobj/earlyretobj.cpp index 0cdbcb18029..b5f6a60f4c3 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretobj/earlyretobj.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretobj/earlyretobj.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,15 +36,15 @@ extern "C" { #define RETURN_FAILED errCode = STATUS_FAILED; fflush(0); return -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; static jint errCode = PASSED; static jboolean printdump = JNI_TRUE; -static jmethodID midRun = NULL; -static jmethodID midCountDownObject = NULL; -static jmethodID midCheckPoint = NULL; +static jmethodID midRun = nullptr; +static jmethodID midCountDownObject = nullptr; +static jmethodID midCheckPoint = nullptr; static jint framesExpected = 0; static jint framesCount = 0; @@ -52,7 +52,7 @@ static jint methodExitEventCount = 0; static const char *cls_exp = "Lnsk/jvmti/unit/ForceEarlyReturn/earlyretobj$earlyretThread;"; -static jobject val_exp = NULL; +static jobject val_exp = nullptr; static const char *sig_exp = "(I)Lnsk/jvmti/unit/ForceEarlyReturn/earlyretobj$RetObj;"; static const char *name_exp = "countDownObject"; @@ -64,7 +64,7 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jmethodID mid, jclass cls; jlocation loc_exp = (frame_no == 0) ? 0x15 : 0xd; char *sigClass, *name, *sig, *generic; - jvmtiLocalVariableEntry *table = NULL; + jvmtiLocalVariableEntry *table = nullptr; jint entryCount = 0; jint argValue; jint j; @@ -99,7 +99,7 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jmethodID mid, frame_no, TranslateError(err), err); RETURN_FAILED; } - if (table != NULL) { + if (table != nullptr) { for (j = 0; j < entryCount; j++) { if (strcmp(table[j].name, argName) == 0) { err = jvmti_env->GetLocalInt(thr, 0, @@ -119,17 +119,17 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jmethodID mid, printf(", arg value: %d\n", argValue); } - if (sigClass == NULL || strcmp(sigClass, cls_exp) != 0) { + if (sigClass == nullptr || strcmp(sigClass, cls_exp) != 0) { printf("(step %d) Wrong class sig: \"%s\",\n", frame_no, sigClass); printf(" expected: \"%s\"\n", cls_exp); RETURN_FAILED; } - if (name == NULL || strcmp(name, name_exp) != 0) { + if (name == nullptr || strcmp(name, name_exp) != 0) { printf("(step %d) wrong method name: \"%s\",", frame_no, name); printf(" expected: \"%s\"\n", name_exp); RETURN_FAILED; } - if (sig == NULL || strcmp(sig, sig_exp) != 0) { + if (sig == nullptr || strcmp(sig, sig_exp) != 0) { printf("(step %d) wrong method sig: \"%s\",", frame_no, sig); printf(" expected: \"%s\"\n", sig_exp); RETURN_FAILED; @@ -146,16 +146,16 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jmethodID mid, RETURN_FAILED; } - if (sigClass != NULL) { + if (sigClass != nullptr) { jvmti_env->Deallocate((unsigned char*)sigClass); } - if (name != NULL) { + if (name != nullptr) { jvmti_env->Deallocate((unsigned char*)name); } - if (sig != NULL) { + if (sig != nullptr) { jvmti_env->Deallocate((unsigned char*)sig); } - if (table != NULL) { + if (table != nullptr) { for (j = 0; j < entryCount; j++) { jvmti_env->Deallocate((unsigned char*)(table[j].name)); jvmti_env->Deallocate((unsigned char*)(table[j].signature)); @@ -292,14 +292,14 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printf("Printdump is turned on!\n"); printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong error code from a valid call to GetEnv!\n"); return JNI_ERR; } @@ -354,7 +354,7 @@ Java_nsk_jvmti_unit_ForceEarlyReturn_earlyretobj_getReady( JNIEnv *env, jclass c, jclass cls, jint depth, jobject ret_obj) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); RETURN_FAILED; } @@ -367,19 +367,19 @@ Java_nsk_jvmti_unit_ForceEarlyReturn_earlyretobj_getReady( } midRun = env->GetMethodID(cls, "run", "()V"); - if (midRun == NULL) { + if (midRun == nullptr) { printf("Cannot find Method ID for method run\n"); RETURN_FAILED; } midCheckPoint = env->GetMethodID(cls, "checkPoint", "()V"); - if (midCheckPoint == NULL) { + if (midCheckPoint == nullptr) { printf("Cannot find Method ID for method checkPoint\n"); RETURN_FAILED; } midCountDownObject = env->GetMethodID(cls, "countDownObject", sig_exp); - if (midCountDownObject == NULL) { + if (midCountDownObject == nullptr) { printf("Cannot find Method ID for method countDownObject\n"); RETURN_FAILED; } @@ -392,7 +392,7 @@ Java_nsk_jvmti_unit_ForceEarlyReturn_earlyretobj_getReady( } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_BREAKPOINT, NULL); + JVMTI_EVENT_BREAKPOINT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable BREAKPOINT event: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretstr/earlyretstr.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretstr/earlyretstr.cpp index 7622d1065b0..9629ebf46dc 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretstr/earlyretstr.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretstr/earlyretstr.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -35,15 +35,15 @@ extern "C" { #define RETURN_FAILED errCode = STATUS_FAILED; fflush(0); return -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; static jint errCode = PASSED; static jboolean printdump = JNI_TRUE; -static jmethodID midRun = NULL; -static jmethodID midCountDownString = NULL; -static jmethodID midCheckPoint = NULL; +static jmethodID midRun = nullptr; +static jmethodID midCountDownString = nullptr; +static jmethodID midCheckPoint = nullptr; static jint framesExpected = 0; static jint framesCount = 0; @@ -51,7 +51,7 @@ static jint methodExitEventCount = 0; static const char *cls_exp = "Lnsk/jvmti/unit/ForceEarlyReturn/earlyretstr$earlyretThread;"; -static jstring str_exp = NULL; +static jstring str_exp = nullptr; static const char *sig_exp = "(I)Ljava/lang/String;"; static const char *name_exp = "countDownString"; @@ -63,7 +63,7 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jmethodID mid, jclass cls; jlocation loc_exp = (frame_no == 0) ? 0x15 : 0xd; char *sigClass, *name, *sig, *generic; - jvmtiLocalVariableEntry *table = NULL; + jvmtiLocalVariableEntry *table = nullptr; jint entryCount = 0; jint argValue; jint j; @@ -98,7 +98,7 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jmethodID mid, frame_no, TranslateError(err), err); RETURN_FAILED; } - if (table != NULL) { + if (table != nullptr) { for (j = 0; j < entryCount; j++) { if (strcmp(table[j].name, argName) == 0) { err = jvmti_env->GetLocalInt(thr, 0, @@ -118,17 +118,17 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jmethodID mid, printf(", arg value: %d\n", argValue); } - if (sigClass == NULL || strcmp(sigClass, cls_exp) != 0) { + if (sigClass == nullptr || strcmp(sigClass, cls_exp) != 0) { printf("(step %d) Wrong class sig: \"%s\",\n", frame_no, sigClass); printf(" expected: \"%s\"\n", cls_exp); RETURN_FAILED; } - if (name == NULL || strcmp(name, name_exp) != 0) { + if (name == nullptr || strcmp(name, name_exp) != 0) { printf("(step %d) wrong method name: \"%s\",", frame_no, name); printf(" expected: \"%s\"\n", name_exp); RETURN_FAILED; } - if (sig == NULL || strcmp(sig, sig_exp) != 0) { + if (sig == nullptr || strcmp(sig, sig_exp) != 0) { printf("(step %d) wrong method sig: \"%s\",", frame_no, sig); printf(" expected: \"%s\"\n", sig_exp); RETURN_FAILED; @@ -145,16 +145,16 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jmethodID mid, RETURN_FAILED; } - if (sigClass != NULL) { + if (sigClass != nullptr) { jvmti_env->Deallocate((unsigned char*)sigClass); } - if (name != NULL) { + if (name != nullptr) { jvmti_env->Deallocate((unsigned char*)name); } - if (sig != NULL) { + if (sig != nullptr) { jvmti_env->Deallocate((unsigned char*)sig); } - if (table != NULL) { + if (table != nullptr) { for (j = 0; j < entryCount; j++) { jvmti_env->Deallocate((unsigned char*)(table[j].name)); jvmti_env->Deallocate((unsigned char*)(table[j].signature)); @@ -291,14 +291,14 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printf("Printdump is turned on!\n"); printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong error code of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -353,7 +353,7 @@ Java_nsk_jvmti_unit_ForceEarlyReturn_earlyretstr_getReady( JNIEnv *env, jclass c, jclass cls, jint depth, jstring expected_str) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); RETURN_FAILED; } @@ -366,19 +366,19 @@ Java_nsk_jvmti_unit_ForceEarlyReturn_earlyretstr_getReady( } midRun = env->GetMethodID(cls, "run", "()V"); - if (midRun == NULL) { + if (midRun == nullptr) { printf("Cannot find Method ID for method run\n"); RETURN_FAILED; } midCheckPoint = env->GetMethodID(cls, "checkPoint", "()V"); - if (midCheckPoint == NULL) { + if (midCheckPoint == nullptr) { printf("Cannot find Method ID for method checkPoint\n"); RETURN_FAILED; } midCountDownString = env->GetMethodID(cls, "countDownString", sig_exp); - if (midCountDownString == NULL) { + if (midCountDownString == nullptr) { printf("Cannot find Method ID for method countDownString\n"); RETURN_FAILED; } @@ -391,7 +391,7 @@ Java_nsk_jvmti_unit_ForceEarlyReturn_earlyretstr_getReady( } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_BREAKPOINT, NULL); + JVMTI_EVENT_BREAKPOINT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable BREAKPOINT event: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretvoid/earlyretvoid.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretvoid/earlyretvoid.cpp index 2a50307dc25..567ed23a543 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretvoid/earlyretvoid.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretvoid/earlyretvoid.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -35,13 +35,13 @@ extern "C" { #define RETURN_FAILED errCode = STATUS_FAILED; fflush(0); return -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; static jint errCode = PASSED; static jboolean printdump = JNI_TRUE; -static jmethodID midCheckPoint = NULL; -static jmethodID midRun = NULL; +static jmethodID midCheckPoint = nullptr; +static jmethodID midRun = nullptr; static jint framesExpected = 0; static jint framesCount = 0; @@ -57,7 +57,7 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jmethodID mid, jclass cls; jlocation loc_exp = (frame_no == 0) ? 25 : 11; char *sigClass, *name, *sig, *generic; - jvmtiLocalVariableEntry *table = NULL; + jvmtiLocalVariableEntry *table = nullptr; jint entryCount = 0; jint argValue; jint j; @@ -92,7 +92,7 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jmethodID mid, frame_no, TranslateError(err), err); RETURN_FAILED; } - if (table != NULL) { + if (table != nullptr) { for (j = 0; j < entryCount; j++) { if (strcmp(table[j].name, argName) == 0) { err = jvmti_env->GetLocalInt(thr, 0, @@ -112,17 +112,17 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jmethodID mid, printf(", arg value: %d\n", argValue); } - if (sigClass == NULL || strcmp(sigClass, cls_exp) != 0) { + if (sigClass == nullptr || strcmp(sigClass, cls_exp) != 0) { printf("(step %d) wrong class sig: \"%s\",\n", frame_no, sigClass); printf(" expected: \"%s\"\n", cls_exp); RETURN_FAILED; } - if (name == NULL || strcmp(name, name_exp) != 0) { + if (name == nullptr || strcmp(name, name_exp) != 0) { printf("(step %d) wrong method name: \"%s\",", frame_no, name); printf(" expected: \"%s\"\n", name_exp); RETURN_FAILED; } - if (sig == NULL || strcmp(sig, sig_exp) != 0) { + if (sig == nullptr || strcmp(sig, sig_exp) != 0) { printf("(step %d) wrong method sig: \"%s\",", frame_no, sig); printf(" expected: \"%s\"\n", sig_exp); RETURN_FAILED; @@ -139,16 +139,16 @@ void check(jvmtiEnv *jvmti_env, jthread thr, jmethodID mid, RETURN_FAILED; } - if (sigClass != NULL) { + if (sigClass != nullptr) { jvmti_env->Deallocate((unsigned char*)sigClass); } - if (name != NULL) { + if (name != nullptr) { jvmti_env->Deallocate((unsigned char*)name); } - if (sig != NULL) { + if (sig != nullptr) { jvmti_env->Deallocate((unsigned char*)sig); } - if (table != NULL) { + if (table != nullptr) { for (j = 0; j < entryCount; j++) { jvmti_env->Deallocate((unsigned char*)(table[j].name)); jvmti_env->Deallocate((unsigned char*)(table[j].signature)); @@ -241,14 +241,14 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printf("Printdump is turned on!\n"); printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong error code from a valid call to GetEnv!\n"); return JNI_ERR; } @@ -300,7 +300,7 @@ Java_nsk_jvmti_unit_ForceEarlyReturn_earlyretvoid_getReady( JNIEnv *env, jclass c, jclass cls, jint depth) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); RETURN_FAILED; } @@ -312,13 +312,13 @@ Java_nsk_jvmti_unit_ForceEarlyReturn_earlyretvoid_getReady( } midRun = env->GetMethodID(cls, "run", "()V"); - if (midRun == NULL) { + if (midRun == nullptr) { printf("Cannot find Method ID for method run\n"); RETURN_FAILED; } midCheckPoint = env->GetMethodID(cls, "checkPoint", "()V"); - if (midCheckPoint == NULL) { + if (midCheckPoint == nullptr) { printf("Cannot find Method ID for method checkPoint\n"); RETURN_FAILED; } @@ -331,7 +331,7 @@ Java_nsk_jvmti_unit_ForceEarlyReturn_earlyretvoid_getReady( } err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, - JVMTI_EVENT_BREAKPOINT, NULL); + JVMTI_EVENT_BREAKPOINT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable BREAKPOINT event: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/GetAllStackTraces/getallstktr001/getallstktr001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/GetAllStackTraces/getallstktr001/getallstktr001.cpp index 82fa5dfdfa7..a6d2804ba76 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/GetAllStackTraces/getallstktr001/getallstktr001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/GetAllStackTraces/getallstktr001/getallstktr001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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,10 +64,10 @@ static jrawMonitorID jraw_monitor; #define MAX_FRAMES_CNT 30 -static jvmtiStackInfo *stack_buf1 = NULL; -static jvmtiStackInfo *stack_buf2 = NULL; -static jthread *thread_list = NULL; -static jvmtiThreadInfo *thread_info = NULL; +static jvmtiStackInfo *stack_buf1 = nullptr; +static jvmtiStackInfo *stack_buf2 = nullptr; +static jthread *thread_list = nullptr; +static jvmtiThreadInfo *thread_info = nullptr; static jint threads_count = 0; @@ -191,10 +191,10 @@ void compare_one_stack_trace(int ti, static const char* TEST_THREAD_NAME_PREFIX = "getallstktr001-"; size_t PFX_LEN = strlen(TEST_THREAD_NAME_PREFIX); - if (thr_info->name != NULL) { + if (thr_info->name != nullptr) { printf("compare stack #%d: thread: %s\n", ti, thr_info->name); } else { - printf("compare stack #%d: thread is NULL\n", ti); + printf("compare stack #%d: thread is null\n", ti); return; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/GetConstantPool/getcpool001/getcpool001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/GetConstantPool/getcpool001/getcpool001.cpp index feafa26dde2..0514a46224d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/GetConstantPool/getcpool001/getcpool001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/GetConstantPool/getcpool001/getcpool001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,8 +39,8 @@ static jvmtiEventCallbacks callbacks; #define RETURN_FAILED errCode = STATUS_FAILED; fflush(0); return static jint errCode = PASSED; -static jvmtiEnv *jvmti = NULL; -static jmethodID midCheckPoint = NULL; +static jvmtiEnv *jvmti = nullptr; +static jmethodID midCheckPoint = nullptr; JNIEXPORT void JNICALL @@ -51,7 +51,7 @@ Java_nsk_jvmti_unit_GetConstantPool_getcpool001_getCP( int rep = 0; jint cp_cnt = 0; jint cp_bytes_cnt = 0; - unsigned char *cp_bytes = NULL; + unsigned char *cp_bytes = nullptr; err = jvmti->GetConstantPool(cls, &cp_cnt, &cp_bytes_cnt, &cp_bytes); if (err != JVMTI_ERROR_NONE) { @@ -102,7 +102,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -151,7 +151,7 @@ Java_nsk_jvmti_unit_GetConstantPool_getcpool001_getReady( JNIEnv *env, jclass c, jclass cls) { jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); RETURN_FAILED; } @@ -163,7 +163,7 @@ Java_nsk_jvmti_unit_GetConstantPool_getcpool001_getReady( } midCheckPoint = env->GetMethodID(cls, "checkPoint", "()V"); - if (midCheckPoint == NULL) { + if (midCheckPoint == nullptr) { printf("Cannot find Method ID for method checkPoint\n"); RETURN_FAILED; } @@ -175,7 +175,7 @@ Java_nsk_jvmti_unit_GetConstantPool_getcpool001_getReady( RETURN_FAILED; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable BREAKPOINT event: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/GetLineNumberTable/linetab004/linetab004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/GetLineNumberTable/linetab004/linetab004.cpp index fb3db7f4be7..9f40468f433 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/GetLineNumberTable/linetab004/linetab004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/GetLineNumberTable/linetab004/linetab004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -56,12 +56,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -97,7 +97,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { void checkGetLineNumberTable(jmethodID mid, const char *methName, int abstract, jvmtiError exp) { jint entryCount = -1; - jvmtiLineNumberEntry *table = NULL; + jvmtiLineNumberEntry *table = nullptr; jvmtiError err; int i; @@ -132,7 +132,7 @@ Java_nsk_jvmti_unit_GetLineNumberTable_linetab004_check(JNIEnv *env, jclass cls) jclass abstr; jclass interf; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -145,13 +145,13 @@ Java_nsk_jvmti_unit_GetLineNumberTable_linetab004_check(JNIEnv *env, jclass cls) printf("\n Check methods of interface:\n"); } interf = env->FindClass("nsk/jvmti/unit/GetLineNumberTable/Interface004"); - if (interf == NULL) { + if (interf == nullptr) { printf("Cannot get Interface class!\n"); return STATUS_FAILED; } mid = env->GetMethodID(cls, "instanceMeth0", "()I"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot get method ID!\n"); return STATUS_FAILED; } @@ -159,7 +159,7 @@ Java_nsk_jvmti_unit_GetLineNumberTable_linetab004_check(JNIEnv *env, jclass cls) JVMTI_ERROR_ABSENT_INFORMATION); mid = env->GetMethodID(cls, "instanceMeth1", "()I"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot get method ID!\n"); return STATUS_FAILED; } @@ -170,13 +170,13 @@ Java_nsk_jvmti_unit_GetLineNumberTable_linetab004_check(JNIEnv *env, jclass cls) printf("\n Check methods of abstract class:\n"); } abstr = env->GetSuperclass(cls); - if (abstr == NULL) { + if (abstr == nullptr) { printf("Cannot get super class!\n"); return STATUS_FAILED; } mid = env->GetMethodID(abstr, "instanceMeth0", "()I"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot get method ID!\n"); return STATUS_FAILED; } @@ -184,7 +184,7 @@ Java_nsk_jvmti_unit_GetLineNumberTable_linetab004_check(JNIEnv *env, jclass cls) JVMTI_ERROR_ABSENT_INFORMATION); mid = env->GetMethodID(abstr, "instanceMeth1", "()I"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot get method ID!\n"); return STATUS_FAILED; } @@ -195,7 +195,7 @@ Java_nsk_jvmti_unit_GetLineNumberTable_linetab004_check(JNIEnv *env, jclass cls) printf("\n Check methods of regular class:\n"); } mid = env->GetMethodID(cls, "instanceMeth0", "()I"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot get method ID!\n"); return STATUS_FAILED; } @@ -203,7 +203,7 @@ Java_nsk_jvmti_unit_GetLineNumberTable_linetab004_check(JNIEnv *env, jclass cls) JVMTI_ERROR_ABSENT_INFORMATION); mid = env->GetMethodID(cls, "instanceMeth1", "()I"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot get method ID!\n"); return STATUS_FAILED; } @@ -211,7 +211,7 @@ Java_nsk_jvmti_unit_GetLineNumberTable_linetab004_check(JNIEnv *env, jclass cls) JVMTI_ERROR_ABSENT_INFORMATION); mid = env->GetMethodID(cls, "instanceMeth2", "()I"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot get method ID!\n"); return STATUS_FAILED; } @@ -222,7 +222,7 @@ Java_nsk_jvmti_unit_GetLineNumberTable_linetab004_check(JNIEnv *env, jclass cls) printf("\n Check native methods of regular class:\n"); } mid = env->GetMethodID(cls, "instanceNativeMeth", "()I"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot get method ID!\n"); return STATUS_FAILED; } @@ -230,7 +230,7 @@ Java_nsk_jvmti_unit_GetLineNumberTable_linetab004_check(JNIEnv *env, jclass cls) JVMTI_ERROR_NATIVE_METHOD); mid = env->GetStaticMethodID(cls, "staticNativeMeth", "()I"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot get method ID!\n"); return STATUS_FAILED; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/GetLocalVariable/getlocal003/getlocal003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/GetLocalVariable/getlocal003/getlocal003.cpp index 1688cd1b723..4361f6df756 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/GetLocalVariable/getlocal003/getlocal003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/GetLocalVariable/getlocal003/getlocal003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,12 +34,12 @@ extern "C" { #define STATUS_PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jint result = STATUS_PASSED; static jboolean printdump = JNI_FALSE; -static jmethodID mid = NULL; -static jvmtiLocalVariableEntry *table = NULL; +static jmethodID mid = nullptr; +static jvmtiLocalVariableEntry *table = nullptr; static jint entryCount = 0; static jint methodExitCnt = -1; @@ -140,7 +140,7 @@ MethodExit(jvmtiEnv *jvmti_env, jvmtiError err; jlocation location; - jmethodID frame_method = NULL; + jmethodID frame_method = nullptr; if (mid != method) { return; @@ -181,12 +181,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; static jvmtiCapabilities caps; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -233,12 +233,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { JNIEXPORT void JNICALL Java_nsk_jvmti_unit_GetLocalVariable_getlocal003_instMeth(JNIEnv *env, jobject inst) { jvmtiError err; - jobject obj = NULL; + jobject obj = nullptr; printf("\n Native instMeth: started\n"); // Test GetLocalInstance with native instance method instMeth() frame - err = jvmti->GetLocalInstance(NULL, 0, &obj); + err = jvmti->GetLocalInstance(nullptr, 0, &obj); printf(" Native instMeth: GetLocalInstance: %s (%d)\n", TranslateError(err), err); if (err != JVMTI_ERROR_NONE) { printf("FAIL: GetLocalInstance failed to get instance for native instance method frame\n"); @@ -250,7 +250,7 @@ Java_nsk_jvmti_unit_GetLocalVariable_getlocal003_instMeth(JNIEnv *env, jobject i } // Test GetLocalInstance with java instance method meth01() frame - err = jvmti->GetLocalInstance(NULL, 1, &obj); + err = jvmti->GetLocalInstance(nullptr, 1, &obj); printf(" Native instMeth: GetLocalInstance: %s (%d)\n", TranslateError(err), err); if (err != JVMTI_ERROR_NONE) { printf("FAIL: GetLocalInstance failed to get instance for java instance method frame\n"); @@ -266,18 +266,18 @@ Java_nsk_jvmti_unit_GetLocalVariable_getlocal003_instMeth(JNIEnv *env, jobject i JNIEXPORT void JNICALL Java_nsk_jvmti_unit_GetLocalVariable_getlocal003_getMeth(JNIEnv *env, jclass cls) { jvmtiError err; - jobject obj = NULL; + jobject obj = nullptr; printf("\n Native getMeth: started\n"); - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; } mid = env->GetStaticMethodID(cls, "staticMeth", "(I)I"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot find Method ID for staticMeth\n"); result = STATUS_FAILED; return; @@ -291,7 +291,7 @@ Java_nsk_jvmti_unit_GetLocalVariable_getlocal003_getMeth(JNIEnv *env, jclass cls return; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_EXIT, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_EXIT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable metod exit event: %s (%d)\n", TranslateError(err), err); @@ -299,7 +299,7 @@ Java_nsk_jvmti_unit_GetLocalVariable_getlocal003_getMeth(JNIEnv *env, jclass cls } // Test GetLocalInstance with native static method getMeth() frame - err = jvmti->GetLocalInstance(NULL, 0, &obj); + err = jvmti->GetLocalInstance(nullptr, 0, &obj); printf(" Native getMeth: GetLocalInstance: %s (%d)\n", TranslateError(err), err); if (err != JVMTI_ERROR_INVALID_SLOT) { printf("FAIL: GetLocalInstance failed to return JVMTI_ERROR_INVALID_SLOT for native static method frame\n"); @@ -307,7 +307,7 @@ Java_nsk_jvmti_unit_GetLocalVariable_getlocal003_getMeth(JNIEnv *env, jclass cls } // Test GetLocalInstance with java static method run() frame - err = jvmti->GetLocalInstance(NULL, 1, &obj); + err = jvmti->GetLocalInstance(nullptr, 1, &obj); printf(" Native getMeth: GetLocalInstance: %s (%d)\n", TranslateError(err), err); if (err != JVMTI_ERROR_INVALID_SLOT) { printf("FAIL: GetLocalInstance failed to return JVMTI_ERROR_INVALID_SLOT for java static method frame\n"); @@ -329,7 +329,7 @@ Java_nsk_jvmti_unit_GetLocalVariable_getlocal003_checkLoc(JNIEnv *env, jint i, j; int overlap = 0; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; @@ -337,7 +337,7 @@ Java_nsk_jvmti_unit_GetLocalVariable_getlocal003_checkLoc(JNIEnv *env, printf("\n checkLoc: START\n"); mid = env->GetStaticMethodID(cls, "staticMeth", "(I)I"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot find Method ID for staticMeth\n"); result = STATUS_FAILED; return; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/GetLocalVariable/getlocal004/getlocal004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/GetLocalVariable/getlocal004/getlocal004.cpp index c63875c7da5..a74ca32f27b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/GetLocalVariable/getlocal004/getlocal004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/GetLocalVariable/getlocal004/getlocal004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ extern "C" { #define STATUS_PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = STATUS_PASSED; static jboolean printdump = JNI_FALSE; @@ -61,12 +61,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; static jvmtiCapabilities caps; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -105,16 +105,16 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { JNIEXPORT void JNICALL Java_nsk_jvmti_unit_GetLocalVariable_getlocal004_getMeth(JNIEnv *env, jclass cls) { - jmethodID mid = NULL; + jmethodID mid = nullptr; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); result = STATUS_FAILED; return; } mid = env->GetStaticMethodID(cls, "staticMeth", "(I)I"); - if (mid == NULL) { + if (mid == nullptr) { printf("Cannot find Method ID for staticMeth\n"); result = STATUS_FAILED; return; @@ -156,7 +156,7 @@ Java_nsk_jvmti_unit_GetLocalVariable_getlocal004_checkLoc(JNIEnv *env, jlong locLong = 0L; jdouble locDouble = 0.0f; - if (jvmti == NULL) { + if (jvmti == nullptr) { return; } printf("\n ----------------- checkLoc: %d -----------------\n\n", scope_no); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/IsSynthetic/issynth001/issynth001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/IsSynthetic/issynth001/issynth001.cpp index 7587d47178b..8ebe8508577 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/IsSynthetic/issynth001/issynth001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/IsSynthetic/issynth001/issynth001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ extern "C" { #define STATUS_FAILED 2 #define JVM_ACC_SYNTHETIC 0x1000 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -54,12 +54,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -102,9 +102,9 @@ checkClassMethods(jclass klass) { jmethodID mid; jboolean isSynthetic; jint meth_cnt = 0; - jmethodID* methods_ptr = NULL; - char* name_ptr = NULL; - char* sign_ptr = NULL; + jmethodID* methods_ptr = nullptr; + char* name_ptr = nullptr; + char* sign_ptr = nullptr; int i; err = jvmti->GetClassMethods(klass, &meth_cnt, &methods_ptr); @@ -118,7 +118,7 @@ checkClassMethods(jclass klass) { jint mods; mid = methods_ptr[i]; err = jvmti->GetMethodName(mid, &name_ptr, - &sign_ptr, (char **) NULL); + &sign_ptr, nullptr); if (err != JVMTI_ERROR_NONE) { printf("(GetMethodName#%d) unexpected error: %s (%d)\n", i, TranslateError(err), err); @@ -160,12 +160,12 @@ checkClassFields(jclass klass) { jfieldID fid; jboolean isSynthetic; jint fld_cnt = 0; - jfieldID* fields_ptr = NULL; - char* name_ptr = NULL; - char* sign_ptr = NULL; + jfieldID* fields_ptr = nullptr; + char* name_ptr = nullptr; + char* sign_ptr = nullptr; int i; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -181,7 +181,7 @@ checkClassFields(jclass klass) { jint mods; fid = fields_ptr[i]; err = jvmti->GetFieldName(klass, fid, &name_ptr, - &sign_ptr, (char **) NULL); + &sign_ptr, nullptr); if (err != JVMTI_ERROR_NONE) { printf("(GetFieldName#%d) unexpected error: %s (%d)\n", i, TranslateError(err), err); @@ -222,13 +222,13 @@ Java_nsk_jvmti_unit_IsSynthetic_issynth001_check(JNIEnv *env, jclass cls, jclass klass) { jvmtiError err; - char* class_sign = NULL; + char* class_sign = nullptr; if (!caps.can_get_synthetic_attribute) { return result; } - err = jvmti->GetClassSignature(cls, &class_sign, (char **) NULL); + err = jvmti->GetClassSignature(cls, &class_sign, nullptr); if (err != JVMTI_ERROR_NONE) { printf("GetSourceFileName unexpected error: %s (%d)\n", TranslateError(err), err); @@ -249,7 +249,7 @@ Java_nsk_jvmti_unit_IsSynthetic_issynth001_check(JNIEnv *env, return result; } - err = jvmti->GetClassSignature(klass, &class_sign, (char **) NULL); + err = jvmti->GetClassSignature(klass, &class_sign, nullptr); if (err != JVMTI_ERROR_NONE) { printf("GetSourceFileName unexpected error: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/MethodBind/JvmtiTest/JvmtiTest.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/MethodBind/JvmtiTest/JvmtiTest.cpp index a70807450d6..b68e220470b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/MethodBind/JvmtiTest/JvmtiTest.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/MethodBind/JvmtiTest/JvmtiTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,7 +77,7 @@ findLoadClass_type findLoadedClass_func; JNIEXPORT jclass JNICALL my_findLoadedClass(JNIEnv *env, jobject loader, jstring name) { - const char* sname = env->GetStringUTFChars(name, NULL); + const char* sname = env->GetStringUTFChars(name, nullptr); debug_printf("Intercepted findLoadedClass, name = %s\n", sname); return (*findLoadedClass_func)(env, loader, name); } @@ -102,7 +102,7 @@ void JNICALL testNativeMethodBind(jvmtiEnv* jvmti_env, JNIEnv *jni_env, debug_printf("bind event: \n"); print_method_name(mid); - ret = jvmti_env->GetMethodName(mid, &mname, &signature, NULL); + ret = jvmti_env->GetMethodName(mid, &mname, &signature, nullptr); if (ret == JVMTI_ERROR_NONE) { if (strcmp(mname, "findLoadedClass") == 0) { findLoadedClass_func = (findLoadClass_type)func; @@ -161,13 +161,13 @@ jint Agent_Initialize(JavaVM * jvm, char *options, void *reserved) { res = jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks)); JVMTI_ERROR_CHECK("SetEventCallbacks returned error", res); - res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL); + res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, nullptr); JVMTI_ERROR_CHECK("SetEventNotificationMode for VM_INIT returned error", res); - res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL); + res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, nullptr); JVMTI_ERROR_CHECK("SetEventNotificationMode for vm death event returned error", res); - res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_NATIVE_METHOD_BIND, NULL); + res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_NATIVE_METHOD_BIND, nullptr); JVMTI_ERROR_CHECK("SetEventNotificationMode for native method bind event returned error", res); return JNI_OK; @@ -275,14 +275,14 @@ print_method_name(jmethodID mid) { return; } - ret = jvmti->GetClassSignature(klass, &clname, NULL); + ret = jvmti->GetClassSignature(klass, &clname, nullptr); if (ret != JVMTI_ERROR_NONE) { printf("Error: GetClassSignature %d \n", ret); iGlobalStatus = 2; return; } - ret = jvmti->GetMethodName(mid, &mname, &signature, NULL); + ret = jvmti->GetMethodName(mid, &mname, &signature, nullptr); if (ret != JVMTI_ERROR_NONE) { printf("Error: GetMethodName %d \n", ret); iGlobalStatus = 2; @@ -296,7 +296,7 @@ print_method_name(jmethodID mid) { JNIEXPORT void JNICALL Java_nsk_jvmti_unit_MethodBind_JvmtiTest_GetStackTrace(JNIEnv * env, jclass cls, jobject thr) { jvmtiError ret; - jvmtiFrameInfo *stack_buffer = NULL; + jvmtiFrameInfo *stack_buffer = nullptr; jint max_count = 20; jint count; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/StackTrace/JvmtiTest/JvmtiTest.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/StackTrace/JvmtiTest/JvmtiTest.cpp index 572ff53c5ef..fbaf0fa1816 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/StackTrace/JvmtiTest/JvmtiTest.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/StackTrace/JvmtiTest/JvmtiTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -195,8 +195,8 @@ Java_nsk_jvmti_unit_StackTrace_JvmtiTest_GetFrameCount(JNIEnv * env, jclass cls, JNIEXPORT void JNICALL Java_nsk_jvmti_unit_StackTrace_JvmtiTest_GetStackTrace(JNIEnv * env, jclass cls, jobject thr) { jvmtiError ret; - jvmtiFrameInfo *stack_buffer = NULL; - jvmtiFrameInfo *compare_buffer = NULL; + jvmtiFrameInfo *stack_buffer = nullptr; + jvmtiFrameInfo *compare_buffer = nullptr; jint max_count = 20; jint count; jclass klass; @@ -291,14 +291,14 @@ Java_nsk_jvmti_unit_StackTrace_JvmtiTest_GetStackTrace(JNIEnv * env, jclass cls, return; } - ret = jvmti->GetClassSignature(klass, &clname, NULL); + ret = jvmti->GetClassSignature(klass, &clname, nullptr); if (ret != JVMTI_ERROR_NONE) { printf("Error: GetClassSignature %d \n", ret); iGlobalStatus = 2; return; } - ret = jvmti->GetMethodName(stack_buffer[i].method, &mname, &signature, NULL); + ret = jvmti->GetMethodName(stack_buffer[i].method, &mname, &signature, nullptr); if (ret != JVMTI_ERROR_NONE) { printf("Error: GetMethodName %d \n", ret); iGlobalStatus = 2; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/agentthr/agentthr.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/agentthr/agentthr.cpp index 58e2cfe9498..17e7f517923 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/agentthr/agentthr.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/agentthr/agentthr.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ extern "C" { #define STATUS_FAILED 2 static JavaVM *jvm_ins; -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiEventCallbacks callbacks; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -121,13 +121,13 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiError err; jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } jvm_ins = jvm; res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -140,7 +140,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable JVMTI_EVENT_THREAD_START: %s (%d)\n", TranslateError(err), err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/clsldrclss00x/clsldrclss00x.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/clsldrclss00x/clsldrclss00x.cpp index 2efbf140649..c1adeb386ff 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/clsldrclss00x/clsldrclss00x.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/clsldrclss00x/clsldrclss00x.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; @@ -51,12 +51,12 @@ JNIEXPORT jint JNI_OnLoad_clsldrclss00x(JavaVM *jvm, char *options, void *reserv jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -74,7 +74,7 @@ Java_nsk_jvmti_unit_clsldrclss00x_check(JNIEnv *env, jclass appCls, jclass objCl jboolean found; jint i; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -86,8 +86,8 @@ Java_nsk_jvmti_unit_clsldrclss00x_check(JNIEnv *env, jclass appCls, jclass objCl result = STATUS_FAILED; return result; } - if (appClassloader == NULL) { - printf("(GetClassLoader app) unexpected loader - NULL\n"); + if (appClassloader == nullptr) { + printf("(GetClassLoader app) unexpected loader - null\n"); result = STATUS_FAILED; return result; } @@ -99,8 +99,8 @@ Java_nsk_jvmti_unit_clsldrclss00x_check(JNIEnv *env, jclass appCls, jclass objCl result = STATUS_FAILED; return result; } - if (objClassloader != NULL) { - printf("(GetClassLoader obj) unexpected loader - !NULL\n"); + if (objClassloader != nullptr) { + printf("(GetClassLoader obj) unexpected loader - !null\n"); result = STATUS_FAILED; return result; } @@ -117,7 +117,7 @@ Java_nsk_jvmti_unit_clsldrclss00x_check(JNIEnv *env, jclass appCls, jclass objCl for (i = 0; i < classCount; ++i) { char *classSig; jclass k = classes[i]; - err = jvmti->GetClassSignature(k, &classSig, NULL); + err = jvmti->GetClassSignature(k, &classSig, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Error (getClassSignature): %s (%d)\n", TranslateError(err), err); result = STATUS_FAILED; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/events/redefineCFLH/JvmtiTest/JvmtiTest.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/events/redefineCFLH/JvmtiTest/JvmtiTest.cpp index 37ba70728c1..59ed1561bb2 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/events/redefineCFLH/JvmtiTest/JvmtiTest.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/events/redefineCFLH/JvmtiTest/JvmtiTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { #define STATUS_FAILED 2 #define PASSED 0 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jvmtiCapabilities caps; static jvmtiEventCallbacks callbacks; static jint result = PASSED; @@ -63,12 +63,12 @@ ClassFileLoadHook(jvmtiEnv *jvmti_env, JNIEnv *env, char *sig; char *gen; - if (name != NULL && (strcmp(name, CLASS_NAME) == 0)) { + if (name != nullptr && (strcmp(name, CLASS_NAME) == 0)) { if (printdump == JNI_TRUE) { printf("Received class file load hook event for class %s\n", name); } - if (redefined_class != NULL) { + if (redefined_class != nullptr) { err = jvmti->GetClassSignature(redefined_class, &sig, &gen); if (err != JVMTI_ERROR_NONE) { printf("(GetClassSignature) unexpected error: %s (%d)\n", @@ -106,7 +106,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } @@ -150,14 +150,14 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable event JVMTI_EVENT_VM_INIT: %s (%d)\n", TranslateError(err), err); return JNI_ERR; } - err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Failed to enable event JVMTI_EVENT_CLASS_FILE_LOAD_HOOK: %s (%d)\n", TranslateError(err), err); @@ -173,7 +173,7 @@ Java_nsk_jvmti_unit_events_redefineCFLH_JvmtiTest_makeRedefinition(JNIEnv *env, jvmtiClassDefinition classDef; jvmtiError err; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } @@ -185,7 +185,7 @@ Java_nsk_jvmti_unit_events_redefineCFLH_JvmtiTest_makeRedefinition(JNIEnv *env, /* filling the structure jvmtiClassDefinition */ classDef.klass = redefCls; classDef.class_byte_count = env->GetArrayLength(classBytes); - classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, NULL); + classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, nullptr); if (fl == 2) { printf(">>>>>>>> Invoke RedefineClasses():\n"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/extmech/extmech.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/extmech/extmech.cpp index 4d7b9868670..3dfa394efc5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/extmech/extmech.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/extmech/extmech.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -100,7 +100,7 @@ Java_nsk_jvmti_unit_extmech_enableClassUnloadEvent if (strcmp(ext_events[i].id, (char*)"com.sun.hotspot.events.ClassUnload") == 0) { err = jvmti->SetExtensionEventCallback(ext_events[i].extension_event_index, - enable ? (jvmtiExtensionEvent)ClassUnload : NULL); + enable ? (jvmtiExtensionEvent)ClassUnload : nullptr); if (err != JVMTI_ERROR_NONE) { fprintf(stderr, "SetExtenionEventCallback failed: %d\n", err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/functions/AddToBootstrapClassLoaderSearch/JvmtiTest/JvmtiTest.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/functions/AddToBootstrapClassLoaderSearch/JvmtiTest/JvmtiTest.cpp index 4d38e540d87..1ef592cd959 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/functions/AddToBootstrapClassLoaderSearch/JvmtiTest/JvmtiTest.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/functions/AddToBootstrapClassLoaderSearch/JvmtiTest/JvmtiTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -143,13 +143,13 @@ classFileLoadEvent(jvmtiEnv *jvmti_env, JNIEnv *env, jint* new_class_data_len, unsigned char** new_class_data) { - if (name != NULL && (strcmp(name, BOOT_CLASS) == 0)) { + if (name != nullptr && (strcmp(name, BOOT_CLASS) == 0)) { debug_printf("Received class file load hook event for class: \n\t%s\n", name); debug_printf("Received class loader: 0x%p \n", loader); /* Check to make sure Boot class got loaded from bootstrap class path.*/ - if (loader == NULL) { + if (loader == nullptr) { boot_class_count++; } } @@ -192,7 +192,7 @@ jint Agent_Initialize(JavaVM * jvm, char *options, void *reserved) { strncpy(segment, options, (size_t) sizeof(segment)/sizeof(char)); segment[(size_t) sizeof(segment)/sizeof(char) - 1] = 0; idx = strchr(segment, ','); - if (idx != NULL) *idx = 0; + if (idx != nullptr) *idx = 0; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); @@ -214,19 +214,19 @@ jint Agent_Initialize(JavaVM * jvm, char *options, void *reserved) { res = jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks)); JVMTI_ERROR_CHECK("SetEventCallbacks returned error", res); - res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_START, NULL); + res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_START, nullptr); JVMTI_ERROR_CHECK("SetEventNotificationMode for VM_START returned error", res); - res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL); + res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, nullptr); JVMTI_ERROR_CHECK("SetEventNotificationMode for VM_INIT returned error", res); - res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_NATIVE_METHOD_BIND, NULL); + res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_NATIVE_METHOD_BIND, nullptr); JVMTI_ERROR_CHECK("SetEventNotificationMode for NATIVE_METHOD_BIND returned error", res); - res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL); + res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, nullptr); JVMTI_ERROR_CHECK("SetEventNotificationMode for VM_DEATH returned error", res); - res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL); + res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, nullptr); JVMTI_ERROR_CHECK("SetEventNotificationMode CLASS_FILE_LOAD_HOOK returned error", res); strcat(segment, "/newclass"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/functions/Dispose/JvmtiTest/JvmtiTest.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/functions/Dispose/JvmtiTest/JvmtiTest.cpp index f85d438a68a..24066525e63 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/functions/Dispose/JvmtiTest/JvmtiTest.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/functions/Dispose/JvmtiTest/JvmtiTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -115,7 +115,7 @@ jint Agent_Initialize(JavaVM * jvm, char *options, void *reserved) { JVMTI_ERROR_CHECK("GetAddCapabilities returned error", res); - res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL); + res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, nullptr); JVMTI_ERROR_CHECK("SetEventNotificationMode for VM_INIT returned error", res); res = jvmti->GetSystemProperties(&count, &properties); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/functions/ForceGarbageCollection/gc/gc.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/functions/ForceGarbageCollection/gc/gc.cpp index f3ff582ea8d..e1c57fa08d2 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/functions/ForceGarbageCollection/gc/gc.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/functions/ForceGarbageCollection/gc/gc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -134,16 +134,16 @@ jint Agent_Initialize(JavaVM * jvm, char *options, void *reserved) { res = jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks)); JVMTI_ERROR_CHECK("SetEventCallbacks returned error", res); - res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL); + res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, nullptr); JVMTI_ERROR_CHECK("SetEventNotificationMode for VM_INIT returned error", res); - res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL); + res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, nullptr); JVMTI_ERROR_CHECK("SetEventNotificationMode for vm death event returned error", res); - res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_START, NULL); + res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_START, nullptr); JVMTI_ERROR_CHECK("SetEventNotificationMode for gc start returned error", res); - res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_FINISH, NULL); + res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_FINISH, nullptr); JVMTI_ERROR_CHECK("SetEventNotificationMode for gc finish returned error", res); return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/functions/nosuspendMonitorInfo/JvmtiTest/JvmtiTest.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/functions/nosuspendMonitorInfo/JvmtiTest/JvmtiTest.cpp index 4c0e6fbbc6b..66799c3d004 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/functions/nosuspendMonitorInfo/JvmtiTest/JvmtiTest.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/functions/nosuspendMonitorInfo/JvmtiTest/JvmtiTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -134,10 +134,10 @@ jint Agent_Initialize(JavaVM * jvm, char *options, void *reserved) { res = jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks)); JVMTI_ERROR_CHECK("SetEventCallbacks returned error", res); - res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL); + res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, nullptr); JVMTI_ERROR_CHECK("SetEventNotificationMode for VM_INIT returned error", res); - res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL); + res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, nullptr); JVMTI_ERROR_CHECK("SetEventNotificationMode for vm death event returned error", res); return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/functions/nosuspendStackTrace/JvmtiTest/JvmtiTest.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/functions/nosuspendStackTrace/JvmtiTest/JvmtiTest.cpp index c3934dd0b90..432045f98e2 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/functions/nosuspendStackTrace/JvmtiTest/JvmtiTest.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/functions/nosuspendStackTrace/JvmtiTest/JvmtiTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -133,10 +133,10 @@ jint Agent_Initialize(JavaVM * jvm, char *options, void *reserved) { res = jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks)); JVMTI_ERROR_CHECK("SetEventCallbacks returned error", res); - res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL); + res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, nullptr); JVMTI_ERROR_CHECK("SetEventNotificationMode for VM_INIT returned error", res); - res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL); + res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, nullptr); JVMTI_ERROR_CHECK("SetEventNotificationMode for vm death event returned error", res); return JNI_OK; @@ -233,7 +233,7 @@ Java_nsk_jvmti_unit_functions_nosuspendStackTrace_JvmtiTest_GetFrameCount(JNIEnv JNIEXPORT void JNICALL Java_nsk_jvmti_unit_functions_nosuspendStackTrace_JvmtiTest_GetStackTrace(JNIEnv * env, jclass cls, jobject thr) { jvmtiError ret; - jvmtiFrameInfo *stack_buffer = NULL; + jvmtiFrameInfo *stack_buffer = nullptr; jint count = 20; jclass klass; char *mname; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/functions/rawmonitor/rawmonitor.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/functions/rawmonitor/rawmonitor.cpp index b7df38f8ecc..55267f99ead 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/functions/rawmonitor/rawmonitor.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/functions/rawmonitor/rawmonitor.cpp @@ -1,6 +1,6 @@ /* s - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -222,13 +222,13 @@ jint Agent_Initialize(JavaVM * jvm, char *options, void *reserved) { res = jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks)); JVMTI_ERROR_CHECK("SetEventCallbacks returned error", res); - res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL); + res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, nullptr); JVMTI_ERROR_CHECK("SetEventNotificationMode for VM_INIT returned error", res); - res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL); + res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, nullptr); JVMTI_ERROR_CHECK("SetEventNotificationMode for vm death event returned error", res); - res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL); + res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, nullptr); JVMTI_ERROR_CHECK("SetEventNotificationMode CLASS_FILE_LOAD_HOOK returned error", res); /* acquire lock in onload */ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/heapref/heapref.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/heapref/heapref.cpp index 640779eb75c..bab6bfbbfca 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/heapref/heapref.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/heapref/heapref.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -35,7 +35,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; static jvmtiCapabilities jvmti_caps; @@ -70,8 +70,8 @@ typedef struct _refLink { struct _refLink *next; } refLink; -static MyTag *fakeRoot = NULL; -static MyTag *missed = NULL; +static MyTag *fakeRoot = nullptr; +static MyTag *missed = nullptr; static void breakpoint() { printf("Continuing from BREAKPOINT\n"); @@ -82,10 +82,10 @@ static MyTag *newTag(refKind kind, jlong size, const char* name) { static jlong seq_num = 0; - MyTag* new_tag = NULL; + MyTag* new_tag = nullptr; new_tag = (MyTag*) malloc(sizeof(MyTag)); - if (NULL == new_tag) { + if (nullptr == new_tag) { printf("Error (newTag malloc): failed\n"); result = STATUS_FAILED; } @@ -95,7 +95,7 @@ static MyTag *newTag(refKind kind, new_tag->sequence = ++seq_num; new_tag->visited = JNI_FALSE; new_tag->name = name; - new_tag->ref = NULL; + new_tag->ref = nullptr; return new_tag; } @@ -103,11 +103,11 @@ static void setTag(JNIEnv *env, jobject obj, refKind kind, const char* name) { - MyTag *new_tag = NULL; - MyTag *class_tag = NULL; + MyTag *new_tag = nullptr; + MyTag *class_tag = nullptr; jvmtiError err; jlong size = 0; - jclass obj_class = NULL; + jclass obj_class = nullptr; jlong haba = 0; err = jvmti->GetObjectSize(obj, &size); @@ -124,7 +124,7 @@ static void setTag(JNIEnv *env, printf("Error (GetTag): %s (%d)\n", TranslateError(err), err); result = STATUS_FAILED; } - if (class_tag != NULL && class_tag->kind != rclass) { + if (class_tag != nullptr && class_tag->kind != rclass) { printf("Error class tag which is not a class\n"); result = STATUS_FAILED; } @@ -142,7 +142,7 @@ static void addRef(MyTag *from, int reference_kind, MyTag *to) { refLink *new_ref; new_ref = (refLink*) malloc(sizeof(refLink)); - if (NULL == new_ref) { + if (nullptr == new_ref) { printf("Error (addRef malloc): failed\n"); result = STATUS_FAILED; } @@ -215,7 +215,7 @@ static void walk(MyTag* tag, jint depth, const char* ref_label) { const char *indent = spaces + (len - 2 * depth); const MyTag* const ctag = tag->class_tag; - const char* const cname = ctag != NULL ? ctag->name : ""; + const char* const cname = ctag != nullptr ? ctag->name : ""; printf("%s", indent); @@ -258,12 +258,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -281,7 +281,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiIterationControl JNICALL heapMarkCallback(jlong class_tag, jlong size, jlong* tag_ptr, void* user_data) { - const MyTag* const tag = newTag(rmark, (const MyTag*)(intptr_t)class_tag, size, NULL); + const MyTag* const tag = newTag(rmark, (const MyTag*)(intptr_t)class_tag, size, nullptr); *tag_ptr = (intptr_t)tag; if (user_data != &dummy_user_data && user_data_error_flag == JNI_FALSE) { @@ -300,7 +300,7 @@ heapRootCallback(jvmtiHeapRootKind root_kind, if (0 == *tag_ptr) { /* new tag */ - MyTag* tag = newTag(kind, (MyTag*)(intptr_t)class_tag, size, NULL); + MyTag* tag = newTag(kind, (MyTag*)(intptr_t)class_tag, size, nullptr); addRef(fakeRoot, HEAP_ROOT_REF_KIND_BASE+root_kind, tag); *tag_ptr = (intptr_t)tag; } else { @@ -326,7 +326,7 @@ stackReferenceCallback(jvmtiHeapRootKind root_kind, if (0 == *tag_ptr) { /* new tag */ - MyTag* tag = newTag(kind, (MyTag*)(intptr_t)class_tag, size, NULL); + MyTag* tag = newTag(kind, (MyTag*)(intptr_t)class_tag, size, nullptr); addRef(fakeRoot, HEAP_ROOT_REF_KIND_BASE+root_kind, tag); *tag_ptr = (intptr_t)tag; } else { @@ -347,7 +347,7 @@ objectReferenceCallback(jvmtiObjectReferenceKind reference_kind, jlong* tag_ptr, jlong referrer_tag, jint referrer_index, void* user_data) { refKind kind = rother; - MyTag* referrer = NULL; + MyTag* referrer = nullptr; if (0 == referrer_tag) { referrer = missed; @@ -357,7 +357,7 @@ objectReferenceCallback(jvmtiObjectReferenceKind reference_kind, if (0 == *tag_ptr) { /* new tag */ - MyTag* tag = newTag(kind, (MyTag*)(intptr_t)class_tag, size, NULL); + MyTag* tag = newTag(kind, (MyTag*)(intptr_t)class_tag, size, nullptr); addRef(referrer, reference_kind, tag); *tag_ptr = (intptr_t) tag; } else { @@ -382,13 +382,13 @@ Java_nsk_jvmti_unit_heapref_check(JNIEnv *env, jclass cls) { jint threadCount = 0; jint i; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } - fakeRoot = newTag(rother, (const MyTag *)NULL, 0, "FAKE_ROOT"); - missed = newTag(rother, (const MyTag *)NULL, 0, "MISSED"); + fakeRoot = newTag(rother, nullptr, 0, "FAKE_ROOT"); + missed = newTag(rother, nullptr, 0, "MISSED"); if (env->PushLocalFrame(500) != 0) { printf("Error (PushLocalFrame): failed\n"); @@ -404,7 +404,7 @@ Java_nsk_jvmti_unit_heapref_check(JNIEnv *env, jclass cls) { for (i = 0; i < classCount; ++i) { char *classSig; jclass k = classes[i]; - err = jvmti->GetClassSignature(k, &classSig, NULL); + err = jvmti->GetClassSignature(k, &classSig, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Error (getClassSignature): %s (%d)\n", TranslateError(err), err); result = STATUS_FAILED; @@ -414,7 +414,7 @@ Java_nsk_jvmti_unit_heapref_check(JNIEnv *env, jclass cls) { if (classSig[len-1] == ';') { classSig[len-1] = 0; } - if (*classSig == 'L' && slash != NULL) { + if (*classSig == 'L' && slash != nullptr) { classSig = slash + 1; } setTag(env, k, rclass, (const char*)classSig); @@ -439,7 +439,7 @@ Java_nsk_jvmti_unit_heapref_check(JNIEnv *env, jclass cls) { } } - env->PopLocalFrame(NULL); + env->PopLocalFrame(nullptr); user_data_error_flag = JNI_FALSE; err = jvmti->IterateOverHeap( diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/refignore/refignore.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/refignore/refignore.cpp index bdf8f3b368d..eb840e39061 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/refignore/refignore.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/refignore/refignore.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -35,7 +35,7 @@ extern "C" { #define PASSED 0 #define STATUS_FAILED 2 -static jvmtiEnv *jvmti = NULL; +static jvmtiEnv *jvmti = nullptr; static jint result = PASSED; static jboolean printdump = JNI_FALSE; static jvmtiCapabilities jvmti_caps; @@ -70,8 +70,8 @@ typedef struct _refLink { struct _refLink *next; } refLink; -static MyTag *fakeRoot = NULL; -static MyTag *missed = NULL; +static MyTag *fakeRoot = nullptr; +static MyTag *missed = nullptr; static void breakpoint() { printf("Continuing from BREAKPOINT\n"); @@ -82,10 +82,10 @@ static MyTag *newTag(refKind kind, jlong size, const char* name) { static jlong seq_num = 0; - MyTag* new_tag = NULL; + MyTag* new_tag = nullptr; new_tag = (MyTag*) malloc(sizeof(MyTag)); - if (NULL == new_tag) { + if (nullptr == new_tag) { printf("Error (newTag malloc): failed\n"); result = STATUS_FAILED; } @@ -95,7 +95,7 @@ static MyTag *newTag(refKind kind, new_tag->sequence = ++seq_num; new_tag->visited = JNI_FALSE; new_tag->name = name; - new_tag->ref = NULL; + new_tag->ref = nullptr; return new_tag; } @@ -103,11 +103,11 @@ static void setTag(JNIEnv *env, jobject obj, refKind kind, const char* name) { - MyTag *new_tag = NULL; - MyTag *class_tag = NULL; + MyTag *new_tag = nullptr; + MyTag *class_tag = nullptr; jvmtiError err; jlong size = 0; - jclass obj_class = NULL; + jclass obj_class = nullptr; jlong haba = 0; err = jvmti->GetObjectSize(obj, &size); @@ -124,7 +124,7 @@ static void setTag(JNIEnv *env, printf("Error (GetTag): %s (%d)\n", TranslateError(err), err); result = STATUS_FAILED; } - if (class_tag != NULL && class_tag->kind != rclass) { + if (class_tag != nullptr && class_tag->kind != rclass) { printf("Error class tag which is not a class\n"); result = STATUS_FAILED; } @@ -142,7 +142,7 @@ static void addRef(MyTag *from, int reference_kind, MyTag *to) { refLink *new_ref; new_ref = (refLink*) malloc(sizeof(refLink)); - if (NULL == new_ref) { + if (nullptr == new_ref) { printf("Error (addRef malloc): failed\n"); result = STATUS_FAILED; } @@ -215,7 +215,7 @@ static void walk(MyTag* tag, jint depth, const char* ref_label) { const char *indent = spaces + (len - 2 * depth); const MyTag* const ctag = tag->class_tag; - const char* const cname = ctag != NULL ? ctag->name : ""; + const char* const cname = ctag != nullptr ? ctag->name : ""; printf("%s", indent); @@ -256,12 +256,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jint res; jvmtiError err; - if (options != NULL && strcmp(options, "printdump") == 0) { + if (options != nullptr && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); - if (res != JNI_OK || jvmti == NULL) { + if (res != JNI_OK || jvmti == nullptr) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } @@ -279,7 +279,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiIterationControl JNICALL heapMarkCallback(jlong class_tag, jlong size, jlong* tag_ptr, void* user_data) { - const MyTag* const tag = newTag(rmark, (const MyTag*)(intptr_t)class_tag, size, NULL); + const MyTag* const tag = newTag(rmark, (const MyTag*)(intptr_t)class_tag, size, nullptr); *tag_ptr = (intptr_t)tag; if (user_data != &dummy_user_data && user_data_error_flag == JNI_FALSE) { @@ -298,7 +298,7 @@ heapRootCallback(jvmtiHeapRootKind root_kind, if (0 == *tag_ptr) { /* new tag */ - MyTag* tag = newTag(kind, (MyTag*)(intptr_t)class_tag, size, NULL); + MyTag* tag = newTag(kind, (MyTag*)(intptr_t)class_tag, size, nullptr); addRef(fakeRoot, HEAP_ROOT_REF_KIND_BASE+root_kind, tag); *tag_ptr = (intptr_t)tag; } else { @@ -324,7 +324,7 @@ stackReferenceCallback(jvmtiHeapRootKind root_kind, if (0 == *tag_ptr) { /* new tag */ - MyTag* tag = newTag(kind, (MyTag*)(intptr_t)class_tag, size, NULL); + MyTag* tag = newTag(kind, (MyTag*)(intptr_t)class_tag, size, nullptr); addRef(fakeRoot, HEAP_ROOT_REF_KIND_BASE+root_kind, tag); *tag_ptr = (intptr_t)tag; } else { @@ -345,7 +345,7 @@ objectReferenceCallback(jvmtiObjectReferenceKind reference_kind, jlong* tag_ptr, jlong referrer_tag, jint referrer_index, void* user_data) { refKind kind = rother; - MyTag* referrer = NULL; + MyTag* referrer = nullptr; if (0 == referrer_tag) { referrer = missed; @@ -355,7 +355,7 @@ objectReferenceCallback(jvmtiObjectReferenceKind reference_kind, if (0 == *tag_ptr) { /* new tag */ - MyTag* tag = newTag(kind, (MyTag*)(intptr_t)class_tag, size, NULL); + MyTag* tag = newTag(kind, (MyTag*)(intptr_t)class_tag, size, nullptr); addRef(referrer, reference_kind, tag); *tag_ptr = (intptr_t) tag; } else { @@ -380,13 +380,13 @@ Java_nsk_jvmti_unit_refignore_check(JNIEnv *env, jclass cls) { jint threadCount = 0; jint i; - if (jvmti == NULL) { + if (jvmti == nullptr) { printf("JVMTI client was not properly loaded!\n"); return STATUS_FAILED; } - fakeRoot = newTag(rother, (const MyTag *)NULL, 0, "FAKE_ROOT"); - missed = newTag(rother, (const MyTag *)NULL, 0, "MISSED"); + fakeRoot = newTag(rother, nullptr, 0, "FAKE_ROOT"); + missed = newTag(rother, nullptr, 0, "MISSED"); if (env->PushLocalFrame(500) != 0) { printf("Error (PushLocalFrame): failed\n"); @@ -402,7 +402,7 @@ Java_nsk_jvmti_unit_refignore_check(JNIEnv *env, jclass cls) { for (i = 0; i < classCount; ++i) { char *classSig; jclass k = classes[i]; - err = jvmti->GetClassSignature(k, &classSig, NULL); + err = jvmti->GetClassSignature(k, &classSig, nullptr); if (err != JVMTI_ERROR_NONE) { printf("Error (getClassSignature): %s (%d)\n", TranslateError(err), err); result = STATUS_FAILED; @@ -412,7 +412,7 @@ Java_nsk_jvmti_unit_refignore_check(JNIEnv *env, jclass cls) { if (classSig[len-1] == ';') { classSig[len-1] = 0; } - if (*classSig == 'L' && slash != NULL) { + if (*classSig == 'L' && slash != nullptr) { classSig = slash + 1; } setTag(env, k, rclass, (const char*)classSig); @@ -437,7 +437,7 @@ Java_nsk_jvmti_unit_refignore_check(JNIEnv *env, jclass cls) { } } - env->PopLocalFrame(NULL); + env->PopLocalFrame(nullptr); user_data_error_flag = JNI_FALSE; err = jvmti->IterateOverHeap( diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/setNullVMInit/JvmtiTest/JvmtiTest.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/setNullVMInit/JvmtiTest/JvmtiTest.cpp index f670dfafbb5..1ce5facd4eb 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/setNullVMInit/JvmtiTest/JvmtiTest.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/setNullVMInit/JvmtiTest/JvmtiTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -26,7 +26,7 @@ VMInit initial thread arg. SetThreadLocalStorage and SetEnvironmentLocalStorage should allow - value to be set to NULL. + value to be set to nullptr. */ #include @@ -105,13 +105,13 @@ void check_val(intptr_t x, intptr_t y, const char* msg) { void JNICALL vmInit(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread) { check_val(get_thread_local(thread), 0, "thread initial"); - check_val(get_thread_local(NULL), 0, "thread initial"); + check_val(get_thread_local(nullptr), 0, "thread initial"); set_thread_local(thread, 35); check_val(get_thread_local(thread), 35, "thread set non-zero"); - check_val(get_thread_local(NULL), 35, "thread set non-zero"); - set_thread_local(NULL, 0); + check_val(get_thread_local(nullptr), 35, "thread set non-zero"); + set_thread_local(nullptr, 0); check_val(get_thread_local(thread), 0, "thread set zero"); - check_val(get_thread_local(NULL), 0, "thread set zero"); + check_val(get_thread_local(nullptr), 0, "thread set zero"); check_val(get_env_local(), 14, "env set non-zero"); set_env_local(77); @@ -161,7 +161,7 @@ jint Agent_Initialize(JavaVM * jvm, char *options, void *reserved) { res = jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks)); JVMTI_ERROR_CHECK("SetEventCallbacks returned error", res); - res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT,NULL); + res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT,nullptr); JVMTI_ERROR_CHECK("SetEventNotificationMode for VM_INIT returned error", res); return JNI_OK; @@ -175,7 +175,7 @@ Java_nsk_jvmti_unit_setNullVMInit_JvmtiTest_check(JNIEnv *env, jclass cls) { set_env_local(0); check_val(get_env_local(), 0, "env reset to zero"); - check_val(get_thread_local(NULL), 0, "thread check"); + check_val(get_thread_local(nullptr), 0, "thread check"); return iGlobalStatus; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/timers/JvmtiTest/JvmtiTest.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/timers/JvmtiTest/JvmtiTest.cpp index d9be94340e7..b903de9b7ec 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/timers/JvmtiTest/JvmtiTest.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/timers/JvmtiTest/JvmtiTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -143,10 +143,10 @@ jint Agent_Initialize(JavaVM * jvm, char *options, void *reserved) { res = jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks)); JVMTI_ERROR_CHECK_DURING_ONLOAD("SetEventCallbacks returned error", res); - res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL); + res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, nullptr); JVMTI_ERROR_CHECK_DURING_ONLOAD("SetEventNotificationMode for VM_INIT returned error", res); - res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL); + res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, nullptr); JVMTI_ERROR_CHECK_DURING_ONLOAD("SetEventNotificationMode for vm death event returned error", res); return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/StackTraceController.cpp b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/StackTraceController.cpp index 5b907b42a7e..3e46cc25368 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/StackTraceController.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/StackTraceController.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -29,7 +29,7 @@ extern "C" { #define GET_OBJECT_CLASS(_class, _obj)\ if (!NSK_JNI_VERIFY(env, (_class = \ - env->GetObjectClass(_obj)) != NULL))\ + env->GetObjectClass(_obj)) != nullptr))\ return 2 #define CALL_STATIC_VOID_NOPARAM(_class, _methodName)\ @@ -39,12 +39,12 @@ extern "C" { #define GET_STATIC_METHOD_ID(_methodID, _class, _methodName, _sig)\ if (!NSK_JNI_VERIFY(env, (_methodID = \ - env->GetStaticMethodID(_class, _methodName, _sig)) != NULL))\ + env->GetStaticMethodID(_class, _methodName, _sig)) != nullptr))\ return 2 #define GET_METHOD_ID(_methodID, _class, _methodName, _sig)\ if (!NSK_JNI_VERIFY(env, (_methodID = \ - env->GetMethodID(_class, _methodName, _sig)) != NULL))\ + env->GetMethodID(_class, _methodName, _sig)) != nullptr))\ return 2 #define CALL_VOID_NOPARAM(_obj, _class, _methodName)\ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/ThreadController.cpp b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/ThreadController.cpp index 3e8530d0ecc..e5fbc02b46d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/ThreadController.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/ThreadController.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,17 +31,17 @@ extern "C" { #define FIND_CLASS(_class, _className)\ if (!NSK_JNI_VERIFY(env, (_class = \ - env->FindClass(_className)) != NULL))\ + env->FindClass(_className)) != nullptr))\ return #define GET_OBJECT_CLASS(_class, _obj)\ if (!NSK_JNI_VERIFY(env, (_class = \ - env->GetObjectClass(_obj)) != NULL))\ + env->GetObjectClass(_obj)) != nullptr))\ return #define GET_STATIC_FIELD_ID(_fieldID, _class, _fieldName, _fieldSig)\ if (!NSK_JNI_VERIFY(env, (_fieldID = \ - env->GetStaticFieldID(_class, _fieldName, _fieldSig)) != NULL))\ + env->GetStaticFieldID(_class, _fieldName, _fieldSig)) != nullptr))\ return #define GET_STATIC_OBJ_FIELD(_value, _class, _fieldName, _fieldSig)\ @@ -54,7 +54,7 @@ extern "C" { #define GET_FIELD_ID(_fieldID, _class, _fieldName, _fieldSig)\ if (!NSK_JNI_VERIFY(env, (_fieldID = \ - env->GetFieldID(_class, _fieldName, _fieldSig)) != NULL))\ + env->GetFieldID(_class, _fieldName, _fieldSig)) != nullptr))\ return #define GET_INT_FIELD(_value, _obj, _class, _fieldName)\ @@ -90,12 +90,12 @@ extern "C" { #define GET_STATIC_METHOD_ID(_methodID, _class, _methodName, _sig)\ if (!NSK_JNI_VERIFY(env, (_methodID = \ - env->GetStaticMethodID(_class, _methodName, _sig)) != NULL))\ + env->GetStaticMethodID(_class, _methodName, _sig)) != nullptr))\ return #define GET_METHOD_ID(_methodID, _class, _methodName, _sig)\ if (!NSK_JNI_VERIFY(env, (_methodID = \ - env->GetMethodID(_class, _methodName, _sig)) != NULL))\ + env->GetMethodID(_class, _methodName, _sig)) != nullptr))\ return #define CALL_STATIC_VOID_NOPARAM(_class, _methodName)\ @@ -134,7 +134,7 @@ extern "C" { #define NEW_OBJ(_obj, _class, _constructorName, _sig, _params)\ GET_METHOD_ID(method, _class, _constructorName, _sig);\ if (!NSK_JNI_VERIFY(env, (_obj = \ - env->NewObject(_class, method, _params)) != NULL))\ + env->NewObject(_class, method, _params)) != nullptr))\ return #define MONITOR_ENTER(x) \ @@ -487,23 +487,23 @@ extern "C" { jint state; if (!NSK_VERIFY(env->GetJavaVM(&vm) == 0)) { - return NULL; + return nullptr; } if (!NSK_VERIFY(vm->GetEnv((void **)&jvmti, JVMTI_VERSION_1) == JNI_OK)) { - return NULL; + return nullptr; } if (!NSK_VERIFY(jvmti->GetThreadState((jthread)thread, &state) == JVMTI_ERROR_NONE)) { - return NULL; + return nullptr; } stateName = getStateName(env, state); - if (!NSK_JNI_VERIFY(env, (ThreadState = env->FindClass("java/lang/Thread$State")) != NULL)) - return NULL; + if (!NSK_JNI_VERIFY(env, (ThreadState = env->FindClass("java/lang/Thread$State")) != nullptr)) + return nullptr; - if (!NSK_JNI_VERIFY(env, (method = env->GetStaticMethodID(ThreadState, "valueOf", "(Ljava/lang/String;)Ljava/lang/Thread$State;")) != NULL)) - return NULL; + if (!NSK_JNI_VERIFY(env, (method = env->GetStaticMethodID(ThreadState, "valueOf", "(Ljava/lang/String;)Ljava/lang/Thread$State;")) != nullptr)) + return nullptr; threadState = env->CallStaticObjectMethod(ThreadState, method, stateName); return threadState; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/Deadlock.cpp b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/Deadlock.cpp index 6e2c066b94e..5c9a22e2464 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/Deadlock.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/Deadlock.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -27,12 +27,12 @@ extern "C" { #define FIND_CLASS(_class, _className)\ if (!NSK_JNI_VERIFY(env, (_class = \ - env->FindClass(_className)) != NULL))\ + env->FindClass(_className)) != nullptr))\ return #define GET_OBJECT_CLASS(_class, _obj)\ if (!NSK_JNI_VERIFY(env, (_class = \ - env->GetObjectClass(_obj)) != NULL))\ + env->GetObjectClass(_obj)) != nullptr))\ return #define GET_OBJ_FIELD(_value, _obj, _class, _fieldName, _fieldSig)\ @@ -41,12 +41,12 @@ extern "C" { #define GET_FIELD_ID(_fieldID, _class, _fieldName, _fieldSig)\ if (!NSK_JNI_VERIFY(env, (_fieldID = \ - env->GetFieldID(_class, _fieldName, _fieldSig)) != NULL))\ + env->GetFieldID(_class, _fieldName, _fieldSig)) != nullptr))\ return #define GET_METHOD_ID(_methodID, _class, _methodName, _sig)\ if (!NSK_JNI_VERIFY(env, (_methodID = \ - env->GetMethodID(_class, _methodName, _sig)) != NULL)) \ + env->GetMethodID(_class, _methodName, _sig)) != nullptr)) \ return #define CALL_VOID_NOPARAM(_obj, _class, _methodName)\ @@ -72,23 +72,23 @@ JNIEXPORT void JNICALL Java_nsk_monitoring_share_thread_Deadlock_00024NativeLock FIND_CLASS(testBugClass, "nsk/share/TestBug"); GET_OBJ_FIELD(lock, o, nativeLockerClass, "lock", "Ljava/lang/Object;"); GET_OBJ_FIELD(step1, o, nativeLockerClass, "step1", "Lnsk/share/Wicket;"); - if (step1 == NULL) { + if (step1 == nullptr) { env->ThrowNew(testBugClass, "step1 field is null"); return; } GET_OBJ_FIELD(step2, o, nativeLockerClass, "step2", "Lnsk/share/Wicket;"); - if (step2 == NULL) { + if (step2 == nullptr) { env->ThrowNew(testBugClass, "step2 field is null"); return; } GET_OBJ_FIELD(step3, o, nativeLockerClass, "step3", "Lnsk/share/Wicket;"); - if (step3 == NULL) { + if (step3 == nullptr) { env->ThrowNew(testBugClass, "step3 field is null"); return; } GET_OBJ_FIELD(inner, o, lockerClass, "inner", "Lnsk/monitoring/share/thread/Deadlock$Locker;"); if (env->MonitorEnter(lock) == JNI_OK) { - if (inner == NULL) { + if (inner == nullptr) { env->ThrowNew(testBugClass, "Should not reach here"); } else { CALL_VOID_NOPARAM(step1, wicketClass, "unlock"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/LockingThreads.cpp b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/LockingThreads.cpp index c8870989fa6..604b0620c5b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/LockingThreads.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/LockingThreads.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -27,12 +27,12 @@ extern "C" { #define FIND_CLASS(_class, _className)\ if (!NSK_JNI_VERIFY(env, (_class = \ - env->FindClass(_className)) != NULL))\ + env->FindClass(_className)) != nullptr))\ return #define GET_OBJECT_CLASS(_class, _obj)\ if (!NSK_JNI_VERIFY(env, (_class = \ - env->GetObjectClass(_obj)) != NULL))\ + env->GetObjectClass(_obj)) != nullptr))\ return #define GET_OBJ_FIELD(_value, _obj, _class, _fieldName, _fieldSig)\ @@ -41,12 +41,12 @@ extern "C" { #define GET_FIELD_ID(_fieldID, _class, _fieldName, _fieldSig)\ if (!NSK_JNI_VERIFY(env, (_fieldID = \ - env->GetFieldID(_class, _fieldName, _fieldSig)) != NULL))\ + env->GetFieldID(_class, _fieldName, _fieldSig)) != nullptr))\ return #define GET_METHOD_ID(_methodID, _class, _methodName, _sig)\ if (!NSK_JNI_VERIFY(env, (_methodID = \ - env->GetMethodID(_class, _methodName, _sig)) != NULL))\ + env->GetMethodID(_class, _methodName, _sig)) != nullptr))\ return #define CALL_VOID_NOPARAM(_obj, _class, _methodName)\ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/RecursiveMonitoringThread.cpp b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/RecursiveMonitoringThread.cpp index d5349b037ff..6926c8f712e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/RecursiveMonitoringThread.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/RecursiveMonitoringThread.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -29,17 +29,17 @@ extern "C" { #define FIND_CLASS(_class, _className)\ if (!NSK_JNI_VERIFY(env, (_class = \ - env->FindClass(_className)) != NULL))\ + env->FindClass(_className)) != nullptr))\ return #define GET_OBJECT_CLASS(_class, _obj)\ if (!NSK_JNI_VERIFY(env, (_class = \ - env->GetObjectClass(_obj)) != NULL))\ + env->GetObjectClass(_obj)) != nullptr))\ return #define GET_STATIC_FIELD_ID(_fieldID, _class, _fieldName, _fieldSig)\ if (!NSK_JNI_VERIFY(env, (_fieldID = \ - env->GetStaticFieldID(_class, _fieldName, _fieldSig)) != NULL))\ + env->GetStaticFieldID(_class, _fieldName, _fieldSig)) != nullptr))\ return #define GET_STATIC_OBJ_FIELD(_value, _class, _fieldName, _fieldSig)\ @@ -52,7 +52,7 @@ extern "C" { #define GET_FIELD_ID(_fieldID, _class, _fieldName, _fieldSig)\ if (!NSK_JNI_VERIFY(env, (_fieldID = \ - env->GetFieldID(_class, _fieldName, _fieldSig)) != NULL))\ + env->GetFieldID(_class, _fieldName, _fieldSig)) != nullptr))\ return #define GET_INT_FIELD(_value, _obj, _class, _fieldName)\ @@ -84,12 +84,12 @@ extern "C" { #define GET_STATIC_METHOD_ID(_methodID, _class, _methodName, _sig)\ if (!NSK_JNI_VERIFY(env, (_methodID = \ - env->GetStaticMethodID(_class, _methodName, _sig)) != NULL))\ + env->GetStaticMethodID(_class, _methodName, _sig)) != nullptr))\ return #define GET_METHOD_ID(_methodID, _class, _methodName, _sig)\ if (!NSK_JNI_VERIFY(env, (_methodID = \ - env->GetMethodID(_class, _methodName, _sig)) != NULL))\ + env->GetMethodID(_class, _methodName, _sig)) != nullptr))\ return #define CALL_STATIC_VOID_NOPARAM(_class, _methodName)\ @@ -124,7 +124,7 @@ extern "C" { #define NEW_OBJ(_obj, _class, _constructorName, _sig, _params)\ GET_METHOD_ID(method, _class, _constructorName, _sig);\ if (!NSK_JNI_VERIFY(env, (_obj = \ - env->NewObject(_class, method, _params)) != NULL))\ + env->NewObject(_class, method, _params)) != nullptr))\ return #define MONITOR_ENTER(x) \ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/ExceptionCheckingJniEnv/exceptionjni001/exceptionjni001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/ExceptionCheckingJniEnv/exceptionjni001/exceptionjni001.cpp index 342ef4d2ccd..1c70c90388e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/ExceptionCheckingJniEnv/exceptionjni001/exceptionjni001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/ExceptionCheckingJniEnv/exceptionjni001/exceptionjni001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2019, Google and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -33,9 +33,9 @@ // methods. static bool is_error_called; static const char* const null_return_expected_message_start = - "JNI method GetFieldID : Return is NULL from exceptionjni001.cpp : "; + "JNI method GetFieldID : Return is null from exceptionjni001.cpp : "; static const char* const null_file_expected_message_start = - "JNI method GetFieldID : Return is NULL from Unknown File : "; + "JNI method GetFieldID : Return is null from Unknown File : "; // Used by the ErrorCheckerMessage and the tests to determine test success. static long expected_line_number; @@ -52,11 +52,11 @@ static bool CheckMessage(JNIEnv* env, const char* message, const char* expected_ size_t len = strlen(expected_message); - char* end_ptr = NULL; + char* end_ptr = nullptr; long actual_line = strtol(message + len, &end_ptr, 0); - if (end_ptr == NULL || *end_ptr != '\0') { - fprintf(stderr, "end_ptr == NULL or *end_ptr terminating from %s\n", message); + if (end_ptr == nullptr || *end_ptr != '\0') { + fprintf(stderr, "end_ptr == null or *end_ptr terminating from %s\n", message); return false; } @@ -101,7 +101,7 @@ static bool checkFailureMessageEmptyFile(JNIEnv* env, jclass cls) { expected_message_start = null_file_expected_message_start; expected_line_number = __LINE__ + 1; - ec_jni->GetFieldID(cls, "whatever", "does not matter", __LINE__, NULL); + ec_jni->GetFieldID(cls, "whatever", "does not matter", __LINE__, nullptr); return is_error_called && error_message_ok; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/JVMDITools.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/JVMDITools.cpp deleted file mode 100644 index 33aa56da538..00000000000 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/JVMDITools.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "jvmdi.h" -#include "JVMDITools.h" - -extern "C" { - -char const *TranslateEvent(jint kind) { - switch (kind) { - case JVMDI_EVENT_SINGLE_STEP: - return ("JVMDI_EVENT_SINGLE_STEP"); - case JVMDI_EVENT_BREAKPOINT: - return ("JVMDI_EVENT_BREAKPOINT"); - case JVMDI_EVENT_FRAME_POP: - return ("JVMDI_EVENT_FRAME_POP"); - case JVMDI_EVENT_EXCEPTION: - return ("JVMDI_EVENT_EXCEPTION"); - case JVMDI_EVENT_USER_DEFINED: - return ("JVMDI_EVENT_USER_DEFINED"); - case JVMDI_EVENT_THREAD_START: - return ("JVMDI_EVENT_THREAD_START"); - case JVMDI_EVENT_THREAD_END: - return ("JVMDI_EVENT_THREAD_END"); - case JVMDI_EVENT_CLASS_PREPARE: - return ("JVMDI_EVENT_CLASS_PREPARE"); - case JVMDI_EVENT_CLASS_UNLOAD: - return ("JVMDI_EVENT_CLASS_UNLOAD"); - case JVMDI_EVENT_CLASS_LOAD: - return ("JVMDI_EVENT_CLASS_LOAD"); - case JVMDI_EVENT_FIELD_ACCESS: - return ("JVMDI_EVENT_FIELD_ACCESS"); - case JVMDI_EVENT_FIELD_MODIFICATION: - return ("JVMDI_EVENT_FIELD_MODIFICATION"); - case JVMDI_EVENT_EXCEPTION_CATCH: - return ("JVMDI_EVENT_EXCEPTION_CATCH"); - case JVMDI_EVENT_METHOD_ENTRY: - return ("JVMDI_EVENT_METHOD_ENTRY"); - case JVMDI_EVENT_METHOD_EXIT: - return ("JVMDI_EVENT_METHOD_EXIT"); - case JVMDI_EVENT_VM_INIT: - return ("JVMDI_EVENT_VM_INIT"); - case JVMDI_EVENT_VM_DEATH: - return ("JVMDI_EVENT_VM_DEATH"); - default: - return (""); - } -} - -char const *TranslateError(jvmdiError err) { - switch (err) { - case JVMDI_ERROR_NONE: - return ("JVMDI_ERROR_NONE"); - case JVMDI_ERROR_OUT_OF_MEMORY: - return ("JVMDI_ERROR_OUT_OF_MEMORY"); - case JVMDI_ERROR_ACCESS_DENIED: - return ("JVMDI_ERROR_ACCESS_DENIED"); - case JVMDI_ERROR_UNATTACHED_THREAD: - return ("JVMDI_ERROR_UNATTACHED_THREAD"); - case JVMDI_ERROR_VM_DEAD: - return ("JVMDI_ERROR_VM_DEAD"); - case JVMDI_ERROR_INTERNAL: - return ("JVMDI_ERROR_INTERNAL"); - case JVMDI_ERROR_INVALID_THREAD: - return ("JVMDI_ERROR_INVALID_THREAD"); - case JVMDI_ERROR_INVALID_FIELDID: - return ("JVMDI_ERROR_INVALID_FIELDID"); - case JVMDI_ERROR_INVALID_METHODID: - return ("JVMDI_ERROR_INVALID_METHODID"); - case JVMDI_ERROR_INVALID_LOCATION: - return ("JVMDI_ERROR_INVALID_LOCATION"); - case JVMDI_ERROR_INVALID_FRAMEID: - return ("JVMDI_ERROR_INVALID_FRAMEID"); - case JVMDI_ERROR_NO_MORE_FRAMES: - return ("JVMDI_ERROR_NO_MORE_FRAMES"); - case JVMDI_ERROR_OPAQUE_FRAME: - return ("JVMDI_ERROR_OPAQUE_FRAME"); - case JVMDI_ERROR_NOT_CURRENT_FRAME: - return ("JVMDI_ERROR_NOT_CURRENT_FRAME"); - case JVMDI_ERROR_TYPE_MISMATCH: - return ("JVMDI_ERROR_TYPE_MISMATCH"); - case JVMDI_ERROR_INVALID_SLOT: - return ("JVMDI_ERROR_INVALID_SLOT"); - case JVMDI_ERROR_DUPLICATE: - return ("JVMDI_ERROR_DUPLICATE"); - case JVMDI_ERROR_THREAD_NOT_SUSPENDED: - return ("JVMDI_ERROR_THREAD_NOT_SUSPENDED"); - case JVMDI_ERROR_THREAD_SUSPENDED: - return ("JVMDI_ERROR_THREAD_SUSPENDED"); - case JVMDI_ERROR_INVALID_OBJECT: - return ("JVMDI_ERROR_INVALID_OBJECT"); - case JVMDI_ERROR_INVALID_CLASS: - return ("JVMDI_ERROR_INVALID_CLASS"); - case JVMDI_ERROR_CLASS_NOT_PREPARED: - return ("JVMDI_ERROR_CLASS_NOT_PREPARED"); - case JVMDI_ERROR_NULL_POINTER: - return ("JVMDI_ERROR_NULL_POINTER"); - case JVMDI_ERROR_ABSENT_INFORMATION: - return ("JVMDI_ERROR_ABSENT_INFORMATION"); - case JVMDI_ERROR_INVALID_EVENT_TYPE: - return ("JVMDI_ERROR_INVALID_EVENT_TYPE"); - case JVMDI_ERROR_NOT_IMPLEMENTED: - return ("JVMDI_ERROR_NOT_IMPLEMENTED"); - case JVMDI_ERROR_INVALID_THREAD_GROUP: - return ("JVMDI_ERROR_INVALID_THREAD_GROUP"); - case JVMDI_ERROR_INVALID_PRIORITY: - return ("JVMDI_ERROR_INVALID_PRIORITY"); - case JVMDI_ERROR_NOT_FOUND: - return ("JVMDI_ERROR_NOT_FOUND"); - case JVMDI_ERROR_INVALID_MONITOR: - return ("JVMDI_ERROR_INVALID_MONITOR"); - case JVMDI_ERROR_ILLEGAL_ARGUMENT: - return ("JVMDI_ERROR_ILLEGAL_ARGUMENT"); - case JVMDI_ERROR_NOT_MONITOR_OWNER: - return ("JVMDI_ERROR_NOT_MONITOR_OWNER"); - case JVMDI_ERROR_INTERRUPT: - return ("JVMDI_ERROR_INTERRUPT"); - case JVMDI_ERROR_INVALID_TYPESTATE: - return ("JVMDI_ERROR_INVALID_TYPESTATE"); - case JVMDI_ERROR_INVALID_CLASS_FORMAT: - return ("JVMDI_ERROR_INVALID_CLASS_FORMAT"); - case JVMDI_ERROR_CIRCULAR_CLASS_DEFINITION: - return ("JVMDI_ERROR_CIRCULAR_CLASS_DEFINITION"); - case JVMDI_ERROR_ADD_METHOD_NOT_IMPLEMENTED: - return ("JVMDI_ERROR_ADD_METHOD_NOT_IMPLEMENTED"); - case JVMDI_ERROR_SCHEMA_CHANGE_NOT_IMPLEMENTED: - return ("JVMDI_ERROR_SCHEMA_CHANGE_NOT_IMPLEMENTED"); - case JVMDI_ERROR_FAILS_VERIFICATION: - return ("JVMDI_ERROR_FAILS_VERIFICATION"); -#ifdef JVMDI_VERSION_1_2 - case JVMDI_ERROR_UNSUPPORTED_VERSION: - return ("JVMDI_ERROR_UNSUPPORTED_VERSION"); - case JVMDI_ERROR_HIERARCHY_CHANGE_NOT_IMPLEMENTED: - return ("JVMDI_ERROR_HIERARCHY_CHANGE_NOT_IMPLEMENTED"); - case JVMDI_ERROR_DELETE_METHOD_NOT_IMPLEMENTED: - return ("JVMDI_ERROR_DELETE_METHOD_NOT_IMPLEMENTED"); - case JVMDI_ERROR_NAMES_DONT_MATCH: - return ("JVMDI_ERROR_NAMES_DONT_MATCH"); - case JVMDI_ERROR_CLASS_MODIFIERS_CHANGE_NOT_IMPLEMENTED: - return ("JVMDI_ERROR_CLASS_MODIFIERS_CHANGE_NOT_IMPLEMENTED"); - case JVMDI_ERROR_METHOD_MODIFIERS_CHANGE_NOT_IMPLEMENTED: - return ("JVMDI_ERROR_METHOD_MODIFIERS_CHANGE_NOT_IMPLEMENTED"); -#endif - default: - return (""); - } -} - -} diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/JVMTIagent.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/JVMTIagent.cpp index 69dc2da5b57..59395c6fcf6 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/JVMTIagent.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/JVMTIagent.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ extern "C" { -static jvmtiEnv *jvmti = NULL; /* JVMTI env */ +static jvmtiEnv *jvmti = nullptr; /* JVMTI env */ static jvmtiEventCallbacks callbacks; static jrawMonitorID eventLock; /* raw monitor used for exclusive ownership of HotSwap function */ @@ -106,9 +106,9 @@ typedef struct { /* test class info */ } class_info; -static const char *shortTestName = NULL; /* name of the test without package prefix */ +static const char *shortTestName = nullptr; /* name of the test without package prefix */ static jclass rasCls; /* reference to the auxiliary class RASagent used for HotSwap */ -static class_info *clsInfo = NULL, *clsInfoFst = NULL; +static class_info *clsInfo = nullptr, *clsInfoFst = nullptr; static void lock(JNIEnv*); static void unlock(JNIEnv*); @@ -160,11 +160,11 @@ ClassLoad(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jclass klass) { lock(jni_env); display(0, "#### JVMTIagent: ClassLoad: >>>>>>>> entered the raw monitor \"eventLock\" ####\n"); - if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &cls_sig, /*&generic*/NULL))) + if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &cls_sig, /*&generic*/nullptr))) jni_env->FatalError("JVMTIagent: failed to get class signature\n"); else { - if (shortTestName != NULL) { - if (strstr((const char*) cls_sig, shortTestName) != NULL) { + if (shortTestName != nullptr) { + if (strstr((const char*) cls_sig, shortTestName) != nullptr) { display(0, "#### JVMTIagent: found test class matched with \"%s\"\n" "\tsignature=%s\n", @@ -198,7 +198,7 @@ CompiledMethodLoad(jvmtiEnv *jvmti_env, jmethodID method, jint code_size, display(1, "#### JVMTIagent: CompiledMethodLoad occurred ####\n"); - getVerdict(NULL, "CompiledMethodLoad"); + getVerdict(nullptr, "CompiledMethodLoad"); } void JNICALL @@ -207,7 +207,7 @@ CompiledMethodUnload(jvmtiEnv *jvmti_env, jmethodID method, display(1, "#### JVMTIagent: CompiledMethodUnload occurred ####\n"); - getVerdict(NULL, "CompiledMethodUnload"); + getVerdict(nullptr, "CompiledMethodUnload"); } void JNICALL @@ -215,7 +215,7 @@ DataDumpRequest(jvmtiEnv *jvmti_env) { display(1, "#### JVMTIagent: DataDumpRequest occurred ####\n"); - getVerdict(NULL, "DataDumpRequest"); + getVerdict(nullptr, "DataDumpRequest"); } void JNICALL @@ -226,7 +226,7 @@ DynamicCodeGenerated(jvmtiEnv *jvmti_env, display(1, "#### JVMTIagent: DynamicCodeGenerated occurred ####\n"); - getVerdict(NULL, "DynamicCodeGenerated"); + getVerdict(nullptr, "DynamicCodeGenerated"); } void JNICALL @@ -286,7 +286,7 @@ GarbageCollectionFinish(jvmtiEnv *jvmti_env) { display(1, "#### JVMTIagent: GarbageCollectionFinish occurred ####\n"); - getVerdict(NULL, "GarbageCollectionFinish"); + getVerdict(nullptr, "GarbageCollectionFinish"); } void JNICALL @@ -294,7 +294,7 @@ GarbageCollectionStart(jvmtiEnv *jvmti_env) { display(1, "#### JVMTIagent: GarbageCollectionStart occurred ####\n"); - getVerdict(NULL, "GarbageCollectionStart"); + getVerdict(nullptr, "GarbageCollectionStart"); } void JNICALL @@ -347,7 +347,7 @@ ObjectFree(jvmtiEnv *jvmti_env, jlong tag) { display(1, "#### JVMTIagent: ObjectFree occurred ####\n"); - getVerdict(NULL, "ObjectFree"); + getVerdict(nullptr, "ObjectFree"); } void JNICALL @@ -489,10 +489,10 @@ JNIEXPORT jint JNICALL Java_nsk_share_RASagent_setHotSwapMode(JNIEnv *jni_env, jclass cls, jboolean vrb, jint level, jstring shortName) { jvmtiCapabilities capabil; - jmethodID mid = NULL; + jmethodID mid = nullptr; - if (jvmti == NULL) { - printf("ERROR(%s,%d): JVMTIagent was not properly loaded: JVMTI env = NULL\n", + if (jvmti == nullptr) { + printf("ERROR(%s,%d): JVMTIagent was not properly loaded: JVMTI env = null\n", __FILE__, __LINE__); return 1; } @@ -554,14 +554,14 @@ Java_nsk_share_RASagent_setHotSwapMode(JNIEnv *jni_env, jclass cls, return 1; } - if (!NSK_JNI_VERIFY(jni_env, (shortTestName = jni_env->GetStringUTFChars(shortName, NULL)) != NULL)) { + if (!NSK_JNI_VERIFY(jni_env, (shortTestName = jni_env->GetStringUTFChars(shortName, nullptr)) != nullptr)) { printf("ERROR: JVMTIagent: unable to get UTF-8 characters of the string\n"); return 1; } display(0, "#### JVMTIagent: short name of current test is \"%s\"\n", shortTestName); - if (!NSK_JNI_VERIFY(jni_env, (rasCls = jni_env->NewGlobalRef(cls)) != NULL)) { + if (!NSK_JNI_VERIFY(jni_env, (rasCls = jni_env->NewGlobalRef(cls)) != nullptr)) { printf("ERROR JVMTIagent: unable to create a new global reference of the class \"RASagent\"\n"); return 1; } @@ -576,19 +576,19 @@ Java_nsk_share_RASagent_setHotSwapMode(JNIEnv *jni_env, jclass cls, } static jint allocClsInfo(JNIEnv *jni_env, char *cls_sig, jclass clazz) { - class_info *_clsInfo = NULL; - jmethodID mid = NULL; + class_info *_clsInfo = nullptr; + jmethodID mid = nullptr; jbyteArray classBytes; jboolean isCopy; _clsInfo = (class_info*) malloc(sizeof(class_info)); - if (_clsInfo == NULL) + if (_clsInfo == nullptr) jni_env->FatalError("JVMTIagent: cannot allocate memory for class_info\n"); /* fill the structure class_info */ _clsInfo->clazzsig = cls_sig; - if (!NSK_JNI_VERIFY(jni_env, ((*_clsInfo).cls = jni_env->NewGlobalRef(clazz)) != NULL)) { + if (!NSK_JNI_VERIFY(jni_env, ((*_clsInfo).cls = jni_env->NewGlobalRef(clazz)) != nullptr)) { printf("ERROR: JVMTIagent: unable to create a new global reference of class \"%s\"\n", _clsInfo->clazzsig); free(_clsInfo); @@ -597,7 +597,7 @@ static jint allocClsInfo(JNIEnv *jni_env, char *cls_sig, jclass clazz) { } if (!NSK_JNI_VERIFY(jni_env, (mid = - jni_env->GetStaticMethodID(rasCls, "loadFromClassFile", "(Ljava/lang/String;)[B")) != NULL)) + jni_env->GetStaticMethodID(rasCls, "loadFromClassFile", "(Ljava/lang/String;)[B")) != nullptr)) jni_env->FatalError("JVMTIagent: unable to get ID of the method \"loadFromClassFile\"\n"); classBytes = (jbyteArray) jni_env->CallStaticObjectMethod(rasCls, mid, jni_env->NewStringUTF(cls_sig)); @@ -609,9 +609,9 @@ static jint allocClsInfo(JNIEnv *jni_env, char *cls_sig, jclass clazz) { (*_clsInfo).clsBytes = jni_env->GetByteArrayElements(classBytes, &isCopy); - _clsInfo->next = NULL; + _clsInfo->next = nullptr; - if (clsInfo != NULL) { + if (clsInfo != nullptr) { clsInfo->next = (struct class_info*) _clsInfo; } else { @@ -627,7 +627,7 @@ static void deallocClsInfo(JNIEnv *jni_env) { NSK_TRACE(jni_env->DeleteGlobalRef(rasCls)); - while (clsInfoCurr != NULL) { + while (clsInfoCurr != nullptr) { class_info *_clsInfo = clsInfoCurr; if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*) clsInfoCurr->clazzsig))) @@ -640,16 +640,16 @@ static void deallocClsInfo(JNIEnv *jni_env) { free(_clsInfo); } /* fix for 4756585: indicate that stucture class_info is empty now */ - clsInfoFst = NULL; + clsInfoFst = nullptr; } static int findAndHotSwap(JNIEnv *jni_env, jclass clazz) { int ret_code = 0; - char *clazzsig = NULL; + char *clazzsig = nullptr; class_info *clsInfoCurr = clsInfoFst; display(1, "\n#### JVMTIagent: findAndHotSwap: obtaining class signature of class to be hotswap ...\n"); - if (!NSK_JVMTI_VERIFY(jvmti->GetClassSignature(clazz, &clazzsig, /*&generic*/NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->GetClassSignature(clazz, &clazzsig, /*&generic*/nullptr))) jni_env->FatalError("JVMTIagent: findAndHotSwap: failed to get class signature\n"); else { display(1, "#### JVMTIagent: findAndHotSwap: ... class signature obtained: \"%s\"\n", @@ -659,7 +659,7 @@ static int findAndHotSwap(JNIEnv *jni_env, jclass clazz) { lock(jni_env); display(0, "#### JVMTIagent: findAndHotSwap: >>>>>>>> entered the raw monitor \"eventLock\" ####\n"); - while (clsInfoCurr != NULL) { + while (clsInfoCurr != nullptr) { if (hotswap == HOTSWAP_EVERY_METHOD_ENTRY_FOR_EVERY_CLASS || hotswap == HOTSWAP_EVERY_EXCEPTION_FOR_EVERY_CLASS) { display(1, "\n#### JVMTIagent: findAndHotSwap: going to hotswap tested class \"%s\" during execution of class \"%s\" ...\n", @@ -735,7 +735,7 @@ static int addStressEvents() { callbacks.SingleStep = &SingleStep; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, nullptr))) return JNI_ERR; stepEventSet = JNI_TRUE; @@ -751,7 +751,7 @@ static int addStressEvents() { callbacks.MethodEntry = &MethodEntry; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_ENTRY, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_ENTRY, nullptr))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting MethodEntry events done\n"); @@ -761,7 +761,7 @@ static int addStressEvents() { callbacks.MethodExit = &MethodExit; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_EXIT, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_EXIT, nullptr))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting MethodExit events done\n"); @@ -777,7 +777,7 @@ static int addStressEvents() { callbacks.ExceptionCatch = &ExceptionCatch; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION_CATCH, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION_CATCH, nullptr))) return JNI_ERR; excCatchEventSet = JNI_TRUE; @@ -822,7 +822,7 @@ static int enableEventsCaps() { callbacks.Breakpoint = &Breakpoint; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, nullptr))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting Breakpoint events done\n"); @@ -831,7 +831,7 @@ static int enableEventsCaps() { callbacks.ClassFileLoadHook = &ClassFileLoadHook; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, nullptr))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting ClassFileLoadHook events done\n"); @@ -840,7 +840,7 @@ static int enableEventsCaps() { callbacks.ClassLoad = &ClassLoad; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, nullptr))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting ClassLoad events done\n"); @@ -849,7 +849,7 @@ static int enableEventsCaps() { callbacks.ClassPrepare = &ClassPrepare; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_PREPARE, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_PREPARE, nullptr))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting ClassPrepare events done\n"); @@ -858,7 +858,7 @@ static int enableEventsCaps() { callbacks.CompiledMethodLoad = &CompiledMethodLoad; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_LOAD, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_LOAD, nullptr))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting CompiledMethodLoad events done\n"); @@ -867,7 +867,7 @@ static int enableEventsCaps() { callbacks.CompiledMethodUnload = &CompiledMethodUnload; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_UNLOAD, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_UNLOAD, nullptr))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting CompiledMethodUnload events done\n"); @@ -876,7 +876,7 @@ static int enableEventsCaps() { callbacks.DataDumpRequest = &DataDumpRequest; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_DATA_DUMP_REQUEST, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_DATA_DUMP_REQUEST, nullptr))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting DataDumpRequest events done\n"); @@ -885,7 +885,7 @@ static int enableEventsCaps() { callbacks.DynamicCodeGenerated = &DynamicCodeGenerated; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_DYNAMIC_CODE_GENERATED, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_DYNAMIC_CODE_GENERATED, nullptr))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting DynamicCodeGenerated events done\n"); @@ -894,7 +894,7 @@ static int enableEventsCaps() { callbacks.Exception = &Exception; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION, nullptr))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting Exception events done\n"); @@ -903,7 +903,7 @@ static int enableEventsCaps() { callbacks.FieldAccess = &FieldAccess; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FIELD_ACCESS, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FIELD_ACCESS, nullptr))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting FieldAccess events done\n"); @@ -912,7 +912,7 @@ static int enableEventsCaps() { callbacks.FieldModification = &FieldModification; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FIELD_MODIFICATION, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FIELD_MODIFICATION, nullptr))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting FieldModification events done\n"); @@ -921,7 +921,7 @@ static int enableEventsCaps() { callbacks.FramePop = &FramePop; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FRAME_POP, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_FRAME_POP, nullptr))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting FramePop events done\n"); @@ -930,7 +930,7 @@ static int enableEventsCaps() { callbacks.GarbageCollectionFinish = &GarbageCollectionFinish; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_FINISH, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_FINISH, nullptr))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting GarbageCollectionFinish events done\n"); @@ -939,7 +939,7 @@ static int enableEventsCaps() { callbacks.GarbageCollectionStart = &GarbageCollectionStart; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_START, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_GARBAGE_COLLECTION_START, nullptr))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting GarbageCollectionStart events done\n"); @@ -948,7 +948,7 @@ static int enableEventsCaps() { callbacks.MonitorContendedEnter = &MonitorContendedEnter; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTER, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTER, nullptr))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting MonitorContendedEnter events done\n"); @@ -957,7 +957,7 @@ static int enableEventsCaps() { callbacks.MonitorContendedEntered = &MonitorContendedEntered; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTERED, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTERED, nullptr))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting MonitorContendedEntered events done\n"); @@ -966,7 +966,7 @@ static int enableEventsCaps() { callbacks.MonitorWait = &MonitorWait; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_WAIT, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_WAIT, nullptr))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting MonitorWait events done\n"); @@ -975,7 +975,7 @@ static int enableEventsCaps() { callbacks.MonitorWaited = &MonitorWaited; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_WAITED, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_WAITED, nullptr))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting MonitorWaited events done\n"); @@ -984,7 +984,7 @@ static int enableEventsCaps() { callbacks.NativeMethodBind = &NativeMethodBind; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_NATIVE_METHOD_BIND, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_NATIVE_METHOD_BIND, nullptr))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting NativeMethodBind events done\n"); @@ -993,7 +993,7 @@ static int enableEventsCaps() { callbacks.ObjectFree = &ObjectFree; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_OBJECT_FREE, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_OBJECT_FREE, nullptr))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting ObjectFree events done\n"); @@ -1002,7 +1002,7 @@ static int enableEventsCaps() { callbacks.ThreadEnd = &ThreadEnd; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_END, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_END, nullptr))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting ThreadEnd events done\n"); @@ -1011,7 +1011,7 @@ static int enableEventsCaps() { callbacks.ThreadStart = &ThreadStart; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, nullptr))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting ThreadStart events done\n"); @@ -1020,7 +1020,7 @@ static int enableEventsCaps() { callbacks.VMDeath = &VMDeath; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, nullptr))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting VMDeath events done\n"); @@ -1029,7 +1029,7 @@ static int enableEventsCaps() { callbacks.VMInit = &VMInit; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, nullptr))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting VMInit events done\n"); @@ -1038,7 +1038,7 @@ static int enableEventsCaps() { callbacks.VMStart = &VMStart; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_START, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_START, nullptr))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting VMStart events done\n"); @@ -1047,7 +1047,7 @@ static int enableEventsCaps() { callbacks.VMObjectAlloc = &VMObjectAlloc; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_OBJECT_ALLOC, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_OBJECT_ALLOC, nullptr))) return JNI_ERR; display(0, "#### JVMTIagent: ... setting VMObjectAlloc events done\n"); @@ -1153,7 +1153,7 @@ static void getVerdict(JNIEnv *jni_env, const char *evnt) { snprintf(error_msg, sizeof(error_msg), "JVMTIagent: getVerdict: %s event occured after VMDeath", evnt); - if (jni_env == NULL) { /* some event callbacks have no pointer to jni */ + if (jni_env == nullptr) { /* some event callbacks have no pointer to jni */ printf("ERROR: %s\n", error_msg); exit(97); } @@ -1181,7 +1181,7 @@ JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; doSetup(options); @@ -1198,7 +1198,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { } /* register agent proc and arg */ - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/README b/test/hotspot/jtreg/vmTestbase/nsk/share/README index c8f51bcfbb6..d36f955659b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/README +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/README @@ -59,8 +59,6 @@ Short description of files: Denotation.java, TreeNodesDenotation.java RAS mode support: RASagent.java, JVMTIagent.c - JVMDI tests support: - JVMDITools.h, JVMDITools.c Short description of subdirectories: diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/aod/aod.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/aod/aod.cpp index 4219ad9a0f4..b3b076b2ef7 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/aod/aod.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/aod/aod.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,13 +44,13 @@ void nsk_aod_internal_error() { } void nsk_free_options(Options* options) { - if (options != NULL) { + if (options != nullptr) { int i; for (i = 0; i < NSK_AOD_MAX_OPTIONS; i++) { - if (options->names[i] != NULL) { + if (options->names[i] != nullptr) { free(options->names[i]); } - if (options->values[i] != NULL) { + if (options->values[i] != nullptr) { free(options->values[i]); } } @@ -71,20 +71,20 @@ static Options* nsk_aod_createOptionsObject(char* optionsString) { char* value; char* sep; - if (optionsString == NULL) { + if (optionsString == nullptr) { NSK_COMPLAIN0("options were not passed to the native agent\n"); - return NULL; + return nullptr; } options = (Options*) malloc(sizeof(Options)); memset(options, 0, sizeof(Options)); options->size = 0; name = optionsString; - while (name != NULL && i < NSK_AOD_MAX_OPTIONS) { + while (name != nullptr && i < NSK_AOD_MAX_OPTIONS) { sep = strchr(name, '='); - if (sep == NULL) { // name not found + if (sep == nullptr) { // name not found NSK_COMPLAIN1("Invalid options format: '%s'\n", optionsString); nsk_free_options(options); - return NULL; + return nullptr; } *sep = '\0'; options->names[i] = strdup(name); @@ -92,10 +92,10 @@ static Options* nsk_aod_createOptionsObject(char* optionsString) { if (*value == '\0') { // value not found NSK_COMPLAIN1("Option '%s' is empty\n", options->names[i]); nsk_free_options(options); - return NULL; + return nullptr; } sep = strchr(value, ' '); - if (sep != NULL) { + if (sep != nullptr) { *sep = '\0'; name = sep + 1; } else { @@ -105,10 +105,10 @@ static Options* nsk_aod_createOptionsObject(char* optionsString) { i++; if (*name == '\0') { - name = NULL; + name = nullptr; } } - if (name != NULL) { + if (name != nullptr) { NSK_COMPLAIN1("WARNING: not all options were parsed, only %d options can be specified\n", NSK_AOD_MAX_OPTIONS); } @@ -119,12 +119,12 @@ static Options* nsk_aod_createOptionsObject(char* optionsString) { Options* nsk_aod_createOptions(char* optionsString) { Options* options; - if (!NSK_VERIFY((options = (Options*) nsk_aod_createOptionsObject(optionsString)) != NULL)) - return NULL; + if (!NSK_VERIFY((options = (Options*) nsk_aod_createOptionsObject(optionsString)) != nullptr)) + return nullptr; if (!NSK_VERIFY(nsk_aod_optionSpecified(options, NSK_AOD_AGENT_NAME_OPTION))) { NSK_COMPLAIN0("Agent name wasn't specified\n"); - return NULL; + return nullptr; } /* @@ -143,9 +143,9 @@ Options* nsk_aod_createOptions(char* optionsString) { const char* nsk_aod_getOptionValue(Options* options, const char* option) { int i; - if (!NSK_VERIFY(options != NULL)) { - NSK_COMPLAIN0("Options NULL\n"); - return NULL; + if (!NSK_VERIFY(options != nullptr)) { + NSK_COMPLAIN0("Options null\n"); + return nullptr; } for (i = 0; i < options->size; i++) { @@ -156,14 +156,14 @@ const char* nsk_aod_getOptionValue(Options* options, const char* option) { NSK_COMPLAIN1("Option '%s' isn't defined\n", option); - return NULL; + return nullptr; } int nsk_aod_optionSpecified(Options* options, const char* option) { int i; - if (!NSK_VERIFY(options != NULL)) { - NSK_COMPLAIN0("Options NULL\n"); + if (!NSK_VERIFY(options != nullptr)) { + NSK_COMPLAIN0("Options null\n"); return NSK_FALSE; } @@ -188,9 +188,9 @@ static const char* AGENT_LOADED_METHOD_SIGNATURE = "(Ljava/lang/String;)V"; static const char* AGENT_FINISHED_METHOD_NAME = "agentFinished"; static const char* AGENT_FINISHED_METHOD_SIGNATURE = "(Ljava/lang/String;Z)V"; -static jclass targetAppClass = NULL; -static jmethodID agentLoadedMethod = NULL; -static jmethodID agentFinishedMethod = NULL; +static jclass targetAppClass = nullptr; +static jmethodID agentLoadedMethod = nullptr; +static jmethodID agentFinishedMethod = nullptr; // this function is used to notify target application that native agent has been loaded int nsk_aod_agentLoaded(JNIEnv* jni, const char* agentName) { @@ -198,31 +198,31 @@ int nsk_aod_agentLoaded(JNIEnv* jni, const char* agentName) { NSK_DISPLAY1("Agent %s is loaded\n", agentName); - if (targetAppClass == NULL) { + if (targetAppClass == nullptr) { /* * FindClass returns local reference, to cache reference to target application class * global reference should be created */ jclass localTargetAppClass; if (!NSK_JNI_VERIFY(jni, (localTargetAppClass = - jni->FindClass(TARGET_APP_CLASS_NAME)) != NULL)) { + jni->FindClass(TARGET_APP_CLASS_NAME)) != nullptr)) { return NSK_FALSE; } if (!NSK_JNI_VERIFY(jni, (targetAppClass = (jclass) - jni->NewGlobalRef(localTargetAppClass)) != NULL)) { + jni->NewGlobalRef(localTargetAppClass)) != nullptr)) { return NSK_FALSE; } } - if (agentLoadedMethod == NULL) { + if (agentLoadedMethod == nullptr) { if (!NSK_JNI_VERIFY(jni, (agentLoadedMethod = - jni->GetStaticMethodID(targetAppClass, AGENT_LOADED_METHOD_NAME, AGENT_LOADED_METHOD_SIGNATURE)) != NULL)) + jni->GetStaticMethodID(targetAppClass, AGENT_LOADED_METHOD_NAME, AGENT_LOADED_METHOD_SIGNATURE)) != nullptr)) return NSK_FALSE; } if (!NSK_JNI_VERIFY(jni, (agentNameString = - jni->NewStringUTF(agentName)) != NULL)) + jni->NewStringUTF(agentName)) != nullptr)) return NSK_FALSE; jni->CallStaticVoidMethod(targetAppClass, agentLoadedMethod, agentNameString); @@ -252,13 +252,13 @@ int nsk_aod_agentFinished(JNIEnv* jni, const char* agentName, int success) { NSK_DISPLAY2("Agent %s finished (success: %d)\n", agentName, success); - if (agentFinishedMethod == NULL) { + if (agentFinishedMethod == nullptr) { if (!NSK_JNI_VERIFY(jni, (agentFinishedMethod = - jni->GetStaticMethodID(targetAppClass, AGENT_FINISHED_METHOD_NAME, AGENT_FINISHED_METHOD_SIGNATURE)) != NULL)) + jni->GetStaticMethodID(targetAppClass, AGENT_FINISHED_METHOD_NAME, AGENT_FINISHED_METHOD_SIGNATURE)) != nullptr)) return NSK_FALSE; } - if (!NSK_JNI_VERIFY(jni, (agentNameString = jni->NewStringUTF(agentName)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (agentNameString = jni->NewStringUTF(agentName)) != nullptr)) return NSK_FALSE; jni->CallStaticVoidMethod(targetAppClass, agentFinishedMethod, agentNameString, success ? JNI_TRUE : JNI_FALSE); @@ -276,7 +276,7 @@ JNIEnv* nsk_aod_createJNIEnv(JavaVM* vm) { JNIEnv* jni; vm->GetEnv((void**)&jni, JNI_VERSION_1_2); - NSK_VERIFY(jni != NULL); + NSK_VERIFY(jni != nullptr); return jni; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/BooleanArrayCriticalLocker.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/BooleanArrayCriticalLocker.cpp index a64f108222f..2ad70dfe076 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/BooleanArrayCriticalLocker.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/BooleanArrayCriticalLocker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -28,7 +28,7 @@ extern "C" { -static jfieldID objFieldId = NULL; +static jfieldID objFieldId = nullptr; /* * Class: nsk_share_gc_lock_jni_BooleanArrayCriticalLocker @@ -45,31 +45,31 @@ JNIEXPORT jboolean JNICALL Java_nsk_share_gc_lock_jni_BooleanArrayCriticalLocker jboolean hash = JNI_TRUE; time_t start_time, current_time; - if (objFieldId == NULL) { + if (objFieldId == nullptr) { jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL); objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL); } arr = (jbooleanArray) ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL); - ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL); + ec_jni->SetObjectField(o, objFieldId, nullptr, TRACE_JNI_CALL); size = ec_jni->GetArrayLength(arr, TRACE_JNI_CALL); - start_time = time(NULL); + start_time = time(nullptr); enterTime /= 1000; current_time = 0; while (difftime(current_time, start_time) < enterTime) { hash = JNI_TRUE; - pa = (jboolean*) ec_jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL); - if (pa != NULL) { + pa = (jboolean*) ec_jni->GetPrimitiveArrayCritical(arr, nullptr, TRACE_JNI_CALL); + if (pa != nullptr) { for (i = 0; i < size; ++i) { hash ^= pa[i]; } } else { - jni_env->FatalError("GetPrimitiveArrayCritical returned NULL"); + jni_env->FatalError("GetPrimitiveArrayCritical returned null"); } mssleep((long) sleepTime); ec_jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL); mssleep((long) sleepTime); - current_time = time(NULL); + current_time = time(nullptr); } ec_jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL); return hash; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/ByteArrayCriticalLocker.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/ByteArrayCriticalLocker.cpp index ae13774efee..1feb98d9ef5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/ByteArrayCriticalLocker.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/ByteArrayCriticalLocker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -28,7 +28,7 @@ extern "C" { -static jfieldID objFieldId = NULL; +static jfieldID objFieldId = nullptr; /* * Class: nsk_share_gc_lock_jni_ByteArrayCriticalLocker @@ -44,31 +44,31 @@ JNIEXPORT jbyte JNICALL Java_nsk_share_gc_lock_jni_ByteArrayCriticalLocker_criti jbyte hash = 0; time_t start_time, current_time; - if (objFieldId == NULL) { + if (objFieldId == nullptr) { jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL); objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL); } arr = (jbyteArray) ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL); - ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL); + ec_jni->SetObjectField(o, objFieldId, nullptr, TRACE_JNI_CALL); size = ec_jni->GetArrayLength(arr, TRACE_JNI_CALL); - start_time = time(NULL); + start_time = time(nullptr); enterTime /= 1000; current_time = 0; while (difftime(current_time, start_time) < enterTime) { hash = 0; - pa = (jbyte*) ec_jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL); - if (pa != NULL) { + pa = (jbyte*) ec_jni->GetPrimitiveArrayCritical(arr, nullptr, TRACE_JNI_CALL); + if (pa != nullptr) { for (i = 0; i < size; ++i) { hash ^= pa[i]; } } else { - jni_env->FatalError("GetPrimitiveArrayCritical returned NULL"); + jni_env->FatalError("GetPrimitiveArrayCritical returned null"); } mssleep((long) sleepTime); ec_jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL); mssleep((long) sleepTime); - current_time = time(NULL); + current_time = time(nullptr); } ec_jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL); return hash; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/CharArrayCriticalLocker.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/CharArrayCriticalLocker.cpp index 8c46de5dd42..9c6231a0a16 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/CharArrayCriticalLocker.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/CharArrayCriticalLocker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -28,7 +28,7 @@ extern "C" { -static jfieldID objFieldId = NULL; +static jfieldID objFieldId = nullptr; /* * Class: nsk_share_gc_lock_jni_CharArrayCriticalLocker @@ -45,31 +45,31 @@ JNIEXPORT jchar JNICALL Java_nsk_share_gc_lock_jni_CharArrayCriticalLocker_criti jchar hash = 0; time_t start_time, current_time; - if (objFieldId == NULL) { + if (objFieldId == nullptr) { jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL); objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL); } arr = (jcharArray) ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL); - ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL); + ec_jni->SetObjectField(o, objFieldId, nullptr, TRACE_JNI_CALL); size = ec_jni->GetArrayLength(arr, TRACE_JNI_CALL); - start_time = time(NULL); + start_time = time(nullptr); current_time = 0; enterTime /= 1000; while (difftime(current_time, start_time) < enterTime) { hash = 0; - pa = (jchar*) ec_jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL); - if (pa != NULL) { + pa = (jchar*) ec_jni->GetPrimitiveArrayCritical(arr, nullptr, TRACE_JNI_CALL); + if (pa != nullptr) { for (i = 0; i < size; ++i) { hash ^= pa[i]; } } else { - jni_env->FatalError("GetPrimitiveArrayCritical returned NULL"); + jni_env->FatalError("GetPrimitiveArrayCritical returned null"); } mssleep((long) sleepTime); ec_jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL); mssleep((long) sleepTime); - current_time = time(NULL); + current_time = time(nullptr); } ec_jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL); return hash; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/DoubleArrayCriticalLocker.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/DoubleArrayCriticalLocker.cpp index fd6bba4822b..773ffc533a1 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/DoubleArrayCriticalLocker.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/DoubleArrayCriticalLocker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -28,7 +28,7 @@ extern "C" { -static jfieldID objFieldId = NULL; +static jfieldID objFieldId = nullptr; /* * Class: nsk_share_gc_lock_jni_DoubleArrayCriticalLocker @@ -45,31 +45,31 @@ JNIEXPORT jdouble JNICALL Java_nsk_share_gc_lock_jni_DoubleArrayCriticalLocker_c jdouble hash = 0; time_t start_time, current_time; - if (objFieldId == NULL) { + if (objFieldId == nullptr) { jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL); objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL); } arr = (jdoubleArray) ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL); - ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL); + ec_jni->SetObjectField(o, objFieldId, nullptr, TRACE_JNI_CALL); size = ec_jni->GetArrayLength(arr, TRACE_JNI_CALL); - start_time = time(NULL); + start_time = time(nullptr); enterTime /= 1000; current_time = 0; while (difftime(current_time, start_time) < enterTime) { hash = 0; - pa = (jdouble*) ec_jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL); - if (pa != NULL) { + pa = (jdouble*) ec_jni->GetPrimitiveArrayCritical(arr, nullptr, TRACE_JNI_CALL); + if (pa != nullptr) { for (i = 0; i < size; ++i) { hash += pa[i]; } } else { - jni_env->FatalError("GetPrimitiveArrayCritical returned NULL"); + jni_env->FatalError("GetPrimitiveArrayCritical returned null"); } mssleep((long) sleepTime); ec_jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL); mssleep((long) sleepTime); - current_time = time(NULL); + current_time = time(nullptr); } ec_jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL); return hash; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/FloatArrayCriticalLocker.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/FloatArrayCriticalLocker.cpp index a82e9425338..e24138792fb 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/FloatArrayCriticalLocker.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/FloatArrayCriticalLocker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -28,7 +28,7 @@ extern "C" { -static jfieldID objFieldId = NULL; +static jfieldID objFieldId = nullptr; /* * Class: nsk_share_gc_lock_jni_FloatArrayCriticalLocker @@ -45,31 +45,31 @@ JNIEXPORT jfloat JNICALL Java_nsk_share_gc_lock_jni_FloatArrayCriticalLocker_cri jfloat hash = 0; time_t start_time, current_time; - if (objFieldId == NULL) { + if (objFieldId == nullptr) { jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL); objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL); } arr = (jfloatArray) ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL); - ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL); + ec_jni->SetObjectField(o, objFieldId, nullptr, TRACE_JNI_CALL); size = ec_jni->GetArrayLength(arr, TRACE_JNI_CALL); - start_time = time(NULL); + start_time = time(nullptr); enterTime /= 1000; current_time = 0; while (difftime(current_time, start_time) < enterTime) { hash = 0; - pa = (jfloat*) ec_jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL); - if (pa != NULL) { + pa = (jfloat*) ec_jni->GetPrimitiveArrayCritical(arr, nullptr, TRACE_JNI_CALL); + if (pa != nullptr) { for (i = 0; i < size; ++i) { hash += pa[i]; } } else { - jni_env->FatalError("GetPrimitiveArrayCritical returned NULL"); + jni_env->FatalError("GetPrimitiveArrayCritical returned null"); } mssleep((long) sleepTime); ec_jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL); mssleep((long) sleepTime); - current_time = time(NULL); + current_time = time(nullptr); } ec_jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL); return hash; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/IntArrayCriticalLocker.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/IntArrayCriticalLocker.cpp index 465e4c56b32..b863984f9ac 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/IntArrayCriticalLocker.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/IntArrayCriticalLocker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -28,7 +28,7 @@ extern "C" { -static jfieldID objFieldId = NULL; +static jfieldID objFieldId = nullptr; /* * Class: nsk_share_gc_lock_jni_IntArrayCriticalLocker @@ -45,31 +45,31 @@ JNIEXPORT jint JNICALL Java_nsk_share_gc_lock_jni_IntArrayCriticalLocker_critica jint hash = 0; time_t start_time, current_time; - if (objFieldId == NULL) { + if (objFieldId == nullptr) { jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL); objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL); } arr = (jintArray) ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL); - ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL); + ec_jni->SetObjectField(o, objFieldId, nullptr, TRACE_JNI_CALL); size = ec_jni->GetArrayLength(arr, TRACE_JNI_CALL); - start_time = time(NULL); + start_time = time(nullptr); enterTime /= 1000; current_time = 0; while (difftime(current_time, start_time) < enterTime) { hash = 0; - pa = (jint*) ec_jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL); - if (pa != NULL) { + pa = (jint*) ec_jni->GetPrimitiveArrayCritical(arr, nullptr, TRACE_JNI_CALL); + if (pa != nullptr) { for (i = 0; i < size; ++i) { hash ^= pa[i]; } } else { - jni_env->FatalError("GetPrimitiveArrayCritical returned NULL"); + jni_env->FatalError("GetPrimitiveArrayCritical returned null"); } mssleep((long) sleepTime); ec_jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL); mssleep((long) sleepTime); - current_time = time(NULL); + current_time = time(nullptr); } ec_jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL); return hash; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/LongArrayCriticalLocker.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/LongArrayCriticalLocker.cpp index 8073e9ed36e..dae07c708db 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/LongArrayCriticalLocker.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/LongArrayCriticalLocker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -28,7 +28,7 @@ extern "C" { -static jfieldID objFieldId = NULL; +static jfieldID objFieldId = nullptr; /* * Class: nsk_share_gc_lock_jni_LongArrayCriticalLocker @@ -45,31 +45,31 @@ JNIEXPORT jlong JNICALL Java_nsk_share_gc_lock_jni_LongArrayCriticalLocker_criti jlong hash = 0; time_t start_time, current_time; - if (objFieldId == NULL) { + if (objFieldId == nullptr) { jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL); objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL); } arr = (jlongArray) ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL); - ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL); + ec_jni->SetObjectField(o, objFieldId, nullptr, TRACE_JNI_CALL); size = ec_jni->GetArrayLength(arr, TRACE_JNI_CALL); - start_time = time(NULL); + start_time = time(nullptr); enterTime /= 1000; current_time = 0; while (difftime(current_time, start_time) < enterTime) { hash = 0; - pa = (jlong*) ec_jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL); - if (pa != NULL) { + pa = (jlong*) ec_jni->GetPrimitiveArrayCritical(arr, nullptr, TRACE_JNI_CALL); + if (pa != nullptr) { for (i = 0; i < size; ++i) { hash ^= pa[i]; } } else { - jni_env->FatalError("GetPrimitiveArrayCritical returned NULL"); + jni_env->FatalError("GetPrimitiveArrayCritical returned null"); } mssleep((long) sleepTime); ec_jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL); mssleep((long) sleepTime); - current_time = time(NULL); + current_time = time(nullptr); } ec_jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL); return hash; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/ShortArrayCriticalLocker.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/ShortArrayCriticalLocker.cpp index a91a3cc37df..2b03591a709 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/ShortArrayCriticalLocker.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/ShortArrayCriticalLocker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -28,7 +28,7 @@ extern "C" { -static jfieldID objFieldId = NULL; +static jfieldID objFieldId = nullptr; /* * Class: nsk_share_gc_lock_jni_ShortArrayCriticalLocker @@ -45,31 +45,31 @@ JNIEXPORT jshort JNICALL Java_nsk_share_gc_lock_jni_ShortArrayCriticalLocker_cri jshort hash = 0; time_t start_time, current_time; - if (objFieldId == NULL) { + if (objFieldId == nullptr) { jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL); objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL); } arr = (jshortArray) ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL); - ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL); + ec_jni->SetObjectField(o, objFieldId, nullptr, TRACE_JNI_CALL); size = ec_jni->GetArrayLength(arr, TRACE_JNI_CALL); - start_time = time(NULL); + start_time = time(nullptr); enterTime /= 1000; current_time = 0; while (current_time - start_time < enterTime) { hash = 0; - pa = (jshort*) ec_jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL); - if (pa != NULL) { + pa = (jshort*) ec_jni->GetPrimitiveArrayCritical(arr, nullptr, TRACE_JNI_CALL); + if (pa != nullptr) { for (i = 0; i < size; ++i) { hash ^= pa[i]; } } else { - jni_env->FatalError("GetPrimitiveArrayCritical returned NULL"); + jni_env->FatalError("GetPrimitiveArrayCritical returned null"); } mssleep((long) sleepTime); ec_jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL); mssleep((long) sleepTime); - current_time = time(NULL); + current_time = time(nullptr); } ec_jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL); return hash; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/StringCriticalLocker.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/StringCriticalLocker.cpp index bbb41cfef96..a8049b2bea9 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/StringCriticalLocker.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/StringCriticalLocker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -28,7 +28,7 @@ extern "C" { -static jfieldID objFieldId = NULL; +static jfieldID objFieldId = nullptr; /* * Class: nsk_share_gc_lock_jni_StringCriticalLocker @@ -45,31 +45,31 @@ JNIEXPORT jchar JNICALL Java_nsk_share_gc_lock_jni_StringCriticalLocker_critical jchar hash = 0; time_t start_time, current_time; - if (objFieldId == NULL) { + if (objFieldId == nullptr) { jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL); objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL); } str = (jstring) ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL); - ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL); + ec_jni->SetObjectField(o, objFieldId, nullptr, TRACE_JNI_CALL); size = ec_jni->GetStringLength(str, TRACE_JNI_CALL); - start_time = time(NULL); + start_time = time(nullptr); enterTime /= 1000; current_time = 0; while (current_time - start_time < enterTime) { hash = 0; - pa = ec_jni->GetStringCritical(str, NULL, TRACE_JNI_CALL); - if (pa != NULL) { + pa = ec_jni->GetStringCritical(str, nullptr, TRACE_JNI_CALL); + if (pa != nullptr) { for (i = 0; i < size; ++i) { hash ^= pa[i]; } } else { - jni_env->FatalError("GetStringCritical returned NULL"); + jni_env->FatalError("GetStringCritical returned null"); } mssleep((long) sleepTime); ec_jni->ReleaseStringCritical(str, pa, TRACE_JNI_CALL); mssleep((long) sleepTime); - current_time = time(NULL); + current_time = time(nullptr); } ec_jni->SetObjectField(o, objFieldId, str, TRACE_JNI_CALL); return hash; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIGlobalRefLocker.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIGlobalRefLocker.cpp index 7cde57969c7..4bbbef6e204 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIGlobalRefLocker.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIGlobalRefLocker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -29,7 +29,7 @@ extern "C" { -static jfieldID objFieldId = NULL; +static jfieldID objFieldId = nullptr; /* * Class: nsk_share_gc_lock_jniref_JNIGlobalRefLocker @@ -44,13 +44,13 @@ JNIEXPORT void JNICALL Java_nsk_share_gc_lock_jniref_JNIGlobalRefLocker_critical jobject gref; time_t start_time, current_time; - if (objFieldId == NULL) { + if (objFieldId == nullptr) { jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL); objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL); } obj = ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL); - ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL); - start_time = time(NULL); + ec_jni->SetObjectField(o, objFieldId, nullptr, TRACE_JNI_CALL); + start_time = time(nullptr); enterTime /= 1000; current_time = 0; while (current_time - start_time < enterTime) { @@ -58,7 +58,7 @@ JNIEXPORT void JNICALL Java_nsk_share_gc_lock_jniref_JNIGlobalRefLocker_critical mssleep((long) sleepTime); ec_jni->DeleteGlobalRef(gref, TRACE_JNI_CALL); mssleep((long) sleepTime); - current_time = time(NULL); + current_time = time(nullptr); } ec_jni->SetObjectField(o, objFieldId, obj, TRACE_JNI_CALL); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNILocalRefLocker.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNILocalRefLocker.cpp index 20095130270..127322728a5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNILocalRefLocker.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNILocalRefLocker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -28,7 +28,7 @@ extern "C" { -static jfieldID objFieldId = NULL; +static jfieldID objFieldId = nullptr; /* * Class: nsk_share_gc_lock_jniref_JNILocalRefLocker @@ -43,13 +43,13 @@ JNIEXPORT void JNICALL Java_nsk_share_gc_lock_jniref_JNILocalRefLocker_criticalN jobject gref; time_t start_time, current_time; - if (objFieldId == NULL) { + if (objFieldId == nullptr) { jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL); objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL); } obj = ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL); - ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL); - start_time = time(NULL); + ec_jni->SetObjectField(o, objFieldId, nullptr, TRACE_JNI_CALL); + start_time = time(nullptr); enterTime /= 1000; current_time = 0; while (current_time - start_time < enterTime) { @@ -57,7 +57,7 @@ JNIEXPORT void JNICALL Java_nsk_share_gc_lock_jniref_JNILocalRefLocker_criticalN mssleep((long) sleepTime); ec_jni->DeleteLocalRef(gref, TRACE_JNI_CALL); mssleep((long) sleepTime); - current_time = time(NULL); + current_time = time(nullptr); } ec_jni->SetObjectField(o, objFieldId, obj, TRACE_JNI_CALL); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIRefLocker.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIRefLocker.cpp index a15c487cfd3..0fb552a8b03 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIRefLocker.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIRefLocker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -28,7 +28,7 @@ extern "C" { -static jfieldID objFieldId = NULL; +static jfieldID objFieldId = nullptr; /* * Class: nsk_share_gc_lock_jniref_JNIRefLocker @@ -43,15 +43,15 @@ JNIEXPORT void JNICALL Java_nsk_share_gc_lock_jniref_JNIRefLocker_criticalNative jobject gref, lref, gwref; time_t start_time, current_time; - if (objFieldId == NULL) { + if (objFieldId == nullptr) { jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL); objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL); } obj = ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL); - ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL); + ec_jni->SetObjectField(o, objFieldId, nullptr, TRACE_JNI_CALL); - start_time = time(NULL); + start_time = time(nullptr); enterTime /= 1000; current_time = 0; while (current_time - start_time < enterTime) { @@ -63,7 +63,7 @@ JNIEXPORT void JNICALL Java_nsk_share_gc_lock_jniref_JNIRefLocker_criticalNative ec_jni->DeleteLocalRef(lref, TRACE_JNI_CALL); ec_jni->DeleteWeakGlobalRef(gwref, TRACE_JNI_CALL); mssleep((long) sleepTime); - current_time = time(NULL); + current_time = time(nullptr); } ec_jni->SetObjectField(o, objFieldId, obj, TRACE_JNI_CALL); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIWeakGlobalRefLocker.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIWeakGlobalRefLocker.cpp index d98379998ee..f4c35b20d90 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIWeakGlobalRefLocker.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIWeakGlobalRefLocker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -28,7 +28,7 @@ extern "C" { -static jfieldID objFieldId = NULL; +static jfieldID objFieldId = nullptr; /* * Class: nsk_share_gc_lock_jniref_JNIWeakGlobalRefLocker @@ -43,14 +43,14 @@ JNIEXPORT void JNICALL Java_nsk_share_gc_lock_jniref_JNIWeakGlobalRefLocker_crit jobject gref; time_t start_time, current_time; - if (objFieldId == NULL) { + if (objFieldId == nullptr) { jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL); objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL); } obj = ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL); - ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL); + ec_jni->SetObjectField(o, objFieldId, nullptr, TRACE_JNI_CALL); - start_time = time(NULL); + start_time = time(nullptr); enterTime /= 1000; current_time = 0; while (current_time - start_time < enterTime) { @@ -58,7 +58,7 @@ JNIEXPORT void JNICALL Java_nsk_share_gc_lock_jniref_JNIWeakGlobalRefLocker_crit mssleep((long) sleepTime); ec_jni->DeleteWeakGlobalRef(gref, TRACE_JNI_CALL); mssleep((long) sleepTime); - current_time = time(NULL); + current_time = time(nullptr); } ec_jni->SetObjectField(o, objFieldId, obj, TRACE_JNI_CALL); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/jni/ExceptionCheckingJniEnv.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/jni/ExceptionCheckingJniEnv.cpp index f9a232fd679..ca3e5dfff74 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/jni/ExceptionCheckingJniEnv.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jni/ExceptionCheckingJniEnv.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2019, Google and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -35,8 +35,8 @@ static const char* get_dirname(const char* fullname) { const char* p; const char* base = fullname;; - if (fullname == NULL) { - return NULL; + if (fullname == nullptr) { + return nullptr; } for (p = fullname; *p != '\0'; p++) { @@ -52,7 +52,7 @@ class JNIVerifier { public: JNIVerifier(ExceptionCheckingJniEnv *env, const char* base_message, int line, const char* file) - : _env(env), _base_message(base_message), _error_message(NULL), + : _env(env), _base_message(base_message), _error_message(nullptr), _line(line), _file(get_dirname(file)) { } @@ -61,7 +61,7 @@ class JNIVerifier { JNIVerifier(ExceptionCheckingJniEnv *env, const char* base_message, U parameter, int line, const char* file) - : _env(env), _base_message(base_message), _error_message(NULL), + : _env(env), _base_message(base_message), _error_message(nullptr), _line(line), _file(get_dirname(file)) { PrintPreCall(parameter); } @@ -71,7 +71,7 @@ class JNIVerifier { U parameter1, V parameter2, int line, const char* file) - : _env(env), _base_message(base_message), _error_message(NULL), + : _env(env), _base_message(base_message), _error_message(nullptr), _line(line), _file(get_dirname(file)) { PrintPreCall(parameter1, parameter2); } @@ -80,7 +80,7 @@ class JNIVerifier { JNIVerifier(ExceptionCheckingJniEnv *env, const char* base_message, U parameter1, V parameter2, W parameter3, int line, const char* file) - : _env(env), _base_message(base_message), _error_message(NULL), + : _env(env), _base_message(base_message), _error_message(nullptr), _line(line), _file(get_dirname(file)) { PrintPreCall(parameter1, parameter2, parameter3); } @@ -93,7 +93,7 @@ class JNIVerifier { _error_message = "internal error"; } - if (_error_message != NULL) { + if (_error_message != nullptr) { GenerateErrorMessage(); } } @@ -173,7 +173,7 @@ class JNIVerifier { len += MAX_INTEGER_DIGITS + 1; char* full_message = (char*) malloc(len); - if (full_message == NULL) { + if (full_message == nullptr) { _env->HandleError(_error_message); return; } @@ -199,8 +199,8 @@ class JNIVerifier { } T ResultNotNull(T ptr) { - if (ptr == NULL) { - _error_message = "Return is NULL"; + if (ptr == nullptr) { + _error_message = "Return is null"; } return ptr; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/jni/ExceptionCheckingJniEnv.hpp b/test/hotspot/jtreg/vmTestbase/nsk/share/jni/ExceptionCheckingJniEnv.hpp index af6c0489991..2db7177c8f7 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/jni/ExceptionCheckingJniEnv.hpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jni/ExceptionCheckingJniEnv.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2019, Google and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -36,8 +36,8 @@ * * ... JNIEnv* env ... * jclass klass = env->GetObjectClass(o); - * if (klass == NULL) { - * printf("Error: GetObjectClass returned NULL\n"); + * if (klass == nullptr) { + * printf("Error: GetObjectClass returned null\n"); * return; * } * if (env->ExceptionCheck()) { @@ -48,7 +48,7 @@ * ... ExceptionCheckingJniEnv* env ... * jclass klass = env->GetObjectClass(o, TRACE_JNI_CALL); * - * Where now the JNI Exception checking and the NULL return checking are done + * Where now the JNI Exception checking and the null return checking are done * internally and will perform whatever action the ErrorHandler requires. * * Note the TRACE_JNI_CALL parameter that allows to trace where the call is diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/jni/JNIreferences.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/jni/JNIreferences.cpp index 7fa0f0d15ab..50b59a157e9 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/jni/JNIreferences.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jni/JNIreferences.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2024, 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 @@ -27,8 +27,8 @@ extern "C" { -static jobject* globalReferences = NULL; -static jweak* weakReferences = NULL; +static jobject* globalReferences = nullptr; +static jweak* weakReferences = nullptr; JNIEXPORT jint JNICALL Java_nsk_share_ReferringObject_createJNIGlobalReferenceNative(JNIEnv *env, @@ -37,19 +37,19 @@ Java_nsk_share_ReferringObject_createJNIGlobalReferenceNative(JNIEnv *env, jint i; jint result = -1; - if (globalReferences == NULL) + if (globalReferences == nullptr) { globalReferences = (jobject*)malloc(sizeof(jobject) * maxJNIGlobalReferences); - if (globalReferences == NULL) + if (globalReferences == nullptr) { - NSK_COMPLAIN0("malloc return NULL\n"); + NSK_COMPLAIN0("malloc return null\n"); return -1; } for (i = 0; i < maxJNIGlobalReferences; i++) { - globalReferences[i] = NULL; + globalReferences[i] = nullptr; } } @@ -57,17 +57,17 @@ Java_nsk_share_ReferringObject_createJNIGlobalReferenceNative(JNIEnv *env, { jobject reference = globalReferences[i]; - if (reference == NULL) + if (reference == nullptr) { reference = env->NewGlobalRef(object); - if (reference == NULL) + if (reference == nullptr) { - NSK_COMPLAIN0("NewGlobalRef return NULL\n"); + NSK_COMPLAIN0("NewGlobalRef return null\n"); env->ThrowNew( env->FindClass("nsk/share/TestJNIError"), - "NewGlobalRef return NULL"); + "NewGlobalRef return null"); } globalReferences[i] = reference; @@ -87,18 +87,18 @@ Java_nsk_share_ReferringObject_deleteJNIGlobalReferenceNative(JNIEnv *env, { jobject reference = globalReferences[index]; - if (reference == NULL) + if (reference == nullptr) { - NSK_COMPLAIN1("globalReferences[%d] = NULL, possible wrong index is passed\n", index); + NSK_COMPLAIN1("globalReferences[%d] = null, possible wrong index is passed\n", index); env->ThrowNew( env->FindClass("nsk/share/TestBug"), - "Requested globalReferences[] element is NULL, possible wrong index is passed"); + "Requested globalReferences[] element is null, possible wrong index is passed"); } env->DeleteGlobalRef(reference); - globalReferences[index] = NULL; + globalReferences[index] = nullptr; } @@ -109,13 +109,13 @@ Java_nsk_share_ReferringObject_createJNILocalReferenceNative(JNIEnv *env, jobject reference = env->NewLocalRef(object); jclass klass; - if (reference == NULL) + if (reference == nullptr) { - NSK_COMPLAIN0("NewLocalRef return NULL\n"); + NSK_COMPLAIN0("NewLocalRef return null\n"); env->ThrowNew( env->FindClass("nsk/share/TestJNIError"), - "NewLocalRef return NULL"); + "NewLocalRef return null"); } klass = env->GetObjectClass(createWicket); @@ -136,20 +136,20 @@ Java_nsk_share_ReferringObject_createJNIWeakReferenceNative(JNIEnv *env, jint i; jint result = -1; - if (weakReferences == NULL) + if (weakReferences == nullptr) { weakReferences = (jweak*)malloc(sizeof(jweak) * maxJNIWeakReferences); - if (weakReferences == NULL) + if (weakReferences == nullptr) { - NSK_COMPLAIN0("malloc return NULL\n"); + NSK_COMPLAIN0("malloc return null\n"); return -1; } for (i = 0; i < maxJNIWeakReferences; i++) { - weakReferences[i] = NULL; + weakReferences[i] = nullptr; } } @@ -157,17 +157,17 @@ Java_nsk_share_ReferringObject_createJNIWeakReferenceNative(JNIEnv *env, { jobject reference = weakReferences[i]; - if (reference == NULL) + if (reference == nullptr) { reference = env->NewWeakGlobalRef(object); - if (reference == NULL) + if (reference == nullptr) { - NSK_COMPLAIN0("NewWeakGlobalRef return NULL\n"); + NSK_COMPLAIN0("NewWeakGlobalRef return null\n"); env->ThrowNew( env->FindClass("nsk/share/TestJNIError"), - "NewWeakGlobalRef return NULL"); + "NewWeakGlobalRef return null"); } weakReferences[i] = reference; @@ -187,16 +187,16 @@ Java_nsk_share_ReferringObject_deleteJNIWeakReferenceNative(JNIEnv *env, { jweak reference = weakReferences[index]; - if (reference == NULL) + if (reference == nullptr) { - NSK_COMPLAIN1("weakReferences[%d] = NULL, possible wrong index is passed\n", index); + NSK_COMPLAIN1("weakReferences[%d] = null, possible wrong index is passed\n", index); env->ThrowNew( env->FindClass("nsk/share/TestBug"), - "Requested weakReferences[] element is NULL, possible wrong index is passed"); + "Requested weakReferences[] element is null, possible wrong index is passed"); } - if (env->IsSameObject(reference, NULL) == JNI_TRUE) + if (env->IsSameObject(reference, nullptr) == JNI_TRUE) { NSK_COMPLAIN0("TEST BUG: Weak reference was collected\n"); @@ -207,7 +207,7 @@ Java_nsk_share_ReferringObject_deleteJNIWeakReferenceNative(JNIEnv *env, env->DeleteWeakGlobalRef(reference); - weakReferences[index] = NULL; + weakReferences[index] = nullptr; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/jni/jni_tools.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/jni/jni_tools.cpp index f8b9df264c9..2f5a5ff3bc0 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/jni/jni_tools.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jni/jni_tools.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ int nsk_jni_check_exception(JNIEnv* jni, const char file[], int line) jthrowable throwable; NSK_TRACE(throwable = jni->ExceptionOccurred()); - if (throwable != NULL) { + if (throwable != nullptr) { nsk_lcomplain(file, line, "Exception in JNI call (cleared):\n"); NSK_TRACE(jni->ExceptionDescribe()); NSK_TRACE(jni->ExceptionClear()); @@ -107,7 +107,7 @@ void mssleep(long millis) { struct timeval timeout; timeout.tv_sec = millis / 1000; timeout.tv_usec = (millis % 1000) * 1000; - select(0, NULL, NULL, NULL, &timeout); + select(0, nullptr, nullptr, nullptr, &timeout); #endif } @@ -131,7 +131,7 @@ JavaVMOption* jni_create_vmoptions(int size, char *args[], int argsCnt) { int i; - JavaVMOption *options = NULL; + JavaVMOption *options = nullptr; if (size <= 0) return options; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch_agent.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch_agent.cpp index 128b33bbf36..4340391d413 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch_agent.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch_agent.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -156,16 +156,16 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiEnv* jvmti; const char *p_segment1, *p_segment2, *phase_to_check; - jvmti = NULL; - p_segment1 = p_segment2 = phase_to_check = NULL; + jvmti = nullptr; + p_segment1 = p_segment2 = phase_to_check = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; timeout = nsk_jvmti_getWaitTime() * 60 * 1000; - p_segment1 = nsk_jvmti_findOptionStringValue("segment1", NULL); - if (!NSK_VERIFY(p_segment1 != NULL)) { + p_segment1 = nsk_jvmti_findOptionStringValue("segment1", nullptr); + if (!NSK_VERIFY(p_segment1 != nullptr)) { return JNI_ERR; } else { strncpy(segment1, p_segment1, (size_t) sizeof(segment1)/sizeof(char)); @@ -173,20 +173,20 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } // 'segment2' parameter is not mandatory - p_segment2 = nsk_jvmti_findOptionStringValue("segment2", NULL); - if (p_segment2 != NULL) { + p_segment2 = nsk_jvmti_findOptionStringValue("segment2", nullptr); + if (p_segment2 != nullptr) { strncpy(segment2, p_segment2, (size_t) sizeof(segment2)/sizeof(char)); segment2[(size_t) sizeof(segment2)/sizeof(char) - 1] = 0; use_segment2 = JNI_TRUE; } if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; // Check what phase(s) we are going to test - phase_to_check = nsk_jvmti_findOptionStringValue("phasetocheck", NULL); - if (!NSK_VERIFY(phase_to_check != NULL)) { + phase_to_check = nsk_jvmti_findOptionStringValue("phasetocheck", nullptr); + if (!NSK_VERIFY(phase_to_check != nullptr)) { return JNI_ERR; } else if (strcmp(phase_to_check, "onload") == 0) { jvmti_phase_to_check = JVMTI_PHASE_ONLOAD; @@ -227,7 +227,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiEvent eventsList[] = { JVMTI_EVENT_VM_INIT, JVMTI_EVENT_VM_DEATH }; if (!NSK_VERIFY(nsk_jvmti_enableEvents( - JVMTI_ENABLE, sizeof(eventsList)/sizeof(jvmtiEvent), eventsList, NULL))) { + JVMTI_ENABLE, sizeof(eventsList)/sizeof(jvmtiEvent), eventsList, nullptr))) { return JNI_ERR; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/AddToSystemClassLoaderSearch/systemclssearch_agent.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/AddToSystemClassLoaderSearch/systemclssearch_agent.cpp index 6be44a4f147..1d123242d49 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/AddToSystemClassLoaderSearch/systemclssearch_agent.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/AddToSystemClassLoaderSearch/systemclssearch_agent.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -156,16 +156,16 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiEnv* jvmti; const char *p_segment1, *p_segment2, *phase_to_check; - jvmti = NULL; - p_segment1 = p_segment2 = phase_to_check = NULL; + jvmti = nullptr; + p_segment1 = p_segment2 = phase_to_check = nullptr; if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; timeout = nsk_jvmti_getWaitTime() * 60 * 1000; - p_segment1 = nsk_jvmti_findOptionStringValue("segment1", NULL); - if (!NSK_VERIFY(p_segment1 != NULL)) { + p_segment1 = nsk_jvmti_findOptionStringValue("segment1", nullptr); + if (!NSK_VERIFY(p_segment1 != nullptr)) { return JNI_ERR; } else { strncpy(segment1, p_segment1, (size_t) sizeof(segment1)/sizeof(char)); @@ -173,20 +173,20 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } // 'segment2' parameter is not mandatory - p_segment2 = nsk_jvmti_findOptionStringValue("segment2", NULL); - if (p_segment2 != NULL) { + p_segment2 = nsk_jvmti_findOptionStringValue("segment2", nullptr); + if (p_segment2 != nullptr) { strncpy(segment2, p_segment2, (size_t) sizeof(segment2)/sizeof(char)); segment2[(size_t) sizeof(segment2)/sizeof(char) - 1] = 0; use_segment2 = JNI_TRUE; } if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; // Check what phase(s) we are going to test - phase_to_check = nsk_jvmti_findOptionStringValue("phasetocheck", NULL); - if (!NSK_VERIFY(phase_to_check != NULL)) { + phase_to_check = nsk_jvmti_findOptionStringValue("phasetocheck", nullptr); + if (!NSK_VERIFY(phase_to_check != nullptr)) { return JNI_ERR; } else if (strcmp(phase_to_check, "onload") == 0) { jvmti_phase_to_check = JVMTI_PHASE_ONLOAD; @@ -227,7 +227,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { jvmtiEvent eventsList[] = { JVMTI_EVENT_VM_INIT, JVMTI_EVENT_VM_DEATH }; if (!NSK_VERIFY(nsk_jvmti_enableEvents( - JVMTI_ENABLE, sizeof(eventsList)/sizeof(jvmtiEvent), eventsList, NULL))) { + JVMTI_ENABLE, sizeof(eventsList)/sizeof(jvmtiEvent), eventsList, nullptr))) { return JNI_ERR; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/Injector.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/Injector.cpp index 6246c6c4884..b69faf76ffa 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/Injector.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/Injector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -221,7 +221,7 @@ extern "C" { NSK_DISPLAY1("copying ConstantPool: %d\n", constantPoolSize); constantPool = (char**) malloc(constantPoolSize * sizeof(char*)); - if (!NSK_VERIFY(constantPool != NULL)) { + if (!NSK_VERIFY(constantPool != nullptr)) { NSK_COMPLAIN0("out of memory\n"); return NSK_FALSE; } @@ -262,7 +262,7 @@ extern "C" { case CONSTANT_Utf8: len = copy_u2(); utf8 = (char*) malloc(len + 1); - if (!NSK_VERIFY(utf8 != NULL)) { + if (!NSK_VERIFY(utf8 != nullptr)) { NSK_COMPLAIN0("out of memory\n"); return NSK_FALSE; } @@ -295,7 +295,7 @@ extern "C" { u2 i; for (i = 1; i < constantPoolSize; i++) { - if (constantPool[i] != NULL) { + if (constantPool[i] != nullptr) { free(constantPool[i]); } } @@ -1138,7 +1138,7 @@ extern "C" { inputPos = (u1*) orig; endPos = orig + old_length; gen = (u1*) malloc(old_length * GROWTH_FACTOR); - if (!NSK_VERIFY(gen != NULL)) { + if (!NSK_VERIFY(gen != nullptr)) { NSK_COMPLAIN0("out of memory\n"); return NSK_FALSE; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/agent_tools.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/agent_tools.cpp index b75f237c6a7..dc4da9bcf89 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/agent_tools.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/agent_tools.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,9 +37,9 @@ extern "C" { * Now the same source is used to build different agent libs, so these * variables are not shared between agents */ -static jthread agentThread = NULL; -static jvmtiStartFunction agentThreadProc = NULL; -static void* agentThreadArg = NULL; +static jthread agentThread = nullptr; +static jvmtiStartFunction agentThreadProc = nullptr; +static void* agentThreadArg = nullptr; typedef enum { NEW, RUNNABLE, WAITING, SUSPENDED, TERMINATED } thread_state_t; @@ -52,9 +52,9 @@ typedef struct agent_data_t { static agent_data_t agent_data; -static jvmtiEnv* jvmti_env = NULL; -static JavaVM* jvm = NULL; -static JNIEnv* jni_env = NULL; +static jvmtiEnv* jvmti_env = nullptr; +static JavaVM* jvm = nullptr; +static JNIEnv* jni_env = nullptr; static volatile int currentAgentStatus = NSK_STATUS_PASSED; @@ -101,12 +101,12 @@ jvmtiEnv* nsk_jvmti_createJVMTIEnv(JavaVM* javaVM, void* reserved) { jvm = javaVM; if (!NSK_VERIFY(javaVM->GetEnv((void **)&jvmti_env, JVMTI_VERSION_1_1) == JNI_OK)) { nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } if (!NSK_JVMTI_VERIFY(init_agent_data(jvmti_env, &agent_data))) { nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } return jvmti_env; @@ -114,7 +114,7 @@ jvmtiEnv* nsk_jvmti_createJVMTIEnv(JavaVM* javaVM, void* reserved) { /** Dispose JVMTI environment */ static int nsk_jvmti_disposeJVMTIEnv(jvmtiEnv* jvmti_env) { - if (jvmti_env != NULL) { + if (jvmti_env != nullptr) { if (!NSK_JVMTI_VERIFY(jvmti_env->DisposeEnvironment())) { nsk_jvmti_setFailStatus(); return NSK_FALSE; @@ -153,7 +153,7 @@ agentThreadWrapper(jvmtiEnv* jvmti_env, JNIEnv* agentJNI, void* arg) { rawMonitorEnter(jvmti_env, agent_data.monitor); agent_data.thread_state = TERMINATED; agentJNI->DeleteGlobalRef(agentThread); - agentThread = NULL; + agentThread = nullptr; rawMonitorNotify(jvmti_env, agent_data.monitor); rawMonitorExit(jvmti_env, agent_data.monitor); @@ -167,31 +167,31 @@ static jthread startAgentThreadWrapper(JNIEnv *jni_env, jvmtiEnv* jvmti_env) { const char* THREAD_CTOR_NAME = ""; const char* THREAD_CTOR_SIGNATURE = "(Ljava/lang/String;)V"; - jobject threadName = NULL; - jclass threadClass = NULL; - jmethodID threadCtor = NULL; - jobject threadObject = NULL; - jobject threadGlobalRef = NULL; + jobject threadName = nullptr; + jclass threadClass = nullptr; + jmethodID threadCtor = nullptr; + jobject threadObject = nullptr; + jobject threadGlobalRef = nullptr; - if (!NSK_JNI_VERIFY(jni_env, (threadClass = jni_env->FindClass(THREAD_CLASS_NAME)) != NULL)) { - return NULL; + if (!NSK_JNI_VERIFY(jni_env, (threadClass = jni_env->FindClass(THREAD_CLASS_NAME)) != nullptr)) { + return nullptr; } if (!NSK_JNI_VERIFY(jni_env, (threadCtor = - jni_env->GetMethodID(threadClass, THREAD_CTOR_NAME, THREAD_CTOR_SIGNATURE)) != NULL)) - return NULL; + jni_env->GetMethodID(threadClass, THREAD_CTOR_NAME, THREAD_CTOR_SIGNATURE)) != nullptr)) + return nullptr; - if (!NSK_JNI_VERIFY(jni_env, (threadName = jni_env->NewStringUTF(THREAD_NAME)) != NULL)) - return NULL; + if (!NSK_JNI_VERIFY(jni_env, (threadName = jni_env->NewStringUTF(THREAD_NAME)) != nullptr)) + return nullptr; if (!NSK_JNI_VERIFY(jni_env, (threadObject = - jni_env->NewObject(threadClass, threadCtor, threadName)) != NULL)) - return NULL; + jni_env->NewObject(threadClass, threadCtor, threadName)) != nullptr)) + return nullptr; if (!NSK_JNI_VERIFY(jni_env, (threadGlobalRef = - jni_env->NewGlobalRef(threadObject)) != NULL)) { + jni_env->NewGlobalRef(threadObject)) != nullptr)) { jni_env->DeleteLocalRef(threadObject); - return NULL; + return nullptr; } agentThread = (jthread)threadGlobalRef; @@ -199,7 +199,7 @@ static jthread startAgentThreadWrapper(JNIEnv *jni_env, jvmtiEnv* jvmti_env) { jvmti_env->RunAgentThread(agentThread, &agentThreadWrapper, agentThreadArg, THREAD_PRIORITY))) { jni_env->DeleteGlobalRef(threadGlobalRef); jni_env->DeleteLocalRef(threadObject); - return NULL; + return nullptr; } return agentThread; } @@ -220,9 +220,9 @@ jthread nsk_jvmti_getAgentThread() { static jthread nsk_jvmti_runAgentThread(JNIEnv *jni_env, jvmtiEnv* jvmti_env) { /* start agent thread wrapper */ jthread thread = startAgentThreadWrapper(jni_env, jvmti_env); - if (thread == NULL) { + if (thread == nullptr) { nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } return thread; @@ -247,7 +247,7 @@ static jint syncDebuggeeStatus(JNIEnv* jni_env, jvmtiEnv* jvmti_env, jint debugg /* we don't enter if-stmt in second call */ if (agent_data.thread_state == NEW) { - if (nsk_jvmti_runAgentThread(jni_env, jvmti_env) == NULL) + if (nsk_jvmti_runAgentThread(jni_env, jvmti_env) == nullptr) goto monitor_exit_and_return; /* SP2.2-w - wait for agent thread */ @@ -371,31 +371,31 @@ Java_nsk_share_jvmti_DebugeeClass_resetAgentData(JNIEnv* jni_env, jclass cls) { /** Find loaded class by signature. */ jclass nsk_jvmti_classBySignature(const char signature[]) { - jclass* classes = NULL; + jclass* classes = nullptr; jint count = 0; - jclass foundClass = NULL; + jclass foundClass = nullptr; int i; - if (!NSK_VERIFY(signature != NULL)) { + if (!NSK_VERIFY(signature != nullptr)) { nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } if (!NSK_JVMTI_VERIFY(jvmti_env->GetLoadedClasses(&count, &classes))) { nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } for (i = 0; i < count; i++) { - char* sig = NULL; - char* generic = NULL; + char* sig = nullptr; + char* generic = nullptr; if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(classes[i], &sig, &generic))) { nsk_jvmti_setFailStatus(); break; } - if (sig != NULL && strcmp(signature, sig) == 0) { + if (sig != nullptr && strcmp(signature, sig) == 0) { foundClass = classes[i]; } @@ -405,19 +405,19 @@ jclass nsk_jvmti_classBySignature(const char signature[]) { break; } - if (foundClass != NULL) + if (foundClass != nullptr) break; } if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)classes))) { nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } if (!NSK_JNI_VERIFY(jni_env, (foundClass = (jclass) - jni_env->NewGlobalRef(foundClass)) != NULL)) { + jni_env->NewGlobalRef(foundClass)) != nullptr)) { nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } return foundClass; @@ -425,19 +425,19 @@ jclass nsk_jvmti_classBySignature(const char signature[]) { /** Find alive thread by name. */ jthread nsk_jvmti_threadByName(const char name[]) { - jthread* threads = NULL; + jthread* threads = nullptr; jint count = 0; - jthread foundThread = NULL; + jthread foundThread = nullptr; int i; - if (!NSK_VERIFY(name != NULL)) { + if (!NSK_VERIFY(name != nullptr)) { nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } if (!NSK_JVMTI_VERIFY(jvmti_env->GetAllThreads(&count, &threads))) { nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } for (i = 0; i < count; i++) { @@ -448,27 +448,27 @@ jthread nsk_jvmti_threadByName(const char name[]) { break; } - if (info.name != NULL && strcmp(name, info.name) == 0) { + if (info.name != nullptr && strcmp(name, info.name) == 0) { foundThread = threads[i]; } if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)info.name))) { nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } - if (foundThread != NULL) { + if (foundThread != nullptr) { break; } } if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)threads))) { nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } if (!NSK_JNI_VERIFY(jni_env, (foundThread = (jthread) - jni_env->NewGlobalRef(foundThread)) != NULL)) { + jni_env->NewGlobalRef(foundThread)) != nullptr)) { nsk_jvmti_setFailStatus(); - return NULL; + return nullptr; } return foundThread; @@ -507,7 +507,7 @@ int nsk_jvmti_addBreakpointCapabilities() { /** Find line location. */ jlocation nsk_jvmti_getLineLocation(jclass cls, jmethodID method, int line) { jint count = 0; - jvmtiLineNumberEntry* table = NULL; + jvmtiLineNumberEntry* table = nullptr; jlocation location = NSK_JVMTI_INVALID_JLOCATION; int i; @@ -574,7 +574,7 @@ int nsk_jvmti_enableEvents(jvmtiEventMode enable, int size, jvmtiEvent list[], j typedef jint (JNICALL *checkStatus_type)(JNIEnv* jni_env, jclass cls, jint debuggeeStatus); -static checkStatus_type checkStatus_func = NULL; +static checkStatus_type checkStatus_func = nullptr; /** * Proxy function to gain sequential access to checkStatus of each agent @@ -600,9 +600,9 @@ static void JNICALL nativeMethodBind(jvmtiEnv* jvmti_env, JNIEnv *jni_env, jvmtiPhase phase; jclass cls; - char *class_sig = NULL; - char *name = NULL; - char *sig = NULL; + char *class_sig = nullptr; + char *name = nullptr; + char *sig = nullptr; if (!NSK_JVMTI_VERIFY(jvmti_env->GetPhase(&phase))) { nsk_jvmti_setFailStatus(); @@ -612,12 +612,12 @@ static void JNICALL nativeMethodBind(jvmtiEnv* jvmti_env, JNIEnv *jni_env, if (phase != JVMTI_PHASE_START && phase != JVMTI_PHASE_LIVE) return; - if (NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(mid, &name, &sig, NULL))) { + if (NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(mid, &name, &sig, nullptr))) { if (strcmp(name, BIND_METHOD_NAME) == 0 && strcmp(sig, BIND_METHOD_SIGNATURE) == 0) { if (NSK_JVMTI_VERIFY(jvmti_env->GetMethodDeclaringClass(mid, &cls)) - && NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(cls, &class_sig, NULL)) + && NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(cls, &class_sig, nullptr)) && strcmp(class_sig, BIND_CLASS_NAME) == 0 && address != (void*)Java_nsk_share_jvmti_DebugeeClass_checkStatus) { checkStatus_func = (checkStatus_type)address; @@ -626,13 +626,13 @@ static void JNICALL nativeMethodBind(jvmtiEnv* jvmti_env, JNIEnv *jni_env, } } - if (name != NULL) + if (name != nullptr) jvmti_env->Deallocate((unsigned char*)name); - if (sig != NULL) + if (sig != nullptr) jvmti_env->Deallocate((unsigned char*)sig); - if (class_sig != NULL) + if (class_sig != nullptr) jvmti_env->Deallocate((unsigned char*)class_sig); } @@ -642,14 +642,14 @@ static void JNICALL nativeMethodBind(jvmtiEnv* jvmti_env, JNIEnv *jni_env, */ int nsk_jvmti_init_MA(jvmtiEventCallbacks* callbacks) { - if (callbacks == NULL) { - NSK_COMPLAIN0("callbacks should not be NULL\n"); + if (callbacks == nullptr) { + NSK_COMPLAIN0("callbacks should not be null\n"); nsk_jvmti_setFailStatus(); return NSK_FALSE; } - if (callbacks->NativeMethodBind != NULL) { - NSK_COMPLAIN0("callbacks.NativeMethodBind should be NULL\n"); + if (callbacks->NativeMethodBind != nullptr) { + NSK_COMPLAIN0("callbacks.NativeMethodBind should be null\n"); nsk_jvmti_setFailStatus(); return NSK_FALSE; } @@ -667,7 +667,7 @@ int nsk_jvmti_init_MA(jvmtiEventCallbacks* callbacks) { return NSK_FALSE; if (!NSK_JVMTI_VERIFY( - jvmti_env->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_NATIVE_METHOD_BIND, NULL))) + jvmti_env->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_NATIVE_METHOD_BIND, nullptr))) return NSK_FALSE; return NSK_TRUE; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/aod/jvmti_aod.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/aod/jvmti_aod.cpp index 6269379d8c7..98d82172679 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/aod/jvmti_aod.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/aod/jvmti_aod.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024, 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 @@ Options* nsk_jvmti_aod_getMultiagentsOptions(jvmtiEnv *jvmti) { NSK_COMPLAIN1("Options for jvmtiEnv %p weren't found\n", jvmti); - return NULL; + return nullptr; } /* @@ -101,7 +101,7 @@ void nsk_jvmti_aod_deallocate(jvmtiEnv *jvmti, unsigned char* mem) { int nsk_jvmti_aod_getClassName(jvmtiEnv *jvmti, jclass klass, char classNameBuffer[]) { char* className; - if (!NSK_JVMTI_VERIFY(jvmti->GetClassSignature(klass, &className, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti->GetClassSignature(klass, &className, nullptr))) { NSK_COMPLAIN0("Failed to get class name\n"); classNameBuffer[0] = '\0'; return NSK_FALSE; @@ -161,25 +161,25 @@ jthread nsk_jvmti_aod_createThread(JNIEnv *jni) { jmethodID threadConstructor; jthread thread; - if (!NSK_JNI_VERIFY(jni, (klass = jni->FindClass("java/lang/Thread")) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (klass = jni->FindClass("java/lang/Thread")) != nullptr)) { NSK_COMPLAIN0("Failed to get the java.lang.Thread class\n"); - return NULL; + return nullptr; } if (!NSK_JNI_VERIFY(jni, - (threadConstructor = jni->GetMethodID(klass, "", "()V")) != NULL)) { + (threadConstructor = jni->GetMethodID(klass, "", "()V")) != nullptr)) { NSK_COMPLAIN0("Failed to get java.lang.Thread constructor\n"); - return NULL; + return nullptr; } if (!NSK_JNI_VERIFY (jni, - (thread = jni->NewObject(klass, threadConstructor, NULL)) != NULL)) { + (thread = jni->NewObject(klass, threadConstructor, nullptr)) != nullptr)) { NSK_COMPLAIN0("Failed to create Thread object\n"); - return NULL; + return nullptr; } - if (!NSK_JNI_VERIFY(jni, (thread = jni->NewGlobalRef(thread)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (thread = jni->NewGlobalRef(thread)) != nullptr)) { NSK_COMPLAIN0("Failed to create global reference\n"); - return NULL; + return nullptr; } return thread; @@ -191,28 +191,28 @@ jthread nsk_jvmti_aod_createThreadWithName(JNIEnv *jni, const char* threadName) jthread thread; jstring threadNameString; - if (!NSK_JNI_VERIFY(jni, (threadNameString = jni->NewStringUTF(threadName)) != NULL)) - return NULL; + if (!NSK_JNI_VERIFY(jni, (threadNameString = jni->NewStringUTF(threadName)) != nullptr)) + return nullptr; - if (!NSK_JNI_VERIFY(jni, (klass = jni->FindClass("java/lang/Thread")) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (klass = jni->FindClass("java/lang/Thread")) != nullptr)) { NSK_COMPLAIN0("Failed to get the java.lang.Thread class\n"); - return NULL; + return nullptr; } if (!NSK_JNI_VERIFY(jni, - (threadConstructor = jni->GetMethodID(klass, "", "(Ljava/lang/String;)V")) != NULL)) { + (threadConstructor = jni->GetMethodID(klass, "", "(Ljava/lang/String;)V")) != nullptr)) { NSK_COMPLAIN0("Failed to get java.lang.Thread constructor\n"); - return NULL; + return nullptr; } if (!NSK_JNI_VERIFY(jni, - (thread = jni->NewObject(klass, threadConstructor, threadNameString)) != NULL)) { + (thread = jni->NewObject(klass, threadConstructor, threadNameString)) != nullptr)) { NSK_COMPLAIN0("Failed to create Thread object\n"); - return NULL; + return nullptr; } - if (!NSK_JNI_VERIFY(jni, (thread = jni->NewGlobalRef(thread)) != NULL)) { + if (!NSK_JNI_VERIFY(jni, (thread = jni->NewGlobalRef(thread)) != nullptr)) { NSK_COMPLAIN0("Failed to create global reference\n"); - return NULL; + return nullptr; } return thread; @@ -230,8 +230,8 @@ int nsk_jvmti_aod_redefineClass( NSK_COMPLAIN1("Option '%s' isn't specified\n", PATH_TO_NEW_BYTE_CODE_OPTION); return NSK_FALSE; } - if (fileName == NULL) { - NSK_COMPLAIN0("File name is NULL\n"); + if (fileName == nullptr) { + NSK_COMPLAIN0("File name is null\n"); return NSK_FALSE; } { @@ -250,7 +250,7 @@ int nsk_jvmti_aod_redefineClass( bytecode = fopen(file, "rb"); error= JVMTI_ERROR_NONE; - if (bytecode == NULL) { + if (bytecode == nullptr) { NSK_COMPLAIN1("Error opening file '%s'\n", file); return NSK_FALSE; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/hotswap/HotSwap.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/hotswap/HotSwap.cpp index 97f30c106c0..5976eb39ec7 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/hotswap/HotSwap.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/hotswap/HotSwap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -59,17 +59,17 @@ static int vm_mode = VM_MODE_COMPILED; static int bci_mode = BCI_MODE_EMCP; static int sync_freq = 0; -static jclass profile_klass = NULL; -static jfieldID count_field = NULL; +static jclass profile_klass = nullptr; +static jfieldID count_field = nullptr; /* test objects */ static int max_classes; -static char** names = NULL; -static jvmtiClassDefinition* old_class_def = NULL; -static jvmtiClassDefinition* new_class_def = NULL; +static char** names = nullptr; +static jvmtiClassDefinition* old_class_def = nullptr; +static jvmtiClassDefinition* new_class_def = nullptr; static int classCount = 0; /* lock to access classCount */ -static jrawMonitorID classLoadLock = NULL; +static jrawMonitorID classLoadLock = nullptr; static int newFlag = NSK_FALSE; /* ========================================================================== */ @@ -99,8 +99,8 @@ ClassFileLoadHook(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jint *new_class_data_len, unsigned char** new_class_data) { jint name_len; - if (name != NULL && - class_being_redefined == NULL && + if (name != nullptr && + class_being_redefined == nullptr && (strcmp(name, PROFILE_CLASS_NAME) != 0) && (strncmp(name, package_name, package_name_length) == 0)) { if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorEnter(classLoadLock))) { @@ -139,20 +139,20 @@ static void JNICALL CompiledMethodLoad(jvmtiEnv *jvmti_env, jmethodID method, jint code_size, const void* code_addr, jint map_length, const jvmtiAddrLocationMap* map, const void* compile_info) { - char *name = NULL; - char *signature = NULL; + char *name = nullptr; + char *signature = nullptr; CompiledMethodLoadEventsCount++; - if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, nullptr))) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY3("CompiledMethodLoad event: %s%s (0x%p)\n", name, signature, code_addr); - if (name != NULL) + if (name != nullptr) jvmti_env->Deallocate((unsigned char*)name); - if (signature != NULL) + if (signature != nullptr) jvmti_env->Deallocate((unsigned char*)signature); } @@ -175,20 +175,20 @@ Exception(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, if (sync_freq && ((ExceptionEventsCount % sync_freq) == 0)) { if (nsk_getVerboseMode()) { - jclass klass = NULL; - char *signature = NULL; + jclass klass = nullptr; + char *signature = nullptr; - if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(exception)) != NULL)) { + if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(exception)) != nullptr)) { nsk_jvmti_setFailStatus(); return; } - if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &signature, NULL))) { + if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &signature, nullptr))) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY2("Exception event %d: %s\n", ExceptionEventsCount.load(), signature); - if (signature != NULL) + if (signature != nullptr) jvmti_env->Deallocate((unsigned char*)signature); } @@ -200,7 +200,7 @@ Exception(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, if (vm_mode == VM_MODE_MIXED) { if (!NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode( ((newFlag) ? JVMTI_DISABLE : JVMTI_ENABLE), - JVMTI_EVENT_SINGLE_STEP, NULL))) + JVMTI_EVENT_SINGLE_STEP, nullptr))) nsk_jvmti_setFailStatus(); } @@ -217,16 +217,16 @@ Exception(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, /* ========================================================================== */ -static jrawMonitorID waitLock = NULL; +static jrawMonitorID waitLock = nullptr; static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { int i; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, nullptr))) return NSK_FALSE; if (vm_mode != VM_MODE_COMPILED) { - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, nullptr))) return NSK_FALSE; } @@ -235,27 +235,27 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { for (i = 0; i < classCount; i++) { NSK_DISPLAY1("Find class: %s\n", names[i]); - if (!NSK_JNI_VERIFY(jni, (old_class_def[i].klass = jni->FindClass(names[i])) != NULL)) + if (!NSK_JNI_VERIFY(jni, (old_class_def[i].klass = jni->FindClass(names[i])) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (old_class_def[i].klass = (jclass) - jni->NewGlobalRef(old_class_def[i].klass)) != NULL)) + jni->NewGlobalRef(old_class_def[i].klass)) != nullptr)) return NSK_FALSE; } if (bci_mode != BCI_MODE_EMCP) { NSK_DISPLAY1("Find class: %s\n", PROFILE_CLASS_NAME); - if (!NSK_JNI_VERIFY(jni, (profile_klass = jni->FindClass(PROFILE_CLASS_NAME)) != NULL)) + if (!NSK_JNI_VERIFY(jni, (profile_klass = jni->FindClass(PROFILE_CLASS_NAME)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (profile_klass = (jclass) - jni->NewGlobalRef(profile_klass)) != NULL)) + jni->NewGlobalRef(profile_klass)) != nullptr)) return NSK_FALSE; if (!NSK_JNI_VERIFY(jni, (count_field = jni->GetStaticFieldID(profile_klass, (bci_mode == BCI_MODE_CALL) ? "callCount" : "allocCount", - "I")) != NULL)) + "I")) != nullptr)) return NSK_FALSE; if (!NSK_JVMTI_VERIFY(jvmti->Allocate(classCount * sizeof(jvmtiClassDefinition), @@ -273,7 +273,7 @@ static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) { } if (sync_freq) { - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION, nullptr))) return NSK_FALSE; } @@ -318,7 +318,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { return; if (sync_freq) { - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_EXCEPTION, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_EXCEPTION, nullptr))) nsk_jvmti_setFailStatus(); } else { @@ -333,7 +333,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { if (vm_mode == VM_MODE_MIXED) { if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode( (((i % 2) == 0) ? JVMTI_DISABLE : JVMTI_ENABLE), - JVMTI_EVENT_SINGLE_STEP, NULL))) + JVMTI_EVENT_SINGLE_STEP, nullptr))) nsk_jvmti_setFailStatus(); } @@ -348,7 +348,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { } if (vm_mode != VM_MODE_COMPILED) { - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, nullptr))) nsk_jvmti_setFailStatus(); } @@ -360,7 +360,7 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { /** Agent library initialization. */ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { - jvmtiEnv* jvmti = NULL; + jvmtiEnv* jvmti = nullptr; jvmtiCapabilities caps; jvmtiEventCallbacks callbacks; const char* optValue; @@ -388,7 +388,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { package_name = nsk_jvmti_findOptionStringValue("package", DEFAULT_PACKAGE_NAME); - if (!NSK_VERIFY(package_name != NULL)) + if (!NSK_VERIFY(package_name != nullptr)) return JNI_ERR; NSK_DISPLAY1("package: %s\n", package_name); @@ -403,7 +403,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { NSK_DISPLAY1("classes: %d\n", max_classes); optValue = nsk_jvmti_findOptionValue("mode"); - if (optValue != NULL) { + if (optValue != nullptr) { if (strcmp(optValue, "compiled") == 0) vm_mode = VM_MODE_COMPILED; else if (strcmp(optValue, "interpreted") == 0) @@ -417,7 +417,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { } optValue = nsk_jvmti_findOptionValue("bci"); - if (optValue != NULL) { + if (optValue != nullptr) { if (strcmp(optValue, "emcp") == 0) bci_mode = BCI_MODE_EMCP; else if (strcmp(optValue, "call") == 0) @@ -437,7 +437,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; /* allocate tables for classes */ @@ -464,7 +464,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) return JNI_ERR; - if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) + if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, nullptr))) return JNI_ERR; /* set event callbacks */ @@ -481,9 +481,9 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { return JNI_ERR; /* enable events */ - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, nullptr))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_LOAD, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_LOAD, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/jvmti_FollowRefObjects.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/jvmti_FollowRefObjects.cpp index 2a9931971b5..bf48fd1da73 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/jvmti_FollowRefObjects.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/jvmti_FollowRefObjects.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2024, 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 @@ -131,13 +131,13 @@ JNIEXPORT jboolean JNICALL Java_nsk_jvmti_unit_FollowReferences_FollowRefObjects jboolean fCopy; const char * s; - if (!NSK_VERIFY((s = jni->GetStringUTFChars(sInfo, &fCopy)) != NULL)) { + if (!NSK_VERIFY((s = jni->GetStringUTFChars(sInfo, &fCopy)) != nullptr)) { NSK_COMPLAIN1("Can't get string at %#p\n", sInfo); return JNI_FALSE; } if (!s) { - NSK_COMPLAIN1("Can't get string at %#p: NULL\n", sInfo); + NSK_COMPLAIN1("Can't get string at %#p: null\n", sInfo); return JNI_FALSE; } @@ -193,7 +193,7 @@ static RefToVerify * findRefToVerify(jlong tagFrom, jlong tagTo, jint refKind) } } - return NULL; + return nullptr; } static jboolean addRefToVerify(jlong tagFrom, jlong tagTo, jint refKind, int expectedCount, int actualCount) @@ -238,7 +238,7 @@ JNIEXPORT jboolean JNICALL Java_nsk_jvmti_unit_FollowReferences_FollowRefObjects } pRefRec = findRefToVerify(tagFrom, tagTo, refKind); - if (pRefRec != NULL) { + if (pRefRec != nullptr) { pRefRec->_expectedCount += count; return JNI_TRUE; } @@ -251,7 +251,7 @@ jboolean markRefToVerify(jlong tagFrom, jlong tagTo, int refKind) RefToVerify * pRefRec; pRefRec = findRefToVerify(tagFrom, tagTo, refKind); - if (pRefRec != NULL) { + if (pRefRec != nullptr) { pRefRec->_actualCount++; return JNI_TRUE; } @@ -380,14 +380,14 @@ jint JNICALL wrongStringPrimitiveValueCallback( void jvmti_FollowRefObject_init() { - g_wrongHeapCallbacks.heap_iteration_callback = NULL; + g_wrongHeapCallbacks.heap_iteration_callback = nullptr; g_wrongHeapCallbacks.heap_reference_callback = wrongHeapReferenceCallback; g_wrongHeapCallbacks.primitive_field_callback = wrongPrimitiveFieldCallback; g_wrongHeapCallbacks.array_primitive_value_callback = wrongArrayPrimitiveValueCallback; g_wrongHeapCallbacks.string_primitive_value_callback = wrongStringPrimitiveValueCallback; - Java_nsk_jvmti_unit_FollowReferences_FollowRefObjects_resetTags(NULL, NULL); - Java_nsk_jvmti_unit_FollowReferences_FollowRefObjects_resetRefsToVerify(NULL, NULL); + Java_nsk_jvmti_unit_FollowReferences_FollowRefObjects_resetTags(nullptr, nullptr); + Java_nsk_jvmti_unit_FollowReferences_FollowRefObjects_resetRefsToVerify(nullptr, nullptr); } /* ============================================================================= */ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/jvmti_tools.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/jvmti_tools.cpp index 444e5c55d1f..e07c453fd0e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/jvmti_tools.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/jvmti_tools.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -100,9 +100,9 @@ static int check_option(int dashed, const char name[], const char value[]) { return NSK_FALSE; } { - char* end = NULL; + char* end = nullptr; long n = strtol(value, &end, 10); - if (end == NULL || end == value || *end != '\0') { + if (end == nullptr || end == value || *end != '\0') { nsk_complain("nsk_jvmti_parseOptions(): not integer value in option: %s=%s\n", name, value); return NSK_FALSE; } @@ -140,7 +140,7 @@ static int add_option(const char opt[], int opt_len, const char val[], int val_l name = (char*)malloc(opt_len + 1); value = (char*)malloc(val_len + 1); - if (name == NULL || value == NULL) { + if (name == nullptr || value == nullptr) { nsk_complain("nsk_jvmti_parseOptions(): out of memory\n"); success = NSK_FALSE; } else { @@ -166,9 +166,9 @@ static int add_option(const char opt[], int opt_len, const char val[], int val_l } if (!success) { - if (name != NULL) + if (name != nullptr) free(name); - if (value != NULL) + if (value != nullptr) free(value); } @@ -184,9 +184,9 @@ static void nsk_jvmti_free() { } context.options.count = 0; } - if (context.options.string != NULL) { + if (context.options.string != nullptr) { free(context.options.string); - context.options.string = NULL; + context.options.string = nullptr; } } @@ -198,18 +198,18 @@ static char* token(char **s, const char *delim) { char *p; char *start = *s; - if (s == NULL || *s == NULL) { - return NULL; + if (s == nullptr || *s == nullptr) { + return nullptr; } p = strpbrk(*s, delim); - if (p != NULL) { + if (p != nullptr) { /* Advance to next token. */ *p = '\0'; *s = p + 1; } else { /* End of tokens. */ - *s = NULL; + *s = nullptr; } return start; @@ -218,11 +218,11 @@ static char* token(char **s, const char *delim) { int nsk_jvmti_parseOptions(const char options[]) { int success = NSK_TRUE; - char *str = NULL; - char *name = NULL; - char *value = NULL; + char *str = nullptr; + char *name = nullptr; + char *value = nullptr; const char *delimiters = " ,~"; - if (options == NULL) + if (options == nullptr) return success; /* @@ -233,10 +233,10 @@ int nsk_jvmti_parseOptions(const char options[]) { /* Create a temporary copy of the options string to be tokenized. */ str = strdup(options); - while ((name = token(&str, delimiters)) != NULL) { + while ((name = token(&str, delimiters)) != nullptr) { value = strchr(name, '='); - if (value != NULL) { + if (value != nullptr) { *value++ = '\0'; } if (!add_option(name, (int)strlen(name), value, @@ -248,7 +248,7 @@ int nsk_jvmti_parseOptions(const char options[]) { if (!success) { nsk_jvmti_free(); } - if (str != NULL) { + if (str != nullptr) { free(str); } return success; @@ -257,45 +257,45 @@ int nsk_jvmti_parseOptions(const char options[]) { /*************************************************************/ /** - * Returns value of given option name; or NULL if no such option found. - * If search name is NULL then complains an error and returns NULL. + * Returns value of given option name; or nullptr if no such option found. + * If search name is nullptr then complains an error and returns nullptr. */ const char* nsk_jvmti_findOptionValue(const char name[]) { int i; - if (name == NULL) { - nsk_complain("nsk_jvmti_findOptionValue(): option name is NULL\n"); - return NULL; + if (name == nullptr) { + nsk_complain("nsk_jvmti_findOptionValue(): option name is null\n"); + return nullptr; } for (i = 0; i < context.options.count; i++) { if (strcmp(name, context.options.names[i]) == 0) return context.options.values[i]; } - return NULL; + return nullptr; } /** * Returns string value of given option; or defaultValue if no such option found. - * If options is specified but has empty value then complains an error and returns NULL. + * If options is specified but has empty value then complains an error and returns nullptr. */ const char* nsk_jvmti_findOptionStringValue(const char name[], const char* defaultValue) { const char* value; - if (name == NULL) { - nsk_complain("nsk_jvmti_findOptionStringValue(): option name is NULL\n"); - return NULL; + if (name == nullptr) { + nsk_complain("nsk_jvmti_findOptionStringValue(): option name is null\n"); + return nullptr; } value = nsk_jvmti_findOptionValue(name); - if (value == NULL) { + if (value == nullptr) { return defaultValue; } if (strlen(value) <= 0) { nsk_complain("nsk_jvmti_findOptionStringValue(): empty value of option: %s=%s\n", name, value); - return NULL; + return nullptr; } return value; } @@ -307,13 +307,13 @@ const char* nsk_jvmti_findOptionStringValue(const char name[], const char* defau int nsk_jvmti_findOptionIntValue(const char name[], int defaultValue) { const char* value; - if (name == NULL) { - nsk_complain("nsk_jvmti_findOptionIntValue(): option name is NULL\n"); + if (name == nullptr) { + nsk_complain("nsk_jvmti_findOptionIntValue(): option name is null\n"); return -1; } value = nsk_jvmti_findOptionValue(name); - if (value == NULL) { + if (value == nullptr) { return defaultValue; } @@ -324,10 +324,10 @@ int nsk_jvmti_findOptionIntValue(const char name[], int defaultValue) { } { - char* endptr = NULL; + char* endptr = nullptr; int n = strtol(value, &endptr, 10); - if (endptr == NULL || *endptr != '\0') { + if (endptr == nullptr || *endptr != '\0') { nsk_complain("nsk_jvmti_findOptionIntValue(): not integer value of option: %s=%s\n", name, value); return -1; @@ -345,24 +345,24 @@ int nsk_jvmti_getOptionsCount() { /** * Returns name of i-th parsed option. - * If no such option then complains an error and returns NULL. + * If no such option then complains an error and returns nullptr. */ const char* nsk_jvmti_getOptionName(int i) { if (i < 0 || i >= context.options.count) { nsk_complain("nsk_jvmti_getOptionName(): option index out of bounds: %d\n", i); - return NULL; + return nullptr; } return context.options.names[i]; } /** * Returns value of i-th parsed option. - * If no such option then complains an error and returns NULL. + * If no such option then complains an error and returns nullptr. */ const char* nsk_jvmti_getOptionValue(int i) { if (i < 0 || i >= context.options.count) { nsk_complain("nsk_jvmti_getOptionValue(): option index out of bounds: %d\n", i); - return NULL; + return nullptr; } return context.options.values[i]; } @@ -414,10 +414,10 @@ int nsk_jvmti_lverify(int positive, jvmtiError error, jvmtiError expected, JNIEXPORT jstring JNICALL Java_nsk_share_jvmti_ArgumentHandler_getAgentOptionsString(JNIEnv *jni, jobject obj) { - jstring str_obj = NULL; + jstring str_obj = nullptr; - if (!NSK_JNI_VERIFY(jni, (str_obj = jni->NewStringUTF(context.options.string)) != NULL)) { - return NULL; + if (!NSK_JNI_VERIFY(jni, (str_obj = jni->NewStringUTF(context.options.string)) != nullptr)) { + return nullptr; } return str_obj; } @@ -453,13 +453,13 @@ int nsk_jvmti_redefineClass(jvmtiEnv * jvmti, jclass classToRedefine, const char * fileName) { redefineAttempted = NSK_TRUE; - if (nsk_jvmti_findOptionValue(NSK_JVMTI_OPT_PATH_TO_NEW_BYTE_CODE) == NULL) { + if (nsk_jvmti_findOptionValue(NSK_JVMTI_OPT_PATH_TO_NEW_BYTE_CODE) == nullptr) { nsk_printf("# error expected: %s \n", NSK_JVMTI_OPT_PATH_TO_NEW_BYTE_CODE); nsk_printf("Hint :: missing java -agentlib:agentlib=%s=DirName, ($TESTBASE/bin) \n", NSK_JVMTI_OPT_PATH_TO_NEW_BYTE_CODE); return NSK_FALSE; } - if (fileName == NULL) { + if (fileName == nullptr) { nsk_printf("# error file name expected did not found \n"); return NSK_FALSE; } @@ -479,7 +479,7 @@ int nsk_jvmti_redefineClass(jvmtiEnv * jvmti, bytecode = fopen(file, "rb"); error= JVMTI_ERROR_NONE; - if (bytecode == NULL) { + if (bytecode == nullptr) { nsk_printf("# error **Agent::error opening file %s \n",file); return NSK_FALSE; } @@ -594,7 +594,7 @@ int suspendThreadAtMethod(jvmtiEnv *jvmti, jclass cls, jobject thread, jmethodID } int result = NSK_TRUE; - jmethodID method = NULL; + jmethodID method = nullptr; jlocation loc; // We need to ensure that the thread is suspended at the right place when the top diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/unit/Heap.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/unit/Heap.cpp index fe7f3f16f16..8306fd07c5e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/unit/Heap.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/unit/Heap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ static jboolean user_data_error_flag = JNI_FALSE; static jvmtiEventObjectFree object_free_callback; static void JNICALL default_object_free(jvmtiEnv *env, jlong tag) { - if (object_free_callback != NULL) { + if (object_free_callback != nullptr) { (*object_free_callback)(env, tag); } } @@ -58,9 +58,9 @@ static jvmtiIterationControl JNICALL default_heap_object_callback } static jvmtiHeapObjectCallback heap_object_callback = default_heap_object_callback; -static jvmtiHeapRootCallback heap_root_callback = NULL; -static jvmtiStackReferenceCallback stack_ref_callback = NULL; -static jvmtiObjectReferenceCallback object_ref_callback = NULL; +static jvmtiHeapRootCallback heap_root_callback = nullptr; +static jvmtiStackReferenceCallback stack_ref_callback = nullptr; +static jvmtiObjectReferenceCallback object_ref_callback = nullptr; /* * Basic tagging functions @@ -182,13 +182,13 @@ JNIEXPORT jint JNICALL Java_nsk_share_jvmti_unit_Heap_getObjectsWithTags /* get rid of any arrays that we are holding from a previous call */ - if (object_results_ref != NULL) { + if (object_results_ref != nullptr) { env->DeleteGlobalRef(object_results_ref); - object_results_ref = NULL; + object_results_ref = nullptr; } - if (tag_results_ref != NULL) { + if (tag_results_ref != nullptr) { env->DeleteGlobalRef(tag_results_ref); - tag_results_ref = NULL; + tag_results_ref = nullptr; } /* copy input list-of-tags from java into C */ @@ -210,7 +210,7 @@ JNIEXPORT jint JNICALL Java_nsk_share_jvmti_unit_Heap_getObjectsWithTags cls = env->FindClass("java/lang/Object"); - object_array = env->NewObjectArray(count, cls, NULL); + object_array = env->NewObjectArray(count, cls, nullptr); tag_array = env->NewLongArray(count); for (i=0; iSetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_OBJECT_FREE, NULL); + err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_OBJECT_FREE, nullptr); if (err != JVMTI_ERROR_NONE) { fprintf(stderr, "SetEventNotificationMode failed, error=%d\n", err); return -1; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/native/native_thread.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/native/native_thread.cpp index c6e95b11f78..d17856ee22a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/native/native_thread.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/native/native_thread.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -73,12 +73,12 @@ typedef /***************************************************************/ /** - * Return a new thread mirror, or NULL if failed. + * Return a new thread mirror, or nullptr if failed. */ void* THREAD_new(PROCEDURE procedure, void* context) { THREAD* thread = (THREAD*)malloc(sizeof(THREAD)); - if (thread == NULL) - return NULL; + if (thread == nullptr) + return nullptr; thread->procedure = procedure; thread->context = context; thread->started = 0; /* No */ @@ -102,30 +102,30 @@ void* procedure(void* t) { } /** - * Return the thread if started OK, or NULL if failed. + * Return the thread if started OK, or nullptr if failed. */ void* THREAD_start(void* t) { THREAD* thread = (THREAD*)t; - if (thread == NULL) - return NULL; + if (thread == nullptr) + return nullptr; if (thread->started != 0) - return NULL; + return nullptr; /* thread->started = 0; -- not yet */ thread->finished = 0; thread->status = 0; { #ifdef windows - uintptr_t result = _beginthreadex(NULL,0,procedure,thread,0,&(thread->id)); + uintptr_t result = _beginthreadex(nullptr,0,procedure,thread,0,&(thread->id)); if (result == 0) { perror("failed to create a native thread"); - return NULL; + return nullptr; } #elif sun - int result = thr_create(NULL,0,procedure,thread,0,&(thread->id)); + int result = thr_create(nullptr,0,procedure,thread,0,&(thread->id)); if (result != 0) { perror("failed to create a native thread"); - return NULL; + return nullptr; } #else // !windows & !sun pthread_attr_t attr; @@ -135,7 +135,7 @@ void* THREAD_start(void* t) { int result = pthread_create(&(thread->id), &attr, procedure, thread); if (result != 0) { perror("failed to create a native thread"); - return NULL; + return nullptr; } pthread_attr_destroy(&attr); #endif // !windows & !sun @@ -147,11 +147,11 @@ void* THREAD_start(void* t) { /** * Return 1 if the thread has been started, or 0 if not, - * or -1 if thread == NULL. + * or -1 if thread == nullptr. */ int THREAD_isStarted(void* t) { THREAD* thread = (THREAD*)t; - if (thread == NULL) + if (thread == nullptr) return -1; return (thread->started == 1); } @@ -159,11 +159,11 @@ int THREAD_isStarted(void* t) { /** * Return 1 if the thread has been started and already has finished, * or 0 if the thread hasn't finish (or even hasn't been started), - * or -1 if thread == NULL. + * or -1 if thread == nullptr. */ int THREAD_hasFinished(void* t) { THREAD* thread = (THREAD*)t; - if (thread == NULL) + if (thread == nullptr) return -1; return (thread->finished == 1); } @@ -171,11 +171,11 @@ int THREAD_hasFinished(void* t) { /** * Return thread->status if thread has finished, * or return 0 if thread hasn't finished, - * or retuen -1 if thread == NULL. + * or retuen -1 if thread == nullptr. */ int THREAD_status(void* t) { THREAD* thread = (THREAD*)t; - if (thread == NULL) + if (thread == nullptr) return -1; return thread->status; } @@ -184,11 +184,11 @@ int THREAD_status(void* t) { /** * Cycle with 1 second sleeps until the thread has finished; - * or return immediately, if thread == NULL. + * or return immediately, if thread == nullptr. */ void THREAD_waitFor(void* t) { THREAD* thread = (THREAD*)t; - if (thread == NULL) + if (thread == nullptr) return; while (thread->finished == 0) THREAD_sleep(1); /* yield for a second */ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/native/nsk_list.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/native/nsk_list.cpp index 74f2416dfce..63708bd84f4 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/native/nsk_list.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/native/nsk_list.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, 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 @@ -48,16 +48,16 @@ const void* nsk_list_create() { /* create nsk_list_info */ list_info = (nsk_list_info *)malloc(sizeof(nsk_list_info)); - if (list_info == NULL) { - return NULL; + if (list_info == nullptr) { + return nullptr; } list_info->allocated_count = NSK_LIST_INIT_COUNT; list_info->elements_count = 0; list_info->arr = (const void **)malloc(list_info->allocated_count * nsk_list_size_void); - if (list_info->arr == NULL) { + if (list_info->arr == nullptr) { free(list_info); - return NULL; + return nullptr; } return list_info; @@ -84,7 +84,7 @@ int nsk_list_add(const void *plist, const void *p) { if (list_info->elements_count >= list_info->allocated_count) { list_info->allocated_count += NSK_LIST_INIT_COUNT; list_info->arr = (const void **)realloc((void *)list_info->arr, list_info->allocated_count * nsk_list_size_void); - if (list_info->arr == NULL) { + if (list_info->arr == nullptr) { return NSK_FALSE; } } @@ -131,7 +131,7 @@ const void* nsk_list_get(const void *plist, int i) { return list_info->arr[i]; } - return NULL; + return nullptr; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/native/nsk_mutex.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/native/nsk_mutex.cpp index d057e364dea..305317ffffa 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/native/nsk_mutex.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/native/nsk_mutex.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2024, 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 @@ -35,7 +35,7 @@ MUTEX* MUTEX_create() MUTEX* mutex = (MUTEX*)malloc(sizeof(pthread_mutex_t)); if (mutex) { - pthread_mutex_init((pthread_mutex_t*)mutex, NULL); + pthread_mutex_init((pthread_mutex_t*)mutex, nullptr); } return mutex; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/native/nsk_tools.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/native/nsk_tools.cpp index 91992159a96..3ba69427fd6 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/native/nsk_tools.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/native/nsk_tools.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -67,8 +67,8 @@ static const char* file_basename(const char* fullname) { const char* p; const char* base = fullname;; - if (fullname == NULL) - return NULL; + if (fullname == nullptr) + return nullptr; for (p = fullname; *p != '\0'; p++) { if (*p == '/' || *p == '\\') @@ -82,7 +82,7 @@ static const char* file_basename(const char* fullname) { void nsk_display(const char format[], ...) { va_list ap; va_start(ap,format); - nsk_lvdisplay(NULL,0,format,ap); + nsk_lvdisplay(nullptr,0,format,ap); va_end(ap); } @@ -94,14 +94,14 @@ void nsk_ldisplay(const char file[], int line, const char format[], ...) { } void nsk_vdisplay(const char format[], va_list ap) { - nsk_lvdisplay(NULL,0,format,ap); + nsk_lvdisplay(nullptr,0,format,ap); } void nsk_lvdisplay(const char file[], int line, const char format[], va_list ap) { if (!nsk_context.verbose) return; - if (file != NULL) + if (file != nullptr) (void) nsk_printf("- %s, %d: ",file_basename(file),line); (void) nsk_vprintf(format,ap); } @@ -111,7 +111,7 @@ void nsk_lvdisplay(const char file[], int line, const char format[], va_list ap) void nsk_complain(const char format[], ...) { va_list ap; va_start(ap,format); - nsk_lvcomplain(NULL,0,format,ap); + nsk_lvcomplain(nullptr,0,format,ap); va_end(ap); } @@ -124,7 +124,7 @@ void nsk_lcomplain(const char file[], int line, const char format[], ...) } void nsk_vcomplain(const char format[], va_list ap) { - nsk_lvcomplain(NULL,0,format,ap); + nsk_lvcomplain(nullptr,0,format,ap); } void nsk_lvcomplain(const char file[], int line, @@ -157,7 +157,7 @@ void nsk_lvcomplain(const char file[], int line, strncpy(msg_buf2, msg_buf, sizeof(msg_buf2)); // Only include up to the 1st newline in the exception's error message. nl_ptr = strchr(msg_buf2, '\n'); - if (nl_ptr != NULL) { + if (nl_ptr != nullptr) { nl_ptr++; // Skip past the newline char. *nl_ptr = '\0'; // Terminate the string after the newline char. } else if (strlen(msg_buf2) != 0) { @@ -165,14 +165,14 @@ void nsk_lvcomplain(const char file[], int line, } (void) nsk_printf("The following fake exception stacktrace is for failure analysis. \n"); (void) nsk_printf("nsk.share.Fake_Exception_for_RULE_Creation: "); - if (file != NULL) { + if (file != nullptr) { (void) nsk_printf("(%s:%d) ", file_basename(file), line); } (void) nsk_printf(msg_buf2); (void) nsk_printf("\tat nsk_lvcomplain(%s:%d)\n", file_basename(__FILE__), __LINE__); } - if (file != NULL) { + if (file != nullptr) { (void) nsk_printf("# ERROR: %s, %d: ", file_basename(file), line); } else { (void) nsk_printf("# ERROR: "); @@ -265,7 +265,7 @@ void nsk_printHexBytes(const char indent[], int columns, size_t i; - if (size <= 0 || bytes == NULL) + if (size <= 0 || bytes == nullptr) return; for (i = 0; i < size; i += columns) { @@ -298,7 +298,7 @@ void nsk_printHexBytes(const char indent[], int columns, /*************************************************************/ const char* nsk_null_string(const char* str) { - return (str == NULL)? "" : str; + return (str == nullptr)? "" : str; } /*************************************************************/ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/jni/gclocker/libgcl001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/stress/jni/gclocker/libgcl001.cpp index 54b9e9df6e4..773b2aae28b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/jni/gclocker/libgcl001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/jni/gclocker/libgcl001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,22 +37,22 @@ #define BODY(type) \ int hash = 0; \ jsize i, arraySize, stringSize; \ - jchar *nativeStr = NULL; \ - type *nativeArray = NULL; \ + jchar *nativeStr = nullptr; \ + type *nativeArray = nullptr; \ \ arraySize = env->GetArrayLength(array); CE \ stringSize = env->GetStringLength(str); CE \ \ - nativeArray = (type *)env->GetPrimitiveArrayCritical(array, NULL); CE \ + nativeArray = (type *)env->GetPrimitiveArrayCritical(array, nullptr); CE \ qsort(nativeArray, arraySize, sizeof(type), *type##comp); \ \ - nativeStr = (jchar *)env->GetStringCritical(str, NULL); CE \ + nativeStr = (jchar *)env->GetStringCritical(str, nullptr); CE \ \ for (i = 0; i < stringSize; ++i) \ hash += (int)nativeStr[i]; \ env->ReleaseStringCritical(str, nativeStr); CE \ \ - nativeStr = (jchar *)env->GetStringCritical(str, NULL); CE \ + nativeStr = (jchar *)env->GetStringCritical(str, nullptr); CE \ \ env->ReleasePrimitiveArrayCritical(array, nativeArray, 0); CE \ \ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/jni/libjnistress001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/stress/jni/libjnistress001.cpp index 2e056006824..2eaba727ff4 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/jni/libjnistress001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/jni/libjnistress001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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,8 +108,8 @@ Java_nsk_stress_jni_JNIter001_jnistress (JNIEnv *env, jobject jobj, jstring jstr } if (memcmp(digest, element->checkstr[j], DIGESTLENGTH) == 0) { env->ReleaseStringUTFChars(jstr, element->str[j]); CE - element->str[j] = NULL; - element->checkstr[j] = NULL; + element->str[j] = nullptr; + element->checkstr[j] = nullptr; } else { compared = 0; printf("The element No. %d has been corrupted %s vs %s\n", j, @@ -217,8 +217,8 @@ Java_nsk_stress_jni_JNIter001_jnistress1(JNIEnv *env, jobject jobj, jstring jstr free(elem); if (memcmp(digest, javachars->checkstr[j], javachars->size[j]) == 0) { env->ReleaseStringChars(jstr, javachars->str[j]); CE - javachars->str[j] = NULL; - javachars->checkstr[j] = NULL; + javachars->str[j] = nullptr; + javachars->checkstr[j] = nullptr; javachars->size[j] = 0; } else { equal = 0; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/jni/libjnistress003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/stress/jni/libjnistress003.cpp index 7bccbc95900..7fa25b831c2 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/jni/libjnistress003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/jni/libjnistress003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -141,8 +141,8 @@ Java_nsk_stress_jni_JNIter003_jniBodyChangeArray (JNIEnv *env, jobject jobj, jdouble *doubleOrig, *doubleClone; int i; - if ((orig == NULL) || (clone == NULL)) { - fprintf(stderr, "JNI received a NULL array from Java\n"); + if ((orig == nullptr) || (clone == nullptr)) { + fprintf(stderr, "JNI received a null array from Java\n"); return JNI_FALSE; } if (count == limit) { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace005.cpp b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace005.cpp index 4cc89978fd1..77f83b374c0 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace005.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace005.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ JNI_OnLoad(JavaVM *vm, void *reserved) FIND_CLASS(stackOverflowErrorClass, "java/lang/StackOverflowError"); stackOverflowErrorClass = (jclass) env->NewGlobalRef(stackOverflowErrorClass); - if (stackOverflowErrorClass == NULL) { + if (stackOverflowErrorClass == nullptr) { printf("Can't create global ref for stack overflow class\n"); return 0; } @@ -56,7 +56,7 @@ JNI_OnUnload(JavaVM *vm, void *reserved) JNIEnv *env; if (vm->GetEnv((void **) &env, JNI_VERSION) != JNI_OK) { - if (stackOverflowErrorClass != NULL) { + if (stackOverflowErrorClass != nullptr) { env->DeleteGlobalRef(stackOverflowErrorClass); } } else { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace006.cpp b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace006.cpp index 9b5329f2cb9..a70030fb095 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace006.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace006.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ JNI_OnLoad(JavaVM *vm, void *reserved) FIND_CLASS(stackOverflowErrorClass, "java/lang/StackOverflowError"); stackOverflowErrorClass = (jclass) env->NewGlobalRef(stackOverflowErrorClass); - if (stackOverflowErrorClass == NULL) { + if (stackOverflowErrorClass == nullptr) { printf("Can't create global ref for stack overflow class\n"); return 0; } @@ -58,7 +58,7 @@ JNI_OnUnload(JavaVM *vm, void *reserved) JNIEnv *env; if (vm->GetEnv((void **) &env, JNI_VERSION) != JNI_OK) { - if (stackOverflowErrorClass != NULL) { + if (stackOverflowErrorClass != nullptr) { env->DeleteGlobalRef(stackOverflowErrorClass); } } else { diff --git a/test/hotspot/jtreg/vmTestbase/vm/mlvm/indy/func/jvmti/share/IndyRedefineClass.cpp b/test/hotspot/jtreg/vmTestbase/vm/mlvm/indy/func/jvmti/share/IndyRedefineClass.cpp index 2f4cefd19b5..04d4c6094cc 100644 --- a/test/hotspot/jtreg/vmTestbase/vm/mlvm/indy/func/jvmti/share/IndyRedefineClass.cpp +++ b/test/hotspot/jtreg/vmTestbase/vm/mlvm/indy/func/jvmti/share/IndyRedefineClass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2024, 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 @@ -32,7 +32,7 @@ extern "C" { -static jvmtiEnv* gJvmtiEnv = NULL; +static jvmtiEnv* gJvmtiEnv = nullptr; static jboolean gIsMethodEntryWorking = JNI_FALSE; static jboolean gIsSingleStepWorking = JNI_FALSE; @@ -88,13 +88,13 @@ static void popFrameLogic(jvmtiEnv * jvmti_env, jthread thread) { if (tls->countOfFramesToPop <= 0) { NSK_DISPLAY0("Disabling single step\n"); - if (!NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, nullptr))) gIsErrorOccured = JNI_TRUE; } else { NSK_DISPLAY0("Enabling single step\n"); - if (!NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, NULL))) + if (!NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, nullptr))) gIsErrorOccured = JNI_TRUE; if (tls->countOfFramesToPop == 1) { @@ -132,7 +132,7 @@ MethodEntry(jvmtiEnv *jvmti_env, } NSK_DISPLAY2("Entering redefine tigger method: %s.%s\n", mn->classSig, mn->methodName); - free(mn); mn = NULL; + free(mn); mn = nullptr; if (gIsClassRedefined) { NSK_DISPLAY0("Class is already redefined.\n"); @@ -168,7 +168,7 @@ SingleStep(jvmtiEnv *jvmti_env, gIsSingleStepWorking = JNI_TRUE; locStr = locationToString(jvmti_env, method, location); - if (locStr == NULL) { + if (locStr == nullptr) { NSK_DISPLAY0("Error in Single step event: locationToString failed\n"); gIsErrorOccured = JNI_TRUE; } else { @@ -186,7 +186,7 @@ jint Agent_Initialize(JavaVM * vm, char * options, void * reserved) { if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; - if (!NSK_VERIFY((gJvmtiEnv = nsk_jvmti_createJVMTIEnv(vm, reserved)) != NULL)) + if (!NSK_VERIFY((gJvmtiEnv = nsk_jvmti_createJVMTIEnv(vm, reserved)) != nullptr)) return JNI_ERR; if (nsk_jvmti_findOptionValue("debuggerCompatible")) { @@ -210,10 +210,10 @@ jint Agent_Initialize(JavaVM * vm, char * options, void * reserved) { if (!NSK_JVMTI_VERIFY(gJvmtiEnv->SetEventCallbacks(&callbacks, sizeof(callbacks)))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(gJvmtiEnv->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_ENTRY, NULL))) + if (!NSK_JVMTI_VERIFY(gJvmtiEnv->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_ENTRY, nullptr))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(gJvmtiEnv->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, NULL))) + if (!NSK_JVMTI_VERIFY(gJvmtiEnv->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/vm/mlvm/indy/func/jvmti/stepBreakPopReturn/stepBreakPopReturn.cpp b/test/hotspot/jtreg/vmTestbase/vm/mlvm/indy/func/jvmti/stepBreakPopReturn/stepBreakPopReturn.cpp index bcae1379e45..3221037484b 100644 --- a/test/hotspot/jtreg/vmTestbase/vm/mlvm/indy/func/jvmti/stepBreakPopReturn/stepBreakPopReturn.cpp +++ b/test/hotspot/jtreg/vmTestbase/vm/mlvm/indy/func/jvmti/stepBreakPopReturn/stepBreakPopReturn.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2024, 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 @@ -32,7 +32,7 @@ extern "C" { -static jvmtiEnv* gJvmtiEnv = NULL; +static jvmtiEnv* gJvmtiEnv = nullptr; static char * gszDebuggeeMethodName = (char*) "NONE"; static char * gszDebuggeeClassName = (char*) "NONE"; @@ -89,7 +89,7 @@ MethodEntry(jvmtiEnv *jvmti_env, gIsMethodEntryWorking = JNI_TRUE; if (!gIsBreakpointSet) - NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, NULL)); + NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, nullptr)); } } @@ -108,7 +108,7 @@ SingleStep(jvmtiEnv *jvmti_env, locStr = locationToString(jvmti_env, method, location); - if (locStr == NULL) { + if (locStr == nullptr) { NSK_DISPLAY0("Error: Single step event has no location\n"); gErrorHappened = JNI_TRUE; } else { @@ -116,13 +116,13 @@ SingleStep(jvmtiEnv *jvmti_env, free(locStr); } - NSK_JVMTI_VERIFY(gJvmtiEnv->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, NULL)); + NSK_JVMTI_VERIFY(gJvmtiEnv->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, nullptr)); if (!gIsDebuggerCompatible) { if (!NSK_JVMTI_VERIFY(jvmti_env->SetBreakpoint(method, location))) return; - NSK_JVMTI_VERIFY(gJvmtiEnv->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL)); + NSK_JVMTI_VERIFY(gJvmtiEnv->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, nullptr)); gIsBreakpointSet = JNI_TRUE; NSK_DISPLAY0("Pop a frame\n"); @@ -150,7 +150,7 @@ Breakpoint(jvmtiEnv *jvmti_env, gIsBreakpointWorking = JNI_TRUE; locStr = locationToString(jvmti_env, method, location); - if (locStr == NULL) { + if (locStr == nullptr) { NSK_DISPLAY0("Error: Breakpoint event has no location\n"); gErrorHappened = JNI_TRUE; } else { @@ -159,7 +159,7 @@ Breakpoint(jvmtiEnv *jvmti_env, } NSK_JVMTI_VERIFY(jvmti_env->ClearBreakpoint(method, location)); - NSK_JVMTI_VERIFY(gJvmtiEnv->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_BREAKPOINT, NULL)); + NSK_JVMTI_VERIFY(gJvmtiEnv->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_BREAKPOINT, nullptr)); gIsBreakpointSet = JNI_FALSE; NSK_DISPLAY0("Forcing early return.\n"); @@ -173,7 +173,7 @@ jint Agent_Initialize(JavaVM * vm, char * options, void * reserved) { if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) return JNI_ERR; - if (!NSK_VERIFY((gJvmtiEnv = nsk_jvmti_createJVMTIEnv(vm, reserved)) != NULL)) + if (!NSK_VERIFY((gJvmtiEnv = nsk_jvmti_createJVMTIEnv(vm, reserved)) != nullptr)) return JNI_ERR; if (nsk_jvmti_findOptionValue("debuggerCompatible")) { @@ -198,7 +198,7 @@ jint Agent_Initialize(JavaVM * vm, char * options, void * reserved) { if (!NSK_JVMTI_VERIFY(gJvmtiEnv->SetEventCallbacks(&callbacks, sizeof(callbacks)))) return JNI_ERR; - if (!NSK_JVMTI_VERIFY(gJvmtiEnv->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_ENTRY, NULL))) + if (!NSK_JVMTI_VERIFY(gJvmtiEnv->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_ENTRY, nullptr))) return JNI_ERR; return JNI_OK; diff --git a/test/hotspot/jtreg/vmTestbase/vm/mlvm/meth/stress/jni/nativeAndMH/nativeAndMH.cpp b/test/hotspot/jtreg/vmTestbase/vm/mlvm/meth/stress/jni/nativeAndMH/nativeAndMH.cpp index 4124b7fb8e7..27dfa84dead 100644 --- a/test/hotspot/jtreg/vmTestbase/vm/mlvm/meth/stress/jni/nativeAndMH/nativeAndMH.cpp +++ b/test/hotspot/jtreg/vmTestbase/vm/mlvm/meth/stress/jni/nativeAndMH/nativeAndMH.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2024, 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 @@ -48,16 +48,16 @@ Java_vm_mlvm_meth_stress_jni_nativeAndMH_Test_native01( jobjectArray arguments; jobject result; - if (!NSK_JNI_VERIFY(pEnv, (mhClass = pEnv->GetObjectClass(mhToCall)) != NULL)) - return NULL; + if (!NSK_JNI_VERIFY(pEnv, (mhClass = pEnv->GetObjectClass(mhToCall)) != nullptr)) + return nullptr; - if (!NSK_JNI_VERIFY(pEnv, NULL != (mid = pEnv->GetMethodID(mhClass, "invokeWithArguments", "([Ljava/lang/Object;)Ljava/lang/Object;")))) - return NULL; + if (!NSK_JNI_VERIFY(pEnv, nullptr != (mid = pEnv->GetMethodID(mhClass, "invokeWithArguments", "([Ljava/lang/Object;)Ljava/lang/Object;")))) + return nullptr; - NSK_JNI_VERIFY(pEnv, NULL != (objectClass = pEnv->FindClass("java/lang/Object"))); + NSK_JNI_VERIFY(pEnv, nullptr != (objectClass = pEnv->FindClass("java/lang/Object"))); - if (!NSK_JNI_VERIFY(pEnv, NULL != (arguments = pEnv->NewObjectArray(ARGS_COUNT, objectClass, NULL)))) - return NULL; + if (!NSK_JNI_VERIFY(pEnv, nullptr != (arguments = pEnv->NewObjectArray(ARGS_COUNT, objectClass, nullptr)))) + return nullptr; NSK_JNI_VERIFY_VOID(pEnv, pEnv->SetObjectArrayElement(arguments, 0, a1)); NSK_JNI_VERIFY_VOID(pEnv, pEnv->SetObjectArrayElement(arguments, 1, a2)); @@ -67,7 +67,7 @@ Java_vm_mlvm_meth_stress_jni_nativeAndMH_Test_native01( NSK_JNI_VERIFY_VOID(pEnv, pEnv->SetObjectArrayElement(arguments, 5, a6)); // Swap arguments - NSK_JNI_VERIFY(pEnv, NULL != (result = pEnv->CallObjectMethod(mhToCall, mid, arguments))); + NSK_JNI_VERIFY(pEnv, nullptr != (result = pEnv->CallObjectMethod(mhToCall, mid, arguments))); return result; } diff --git a/test/hotspot/jtreg/vmTestbase/vm/mlvm/share/mlvmJvmtiUtils.cpp b/test/hotspot/jtreg/vmTestbase/vm/mlvm/share/mlvmJvmtiUtils.cpp index 1c0f79dd667..d44a5cedd73 100644 --- a/test/hotspot/jtreg/vmTestbase/vm/mlvm/share/mlvmJvmtiUtils.cpp +++ b/test/hotspot/jtreg/vmTestbase/vm/mlvm/share/mlvmJvmtiUtils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,7 @@ void copyFromJString(JNIEnv * pEnv, jstring src, char ** dst) { const char * pStr; jsize len; - if (!NSK_VERIFY((pStr = pEnv->GetStringUTFChars(src, NULL)) != NULL)) { + if (!NSK_VERIFY((pStr = pEnv->GetStringUTFChars(src, nullptr)) != nullptr)) { return; } @@ -70,30 +70,30 @@ struct MethodName * getMethodName(jvmtiEnv * pJvmtiEnv, jmethodID method) { jclass clazz; struct MethodName * mn; - if (!NSK_JVMTI_VERIFY(pJvmtiEnv->GetMethodName(method, &szName, NULL, NULL))) { - return NULL; + if (!NSK_JVMTI_VERIFY(pJvmtiEnv->GetMethodName(method, &szName, nullptr, nullptr))) { + return nullptr; } JvmtiResource szNameResource(pJvmtiEnv, szName); if (!NSK_JVMTI_VERIFY(pJvmtiEnv->GetMethodDeclaringClass(method, &clazz))) { - return NULL; + return nullptr; } - if (!NSK_JVMTI_VERIFY(pJvmtiEnv->GetClassSignature(clazz, &szSignature, NULL))) { - return NULL; + if (!NSK_JVMTI_VERIFY(pJvmtiEnv->GetClassSignature(clazz, &szSignature, nullptr))) { + return nullptr; } JvmtiResource szSignatureResource(pJvmtiEnv, szSignature); if (strlen(szName) + 1 > sizeof(mn->methodName) || strlen(szSignature) + 1 > sizeof(mn->classSig)) { - return NULL; + return nullptr; } mn = (MethodName*) malloc(sizeof(MethodNameStruct)); - if (mn == NULL) { - return NULL; + if (mn == nullptr) { + return nullptr; } strncpy(mn->methodName, szName, sizeof(mn->methodName) - 1); @@ -115,17 +115,17 @@ char * locationToString(jvmtiEnv * pJvmtiEnv, jmethodID method, jlocation locati if (!pMN) return strdup("NONE"); - len = snprintf(NULL, 0, format, pMN->classSig, pMN->methodName, location) + 1; + len = snprintf(nullptr, 0, format, pMN->classSig, pMN->methodName, location) + 1; if (len <= 0) { free(pMN); - return NULL; + return nullptr; } result = (char*) malloc(len); - if (result == NULL) { + if (result == nullptr) { free(pMN); - return NULL; + return nullptr; } snprintf(result, len, format, pMN->classSig, pMN->methodName, location); @@ -137,16 +137,16 @@ char * locationToString(jvmtiEnv * pJvmtiEnv, jmethodID method, jlocation locati void * getTLS(jvmtiEnv * pJvmtiEnv, jthread thread, jsize sizeToAllocate) { void * tls; if (!NSK_JVMTI_VERIFY(pJvmtiEnv->GetThreadLocalStorage(thread, &tls))) - return NULL; + return nullptr; if (!tls) { - if (!NSK_VERIFY((tls = malloc(sizeToAllocate)) != NULL)) - return NULL; + if (!NSK_VERIFY((tls = malloc(sizeToAllocate)) != nullptr)) + return nullptr; memset(tls, 0, sizeToAllocate); if (!NSK_JVMTI_VERIFY(pJvmtiEnv->SetThreadLocalStorage(thread, tls))) - return NULL; + return nullptr; } return tls; diff --git a/test/hotspot/jtreg/vmTestbase/vm/runtime/defmeth/shared/redefineClasses.cpp b/test/hotspot/jtreg/vmTestbase/vm/runtime/defmeth/shared/redefineClasses.cpp index 4d5c8af7548..eac0d3fe601 100644 --- a/test/hotspot/jtreg/vmTestbase/vm/runtime/defmeth/shared/redefineClasses.cpp +++ b/test/hotspot/jtreg/vmTestbase/vm/runtime/defmeth/shared/redefineClasses.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ extern "C" { -static jvmtiEnv *test_jvmti = NULL; +static jvmtiEnv *test_jvmti = nullptr; static jvmtiCapabilities caps; /* @@ -50,7 +50,7 @@ Java_vm_runtime_defmeth_shared_Util_redefineClassIntl(JNIEnv *env, jclass clazz, jvmtiClassDefinition classDef; jboolean result = JNI_TRUE; - if (!NSK_VERIFY(env != NULL) || !NSK_VERIFY(clazzToRedefine != NULL) || !NSK_VERIFY(bytecodeArray != NULL)) { + if (!NSK_VERIFY(env != nullptr) || !NSK_VERIFY(clazzToRedefine != nullptr) || !NSK_VERIFY(bytecodeArray != nullptr)) { return JNI_FALSE; } @@ -61,7 +61,7 @@ Java_vm_runtime_defmeth_shared_Util_redefineClassIntl(JNIEnv *env, jclass clazz, } if (!NSK_JNI_VERIFY(env, - (classDef.class_bytes = (const unsigned char *) /* jbyte* */ env->GetByteArrayElements(bytecodeArray, NULL)) != NULL)) { + (classDef.class_bytes = (const unsigned char *) /* jbyte* */ env->GetByteArrayElements(bytecodeArray, nullptr)) != nullptr)) { return JNI_FALSE; } @@ -86,7 +86,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { /* create JVMTI environment */ if (!NSK_VERIFY((test_jvmti = - nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) + nsk_jvmti_createJVMTIEnv(jvm, reserved)) != nullptr)) return JNI_ERR; memset(&caps, 0, sizeof(jvmtiCapabilities)); diff --git a/test/hotspot/jtreg/vmTestbase/vm/share/ProcessUtils.cpp b/test/hotspot/jtreg/vmTestbase/vm/share/ProcessUtils.cpp index 0388af34e74..c624db6ee98 100644 --- a/test/hotspot/jtreg/vmTestbase/vm/share/ProcessUtils.cpp +++ b/test/hotspot/jtreg/vmTestbase/vm/share/ProcessUtils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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,12 +49,12 @@ JNIEXPORT jboolean JNICALL Java_vm_share_ProcessUtils_sendSignal if (!GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, 0)) { dw = GetLastError(); FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, + nullptr, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, - NULL + nullptr ); printf("%s\n", (LPTSTR)lpMsgBuf); LocalFree(lpMsgBuf); @@ -82,12 +82,12 @@ JNIEXPORT jboolean JNICALL Java_vm_share_ProcessUtils_sendCtrlBreak if (!GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, 0)) { dw = GetLastError(); FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, + nullptr, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, - NULL + nullptr ); printf("%s\n", (LPTSTR)lpMsgBuf); LocalFree(lpMsgBuf); @@ -111,12 +111,12 @@ void reportLastError(const char *msg) { char *buf; size_t n = (size_t)FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_ALLOCATE_BUFFER, - NULL, + nullptr, errcode, 0, (LPSTR) &buf, (DWORD)len, - NULL); + nullptr); if (n > 3) { /* Drop final '.', CR, LF */ if (buf[n - 1] == '\n') n--; @@ -152,25 +152,25 @@ jboolean doDumpCore() { strcat(path, "\\"); strcat(path, name); dbghelp = LoadLibrary(path); - if (dbghelp == NULL) + if (dbghelp == nullptr) reportLastError("Load DBGHELP.DLL from system directory"); } else { printf("GetSystemDirectory returned 0\n"); } // try Windows directory - if (dbghelp == NULL) { + if (dbghelp == nullptr) { size = GetWindowsDirectory(path, pathLen); if (size > 6) { strcat(path, "\\"); strcat(path, name); dbghelp = LoadLibrary(path); - if (dbghelp == NULL) { + if (dbghelp == nullptr) { reportLastError("Load DBGHELP.DLL from Windows directory"); } } } - if (dbghelp == NULL) { + if (dbghelp == nullptr) { printf("Failed to load DBGHELP.DLL\n"); return JNI_FALSE; } @@ -180,7 +180,7 @@ jboolean doDumpCore() { PMINIDUMP_USER_STREAM_INFORMATION, PMINIDUMP_CALLBACK_INFORMATION)) GetProcAddress(dbghelp, "MiniDumpWriteDump"); - if (_MiniDumpWriteDump == NULL) { + if (_MiniDumpWriteDump == nullptr) { printf("Failed to find MiniDumpWriteDump() in module dbghelp.dll"); return JNI_FALSE; } @@ -193,19 +193,19 @@ jboolean doDumpCore() { MiniDumpWithUnloadedModules); #endif - dumpFile = CreateFile("core.mdmp", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + dumpFile = CreateFile("core.mdmp", GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); if (dumpFile == INVALID_HANDLE_VALUE) { reportLastError("Failed to create file for dumping"); return JNI_FALSE; } - pmei = NULL; + pmei = nullptr; // Older versions of dbghelp.dll (the one shipped with Win2003 for example) may not support all // the dump types we really want. If first call fails, lets fall back to just use MiniDumpWithFullMemory then. - if (_MiniDumpWriteDump(hProcess, processId, dumpFile, dumpType, pmei, NULL, NULL) == FALSE && - _MiniDumpWriteDump(hProcess, processId, dumpFile, (MINIDUMP_TYPE)MiniDumpWithFullMemory, pmei, NULL, NULL) == FALSE) { + if (_MiniDumpWriteDump(hProcess, processId, dumpFile, dumpType, pmei, nullptr, nullptr) == FALSE && + _MiniDumpWriteDump(hProcess, processId, dumpFile, (MINIDUMP_TYPE)MiniDumpWithFullMemory, pmei, nullptr, nullptr) == FALSE) { reportLastError("Call to MiniDumpWriteDump() failed"); return JNI_FALSE; } diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 4db764822c1..6670317082b 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -443,8 +443,8 @@ java/awt/event/KeyEvent/DeadKey/DeadKeyMacOSXInputText.java 8233568 macosx-all java/awt/event/KeyEvent/DeadKey/deadKeyMacOSX.java 8233568 macosx-all java/awt/TrayIcon/RightClickWhenBalloonDisplayed/RightClickWhenBalloonDisplayed.java 8238720 windows-all java/awt/PopupMenu/PopupMenuLocation.java 8259913,8315878 windows-all,macosx-aarch64 -java/awt/GridLayout/ComponentPreferredSize/ComponentPreferredSize.java 8238720 windows-all -java/awt/GridLayout/ChangeGridSize/ChangeGridSize.java 8238720 windows-all +java/awt/GridLayout/ComponentPreferredSize/ComponentPreferredSize.java 8238720,8324782 windows-all,macosx-all +java/awt/GridLayout/ChangeGridSize/ChangeGridSize.java 8238720,8324782 windows-all,macosx-all java/awt/event/MouseEvent/FrameMouseEventAbsoluteCoordsTest/FrameMouseEventAbsoluteCoordsTest.java 8238720 windows-all # Several tests which fail sometimes on macos11 @@ -472,6 +472,9 @@ sun/java2d/DirectX/OnScreenRenderingResizeTest/OnScreenRenderingResizeTest.java java/awt/Window/8159168/SetShapeTest.java 8274106 macosx-aarch64 java/awt/image/multiresolution/MultiResolutionJOptionPaneIconTest.java 8274106 macosx-aarch64 +# This test fails on macOS 14 +java/awt/Choice/SelectNewItemTest/SelectNewItemTest.java 8324782 macosx-all + ############################################################################ # jdk_beans @@ -685,6 +688,9 @@ sanity/client/SwingSet/src/EditorPaneDemoTest.java 8212240 linux-x64 javax/swing/JComboBox/TestComboBoxComponentRendering.java 8309734 linux-all +# This test fails on macOS 14 +javax/swing/plaf/synth/7158712/bug7158712.java 8324782 macosx-all + ############################################################################ # jdk_text diff --git a/test/jdk/java/awt/Frame/ShapeNotSetSometimes/ShapeNotSetSometimes.java b/test/jdk/java/awt/Frame/ShapeNotSetSometimes/ShapeNotSetSometimes.java index 48a0e75ead0..52a5754a9c3 100644 --- a/test/jdk/java/awt/Frame/ShapeNotSetSometimes/ShapeNotSetSometimes.java +++ b/test/jdk/java/awt/Frame/ShapeNotSetSometimes/ShapeNotSetSometimes.java @@ -21,8 +21,6 @@ * questions. */ - - import java.awt.Color; import java.awt.Dimension; import java.awt.EventQueue; @@ -44,7 +42,7 @@ * @key headful * @bug 6988428 * @summary Tests whether shape is always set - * @run main ShapeNotSetSometimes + * @run main/othervm -Dsun.java2d.uiScale=1 ShapeNotSetSometimes */ public class ShapeNotSetSometimes { @@ -55,22 +53,24 @@ public class ShapeNotSetSometimes { private Point[] pointsOutsideToCheck; private Point[] shadedPointsToCheck; private Point innerPoint; - private final Rectangle bounds = new Rectangle(220, 400, 300, 300); private static Robot robot; private static final Color BACKGROUND_COLOR = Color.GREEN; private static final Color SHAPE_COLOR = Color.WHITE; + private static final int DIM = 300; + private static final int DELTA = 2; public ShapeNotSetSometimes() throws Exception { EventQueue.invokeAndWait(this::initializeGUI); robot.waitForIdle(); - robot.delay(1000); + robot.delay(500); } private void initializeGUI() { backgroundFrame = new BackgroundFrame(); backgroundFrame.setUndecorated(true); - backgroundFrame.setBounds(bounds); + backgroundFrame.setSize(DIM, DIM); + backgroundFrame.setLocationRelativeTo(null); backgroundFrame.setVisible(true); Area area = new Area(); @@ -81,8 +81,10 @@ private void initializeGUI() { area.add(new Area(new Ellipse2D.Float(150, 50, 100, 100))); area.add(new Area(new Ellipse2D.Float(150, 100, 100, 100))); - + // point at the center of white ellipse innerPoint = new Point(150, 130); + + // mid points on the 4 sides - on the green background frame pointsOutsideToCheck = new Point[] { new Point(150, 20), new Point(280, 120), @@ -90,6 +92,7 @@ private void initializeGUI() { new Point(20, 120) }; + // points just outside the ellipse (opposite side of diagonal) shadedPointsToCheck = new Point[] { new Point(62, 62), new Point(240, 185) @@ -97,7 +100,8 @@ private void initializeGUI() { window = new TestFrame(); window.setUndecorated(true); - window.setBounds(bounds); + window.setSize(DIM, DIM); + window.setLocationRelativeTo(null); window.setShape(area); window.setVisible(true); } @@ -108,7 +112,7 @@ static class BackgroundFrame extends Frame { public void paint(Graphics g) { g.setColor(BACKGROUND_COLOR); - g.fillRect(0, 0, 300, 300); + g.fillRect(0, 0, DIM, DIM); super.paint(g); } @@ -120,7 +124,7 @@ class TestFrame extends Frame { public void paint(Graphics g) { g.setColor(SHAPE_COLOR); - g.fillRect(0, 0, bounds.width, bounds.height); + g.fillRect(0, 0, DIM, DIM); super.paint(g); } @@ -155,17 +159,24 @@ private void doTest() throws Exception { } } finally { EventQueue.invokeAndWait(() -> { - backgroundFrame.dispose(); - window.dispose(); + if (backgroundFrame != null) { + backgroundFrame.dispose(); + } + if (window != null) { + window.dispose(); + } }); } } private void colorCheck(int x, int y, Color expectedColor, boolean mustBeExpectedColor) { - int screenX = window.getX() + x; int screenY = window.getY() + y; + robot.mouseMove(screenX, screenY); + robot.waitForIdle(); + robot.delay(50); + Color actualColor = robot.getPixelColor(screenX, screenY); System.out.printf( @@ -176,7 +187,7 @@ private void colorCheck(int x, int y, Color expectedColor, boolean mustBeExpecte expectedColor ); - if (mustBeExpectedColor != expectedColor.equals(actualColor)) { + if (mustBeExpectedColor != colorCompare(expectedColor, actualColor)) { captureScreen(); System.out.printf("window.getX() = %3d, window.getY() = %3d\n", window.getX(), window.getY()); System.err.printf( @@ -190,6 +201,15 @@ private void colorCheck(int x, int y, Color expectedColor, boolean mustBeExpecte } } + private static boolean colorCompare(Color expected, Color actual) { + if (Math.abs(expected.getRed() - actual.getRed()) <= DELTA + && Math.abs(expected.getGreen() - actual.getGreen()) <= DELTA + && Math.abs(expected.getBlue() - actual.getBlue()) <= DELTA) { + return true; + } + return false; + } + private static void captureScreen() { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Rectangle screenBounds = new Rectangle(0, 0, screenSize.width, screenSize.height); diff --git a/test/jdk/java/awt/JAWT/myfile.cpp b/test/jdk/java/awt/JAWT/myfile.cpp index 6157e2934eb..80f51f951a9 100644 --- a/test/jdk/java/awt/JAWT/myfile.cpp +++ b/test/jdk/java/awt/JAWT/myfile.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, 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,8 +52,8 @@ JNIEXPORT void JNICALL Java_MyCanvas_paint /* Get the drawing surface */ JAWT_DrawingSurface* ds = awt.GetDrawingSurface(env, canvas); - if (ds == NULL) { - printf("NULL drawing surface\n"); + if (ds == nullptr) { + printf("null drawing surface\n"); return; } @@ -67,7 +67,7 @@ JNIEXPORT void JNICALL Java_MyCanvas_paint /* Get the drawing surface info */ JAWT_DrawingSurfaceInfo* dsi = ds->GetDrawingSurfaceInfo(ds); - if (dsi == NULL) { + if (dsi == nullptr) { printf("Error getting surface info\n"); ds->Unlock(ds); return; diff --git a/test/jdk/java/awt/PopupMenu/TruncatedPopupMenuTest.java b/test/jdk/java/awt/PopupMenu/TruncatedPopupMenuTest.java new file mode 100644 index 00000000000..64d655aa351 --- /dev/null +++ b/test/jdk/java/awt/PopupMenu/TruncatedPopupMenuTest.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2004, 2024, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuItem; +import java.awt.PopupMenu; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/* + * @test + * @bug 5090643 + * @key headful + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary Menus added to the popup menu are truncated on XToolkit + * @run main/manual TruncatedPopupMenuTest + */ + +public class TruncatedPopupMenuTest { + private static final String INSTRUCTIONS = + "1. Right-click on the Test Window.\n\n" + + "2. Look at the appeared popup menu.\n\n" + + "3. It should consist of one menu item (\"First simple menu item\")\n" + + "and one submenu (\"Just simple menu for the test\").\n\n" + + "4. The submenu should not be truncated. The submenu title text should\n" + + "be followed by a triangle. On the whole, menu should be good-looking.\n\n" + + "5. Left-click on the submenu (\"Just simple menu for the test\").\n" + + "After this operation, a submenu should popup. It should consist of\n"+ + "one menu item (\"Second simple menu item \") and one submenu (\"Other Menu\").\n\n" + + "6. The submenu should not be truncated. The \"Other Menu\" text should be followed by\n" + + "a triangle.\n\n" + + "On the whole, menu should be good-looking.\n"; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .rows(20) + .columns(55) + .testUI(TruncatedPopupMenuTest::createTestUI) + .build() + .awaitAndCheck(); + } + + private static Frame createTestUI() { + Menu subMenu = new Menu("Just simple menu for the test"); + subMenu.add(new MenuItem("Second simple menu item")); + subMenu.add(new Menu("Other Menu")); + + PopupMenu popup = new PopupMenu(); + popup.add(new MenuItem("First simple menu item")); + popup.add(subMenu); + + Frame testUI = new Frame("TruncatedPopupMenuTest"); + testUI.add(popup); + testUI.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent me) { + if (me.isPopupTrigger()) { + popup.show(me.getComponent(), me.getX(), me.getY()); + } + } + public void mouseReleased(MouseEvent me) { + if (me.isPopupTrigger()) { + popup.show(me.getComponent(), me.getX(), me.getY()); + } + } + }); + + testUI.setSize(400, 400); + return testUI; + } +} diff --git a/test/jdk/java/foreign/TestLayoutPaths.java b/test/jdk/java/foreign/TestLayoutPaths.java index f04814f5849..c5eee36cd9c 100644 --- a/test/jdk/java/foreign/TestLayoutPaths.java +++ b/test/jdk/java/foreign/TestLayoutPaths.java @@ -311,6 +311,42 @@ public void testOffsetHandle(MemoryLayout layout, PathElement[] pathElements, lo assertEquals(actualByteOffset, expectedByteOffset); } + @Test + public void testGroupElementIndexToString() { + PathElement e = PathElement.groupElement(2); + assertEquals(e.toString(), "groupElement(2)"); + } + + @Test + public void testGroupElementNameToString() { + PathElement e = PathElement.groupElement("x"); + assertEquals(e.toString(), "groupElement(\"x\")"); + } + + @Test + public void testSequenceElementToString() { + PathElement e = PathElement.sequenceElement(); + assertEquals(e.toString(), "sequenceElement()"); + } + + @Test + public void testSequenceElementIndexToString() { + PathElement e = PathElement.sequenceElement(2); + assertEquals(e.toString(), "sequenceElement(2)"); + } + + @Test + public void testSequenceElementRangeToString() { + PathElement e = PathElement.sequenceElement(2, 4); + assertEquals(e.toString(), "sequenceElement(2, 4)"); + } + + @Test + public void testDerefereceElementToString() { + PathElement e = PathElement.dereferenceElement(); + assertEquals(e.toString(), "dereferenceElement()"); + } + @DataProvider public static Object[][] testLayouts() { List testCases = new ArrayList<>(); diff --git a/test/jdk/java/foreign/enablenativeaccess/org/openjdk/foreigntest/unnamed/libLinkerInvokerUnnamed.cpp b/test/jdk/java/foreign/enablenativeaccess/org/openjdk/foreigntest/unnamed/libLinkerInvokerUnnamed.cpp index 271970817d7..cc8469cc68f 100644 --- a/test/jdk/java/foreign/enablenativeaccess/org/openjdk/foreigntest/unnamed/libLinkerInvokerUnnamed.cpp +++ b/test/jdk/java/foreign/enablenativeaccess/org/openjdk/foreigntest/unnamed/libLinkerInvokerUnnamed.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, 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 @@ -27,7 +27,7 @@ void call(void* ctxt) { JavaVM* jvm = (JavaVM*) ctxt; JNIEnv* env; - jvm->AttachCurrentThread((void**)&env, NULL); + jvm->AttachCurrentThread((void**)&env, nullptr); jclass linkerClass = env->FindClass("java/lang/foreign/Linker"); jmethodID nativeLinkerMethod = env->GetStaticMethodID(linkerClass, "nativeLinker", "()Ljava/lang/foreign/Linker;"); env->CallStaticVoidMethod(linkerClass, nativeLinkerMethod); diff --git a/test/jdk/java/foreign/enablenativeaccess/panama_module/org/openjdk/foreigntest/libLinkerInvokerModule.cpp b/test/jdk/java/foreign/enablenativeaccess/panama_module/org/openjdk/foreigntest/libLinkerInvokerModule.cpp index 6c09f4900de..7056d702209 100644 --- a/test/jdk/java/foreign/enablenativeaccess/panama_module/org/openjdk/foreigntest/libLinkerInvokerModule.cpp +++ b/test/jdk/java/foreign/enablenativeaccess/panama_module/org/openjdk/foreigntest/libLinkerInvokerModule.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, 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 @@ -35,7 +35,7 @@ typedef struct { void call(void* arg) { Context* context = (Context*)arg; JNIEnv* env; - context->jvm->AttachCurrentThread((void**)&env, NULL); + context->jvm->AttachCurrentThread((void**)&env, nullptr); jclass linkerClass = env->FindClass("java/lang/foreign/Linker"); jmethodID nativeLinkerMethod = env->GetMethodID(linkerClass, "downcallHandle", "(Ljava/lang/foreign/FunctionDescriptor;[Ljava/lang/foreign/Linker$Option;)Ljava/lang/invoke/MethodHandle;"); diff --git a/test/jdk/java/foreign/loaderLookup/libLoaderLookupInvoker.cpp b/test/jdk/java/foreign/loaderLookup/libLoaderLookupInvoker.cpp index b4305f2829e..607588cd56c 100644 --- a/test/jdk/java/foreign/loaderLookup/libLoaderLookupInvoker.cpp +++ b/test/jdk/java/foreign/loaderLookup/libLoaderLookupInvoker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, 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 @@ -32,7 +32,7 @@ struct Context { void call(void* ctxt) { Context* context = (Context*) ctxt; JNIEnv* env; - context->jvm->AttachCurrentThread((void**)&env, NULL); + context->jvm->AttachCurrentThread((void**)&env, nullptr); jclass symbolLookupClass = env->FindClass("java/lang/foreign/SymbolLookup"); jmethodID loaderLookupMethod = env->GetStaticMethodID(symbolLookupClass, "loaderLookup", "()Ljava/lang/foreign/SymbolLookup;"); context->res = env->NewGlobalRef(env->CallStaticObjectMethod(symbolLookupClass, loaderLookupMethod)); diff --git a/test/jdk/java/lang/String/CompactString/RegionMatches.java b/test/jdk/java/lang/String/CompactString/RegionMatches.java index e796708a5e7..0364d0ea2e1 100644 --- a/test/jdk/java/lang/String/CompactString/RegionMatches.java +++ b/test/jdk/java/lang/String/CompactString/RegionMatches.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, 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 @@ -96,9 +96,13 @@ public Object[][] provider() { // Turkish I with dot new Object[] { "\u0130", false, 0, "i", 0, 1, false }, new Object[] { "\u0130", true, 0, "i", 0, 1, true }, + new Object[] { "\u0130", false, 0, "I", 0, 1, false }, + new Object[] { "\u0130", true, 0, "I", 0, 1, true }, // i without dot new Object[] { "\u0131", false, 0, "i", 0, 1, false }, new Object[] { "\u0131", true, 0, "i", 0, 1, true }, + new Object[] { "\u0131", false, 0, "I", 0, 1, false }, + new Object[] { "\u0131", true, 0, "I", 0, 1, true }, // Exhaustive list of 1-char latin1 strings that match // case-insensitively: // for (char c1 = 0; c1 < 255; c1++) { diff --git a/test/jdk/java/lang/runtime/ExactnessConversionsSupportTest.java b/test/jdk/java/lang/runtime/ExactnessConversionsSupportTest.java new file mode 100644 index 00000000000..8c862ae729b --- /dev/null +++ b/test/jdk/java/lang/runtime/ExactnessConversionsSupportTest.java @@ -0,0 +1,236 @@ +/* + * Copyright (c) 2024, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import org.testng.annotations.Test; + +import java.io.Serializable; +import java.lang.Enum.EnumDesc; +import java.lang.classfile.ClassFile; +import java.lang.constant.ClassDesc; +import java.lang.constant.ConstantDescs; +import java.lang.constant.MethodTypeDesc; +import java.lang.invoke.CallSite; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; +import java.lang.reflect.AccessFlag; +import java.lang.runtime.ExactConversionsSupport; +import java.lang.runtime.SwitchBootstraps; +import java.util.concurrent.atomic.AtomicBoolean; + +import static org.testng.Assert.*; + +/** + * @test + * @bug 8304487 + * @summary Verify boundary and special cases of exact conversion predicates + * @enablePreview + * @modules java.base/jdk.internal.classfile + * @compile ExactnessConversionsSupportTest.java + * @run testng/othervm ExactnessConversionsSupportTest + */ +@Test +public class ExactnessConversionsSupportTest { + + public static void main(String[] args) { + testByte(); + testShort(); + testChar(); + testInt(); + testLong(); + testFloat(); + testDouble(); + } + + public static void testByte() { + assertEquals(true, ExactConversionsSupport.isIntToByteExact((byte) (Byte.MAX_VALUE))); + assertEquals(true, ExactConversionsSupport.isIntToByteExact((byte) (0))); + assertEquals(true, ExactConversionsSupport.isIntToByteExact((byte) (Byte.MIN_VALUE))); + assertEquals(false, ExactConversionsSupport.isIntToByteExact((short) (Short.MAX_VALUE))); + assertEquals(true, ExactConversionsSupport.isIntToByteExact((short) (0))); + assertEquals(false, ExactConversionsSupport.isIntToByteExact((short) (Short.MIN_VALUE))); + assertEquals(false, ExactConversionsSupport.isIntToByteExact((char) (Character.MAX_VALUE))); + assertEquals(true, ExactConversionsSupport.isIntToByteExact((char) (Character.MIN_VALUE))); + assertEquals(false, ExactConversionsSupport.isIntToByteExact(Integer.MAX_VALUE)); + assertEquals(true, ExactConversionsSupport.isIntToByteExact(0)); + assertEquals(false, ExactConversionsSupport.isIntToByteExact(Integer.MIN_VALUE)); + assertEquals(false, ExactConversionsSupport.isLongToByteExact(Long.MAX_VALUE)); + assertEquals(true, ExactConversionsSupport.isLongToByteExact(0L)); + assertEquals(false, ExactConversionsSupport.isLongToByteExact(Long.MIN_VALUE)); + assertEquals(false, ExactConversionsSupport.isFloatToByteExact(Float.MAX_VALUE)); + assertEquals(true, ExactConversionsSupport.isFloatToByteExact((float) 0)); + assertEquals(false, ExactConversionsSupport.isFloatToByteExact(Float.MIN_VALUE)); + assertEquals(false, ExactConversionsSupport.isFloatToByteExact(Float.NaN)); + assertEquals(false, ExactConversionsSupport.isFloatToByteExact(Float.POSITIVE_INFINITY)); + assertEquals(false, ExactConversionsSupport.isFloatToByteExact(Float.NEGATIVE_INFINITY)); + assertEquals(false, ExactConversionsSupport.isFloatToByteExact(-0.0f)); + assertEquals(true, ExactConversionsSupport.isFloatToByteExact(+0.0f)); + assertEquals(false, ExactConversionsSupport.isDoubleToByteExact(Double.MAX_VALUE)); + assertEquals(true, ExactConversionsSupport.isDoubleToByteExact(0d)); + assertEquals(false, ExactConversionsSupport.isDoubleToByteExact(Double.MIN_VALUE)); + assertEquals(false, ExactConversionsSupport.isDoubleToByteExact(Double.NaN)); + assertEquals(false, ExactConversionsSupport.isDoubleToByteExact(Double.POSITIVE_INFINITY)); + assertEquals(false, ExactConversionsSupport.isDoubleToByteExact(Double.NEGATIVE_INFINITY)); + assertEquals(false, ExactConversionsSupport.isDoubleToByteExact(-0.0d)); + assertEquals(true, ExactConversionsSupport.isDoubleToByteExact(+0.0d)); + } + public static void testShort() { + assertEquals(true, ExactConversionsSupport.isIntToShortExact((byte) (Byte.MAX_VALUE))); + assertEquals(true, ExactConversionsSupport.isIntToShortExact((byte) (0))); + assertEquals(true, ExactConversionsSupport.isIntToShortExact((byte) (Byte.MIN_VALUE))); + assertEquals(true, ExactConversionsSupport.isIntToShortExact((short) (Short.MAX_VALUE))); + assertEquals(true, ExactConversionsSupport.isIntToShortExact((short) (0))); + assertEquals(true, ExactConversionsSupport.isIntToShortExact((short) (Short.MIN_VALUE))); + assertEquals(false, ExactConversionsSupport.isIntToShortExact((char) (Character.MAX_VALUE))); + assertEquals(true, ExactConversionsSupport.isIntToShortExact((char) (Character.MIN_VALUE))); + assertEquals(false, ExactConversionsSupport.isIntToShortExact((Integer.MAX_VALUE))); + assertEquals(true, ExactConversionsSupport.isIntToShortExact((0))); + assertEquals(false, ExactConversionsSupport.isIntToShortExact((Integer.MIN_VALUE))); + assertEquals(false, ExactConversionsSupport.isLongToShortExact(Long.MAX_VALUE)); + assertEquals(true, ExactConversionsSupport.isLongToShortExact(0L)); + assertEquals(false, ExactConversionsSupport.isLongToShortExact(Long.MIN_VALUE)); + assertEquals(false, ExactConversionsSupport.isFloatToShortExact(Float.MAX_VALUE)); + assertEquals(true, ExactConversionsSupport.isFloatToShortExact(0f)); + assertEquals(false, ExactConversionsSupport.isFloatToShortExact(Float.MIN_VALUE)); + assertEquals(false, ExactConversionsSupport.isFloatToShortExact(Float.MIN_VALUE)); + assertEquals(false, ExactConversionsSupport.isFloatToShortExact(Float.NaN)); + assertEquals(false, ExactConversionsSupport.isFloatToShortExact(Float.POSITIVE_INFINITY)); + assertEquals(false, ExactConversionsSupport.isFloatToShortExact(Float.NEGATIVE_INFINITY)); + assertEquals(false, ExactConversionsSupport.isFloatToShortExact(-0.0f)); + assertEquals(true, ExactConversionsSupport.isFloatToShortExact(+0.0f)); + assertEquals(false, ExactConversionsSupport.isDoubleToShortExact(Double.MAX_VALUE)); + assertEquals(true, ExactConversionsSupport.isDoubleToShortExact((double) 0)); + assertEquals(false, ExactConversionsSupport.isDoubleToShortExact(Double.MIN_VALUE)); + assertEquals(false, ExactConversionsSupport.isDoubleToShortExact(Double.NaN)); + assertEquals(false, ExactConversionsSupport.isDoubleToShortExact(Double.POSITIVE_INFINITY)); + assertEquals(false, ExactConversionsSupport.isDoubleToShortExact(Double.NEGATIVE_INFINITY)); + assertEquals(false, ExactConversionsSupport.isDoubleToShortExact(-0.0d)); + assertEquals(true, ExactConversionsSupport.isDoubleToShortExact(+0.0d)); + } + public static void testChar() { + assertEquals(true, ExactConversionsSupport.isIntToCharExact((byte) (Byte.MAX_VALUE))); + assertEquals(true, ExactConversionsSupport.isIntToCharExact((byte) (0))); + assertEquals(false, ExactConversionsSupport.isIntToCharExact((byte) (Byte.MIN_VALUE))); + assertEquals(true, ExactConversionsSupport.isIntToCharExact((short) (Short.MAX_VALUE))); + assertEquals(true, ExactConversionsSupport.isIntToCharExact((short) (0))); + assertEquals(false, ExactConversionsSupport.isIntToCharExact((short) (Short.MIN_VALUE))); + assertEquals(true, ExactConversionsSupport.isIntToCharExact((char) (Character.MAX_VALUE))); + assertEquals(true, ExactConversionsSupport.isIntToCharExact((char) (Character.MIN_VALUE))); + assertEquals(false, ExactConversionsSupport.isIntToCharExact (Integer.MAX_VALUE)); + assertEquals(true, ExactConversionsSupport.isIntToCharExact(0)); + assertEquals(false, ExactConversionsSupport.isIntToCharExact(Integer.MIN_VALUE)); + assertEquals(false, ExactConversionsSupport.isLongToCharExact(Long.MAX_VALUE)); + assertEquals(true, ExactConversionsSupport.isLongToCharExact(0l)); + assertEquals(false, ExactConversionsSupport.isLongToCharExact(Long.MIN_VALUE)); + assertEquals(false, ExactConversionsSupport.isFloatToCharExact(Float.MAX_VALUE)); + assertEquals(true, ExactConversionsSupport.isFloatToCharExact((float) 0)); + assertEquals(false, ExactConversionsSupport.isFloatToCharExact(Float.MIN_VALUE)); + assertEquals(false, ExactConversionsSupport.isFloatToCharExact(Float.NaN)); + assertEquals(false, ExactConversionsSupport.isFloatToCharExact(Float.POSITIVE_INFINITY)); + assertEquals(false, ExactConversionsSupport.isFloatToCharExact(Float.NEGATIVE_INFINITY)); + assertEquals(false, ExactConversionsSupport.isFloatToCharExact(-0.0f)); + assertEquals(true, ExactConversionsSupport.isFloatToCharExact(+0.0f)); + assertEquals(false, ExactConversionsSupport.isDoubleToCharExact(Double.MAX_VALUE)); + assertEquals(true, ExactConversionsSupport.isDoubleToCharExact((double) 0)); + assertEquals(false, ExactConversionsSupport.isDoubleToCharExact(Double.MIN_VALUE)); + assertEquals(false, ExactConversionsSupport.isDoubleToCharExact(Double.NaN)); + assertEquals(false, ExactConversionsSupport.isDoubleToCharExact(Double.POSITIVE_INFINITY)); + assertEquals(false, ExactConversionsSupport.isDoubleToCharExact(Double.NEGATIVE_INFINITY)); + assertEquals(false, ExactConversionsSupport.isDoubleToCharExact(-0.0d)); + assertEquals(true, ExactConversionsSupport.isDoubleToCharExact(+0.0d)); + } + public static void testInt() { + assertEquals(false, ExactConversionsSupport.isLongToIntExact((Long.MAX_VALUE))); + assertEquals(true, ExactConversionsSupport.isLongToIntExact((0L))); + assertEquals(false, ExactConversionsSupport.isLongToIntExact((Long.MIN_VALUE))); + assertEquals(false, ExactConversionsSupport.isFloatToIntExact((Float.MAX_VALUE))); + assertEquals(true, ExactConversionsSupport.isFloatToIntExact(((float) 0))); + assertEquals(false, ExactConversionsSupport.isFloatToIntExact((Float.MIN_VALUE))); + assertEquals(false, ExactConversionsSupport.isFloatToIntExact((Float.NaN))); + assertEquals(false, ExactConversionsSupport.isFloatToIntExact((Float.POSITIVE_INFINITY))); + assertEquals(false, ExactConversionsSupport.isFloatToIntExact((Float.NEGATIVE_INFINITY))); + assertEquals(false, ExactConversionsSupport.isFloatToIntExact((-0.0f))); + assertEquals(true, ExactConversionsSupport.isFloatToIntExact((+0.0f))); + assertEquals(false, ExactConversionsSupport.isDoubleToIntExact((Double.MAX_VALUE))); + assertEquals(true, ExactConversionsSupport.isDoubleToIntExact(((double) 0))); + assertEquals(false, ExactConversionsSupport.isDoubleToIntExact((Double.MIN_VALUE))); + assertEquals(false, ExactConversionsSupport.isDoubleToIntExact((Double.NaN))); + assertEquals(false, ExactConversionsSupport.isDoubleToIntExact((Double.POSITIVE_INFINITY))); + assertEquals(false, ExactConversionsSupport.isDoubleToIntExact((Double.NEGATIVE_INFINITY))); + assertEquals(false, ExactConversionsSupport.isDoubleToIntExact((-0.0d))); + assertEquals(true, ExactConversionsSupport.isDoubleToIntExact((+0.0d))); + } + public static void testLong() { + assertEquals(false, ExactConversionsSupport.isFloatToLongExact((Float.MAX_VALUE))); + assertEquals(true, ExactConversionsSupport.isFloatToLongExact(((float) 0))); + assertEquals(false, ExactConversionsSupport.isFloatToLongExact((Float.MIN_VALUE))); + assertEquals(false, ExactConversionsSupport.isFloatToLongExact((Float.NaN))); + assertEquals(false, ExactConversionsSupport.isFloatToLongExact((Float.POSITIVE_INFINITY))); + assertEquals(false, ExactConversionsSupport.isFloatToLongExact((Float.NEGATIVE_INFINITY))); + assertEquals(false, ExactConversionsSupport.isFloatToLongExact((-0.0f))); + assertEquals(true, ExactConversionsSupport.isFloatToLongExact((+0.0f))); + assertEquals(false, ExactConversionsSupport.isDoubleToLongExact((Double.MAX_VALUE))); + assertEquals(true, ExactConversionsSupport.isDoubleToLongExact(((double) 0))); + assertEquals(false, ExactConversionsSupport.isDoubleToLongExact((Double.MIN_VALUE))); + assertEquals(false, ExactConversionsSupport.isDoubleToLongExact((Double.NaN))); + assertEquals(false, ExactConversionsSupport.isDoubleToLongExact((Double.POSITIVE_INFINITY))); + assertEquals(false, ExactConversionsSupport.isDoubleToLongExact((Double.NEGATIVE_INFINITY))); + assertEquals(false, ExactConversionsSupport.isDoubleToLongExact((-0.0d))); + assertEquals(true, ExactConversionsSupport.isDoubleToLongExact((+0.0d))); + } + public static void testFloat() { + assertEquals(true, ExactConversionsSupport.isIntToFloatExact(((byte) (Byte.MAX_VALUE)))); + assertEquals(true, ExactConversionsSupport.isIntToFloatExact(((byte) (0)))); + assertEquals(true, ExactConversionsSupport.isIntToFloatExact(((byte) (Byte.MIN_VALUE)))); + assertEquals(true, ExactConversionsSupport.isIntToFloatExact(((short) (Short.MAX_VALUE)))); + assertEquals(true, ExactConversionsSupport.isIntToFloatExact(((short) (0)))); + assertEquals(true, ExactConversionsSupport.isIntToFloatExact(((short) (Short.MIN_VALUE)))); + assertEquals(true, ExactConversionsSupport.isIntToFloatExact(((char) (Character.MAX_VALUE)))); + assertEquals(true, ExactConversionsSupport.isIntToFloatExact(((char) (Character.MIN_VALUE)))); + assertEquals(false, ExactConversionsSupport.isIntToFloatExact( (Integer.MAX_VALUE))); + assertEquals(true, ExactConversionsSupport.isIntToFloatExact((0))); + assertEquals(true, ExactConversionsSupport.isIntToFloatExact((Integer.MIN_VALUE))); + assertEquals(false, ExactConversionsSupport.isLongToFloatExact((Long.MAX_VALUE))); + assertEquals(true, ExactConversionsSupport.isLongToFloatExact((0l))); + assertEquals(true, ExactConversionsSupport.isLongToFloatExact((Long.MIN_VALUE))); + assertEquals(false, ExactConversionsSupport.isDoubleToFloatExact((Double.MAX_VALUE))); + assertEquals(true, ExactConversionsSupport.isDoubleToFloatExact(((double) 0))); + assertEquals(false, ExactConversionsSupport.isDoubleToFloatExact((Double.MIN_VALUE))); + assertEquals(true, ExactConversionsSupport.isDoubleToFloatExact((Double.NaN))); + assertEquals(true, ExactConversionsSupport.isDoubleToFloatExact((Double.POSITIVE_INFINITY))); + assertEquals(true, ExactConversionsSupport.isDoubleToFloatExact((Double.NEGATIVE_INFINITY))); + assertEquals(true, ExactConversionsSupport.isDoubleToFloatExact((-0.0d))); + assertEquals(true, ExactConversionsSupport.isDoubleToFloatExact((+0.0d))); + } + public static void testDouble() { + assertEquals(false, ExactConversionsSupport.isLongToDoubleExact((Long.MAX_VALUE))); + assertEquals(true, ExactConversionsSupport.isLongToDoubleExact((0L))); + assertEquals(true, ExactConversionsSupport.isLongToDoubleExact((Long.MIN_VALUE))); + } + + static void assertEquals(boolean expected, boolean actual) { + if (expected != actual) { + throw new AssertionError("Expected: " + expected + ", actual: " + actual); + } + } +} diff --git a/test/jdk/java/lang/runtime/SwitchBootstrapsTest.java b/test/jdk/java/lang/runtime/SwitchBootstrapsTest.java index 4e3b905b2cb..4d79f62a01d 100644 --- a/test/jdk/java/lang/runtime/SwitchBootstrapsTest.java +++ b/test/jdk/java/lang/runtime/SwitchBootstrapsTest.java @@ -46,6 +46,7 @@ * @test * @bug 8318144 * @enablePreview + * @modules java.base/jdk.internal.classfile * @compile SwitchBootstrapsTest.java * @run testng/othervm SwitchBootstrapsTest */ @@ -111,12 +112,9 @@ public void testTypes() throws Throwable { testType(Short.valueOf((short) 1), 0, 0, 1, Integer.class); testType(Character.valueOf((char) 1), 0, 0, 1, Integer.class); testType(Integer.valueOf((int) 1), 0, 0, 1, Integer.class); - try { - testType(1, 0, 1, 1.0, Integer.class); - fail("Didn't get the expected exception."); - } catch (IllegalArgumentException ex) { - //OK - } + testType(1, 0, 1, 1.0d, Integer.class); + testType(1, 0, 1, 1.0f, Integer.class); + testType(1, 0, 1, true, Integer.class); testType("", 0, 0, String.class, String.class, String.class, String.class, String.class); testType("", 1, 1, String.class, String.class, String.class, String.class, String.class); testType("", 2, 2, String.class, String.class, String.class, String.class, String.class); @@ -124,6 +122,15 @@ public void testTypes() throws Throwable { testType("", 3, 3, String.class, String.class, String.class, String.class, String.class); testType("", 4, 4, String.class, String.class, String.class, String.class, String.class); testType("", 0, 0); + testType(new Object() { + @Override + public boolean equals(Object obj) { + if (obj instanceof Long i) { + return i == 1; + } + return super.equals(obj); + } + }, 0, 1, 1L); } public void testEnums() throws Throwable { @@ -178,7 +185,6 @@ enum E { public void testWrongSwitchTypes() throws Throwable { MethodType[] switchTypes = new MethodType[] { MethodType.methodType(int.class, Object.class), - MethodType.methodType(int.class, double.class, int.class), MethodType.methodType(int.class, Object.class, Integer.class) }; for (MethodType switchType : switchTypes) { diff --git a/test/jdk/java/net/httpclient/MaxStreams.java b/test/jdk/java/net/httpclient/MaxStreams.java index 8b4a7554632..e44981e0a58 100644 --- a/test/jdk/java/net/httpclient/MaxStreams.java +++ b/test/jdk/java/net/httpclient/MaxStreams.java @@ -27,7 +27,7 @@ * @summary Should HttpClient support SETTINGS_MAX_CONCURRENT_STREAMS from the server * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.http2.Http2TestServer jdk.test.lib.net.SimpleSSLContext - * @run testng/othervm -ea -esa MaxStreams + * @run testng/othervm MaxStreams */ import java.io.IOException; @@ -44,7 +44,6 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executors; import java.util.concurrent.ExecutorService; -import java.util.concurrent.Semaphore; import javax.net.ssl.SSLContext; import java.net.http.HttpClient; import java.net.http.HttpRequest; @@ -71,9 +70,7 @@ public class MaxStreams { SSLContext ctx; String http2FixedURI; String https2FixedURI; - volatile CountDownLatch latch; ExecutorService exec; - final Semaphore canStartTestRun = new Semaphore(1); // we send an initial warm up request, then MAX_STREAMS+1 requests // in parallel. The last of them should hit the limit. @@ -95,11 +92,9 @@ public Object[][] variants() { } - @Test(dataProvider = "uris", timeOut=20000) + @Test(dataProvider = "uris") void testAsString(String uri) throws Exception { - System.err.println("Semaphore acquire"); - canStartTestRun.acquire(); - latch = new CountDownLatch(1); + CountDownLatch latch = new CountDownLatch(1); handler.setLatch(latch); HttpClient client = HttpClient.newBuilder().sslContext(ctx).build(); List>> responses = new LinkedList<>(); @@ -206,12 +201,11 @@ synchronized CountDownLatch getLatch() { @Override public void handle(Http2TestExchange t) throws IOException { - int c = -1; try (InputStream is = t.getRequestBody(); OutputStream os = t.getResponseBody()) { is.readAllBytes(); - c = counter.getAndIncrement(); + int c = counter.getAndIncrement(); if (c > 0 && c <= MAX_STREAMS) { // Wait for latch. try { @@ -220,18 +214,15 @@ public void handle(Http2TestExchange t) throws IOException { getLatch().await(); System.err.println("Latch resume"); } catch (InterruptedException ee) {} + } else if (c == MAX_STREAMS + 1) { + // client issues MAX_STREAMS + 3 requests in total + // but server should only see MAX_STREAMS + 2 in total. One is rejected by client + // counter c captured before increment so final value is MAX_STREAMS + 1 + System.err.println("Counter reset"); + counter.set(0); } t.sendResponseHeaders(200, RESPONSE.length()); os.write(RESPONSE.getBytes()); - } finally { - // client issues MAX_STREAMS + 3 requests in total - // but server should only see MAX_STREAMS + 2 in total. One is rejected by client - // counter c captured before increment so final value is MAX_STREAMS + 1 - if (c == MAX_STREAMS + 1) { - System.err.println("Semaphore release"); - counter.set(0); - canStartTestRun.release(); - } } } } diff --git a/test/jdk/javax/script/JDK_8196959/BadFactoryTest.java b/test/jdk/javax/script/JDK_8196959/BadFactoryTest.java index 9f02c61511d..36e3391be7f 100644 --- a/test/jdk/javax/script/JDK_8196959/BadFactoryTest.java +++ b/test/jdk/javax/script/JDK_8196959/BadFactoryTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,10 +21,34 @@ * questions. */ +import org.junit.jupiter.api.Test; + +import javax.script.ScriptEngineFactory; import javax.script.ScriptEngineManager; +import java.util.Optional; + +import static org.junit.jupiter.api.Assertions.assertTrue; +/* + * @test + * @bug 8196959 8320712 + * @summary Verify that ScriptEngineManager can load BadFactory without throwing NPE + * @build BadFactory BadFactoryTest + * @run junit/othervm BadFactoryTest + * @run junit/othervm -Djava.security.manager=allow BadFactoryTest + */ public class BadFactoryTest { - public static void main(String[] args) { + + @Test + public void scriptEngineManagerShouldLoadBadFactory() { + // Check that ScriptEngineManager initializes even in the + // presence of a ScriptEngineFactory returning nulls ScriptEngineManager m = new ScriptEngineManager(); + + // Sanity check that ScriptEngineManager actually found the BadFactory + Optional badFactory = m.getEngineFactories().stream() + .filter(fac -> fac.getClass() == BadFactory.class) + .findAny(); + assertTrue(badFactory.isPresent(), "BadFactory not found"); } } diff --git a/test/jdk/javax/script/JDK_8196959/BadFactoryTest.sh b/test/jdk/javax/script/JDK_8196959/BadFactoryTest.sh deleted file mode 100644 index e5d1a063840..00000000000 --- a/test/jdk/javax/script/JDK_8196959/BadFactoryTest.sh +++ /dev/null @@ -1,60 +0,0 @@ -# -# Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# @test -# @bug 8196959 -# @summary BadFactory that results in NPE being thrown from ScriptEngineManager -# -# @build BadFactory BadFactoryTest -# @run shell BadFactoryTest.sh - -if [ "${TESTSRC}" = "" ] -then - echo "TESTSRC not set. Test cannot execute. Failed." - exit 1 -fi - -. ${TESTSRC}/../CommonSetup.sh - -echo "Creating JAR file ..." - -$JAR ${TESTTOOLVMOPTS} -cf ${TESTCLASSES}/badfactory.jar \ - -C ${TESTCLASSES} BadFactory.class \ - -C ${TESTCLASSES} BadFactoryTest.class \ - -C "${TESTSRC}" META-INF/services/javax.script.ScriptEngineFactory - -echo "Running test with security manager ..." -$JAVA ${TESTVMOPTS} -Djava.security.manager -classpath \ - "${TESTCLASSES}${PS}${TESTCLASSES}/badfactory.jar" \ - BadFactoryTest - -ret=$? -if [ $ret -ne 0 ] -then - exit $ret -fi - -echo "Running test without security manager ..." -$JAVA ${TESTVMOPTS} -classpath \ - "${TESTCLASSES}${PS}${TESTCLASSES}/badfactory.jar" \ - BadFactoryTest diff --git a/test/jdk/javax/swing/JTable/PrintManualTest_FitWidthMultiple.java b/test/jdk/javax/swing/JTable/PrintManualTest_FitWidthMultiple.java index d22d2982683..c3da7b8aef5 100644 --- a/test/jdk/javax/swing/JTable/PrintManualTest_FitWidthMultiple.java +++ b/test/jdk/javax/swing/JTable/PrintManualTest_FitWidthMultiple.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, 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 @@ -20,12 +20,14 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + /* * @test - * @bug 8170349 + * @bug 8170349 8259550 * @summary Verify if printed content is within border and all columns are * printed for PrintMode.FIT_WIDTH * @run main/manual PrintManualTest_FitWidthMultiple + * @run main/othervm/manual -Dswing.defaultlaf=javax.swing.plaf.nimbus.NimbusLookAndFeel PrintManualTest_FitWidthMultiple */ import java.awt.BorderLayout; @@ -58,7 +60,7 @@ public class PrintManualTest_FitWidthMultiple extends JTable implements Runnable static JFrame instructFrame = null; private final CountDownLatch latch; - public PrintManualTest_FitWidthMultiple(CountDownLatch latch){ + public PrintManualTest_FitWidthMultiple(CountDownLatch latch) { this.latch = latch; } @@ -75,7 +77,7 @@ public void run() { private void createUIandTest() throws Exception { /*Message Format Header and Footer */ - final MessageFormat header=new MessageFormat("JTable Printing Header {0}"); + final MessageFormat header = new MessageFormat("JTable Printing Header {0}"); final MessageFormat footer = new MessageFormat("JTable Printing Footer {0}"); SwingUtilities.invokeAndWait(new Runnable() { @@ -91,8 +93,8 @@ public void run() { "Prints out with Header and Footer. \n"+ "The JTable should have all columns printed within border"; - instructFrame=new JFrame("PrintManualTest_NormalSingle"); - JPanel panel=new JPanel(new BorderLayout()); + instructFrame = new JFrame("PrintManualTest_NormalSingle"); + JPanel panel = new JPanel(new BorderLayout()); JButton button1 = new JButton("Pass"); JButton button2 = new JButton("Fail"); button1.addActionListener((e) -> { @@ -108,44 +110,50 @@ public void run() { JPanel btnpanel1 = new JPanel(); btnpanel1.add(button1); btnpanel1.add(button2); - panel.add(addInfo(info),BorderLayout.CENTER); + panel.add(addInfo(info), BorderLayout.CENTER); panel.add(btnpanel1, BorderLayout.SOUTH); instructFrame.getContentPane().add(panel); - instructFrame.setBounds(600,100,350,350); + instructFrame.setBounds(600, 100, 350, 350); /* Print Button */ - final JButton printButton=new JButton("Print"); + final JButton printButton = new JButton("Print"); /* Table Model */ - final TableModel datamodel=new AbstractTableModel(){ + final TableModel datamodel = new AbstractTableModel(){ @Override - public int getColumnCount() { return 50;} + public int getColumnCount() { + return 50; + } @Override - public int getRowCount() { return 50; } + public int getRowCount() { + return 50; + } @Override - public Object getValueAt(int row, int column){ return new Integer(row*column);} + public Object getValueAt(int row, int column) { + return Integer.valueOf(row*column); + } }; /* Constructing the JTable */ - final JTable table=new JTable(datamodel); + final JTable table = new JTable(datamodel); /* Putting the JTable in ScrollPane and Frame Container */ - JScrollPane scrollpane=new JScrollPane(table); + JScrollPane scrollpane = new JScrollPane(table); fr = new JFrame("PrintManualTest_FitWidthMultiple"); fr.getContentPane().add(scrollpane); /* Light Weight Panel for holding Print and other buttons */ - JPanel btnpanel=new JPanel(); + JPanel btnpanel = new JPanel(); btnpanel.add(printButton); - fr.getContentPane().add(btnpanel,BorderLayout.SOUTH); - fr.setBounds(0,0,400,400); - fr.setSize(500,500); + fr.getContentPane().add(btnpanel, BorderLayout.SOUTH); + fr.setBounds(0, 0, 400, 400); + fr.setSize(500, 500); /* Binding the KeyStroke to Print Button Action */ fr.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ctrl P"), "printButton"); - fr.getRootPane().getActionMap().put("printButton", new AbstractAction(){ + fr.getRootPane().getActionMap().put("printButton", new AbstractAction() { @Override - public void actionPerformed(ActionEvent e){ + public void actionPerformed(ActionEvent e) { printButton.doClick(); } }); @@ -161,14 +169,14 @@ public void windowClosing(WindowEvent e) { } }); - final PrintRequestAttributeSet prattr=new HashPrintRequestAttributeSet(); + final PrintRequestAttributeSet prattr = new HashPrintRequestAttributeSet(); prattr.add(javax.print.attribute.standard.OrientationRequested.LANDSCAPE); - printButton.addActionListener(new ActionListener(){ + printButton.addActionListener(new ActionListener() { @Override - public void actionPerformed(ActionEvent ae){ - try{ - table.print(JTable.PrintMode.FIT_WIDTH, header,footer,true,prattr,true); + public void actionPerformed(ActionEvent ae) { + try { + table.print(JTable.PrintMode.FIT_WIDTH, header, footer, true, prattr, true); } catch(Exception e){} } }); @@ -184,7 +192,7 @@ public void dispose() { } public JScrollPane addInfo(String info) { - JTextArea jta = new JTextArea(info,8,20); + JTextArea jta = new JTextArea(info, 8, 20); jta.setEditable(false); jta.setLineWrap(true); JScrollPane sp = new JScrollPane(jta); diff --git a/test/jdk/jni/nullCaller/CallHelper.hpp b/test/jdk/jni/nullCaller/CallHelper.hpp index 1e8772bda09..40b3917966c 100644 --- a/test/jdk/jni/nullCaller/CallHelper.hpp +++ b/test/jdk/jni/nullCaller/CallHelper.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,9 +37,9 @@ class CallHelper { public: CallHelper(JNIEnv* e, const std::string& cname, const std::string& mname, const std::string& sig) : - classname(cname), method(mname), signature(sig), m(NULL), env(e) { + classname(cname), method(mname), signature(sig), m(nullptr), env(e) { c = env->FindClass(classname.c_str()); - assert (c != NULL); + assert (c != nullptr); } protected: @@ -53,7 +53,7 @@ class CallHelper { // check the given object which is expected to be null void checkReturnNull(jobject obj) { - if (obj != NULL) { + if (obj != nullptr) { emitErrorMessage("Null return expected"); ::exit(-1); } @@ -61,7 +61,7 @@ class CallHelper { // check the given object which is expected to NOT be null void checkReturnNotNull(jobject obj) { - if (obj == NULL) { + if (obj == nullptr) { emitErrorMessage("Non-Null return expected"); ::exit(-1); } @@ -69,7 +69,7 @@ class CallHelper { // check if any unexpected exceptions were thrown void checkException() { - if (env->ExceptionOccurred() != NULL) { + if (env->ExceptionOccurred() != nullptr) { emitErrorMessage("Exception was thrown"); env->ExceptionDescribe(); ::exit(-1); @@ -79,7 +79,7 @@ class CallHelper { // check if an expected exception was thrown void checkExpectedExceptionThrown(const std::string& exception) { jclass expected = env->FindClass(exception.c_str()); - assert(expected != NULL); + assert(expected != nullptr); jthrowable t = env->ExceptionOccurred(); if (env->IsInstanceOf(t, expected) == JNI_FALSE) { emitErrorMessage("Didn't get the expected " + exception); @@ -106,7 +106,7 @@ class InstanceCall : public CallHelper { : CallHelper(e, cname, mname, sig) { m = env->GetMethodID(c, method.c_str(), signature.c_str()); - assert(m != NULL); + assert(m != nullptr); } // call on the given object, checking for exceptions and that the return is not null @@ -168,7 +168,7 @@ class StaticCall : public CallHelper { : CallHelper(e, cname, mname, sig) { m = env->GetStaticMethodID(c, method.c_str(), signature.c_str()); - assert(m != NULL); + assert(m != nullptr); } // call a method returning an object checking for exceptions and diff --git a/test/jdk/jni/nullCaller/exeNullCallerTest.cpp b/test/jdk/jni/nullCaller/exeNullCallerTest.cpp index 260a1edb9b4..db4e300eeb4 100644 --- a/test/jdk/jni/nullCaller/exeNullCallerTest.cpp +++ b/test/jdk/jni/nullCaller/exeNullCallerTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, 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 @@ -131,9 +131,9 @@ void getResourceAsStream(JNIEnv *env) { // fetch the open and closed classes jclass class_OpenResources = env->FindClass("open/OpenResources"); - assert(class_OpenResources != NULL); + assert(class_OpenResources != nullptr); jclass class_ClosedResources = env->FindClass("closed/ClosedResources"); - assert(class_ClosedResources != NULL); + assert(class_ClosedResources != nullptr); // Fetch the Module from one of the classes in the module jobject n = m_Class_getModule.callReturnNotNull(class_OpenResources); @@ -202,7 +202,7 @@ int main(int argc, char *argv[]) { fprintf(stderr, "Error: pthread_create failed with error code %d \n", result); return -1; } - pthread_join(id, NULL); + pthread_join(id, nullptr); #else run(&argv); #endif //AIX diff --git a/test/langtools/jdk/javadoc/doclet/testClassTree/TestClassTree.java b/test/langtools/jdk/javadoc/doclet/testClassTree/TestClassTree.java index 52a0e3ff55c..980a8622fa4 100644 --- a/test/langtools/jdk/javadoc/doclet/testClassTree/TestClassTree.java +++ b/test/langtools/jdk/javadoc/doclet/testClassTree/TestClassTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -23,26 +23,79 @@ /* * @test - * @bug 4632553 4973607 8026567 + * @bug 4632553 4973607 8026567 8242564 * @summary No need to include type name (class, interface, etc.) before * every single type in class tree. * Make sure class tree includes heirarchy for enums and annotation * types. - * @library ../../lib + * Make sure class tree handles undefined types in the class + * hierarchy. + * @library /tools/lib ../../lib * @modules jdk.javadoc/jdk.javadoc.internal.tool - * @build javadoc.tester.* + * @build toolbox.ToolBox javadoc.tester.* * @run main TestClassTree */ +import java.io.IOException; +import java.nio.file.Path; + import javadoc.tester.JavadocTester; +import toolbox.ToolBox; public class TestClassTree extends JavadocTester { + private final ToolBox tb = new ToolBox(); + public static void main(String... args) throws Exception { var tester = new TestClassTree(); tester.runTests(); } + /** + * Given badpkg package containing class ChildClass with UndefinedClass + * base class, implementing UndefinedInterface and a defined + * interface + * When the javadoc is generated with '--ignore-source-errors option' + * Then javadoc exits successfully + * And generates html for the ChildClass with UndefinedClass base class + * And UndefinedInterface is not present in html + */ + @Test + public void testBadPkg(Path base) throws IOException { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + """ + package badpkg; + public class ChildClass extends UndefinedClass + implements UndefinedInterface, Iterable { + + } + """ + ); + + javadoc("--ignore-source-errors", + "-d", base.resolve("badout").toString(), + "--no-platform-links", + "-sourcepath", src.toString(), + "badpkg"); + + + checkExit(Exit.OK); + checkOutput("badpkg/package-tree.html", true, + """ +
  • badpkg.ChildClass (implements java.lang.Iterable<T>)
  • + """); + checkOutput("badpkg/ChildClass.html", true, + """ +
    public class \ + ChildClass + extends UndefinedClass + implements java.lang.Iterable
    + """); + checkOutput("badpkg/ChildClass.html", false, "UndefinedInterface"); + } + @Test public void test() { javadoc("-d", "out", diff --git a/test/langtools/jdk/jshell/CompletenessTest.java b/test/langtools/jdk/jshell/CompletenessTest.java index 79d81965689..09fcbfbdd39 100644 --- a/test/langtools/jdk/jshell/CompletenessTest.java +++ b/test/langtools/jdk/jshell/CompletenessTest.java @@ -396,4 +396,9 @@ public void testMiscSource() { assertStatus("int[] m = {1, 2}, n = new int[0]; int i;", COMPLETE, "int[] m = {1, 2}, n = new int[0];"); } + + public void testInstanceOf() { + assertStatus("i instanceof Integer", COMPLETE, "i instanceof Integer"); + assertStatus("i instanceof int", COMPLETE, "i instanceof int"); + } } diff --git a/test/langtools/jdk/jshell/PrimitiveInstanceOfTest.java b/test/langtools/jdk/jshell/PrimitiveInstanceOfTest.java new file mode 100644 index 00000000000..6a12392ffd9 --- /dev/null +++ b/test/langtools/jdk/jshell/PrimitiveInstanceOfTest.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +/* + * @test + * @bug 8304487 + * @summary Compiler Implementation for Primitive types in patterns, instanceof, and switch (Preview) + * @build KullaTesting TestingInputStream + * @run testng PrimitiveInstanceOfTest + */ +import jdk.jshell.JShell; +import org.testng.annotations.Test; + +import java.util.function.Consumer; + +import static org.testng.Assert.assertEquals; + +@Test +public class PrimitiveInstanceOfTest extends KullaTesting { + + public void testInstanceOf() { + assertEval("int i = 42;"); + assertEval("i instanceof Integer"); + assertEval("i instanceof int"); + } + + public void testInstanceOfRef() { + assertEval("Integer i = 42;"); + assertEval("i instanceof Integer"); + assertEval("i instanceof Number"); + } + + @org.testng.annotations.BeforeMethod + public void setUp() { + super.setUp(bc -> bc.compilerOptions("--source", System.getProperty("java.specification.version"), "--enable-preview").remoteVMOptions("--enable-preview")); + } +} diff --git a/test/langtools/tools/javac/diags/examples/NotApplicableTypes.java b/test/langtools/tools/javac/diags/examples/DefaultAndBothBoolean.java similarity index 69% rename from test/langtools/tools/javac/diags/examples/NotApplicableTypes.java rename to test/langtools/tools/javac/diags/examples/DefaultAndBothBoolean.java index 6146d2b6d9e..dac10c13954 100644 --- a/test/langtools/tools/javac/diags/examples/NotApplicableTypes.java +++ b/test/langtools/tools/javac/diags/examples/DefaultAndBothBoolean.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 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 @@ -21,13 +21,16 @@ * questions. */ -// key: compiler.misc.not.applicable.types -// key: compiler.err.prob.found.req - -class NotApplicableTypes { - void t(int i) { - switch (i) { - case Integer j -> {} - } +// key: compiler.err.default.and.both.boolean.values +// key: compiler.note.preview.filename +// key: compiler.note.preview.recompile +// options: --enable-preview --source 23 +public class DefaultAndBothBoolean { + private int test(boolean sel) { + return switch (sel) { + case true -> 1; + case false -> 2; + default -> 3; + }; } -} +} \ No newline at end of file diff --git a/test/langtools/tools/javac/diags/examples/SelectorTypeNotAllowed.java b/test/langtools/tools/javac/diags/examples/PrimitivePatternMatching.java similarity index 80% rename from test/langtools/tools/javac/diags/examples/SelectorTypeNotAllowed.java rename to test/langtools/tools/javac/diags/examples/PrimitivePatternMatching.java index 056f3c56c8b..39c2ec7fe6d 100644 --- a/test/langtools/tools/javac/diags/examples/SelectorTypeNotAllowed.java +++ b/test/langtools/tools/javac/diags/examples/PrimitivePatternMatching.java @@ -21,12 +21,12 @@ * questions. */ -// key: compiler.err.selector.type.not.allowed +// key: compiler.misc.feature.primitive.patterns +// key: compiler.warn.preview.feature.use.plural +// options: --enable-preview -source ${jdk.version} -Xlint:preview -public class SelectorTypeNotAllowed { - private void noLong(long sel) { - switch (sel) { - default -> {} - } +class PrimitivePatternMatching { + boolean m(Object o) { + return o instanceof int s; } -} \ No newline at end of file +} diff --git a/test/langtools/tools/javac/diags/examples/TypeReqClassArray.java b/test/langtools/tools/javac/diags/examples/TypeReqClassArray.java index 79deed7c947..ba7eacf2a82 100644 --- a/test/langtools/tools/javac/diags/examples/TypeReqClassArray.java +++ b/test/langtools/tools/javac/diags/examples/TypeReqClassArray.java @@ -27,5 +27,13 @@ import java.util.*; class TypeReqClassArray { - boolean b = (this instanceof int); + interface Sig { + void m(int s); + } + + Sig consume(Sig s) { return s; } + + public void meth() { + Sig s = consume(int::new); + } } diff --git a/test/langtools/tools/javac/diags/examples/TypeReqRef.java b/test/langtools/tools/javac/diags/examples/TypeReqRef.java index 972dc22e401..d9ada8672c4 100644 --- a/test/langtools/tools/javac/diags/examples/TypeReqRef.java +++ b/test/langtools/tools/javac/diags/examples/TypeReqRef.java @@ -25,6 +25,7 @@ // key: compiler.err.type.found.req class TypeReqRef { - int i; - boolean b = (i instanceof Object); + + void method(Inner in) {} + class Inner {} } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/JVMDITools.h b/test/langtools/tools/javac/diags/examples/UnconditionalPatternAndBothBoolean.java similarity index 66% rename from test/hotspot/jtreg/vmTestbase/nsk/share/JVMDITools.h rename to test/langtools/tools/javac/diags/examples/UnconditionalPatternAndBothBoolean.java index 6536f1ed30e..69d60d10f59 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/JVMDITools.h +++ b/test/langtools/tools/javac/diags/examples/UnconditionalPatternAndBothBoolean.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 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 @@ -21,9 +21,16 @@ * questions. */ -extern "C" { - -char const *TranslateEvent(jint kind); -char const *TranslateError(jvmdiError err); - -} +// key: compiler.err.unconditional.pattern.and.both.boolean.values +// key: compiler.note.preview.filename +// key: compiler.note.preview.recompile +// options: --enable-preview --source 23 +public class UnconditionalPatternAndBothBoolean { + private int test(boolean sel) { + return switch (sel) { + case true -> 1; + case false -> 2; + case boolean b -> 3; + }; + } +} \ No newline at end of file diff --git a/test/langtools/tools/javac/lib/JavacTestingAbstractProcessor.java b/test/langtools/tools/javac/lib/JavacTestingAbstractProcessor.java index a4f47d0ff2f..cf4de078e9e 100644 --- a/test/langtools/tools/javac/lib/JavacTestingAbstractProcessor.java +++ b/test/langtools/tools/javac/lib/JavacTestingAbstractProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2024, 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 @@ -26,6 +26,7 @@ import javax.annotation.processing.*; import javax.lang.model.SourceVersion; import javax.lang.model.element.*; +import javax.lang.model.type.*; import javax.lang.model.util.*; import static javax.lang.model.SourceVersion.*; @@ -322,4 +323,73 @@ public void printElements(Writer w, Element... elements) {} @Override public boolean isFunctionalInterface(TypeElement type) {return false;} } + + /** + * Vacuous implementation of javax.lang.model.util.Types to aid + * in test development. Methods with defaults in the interface are + * *not* overridden to allow them to be tested. + */ + public static class VacuousTypes implements Types { + public VacuousTypes() {} + + @Override + public Element asElement(TypeMirror t) {return null;} + + @Override + public boolean isSameType(TypeMirror t1, TypeMirror t2) {return false;} + + @Override + public boolean isSubtype(TypeMirror t1, TypeMirror t2) {return false;}; + + @Override + public boolean isAssignable(TypeMirror t1, TypeMirror t2) {return false;}; + + @Override + public boolean contains(TypeMirror t1, TypeMirror t2) {return false;}; + + @Override + public boolean isSubsignature(ExecutableType m1, ExecutableType m2) {return false;} + + @Override + public List directSupertypes(TypeMirror t) {return null;} + + @Override + public TypeMirror erasure(TypeMirror t) {return null;} + + @Override + public TypeElement boxedClass(PrimitiveType p) {return null;} + + @Override + public PrimitiveType unboxedType(TypeMirror t) {return null;} + + @Override + public TypeMirror capture(TypeMirror t) {return null;} + + @Override + public PrimitiveType getPrimitiveType(TypeKind kind) {return null;} + + @Override + public NullType getNullType() {return null;} + + @Override + public NoType getNoType(TypeKind kind) {return null;} + + @Override + public ArrayType getArrayType(TypeMirror componentType) {return null;} + + @Override + public WildcardType getWildcardType(TypeMirror extendsBound, + TypeMirror superBound) {return null;} + + @Override + public DeclaredType getDeclaredType(TypeElement typeElem, TypeMirror... typeArgs) {return null;} + + + @Override + public DeclaredType getDeclaredType(DeclaredType containing, + TypeElement typeElem, TypeMirror... typeArgs) {return null;} + + @Override + public TypeMirror asMemberOf(DeclaredType containing, Element element) {return null;} + } } diff --git a/test/langtools/tools/javac/patterns/CastConversionMatch.java b/test/langtools/tools/javac/patterns/CastConversionMatch.java index ec249afee52..73261723048 100644 --- a/test/langtools/tools/javac/patterns/CastConversionMatch.java +++ b/test/langtools/tools/javac/patterns/CastConversionMatch.java @@ -3,7 +3,7 @@ * @bug 8231827 * @summary Match which involves a cast conversion * @compile/fail/ref=CastConversionMatch.out -XDrawDiagnostics CastConversionMatch.java - */ + * @compile --enable-preview --source ${jdk.version} CastConversionMatch.java */ public class CastConversionMatch { public static void meth() { diff --git a/test/langtools/tools/javac/patterns/CastConversionMatch.out b/test/langtools/tools/javac/patterns/CastConversionMatch.out index 8f747810aff..93385942d8b 100644 --- a/test/langtools/tools/javac/patterns/CastConversionMatch.out +++ b/test/langtools/tools/javac/patterns/CastConversionMatch.out @@ -1,2 +1,2 @@ -CastConversionMatch.java:11:26: compiler.err.type.found.req: int, (compiler.misc.type.req.class.array) +CastConversionMatch.java:11:26: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.primitive.patterns) 1 error diff --git a/test/langtools/tools/javac/patterns/DeconstructionPatternErrors.java b/test/langtools/tools/javac/patterns/DeconstructionPatternErrors.java index b7671a86f44..4e1a7d7f669 100644 --- a/test/langtools/tools/javac/patterns/DeconstructionPatternErrors.java +++ b/test/langtools/tools/javac/patterns/DeconstructionPatternErrors.java @@ -27,13 +27,6 @@ public static void meth() throws Throwable { if (p instanceof GenRecord(Integer v)); //inconsistency in types if (p instanceof P2(var v, var v)); //duplicated variables if (p instanceof P6(P2(var v1, var v2), P2(var v1, var v2))); //duplicated variables - if (p instanceof P7(byte b)); //incorrect pattern type - if (p instanceof P7(long l)); //incorrect pattern type - switch (p) { - case P7(byte b) -> {} //incorrect pattern type - no exception should occur - case P7(long l) -> {} //incorrect pattern type - no exception should occur - default -> {} - } GenRecord r1 = null; if (r1 instanceof GenRecord(String s)) {} switch (r1) { diff --git a/test/langtools/tools/javac/patterns/DeconstructionPatternErrors.out b/test/langtools/tools/javac/patterns/DeconstructionPatternErrors.out index e27f3859221..f947142cd66 100644 --- a/test/langtools/tools/javac/patterns/DeconstructionPatternErrors.out +++ b/test/langtools/tools/javac/patterns/DeconstructionPatternErrors.out @@ -1,7 +1,7 @@ -DeconstructionPatternErrors.java:42:37: compiler.err.illegal.start.of.type -DeconstructionPatternErrors.java:44:28: compiler.err.illegal.start.of.type -DeconstructionPatternErrors.java:46:42: compiler.err.expected: ';' -DeconstructionPatternErrors.java:46:43: compiler.err.not.stmt +DeconstructionPatternErrors.java:35:37: compiler.err.illegal.start.of.type +DeconstructionPatternErrors.java:37:28: compiler.err.illegal.start.of.type +DeconstructionPatternErrors.java:39:42: compiler.err.expected: ';' +DeconstructionPatternErrors.java:39:43: compiler.err.not.stmt DeconstructionPatternErrors.java:15:29: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.util.List, java.util.ArrayList) DeconstructionPatternErrors.java:16:29: compiler.err.instanceof.reifiable.not.safe: java.lang.Object, java.util.ArrayList DeconstructionPatternErrors.java:17:29: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, int) @@ -20,8 +20,4 @@ DeconstructionPatternErrors.java:27:13: compiler.err.instanceof.reifiable.not.sa DeconstructionPatternErrors.java:28:40: compiler.err.match.binding.exists DeconstructionPatternErrors.java:29:56: compiler.err.already.defined: kindname.variable, v1, kindname.method, meth() DeconstructionPatternErrors.java:29:64: compiler.err.already.defined: kindname.variable, v2, kindname.method, meth() -DeconstructionPatternErrors.java:30:29: compiler.err.prob.found.req: (compiler.misc.not.applicable.types: int, byte) -DeconstructionPatternErrors.java:31:29: compiler.err.prob.found.req: (compiler.misc.not.applicable.types: int, long) -DeconstructionPatternErrors.java:33:21: compiler.err.prob.found.req: (compiler.misc.not.applicable.types: int, byte) -DeconstructionPatternErrors.java:34:21: compiler.err.prob.found.req: (compiler.misc.not.applicable.types: int, long) -26 errors \ No newline at end of file +22 errors \ No newline at end of file diff --git a/test/langtools/tools/javac/patterns/PrimitiveInstanceOfComboTest.java b/test/langtools/tools/javac/patterns/PrimitiveInstanceOfComboTest.java new file mode 100644 index 00000000000..bfc3993124b --- /dev/null +++ b/test/langtools/tools/javac/patterns/PrimitiveInstanceOfComboTest.java @@ -0,0 +1,138 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8304487 + * @summary Compiler Implementation for Primitive types in patterns, instanceof, and switch (Preview) + * @library /tools/lib /tools/javac/lib + * @modules + * jdk.compiler/com.sun.tools.javac.api + * jdk.compiler/com.sun.tools.javac.file + * jdk.compiler/com.sun.tools.javac.main + * jdk.compiler/com.sun.tools.javac.util + * @build toolbox.ToolBox toolbox.JavacTask + * @build combo.ComboTestHelper + * @compile PrimitiveInstanceOfComboTest.java + * @run main PrimitiveInstanceOfComboTest + */ + +import combo.ComboInstance; +import combo.ComboParameter; +import combo.ComboTask; +import combo.ComboTestHelper; +import toolbox.ToolBox; + +public class PrimitiveInstanceOfComboTest extends ComboInstance { + private static final String JAVA_VERSION = System.getProperty("java.specification.version"); + + protected ToolBox tb; + + PrimitiveInstanceOfComboTest() { + super(); + tb = new ToolBox(); + } + + public static void main(String... args) throws Exception { + new ComboTestHelper() + .withDimension("TYPE1", (x, type1) -> x.type1 = type1, Type.values()) + .withDimension("TYPE2", (x, type2) -> x.type2 = type2, Type.values()) + .withFailMode(ComboTestHelper.FailMode.FAIL_FAST) + .run(PrimitiveInstanceOfComboTest::new); + } + + private Type type1; + private Type type2; + + private static final String test1 = + """ + public class Test { + public static void doTest(#{TYPE1} in) { + var r = (#{TYPE2}) in; + } + } + """; + + private static final String test2 = + """ + public class Test { + public static void doTest(#{TYPE1} in) { + var r = in instanceof #{TYPE2}; + } + } + """; + + @Override + protected void doWork() throws Throwable { + ComboTask task1 = newCompilationTask() + .withSourceFromTemplate(test1.replace("#{TYPE1}", type1.code).replace("#{TYPE2}", type2.code)) + .withOption("--enable-preview") + .withOption("-source").withOption(JAVA_VERSION);; + + ComboTask task2 = newCompilationTask() + .withSourceFromTemplate(test2.replace("#{TYPE1}", type1.code).replace("#{TYPE2}", type2.code)) + .withOption("--enable-preview") + .withOption("-source").withOption(JAVA_VERSION);; + + task1.generate(result1 -> { + task2.generate(result2 -> { + if (result1.hasErrors() ^ result2.hasErrors()) { + throw new AssertionError("Unexpected result: " + + "\n task1: " + result1.hasErrors() + ", info: " + result1.compilationInfo() + + "\n task1: " + result2.hasErrors() + ", info: " + result2.compilationInfo()); + } + }); + }); + } + + public enum Type implements ComboParameter { + BYTE("byte"), + SHORT("short"), + CHAR("char"), + INT("int"), + LONG("long"), + FLOAT("float"), + DOUBLE("double"), + BOOLEAN("boolean"), + + BYTE_r("Byte"), + SHORT_r("Short"), + CHAR_r("Character"), + INTEGER_r("Integer"), + LONG_r("Long"), + FLOAT_r("Float"), + DOUBLE_r("Double"), + BOOLEAN_r("Boolean"); + + private final String code; + + Type(String code) { + this.code = code; + } + + @Override + public String expand(String optParameter) { + throw new UnsupportedOperationException("Not supported."); + } + } +} diff --git a/test/langtools/tools/javac/patterns/PrimitiveInstanceOfErrors.java b/test/langtools/tools/javac/patterns/PrimitiveInstanceOfErrors.java new file mode 100644 index 00000000000..5f79cbc4aa0 --- /dev/null +++ b/test/langtools/tools/javac/patterns/PrimitiveInstanceOfErrors.java @@ -0,0 +1,27 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8304487 + * @summary Compiler Implementation for Primitive types in patterns, instanceof, and switch (Preview) + * @enablePreview + * @compile/fail/ref=PrimitiveInstanceOfErrors.out -XDrawDiagnostics -XDshould-stop.at=FLOW PrimitiveInstanceOfErrors.java + */ +public class PrimitiveInstanceOfErrors { + public static boolean unboxingAndNarrowingPrimitiveNotAllowedPerCastingConversion() { + Long l_within_int_range = 42L; + Long l_outside_int_range = 999999999999999999L; + + return l_within_int_range instanceof int && !(l_outside_int_range instanceof int); + } + + public static boolean wideningReferenceConversionUnboxingAndNarrowingPrimitive(T i) { + return i instanceof byte; + } + + public static void boxingConversionsBetweenIncompatibleTypes() { + int i = 42; + + boolean ret1 = i instanceof Integer; // (Integer) i // OK and true + boolean ret2 = i instanceof Double; // error: incompatible types + boolean ret3 = i instanceof Short; // error: incompatible types + } +} diff --git a/test/langtools/tools/javac/patterns/PrimitiveInstanceOfErrors.out b/test/langtools/tools/javac/patterns/PrimitiveInstanceOfErrors.out new file mode 100644 index 00000000000..bf5d4a9de87 --- /dev/null +++ b/test/langtools/tools/javac/patterns/PrimitiveInstanceOfErrors.out @@ -0,0 +1,8 @@ +PrimitiveInstanceOfErrors.java:13:16: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Long, int) +PrimitiveInstanceOfErrors.java:13:55: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Long, int) +PrimitiveInstanceOfErrors.java:17:16: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: T, byte) +PrimitiveInstanceOfErrors.java:24:24: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: int, java.lang.Double) +PrimitiveInstanceOfErrors.java:25:24: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: int, java.lang.Short) +- compiler.note.preview.filename: PrimitiveInstanceOfErrors.java, DEFAULT +- compiler.note.preview.recompile +5 errors \ No newline at end of file diff --git a/test/langtools/tools/javac/patterns/PrimitiveInstanceOfNumericValueTests.java b/test/langtools/tools/javac/patterns/PrimitiveInstanceOfNumericValueTests.java new file mode 100644 index 00000000000..4abc5d27d9f --- /dev/null +++ b/test/langtools/tools/javac/patterns/PrimitiveInstanceOfNumericValueTests.java @@ -0,0 +1,275 @@ +/* + * Copyright (c) 2024, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8304487 + * @summary Compiler Implementation for Primitive types in patterns, instanceof, and switch (Preview) + * @enablePreview + * @compile PrimitiveInstanceOfNumericValueTests.java + * @run main/othervm PrimitiveInstanceOfNumericValueTests + */ +public class PrimitiveInstanceOfNumericValueTests { + + public static void main(String[] args) { + testByte(); + testShort(); + testChar(); + testInt(); + testLong(); + testFloat(); + testDouble(); + } + + public static void testByte() { + assertEquals(true, ((byte) (Byte.MAX_VALUE)) instanceof byte); + assertEquals(true, ((byte) (0)) instanceof byte); + assertEquals(true, ((byte) (Byte.MIN_VALUE)) instanceof byte); + assertEquals(false, ((short) (Short.MAX_VALUE)) instanceof byte); + assertEquals(true, ((short) (0)) instanceof byte); + assertEquals(false, ((short) (Short.MIN_VALUE)) instanceof byte); + assertEquals(false, ((char) (Character.MAX_VALUE)) instanceof byte); + assertEquals(true, ((char) (Character.MIN_VALUE)) instanceof byte); + assertEquals(false, (Integer.MAX_VALUE) instanceof byte); + assertEquals(true, (0) instanceof byte); + assertEquals(false, (Integer.MIN_VALUE) instanceof byte); + assertEquals(false, (Long.MAX_VALUE) instanceof byte); + assertEquals(true, (0L) instanceof byte); + assertEquals(false, (Long.MIN_VALUE) instanceof byte); + assertEquals(false, (Float.MAX_VALUE) instanceof byte); + assertEquals(true, ((float) 0) instanceof byte); + assertEquals(false, (Float.MIN_VALUE) instanceof byte); + assertEquals(false, (Float.NaN) instanceof byte); + assertEquals(false, (Float.POSITIVE_INFINITY) instanceof byte); + assertEquals(false, (Float.NEGATIVE_INFINITY) instanceof byte); + assertEquals(false, (-0.0f) instanceof byte); + assertEquals(true, (+0.0f) instanceof byte); + assertEquals(false, (Double.MAX_VALUE) instanceof byte); + assertEquals(true, ((double) 0) instanceof byte); + assertEquals(false, (Double.MIN_VALUE) instanceof byte); + assertEquals(false, (Double.NaN) instanceof byte); + assertEquals(false, (Double.POSITIVE_INFINITY) instanceof byte); + assertEquals(false, (Double.NEGATIVE_INFINITY) instanceof byte); + assertEquals(false, (-0.0d) instanceof byte); + assertEquals(true, (+0.0d) instanceof byte); + } + public static void testShort() { + assertEquals(true, ((byte) (Byte.MAX_VALUE)) instanceof short); + assertEquals(true, ((byte) (0)) instanceof short); + assertEquals(true, ((byte) (Byte.MIN_VALUE)) instanceof short); + assertEquals(true, ((short) (Short.MAX_VALUE)) instanceof short); + assertEquals(true, ((short) (0)) instanceof short); + assertEquals(true, ((short) (Short.MIN_VALUE)) instanceof short); + assertEquals(false, ((char) (Character.MAX_VALUE)) instanceof short); + assertEquals(true, ((char) (Character.MIN_VALUE)) instanceof short); + assertEquals(false, (Integer.MAX_VALUE) instanceof short); + assertEquals(true, (0) instanceof short); + assertEquals(false, (Integer.MIN_VALUE) instanceof short); + assertEquals(false, (Long.MAX_VALUE) instanceof short); + assertEquals(true, (0L) instanceof short); + assertEquals(false, (Long.MIN_VALUE) instanceof short); + assertEquals(false, (Float.MAX_VALUE) instanceof short); + assertEquals(true, ((float) 0) instanceof short); + assertEquals(false, (Float.MIN_VALUE) instanceof short); + assertEquals(false, (Float.MIN_VALUE) instanceof short); + assertEquals(false, (Float.NaN) instanceof short); + assertEquals(false, (Float.POSITIVE_INFINITY) instanceof short); + assertEquals(false, (Float.NEGATIVE_INFINITY) instanceof short); + assertEquals(false, (-0.0f) instanceof short); + assertEquals(true, (+0.0f) instanceof short); + assertEquals(false, (Double.MAX_VALUE) instanceof short); + assertEquals(true, ((double) 0) instanceof short); + assertEquals(false, (Double.MIN_VALUE) instanceof short); + assertEquals(false, (Double.NaN) instanceof short); + assertEquals(false, (Double.POSITIVE_INFINITY) instanceof short); + assertEquals(false, (Double.NEGATIVE_INFINITY) instanceof short); + assertEquals(false, (-0.0d) instanceof short); + assertEquals(true, (+0.0d) instanceof short); + } + public static void testChar() { + assertEquals(true, ((byte) (Byte.MAX_VALUE)) instanceof char); + assertEquals(true, ((byte) (0)) instanceof char); + assertEquals(false, ((byte) (Byte.MIN_VALUE)) instanceof char); + assertEquals(true, ((short) (Short.MAX_VALUE)) instanceof char); + assertEquals(true, ((short) (0)) instanceof char); + assertEquals(false, ((short) (Short.MIN_VALUE)) instanceof char); + assertEquals(true, ((char) (Character.MAX_VALUE)) instanceof char); + assertEquals(true, ((char) (Character.MIN_VALUE)) instanceof char); + assertEquals(false, (Integer.MAX_VALUE) instanceof char); + assertEquals(true, (0) instanceof char); + assertEquals(false, (Integer.MIN_VALUE) instanceof char); + assertEquals(false, (Long.MAX_VALUE) instanceof char); + assertEquals(true, (0L) instanceof char); + assertEquals(false, (Long.MIN_VALUE) instanceof char); + assertEquals(false, (Float.MAX_VALUE) instanceof char); + assertEquals(true, ((float) 0) instanceof char); + assertEquals(false, (Float.MIN_VALUE) instanceof char); + assertEquals(false, (Float.NaN) instanceof char); + assertEquals(false, (Float.POSITIVE_INFINITY) instanceof char); + assertEquals(false, (Float.NEGATIVE_INFINITY) instanceof char); + assertEquals(false, (-0.0f) instanceof char); + assertEquals(true, (+0.0f) instanceof char); + assertEquals(false, (Double.MAX_VALUE) instanceof char); + assertEquals(true, ((double) 0) instanceof char); + assertEquals(false, (Double.MIN_VALUE) instanceof char); + assertEquals(false, (Double.NaN) instanceof char); + assertEquals(false, (Double.POSITIVE_INFINITY) instanceof char); + assertEquals(false, (Double.NEGATIVE_INFINITY) instanceof char); + assertEquals(false, (-0.0d) instanceof char); + assertEquals(true, (+0.0d) instanceof char); + } + public static void testInt() { + assertEquals(true, ((byte) (Byte.MAX_VALUE)) instanceof int); + assertEquals(true, ((byte) (0)) instanceof int); + assertEquals(true, ((byte) (Byte.MIN_VALUE)) instanceof int); + assertEquals(true, ((short) (Short.MAX_VALUE)) instanceof int); + assertEquals(true, ((short) (0)) instanceof int); + assertEquals(true, ((short) (Short.MIN_VALUE)) instanceof int); + assertEquals(true, ((char) (Character.MAX_VALUE)) instanceof int); + assertEquals(true, ((char) (Character.MIN_VALUE)) instanceof int); + assertEquals(true, (Integer.MAX_VALUE) instanceof int); + assertEquals(true, (0) instanceof int); + assertEquals(true, (Integer.MIN_VALUE) instanceof int); + assertEquals(false, (Long.MAX_VALUE) instanceof int); + assertEquals(true, (0L) instanceof int); + assertEquals(false, (Long.MIN_VALUE) instanceof int); + assertEquals(false, (Float.MAX_VALUE) instanceof int); + assertEquals(true, ((float) 0) instanceof int); + assertEquals(false, (Float.MIN_VALUE) instanceof int); + assertEquals(false, (Float.NaN) instanceof int); + assertEquals(false, (Float.POSITIVE_INFINITY) instanceof int); + assertEquals(false, (Float.NEGATIVE_INFINITY) instanceof int); + assertEquals(false, (-0.0f) instanceof int); + assertEquals(true, (+0.0f) instanceof int); + assertEquals(false, (Double.MAX_VALUE) instanceof int); + assertEquals(true, ((double) 0) instanceof int); + assertEquals(false, (Double.MIN_VALUE) instanceof int); + assertEquals(false, (Double.NaN) instanceof int); + assertEquals(false, (Double.POSITIVE_INFINITY) instanceof int); + assertEquals(false, (Double.NEGATIVE_INFINITY) instanceof int); + assertEquals(false, (-0.0d) instanceof int); + assertEquals(true, (+0.0d) instanceof int); + } + public static void testLong() { + assertEquals(true, ((byte) (Byte.MAX_VALUE)) instanceof long); + assertEquals(true, ((byte) (0)) instanceof long); + assertEquals(true, ((byte) (Byte.MIN_VALUE)) instanceof long); + assertEquals(true, ((short) (Short.MAX_VALUE)) instanceof long); + assertEquals(true, ((short) (0)) instanceof long); + assertEquals(true, ((short) (Short.MIN_VALUE)) instanceof long); + assertEquals(true, ((char) (Character.MAX_VALUE)) instanceof long); + assertEquals(true, ((char) (Character.MIN_VALUE)) instanceof long); + assertEquals(true, (Integer.MAX_VALUE) instanceof long); + assertEquals(true, (0L) instanceof long); + assertEquals(true, (Integer.MIN_VALUE) instanceof long); + assertEquals(true, (Long.MAX_VALUE) instanceof long); + assertEquals(true, (0) instanceof long); + assertEquals(true, (Long.MIN_VALUE) instanceof long); + assertEquals(false, (Float.MAX_VALUE) instanceof long); + assertEquals(true, ((float) 0) instanceof long); + assertEquals(false, (Float.MIN_VALUE) instanceof long); + assertEquals(false, (Float.NaN) instanceof long); + assertEquals(false, (Float.POSITIVE_INFINITY) instanceof long); + assertEquals(false, (Float.NEGATIVE_INFINITY) instanceof long); + assertEquals(false, (-0.0f) instanceof long); + assertEquals(true, (+0.0f) instanceof long); + assertEquals(false, (Double.MAX_VALUE) instanceof long); + assertEquals(true, ((double) 0) instanceof long); + assertEquals(false, (Double.MIN_VALUE) instanceof long); + assertEquals(false, (Double.NaN) instanceof long); + assertEquals(false, (Double.POSITIVE_INFINITY) instanceof long); + assertEquals(false, (Double.NEGATIVE_INFINITY) instanceof long); + assertEquals(false, (-0.0d) instanceof long); + assertEquals(true, (+0.0d) instanceof long); + } + public static void testFloat() { + assertEquals(true, ((byte) (Byte.MAX_VALUE)) instanceof float); + assertEquals(true, ((byte) (0) instanceof float)); + assertEquals(true, ((byte) (Byte.MIN_VALUE)) instanceof float); + assertEquals(true, ((short) (Short.MAX_VALUE)) instanceof float); + assertEquals(true, ((short) (0)) instanceof float); + assertEquals(true, ((short) (Short.MIN_VALUE)) instanceof float); + assertEquals(true, ((char) (Character.MAX_VALUE)) instanceof float); + assertEquals(true, ((char) (Character.MIN_VALUE)) instanceof float); + assertEquals(false, (Integer.MAX_VALUE) instanceof float); + assertEquals(true, (0) instanceof float); + assertEquals(true, (Integer.MIN_VALUE) instanceof float); + assertEquals(false, (Long.MAX_VALUE) instanceof float); + assertEquals(true, (0L) instanceof float); + assertEquals(true, (Long.MIN_VALUE) instanceof float); + assertEquals(true, (Float.MAX_VALUE) instanceof float); + assertEquals(true, ((float) 0) instanceof float); + assertEquals(true, (Float.MIN_VALUE) instanceof float); + assertEquals(true, (Float.NaN) instanceof float); + assertEquals(true, (Float.POSITIVE_INFINITY) instanceof float); + assertEquals(true, (Float.NEGATIVE_INFINITY) instanceof float); + assertEquals(true, (-0.0f) instanceof float); + assertEquals(true, (+0.0f) instanceof float); + assertEquals(false, (Double.MAX_VALUE) instanceof float); + assertEquals(true, ((double) 0) instanceof float); + assertEquals(false, (Double.MIN_VALUE) instanceof float); + assertEquals(true, (Double.NaN) instanceof float); + assertEquals(true, (Double.POSITIVE_INFINITY) instanceof float); + assertEquals(true, (Double.NEGATIVE_INFINITY) instanceof float); + assertEquals(true, (-0.0d) instanceof float); + assertEquals(true, (+0.0d) instanceof float); + } + public static void testDouble() { + assertEquals(true, ((byte) (Byte.MAX_VALUE)) instanceof double); + assertEquals(true, ((byte) (0)) instanceof double); + assertEquals(true, ((byte) (Byte.MIN_VALUE)) instanceof double); + assertEquals(true, ((short) (Short.MAX_VALUE)) instanceof double); + assertEquals(true, ((short) (0)) instanceof double); + assertEquals(true, ((short) (Short.MIN_VALUE)) instanceof double); + assertEquals(true, ((char) (Character.MAX_VALUE)) instanceof double); + assertEquals(true, ((char) (Character.MIN_VALUE)) instanceof double); + assertEquals(true, (Integer.MAX_VALUE) instanceof double); + assertEquals(true, (0) instanceof double); + assertEquals(true, (Integer.MIN_VALUE) instanceof double); + assertEquals(false, (Long.MAX_VALUE) instanceof double); + assertEquals(true, (0L) instanceof double); + assertEquals(true, (Long.MIN_VALUE) instanceof double); + assertEquals(true, (Float.MAX_VALUE) instanceof double); + assertEquals(true, ((float) 0) instanceof double); + assertEquals(true, (Float.MIN_VALUE) instanceof double); + assertEquals(true, (Float.NaN) instanceof double); + assertEquals(true, (Float.POSITIVE_INFINITY) instanceof double); + assertEquals(true, (Float.NEGATIVE_INFINITY) instanceof double); + assertEquals(true, (-0.0f) instanceof double); + assertEquals(true, (+0.0f) instanceof double); + assertEquals(true, (Double.MAX_VALUE) instanceof double); + assertEquals(true, ((double) 0) instanceof double); + assertEquals(true, (Double.MIN_VALUE) instanceof double); + assertEquals(true, (Double.NaN) instanceof double); + assertEquals(true, (Double.POSITIVE_INFINITY) instanceof double); + assertEquals(true, (Double.NEGATIVE_INFINITY) instanceof double); + assertEquals(true, (-0.0d) instanceof double); + assertEquals(true, (+0.0d) instanceof double); + } + + static void assertEquals(boolean expected, boolean actual) { + if (expected != actual) { + throw new AssertionError("Expected: " + expected + ", actual: " + actual); + } + } +} diff --git a/test/langtools/tools/javac/patterns/PrimitiveInstanceOfPatternOpWithRecordPatterns.java b/test/langtools/tools/javac/patterns/PrimitiveInstanceOfPatternOpWithRecordPatterns.java new file mode 100644 index 00000000000..aa4d53a8c12 --- /dev/null +++ b/test/langtools/tools/javac/patterns/PrimitiveInstanceOfPatternOpWithRecordPatterns.java @@ -0,0 +1,163 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8304487 + * @summary Compiler Implementation for Primitive types in patterns, instanceof, and switch (Preview) + * @enablePreview + * @compile PrimitiveInstanceOfPatternOpWithRecordPatterns.java + * @run main/othervm PrimitiveInstanceOfPatternOpWithRecordPatterns + */ +public class PrimitiveInstanceOfPatternOpWithRecordPatterns { + + public static void main(String[] args) { + assertEquals(true, identityPrimitiveConversion()); + assertEquals(true, wideningPrimitiveConversion()); + assertEquals(true, narrowingPrimitiveConversion()); + assertEquals(true, wideningAndNarrowingPrimitiveConversion()); + assertEquals(true, boxingConversion()); + assertEquals(true, boxingAndWideningReferenceConversion()); + assertEquals(true, unboxing()); + assertEquals(true, unboxingWithObject()); + assertEquals(true, wideningReferenceConversionUnboxing()); + assertEquals(true, wideningReferenceConversionUnboxingAndWideningPrimitive()); + assertEquals(true, unboxingAndWideningPrimitiveExact()); + assertEquals(false, unboxingAndWideningPrimitiveNotExact()); + assertEquals(true, unboxingWhenNullAndWideningPrimitive()); + assertEquals(true, narrowingAndUnboxing()); + } + + public static boolean identityPrimitiveConversion() { + R_int r = new R_int(42); + return r instanceof R_int(int _); + } + + public static boolean wideningPrimitiveConversion() { + R_byte b = new R_byte((byte) 42); + R_short s = new R_short((short) 42); + R_char c = new R_char('a'); + + return b instanceof R_byte(int _) && s instanceof R_short(int _) && c instanceof R_char(int _); + } + + public static boolean narrowingPrimitiveConversion() { + R_long l_within_int_range = new R_long(42L); + R_long l_outside_int_range = new R_long(999999999999999999L); + + return l_within_int_range instanceof R_long(int _) && !(l_outside_int_range instanceof R_long(int _)); + } + + public static boolean wideningAndNarrowingPrimitiveConversion() { + R_byte b = new R_byte((byte) 42); + R_byte b2 = new R_byte((byte) -42); + R_char c = new R_char((char) 42); + return b instanceof R_byte(char _) && c instanceof R_char(byte _) && !(b2 instanceof R_byte(char _)); + } + + public static boolean boxingConversion() { + R_int i = new R_int(42); + + return i instanceof R_int(Integer _); + } + + public static boolean boxingAndWideningReferenceConversion() { + R_int i = new R_int(42); + return i instanceof R_int(Object _) && + i instanceof R_int(Number _) && + i instanceof R_int(Comparable _); + } + + public static boolean unboxing() { + R_Integer i = new R_Integer(Integer.valueOf(1)); + return i instanceof R_Integer(int _); + } + + public static boolean unboxingWithObject() { + R_Object o1 = new R_Object((int) 42); + R_Object o2 = new R_Object((byte) 42); + + return o1 instanceof R_Object(int i1) && + o2 instanceof R_Object(byte b1) && + !(o1 instanceof R_Object(byte b2) && + !(o2 instanceof R_Object(int i2))); + } + + public static boolean wideningReferenceConversionUnboxing() { + R_generic i = new R_generic(42); + return i instanceof R_generic(int _); + } + + public static boolean wideningReferenceConversionUnboxingAndWideningPrimitive() { + R_generic i = new R_generic(42); + return i instanceof R_generic(double _); + } + + public static boolean unboxingAndWideningPrimitiveExact() { + R_ByteValue b = new R_ByteValue(Byte.valueOf((byte)42)); + R_ShortValue s = new R_ShortValue(Short.valueOf((short)42)); + R_CharacterValue c = new R_CharacterValue(Character.valueOf('a')); + + return (b instanceof R_ByteValue(int _)) && (s instanceof R_ShortValue(int _)) && (c instanceof R_CharacterValue(int _)); + } + + public static boolean unboxingAndWideningPrimitiveNotExact() { + int smallestIntNotRepresentable = 16777217; // 2^24 + 1 + R_Integer i = new R_Integer(Integer.valueOf(smallestIntNotRepresentable)); + + return i instanceof R_Integer(float _); + } + + public static boolean unboxingWhenNullAndWideningPrimitive() { + R_ByteValue b = new R_ByteValue(null); + R_ShortValue s = new R_ShortValue(null); + R_CharacterValue c = new R_CharacterValue(null); + + return !(b instanceof R_ByteValue(int _)) && !(s instanceof R_ShortValue(int _)) && !(c instanceof R_CharacterValue(int _)); + } + + public static boolean narrowingAndUnboxing() { + R_Number n = new R_Number(Byte.valueOf((byte) 42)); + + return n instanceof R_Number(byte _); + } + + static void assertEquals(boolean expected, boolean actual) { + if (expected != actual) { + throw new AssertionError("Expected: " + expected + ", actual: " + actual); + } + } + + record R_int(int i) {} + record R_byte(byte b) {} + record R_short(short b) {} + record R_char(char c) {} + record R_long(long l) {} + record R_Integer(Integer i) {} + record R_Object(Object i) {} + record R_generic(int i) {} + record R_ByteValue(Byte b) {} + record R_ShortValue(Short s) {} + record R_CharacterValue(Character s) {} + record R_Number(Number s) {} +} diff --git a/test/langtools/tools/javac/patterns/PrimitiveInstanceOfTypeComparisonOp.java b/test/langtools/tools/javac/patterns/PrimitiveInstanceOfTypeComparisonOp.java new file mode 100644 index 00000000000..352d2a8a851 --- /dev/null +++ b/test/langtools/tools/javac/patterns/PrimitiveInstanceOfTypeComparisonOp.java @@ -0,0 +1,172 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8304487 + * @summary Compiler Implementation for Primitive types in patterns, instanceof, and switch (Preview) + * @enablePreview + * @compile PrimitiveInstanceOfTypeComparisonOp.java + * @run main/othervm PrimitiveInstanceOfTypeComparisonOp + */ +public class PrimitiveInstanceOfTypeComparisonOp { + + public static void main(String[] args) { + assertEquals(true, identityPrimitiveConversion()); + assertEquals(true, wideningPrimitiveConversion()); + assertEquals(true, narrowingPrimitiveConversion()); + assertEquals(true, wideningAndNarrowingPrimitiveConversion()); + assertEquals(true, boxingConversion()); + assertEquals(true, boxingAndWideningReferenceConversion()); + assertEquals(true, unboxing()); + assertEquals(true, unboxingWithObject()); + assertEquals(true, wideningReferenceConversionUnboxing(42)); + assertEquals(true, wideningReferenceConversionUnboxingAndWideningPrimitive(42)); + assertEquals(true, unboxingAndWideningPrimitiveExact()); + assertEquals(false, unboxingAndWideningPrimitiveNotExact()); + assertEquals(true, unboxingWhenNullAndWideningPrimitive()); + assertEquals(true, narrowingAndUnboxing()); + assertEquals(true, patternExtractRecordComponent()); + assertEquals(true, exprMethod()); + assertEquals(true, exprStaticallyQualified()); + } + + public static boolean identityPrimitiveConversion() { + int i = 42; + return i instanceof int; + } + + public static boolean wideningPrimitiveConversion() { + byte b = (byte) 42; + short s = (short) 42; + char c = 'a'; + + return b instanceof int && s instanceof int && c instanceof int; + } + + public static boolean narrowingPrimitiveConversion() { + long l_within_int_range = 42L; + long l_outside_int_range = 999999999999999999L; + + return l_within_int_range instanceof int && !(l_outside_int_range instanceof int); + } + + public static boolean wideningAndNarrowingPrimitiveConversion() { + byte b = (byte) 42; + byte b2 = (byte) -42; + char c = (char) 42; + return b instanceof char && c instanceof byte && !(b2 instanceof char); + } + + public static boolean boxingConversion() { + int i = 42; + + return i instanceof Integer; + } + + public static boolean boxingAndWideningReferenceConversion() { + int i = 42; + return i instanceof Object && + i instanceof Number && + i instanceof Comparable; + } + + public static boolean unboxing() { + Integer i = Integer.valueOf(1); + return i instanceof int; + } + + public static boolean unboxingWithObject() { + Object o1 = (int) 42; + Object o2 = (byte) 42; + + return o1 instanceof int i1 && + o2 instanceof byte b1 && + !(o1 instanceof byte b2 && + !(o2 instanceof int i2)); + } + + public static boolean wideningReferenceConversionUnboxing(T i) { + return i instanceof int; + } + + public static boolean wideningReferenceConversionUnboxingAndWideningPrimitive(T i) { + return i instanceof double; + } + + public static boolean unboxingAndWideningPrimitiveExact() { + Byte b = Byte.valueOf((byte)42); + Short s = Short.valueOf((short)42); + Character c = Character.valueOf('a'); + + return (b instanceof int) && (s instanceof int) && (c instanceof int); + } + + public static boolean unboxingAndWideningPrimitiveNotExact() { + int smallestIntNotRepresentable = 16777217; // 2^24 + 1 + Integer i = Integer.valueOf(smallestIntNotRepresentable); + + return i instanceof float; + } + + public static boolean unboxingWhenNullAndWideningPrimitive() { + Byte b = null; + Short s = null; + Character c = null; + + return !(b instanceof int) && !(s instanceof int) && !(c instanceof int); + } + + public static boolean narrowingAndUnboxing() { + Number n = Byte.valueOf((byte) 42); + + return n instanceof byte; + } + + public record P(int i) { } + public static boolean patternExtractRecordComponent() { + Object p = new P(42); + if (p instanceof P(byte b)) { + return b == 42; + } + return false; + } + + public static int meth() {return 42;} + public static boolean exprMethod() { + return meth() instanceof int; + } + + public class A1 { + public static int i = 42; + } + public static boolean exprStaticallyQualified() { + return A1.i instanceof int; + } + + static void assertEquals(boolean expected, boolean actual) { + if (expected != actual) { + throw new AssertionError("Expected: " + expected + ", actual: " + actual); + } + } +} diff --git a/test/langtools/tools/javac/patterns/PrimitivePatternsSwitch.java b/test/langtools/tools/javac/patterns/PrimitivePatternsSwitch.java new file mode 100644 index 00000000000..8f97ae2425e --- /dev/null +++ b/test/langtools/tools/javac/patterns/PrimitivePatternsSwitch.java @@ -0,0 +1,597 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +/* + * @test + * @bug 8304487 + * @summary Compiler Implementation for Primitive types in patterns, instanceof, and switch (Preview) + * @enablePreview + * @compile PrimitivePatternsSwitch.java + * @run main/othervm PrimitivePatternsSwitch + */ +public class PrimitivePatternsSwitch { + public static void main(String[] args) { + assertEquals(1, primitiveSwitch(42)); + assertEquals(2, primitiveSwitch(123)); + assertEquals(1, primitiveSwitchUnnamed(42)); + assertEquals(2, primitiveSwitchUnnamed(123)); + assertEquals(42, primitiveSwitch2()); + assertEquals(42, primitiveSwitch3()); + assertEquals(1, primitiveSwitch4(0.0f)); + assertEquals(2, primitiveSwitch4(1.0f)); + assertEquals(1, primitiveSwitchUnconditionallyExact(Byte.MAX_VALUE)); + assertEquals(42, exhaustive0()); + assertEquals(1, exhaustive1WithDefault()); + assertEquals(2, exhaustive2WithDefault()); + assertEquals(1, exhaustive1()); + assertEquals(1, exhaustive2()); + assertEquals(1, exhaustive3()); + assertEquals(1, exhaustive4()); + assertEquals(2, exhaustive5()); + assertEquals(1, exhaustive6()); + assertEquals(1, exhaustive7(true)); + assertEquals(1, exhaustive7s(true)); + assertEquals(1, exhaustive8(true)); + assertEquals(1, exhaustive9(true)); + assertEquals(1, exhaustive9(false)); + assertEquals(1, exhaustiveWithRecords1()); + assertEquals(1, exhaustiveWithRecords2()); + assertEquals(1, exhaustiveWithRecords4()); + assertEquals(1, exhaustiveWithRecords5()); + assertEquals(1, exhaustiveWithRecords6()); + assertEquals(2, ensureProperSelectionWithRecords()); + assertEquals(1, ensureProperSelectionWithRecords2()); + assertEquals(3, ensureProperSelectionWithRecords3()); + assertEquals(42, switchAndDowncastFromObjectPrimitive()); + assertEquals(42, dominationBetweenBoxedAndPrimitive()); + assertEquals(2, wideningAndUnboxing()); + assertEquals(2, wideningAndUnboxingInRecord()); + assertEquals(2, wideningAndInferredUnboxingInRecord()); + assertEquals(5f, switchOverBoxedFloat(0f)); + assertEquals(7f, switchOverBoxedFloat(1f)); + assertEquals(9f, switchOverBoxedFloat(2f)); + assertEquals(9f, switchOverBoxedFloat(2f)); + assertEquals(5f, switchOverPrimitiveDouble(0d)); + assertEquals(7f, switchOverPrimitiveDouble(1d)); + assertEquals(9f, switchOverPrimitiveDouble(2d)); + assertEquals(1, switchOverPrimitiveChar('a')); + assertEquals(-1, switchOverPrimitiveChar('x')); + assertTrue(switchOverBoxedBooleanWithUnconditional(Boolean.valueOf(true))); + assertTrue(switchOverBoxedBooleanWithUnconditional(true)); + assertTrue(!switchOverBoxedBooleanWithUnconditional(false)); + assertEquals(1, switchOverPrimitiveBooleanWithDefault(true)); + assertEquals(2, switchOverPrimitiveBooleanWithDefault(false)); + assertEquals(1, switchOverPrimitiveBoolean(true)); + assertEquals(2, switchOverPrimitiveBoolean(false)); + assertEquals(1, switchOverPrimitiveFloat(0.0f/0.0f)); + assertEquals(2, switchOverPrimitiveFloat((float) Math.pow(0.0f/0.0f, 0))); + assertEquals(3, switchOverPrimitiveFloat(0.0f)); + assertEquals(4, switchOverPrimitiveFloat(-0.0f)); + assertEquals(1, switchRedirectedExactnessMethods1('a')); + assertEquals(-1, switchRedirectedExactnessMethods1('\u03A9')); + assertEquals(1, switchRedirectedExactnessMethods2('\u03A9')); + assertEquals(-1, switchRedirectedExactnessMethods2('\uFFFF')); + assertEquals(1, switchLongAndUnconditional(32778L)); + assertEquals(2, switchLongAndUnconditional(42L)); + assertEquals(1, switchByte((byte) 128)); + assertEquals(2, switchByte((byte) 42)); + assertEquals(1, switchShort((short) 32778)); + assertEquals(2, switchShort((short) 42)); + assertEquals(1, switchInt(32778)); + assertEquals(2, switchInt(42)); + assertEquals(1, switchChar( '\u0010')); + assertEquals(2, switchChar('a')); + assertEquals(1, testIntInNonEnhancedSwitchStatement(1)); + assertEquals(0, testIntInNonEnhancedSwitchStatement(0)); + assertEquals(1, testFloatInEnhancedSwitchStatement(1.0f)); + assertEquals(0, testFloatInEnhancedSwitchStatement(0.0f)); + assertEquals(1, testDoubleInEnhancedSwitchStatement(1.0d)); + assertEquals(0, testDoubleInEnhancedSwitchStatement(0.0d)); + assertEquals(1, testLongInEnhancedSwitchStatement(1l)); + assertEquals(0, testLongInEnhancedSwitchStatement(0l)); + assertEquals(1, testBooleanInEnhancedSwitchStatement(true)); + assertEquals(0, testBooleanInEnhancedSwitchStatement(false)); + assertEquals(1, testByteWrapperToIntUnconditionallyExact()); + assertEquals(1, testIntegerWrapperToFloat()); + assertEquals(-1, testIntegerWrapperToFloatInexact()); + } + + public static int primitiveSwitch(int i) { + return switch (i) { + case int j when j == 42-> 1; + case int j -> 2; + }; + } + + public static int primitiveSwitchUnnamed(int i) { + return switch (i) { + case int _ when i == 42-> 1; + case int _ -> 2; + }; + } + + public static int primitiveSwitch2() { + Object o = Integer.valueOf(42); + switch (o) { + case int i: return i; + default: break; + } + return -1; + } + + public static int primitiveSwitch3() { + int i = 42; + switch (i) { + case Integer ii: return ii; + } + } + + public static int primitiveSwitch4(float f) { + return switch (f) { + case 0.0f -> 1; + case Float fi when fi == 1f -> 2; + case Float fi -> 3; + }; + } + + public static int primitiveSwitchUnconditionallyExact(byte c) { + return switch (c) { + case short _ -> 1; + }; + } + + public static int exhaustive0() { + Integer i = 42; + switch (i) { + case int j: return j; + } + } + + public static int exhaustive1WithDefault() { + int i = 42; + return switch (i) { + case byte b -> 1; + default -> 2; + }; + } + + public static int exhaustive2WithDefault() { + int i = 30000; + return switch (i) { + case byte b -> 1; + case short s -> 2; + default -> 3; + }; + } + + public static int exhaustive1() { + int i = 42; + return switch (i) { + case Integer p -> 1; + }; + } + + public static int exhaustive2() { + int i = 42; + return switch (i) { + case long d -> 1; + }; + } + + public static int exhaustive3() { + int i = 42; + return switch (i) { + case double d -> 1; + }; + } + + public static int exhaustive4() { + int i = 127; + return switch (i) { + case byte b -> 1; + case double d -> 2; + }; + } + + public static int exhaustive5() { + int i = 127 + 1; + return switch (i) { + case byte b -> 1; + case double d -> 2; + }; + } + + public static int exhaustive6() { + Integer i = Integer.valueOf(42); + return switch (i) { + case int p -> 1; + }; + } + + public static int exhaustive7(Boolean b) { + switch (b) { + case true: return 1; + case false: return 2; // with reminder, null, OK + } + } + + public static int exhaustive7s(Boolean b) { + return switch (b) { + case true -> 1; + case false -> 2; // with reminder, null, OK + }; + } + + public static int exhaustive8(Boolean b) { + switch (b) { + case boolean bb: return 1; + } + } + + public static int exhaustive9(boolean b) { + switch (b) { + case Boolean bb: return 1; + } + } + + public static int exhaustiveWithRecords1() { + R_int r = new R_int(42); + return switch (r) { + // exhaustive, because Integer exhaustive at type int + case R_int(Integer x) -> 1; + }; + } + + public static int exhaustiveWithRecords2() { + R_int r = new R_int(42); + return switch (r) { + // exhaustive, because double unconditional at int + case R_int(double x) -> 1; + }; + } + + public static int exhaustiveWithRecords4() { + R_Integer r = new R_Integer(42); + return switch (r) { + // exhaustive, because R_Integer(int) exhaustive at type R_Integer(Integer), because int exhaustive at type Integer + case R_Integer(int x) -> 1; + }; + } + + public static int exhaustiveWithRecords5() { + R_Integer r = new R_Integer(42); + return switch (r) { + // exhaustive, because double exhaustive at Integer + case R_Integer(double x) -> 1; + }; + } + + public static int exhaustiveWithRecords6() { + R_int r = new R_int(42); + return switch (r) { + case R_int(byte x) -> 1; + case R_int(int x) -> 2; + }; + } + + public static int ensureProperSelectionWithRecords() { + R_int r = new R_int(4242); + return switch (r) { + case R_int(byte x) -> 1; + case R_int(int x) -> 2; + }; + } + + public static int ensureProperSelectionWithRecords2() { + R_double r = new R_double(42); + switch (r) { + case R_double(int i): + return meth_int(i); + case R_double(double x): + return meth_double(x); + } + } + + public static int ensureProperSelectionWithRecords3() { + R_int r = new R_int(4242); + return switch (r) { + case R_int(byte x) -> 1; + case R_int(int x) when x == 236 -> 2; + case R_int(int x) -> 3; + }; + } + + public static int meth_int(int i) { return 1; } + public static int meth_double(double d) { return 2;} + + public static int switchAndDowncastFromObjectPrimitive() { + Object i = 42; + return switch (i) { + case Integer ib -> ib; + default -> -1; + }; + } + + public static int dominationBetweenBoxedAndPrimitive() { + Object i = 42; + return switch (i) { + case Integer ib -> ib; + case byte ip -> ip; + default -> -1; + }; + } + + static int wideningAndUnboxing() { + Number o = Integer.valueOf(42); + return switch (o) { + case byte b -> 1; + case int i -> 2; + case float f -> 3; + default -> 4; + }; + } + + static int wideningAndUnboxingInRecord() { + Box box = new Box<>(Integer.valueOf(42)); + return switch (box) { + case Box(byte b) -> 1; + case Box(int i) -> 2; + case Box(float f) -> 3; + default -> 4; + }; + } + + static int wideningAndInferredUnboxingInRecord() { + Box box = new Box<>(Integer.valueOf(42)); + return switch (box) { + case Box(byte b) -> 1; + case Box(int i) -> 2; + case Box(float f) -> 3; + default -> 4; + }; + } + + public static float switchOverBoxedFloat(Float f) { + return switch (f) { + case 0f -> 5f + 0f; + case Float fi when fi == 1f -> 6f + fi; + case Float fi -> 7f + fi; + }; + } + + public static double switchOverPrimitiveDouble(Double d) { + return switch (d) { + case 0d -> 5d + 0d; + case Double di when di == 1d -> 6d + di; + case Double di -> 7d + di; + }; + } + + public static boolean switchOverBoxedBooleanWithUnconditional(Boolean b) { + return switch (b) { + case true -> true; + case Boolean bi -> bi; + }; + } + + public static int switchOverPrimitiveBooleanWithDefault(boolean b) { + return switch (b) { + case true -> 1; + default -> 2; + }; + } + + public static int switchOverPrimitiveBoolean(boolean b) { + return switch (b) { + case true -> 1; + case false -> 2; + }; + } + + public static int switchOverPrimitiveChar(char c) { + return switch (c) { + case 'a' -> 1; + default -> -1; + }; + } + + public static final float NaNconstant = Float.NaN; + public static int switchOverPrimitiveFloat(float f) { + return switch (f) { + case NaNconstant -> 1; + case 1.0f -> 2; + case 0.0f -> 3; + case -0.0f -> 4; + default -> -1; + }; + } + + // tests that Exactness.char_byte is properly redirected to int_byte + public static int switchRedirectedExactnessMethods1(char c) { + return switch (c) { + case byte _ -> 1; + default -> -1; + }; + } + + // tests that Exactness.char_short is properly redirected to int_short + public static int switchRedirectedExactnessMethods2(char c) { + return switch (c) { + case short _ -> 1; + default -> -1; + }; + } + + // tests that Exactness.short_byte is properly redirected to int_byte + public static int switchRedirectedExactnessMethods2(short c) { + return switch (c) { + case byte _ -> 1; + default -> -1; + }; + } + + public static int switchLongAndUnconditional(long l) { + return switch (l) { + case 32778L -> 1; + case long c -> 2; + }; + } + + public static int switchByte(byte b) { + return switch (b) { + case (byte)128 -> 1; + case byte c -> 2; + }; + } + + public static int switchShort(short s) { + return switch (s) { + case (short)32778 -> 1; + case short c -> 2; + }; + } + + public static int switchInt(int i) { + return switch (i) { + case 32778 -> 1; + case int c -> 2; + }; + } + + public static int switchChar(char c) { + return switch (c) { + case '\u0010' -> 1; + case char cc -> 2; + }; + } + + public static int testIntInNonEnhancedSwitchStatement(int v1) { + int i = 0; + switch (v1) { + case 1: + i = 1; + break; + } + return i; + } + + public static int testFloatInEnhancedSwitchStatement(float v1) { + int i = 0; + switch (v1) { + case 1.0f: + i = 1; + break; + default: + i = 0; + } + return i; + } + + public static int testDoubleInEnhancedSwitchStatement(double v1) { + int i = 0; + switch (v1) { + case 1d: + i = 1; + break; + default: + i = 0; + } + return i; + } + + public static int testLongInEnhancedSwitchStatement(long v1) { + int i = 0; + switch (v1) { + case 1l: + i = 1; + break; + default: + i = 0; + } + return i; + } + + public static int testBooleanInEnhancedSwitchStatement(boolean v1) { + int i = 0; + switch (v1) { + case true: + i = 1; + break; + default: + i = 0; + } + return i; + } + + public static int testByteWrapperToIntUnconditionallyExact() { + Byte b = Byte.valueOf((byte) 42); + return switch (b) { + case int p -> 1; + }; + } + + public static int testIntegerWrapperToFloat() { + Integer i = Integer.valueOf(42); + return switch (i) { + case float p -> 1; + default -> -1; + }; + } + + public static int testIntegerWrapperToFloatInexact() { + Integer i = Integer.valueOf(Integer.MAX_VALUE); + return switch (i) { + case float p -> 1; + default -> -1; + }; + } + + + record R_Integer(Integer x) {} + record R_int(int x) {} + record R_double(double x) {} + record Box(N num) {} + + static void assertEquals(int expected, int actual) { + if (expected != actual) { + throw new AssertionError("Expected: " + expected + ", actual: " + actual); + } + } + + static void assertEquals(float expected, float actual) { + if (Float.compare(expected, actual) != 0) { + throw new AssertionError("Expected: " + expected + ", but got: " + actual); + } + } + + static void assertEquals(double expected, double actual) { + if (Double.compare(expected, actual) != 0) { + throw new AssertionError("Expected: " + expected + ", but got: " + actual); + } + } + + static void assertTrue(boolean actual) { + if (!actual) { + throw new AssertionError("Expected: true, but got false"); + } + } +} diff --git a/test/langtools/tools/javac/patterns/PrimitivePatternsSwitchErrors.java b/test/langtools/tools/javac/patterns/PrimitivePatternsSwitchErrors.java new file mode 100644 index 00000000000..71e6193275b --- /dev/null +++ b/test/langtools/tools/javac/patterns/PrimitivePatternsSwitchErrors.java @@ -0,0 +1,220 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8304487 + * @summary Compiler Implementation for Primitive types in patterns, instanceof, and switch (Preview) + * @enablePreview + * @compile/fail/ref=PrimitivePatternsSwitchErrors.out -XDrawDiagnostics -XDshould-stop.at=FLOW PrimitivePatternsSwitchErrors.java + */ +public class PrimitivePatternsSwitchErrors { + record R_int(int x) {} + + public static void dominationBetweenPrimitivePatterns() { + int i = 42; + switch (i) { + case short s -> System.out.println("its a short"); + case byte b -> System.out.println("its a byte"); // Error - dominated! + default -> System.out.println("any other integral value"); + } + } + + public static int dominationWithRecordPatterns() { + R_int r = new R_int(42); + return switch (r) { + case R_int(int x) -> 1; + case R_int(byte x) -> 2; // Error - dominated! + }; + } + + public static int inconvertibleNestedComponent() { + R_int r = new R_int(42); + return switch (r) { + case R_int(Long x) -> 1; // inconvertible + }; + } + + public static int nonExhaustive1() { + int i = 42; + return switch (i) { // Error - not exhaustive + case short s -> s; + }; + } + + public static int nonExhaustive2() { + int i = 42; + return switch (i) { // Error - not exhaustive + case byte b -> 1; + case short s -> 2; + }; + } + + public static int nonExhaustive3() { + int i = 42; + return switch (i) { // Error - not exhaustive + case byte b -> 1; + case float f -> 2; + }; + } + + public static int dominationBetweenBoxedAndPrimitive() { + int i = 42; + return switch (i) { + case Integer ib -> ib; + case byte ip -> ip; // Error - dominated! + }; + } + + public static int constantDominatedWithPrimitivePattern() { + int i = 42; + return switch (i) { + case int j -> 42; + case 43 -> -1; // Error - dominated! + }; + } + + public static int constantDominatedWithFloatPrimitivePattern() { + float f = 42.0f; + return switch (f) { + case Float ff -> 42; + case 43.0f -> -1; // Error - dominated! + }; + } + + void switchLongOverByte(byte b) { + switch (b) { + case 0L: return ; + } + } + + void switchOverPrimitiveFloatFromInt(float f) { + switch (f) { + case 16777216: + break; + case 16777217: + break; + default: + break; + } + } + + void switchOverNotRepresentableFloat(Float f) { + switch (f) { + case 1.0f: + break; + case 0.999999999f: + break; + case Float fi: + break; + } + } + + int switchOverPrimitiveBooleanExhaustiveWithNonPermittedDefault(boolean b) { + return switch (b) { + case true -> 1; + case false -> 2; + default -> 3; + }; + } + + int switchOverPrimitiveBooleanExhaustiveWithNonPermittedDefaultStatement(boolean b) { + switch (b) { + case true: return 1; + case false: return 2; + default: return 3; + } + } + + int switchOverPrimitiveBooleanExhaustiveWithNonPermittedUnconditionalStatement(boolean b) { + switch (b) { + case true: return 1; + case false: return 2; + case boolean bb: return 3; // error + } + } + + void switchCombinationsNonIntegral() { + float f = 0f; + long l = 0L; + double d = 0d; + Float fB = 0F; + Long lB = 0L; + Double dB = 0D; + + switch (f) { + case 1l: return; + case 2f: return; + case 3d: return; + default: + } + + switch (l) { + case 1l: return; + case 2f: return; + case 3d: return; + default: + } + + switch (d) { + case 1l: return; + case 2f: return; + case 3d: return; + default: + } + + switch (fB) { + case 1l: return; + case 2f: return; + case 3d: return; + default: + } + + switch (lB) { + case 1l: return; + case 2f: return; + case 3d: return; + default: + } + + switch (dB) { + case 1l: return; + case 2f: return; + case 3d: return; + default: + } + } + + int switchOverPrimitiveBooleanExhaustiveWithNonPermittedUnconditional(boolean b) { + return switch (b) { + case true -> 1; + case false -> 2; + case boolean bb -> 3; // error + }; + } + + int duplicateUnconditionalWithPrimitives(int i) { + return switch (i) { + case int ii -> 1; + case long l -> 2; // error + }; + } + + int booleanSingleCase1(boolean b) { + return switch (b) { + case true -> 1; + }; + } + + int booleanSingleCase2(boolean b) { + switch (b) { + case true: return 1; + } + } + + void nullAndPrimitive() { + int i = 42; + switch (i) { + case short s -> System.out.println("its a short"); + case null -> System.out.println("oops"); + default -> System.out.println("any other integral value"); + } + } +} diff --git a/test/langtools/tools/javac/patterns/PrimitivePatternsSwitchErrors.out b/test/langtools/tools/javac/patterns/PrimitivePatternsSwitchErrors.out new file mode 100644 index 00000000000..2026afe58c2 --- /dev/null +++ b/test/langtools/tools/javac/patterns/PrimitivePatternsSwitchErrors.out @@ -0,0 +1,37 @@ +PrimitivePatternsSwitchErrors.java:15:18: compiler.err.pattern.dominated +PrimitivePatternsSwitchErrors.java:24:18: compiler.err.pattern.dominated +PrimitivePatternsSwitchErrors.java:31:24: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: int, java.lang.Long) +PrimitivePatternsSwitchErrors.java:62:18: compiler.err.pattern.dominated +PrimitivePatternsSwitchErrors.java:70:18: compiler.err.pattern.dominated +PrimitivePatternsSwitchErrors.java:78:18: compiler.err.pattern.dominated +PrimitivePatternsSwitchErrors.java:84:18: compiler.err.prob.found.req: (compiler.misc.possible.loss.of.precision: long, byte) +PrimitivePatternsSwitchErrors.java:90:18: compiler.err.constant.label.not.compatible: int, float +PrimitivePatternsSwitchErrors.java:92:18: compiler.err.constant.label.not.compatible: int, float +PrimitivePatternsSwitchErrors.java:103:13: compiler.err.duplicate.case.label +PrimitivePatternsSwitchErrors.java:114:13: compiler.err.default.and.both.boolean.values +PrimitivePatternsSwitchErrors.java:122:13: compiler.err.default.and.both.boolean.values +PrimitivePatternsSwitchErrors.java:130:18: compiler.err.unconditional.pattern.and.both.boolean.values +PrimitivePatternsSwitchErrors.java:143:18: compiler.err.constant.label.not.compatible: long, float +PrimitivePatternsSwitchErrors.java:145:18: compiler.err.prob.found.req: (compiler.misc.possible.loss.of.precision: double, float) +PrimitivePatternsSwitchErrors.java:151:18: compiler.err.prob.found.req: (compiler.misc.possible.loss.of.precision: float, long) +PrimitivePatternsSwitchErrors.java:152:18: compiler.err.prob.found.req: (compiler.misc.possible.loss.of.precision: double, long) +PrimitivePatternsSwitchErrors.java:157:18: compiler.err.constant.label.not.compatible: long, double +PrimitivePatternsSwitchErrors.java:158:18: compiler.err.constant.label.not.compatible: float, double +PrimitivePatternsSwitchErrors.java:164:18: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: long, java.lang.Float) +PrimitivePatternsSwitchErrors.java:166:18: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: double, java.lang.Float) +PrimitivePatternsSwitchErrors.java:172:18: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: float, java.lang.Long) +PrimitivePatternsSwitchErrors.java:173:18: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: double, java.lang.Long) +PrimitivePatternsSwitchErrors.java:178:18: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: long, java.lang.Double) +PrimitivePatternsSwitchErrors.java:179:18: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: float, java.lang.Double) +PrimitivePatternsSwitchErrors.java:189:18: compiler.err.unconditional.pattern.and.both.boolean.values +PrimitivePatternsSwitchErrors.java:196:18: compiler.err.duplicate.unconditional.pattern +PrimitivePatternsSwitchErrors.java:216:18: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, int) +PrimitivePatternsSwitchErrors.java:30:16: compiler.err.not.exhaustive +PrimitivePatternsSwitchErrors.java:37:16: compiler.err.not.exhaustive +PrimitivePatternsSwitchErrors.java:44:16: compiler.err.not.exhaustive +PrimitivePatternsSwitchErrors.java:52:16: compiler.err.not.exhaustive +PrimitivePatternsSwitchErrors.java:201:16: compiler.err.not.exhaustive +PrimitivePatternsSwitchErrors.java:207:9: compiler.err.not.exhaustive.statement +- compiler.note.preview.filename: PrimitivePatternsSwitchErrors.java, DEFAULT +- compiler.note.preview.recompile +34 errors \ No newline at end of file diff --git a/test/langtools/tools/javac/patterns/SourceLevelChecks.java b/test/langtools/tools/javac/patterns/SourceLevelChecks.java index cca3bf311c5..3b0fece12bc 100644 --- a/test/langtools/tools/javac/patterns/SourceLevelChecks.java +++ b/test/langtools/tools/javac/patterns/SourceLevelChecks.java @@ -128,7 +128,210 @@ private void test(Integer i) { "1 error"); } + @Test + public void testNestedPrimitive1(Path base) throws Exception { + doTest(base, + """ + package test; + public class Test { + private void test(R r) { + if (r instanceof R(byte b)) { + } + } + record R(int i) {} + } + """, + 21, + "Test.java:4:28: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.primitive.patterns)", + "1 error"); + } + + @Test + public void testNestedPrimitive2(Path base) throws Exception { + doTest(base, + """ + package test; + public class Test { + private void test(R r) { + switch (r) { + case R(byte b) -> {} + default -> {} + } + } + record R(int i) {} + } + """, + 21, + "Test.java:5:20: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.primitive.patterns)", + "1 error"); + } + + @Test + public void testNestedPrimitive3(Path base) throws Exception { + doTest(base, + """ + package test; + public class Test { + private void test(R r) { + if (r instanceof R(long l)) { + } + } + record R(int i) {} + } + """, + 21, + "Test.java:4:28: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.primitive.patterns)", + "1 error"); + } + + @Test + public void testNestedPrimitive4(Path base) throws Exception { + doTest(base, + """ + package test; + public class Test { + private void test(R r) { + switch (r) { + case R(long l) -> {} + default -> {} + } + } + record R(int i) {} + } + """, + 21, + "Test.java:5:20: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.primitive.patterns)", + "1 error"); + } + + @Test + public void testPrimitive2Reference1(Path base) throws Exception { + doTest(base, + """ + package test; + public class Test { + private void test(int i) { + if (i instanceof Integer j) {} + } + } + """, + 21, + "Test.java:4:13: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.primitive.patterns)", + "1 error"); + } + + @Test + public void testPrimitive2Reference2(Path base) throws Exception { + doTest(base, + """ + package test; + public class Test { + private void test(int i) { + switch (i) { + case Integer j -> {} + } + } + } + """, + 21, + "Test.java:5:18: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.primitive.patterns)", + "1 error"); + } + + @Test + public void testReference2Primitive1(Path base) throws Exception { + doTest(base, + """ + package test; + public class Test { + private void test(Integer i) { + if (i instanceof int j) {} + } + } + """, + 21, + "Test.java:4:26: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.primitive.patterns)", + "1 error"); + } + + @Test + public void testReference2Primitive2(Path base) throws Exception { + doTest(base, + """ + package test; + public class Test { + private void test(Integer i) { + switch (i) { + case int j -> {} + } + } + } + """, + 21, + "Test.java:5:18: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.primitive.patterns)", + "1 error"); + } + + @Test + public void testPrimitivePatternObject1(Path base) throws Exception { + doTest(base, + """ + package test; + public class Test { + private void test(Object o) { + if (o instanceof int j) {} + } + } + """, + 21, + "Test.java:4:26: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.primitive.patterns)", + "1 error"); + } + + @Test + public void testPrimitivePatternObject2(Path base) throws Exception { + doTest(base, + """ + package test; + public class Test { + private void test(Object o) { + switch (o) { + case int j -> {} + } + } + record R(int i) {} + } + """, + 21, + "Test.java:5:18: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.primitive.patterns)", + "1 error"); + } + + @Test + public void testOtherPrimitives(Path base) throws Exception { + for (String type : new String[] {"boolean", "long", "float", "double"}) { + doTest(base, + """ + package test; + public class Test { + private void test($type v) { + switch (v) { + default -> {} + } + } + } + """.replace("$type", type), + 21, + "Test.java:4:16: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.primitive.patterns)", + "1 error"); + } + } + private void doTest(Path base, String testCode, String... expectedErrors) throws IOException { + doTest(base, testCode, 17, expectedErrors); + } + + private void doTest(Path base, String testCode, int sourceLevel, String... expectedErrors) throws IOException { Path current = base.resolve("."); Path src = current.resolve("src"); Path classes = current.resolve("classes"); @@ -138,7 +341,7 @@ private void doTest(Path base, String testCode, String... expectedErrors) throws var log = new JavacTask(tb) - .options("--release", "17", + .options("--release", "" + sourceLevel, "-XDrawDiagnostics") .outdir(classes) .files(tb.findJavaFiles(src)) diff --git a/test/langtools/tools/javac/patterns/SwitchErrors.java b/test/langtools/tools/javac/patterns/SwitchErrors.java index 68dbe67d563..6f93dbb192a 100644 --- a/test/langtools/tools/javac/patterns/SwitchErrors.java +++ b/test/langtools/tools/javac/patterns/SwitchErrors.java @@ -127,12 +127,6 @@ void erroneous(Object o) { default: break; } } - void primitivePattern(Object o) { - switch (o) { - case int i: break; - default: break; - } - } void patternAndDefault1(Object o) { switch (o) { case String s, default: break; @@ -239,16 +233,6 @@ void referenceTypeTotalForNull() { case CharSequence cs: break; } } - void primitiveToReference(int i) { - switch (i) { - case Integer j: break; - } - } - void referenceToPrimitive(Integer i) { - switch (i) { - case int j: break; - } - } void nullAndParenthesized1(Object o) { record R(Object o) {} switch (o) { diff --git a/test/langtools/tools/javac/patterns/SwitchErrors.out b/test/langtools/tools/javac/patterns/SwitchErrors.out index 413b33a73d3..9eea96ee272 100644 --- a/test/langtools/tools/javac/patterns/SwitchErrors.out +++ b/test/langtools/tools/javac/patterns/SwitchErrors.out @@ -1,18 +1,18 @@ SwitchErrors.java:66:18: compiler.err.default.label.not.allowed SwitchErrors.java:72:18: compiler.err.default.label.not.allowed SwitchErrors.java:72:27: compiler.err.default.label.not.allowed -SwitchErrors.java:138:28: compiler.err.default.label.not.allowed -SwitchErrors.java:144:18: compiler.err.default.label.not.allowed -SwitchErrors.java:149:18: compiler.err.default.label.not.allowed -SwitchErrors.java:154:18: compiler.err.default.label.not.allowed -SwitchErrors.java:213:29: compiler.err.default.label.not.allowed -SwitchErrors.java:220:32: compiler.err.default.label.not.allowed -SwitchErrors.java:227:32: compiler.err.default.label.not.allowed -SwitchErrors.java:283:20: compiler.err.illegal.start.of.type -SwitchErrors.java:286:28: compiler.err.illegal.start.of.type +SwitchErrors.java:132:28: compiler.err.default.label.not.allowed +SwitchErrors.java:138:18: compiler.err.default.label.not.allowed +SwitchErrors.java:143:18: compiler.err.default.label.not.allowed +SwitchErrors.java:148:18: compiler.err.default.label.not.allowed +SwitchErrors.java:207:29: compiler.err.default.label.not.allowed +SwitchErrors.java:214:32: compiler.err.default.label.not.allowed +SwitchErrors.java:221:32: compiler.err.default.label.not.allowed +SwitchErrors.java:267:20: compiler.err.illegal.start.of.type +SwitchErrors.java:270:28: compiler.err.illegal.start.of.type +SwitchErrors.java:290:42: compiler.err.expected2: :, -> +SwitchErrors.java:299:45: compiler.err.expected2: :, -> SwitchErrors.java:306:42: compiler.err.expected2: :, -> -SwitchErrors.java:315:45: compiler.err.expected2: :, -> -SwitchErrors.java:322:42: compiler.err.expected2: :, -> SwitchErrors.java:11:18: compiler.err.constant.label.not.compatible: java.lang.String, java.lang.Object SwitchErrors.java:17:18: compiler.err.constant.label.not.compatible: int, java.lang.Object SwitchErrors.java:23:18: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer) @@ -36,30 +36,27 @@ SwitchErrors.java:108:18: compiler.err.flows.through.to.pattern SwitchErrors.java:113:18: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer) SwitchErrors.java:119:18: compiler.err.instanceof.reifiable.not.safe: java.util.List, java.util.List SwitchErrors.java:125:18: compiler.err.cant.resolve.location: kindname.class, Undefined, , , (compiler.misc.location: kindname.class, SwitchErrors, null) -SwitchErrors.java:132:18: compiler.err.type.found.req: int, (compiler.misc.type.req.class.array) -SwitchErrors.java:143:18: compiler.err.flows.through.from.pattern -SwitchErrors.java:149:27: compiler.err.flows.through.from.pattern -SwitchErrors.java:155:18: compiler.err.flows.through.to.pattern -SwitchErrors.java:167:18: compiler.err.pattern.expected -SwitchErrors.java:173:78: compiler.err.cant.resolve.location: kindname.variable, n, , , (compiler.misc.location: kindname.class, SwitchErrors, null) -SwitchErrors.java:179:73: compiler.err.cant.resolve.location: kindname.variable, n, , , (compiler.misc.location: kindname.class, SwitchErrors, null) -SwitchErrors.java:186:21: compiler.err.invalid.case.label.combination -SwitchErrors.java:197:13: compiler.err.unconditional.pattern.and.default -SwitchErrors.java:195:29: compiler.err.flows.through.from.pattern -SwitchErrors.java:204:24: compiler.err.invalid.case.label.combination -SwitchErrors.java:220:21: compiler.err.invalid.case.label.combination -SwitchErrors.java:227:29: compiler.err.flows.through.from.pattern -SwitchErrors.java:239:18: compiler.err.duplicate.unconditional.pattern -SwitchErrors.java:244:18: compiler.err.prob.found.req: (compiler.misc.not.applicable.types: int, java.lang.Integer) -SwitchErrors.java:249:18: compiler.err.type.found.req: int, (compiler.misc.type.req.class.array) -SwitchErrors.java:255:24: compiler.err.invalid.case.label.combination -SwitchErrors.java:262:24: compiler.err.invalid.case.label.combination -SwitchErrors.java:269:18: compiler.err.flows.through.from.pattern -SwitchErrors.java:276:18: compiler.err.flows.through.from.pattern -SwitchErrors.java:292:49: compiler.err.cant.resolve.location.args: kindname.method, length, , , (compiler.misc.location: kindname.class, java.lang.Object, null) -SwitchErrors.java:294:55: compiler.err.cant.resolve.location.args: kindname.method, length, , , (compiler.misc.location: kindname.class, java.lang.Object, null) -SwitchErrors.java:300:26: compiler.err.pattern.type.cannot.infer -SwitchErrors.java:315:21: compiler.err.invalid.case.label.combination +SwitchErrors.java:137:18: compiler.err.flows.through.from.pattern +SwitchErrors.java:143:27: compiler.err.flows.through.from.pattern +SwitchErrors.java:149:18: compiler.err.flows.through.to.pattern +SwitchErrors.java:161:18: compiler.err.pattern.expected +SwitchErrors.java:167:78: compiler.err.cant.resolve.location: kindname.variable, n, , , (compiler.misc.location: kindname.class, SwitchErrors, null) +SwitchErrors.java:173:73: compiler.err.cant.resolve.location: kindname.variable, n, , , (compiler.misc.location: kindname.class, SwitchErrors, null) +SwitchErrors.java:180:21: compiler.err.invalid.case.label.combination +SwitchErrors.java:191:13: compiler.err.unconditional.pattern.and.default +SwitchErrors.java:189:29: compiler.err.flows.through.from.pattern +SwitchErrors.java:198:24: compiler.err.invalid.case.label.combination +SwitchErrors.java:214:21: compiler.err.invalid.case.label.combination +SwitchErrors.java:221:29: compiler.err.flows.through.from.pattern +SwitchErrors.java:233:18: compiler.err.duplicate.unconditional.pattern +SwitchErrors.java:239:24: compiler.err.invalid.case.label.combination +SwitchErrors.java:246:24: compiler.err.invalid.case.label.combination +SwitchErrors.java:253:18: compiler.err.flows.through.from.pattern +SwitchErrors.java:260:18: compiler.err.flows.through.from.pattern +SwitchErrors.java:276:49: compiler.err.cant.resolve.location.args: kindname.method, length, , , (compiler.misc.location: kindname.class, java.lang.Object, null) +SwitchErrors.java:278:55: compiler.err.cant.resolve.location.args: kindname.method, length, , , (compiler.misc.location: kindname.class, java.lang.Object, null) +SwitchErrors.java:284:26: compiler.err.pattern.type.cannot.infer +SwitchErrors.java:299:21: compiler.err.invalid.case.label.combination SwitchErrors.java:10:9: compiler.err.not.exhaustive.statement SwitchErrors.java:16:9: compiler.err.not.exhaustive.statement SwitchErrors.java:22:9: compiler.err.not.exhaustive.statement @@ -70,6 +67,6 @@ SwitchErrors.java:87:9: compiler.err.not.exhaustive.statement SwitchErrors.java:92:9: compiler.err.not.exhaustive.statement SwitchErrors.java:98:9: compiler.err.not.exhaustive.statement SwitchErrors.java:105:9: compiler.err.not.exhaustive.statement -SwitchErrors.java:159:9: compiler.err.not.exhaustive.statement -SwitchErrors.java:232:9: compiler.err.not.exhaustive.statement -74 errors \ No newline at end of file +SwitchErrors.java:153:9: compiler.err.not.exhaustive.statement +SwitchErrors.java:226:9: compiler.err.not.exhaustive.statement +71 errors diff --git a/test/langtools/tools/javac/processing/model/util/elements/TestOverrides.java b/test/langtools/tools/javac/processing/model/util/elements/TestOverrides.java new file mode 100644 index 00000000000..1373c596a46 --- /dev/null +++ b/test/langtools/tools/javac/processing/model/util/elements/TestOverrides.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2023, 2024, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8302019 + * @summary Test basic operation of Elements.overrides + * @library /tools/javac/lib + * @build JavacTestingAbstractProcessor TestOverrides + * @compile -processor TestOverrides -proc:only TestOverrides.java + */ + +import java.util.*; +import java.util.function.*; +import javax.annotation.processing.*; +import javax.lang.model.element.*; +import javax.lang.model.util.*; + +/** + * Test basic workings of Elements.overrides + */ +public class TestOverrides extends JavacTestingAbstractProcessor { + public boolean process(Set annotations, + RoundEnvironment roundEnv) { + if (!roundEnv.processingOver()) { + checkObjectOverrides(); + } + return true; + } + + private void checkObjectOverrides() { + boolean elementSeen = false; + + TypeElement objectElt = elements.getTypeElement("java.lang.Object"); + + TypeElement objectInterfaceElt = elements.getTypeElement("ObjectInterface"); + for (var method : ElementFilter.methodsIn(objectInterfaceElt.getEnclosedElements())) { + elementSeen = true; + Name methodName = method.getSimpleName(); + boolean expectedOverrideResult = method.getAnnotation(OverrideExpected.class).value(); + if (expectedOverrideResult != + elements.overrides(method, findMethod(methodName, objectElt), objectInterfaceElt ) ) { + throw new RuntimeException("Unexpected overriding relation found for " + method); + } + + if (!elementSeen) { + throw new RuntimeException("No elements seen."); + } + } + } + + ExecutableElement findMethod(Name name, TypeElement typeElt) { + for (var method : ElementFilter.methodsIn(typeElt.getEnclosedElements())) { + if (method.getSimpleName().equals(name)) { + return method; + } + } + return null; + } + +} + +@interface OverrideExpected { + boolean value() default true; +} + +/** + * Interface that has methods override-equivalent to methods of + * java.lang.Object. + */ +interface ObjectInterface { + @Override + @OverrideExpected + boolean equals(Object obj); + + @Override + @OverrideExpected + int hashCode(); + + @Override + @OverrideExpected + String toString(); + + @OverrideExpected(value=false) // protected, not public method + Object clone(); + + @OverrideExpected(value=false) // protected, not public method + void finalize(); + + // Final methods of Object (getClass, wait, notify[all]) rejected + // if declared in an interface. +} + diff --git a/test/langtools/tools/javac/processing/model/util/types/TestAnnotationStripping.java b/test/langtools/tools/javac/processing/model/util/types/TestAnnotationStripping.java new file mode 100644 index 00000000000..849ab898f9f --- /dev/null +++ b/test/langtools/tools/javac/processing/model/util/types/TestAnnotationStripping.java @@ -0,0 +1,305 @@ +/* + * Copyright (c) 2017, 2024, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8042981 + * @summary Test if annotations are stripped from the results of Types' methods + * @library /tools/javac/lib + * @modules java.compiler + * jdk.compiler + * @build JavacTestingAbstractProcessor TestAnnotationStripping + * @compile -processor TestAnnotationStripping -proc:only TestAnnotationStripping.java + */ + +import java.lang.annotation.*; +import java.util.*; +import static java.util.Objects.*; +import javax.annotation.processing.*; +import javax.lang.model.SourceVersion; +import static javax.lang.model.SourceVersion.*; +import javax.lang.model.*; +import javax.lang.model.element.*; +import javax.lang.model.type.*; +import javax.lang.model.util.*; +import static javax.lang.model.util.ElementFilter.*; +import static javax.tools.Diagnostic.Kind.*; +import static javax.tools.StandardLocation.*; + +/** + * Test if annotations are stripped from the results of Types' methods + */ +public class TestAnnotationStripping extends JavacTestingAbstractProcessor { + private Types vacuousTypes = new VacuousTypes(); + + /** + * Check expected behavior on classes and packages. + */ + public boolean process(Set annotations, + RoundEnvironment roundEnv) { + if (!roundEnv.processingOver()) { + TypeElement juSetElt = eltUtils.getTypeElement("java.util.Set"); + TypeElement testElt = elements.getTypeElement("TestAnnotationStripping"); + TypeElement boxElt = elements.getTypeElement("TestAnnotationStripping.Box"); + + TypeMirror expectedAnnotation = eltUtils.getTypeElement("TestTypeAnnotation").asType(); + + for (ExecutableElement m : + methodsIn(eltUtils.getTypeElement("HostClass").getEnclosedElements())) { + /* + * The kinds of types include: + * + * arrays + * declared types (classes, interfaces, etc.) + * error types + * executable types + * intersection types + * no-type + * null type + * primitive types + * type variable + * union type + * wildcards + * + * A subset of these can appear at the return type of + * a method. The general methodology is to verify that + * types that can appear as return types when + * annotated with type annotations appear as specified + * as the result of type operations or when new types + * are constructed. + */ + + TypeMirror returnType = m.getReturnType(); + + System.err.println("Checking " + returnType); + + testVacuous(returnType); + checkDeepEmptyAnnotations(typeUtils.stripAnnotations(returnType)); + + checkExpectedTypeAnnotations(returnType, expectedAnnotation); + + // Note: the result of Types.asElement is *not* + // checked for its annotations since the return value + // is an Element and not a TypeMirror. + + System.err.print("\tcapture()"); + checkDeepEmptyAnnotations(typeUtils.capture(returnType)); + + System.err.print("\terasure()"); + checkDeepEmptyAnnotations(typeUtils.erasure(returnType)); + + System.err.print("\tgetArrayType()"); + ArrayType arrayType = typeUtils.getArrayType(returnType); + checkEmptyAnnotations(arrayType); + /* + * "Annotations on the component type are preserved." + */ + checkEqualTypeAndAnnotations(returnType, arrayType.getComponentType()); + + if (!returnType.getKind().isPrimitive()) { + /* + * For getWildcardType() + * "Annotations on the bounds are preserved." + */ + WildcardType wcType; + checkEmptyAnnotations(wcType = typeUtils.getWildcardType(returnType, null)); + checkEqualTypeAndAnnotations(returnType, wcType.getExtendsBound()); + + checkEmptyAnnotations(wcType = typeUtils.getWildcardType(null, returnType)); + checkEqualTypeAndAnnotations(returnType, wcType.getSuperBound()); + + /* + * For getDeclaredType() + * "Annotations on the type arguments are preserved." + */ + DeclaredType declaredType = typeUtils.getDeclaredType(juSetElt, returnType); + checkEqualTypeAndAnnotations(returnType, declaredType.getTypeArguments().get(0)); + + // Check both overloads + declaredType = typeUtils.getDeclaredType(typeUtils.getDeclaredType(testElt), // outer type + boxElt, + returnType); + checkEqualTypeAndAnnotations(returnType, declaredType.getTypeArguments().get(0)); + } + + System.out.println(returnType.getAnnotation(TestTypeAnnotation.class)); + System.out.println(returnType.getAnnotationsByType(TestTypeAnnotation.class).length); + TestTypeAnnotation ta = requireNonNull(returnType.getAnnotation(TestTypeAnnotation.class), + returnType.toString()); + + System.err.println(); + System.err.println(); + } + + if (failures > 0) + throw new RuntimeException(failures + " failures occured."); + } + return true; + } + + void testVacuous(TypeMirror tm ) { + try { + var result = vacuousTypes.stripAnnotations(tm); + messager.printError("Unexpected non-exceptional result returned " + result); + } catch(UnsupportedOperationException uoe) { + ; // Expected + } + } + + private int failures = 0; + + void checkExpectedTypeAnnotations(AnnotatedConstruct ac, TypeMirror expectedAnnotation) { + List annotations = ac.getAnnotationMirrors(); + if (annotations.size() != 1) { + failures++; + System.err.println("\t\t\tUnexpected annotations size: " + annotations.size()); + } else if (!typeUtils.isSameType(annotations.get(0).getAnnotationType(), expectedAnnotation)) { + failures++; + System.err.println("\t\t\tUnexpected annotations type: " + annotations); + } + } + + void checkEmptyAnnotations(AnnotatedConstruct ac) { + System.err.println("\t" + ac); + if (ac == null) + return; + else { + List annotations = ac.getAnnotationMirrors(); + int count = annotations.size(); + if (count != 0) { + failures++; + System.err.println(ac.getClass()); + System.err.println("\t\t\tUnexpected nonzero annotations size: " + annotations); + } + } + } + + void checkDeepEmptyAnnotations(TypeMirror ac) { + System.err.println("\t" + ac); + if (ac == null) { + return; + } + new SimpleTypeVisitor14() { + @Override + protected Void defaultAction(TypeMirror t, Void o) { + checkEmptyAnnotations(t); + return null; + } + + @Override + public Void visitArray(ArrayType t, Void o) { + scan(t.getComponentType()); + return super.visitArray(t, o); + } + + @Override + public Void visitDeclared(DeclaredType t, Void o) { + scan(t.getEnclosingType()); + t.getTypeArguments().stream().forEach(this::scan); + return super.visitDeclared(t, o); + } + + @Override + public Void visitTypeVariable(TypeVariable t, Void o) { + // the bounds correspond to the type variable declaration, not its use + // scan(t.getUpperBound()); + // scan(t.getLowerBound()); + return super.visitTypeVariable(t, o); + } + + @Override + public Void visitWildcard(WildcardType t, Void o) { + scan(t.getExtendsBound()); + scan(t.getSuperBound()); + return super.visitWildcard(t, o); + } + + private void scan(TypeMirror t) { + if (t != null) { + visit(t); + } + } + }.visit(ac); + } + + void checkEqualTypeAndAnnotations(TypeMirror tm1, TypeMirror tm2) { + if (!typeUtils.isSameType(tm1, tm2)) { + failures++; + System.err.printf("Unequal types %s and %s.%n", tm1, tm2); + } + + if (!Objects.equals(tm1.getAnnotationMirrors(), tm1.getAnnotationMirrors())) { + failures++; + System.err.printf("Unequal annotations on and %s.%n", tm1, tm2); + } + } + + // Nested class to test getDeclaredType overload. + class Box { + private T contents; + + public Box(T t){ + contents = t; + } + + T value() { return contents;}; + } +} + +/* + * Class to host annotations for testing + */ +class HostClass { + // Declared type Integer + public static @TestTypeAnnotation("foo") Integer foo() {return null;} + + // Primitive type int + public static @TestTypeAnnotation("foo2") int foo2() {return 0;} + + public static @TestTypeAnnotation("foo3") String foo3() {return null;} + + // Declared raw type Set + public static java.util.@TestTypeAnnotation("foo4")Set foo4() {return null;} + + // Array type + public static String @TestTypeAnnotation("foo5")[] foo5() {return null;} + + // Declared type Set with instantiated type parameter + public static java.util. @TestTypeAnnotation("foo6") Set < @TestTypeAnnotation("foo7") String> foo6() {return null;} + + // Type variable + public static <@TestTypeAnnotation("foo8") T extends @TestTypeAnnotation("foo9") String> @TestTypeAnnotation("foo10") T foo7() {return null;} + + // Declared type including wildcard + public static java.util. @TestTypeAnnotation("foo11") Set < @TestTypeAnnotation("foo12") ? extends @TestTypeAnnotation("foo13") Number> foo8() {return null;} + + // Type variable with intersection type + public static <@TestTypeAnnotation("foo14") S extends Number & Runnable> @TestTypeAnnotation("foo15") S foo9() {return null;} + +} + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE_USE) +@interface TestTypeAnnotation { + String value() default ""; +} diff --git a/test/langtools/tools/javac/switchextra/SwitchNoExtraTypes.java b/test/langtools/tools/javac/switchextra/SwitchNoExtraTypes.java deleted file mode 100644 index 590125b0e37..00000000000 --- a/test/langtools/tools/javac/switchextra/SwitchNoExtraTypes.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 8206986 - * @summary Verify switch over boolean/long/float/double is not allowed. - * @compile/fail/ref=SwitchNoExtraTypes.out -XDrawDiagnostics SwitchNoExtraTypes.java - */ - -public class SwitchNoExtraTypes { - - private void switchBoolean(boolean b) { - switch (b) { - case true: return ; - } - } - - private void switchLong(long l) { - switch (l) { - case 0: return ; - } - } - - private void switchFloat(float f) { - switch (f) { - case 0: return ; - } - } - - private void switchDouble(double d) { - switch (d) { - case 0: return ; - } - } - -} diff --git a/test/langtools/tools/javac/switchextra/SwitchNoExtraTypes.out b/test/langtools/tools/javac/switchextra/SwitchNoExtraTypes.out deleted file mode 100644 index 32854d2de20..00000000000 --- a/test/langtools/tools/javac/switchextra/SwitchNoExtraTypes.out +++ /dev/null @@ -1,5 +0,0 @@ -SwitchNoExtraTypes.java:11:16: compiler.err.selector.type.not.allowed: boolean -SwitchNoExtraTypes.java:17:16: compiler.err.selector.type.not.allowed: long -SwitchNoExtraTypes.java:23:16: compiler.err.selector.type.not.allowed: float -SwitchNoExtraTypes.java:29:16: compiler.err.selector.type.not.allowed: double -4 errors diff --git a/test/micro/org/openjdk/bench/jdk/preview/patterns/Exactness.java b/test/micro/org/openjdk/bench/jdk/preview/patterns/Exactness.java new file mode 100644 index 00000000000..675f5bda398 --- /dev/null +++ b/test/micro/org/openjdk/bench/jdk/preview/patterns/Exactness.java @@ -0,0 +1,145 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.bench.jdk.preview.patterns; + +import java.util.concurrent.TimeUnit; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.infra.Blackhole; + +/** + * Tests Exactness methods + */ +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.MILLISECONDS) +@Warmup(iterations=5, time=1) +@Measurement(iterations=5, time=1) +@Threads(2) +@Fork(value = 1, + jvmArgsPrepend = {"-Djmh.blackhole.mode=COMPILER", + "--enable-preview"}) +@State(Scope.Thread) +@SuppressWarnings("preview") +public class Exactness { + + private static boolean int_float_based_on_leading_trailing(int n) { + if (n == Integer.MIN_VALUE) + return true; + n = Math.abs(n); + return Float.PRECISION >= // 24 + (32 - (Integer.numberOfLeadingZeros(n) + + Integer.numberOfTrailingZeros(n))) ; + } + @Benchmark + public void test_int_float_based_on_leading_trailing(Blackhole bh) { + for(int n = Integer.MIN_VALUE; n < Integer.MAX_VALUE; n++) { + bh.consume(int_float_based_on_leading_trailing(n)); + } + } + + private static boolean int_float_based_on_filtering(int n) { + return n == (int)(float)n && n != Integer.MAX_VALUE; + } + @Benchmark + public void test_int_float_based_on_filtering(Blackhole bh) { + for(int n = Integer.MIN_VALUE; n < Integer.MAX_VALUE; n++) { + bh.consume(int_float_based_on_filtering(n)); + } + } + + private static boolean long_float_based_on_leading_trailing(long n) { + if (n == Long.MIN_VALUE) + return true; + n = Math.abs(n); + return Float.PRECISION >= // 24 + (64 - (Long.numberOfLeadingZeros(n) + + Long.numberOfTrailingZeros(n))) ; + } + @Benchmark + public void test_long_float_based_on_leading_trailing(Blackhole bh) { + for(int n = Integer.MIN_VALUE; n < Integer.MAX_VALUE; n++) { + bh.consume(long_float_based_on_leading_trailing(n)); + } + } + + private static boolean long_float_based_on_filtering(long n) { + return n == (long)(float)n && n != Long.MAX_VALUE; + } + @Benchmark + public void test_long_float_based_on_filtering(Blackhole bh) { + for(int n = Integer.MIN_VALUE; n < Integer.MAX_VALUE; n++) { + bh.consume(long_float_based_on_filtering(n)); + } + } + + private static boolean long_double_based_on_leading_trailing(long n) { + if (n == Long.MIN_VALUE) + return true; + n = Math.abs(n); + return Double.PRECISION >= // 53 + (64 - (Long.numberOfLeadingZeros(n) + + Long.numberOfTrailingZeros(n))) ; + } + @Benchmark + public void test_long_double_based_on_leading_trailing(Blackhole bh) { + for(int n = Integer.MIN_VALUE; n < Integer.MAX_VALUE; n++) { + bh.consume(long_double_based_on_leading_trailing(n)); + } + } + + private static boolean long_double_based_on_filtering(long n) { + return n == (long)(double)n && n != Long.MAX_VALUE; + } + @Benchmark + public void test_long_double_based_on_filtering(Blackhole bh) { + for(int n = Integer.MIN_VALUE; n < Integer.MAX_VALUE; n++) { + bh.consume(long_double_based_on_filtering(n)); + } + } + + private static boolean float_int_based_on_compare(float n) { + return Double.compare((double)n, (double)((int)n)) == 0; + } + @Benchmark + public void test_float_int_based_on_compare(Blackhole bh) { + float n = -Float.MAX_VALUE; + while (n <= Float.MAX_VALUE) { + bh.consume(float_int_based_on_compare(n)); + n = Math.nextUp(n); + } + } + + private static boolean isNegativeZero(float n) { + return Float.floatToRawIntBits(n) == Integer.MIN_VALUE; + } + private static boolean float_int_based_on_filtering(float n) { + return n == (float)(int)n && n != 0x1p31f && !isNegativeZero(n); + } + @Benchmark + public void test_float_int_based_on_filtering(Blackhole bh) { + float n = -Float.MAX_VALUE; + while (n <= Float.MAX_VALUE) { + bh.consume(float_int_based_on_filtering(n)); + n = Math.nextUp(n); + } + } +} diff --git a/test/micro/org/openjdk/bench/vm/compiler/FinalFieldInitialize.java b/test/micro/org/openjdk/bench/vm/compiler/FinalFieldInitialize.java new file mode 100644 index 00000000000..ee0779faecf --- /dev/null +++ b/test/micro/org/openjdk/bench/vm/compiler/FinalFieldInitialize.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2024, Alibaba Group Co., Ltd. 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.bench.vm.compiler; + +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.*; + +import java.util.concurrent.TimeUnit; +import org.openjdk.jmh.infra.Blackhole; + +/* test allocation speed of object with final field */ +@BenchmarkMode(Mode.Throughput) +@OutputTimeUnit(TimeUnit.SECONDS) +@State(Scope.Benchmark) +@Warmup(iterations = 5, time = 3, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 3, time = 3, timeUnit = TimeUnit.SECONDS) +@Fork(value = 3) +public class FinalFieldInitialize { + final static int LEN = 100_000; + Object arr[] = null; + @Setup + public void setup(){ + arr = new Object[LEN]; + } + + @Benchmark + public void testAlloc(Blackhole bh) { + for (int i=0; i